diff --git a/gradle.properties b/gradle.properties index 3ef01c00ac9..db000abde1c 100755 --- a/gradle.properties +++ b/gradle.properties @@ -93,6 +93,6 @@ usesSonarQube=true usesCrowdInTranslationManagement=true crowdInDownloadDirectory=src/main/resources/assets/minecolonies/lang -usesCrowdInUploadWithFilteredBranchesSpec=(version|release)\/.+ +usesCrowdInUploadWithFilteredBranchesSpec=(version|release)\/1\.21 additionalModsInDataGen=structurize;domum_ornamentum diff --git a/src/main/java/com/minecolonies/api/IMinecoloniesAPI.java b/src/main/java/com/minecolonies/api/IMinecoloniesAPI.java index 8c90e379254..80b9ddade15 100755 --- a/src/main/java/com/minecolonies/api/IMinecoloniesAPI.java +++ b/src/main/java/com/minecolonies/api/IMinecoloniesAPI.java @@ -22,6 +22,7 @@ import com.minecolonies.api.entity.citizen.happiness.HappinessRegistry; import com.minecolonies.api.entity.pathfinding.registry.IPathNavigateRegistry; import com.minecolonies.api.equipment.registry.EquipmentTypeEntry; +import com.minecolonies.api.eventbus.EventBus; import com.minecolonies.api.quests.registries.QuestRegistries; import com.minecolonies.api.research.IGlobalResearchTree; import com.minecolonies.api.research.ModResearchCostTypes.ResearchCostType; @@ -101,4 +102,6 @@ static IMinecoloniesAPI getInstance() void onRegistryNewRegistry(NewRegistryEvent event); IForgeRegistry getEquipmentTypeRegistry(); + + EventBus getEventBus(); } diff --git a/src/main/java/com/minecolonies/api/MinecoloniesAPIProxy.java b/src/main/java/com/minecolonies/api/MinecoloniesAPIProxy.java index 12d82f35011..18dddf94003 100755 --- a/src/main/java/com/minecolonies/api/MinecoloniesAPIProxy.java +++ b/src/main/java/com/minecolonies/api/MinecoloniesAPIProxy.java @@ -22,6 +22,7 @@ import com.minecolonies.api.entity.citizen.happiness.HappinessRegistry; import com.minecolonies.api.entity.pathfinding.registry.IPathNavigateRegistry; import com.minecolonies.api.equipment.registry.EquipmentTypeEntry; +import com.minecolonies.api.eventbus.EventBus; import com.minecolonies.api.quests.registries.QuestRegistries; import com.minecolonies.api.research.IGlobalResearchTree; import com.minecolonies.api.research.ModResearchCostTypes.ResearchCostType; @@ -32,7 +33,7 @@ public final class MinecoloniesAPIProxy implements IMinecoloniesAPI { - private static MinecoloniesAPIProxy ourInstance = new MinecoloniesAPIProxy(); + private static final MinecoloniesAPIProxy ourInstance = new MinecoloniesAPIProxy(); private IMinecoloniesAPI apiInstance; @@ -235,4 +236,10 @@ public IForgeRegistry getEquipmentTypeRegistry() { return apiInstance.getEquipmentTypeRegistry(); } + + @Override + public EventBus getEventBus() + { + return apiInstance.getEventBus(); + } } diff --git a/src/main/java/com/minecolonies/api/client/render/modeltype/ISimpleModelType.java b/src/main/java/com/minecolonies/api/client/render/modeltype/ISimpleModelType.java index d0173c4af37..5be7d9be2c5 100755 --- a/src/main/java/com/minecolonies/api/client/render/modeltype/ISimpleModelType.java +++ b/src/main/java/com/minecolonies/api/client/render/modeltype/ISimpleModelType.java @@ -51,7 +51,7 @@ default ResourceLocation getTexture(@NotNull final AbstractEntityCitizen entityC { if (cachedHalloweenStyle == null) { - if (MineColonies.getConfig().getServer().holidayFeatures.get() && + if (MineColonies.getConfig().getClient().holidayFeatures.get() && ((LocalDateTime.now().getDayOfMonth() >= 29 && LocalDateTime.now().getMonth() == Month.OCTOBER) || (LocalDateTime.now().getDayOfMonth() <= 2 && LocalDateTime.now().getMonth() == Month.NOVEMBER))) { diff --git a/src/main/java/com/minecolonies/api/colony/buildings/event/BuildingConstructionEvent.java b/src/main/java/com/minecolonies/api/colony/buildings/event/BuildingConstructionEvent.java deleted file mode 100644 index f470839e587..00000000000 --- a/src/main/java/com/minecolonies/api/colony/buildings/event/BuildingConstructionEvent.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.minecolonies.api.colony.buildings.event; - -import com.minecolonies.api.colony.buildings.IBuilding; -import com.minecolonies.api.colony.workorders.WorkOrderType; - -/** - * Event for when a building was built/repaired/removed. - */ -public final class BuildingConstructionEvent extends AbstractBuildingEvent -{ - /** - * What happened to the building. - */ - private final EventType eventType; - - /** - * Building construction event. - * - * @param building the building the event was for. - * @param eventType what happened to the building. - */ - public BuildingConstructionEvent(final IBuilding building, final EventType eventType) - { - super(building); - this.eventType = eventType; - } - - /** - * Get what happened to the building. - * - * @return the event type. - */ - public EventType getEventType() - { - return eventType; - } - - /** - * What happened to the building. - */ - public enum EventType - { - BUILT, - UPGRADED, - REPAIRED, - REMOVED; - - /** - * Obtain the construction event type from the work order type. - * - * @param workOrderType the work order type. - * @return the construction event type. - */ - public static EventType fromWorkOrderType(final WorkOrderType workOrderType) - { - return switch (workOrderType) - { - case BUILD -> BUILT; - case UPGRADE -> UPGRADED; - case REPAIR -> REPAIRED; - case REMOVE -> REMOVED; - }; - } - } -} diff --git a/src/main/java/com/minecolonies/api/colony/event/ColonyInformationChangedEvent.java b/src/main/java/com/minecolonies/api/colony/event/ColonyInformationChangedEvent.java deleted file mode 100644 index 69e62fdb966..00000000000 --- a/src/main/java/com/minecolonies/api/colony/event/ColonyInformationChangedEvent.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.minecolonies.api.colony.event; - -import com.minecolonies.api.colony.IColony; -import org.jetbrains.annotations.NotNull; - -/** - * Colony information changed event. - */ -public class ColonyInformationChangedEvent extends AbstractColonyEvent -{ - /** - * What type of information changed on the colony. - */ - private final Type type; - - /** - * Constructs a colony information changed event. - * - * @param colony the colony related to the event. - * @param type what type of information changed on the colony. - */ - public ColonyInformationChangedEvent(final @NotNull IColony colony, final Type type) - { - super(colony); - this.type = type; - } - - /** - * Get what type of information changed on the colony. - * - * @return the enum value. - */ - public Type getType() - { - return type; - } - - /** - * What information of the colony changed. - */ - public enum Type - { - NAME, - TEAM_COLOR, - FLAG - } -} diff --git a/src/main/java/com/minecolonies/api/configuration/ClientConfiguration.java b/src/main/java/com/minecolonies/api/configuration/ClientConfiguration.java index fb74e377d05..2442b502161 100755 --- a/src/main/java/com/minecolonies/api/configuration/ClientConfiguration.java +++ b/src/main/java/com/minecolonies/api/configuration/ClientConfiguration.java @@ -12,6 +12,7 @@ public class ClientConfiguration extends AbstractConfiguration public final ForgeConfigSpec.IntValue neighborbuildingrange; public final ForgeConfigSpec.IntValue buildgogglerange; public final ForgeConfigSpec.BooleanValue colonyteamborders; + public final ForgeConfigSpec.BooleanValue holidayFeatures; /** * Builds client configuration. @@ -26,6 +27,7 @@ protected ClientConfiguration(final ForgeConfigSpec.Builder builder) neighborbuildingrange = defineInteger(builder, "neighborbuildingrange", 4, -2, 16); buildgogglerange = defineInteger(builder, "buildgogglerange", 50, 1, 250); colonyteamborders = defineBoolean(builder, "colonyteamborders", true); + holidayFeatures = defineBoolean(builder, "holidayfeatures", true); swapToCategory(builder, "pathfinding"); diff --git a/src/main/java/com/minecolonies/api/configuration/ServerConfiguration.java b/src/main/java/com/minecolonies/api/configuration/ServerConfiguration.java index 3d33f5ee439..96e367723c0 100755 --- a/src/main/java/com/minecolonies/api/configuration/ServerConfiguration.java +++ b/src/main/java/com/minecolonies/api/configuration/ServerConfiguration.java @@ -26,7 +26,6 @@ public class ServerConfiguration extends AbstractConfiguration public final ForgeConfigSpec.BooleanValue enableInDevelopmentFeatures; public final ForgeConfigSpec.BooleanValue alwaysRenderNameTag; public final ForgeConfigSpec.BooleanValue workersAlwaysWorkInRain; - public final ForgeConfigSpec.BooleanValue holidayFeatures; public final ForgeConfigSpec.IntValue luckyBlockChance; public final ForgeConfigSpec.IntValue minThLevelToTeleport; public final ForgeConfigSpec.DoubleValue foodModifier; @@ -132,7 +131,6 @@ protected ServerConfiguration(final ForgeConfigSpec.Builder builder) enableInDevelopmentFeatures = defineBoolean(builder, "enableindevelopmentfeatures", false); alwaysRenderNameTag = defineBoolean(builder, "alwaysrendernametag", true); workersAlwaysWorkInRain = defineBoolean(builder, "workersalwaysworkinrain", false); - holidayFeatures = defineBoolean(builder, "holidayfeatures", true); luckyBlockChance = defineInteger(builder, "luckyblockchance", 1, 0, 100); minThLevelToTeleport = defineInteger(builder, "minthleveltoteleport", 3, 0, 5); foodModifier = defineDouble(builder, "foodmodifier", 1.0, 0.1, 100); diff --git a/src/main/java/com/minecolonies/api/entity/mobs/AbstractEntityMinecoloniesMonster.java b/src/main/java/com/minecolonies/api/entity/mobs/AbstractEntityMinecoloniesMonster.java index 26b80dfcf8c..146189ccc2b 100644 --- a/src/main/java/com/minecolonies/api/entity/mobs/AbstractEntityMinecoloniesMonster.java +++ b/src/main/java/com/minecolonies/api/entity/mobs/AbstractEntityMinecoloniesMonster.java @@ -20,7 +20,6 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvent; -import net.minecraft.util.Tuple; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.damagesource.DamageTypes; import net.minecraft.world.entity.*; @@ -178,15 +177,12 @@ public AbstractAdvancedPathNavigate getNavigation() this.navigation = newNavigator; this.newNavigator.setCanFloat(true); newNavigator.setSwimSpeedFactor(getSwimSpeedFactor()); - this.newNavigator.getPathingOptions().setEnterDoors(true); + newNavigator.getPathingOptions().setEnterDoors(true); + newNavigator.getPathingOptions().setCanOpenDoors(true); newNavigator.getPathingOptions().withDropCost(1D); newNavigator.getPathingOptions().withJumpCost(1D); newNavigator.getPathingOptions().setPassDanger(true); - PathingStuckHandler stuckHandler = PathingStuckHandler.createStuckHandler() - .withTakeDamageOnStuck(0.4f) - .withBuildLeafBridges() - .withChanceToByPassMovingAway(0.20) - .withPlaceLadders(); + PathingStuckHandler stuckHandler = PathingStuckHandler.createStuckHandler(); if (MinecoloniesAPIProxy.getInstance().getConfig().getServer().raidersbreakblocks.get()) { diff --git a/src/main/java/com/minecolonies/api/entity/mobs/AbstractEntityMinecoloniesRaider.java b/src/main/java/com/minecolonies/api/entity/mobs/AbstractEntityMinecoloniesRaider.java index 8b50e8825b4..a4ccb91ecf4 100644 --- a/src/main/java/com/minecolonies/api/entity/mobs/AbstractEntityMinecoloniesRaider.java +++ b/src/main/java/com/minecolonies/api/entity/mobs/AbstractEntityMinecoloniesRaider.java @@ -9,10 +9,12 @@ import com.minecolonies.api.enchants.ModEnchants; import com.minecolonies.api.entity.CustomGoalSelector; import com.minecolonies.api.entity.ai.combat.threat.IThreatTableEntity; +import com.minecolonies.api.entity.pathfinding.registry.IPathNavigateRegistry; import com.minecolonies.api.items.IChiefSwordItem; import com.minecolonies.api.util.ColonyUtils; import com.minecolonies.api.util.DamageSourceKeys; import com.minecolonies.core.entity.pathfinding.navigation.AbstractAdvancedPathNavigate; +import com.minecolonies.core.entity.pathfinding.navigation.PathingStuckHandler; import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.DifficultyInstance; @@ -171,6 +173,37 @@ public AbstractEntityMinecoloniesRaider(final EntityType, List>> eventHandlersPerType = new HashMap<>(); + + @Override + public void subscribe(final @NotNull Class eventType, final @NotNull EventHandler handler) + { + Log.getLogger().debug("Registering event handler for id {}.", eventType.getSimpleName()); + + eventHandlersPerType.computeIfAbsent(eventType, (f) -> new ArrayList<>()).add(handler); + } + + @Override + public void post(final @NotNull IModEvent event) + { + final List> eventHandlers = eventHandlersPerType.get(event.getClass()); + if (eventHandlers == null) + { + return; + } + + Log.getLogger().debug("Sending event '{}' for type '{}'. Sending to {} handlers.", event.getEventId(), event.getClass().getSimpleName(), eventHandlers.size()); + + for (final EventHandler handler : eventHandlers) + { + try + { + ((EventHandler) handler).apply(event); + } + catch (Exception ex) + { + Log.getLogger().warn("Sending event '{}' for type '{}'. Error occurred in handler:", event.getEventId(), event.getClass().getSimpleName(), ex); + } + } + } +} diff --git a/src/main/java/com/minecolonies/api/eventbus/EventBus.java b/src/main/java/com/minecolonies/api/eventbus/EventBus.java new file mode 100644 index 00000000000..bf899439f40 --- /dev/null +++ b/src/main/java/com/minecolonies/api/eventbus/EventBus.java @@ -0,0 +1,36 @@ +package com.minecolonies.api.eventbus; + +import org.jetbrains.annotations.NotNull; + +/** + * Interface for the mod event bus. + */ +public interface EventBus +{ + /** + * Subscribe to the given event type, providing a handler function. + * + * @param eventType the event class type. + * @param handler the handler function handling the event logic. + * @param the generic type of the event class. + */ + void subscribe(final @NotNull Class eventType, final @NotNull EventHandler handler); + + /** + * Posts a new event on the event bus for the given type. + * + * @param event the event to send. + */ + void post(final @NotNull IModEvent event); + + /** + * The event handler lambda definition. + * + * @param the generic type of the event class. + */ + @FunctionalInterface + interface EventHandler + { + void apply(final @NotNull T event); + } +} diff --git a/src/main/java/com/minecolonies/api/eventbus/IModEvent.java b/src/main/java/com/minecolonies/api/eventbus/IModEvent.java new file mode 100644 index 00000000000..619d7afa4a7 --- /dev/null +++ b/src/main/java/com/minecolonies/api/eventbus/IModEvent.java @@ -0,0 +1,16 @@ +package com.minecolonies.api.eventbus; + +import java.util.UUID; + +/** + * Default event interface. + */ +public interface IModEvent +{ + /** + * The unique id for this event. + * + * @return the event id. + */ + UUID getEventId(); +} diff --git a/src/main/java/com/minecolonies/api/eventbus/events/AbstractModEvent.java b/src/main/java/com/minecolonies/api/eventbus/events/AbstractModEvent.java new file mode 100644 index 00000000000..d4f88210bf4 --- /dev/null +++ b/src/main/java/com/minecolonies/api/eventbus/events/AbstractModEvent.java @@ -0,0 +1,30 @@ +package com.minecolonies.api.eventbus.events; + +import com.minecolonies.api.eventbus.IModEvent; + +import java.util.UUID; + +/** + * Abstract implementation for this mod bus events. + */ +public class AbstractModEvent implements IModEvent +{ + /** + * The unique id for this event. + */ + private final UUID eventId; + + /** + * Default constructor. + */ + protected AbstractModEvent() + { + this.eventId = UUID.randomUUID(); + } + + @Override + public UUID getEventId() + { + return eventId; + } +} diff --git a/src/main/java/com/minecolonies/api/colony/managers/events/ColonyManagerLoadedEvent.java b/src/main/java/com/minecolonies/api/eventbus/events/ColonyManagerLoadedModEvent.java similarity index 63% rename from src/main/java/com/minecolonies/api/colony/managers/events/ColonyManagerLoadedEvent.java rename to src/main/java/com/minecolonies/api/eventbus/events/ColonyManagerLoadedModEvent.java index a3d7a78881a..6a45bfce5e4 100644 --- a/src/main/java/com/minecolonies/api/colony/managers/events/ColonyManagerLoadedEvent.java +++ b/src/main/java/com/minecolonies/api/eventbus/events/ColonyManagerLoadedModEvent.java @@ -1,13 +1,12 @@ -package com.minecolonies.api.colony.managers.events; +package com.minecolonies.api.eventbus.events; import com.minecolonies.api.colony.IColonyManager; -import net.minecraftforge.eventbus.api.Event; import org.jetbrains.annotations.NotNull; /** * Colony manager loaded event. */ -public final class ColonyManagerLoadedEvent extends Event +public final class ColonyManagerLoadedModEvent extends AbstractModEvent { /** * The colony manager instance. @@ -18,7 +17,7 @@ public final class ColonyManagerLoadedEvent extends Event /** * Event for colony manager loaded. */ - public ColonyManagerLoadedEvent(final @NotNull IColonyManager colonyManager) + public ColonyManagerLoadedModEvent(final @NotNull IColonyManager colonyManager) { this.colonyManager = colonyManager; } @@ -28,7 +27,8 @@ public ColonyManagerLoadedEvent(final @NotNull IColonyManager colonyManager) * * @return the colony manager. */ - public @NotNull IColonyManager getColonyManager() + @NotNull + public IColonyManager getColonyManager() { return colonyManager; } diff --git a/src/main/java/com/minecolonies/api/colony/managers/events/ColonyManagerUnloadedEvent.java b/src/main/java/com/minecolonies/api/eventbus/events/ColonyManagerUnloadedModEvent.java similarity index 63% rename from src/main/java/com/minecolonies/api/colony/managers/events/ColonyManagerUnloadedEvent.java rename to src/main/java/com/minecolonies/api/eventbus/events/ColonyManagerUnloadedModEvent.java index 980b9719932..7443b63d1fd 100644 --- a/src/main/java/com/minecolonies/api/colony/managers/events/ColonyManagerUnloadedEvent.java +++ b/src/main/java/com/minecolonies/api/eventbus/events/ColonyManagerUnloadedModEvent.java @@ -1,13 +1,12 @@ -package com.minecolonies.api.colony.managers.events; +package com.minecolonies.api.eventbus.events; import com.minecolonies.api.colony.IColonyManager; -import net.minecraftforge.eventbus.api.Event; import org.jetbrains.annotations.NotNull; /** * Colony manager unloaded event. */ -public class ColonyManagerUnloadedEvent extends Event +public final class ColonyManagerUnloadedModEvent extends AbstractModEvent { /** * The colony manager instance. @@ -18,7 +17,7 @@ public class ColonyManagerUnloadedEvent extends Event /** * Event for colony manager loaded. */ - public ColonyManagerUnloadedEvent(final @NotNull IColonyManager colonyManager) + public ColonyManagerUnloadedModEvent(final @NotNull IColonyManager colonyManager) { this.colonyManager = colonyManager; } @@ -28,7 +27,8 @@ public ColonyManagerUnloadedEvent(final @NotNull IColonyManager colonyManager) * * @return the colony manager. */ - public @NotNull IColonyManager getColonyManager() + @NotNull + public IColonyManager getColonyManager() { return colonyManager; } diff --git a/src/main/java/com/minecolonies/core/colony/crafting/CustomRecipesReloadedEvent.java b/src/main/java/com/minecolonies/api/eventbus/events/CustomRecipesReloadedEvent.java similarity index 63% rename from src/main/java/com/minecolonies/core/colony/crafting/CustomRecipesReloadedEvent.java rename to src/main/java/com/minecolonies/api/eventbus/events/CustomRecipesReloadedEvent.java index f1397c855cb..57d80030fae 100644 --- a/src/main/java/com/minecolonies/core/colony/crafting/CustomRecipesReloadedEvent.java +++ b/src/main/java/com/minecolonies/api/eventbus/events/CustomRecipesReloadedEvent.java @@ -1,10 +1,10 @@ -package com.minecolonies.core.colony.crafting; +package com.minecolonies.api.eventbus.events; import net.minecraftforge.eventbus.api.Event; /** * This event is fired on the client side whenever the CustomRecipeManager has been - * populated. This occurs once on world load/connect and again whenever datapacks are reloaded. + * populated. This occurs once on world load/connect and again whenever data-packs are reloaded. */ public class CustomRecipesReloadedEvent extends Event { diff --git a/src/main/java/com/minecolonies/api/colony/event/AbstractColonyEvent.java b/src/main/java/com/minecolonies/api/eventbus/events/colony/AbstractColonyModEvent.java similarity index 56% rename from src/main/java/com/minecolonies/api/colony/event/AbstractColonyEvent.java rename to src/main/java/com/minecolonies/api/eventbus/events/colony/AbstractColonyModEvent.java index 4e672d2faa2..3e60277cb26 100644 --- a/src/main/java/com/minecolonies/api/colony/event/AbstractColonyEvent.java +++ b/src/main/java/com/minecolonies/api/eventbus/events/colony/AbstractColonyModEvent.java @@ -1,37 +1,36 @@ -package com.minecolonies.api.colony.event; - -import com.minecolonies.api.colony.IColony; -import net.minecraftforge.eventbus.api.Event; -import org.jetbrains.annotations.NotNull; - -/** - * This is a colony-related event in the Forge sense, not in the - * {@link com.minecolonies.api.colony.colonyEvents.IColonyEvent} sense. - */ -public abstract class AbstractColonyEvent extends Event -{ - /** - * The colony this event was called in. - */ - @NotNull - private final IColony colony; - - /** - * Constructs a colony-based event. - * - * @param colony The colony related to the event. - */ - protected AbstractColonyEvent(@NotNull final IColony colony) - { - this.colony = colony; - } - - /** - * Gets the colony related to the event. - */ - @NotNull - public IColony getColony() - { - return colony; - } -} +package com.minecolonies.api.eventbus.events.colony; + +import com.minecolonies.api.colony.IColony; +import com.minecolonies.api.eventbus.events.AbstractModEvent; +import org.jetbrains.annotations.NotNull; + +/** + * Any colony related event, provides the target colony the event occurred in. + */ +public abstract class AbstractColonyModEvent extends AbstractModEvent +{ + /** + * The colony this event was called in. + */ + @NotNull + private final IColony colony; + + /** + * Constructs a colony-based event. + * + * @param colony The colony related to the event. + */ + protected AbstractColonyModEvent(@NotNull final IColony colony) + { + this.colony = colony; + } + + /** + * Gets the colony related to the event. + */ + @NotNull + public IColony getColony() + { + return colony; + } +} diff --git a/src/main/java/com/minecolonies/api/colony/event/ColonyCreatedEvent.java b/src/main/java/com/minecolonies/api/eventbus/events/colony/ColonyCreatedModEvent.java similarity index 59% rename from src/main/java/com/minecolonies/api/colony/event/ColonyCreatedEvent.java rename to src/main/java/com/minecolonies/api/eventbus/events/colony/ColonyCreatedModEvent.java index 8b0e1d66fef..8fb54bdc6e7 100644 --- a/src/main/java/com/minecolonies/api/colony/event/ColonyCreatedEvent.java +++ b/src/main/java/com/minecolonies/api/eventbus/events/colony/ColonyCreatedModEvent.java @@ -1,4 +1,4 @@ -package com.minecolonies.api.colony.event; +package com.minecolonies.api.eventbus.events.colony; import com.minecolonies.api.colony.IColony; import org.jetbrains.annotations.NotNull; @@ -6,14 +6,14 @@ /** * Colony created event. */ -public class ColonyCreatedEvent extends AbstractColonyEvent +public final class ColonyCreatedModEvent extends AbstractColonyModEvent { /** * Constructs a colony created event. * * @param colony The colony related to the event. */ - public ColonyCreatedEvent(final @NotNull IColony colony) + public ColonyCreatedModEvent(final @NotNull IColony colony) { super(colony); } diff --git a/src/main/java/com/minecolonies/api/colony/event/ColonyDeletedEvent.java b/src/main/java/com/minecolonies/api/eventbus/events/colony/ColonyDeletedModEvent.java similarity index 59% rename from src/main/java/com/minecolonies/api/colony/event/ColonyDeletedEvent.java rename to src/main/java/com/minecolonies/api/eventbus/events/colony/ColonyDeletedModEvent.java index cb08a6daecc..ef0bb7e0089 100644 --- a/src/main/java/com/minecolonies/api/colony/event/ColonyDeletedEvent.java +++ b/src/main/java/com/minecolonies/api/eventbus/events/colony/ColonyDeletedModEvent.java @@ -1,4 +1,4 @@ -package com.minecolonies.api.colony.event; +package com.minecolonies.api.eventbus.events.colony; import com.minecolonies.api.colony.IColony; import org.jetbrains.annotations.NotNull; @@ -6,14 +6,14 @@ /** * Colony deleted event. */ -public class ColonyDeletedEvent extends AbstractColonyEvent +public final class ColonyDeletedModEvent extends AbstractColonyModEvent { /** * Constructs a colony deleted event. * * @param colony The colony related to the event. */ - public ColonyDeletedEvent(final @NotNull IColony colony) + public ColonyDeletedModEvent(final @NotNull IColony colony) { super(colony); } diff --git a/src/main/java/com/minecolonies/api/eventbus/events/colony/ColonyFlagChangedModEvent.java b/src/main/java/com/minecolonies/api/eventbus/events/colony/ColonyFlagChangedModEvent.java new file mode 100644 index 00000000000..a6a6ec1a67d --- /dev/null +++ b/src/main/java/com/minecolonies/api/eventbus/events/colony/ColonyFlagChangedModEvent.java @@ -0,0 +1,20 @@ +package com.minecolonies.api.eventbus.events.colony; + +import com.minecolonies.api.colony.IColony; +import org.jetbrains.annotations.NotNull; + +/** + * Colony flag changed event. + */ +public final class ColonyFlagChangedModEvent extends AbstractColonyModEvent +{ + /** + * Constructs a colony flag changed event. + * + * @param colony the colony related to the event. + */ + public ColonyFlagChangedModEvent(final @NotNull IColony colony) + { + super(colony); + } +} diff --git a/src/main/java/com/minecolonies/api/eventbus/events/colony/ColonyNameChangedModEvent.java b/src/main/java/com/minecolonies/api/eventbus/events/colony/ColonyNameChangedModEvent.java new file mode 100644 index 00000000000..b457042535b --- /dev/null +++ b/src/main/java/com/minecolonies/api/eventbus/events/colony/ColonyNameChangedModEvent.java @@ -0,0 +1,20 @@ +package com.minecolonies.api.eventbus.events.colony; + +import com.minecolonies.api.colony.IColony; +import org.jetbrains.annotations.NotNull; + +/** + * Colony name changed event. + */ +public final class ColonyNameChangedModEvent extends AbstractColonyModEvent +{ + /** + * Constructs a colony name changed event. + * + * @param colony the colony related to the event. + */ + public ColonyNameChangedModEvent(final @NotNull IColony colony) + { + super(colony); + } +} diff --git a/src/main/java/com/minecolonies/api/eventbus/events/colony/ColonyTeamColorChangedModEvent.java b/src/main/java/com/minecolonies/api/eventbus/events/colony/ColonyTeamColorChangedModEvent.java new file mode 100644 index 00000000000..00fb7ac90f7 --- /dev/null +++ b/src/main/java/com/minecolonies/api/eventbus/events/colony/ColonyTeamColorChangedModEvent.java @@ -0,0 +1,20 @@ +package com.minecolonies.api.eventbus.events.colony; + +import com.minecolonies.api.colony.IColony; +import org.jetbrains.annotations.NotNull; + +/** + * Colony team changed event. + */ +public final class ColonyTeamColorChangedModEvent extends AbstractColonyModEvent +{ + /** + * Constructs a colony team changed event. + * + * @param colony the colony related to the event. + */ + public ColonyTeamColorChangedModEvent(final @NotNull IColony colony) + { + super(colony); + } +} diff --git a/src/main/java/com/minecolonies/api/colony/event/ColonyViewUpdatedEvent.java b/src/main/java/com/minecolonies/api/eventbus/events/colony/ColonyViewUpdatedModEvent.java similarity index 69% rename from src/main/java/com/minecolonies/api/colony/event/ColonyViewUpdatedEvent.java rename to src/main/java/com/minecolonies/api/eventbus/events/colony/ColonyViewUpdatedModEvent.java index 23e7a3f0151..77d5bed15ce 100644 --- a/src/main/java/com/minecolonies/api/colony/event/ColonyViewUpdatedEvent.java +++ b/src/main/java/com/minecolonies/api/eventbus/events/colony/ColonyViewUpdatedModEvent.java @@ -1,26 +1,26 @@ -package com.minecolonies.api.colony.event; - -import com.minecolonies.api.colony.IColonyView; -import org.jetbrains.annotations.NotNull; - -/** - * This event is raised client-side whenever a particular colony's data is refreshed. - */ -public class ColonyViewUpdatedEvent extends AbstractColonyEvent -{ - /** - * Constructs a new event. - * - * @param colony The colony (view) that was just updated. - */ - public ColonyViewUpdatedEvent(final @NotNull IColonyView colony) - { - super(colony); - } - - @Override - public @NotNull IColonyView getColony() - { - return (IColonyView) super.getColony(); - } -} +package com.minecolonies.api.eventbus.events.colony; + +import com.minecolonies.api.colony.IColonyView; +import org.jetbrains.annotations.NotNull; + +/** + * This event is raised client-side whenever a particular colony's data is refreshed. + */ +public final class ColonyViewUpdatedModEvent extends AbstractColonyModEvent +{ + /** + * Constructs a new event. + * + * @param colony The colony (view) that was just updated. + */ + public ColonyViewUpdatedModEvent(final @NotNull IColonyView colony) + { + super(colony); + } + + @Override + public @NotNull IColonyView getColony() + { + return (IColonyView) super.getColony(); + } +} diff --git a/src/main/java/com/minecolonies/api/colony/buildings/event/AbstractBuildingEvent.java b/src/main/java/com/minecolonies/api/eventbus/events/colony/buildings/AbstractBuildingModEvent.java similarity index 68% rename from src/main/java/com/minecolonies/api/colony/buildings/event/AbstractBuildingEvent.java rename to src/main/java/com/minecolonies/api/eventbus/events/colony/buildings/AbstractBuildingModEvent.java index f5759a3399f..dd0a737e6df 100644 --- a/src/main/java/com/minecolonies/api/colony/buildings/event/AbstractBuildingEvent.java +++ b/src/main/java/com/minecolonies/api/eventbus/events/colony/buildings/AbstractBuildingModEvent.java @@ -1,12 +1,12 @@ -package com.minecolonies.api.colony.buildings.event; +package com.minecolonies.api.eventbus.events.colony.buildings; import com.minecolonies.api.colony.buildings.IBuilding; -import com.minecolonies.api.colony.event.AbstractColonyEvent; +import com.minecolonies.api.eventbus.events.colony.AbstractColonyModEvent; /** * Abstract event for building related things. */ -public abstract class AbstractBuildingEvent extends AbstractColonyEvent +public abstract class AbstractBuildingModEvent extends AbstractColonyModEvent { /** * The building related to the event. @@ -18,7 +18,7 @@ public abstract class AbstractBuildingEvent extends AbstractColonyEvent * * @param building the building related to the event. */ - protected AbstractBuildingEvent(final IBuilding building) + protected AbstractBuildingModEvent(final IBuilding building) { super(building.getColony()); this.building = building; diff --git a/src/main/java/com/minecolonies/api/eventbus/events/colony/buildings/BuildingConstructionModEvent.java b/src/main/java/com/minecolonies/api/eventbus/events/colony/buildings/BuildingConstructionModEvent.java new file mode 100644 index 00000000000..87e133bdf15 --- /dev/null +++ b/src/main/java/com/minecolonies/api/eventbus/events/colony/buildings/BuildingConstructionModEvent.java @@ -0,0 +1,37 @@ +package com.minecolonies.api.eventbus.events.colony.buildings; + +import com.minecolonies.api.colony.buildings.IBuilding; +import com.minecolonies.core.colony.workorders.WorkOrderBuilding; + +/** + * Event for when a building was built, upgraded, repaired or removed. + */ +public final class BuildingConstructionModEvent extends AbstractBuildingModEvent +{ + /** + * The work order which was completed. + */ + private final WorkOrderBuilding workOrder; + + /** + * Building construction event. + * + * @param building the building the event was for. + * @param workOrder the work order which was completed. + */ + public BuildingConstructionModEvent(final IBuilding building, final WorkOrderBuilding workOrder) + { + super(building); + this.workOrder = workOrder; + } + + /** + * Get the work order which was completed. + * + * @return the event type. + */ + public WorkOrderBuilding getWorkOrder() + { + return workOrder; + } +} diff --git a/src/main/java/com/minecolonies/api/colony/citizens/event/AbstractCitizenEvent.java b/src/main/java/com/minecolonies/api/eventbus/events/colony/citizens/AbstractCitizenModEvent.java similarity index 71% rename from src/main/java/com/minecolonies/api/colony/citizens/event/AbstractCitizenEvent.java rename to src/main/java/com/minecolonies/api/eventbus/events/colony/citizens/AbstractCitizenModEvent.java index 05942def618..eca9aa3123d 100644 --- a/src/main/java/com/minecolonies/api/colony/citizens/event/AbstractCitizenEvent.java +++ b/src/main/java/com/minecolonies/api/eventbus/events/colony/citizens/AbstractCitizenModEvent.java @@ -1,14 +1,14 @@ -package com.minecolonies.api.colony.citizens.event; +package com.minecolonies.api.eventbus.events.colony.citizens; import com.minecolonies.api.colony.ICitizen; import com.minecolonies.api.colony.ICitizenData; -import com.minecolonies.api.colony.event.AbstractColonyEvent; +import com.minecolonies.api.eventbus.events.colony.AbstractColonyModEvent; import org.jetbrains.annotations.NotNull; /** * Abstract event for citizen related things. */ -public class AbstractCitizenEvent extends AbstractColonyEvent +public class AbstractCitizenModEvent extends AbstractColonyModEvent { /** * The citizen related to the event. @@ -20,7 +20,7 @@ public class AbstractCitizenEvent extends AbstractColonyEvent * * @param citizen the citizen related to the event. */ - protected AbstractCitizenEvent(final @NotNull ICitizenData citizen) + protected AbstractCitizenModEvent(final @NotNull ICitizenData citizen) { super(citizen.getColony()); this.citizen = citizen; diff --git a/src/main/java/com/minecolonies/api/colony/citizens/event/CitizenAddedEvent.java b/src/main/java/com/minecolonies/api/eventbus/events/colony/citizens/CitizenAddedModEvent.java similarity index 77% rename from src/main/java/com/minecolonies/api/colony/citizens/event/CitizenAddedEvent.java rename to src/main/java/com/minecolonies/api/eventbus/events/colony/citizens/CitizenAddedModEvent.java index c2baf35e0d0..559e5ec8f27 100644 --- a/src/main/java/com/minecolonies/api/colony/citizens/event/CitizenAddedEvent.java +++ b/src/main/java/com/minecolonies/api/eventbus/events/colony/citizens/CitizenAddedModEvent.java @@ -1,16 +1,16 @@ -package com.minecolonies.api.colony.citizens.event; +package com.minecolonies.api.eventbus.events.colony.citizens; import com.minecolonies.api.colony.ICitizenData; /** * Event for when a citizen was added to the colony. */ -public class CitizenAddedEvent extends AbstractCitizenEvent +public final class CitizenAddedModEvent extends AbstractCitizenModEvent { /** * The way the citizen came into the colony. */ - private final Source source; + private final CitizenAddedSource source; /** * Citizen added event. @@ -18,7 +18,7 @@ public class CitizenAddedEvent extends AbstractCitizenEvent * @param citizen the citizen related to the event. * @param source the way the citizen came into the colony. */ - public CitizenAddedEvent(final ICitizenData citizen, final Source source) + public CitizenAddedModEvent(final ICitizenData citizen, final CitizenAddedSource source) { super(citizen); this.source = source; @@ -29,7 +29,7 @@ public CitizenAddedEvent(final ICitizenData citizen, final Source source) * * @return the enum value. */ - public Source getSource() + public CitizenAddedSource getSource() { return source; } @@ -37,7 +37,7 @@ public Source getSource() /** * How the citizen came into the colony. */ - public enum Source + public enum CitizenAddedSource { /** * The citizen spawned as part of the {@link com.minecolonies.api.configuration.ServerConfiguration#initialCitizenAmount}. diff --git a/src/main/java/com/minecolonies/api/colony/citizens/event/CitizenRemovedEvent.java b/src/main/java/com/minecolonies/api/eventbus/events/colony/citizens/CitizenDiedModEvent.java similarity index 66% rename from src/main/java/com/minecolonies/api/colony/citizens/event/CitizenRemovedEvent.java rename to src/main/java/com/minecolonies/api/eventbus/events/colony/citizens/CitizenDiedModEvent.java index 779372a5be6..c5b9366a573 100644 --- a/src/main/java/com/minecolonies/api/colony/citizens/event/CitizenRemovedEvent.java +++ b/src/main/java/com/minecolonies/api/eventbus/events/colony/citizens/CitizenDiedModEvent.java @@ -1,13 +1,13 @@ -package com.minecolonies.api.colony.citizens.event; +package com.minecolonies.api.eventbus.events.colony.citizens; import com.minecolonies.api.colony.ICitizenData; import net.minecraft.world.damagesource.DamageSource; import org.jetbrains.annotations.NotNull; /** - * Event for when a citizen was removed from the colony. + * Event for when a citizen died in any colony. */ -public class CitizenRemovedEvent extends AbstractCitizenEvent +public final class CitizenDiedModEvent extends AbstractCitizenModEvent { /** * The damage source that caused a citizen to die. @@ -15,12 +15,12 @@ public class CitizenRemovedEvent extends AbstractCitizenEvent private final @NotNull DamageSource source; /** - * Citizen removed event. + * Citizen died event. * * @param citizen the citizen related to the event. - * @param source the way the citizen went out of the colony. + * @param source the damage source the citizen died from. */ - public CitizenRemovedEvent(final @NotNull ICitizenData citizen, final @NotNull DamageSource source) + public CitizenDiedModEvent(final @NotNull ICitizenData citizen, final @NotNull DamageSource source) { super(citizen); this.source = source; diff --git a/src/main/java/com/minecolonies/api/eventbus/events/colony/citizens/CitizenRemovedModEvent.java b/src/main/java/com/minecolonies/api/eventbus/events/colony/citizens/CitizenRemovedModEvent.java new file mode 100644 index 00000000000..859bd3a0b34 --- /dev/null +++ b/src/main/java/com/minecolonies/api/eventbus/events/colony/citizens/CitizenRemovedModEvent.java @@ -0,0 +1,39 @@ +package com.minecolonies.api.eventbus.events.colony.citizens; + +import com.minecolonies.api.colony.ICitizenData; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +/** + * Event for when a citizen was removed from the colony. + */ +public final class CitizenRemovedModEvent extends AbstractCitizenModEvent +{ + /** + * The damage source that caused a citizen to die. + */ + private final @NotNull Entity.RemovalReason reason; + + /** + * Citizen removed event. + * + * @param citizen the citizen related to the event. + * @param reason the reason the citizen was removed. + */ + public CitizenRemovedModEvent(final @NotNull ICitizenData citizen, final @NotNull Entity.RemovalReason reason) + { + super(citizen); + this.reason = reason; + } + + /** + * The damage source that caused the citizen to die. + * + * @return the damage source. + */ + @NotNull + public Entity.RemovalReason getRemovalReason() + { + return reason; + } +} diff --git a/src/main/java/com/minecolonies/api/events/ColonyEvents.java b/src/main/java/com/minecolonies/api/events/ColonyEvents.java deleted file mode 100644 index aef3f6d7b4c..00000000000 --- a/src/main/java/com/minecolonies/api/events/ColonyEvents.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.minecolonies.api.events; - -import com.minecolonies.api.colony.IColony; -import com.minecolonies.api.colony.event.ColonyDeletedEvent; -import com.minecolonies.api.util.Log; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.eventbus.api.Event; - -/** - * Event manager for all forge events. - */ -public class ColonyEvents -{ - /** - * Event triggered when a colony is being deleted. - * - * @param colony the colony in question. - */ - public static void deleteColony(final IColony colony) - { - sendEventSafe(new ColonyDeletedEvent(colony)); - } - - /** - * Underlying logic for transmitting an event. - */ - private static void sendEventSafe(final Event event) - { - try - { - MinecraftForge.EVENT_BUS.post(event); - } - catch (final Exception e) - { - Log.getLogger().atError().withThrowable(e).log("Exception occurred during {} event", event.getClass().getName()); - } - } -} diff --git a/src/main/java/com/minecolonies/apiimp/CommonMinecoloniesAPIImpl.java b/src/main/java/com/minecolonies/apiimp/CommonMinecoloniesAPIImpl.java index 7400bf0fa5e..dd69ac6d1c9 100755 --- a/src/main/java/com/minecolonies/apiimp/CommonMinecoloniesAPIImpl.java +++ b/src/main/java/com/minecolonies/apiimp/CommonMinecoloniesAPIImpl.java @@ -24,6 +24,8 @@ import com.minecolonies.api.entity.citizen.happiness.HappinessRegistry; import com.minecolonies.api.entity.pathfinding.registry.IPathNavigateRegistry; import com.minecolonies.api.equipment.registry.EquipmentTypeEntry; +import com.minecolonies.api.eventbus.DefaultEventBus; +import com.minecolonies.api.eventbus.EventBus; import com.minecolonies.api.quests.registries.QuestRegistries; import com.minecolonies.api.research.IGlobalResearchTree; import com.minecolonies.api.research.ModResearchCostTypes.ResearchCostType; @@ -81,6 +83,8 @@ public class CommonMinecoloniesAPIImpl implements IMinecoloniesAPI private IForgeRegistry happinessFactorTypeRegistry; private IForgeRegistry happinessFunctionRegistry; + private EventBus eventBus = new DefaultEventBus(); + @Override @NotNull public IColonyManager getColonyManager() @@ -393,5 +397,11 @@ public IForgeRegistry getEquipmentTypeRegistry() { return equipmentTypeRegistry; } + + @Override + public EventBus getEventBus() + { + return eventBus; + } } diff --git a/src/main/java/com/minecolonies/core/colony/CitizenDataView.java b/src/main/java/com/minecolonies/core/colony/CitizenDataView.java index d79e3efd36f..1f39ffc3b95 100644 --- a/src/main/java/com/minecolonies/core/colony/CitizenDataView.java +++ b/src/main/java/com/minecolonies/core/colony/CitizenDataView.java @@ -632,7 +632,7 @@ public ItemStack getDisplayArmor(final EquipmentSlot equipmentSlot) { if (cachedDisplaySantaHat == null) { - if (MineColonies.getConfig().getServer().holidayFeatures.get() && LocalDate.now(Clock.systemDefaultZone()).getMonth() == Month.DECEMBER) + if (MineColonies.getConfig().getClient().holidayFeatures.get() && LocalDate.now(Clock.systemDefaultZone()).getMonth() == Month.DECEMBER) { cachedDisplaySantaHat = new ItemStack(ModItems.santaHat); } diff --git a/src/main/java/com/minecolonies/core/colony/ColonyManager.java b/src/main/java/com/minecolonies/core/colony/ColonyManager.java index b11c9cbed41..88b2d6c56b4 100755 --- a/src/main/java/com/minecolonies/core/colony/ColonyManager.java +++ b/src/main/java/com/minecolonies/core/colony/ColonyManager.java @@ -1,17 +1,18 @@ package com.minecolonies.core.colony; +import com.minecolonies.api.IMinecoloniesAPI; import com.minecolonies.api.blocks.AbstractBlockHut; import com.minecolonies.api.colony.*; import com.minecolonies.api.colony.buildings.IBuilding; import com.minecolonies.api.colony.buildings.views.IBuildingView; -import com.minecolonies.api.colony.event.ColonyViewUpdatedEvent; -import com.minecolonies.api.colony.managers.events.ColonyManagerLoadedEvent; -import com.minecolonies.api.colony.managers.events.ColonyManagerUnloadedEvent; import com.minecolonies.api.colony.permissions.ColonyPlayer; import com.minecolonies.api.compatibility.CompatibilityManager; import com.minecolonies.api.compatibility.ICompatibilityManager; import com.minecolonies.api.crafting.IRecipeManager; -import com.minecolonies.api.events.ColonyEvents; +import com.minecolonies.api.eventbus.events.ColonyManagerLoadedModEvent; +import com.minecolonies.api.eventbus.events.ColonyManagerUnloadedModEvent; +import com.minecolonies.api.eventbus.events.colony.ColonyDeletedModEvent; +import com.minecolonies.api.eventbus.events.colony.ColonyViewUpdatedModEvent; import com.minecolonies.api.sounds.SoundManager; import com.minecolonies.api.util.BlockPosUtil; import com.minecolonies.api.util.ColonyUtils; @@ -202,7 +203,7 @@ private void deleteColony(@Nullable final IColony iColony, final boolean canDest return; } - ColonyEvents.deleteColony(colony); + IMinecoloniesAPI.getInstance().getEventBus().post(new ColonyDeletedModEvent(colony)); cap.deleteColony(id); BackUpHelper.markColonyDeleted(colony.getID(), colony.getDimension()); colony.getImportantMessageEntityPlayers() @@ -645,14 +646,7 @@ public void onWorldLoad(@NotNull final Level world) c.onWorldLoad(world); } - try - { - MinecraftForge.EVENT_BUS.post(new ColonyManagerLoadedEvent(this)); - } - catch (final Exception e) - { - Log.getLogger().error("Error during ColonyManagerLoadedEvent", e); - } + IMinecoloniesAPI.getInstance().getEventBus().post(new ColonyManagerLoadedModEvent(this)); } } @@ -679,14 +673,7 @@ public void onWorldUnload(@NotNull final Level world) BackUpHelper.backupColonyData(); } - try - { - MinecraftForge.EVENT_BUS.post(new ColonyManagerUnloadedEvent(this)); - } - catch (final Exception e) - { - Log.getLogger().error("Error during ColonyManagerUnloadedEvent", e); - } + IMinecoloniesAPI.getInstance().getEventBus().post(new ColonyManagerUnloadedModEvent(this)); } } @@ -715,14 +702,7 @@ public void handleColonyViewMessage( } view.handleColonyViewMessage(colonyData, world, isNewSubscription); - try - { - MinecraftForge.EVENT_BUS.post(new ColonyViewUpdatedEvent(view)); - } - catch (final Exception e) - { - Log.getLogger().error("Error during ColonyViewUpdatedEvent", e); - } + IMinecoloniesAPI.getInstance().getEventBus().post(new ColonyViewUpdatedModEvent(view)); } @Override diff --git a/src/main/java/com/minecolonies/core/colony/crafting/CustomRecipeManager.java b/src/main/java/com/minecolonies/core/colony/crafting/CustomRecipeManager.java index 0d599b9de2c..73cf557d99a 100644 --- a/src/main/java/com/minecolonies/core/colony/crafting/CustomRecipeManager.java +++ b/src/main/java/com/minecolonies/core/colony/crafting/CustomRecipeManager.java @@ -5,6 +5,7 @@ import com.minecolonies.api.colony.buildings.modules.ICraftingBuildingModule; import com.minecolonies.api.colony.buildings.registry.BuildingEntry; import com.minecolonies.api.crafting.ItemStorage; +import com.minecolonies.api.eventbus.events.CustomRecipesReloadedEvent; import com.minecolonies.api.loot.ModLootTables; import com.minecolonies.api.util.Log; import com.minecolonies.core.Network; diff --git a/src/main/java/com/minecolonies/core/colony/interactionhandling/RecruitmentInteraction.java b/src/main/java/com/minecolonies/core/colony/interactionhandling/RecruitmentInteraction.java index cce517c02d3..696b4525557 100644 --- a/src/main/java/com/minecolonies/core/colony/interactionhandling/RecruitmentInteraction.java +++ b/src/main/java/com/minecolonies/core/colony/interactionhandling/RecruitmentInteraction.java @@ -6,13 +6,13 @@ import com.ldtteam.blockui.controls.Text; import com.ldtteam.blockui.views.BOWindow; import com.ldtteam.blockui.views.Box; +import com.minecolonies.api.IMinecoloniesAPI; import com.minecolonies.api.colony.*; -import com.minecolonies.api.colony.citizens.event.CitizenAddedEvent; import com.minecolonies.api.colony.interactionhandling.IChatPriority; import com.minecolonies.api.colony.interactionhandling.IInteractionResponseHandler; import com.minecolonies.api.colony.interactionhandling.ModInteractionResponseHandlers; +import com.minecolonies.api.eventbus.events.colony.citizens.CitizenAddedModEvent; import com.minecolonies.api.util.InventoryUtils; -import com.minecolonies.api.util.Log; import com.minecolonies.api.util.MessageUtils; import com.minecolonies.api.util.Tuple; import com.minecolonies.api.util.constant.Constants; @@ -23,7 +23,6 @@ import net.minecraft.world.item.ItemStack; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.items.wrapper.InvWrapper; import java.util.Collections; @@ -189,14 +188,9 @@ public void onServerResponseTriggered(final int responseId, final Player player, MessageUtils.format(MESSAGE_RECRUITMENT_SUCCESS, data.getName()).sendTo(colony).forAllPlayers(); } - try - { - MinecraftForge.EVENT_BUS.post(new CitizenAddedEvent(newCitizen, CitizenAddedEvent.Source.HIRED)); - } - catch (final Exception e) - { - Log.getLogger().error("Error during CitizenAddedEvent", e); - } + IMinecoloniesAPI.getInstance() + .getEventBus() + .post(new CitizenAddedModEvent(newCitizen, CitizenAddedModEvent.CitizenAddedSource.HIRED)); } } else diff --git a/src/main/java/com/minecolonies/core/colony/managers/CitizenManager.java b/src/main/java/com/minecolonies/core/colony/managers/CitizenManager.java index 0ac81368971..5ab0edfc09c 100755 --- a/src/main/java/com/minecolonies/core/colony/managers/CitizenManager.java +++ b/src/main/java/com/minecolonies/core/colony/managers/CitizenManager.java @@ -1,5 +1,6 @@ package com.minecolonies.core.colony.managers; +import com.minecolonies.api.IMinecoloniesAPI; import com.minecolonies.api.MinecoloniesAPIProxy; import com.minecolonies.api.colony.ICitizenData; import com.minecolonies.api.colony.ICitizenDataManager; @@ -7,12 +8,12 @@ import com.minecolonies.api.colony.IColony; import com.minecolonies.api.colony.buildings.HiringMode; import com.minecolonies.api.colony.buildings.IBuilding; -import com.minecolonies.api.colony.citizens.event.CitizenAddedEvent; import com.minecolonies.api.colony.managers.interfaces.ICitizenManager; import com.minecolonies.api.entity.ModEntities; import com.minecolonies.api.entity.citizen.AbstractCivilianEntity; import com.minecolonies.api.entity.citizen.AbstractEntityCitizen; import com.minecolonies.api.entity.citizen.happiness.IHappinessModifier; +import com.minecolonies.api.eventbus.events.colony.citizens.CitizenAddedModEvent; import com.minecolonies.api.util.*; import com.minecolonies.api.util.constant.CitizenConstants; import com.minecolonies.core.MineColonies; @@ -40,7 +41,6 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.Level; -import net.minecraftforge.common.MinecraftForge; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -363,14 +363,7 @@ public ICitizenData resurrectCivilianData(@NotNull final CompoundTag compoundNBT citizens.put(citizenData.getId(), citizenData); spawnOrCreateCitizen(citizenData, world, spawnPos); - try - { - MinecraftForge.EVENT_BUS.post(new CitizenAddedEvent(citizenData, CitizenAddedEvent.Source.RESURRECTED)); - } - catch (final Exception e) - { - Log.getLogger().error("Error during CitizenAddedEvent", e); - } + IMinecoloniesAPI.getInstance().getEventBus().post(new CitizenAddedModEvent(citizenData, CitizenAddedModEvent.CitizenAddedSource.RESURRECTED)); return citizenData; } @@ -628,14 +621,7 @@ else if (femaleCount < (getCitizens().size() - 1) / 2.0) spawnOrCreateCivilian(newCitizen, colony.getWorld(), null, true); - try - { - MinecraftForge.EVENT_BUS.post(new CitizenAddedEvent(newCitizen, CitizenAddedEvent.Source.INITIAL)); - } - catch (final Exception e) - { - Log.getLogger().error("Error during CitizenAddedEvent", e); - } + IMinecoloniesAPI.getInstance().getEventBus().post(new CitizenAddedModEvent(newCitizen, CitizenAddedModEvent.CitizenAddedSource.INITIAL)); colony.getEventDescriptionManager().addEventDescription(new CitizenSpawnedEvent(colony.getBuildingManager().getTownHall().getPosition(), newCitizen.getName())); } diff --git a/src/main/java/com/minecolonies/core/commands/citizencommands/CommandCitizenSpawnNew.java b/src/main/java/com/minecolonies/core/commands/citizencommands/CommandCitizenSpawnNew.java index 0e8cddcbee6..0c587343a6b 100755 --- a/src/main/java/com/minecolonies/core/commands/citizencommands/CommandCitizenSpawnNew.java +++ b/src/main/java/com/minecolonies/core/commands/citizencommands/CommandCitizenSpawnNew.java @@ -1,10 +1,10 @@ package com.minecolonies.core.commands.citizencommands; +import com.minecolonies.api.IMinecoloniesAPI; import com.minecolonies.api.colony.ICitizenData; import com.minecolonies.api.colony.IColony; import com.minecolonies.api.colony.IColonyManager; -import com.minecolonies.api.colony.citizens.event.CitizenAddedEvent; -import com.minecolonies.api.util.Log; +import com.minecolonies.api.eventbus.events.colony.citizens.CitizenAddedModEvent; import com.minecolonies.core.commands.commandTypes.IMCCommand; import com.minecolonies.core.commands.commandTypes.IMCOPCommand; import com.mojang.brigadier.arguments.IntegerArgumentType; @@ -12,7 +12,6 @@ import com.mojang.brigadier.context.CommandContext; import net.minecraft.commands.CommandSourceStack; import net.minecraft.network.chat.Component; -import net.minecraftforge.common.MinecraftForge; import static com.minecolonies.api.util.constant.translation.CommandTranslationConstants.COMMAND_CITIZEN_SPAWN_SUCCESS; import static com.minecolonies.api.util.constant.translation.CommandTranslationConstants.COMMAND_COLONY_ID_NOT_FOUND; @@ -43,14 +42,7 @@ public int onExecute(final CommandContext context) final ICitizenData newCitizen = colony.getCitizenManager().spawnOrCreateCivilian(null, colony.getWorld(), null, true); context.getSource().sendSuccess(() -> Component.translatable(COMMAND_CITIZEN_SPAWN_SUCCESS, newCitizen.getName()), true); - try - { - MinecraftForge.EVENT_BUS.post(new CitizenAddedEvent(newCitizen, CitizenAddedEvent.Source.COMMANDS)); - } - catch (final Exception e) - { - Log.getLogger().error("Error during CitizenAddedEvent", e); - } + IMinecoloniesAPI.getInstance().getEventBus().post(new CitizenAddedModEvent(newCitizen, CitizenAddedModEvent.CitizenAddedSource.COMMANDS)); return 1; } diff --git a/src/main/java/com/minecolonies/core/compatibility/jei/JobBasedRecipeCategory.java b/src/main/java/com/minecolonies/core/compatibility/jei/JobBasedRecipeCategory.java index 5f9a1af38f9..d001f34d674 100644 --- a/src/main/java/com/minecolonies/core/compatibility/jei/JobBasedRecipeCategory.java +++ b/src/main/java/com/minecolonies/core/compatibility/jei/JobBasedRecipeCategory.java @@ -1,5 +1,6 @@ package com.minecolonies.core.compatibility.jei; +import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; @@ -12,6 +13,7 @@ import com.minecolonies.api.entity.ModEntities; import com.minecolonies.api.equipment.ModEquipmentTypes; import com.minecolonies.api.equipment.registry.EquipmentTypeEntry; +import com.minecolonies.api.util.Log; import com.minecolonies.api.util.constant.Constants; import com.minecolonies.api.util.constant.TranslationConstants; import com.minecolonies.core.colony.CitizenData; @@ -48,7 +50,9 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import java.time.Duration; import java.util.*; import java.util.stream.Collectors; @@ -67,10 +71,13 @@ public abstract class JobBasedRecipeCategory implements IRecipeCategory @NotNull private final IDrawable icon; @NotNull protected final IDrawableStatic slot; @NotNull protected final IDrawableStatic chanceSlot; - @NotNull private final EntityCitizen citizen; @NotNull private final List description; @NotNull private final LoadingCache> infoBlocksCache; + private static final Cache, EntityCitizen> citizenCache = CacheBuilder.newBuilder() + .expireAfterAccess(Duration.ofMinutes(2)) + .build(); + protected static final int WIDTH = 167; protected static final int HEIGHT = 120; protected static final int CITIZEN_X = 2; @@ -92,8 +99,6 @@ protected JobBasedRecipeCategory(@NotNull final IJob job, this.slot = guiHelper.getSlotDrawable(); this.chanceSlot = guiHelper.createDrawable(TEXTURE, 0, 121, 18, 18); - this.citizen = createCitizenWithJob(this.job); - this.description = wordWrap(breakLines(translateDescription( TranslationConstants.PARTIAL_JEI_INFO + this.job.getJobRegistryEntry().getKey().getPath()))); @@ -210,12 +215,16 @@ public void draw(@NotNull final T recipe, final int citizen_by = CITIZEN_Y + CITIZEN_H; final int offsetY = 4; - final float headYaw = (float) Math.atan((citizen_cx - mouseX) / 40.0F) * 40.0F; - final float yaw = (float) Math.atan((citizen_cx - mouseX) / 40.0F) * 20.0F; - final float pitch = (float) Math.atan((citizen_cy - offsetY - mouseY) / 40.0F) * 20.0F; - Lighting.setupForFlatItems(); - UiRenderMacros.drawEntity(stack.pose(), citizen_cx, citizen_by - offsetY, scale, headYaw, yaw, pitch, this.citizen); - Lighting.setupFor3DItems(); + final EntityCitizen citizen = createCitizenWithJob(this.job); + if (citizen != null) + { + final float headYaw = (float) Math.atan((citizen_cx - mouseX) / 40.0F) * 40.0F; + final float yaw = (float) Math.atan((citizen_cx - mouseX) / 40.0F) * 20.0F; + final float pitch = (float) Math.atan((citizen_cy - offsetY - mouseY) / 40.0F) * 20.0F; + Lighting.setupForFlatItems(); + UiRenderMacros.drawEntity(stack.pose(), citizen_cx, citizen_by - offsetY, scale, headYaw, yaw, pitch, citizen); + Lighting.setupFor3DItems(); + } int y = 0; final Minecraft mc = Minecraft.getInstance(); @@ -298,15 +307,26 @@ public InfoBlock(final String text, final String tip, final Rect2i bounds) public final Rect2i bounds; } - @NotNull + @Nullable private static EntityCitizen createCitizenWithJob(@NotNull final IJob job) { - final EntityCitizen citizen = new EntityCitizen(ModEntities.CITIZEN, FAKE_LEVEL); - citizen.setFemale(citizen.getRandom().nextBoolean()); - citizen.setTextureId(citizen.getRandom().nextInt(255)); - citizen.getEntityData().set(EntityCitizen.DATA_TEXTURE_SUFFIX, CitizenData.SUFFIXES.get(citizen.getRandom().nextInt(CitizenData.SUFFIXES.size()))); - citizen.setModelId(job.getModel()); - return citizen; + try + { + return citizenCache.get(job, () -> + { + final EntityCitizen citizen = new EntityCitizen(ModEntities.CITIZEN, FAKE_LEVEL); + citizen.setFemale(citizen.getRandom().nextBoolean()); + citizen.setTextureId(citizen.getRandom().nextInt(255)); + citizen.getEntityData().set(EntityCitizen.DATA_TEXTURE_SUFFIX, CitizenData.SUFFIXES.get(citizen.getRandom().nextInt(CitizenData.SUFFIXES.size()))); + citizen.setModelId(job.getModel()); + return citizen; + }); + } + catch (final Throwable e) + { + Log.getLogger().error("Error creating citizen for {}", job.getJobRegistryEntry().getTranslationKey(), e); + return null; + } } @NotNull diff --git a/src/main/java/com/minecolonies/core/compatibility/journeymap/EventListener.java b/src/main/java/com/minecolonies/core/compatibility/journeymap/EventListener.java index 99e9e535223..7dc6a0e2fa6 100644 --- a/src/main/java/com/minecolonies/core/compatibility/journeymap/EventListener.java +++ b/src/main/java/com/minecolonies/core/compatibility/journeymap/EventListener.java @@ -1,8 +1,9 @@ package com.minecolonies.core.compatibility.journeymap; +import com.minecolonies.api.IMinecoloniesAPI; import com.minecolonies.api.colony.IColonyView; -import com.minecolonies.api.colony.event.ClientChunkUpdatedEvent; -import com.minecolonies.api.colony.event.ColonyViewUpdatedEvent; +import com.minecolonies.core.event.ClientChunkUpdatedEvent; +import com.minecolonies.api.eventbus.events.colony.ColonyViewUpdatedModEvent; import com.minecolonies.api.colony.jobs.IJob; import com.minecolonies.api.colony.jobs.registry.IJobRegistry; import com.minecolonies.api.colony.jobs.registry.JobEntry; @@ -50,6 +51,7 @@ public EventListener(@NotNull final Journeymap jmap) this.jmap = jmap; MinecraftForge.EVENT_BUS.register(this); + IMinecoloniesAPI.getInstance().getEventBus().subscribe(ColonyViewUpdatedModEvent.class, this::onColonyViewUpdated); } @SubscribeEvent @@ -80,8 +82,7 @@ public void onColonyChunkDataUpdated(@NotNull final ClientChunkUpdatedEvent even ColonyBorderMapping.updateChunk(this.jmap, dimension, event.getChunk()); } - @SubscribeEvent - public void onColonyViewUpdated(@NotNull final ColonyViewUpdatedEvent event) + public void onColonyViewUpdated(@NotNull final ColonyViewUpdatedModEvent event) { final IColonyView colony = event.getColony(); final Set graves = colony.getGraveManager().getGraves().keySet(); diff --git a/src/main/java/com/minecolonies/core/entity/ai/workers/AbstractEntityAIStructureWithWorkOrder.java b/src/main/java/com/minecolonies/core/entity/ai/workers/AbstractEntityAIStructureWithWorkOrder.java index 35133163f24..abbb1889014 100755 --- a/src/main/java/com/minecolonies/core/entity/ai/workers/AbstractEntityAIStructureWithWorkOrder.java +++ b/src/main/java/com/minecolonies/core/entity/ai/workers/AbstractEntityAIStructureWithWorkOrder.java @@ -6,13 +6,14 @@ import com.ldtteam.structurize.placement.StructurePlacer; import com.ldtteam.structurize.util.BlockUtils; import com.ldtteam.structurize.util.PlacementSettings; +import com.minecolonies.api.IMinecoloniesAPI; import com.minecolonies.api.colony.IColony; import com.minecolonies.api.colony.buildings.IBuilding; -import com.minecolonies.api.colony.buildings.event.BuildingConstructionEvent; import com.minecolonies.api.colony.workorders.IWorkOrder; import com.minecolonies.api.colony.workorders.WorkOrderType; import com.minecolonies.api.crafting.ItemStorage; import com.minecolonies.api.entity.ai.statemachine.states.IAIState; +import com.minecolonies.api.eventbus.events.colony.buildings.BuildingConstructionModEvent; import com.minecolonies.api.tileentities.AbstractTileEntityColonyBuilding; import com.minecolonies.api.util.*; import com.minecolonies.api.util.constant.Constants; @@ -31,7 +32,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraftforge.common.MinecraftForge; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -421,31 +421,24 @@ public void executeSpecificCompleteActions() job.complete(); - if (wo instanceof WorkOrderBuilding) + if (wo instanceof WorkOrderBuilding workOrderBuilding) { final IBuilding building = colony.getBuildingManager().getBuilding(wo.getLocation()); - try - { - MinecraftForge.EVENT_BUS.post(new BuildingConstructionEvent(building, BuildingConstructionEvent.EventType.fromWorkOrderType(wo.getWorkOrderType()))); - } - catch (final Exception e) + if (building == null) { - Log.getLogger().error("Error during BuildingConstructionEvent", e); + Log.getLogger() + .error("Builder ({}:{}) ERROR - Finished, but missing building({})", + worker.getCitizenColonyHandler().getColonyOrRegister().getID(), + worker.getCitizenData().getId(), + wo.getLocation()); } - switch (wo.getWorkOrderType()) + else { - case BUILD: - case UPGRADE: - case REPAIR: - if (building == null) - { - Log.getLogger().error(String.format("Builder (%d:%d) ERROR - Finished, but missing building(%s)", - worker.getCitizenColonyHandler().getColonyOrRegister().getID(), - worker.getCitizenData().getId(), - wo.getLocation())); - } - else - { + switch (wo.getWorkOrderType()) + { + case BUILD: + case UPGRADE: + case REPAIR: // Normally levels are done through the schematic data, but in case it is missing we do it manually here. final BlockEntity te = worker.level.getBlockEntity(building.getID()); if (te instanceof AbstractTileEntityColonyBuilding && ((IBlueprintDataProviderBE) te).getSchematicName().isEmpty()) @@ -453,21 +446,12 @@ public void executeSpecificCompleteActions() building.onUpgradeComplete(wo.getTargetLevel()); building.setBuildingLevel(wo.getTargetLevel()); } - } - break; - case REMOVE: - if (building == null) - { - Log.getLogger().error(String.format("Builder (%d:%d) ERROR - Finished, but missing building(%s)", - worker.getCitizenColonyHandler().getColonyOrRegister().getID(), - worker.getCitizenData().getId(), - wo.getLocation())); - } - else - { + break; + case REMOVE: building.setDeconstructed(); - } - break; + break; + } + IMinecoloniesAPI.getInstance().getEventBus().post(new BuildingConstructionModEvent(building, workOrderBuilding)); } } } diff --git a/src/main/java/com/minecolonies/core/entity/citizen/EntityCitizen.java b/src/main/java/com/minecolonies/core/entity/citizen/EntityCitizen.java index 684e7ef561a..d5c73d58186 100755 --- a/src/main/java/com/minecolonies/core/entity/citizen/EntityCitizen.java +++ b/src/main/java/com/minecolonies/core/entity/citizen/EntityCitizen.java @@ -1,10 +1,10 @@ package com.minecolonies.core.entity.citizen; +import com.minecolonies.api.IMinecoloniesAPI; import com.minecolonies.api.blocks.AbstractBlockHut; import com.minecolonies.api.colony.*; import com.minecolonies.api.colony.buildings.IGuardBuilding; import com.minecolonies.api.colony.buildings.registry.BuildingEntry; -import com.minecolonies.api.colony.citizens.event.CitizenRemovedEvent; import com.minecolonies.api.colony.jobs.IJob; import com.minecolonies.api.colony.permissions.Action; import com.minecolonies.api.colony.permissions.IPermissions; @@ -27,6 +27,8 @@ import com.minecolonies.api.entity.citizen.citizenhandlers.*; import com.minecolonies.api.entity.citizen.happiness.ExpirationBasedHappinessModifier; import com.minecolonies.api.entity.citizen.happiness.StaticHappinessSupplier; +import com.minecolonies.api.eventbus.events.colony.citizens.CitizenDiedModEvent; +import com.minecolonies.api.eventbus.events.colony.citizens.CitizenRemovedModEvent; import com.minecolonies.api.inventory.InventoryCitizen; import com.minecolonies.api.inventory.container.ContainerCitizenInventory; import com.minecolonies.api.items.ModItems; @@ -99,7 +101,6 @@ import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.ForgeCapabilities; import net.minecraftforge.common.util.LazyOptional; @@ -1572,18 +1573,18 @@ public void die(@NotNull final DamageSource damageSource) Component.literal(damageSource.getLocalizedDeathMessage(this).getString()).getString().replaceFirst(this.getDisplayName().getString(), "Citizen"); citizenColonyHandler.getColonyOrRegister().getEventDescriptionManager().addEventDescription(new CitizenDiedEvent(blockPosition(), citizenData.getName(), deathCause)); - try - { - MinecraftForge.EVENT_BUS.post(new CitizenRemovedEvent(citizenData, damageSource)); - } - catch (final Exception e) - { - Log.getLogger().error("Error during CitizenRemovedEvent", e); - } + IMinecoloniesAPI.getInstance().getEventBus().post(new CitizenDiedModEvent(citizenData, damageSource)); } super.die(damageSource); } + @Override + public void remove(final @NotNull RemovalReason reason) + { + super.remove(reason); + IMinecoloniesAPI.getInstance().getEventBus().post(new CitizenRemovedModEvent(citizenData, reason)); + } + /** * Trigger the corresponding death achievement. * diff --git a/src/main/java/com/minecolonies/api/colony/event/ClientChunkUpdatedEvent.java b/src/main/java/com/minecolonies/core/event/ClientChunkUpdatedEvent.java similarity index 87% rename from src/main/java/com/minecolonies/api/colony/event/ClientChunkUpdatedEvent.java rename to src/main/java/com/minecolonies/core/event/ClientChunkUpdatedEvent.java index 742fce230ad..36429d48204 100644 --- a/src/main/java/com/minecolonies/api/colony/event/ClientChunkUpdatedEvent.java +++ b/src/main/java/com/minecolonies/core/event/ClientChunkUpdatedEvent.java @@ -1,35 +1,35 @@ -package com.minecolonies.api.colony.event; - -import net.minecraft.world.level.chunk.LevelChunk; -import net.minecraftforge.eventbus.api.Event; -import org.jetbrains.annotations.NotNull; - -/** - * This event is fired client-side after the colony chunk capabilities are synched to the player; - * i.e. there might be an update to which colony claims a particular chunk. This is fired even if - * no colony owns the chunk in question, as that may also be interesting; and even if the data did - * not actually change, as it might still be new to the listener. - */ -public class ClientChunkUpdatedEvent extends Event -{ - private final LevelChunk chunk; - - /** - * Constructs a chunk update event. - * - * @param chunk The chunk that was updated. - */ - public ClientChunkUpdatedEvent(@NotNull final LevelChunk chunk) - { - this.chunk = chunk; - } - - /** - * Gets the chunk related to the event. - */ - @NotNull - public LevelChunk getChunk() - { - return this.chunk; - } -} +package com.minecolonies.core.event; + +import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraftforge.eventbus.api.Event; +import org.jetbrains.annotations.NotNull; + +/** + * This event is fired client-side after the colony chunk capabilities are synched to the player; + * i.e. there might be an update to which colony claims a particular chunk. This is fired even if + * no colony owns the chunk in question, as that may also be interesting; and even if the data did + * not actually change, as it might still be new to the listener. + */ +public final class ClientChunkUpdatedEvent extends Event +{ + private final LevelChunk chunk; + + /** + * Constructs a chunk update event. + * + * @param chunk The chunk that was updated. + */ + public ClientChunkUpdatedEvent(@NotNull final LevelChunk chunk) + { + this.chunk = chunk; + } + + /** + * Gets the chunk related to the event. + */ + @NotNull + public LevelChunk getChunk() + { + return this.chunk; + } +} diff --git a/src/main/java/com/minecolonies/core/event/EventHandler.java b/src/main/java/com/minecolonies/core/event/EventHandler.java index b8812e661be..bf0407d2477 100755 --- a/src/main/java/com/minecolonies/core/event/EventHandler.java +++ b/src/main/java/com/minecolonies/core/event/EventHandler.java @@ -745,7 +745,7 @@ public static void onWorldLoad(@NotNull final LevelEvent.Load event) // Global events // Halloween ghost mode - if (event.getLevel().isClientSide() && MineColonies.getConfig().getServer().holidayFeatures.get() && + if (event.getLevel().isClientSide() && MineColonies.getConfig().getClient().holidayFeatures.get() && (LocalDateTime.now().getDayOfMonth() == 31 && LocalDateTime.now().getMonth() == Month.OCTOBER || LocalDateTime.now().getDayOfMonth() == 1 && LocalDateTime.now().getMonth() == Month.NOVEMBER || LocalDateTime.now().getDayOfMonth() == 2 && LocalDateTime.now().getMonth() == Month.NOVEMBER)) diff --git a/src/main/java/com/minecolonies/core/network/messages/server/CreateColonyMessage.java b/src/main/java/com/minecolonies/core/network/messages/server/CreateColonyMessage.java index 995c8bc45ab..4edf35ef90a 100755 --- a/src/main/java/com/minecolonies/core/network/messages/server/CreateColonyMessage.java +++ b/src/main/java/com/minecolonies/core/network/messages/server/CreateColonyMessage.java @@ -1,12 +1,12 @@ package com.minecolonies.core.network.messages.server; import com.ldtteam.structurize.storage.StructurePacks; +import com.minecolonies.api.IMinecoloniesAPI; import com.minecolonies.api.colony.IColony; import com.minecolonies.api.colony.IColonyManager; import com.minecolonies.api.colony.buildings.IBuilding; -import com.minecolonies.api.colony.event.ColonyCreatedEvent; +import com.minecolonies.api.eventbus.events.colony.ColonyCreatedModEvent; import com.minecolonies.api.network.IMessage; -import com.minecolonies.api.util.Log; import com.minecolonies.core.Network; import com.minecolonies.core.network.messages.client.colony.OpenBuildingUIMessage; import com.minecolonies.core.tileentities.TileEntityColonyBuilding; @@ -20,7 +20,6 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.LogicalSide; import net.minecraftforge.network.NetworkEvent; import org.jetbrains.annotations.Nullable; @@ -188,16 +187,8 @@ else if (spawnDistance > MineColonies.getConfig().getServer().maxDistanceFromWor .sendTo(sender); } + IMinecoloniesAPI.getInstance().getEventBus().post(new ColonyCreatedModEvent(createdColony)); Network.getNetwork().sendToPlayer(new OpenBuildingUIMessage(building), sender); - - try - { - MinecraftForge.EVENT_BUS.post(new ColonyCreatedEvent(createdColony)); - } - catch (final Exception e) - { - Log.getLogger().error("Error during ColonyCreatedEvent", e); - } return; } diff --git a/src/main/java/com/minecolonies/core/network/messages/server/colony/ColonyFlagChangeMessage.java b/src/main/java/com/minecolonies/core/network/messages/server/colony/ColonyFlagChangeMessage.java index a127e6613d4..79b606c3375 100644 --- a/src/main/java/com/minecolonies/core/network/messages/server/colony/ColonyFlagChangeMessage.java +++ b/src/main/java/com/minecolonies/core/network/messages/server/colony/ColonyFlagChangeMessage.java @@ -1,14 +1,13 @@ package com.minecolonies.core.network.messages.server.colony; +import com.minecolonies.api.IMinecoloniesAPI; import com.minecolonies.api.colony.IColony; -import com.minecolonies.api.colony.event.ColonyInformationChangedEvent; -import com.minecolonies.api.util.Log; +import com.minecolonies.api.eventbus.events.colony.ColonyFlagChangedModEvent; import com.minecolonies.api.util.constant.Constants; import com.minecolonies.core.network.messages.server.AbstractColonyServerMessage; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.network.FriendlyByteBuf; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.network.NetworkEvent; import static com.minecolonies.api.util.constant.NbtTagConstants.TAG_BANNER_PATTERNS; @@ -18,18 +17,23 @@ */ public class ColonyFlagChangeMessage extends AbstractColonyServerMessage { - /** The chosen list of patterns from the window */ + /** + * The chosen list of patterns from the window + */ private ListTag patterns; - /** Default constructor **/ - public ColonyFlagChangeMessage () { super(); } + /** + * Default constructor + **/ + public ColonyFlagChangeMessage() {super();} /** * Spawn a new change message - * @param colony the colony the player changed the banner in + * + * @param colony the colony the player changed the banner in * @param patternList the list of patterns they set in the banner picker */ - public ColonyFlagChangeMessage (IColony colony, ListTag patternList) + public ColonyFlagChangeMessage(IColony colony, ListTag patternList) { super(colony); @@ -40,14 +44,7 @@ public ColonyFlagChangeMessage (IColony colony, ListTag patternList) protected void onExecute(NetworkEvent.Context ctxIn, boolean isLogicalServer, IColony colony) { colony.setColonyFlag(patterns); - try - { - MinecraftForge.EVENT_BUS.post(new ColonyInformationChangedEvent(colony, ColonyInformationChangedEvent.Type.FLAG)); - } - catch (final Exception e) - { - Log.getLogger().error("Error during ColonyInformationChangedEvent", e); - } + IMinecoloniesAPI.getInstance().getEventBus().post(new ColonyFlagChangedModEvent(colony)); } @Override @@ -63,6 +60,8 @@ protected void fromBytesOverride(FriendlyByteBuf buf) { CompoundTag nbt = buf.readNbt(); if (nbt != null) + { this.patterns = nbt.getList(TAG_BANNER_PATTERNS, Constants.TAG_COMPOUND); + } } } diff --git a/src/main/java/com/minecolonies/core/network/messages/server/colony/TeamColonyColorChangeMessage.java b/src/main/java/com/minecolonies/core/network/messages/server/colony/TeamColonyColorChangeMessage.java index b54453ca333..afe5f860aa0 100755 --- a/src/main/java/com/minecolonies/core/network/messages/server/colony/TeamColonyColorChangeMessage.java +++ b/src/main/java/com/minecolonies/core/network/messages/server/colony/TeamColonyColorChangeMessage.java @@ -1,13 +1,12 @@ package com.minecolonies.core.network.messages.server.colony; +import com.minecolonies.api.IMinecoloniesAPI; import com.minecolonies.api.colony.IColony; import com.minecolonies.api.colony.buildings.views.IBuildingView; -import com.minecolonies.api.colony.event.ColonyInformationChangedEvent; -import com.minecolonies.api.util.Log; +import com.minecolonies.api.eventbus.events.colony.ColonyTeamColorChangedModEvent; import com.minecolonies.core.network.messages.server.AbstractColonyServerMessage; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.ChatFormatting; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.network.NetworkEvent; import org.jetbrains.annotations.NotNull; @@ -68,13 +67,6 @@ public void toBytesOverride(@NotNull final FriendlyByteBuf buf) protected void onExecute(final NetworkEvent.Context ctxIn, final boolean isLogicalServer, final IColony colony) { colony.setColonyColor(ChatFormatting.values()[colorOrdinal]); - try - { - MinecraftForge.EVENT_BUS.post(new ColonyInformationChangedEvent(colony, ColonyInformationChangedEvent.Type.TEAM_COLOR)); - } - catch (final Exception e) - { - Log.getLogger().error("Error during ColonyInformationChangedEvent", e); - } + IMinecoloniesAPI.getInstance().getEventBus().post(new ColonyTeamColorChangedModEvent(colony)); } } diff --git a/src/main/java/com/minecolonies/core/network/messages/server/colony/TownHallRenameMessage.java b/src/main/java/com/minecolonies/core/network/messages/server/colony/TownHallRenameMessage.java index d2d94f7c951..19f83a57b06 100755 --- a/src/main/java/com/minecolonies/core/network/messages/server/colony/TownHallRenameMessage.java +++ b/src/main/java/com/minecolonies/core/network/messages/server/colony/TownHallRenameMessage.java @@ -1,18 +1,16 @@ package com.minecolonies.core.network.messages.server.colony; +import com.minecolonies.api.IMinecoloniesAPI; import com.minecolonies.api.colony.IColony; import com.minecolonies.api.colony.IColonyView; -import com.minecolonies.api.colony.event.ColonyInformationChangedEvent; -import com.minecolonies.api.util.Log; -import com.minecolonies.core.Network; +import com.minecolonies.api.eventbus.events.colony.ColonyNameChangedModEvent; import com.minecolonies.core.network.messages.server.AbstractColonyServerMessage; import net.minecraft.network.FriendlyByteBuf; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.network.NetworkEvent; import org.jetbrains.annotations.NotNull; /** - * Message to execute the renaiming of the townHall. + * Message to execute the renaming of the townHall. */ public class TownHallRenameMessage extends AbstractColonyServerMessage { @@ -57,13 +55,6 @@ protected void onExecute(final NetworkEvent.Context ctxIn, final boolean isLogic { name = (name.length() <= MAX_NAME_LENGTH) ? name : name.substring(0, SUBSTRING_LENGTH); colony.setName(name); - try - { - MinecraftForge.EVENT_BUS.post(new ColonyInformationChangedEvent(colony, ColonyInformationChangedEvent.Type.NAME)); - } - catch (final Exception e) - { - Log.getLogger().error("Error during ColonyInformationChangedEvent", e); - } + IMinecoloniesAPI.getInstance().getEventBus().post(new ColonyNameChangedModEvent(colony)); } } diff --git a/src/main/java/com/minecolonies/core/placementhandlers/main/SurvivalHandler.java b/src/main/java/com/minecolonies/core/placementhandlers/main/SurvivalHandler.java index 45864dd6693..cdfdb66cb11 100644 --- a/src/main/java/com/minecolonies/core/placementhandlers/main/SurvivalHandler.java +++ b/src/main/java/com/minecolonies/core/placementhandlers/main/SurvivalHandler.java @@ -39,7 +39,9 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.BlockSnapshot; +import net.minecraftforge.event.entity.EntityAttributeCreationEvent; import net.minecraftforge.event.level.BlockEvent; +import net.minecraftforge.event.level.BlockEvent.EntityPlaceEvent; import net.minecraftforge.items.wrapper.InvWrapper; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/minecolonies/core/structures/MineColoniesStructures.java b/src/main/java/com/minecolonies/core/structures/MineColoniesStructures.java index ccc6fafb273..9cc16059b29 100644 --- a/src/main/java/com/minecolonies/core/structures/MineColoniesStructures.java +++ b/src/main/java/com/minecolonies/core/structures/MineColoniesStructures.java @@ -20,8 +20,7 @@ public class MineColoniesStructures public static final DeferredRegister> DEFERRED_REGISTRY_STRUCTURE = DeferredRegister.create(Registries.STRUCTURE_TYPE, Constants.MOD_ID); /** - * Registers the base structure itself and sets what its path is. In this case, - * this base structure will have the resourcelocation of structure_tutorial:sky_structures. + * Empty colony structure. */ public static final RegistryObject> EMPTY_COLONY = DEFERRED_REGISTRY_STRUCTURE.register("empty_colony", () -> () -> COLONY_CODEC); } diff --git a/src/main/java/com/minecolonies/core/util/ChunkClientDataHelper.java b/src/main/java/com/minecolonies/core/util/ChunkClientDataHelper.java index f33f6a36099..d5d445efc9b 100755 --- a/src/main/java/com/minecolonies/core/util/ChunkClientDataHelper.java +++ b/src/main/java/com/minecolonies/core/util/ChunkClientDataHelper.java @@ -1,7 +1,7 @@ package com.minecolonies.core.util; import com.minecolonies.api.colony.IColonyTagCapability; -import com.minecolonies.api.colony.event.ClientChunkUpdatedEvent; +import com.minecolonies.core.event.ClientChunkUpdatedEvent; import com.minecolonies.api.util.ChunkCapData; import net.minecraft.world.level.chunk.LevelChunk; import net.minecraftforge.common.MinecraftForge; diff --git a/src/main/resources/assets/minecolonies/lang/manual_en_us.json b/src/main/resources/assets/minecolonies/lang/manual_en_us.json index c9b1624ac4b..6c7f88df3be 100644 --- a/src/main/resources/assets/minecolonies/lang/manual_en_us.json +++ b/src/main/resources/assets/minecolonies/lang/manual_en_us.json @@ -1842,11 +1842,13 @@ "death.attack.entity.minecolonies.amazon": "%s was pierced by an Amazon's arrow", "entity.amazonspearman": "Amazon Spearman", "entity.minecolonies.amazonspearman": "Amazon Spearman", - "death.attack.entity.minecolonies.amazonspearman": "%s was pierced by an Amazon's spear", - "death.attack.entity.minecolonies.spear": "%s was perforated by a spear", + "entity.amazonchief": "Amazon Leader", "entity.minecolonies.amazonchief": "Amazon Leader", "death.attack.entity.minecolonies.amazonchief": "%s was expelled by the great Amazon Leader", + "death.attack.entity.minecolonies.amazonspearman": "%s was pierced by an Amazon's spear", + "death.attack.entity.minecolonies.amazon": "%s was pierced by an Amazon's arrow", + "death.attack.entity.minecolonies.spear": "%s was perforated by a spear", "com.minecolonies.coremod.job.mechanic": "Mechanic", "com.minecolonies.coremod.gui.workerhuts.plantation.to_plant": "Planting:", @@ -2770,5 +2772,72 @@ "com.minecolonies.coremod.diseases.influenza": "Influenza", "com.minecolonies.coremod.diseases.measles": "Measles", - "com.minecolonies.coremod.diseases.smallpox": "Smallpox" + "com.minecolonies.coremod.diseases.smallpox": "Smallpox", + + "entity.campamazon": "Amazon", + "entity.acampmazonspearman": "Amazon Spearman", + "entity.campamazonchief": "Amazon Leader", + + "entity.minecolonies.campamazon": "Amazon", + "entity.minecolonies.campamazonspearman": "Amazon Spearman", + "entity.minecolonies.campamazonchief": "Amazon Leader", + + "entity.minecolonies.campnorsemenchief": "Chief Norseman", + "entity.minecolonies.campnorsemenarcher": "Archer Norseman", + "entity.minecolonies.campshieldmaiden": "Shieldmaiden", + + "entity.campnorsemenchief": "Chief Norseman", + "entity.campnorsemenarcher": "Archer Norseman", + "entity.campshieldmaiden": "Shieldmaiden", + + "entity.campbarbarian": "Barbarian", + "entity.camparcherbarbarian": "Archer Barbarian", + "entity.campchiefbarbarian": "Chief Barbarian", + + "entity.minecolonies.campbarbarian": "Barbarian", + "entity.minecolonies.camparcherbarbarian": "Archer Barbarian", + "entity.minecolonies.campchiefbarbarian": "Chief Barbarian", + + "entity.camppirate": "Pirate", + "entity.camparcherpirate": "Archer Pirate", + "entity.campchiefpirate": "Pirate Captain", + + "entity.minecolonies.camppirate": "Pirate", + "entity.minecolonies.camparcherpirate": "Archer Pirate", + "entity.minecolonies.campchiefpirate": "Pirate Captain", + + "entity.campmummy": "Mummy", + "entity.camparchermummy": "Archer Mummy", + "entity.camppharao": "Pharaoh", + + "entity.minecolonies.campmummy": "Mummy", + "entity.minecolonies.camparchermummy": "Archer Mummy", + "entity.minecolonies.camppharao": "Pharaoh", + + "entity.minecolonies.campdrownedpirate": "Drowned Pirate", + "entity.minecolonies.campdrownedarcherpirate": "Drowned Pirate Archer", + "entity.minecolonies.campdrownedchiefpirate": "Drowned Pirate Chief", + + "entity.campdrownedpirate": "Drowned Pirate", + "entity.campdrownedarcherpirate": "Drowned Pirate Archer", + "entity.campdrownedchiefpirate": "Drowned Pirate Chief", + + "death.attack.entity.minecolonies.campbarbarian": "%s was sliced and diced by a Barbarian", + "death.attack.entity.minecolonies.campchiefbarbarian": "%s was macerated by a Great Chief", + "death.attack.entity.minecolonies.camparcherbarbarian": "%s was ravaged by an Archer Barbarian", + "death.attack.entity.minecolonies.camppirate": "%s was sliced and diced by a Pirate", + "death.attack.entity.minecolonies.campchiefpirate": "%s was macerated by a Pirate Captain", + "death.attack.entity.minecolonies.camparcherpirate": "%s was ravaged by an Archer Pirate", + "death.attack.entity.minecolonies.campmummy": "%s was scared to death by a Mummy", + "death.attack.entity.minecolonies.camppharao": "%s was put to sleep by a Pharaoh", + "death.attack.entity.minecolonies.camparchermummy": "%s was pierced by a Mummy's deadly glare", + "death.attack.entity.minecolonies.campamazonchief": "%s was expelled by the great Amazon Leader", + "death.attack.entity.minecolonies.campamazonspearman": "%s was pierced by an Amazon's spear", + "death.attack.entity.minecolonies.campamazon": "%s was pierced by an Amazon's arrow", + "death.attack.entity.minecolonies.campnorsemenchief": "%s was grounded by the great Viking Chief", + "death.attack.entity.minecolonies.campnorsemenarcher": "%s was hit by an Archer Viking", + "death.attack.entity.minecolonies.campshieldmaiden": "%s was crushed by a Shieldmaiden", + "death.attack.entity.minecolonies.campdrownedpirate": "%s was taken to the depths by a drowned Pirate", + "death.attack.entity.minecolonies.campdrownedarcherpirate": "%s was pierced from the depths by a drowned Pirate Archer", + "death.attack.entity.minecolonies.campdrownedchiefpirate": "%s was put to a watery grave by a drowned Pirate Chief" } diff --git a/src/main/resources/data/minecolonies/structures/ships/large_norse_ship.nbt b/src/main/resources/data/minecolonies/structures/ships/large_norse_ship.nbt new file mode 100644 index 00000000000..6b4e8812362 Binary files /dev/null and b/src/main/resources/data/minecolonies/structures/ships/large_norse_ship.nbt differ diff --git a/src/main/resources/data/minecolonies/structures/ships/large_pirate_ship.nbt b/src/main/resources/data/minecolonies/structures/ships/large_pirate_ship.nbt new file mode 100644 index 00000000000..5630dba56ee Binary files /dev/null and b/src/main/resources/data/minecolonies/structures/ships/large_pirate_ship.nbt differ diff --git a/src/main/resources/data/minecolonies/structures/ships/medium_norse_ship.nbt b/src/main/resources/data/minecolonies/structures/ships/medium_norse_ship.nbt new file mode 100644 index 00000000000..849969f3d89 Binary files /dev/null and b/src/main/resources/data/minecolonies/structures/ships/medium_norse_ship.nbt differ diff --git a/src/main/resources/data/minecolonies/structures/ships/medium_pirate_ship.nbt b/src/main/resources/data/minecolonies/structures/ships/medium_pirate_ship.nbt new file mode 100644 index 00000000000..2d4be1dd626 Binary files /dev/null and b/src/main/resources/data/minecolonies/structures/ships/medium_pirate_ship.nbt differ diff --git a/src/main/resources/data/minecolonies/structures/ships/small_norse_ship.nbt b/src/main/resources/data/minecolonies/structures/ships/small_norse_ship.nbt new file mode 100644 index 00000000000..42593c5946f Binary files /dev/null and b/src/main/resources/data/minecolonies/structures/ships/small_norse_ship.nbt differ diff --git a/src/main/resources/data/minecolonies/structures/ships/small_pirate_ship.nbt b/src/main/resources/data/minecolonies/structures/ships/small_pirate_ship.nbt new file mode 100644 index 00000000000..5f0aa9f7950 Binary files /dev/null and b/src/main/resources/data/minecolonies/structures/ships/small_pirate_ship.nbt differ diff --git a/src/main/resources/data/minecolonies/tags/worldgen/biome/has_structure/ship.json b/src/main/resources/data/minecolonies/tags/worldgen/biome/has_structure/ship.json new file mode 100644 index 00000000000..b9aaf01eda3 --- /dev/null +++ b/src/main/resources/data/minecolonies/tags/worldgen/biome/has_structure/ship.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "#minecraft:is_ocean" + ] +} diff --git a/src/main/resources/data/minecolonies/worldgen/processor_list/placeholder_replacement.json b/src/main/resources/data/minecolonies/worldgen/processor_list/placeholder_replacement.json new file mode 100644 index 00000000000..36137bc0526 --- /dev/null +++ b/src/main/resources/data/minecolonies/worldgen/processor_list/placeholder_replacement.json @@ -0,0 +1,44 @@ +{ + "processors": [ + { + "blocks": [ + { + "Name": "structurize:blocksubstitution" + }, + { + "Name": "minecolonies:blockwaypoint" + } + ], + "processor_type": "minecraft:block_ignore" + }, + { + "rules": [ + { + "output_state": { + "Name": "minecraft:grass_block" + }, + "input_predicate": { + "block": "structurize:blocksolidsubstitution", + "predicate_type": "minecraft:block_match" + }, + "location_predicate": { + "predicate_type": "minecraft:always_true" + } + }, + { + "output_state": { + "Name": "minecraft:water" + }, + "input_predicate": { + "block": "structurize:blockfluidsubstitution", + "predicate_type": "minecraft:block_match" + }, + "location_predicate": { + "predicate_type": "minecraft:always_true" + } + } + ], + "processor_type": "minecraft:rule" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/minecolonies/worldgen/structure/ship.json b/src/main/resources/data/minecolonies/worldgen/structure/ship.json new file mode 100644 index 00000000000..401dece0425 --- /dev/null +++ b/src/main/resources/data/minecolonies/worldgen/structure/ship.json @@ -0,0 +1,16 @@ +{ + "type": "minecraft:jigsaw", + "biomes": "#minecolonies:has_structure/ship", + "adapt_noise": false, + "start_pool": "minecolonies:ship_pool", + "spawn_overrides": {}, + "size": 1, + "step": "surface_structures", + + "start_height": { + "absolute": -3 + }, + "project_start_to_heightmap": "WORLD_SURFACE_WG", + "max_distance_from_center": 16, + "use_expansion_hack": false +} diff --git a/src/main/resources/data/minecolonies/worldgen/structure_set/ship.json b/src/main/resources/data/minecolonies/worldgen/structure_set/ship.json new file mode 100644 index 00000000000..a9abff716ad --- /dev/null +++ b/src/main/resources/data/minecolonies/worldgen/structure_set/ship.json @@ -0,0 +1,14 @@ +{ + "structures": [ + { + "structure": "minecolonies:ship", + "weight": 1 + } + ], + "placement": { + "salt": 1225566777, + "spacing": 55, + "separation": 25, + "type": "minecraft:random_spread" + } +} \ No newline at end of file diff --git a/src/main/resources/data/minecolonies/worldgen/template_pool/ship_pool.json b/src/main/resources/data/minecolonies/worldgen/template_pool/ship_pool.json new file mode 100644 index 00000000000..73f5c34a460 --- /dev/null +++ b/src/main/resources/data/minecolonies/worldgen/template_pool/ship_pool.json @@ -0,0 +1,60 @@ +{ + "name": "minecolonies:start_pool", + "fallback": "minecraft:empty", + "elements": [ + { + "weight": 1, + "element": { + "location": "minecolonies:ships/large_pirate_ship", + "processors": "minecolonies:placeholder_replacement", + "projection": "rigid", + "element_type": "minecraft:single_pool_element" + } + }, + { + "weight": 1, + "element": { + "location": "minecolonies:ships/medium_pirate_ship", + "processors": "minecolonies:placeholder_replacement", + "projection": "rigid", + "element_type": "minecraft:single_pool_element" + } + }, + { + "weight": 1, + "element": { + "location": "minecolonies:ships/small_pirate_ship", + "processors": "minecolonies:placeholder_replacement", + "projection": "rigid", + "element_type": "minecraft:single_pool_element" + } + }, + { + "weight": 1, + "element": { + "location": "minecolonies:ships/large_norse_ship", + "processors": "minecolonies:placeholder_replacement", + "projection": "rigid", + "element_type": "minecraft:single_pool_element" + } + }, + { + "weight": 1, + "element": { + "location": "minecolonies:ships/medium_norse_ship", + "processors": "minecolonies:placeholder_replacement", + "projection": "rigid", + "element_type": "minecraft:single_pool_element" + } + }, + { + "weight": 1, + "element": { + "location": "minecolonies:ships/small_norse_ship", + "processors": "minecolonies:placeholder_replacement", + "projection": "rigid", + "element_type": "minecraft:single_pool_element" + } + } + ] +}