From f84902c782d33907d77b84fd8febff4afdfebcfe Mon Sep 17 00:00:00 2001 From: Thom van den Akker Date: Mon, 23 Dec 2024 20:12:19 +0100 Subject: [PATCH] Fix compile issue and diseases parsing as air --- .../core/entity/citizen/EntityCitizen.java | 13 ++++--------- .../server/colony/ColonyDeleteOwnMessage.java | 3 --- .../colony/TeamColonyColorChangeMessage.java | 14 +++----------- .../minecolonies/colony/diseases/influenza.json | 4 ++-- .../data/minecolonies/colony/diseases/measles.json | 8 ++++---- .../minecolonies/colony/diseases/smallpox.json | 6 +++--- 6 files changed, 16 insertions(+), 32 deletions(-) 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 a8a331bebbd..b9e572515a8 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; @@ -26,6 +26,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; @@ -1587,14 +1589,7 @@ 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 - { - NeoForge.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); } diff --git a/src/main/java/com/minecolonies/core/network/messages/server/colony/ColonyDeleteOwnMessage.java b/src/main/java/com/minecolonies/core/network/messages/server/colony/ColonyDeleteOwnMessage.java index 784c8823e21..11f5746b81b 100755 --- a/src/main/java/com/minecolonies/core/network/messages/server/colony/ColonyDeleteOwnMessage.java +++ b/src/main/java/com/minecolonies/core/network/messages/server/colony/ColonyDeleteOwnMessage.java @@ -4,13 +4,10 @@ import com.ldtteam.common.network.PlayMessageType; import com.minecolonies.api.colony.IColony; import com.minecolonies.api.colony.IColonyManager; -import com.minecolonies.api.colony.event.ColonyDeletedEvent; -import com.minecolonies.api.util.Log; import com.minecolonies.api.util.MessageUtils; import com.minecolonies.api.util.constant.Constants; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.server.level.ServerPlayer; -import net.neoforged.neoforge.common.NeoForge; import net.neoforged.neoforge.network.handling.IPayloadContext; import static com.minecolonies.api.util.constant.TranslationConstants.MESSAGE_INFO_COLONY_DESTROY_SUCCESS; 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 424e7028df3..4b31ea1a1d0 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,16 +1,15 @@ package com.minecolonies.core.network.messages.server.colony; import com.ldtteam.common.network.PlayMessageType; +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.api.util.constant.Constants; import com.minecolonies.core.network.messages.server.AbstractColonyServerMessage; import net.minecraft.ChatFormatting; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.server.level.ServerPlayer; -import net.neoforged.neoforge.common.NeoForge; import net.neoforged.neoforge.network.handling.IPayloadContext; import org.jetbrains.annotations.NotNull; @@ -66,13 +65,6 @@ protected void toBytes(@NotNull final RegistryFriendlyByteBuf buf) protected void onExecute(final IPayloadContext ctxIn, final ServerPlayer player, final IColony colony) { colony.setColonyColor(ChatFormatting.values()[colorOrdinal]); - try - { - NeoForge.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/resources/data/minecolonies/colony/diseases/influenza.json b/src/main/resources/data/minecolonies/colony/diseases/influenza.json index 29b3fdfdd16..972f26e0837 100644 --- a/src/main/resources/data/minecolonies/colony/diseases/influenza.json +++ b/src/main/resources/data/minecolonies/colony/diseases/influenza.json @@ -3,11 +3,11 @@ "rarity": 100, "items": [ { - "item": "minecraft:carrot", + "id": "minecraft:carrot", "count": 1 }, { - "item": "minecraft:potato", + "id": "minecraft:potato", "count": 1 } ] diff --git a/src/main/resources/data/minecolonies/colony/diseases/measles.json b/src/main/resources/data/minecolonies/colony/diseases/measles.json index bccd625c97b..3cee82f764a 100644 --- a/src/main/resources/data/minecolonies/colony/diseases/measles.json +++ b/src/main/resources/data/minecolonies/colony/diseases/measles.json @@ -3,16 +3,16 @@ "rarity": 10, "items": [ { - "item": "minecraft:poppy", + "id": "minecraft:poppy", "count": 1 }, { - "item": "minecraft:dandelion", + "id": "minecraft:dandelion", "count": 1 }, { - "item": "minecraft:kelp", + "id": "minecraft:kelp", "count": 1 } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/minecolonies/colony/diseases/smallpox.json b/src/main/resources/data/minecolonies/colony/diseases/smallpox.json index 952048a1e15..41cf4a8c38a 100644 --- a/src/main/resources/data/minecolonies/colony/diseases/smallpox.json +++ b/src/main/resources/data/minecolonies/colony/diseases/smallpox.json @@ -3,12 +3,12 @@ "rarity": 1, "items": [ { - "item": "minecraft:honey_bottle", + "id": "minecraft:honey_bottle", "count": 1 }, { - "item": "minecraft:golden_apple", + "id": "minecraft:golden_apple", "count": 1 } ] -} \ No newline at end of file +}