diff --git a/src/datagen/generated/minecolonies/data/minecolonies/tags/item/cook_product.json b/src/datagen/generated/minecolonies/data/minecolonies/tags/item/cook_product.json index cc9ed349941..e6e2e7f4548 100644 --- a/src/datagen/generated/minecolonies/data/minecolonies/tags/item/cook_product.json +++ b/src/datagen/generated/minecolonies/data/minecolonies/tags/item/cook_product.json @@ -42,7 +42,6 @@ "minecolonies:yogurt_with_berries", "minecolonies:mutton_dinner", "minecolonies:tortillas", - "minecolonies:apple_pie", "minecolonies:spicy_eggplant" ] } \ No newline at end of file diff --git a/src/datagen/generated/minecolonies/data/minecolonies/tags/item/poisonousfood.json b/src/datagen/generated/minecolonies/data/minecolonies/tags/item/poisonousfood.json new file mode 100644 index 00000000000..9e58ef6d925 --- /dev/null +++ b/src/datagen/generated/minecolonies/data/minecolonies/tags/item/poisonousfood.json @@ -0,0 +1,8 @@ +{ + "values": [ + "minecraft:poisonous_potato", + "minecraft:chicken", + "minecraft:spider_eye", + "minecraft:rotten_flesh" + ] +} \ No newline at end of file diff --git a/src/main/java/com/minecolonies/api/entity/citizen/citizenhandlers/ICitizenDiseaseHandler.java b/src/main/java/com/minecolonies/api/entity/citizen/citizenhandlers/ICitizenDiseaseHandler.java index 76bc1bb0f56..56209ad2a4f 100755 --- a/src/main/java/com/minecolonies/api/entity/citizen/citizenhandlers/ICitizenDiseaseHandler.java +++ b/src/main/java/com/minecolonies/api/entity/citizen/citizenhandlers/ICitizenDiseaseHandler.java @@ -68,4 +68,10 @@ public interface ICitizenDiseaseHandler * Sets a flag that the citizen is now at the hospital. */ void setSleepsAtHospital(final boolean isAtHospital); + + /** + * Set a disease on the citizen. + * @param disease to set. + */ + void setDisease(String disease); } diff --git a/src/main/java/com/minecolonies/api/items/ModTags.java b/src/main/java/com/minecolonies/api/items/ModTags.java index 272445d2448..7a6cac22cf4 100644 --- a/src/main/java/com/minecolonies/api/items/ModTags.java +++ b/src/main/java/com/minecolonies/api/items/ModTags.java @@ -66,6 +66,8 @@ public class ModTags public static final TagKey breakable_ore = ItemTags.create(TagConstants.BREAKABLE_ORE); public static final TagKey raw_ore = ItemTags.create(TagConstants.RAW_ORE); + public static final TagKey poisonous_food = ItemTags.create(TagConstants.POISONOUS_FOOD); + public static final TagKey> hostile = TagKey.create(Registries.ENTITY_TYPE, TagConstants.HOSTILE); public static final TagKey> mobAttackBlacklist = TagKey.create(Registries.ENTITY_TYPE, TagConstants.MOB_ATTACK_BLACKLIST); diff --git a/src/main/java/com/minecolonies/api/util/constant/TagConstants.java b/src/main/java/com/minecolonies/api/util/constant/TagConstants.java index 5752cfe9dfe..86fc7451d57 100644 --- a/src/main/java/com/minecolonies/api/util/constant/TagConstants.java +++ b/src/main/java/com/minecolonies/api/util/constant/TagConstants.java @@ -53,6 +53,7 @@ public final class TagConstants public static final ResourceLocation TEMPERATE_BIOMES = new ResourceLocation(MOD_ID, "temperatebiomes"); public static final ResourceLocation HUMID_BIOMES = new ResourceLocation(MOD_ID, "humidbiomes"); public static final ResourceLocation DRY_BIOMES = new ResourceLocation(MOD_ID, "drybiomes"); + public static final ResourceLocation POISONOUS_FOOD = new ResourceLocation(MOD_ID, "poisonousfood"); public static final String CRAFTING_BAKER = ModJobs.BAKER_ID.getPath(); public static final String CRAFTING_BLACKSMITH = ModJobs.BLACKSMITH_ID.getPath(); diff --git a/src/main/java/com/minecolonies/api/util/constant/TranslationConstants.java b/src/main/java/com/minecolonies/api/util/constant/TranslationConstants.java index efddbc6abfe..25ac269c787 100755 --- a/src/main/java/com/minecolonies/api/util/constant/TranslationConstants.java +++ b/src/main/java/com/minecolonies/api/util/constant/TranslationConstants.java @@ -634,6 +634,8 @@ public final class TranslationConstants @NonNls public static final String MESSAGE_INTERACTION_COOKIE = "com.minecolonies.coremod.interaction.nocookie"; @NonNls + public static final String MESSAGE_INTERACTION_POISON = "com.minecolonies.coremod.interaction.poison"; + @NonNls public static final String MESSAGE_INTERACTION_VISITOR_FOOD = "com.minecolonies.coremod.interaction.visitor.food"; @NonNls public static final String WARNING_UPGRADE_BARRACKS = "com.minecolonies.coremod.worker.needbarracks"; diff --git a/src/main/java/com/minecolonies/core/blocks/BlockMinecoloniesGrave.java b/src/main/java/com/minecolonies/core/blocks/BlockMinecoloniesGrave.java index 0fda6ee753b..02dc45e1ef5 100644 --- a/src/main/java/com/minecolonies/core/blocks/BlockMinecoloniesGrave.java +++ b/src/main/java/com/minecolonies/core/blocks/BlockMinecoloniesGrave.java @@ -195,6 +195,12 @@ public void setPlacedBy(final Level worldIn, final BlockPos pos, final BlockStat worldIn.setBlock(pos, tempState, 2); } + @Override + public VoxelShape getCollisionShape(final BlockState p_60572_, final BlockGetter p_60573_, final BlockPos p_60574_, final CollisionContext p_60575_) + { + return Shapes.empty(); + } + @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { diff --git a/src/main/java/com/minecolonies/core/colony/buildings/AbstractBuildingGuards.java b/src/main/java/com/minecolonies/core/colony/buildings/AbstractBuildingGuards.java index 8f3c108f960..7f3a1cdec5d 100755 --- a/src/main/java/com/minecolonies/core/colony/buildings/AbstractBuildingGuards.java +++ b/src/main/java/com/minecolonies/core/colony/buildings/AbstractBuildingGuards.java @@ -396,9 +396,9 @@ private void startPatrolNext() { if (curguard.getEntity().isPresent()) { - if (curguard.getEntity().get().getCitizenJobHandler().getColonyJob() instanceof AbstractJobGuard guardEntity) + if (curguard.getJob() instanceof AbstractJobGuard guardEntity) { - ((AbstractEntityAIGuard) guardEntity.getWorkerAI()).setNextPatrolTarget(lastPatrolPoint); + ((AbstractEntityAIGuard) guardEntity.getWorkerAI()).setNextPatrolTargetAndMove(lastPatrolPoint); } } } diff --git a/src/main/java/com/minecolonies/core/colony/buildings/modules/RestaurantMenuModule.java b/src/main/java/com/minecolonies/core/colony/buildings/modules/RestaurantMenuModule.java index 7912e38d2eb..3b9436256a9 100644 --- a/src/main/java/com/minecolonies/core/colony/buildings/modules/RestaurantMenuModule.java +++ b/src/main/java/com/minecolonies/core/colony/buildings/modules/RestaurantMenuModule.java @@ -192,6 +192,11 @@ public void alterItemsToBeKept(final TriConsumer, Integer, for (final ItemStorage menuItem : menu) { consumer.accept(stack -> ItemStackUtils.compareItemStacksIgnoreStackSize(stack, menuItem.getItemStack(), false, true), menuItem.getItemStack().getMaxStackSize() * getExpectedStock(), false); + if (canCook && MinecoloniesAPIProxy.getInstance().getFurnaceRecipes().getFirstSmeltingRecipeByResult(menuItem) instanceof RecipeStorage recipeStorage) + { + final ItemStack smeltStack = recipeStorage.getInput().get(0).getItemStack(); + consumer.accept(stack -> ItemStackUtils.compareItemStacksIgnoreStackSize(stack, smeltStack, false, true), smeltStack.getMaxStackSize() * getExpectedStock(), false); + } } } diff --git a/src/main/java/com/minecolonies/core/colony/buildings/workerbuildings/BuildingCook.java b/src/main/java/com/minecolonies/core/colony/buildings/workerbuildings/BuildingCook.java index 982e4ef6032..cbdc173aeba 100755 --- a/src/main/java/com/minecolonies/core/colony/buildings/workerbuildings/BuildingCook.java +++ b/src/main/java/com/minecolonies/core/colony/buildings/workerbuildings/BuildingCook.java @@ -68,7 +68,6 @@ public class BuildingCook extends AbstractBuilding public BuildingCook(final IColony c, final BlockPos l) { super(c, l); - keepX.put(stack -> !ItemStackUtils.isEmpty(stack.getCraftingRemainingItem()) && !stack.getCraftingRemainingItem().getItem().equals(Items.BUCKET), new Tuple<>(STACKSIZE, false)); } /** @@ -92,6 +91,12 @@ public void onUpgradeComplete(final int newLevel) initTags = false; } + @Override + protected boolean keepFood() + { + return false; + } + /** * Gets the next sitting position to use for eating, just keeps iterating the aviable positions, so we do not have to keep track of who is where. * diff --git a/src/main/java/com/minecolonies/core/colony/events/raid/RaidManager.java b/src/main/java/com/minecolonies/core/colony/events/raid/RaidManager.java index 8df3cfece8f..78284ca8850 100644 --- a/src/main/java/com/minecolonies/core/colony/events/raid/RaidManager.java +++ b/src/main/java/com/minecolonies/core/colony/events/raid/RaidManager.java @@ -896,7 +896,7 @@ public BlockPos getRandomBuilding() for (int i = 0; i < possibleGuards.size() && i <= 3; i++) { - ((AbstractEntityAIGuard) possibleGuards.get(i).getCitizenData().getJob().getWorkerAI()).setNextPatrolTarget(lastBuilding); + ((AbstractEntityAIGuard) possibleGuards.get(i).getCitizenData().getJob().getWorkerAI()).setNextPatrolTargetAndMove(lastBuilding); } } diff --git a/src/main/java/com/minecolonies/core/entity/ai/workers/crafting/EntityAIWorkSmelter.java b/src/main/java/com/minecolonies/core/entity/ai/workers/crafting/EntityAIWorkSmelter.java index 7b0dbc37fa0..7bf6dcbb918 100755 --- a/src/main/java/com/minecolonies/core/entity/ai/workers/crafting/EntityAIWorkSmelter.java +++ b/src/main/java/com/minecolonies/core/entity/ai/workers/crafting/EntityAIWorkSmelter.java @@ -30,7 +30,7 @@ import net.minecraft.world.InteractionHand; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.entity.FurnaceBlockEntity; -import net.minecraft.network.chat.Component; +import net.neoforged.neoforge.items.wrapper.InvWrapper; import org.jetbrains.annotations.NotNull; import java.util.List; diff --git a/src/main/java/com/minecolonies/core/entity/ai/workers/guard/AbstractEntityAIGuard.java b/src/main/java/com/minecolonies/core/entity/ai/workers/guard/AbstractEntityAIGuard.java index bcff46753cd..3a365ba083a 100755 --- a/src/main/java/com/minecolonies/core/entity/ai/workers/guard/AbstractEntityAIGuard.java +++ b/src/main/java/com/minecolonies/core/entity/ai/workers/guard/AbstractEntityAIGuard.java @@ -520,7 +520,7 @@ public IAIState patrol() if (currentPatrolPoint != null) { - setNextPatrolTarget(currentPatrolPoint); + setNextPatrolTargetAndMove(currentPatrolPoint); } } } @@ -561,11 +561,11 @@ public IAIState patrolMine() final MinerLevel level = buildingMiner.getFirstModuleOccurance(MinerLevelManagementModule.class).getCurrentLevel(); if (level == null) { - setNextPatrolTarget(buildingMiner.getPosition()); + setNextPatrolTargetAndMove(buildingMiner.getPosition()); } else { - setNextPatrolTarget(level.getRandomCompletedNode(buildingMiner)); + setNextPatrolTargetAndMove(level.getRandomCompletedNode(buildingMiner)); } } else @@ -586,14 +586,9 @@ public IAIState patrolMine() * * @param target the next patrol target. */ - public void setNextPatrolTarget(final BlockPos target) + public void setNextPatrolTargetAndMove(final BlockPos target) { currentPatrolPoint = target; - if (getState() == CombatAIStates.NO_TARGET) - { - worker.isWorkerAtSiteWithMove(currentPatrolPoint, 2); - } - registerTarget(new AIOneTimeEventTarget(() -> { if (getState() == CombatAIStates.NO_TARGET) 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 682f1bdfa25..c44ae44f4cf 100755 --- a/src/main/java/com/minecolonies/core/entity/citizen/EntityCitizen.java +++ b/src/main/java/com/minecolonies/core/entity/citizen/EntityCitizen.java @@ -30,6 +30,7 @@ import com.minecolonies.api.inventory.InventoryCitizen; import com.minecolonies.api.inventory.container.ContainerCitizenInventory; import com.minecolonies.api.items.ModItems; +import com.minecolonies.api.items.ModTags; import com.minecolonies.api.sounds.EventType; import com.minecolonies.api.util.*; import com.minecolonies.api.util.MessageUtils.MessagePriority; @@ -74,6 +75,8 @@ import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.tags.DamageTypeTags; +import net.minecraft.tags.FluidTags; +import net.minecraft.util.Mth; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.CombatRules; @@ -83,7 +86,10 @@ import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.*; +import net.minecraft.world.entity.ai.attributes.AttributeInstance; +import net.minecraft.world.entity.ai.attributes.AttributeModifier; import net.minecraft.world.entity.ai.attributes.Attributes; +import net.minecraft.world.entity.animal.FlyingAnimal; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; @@ -92,6 +98,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.ShieldItem; +import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.Level; import net.neoforged.neoforge.common.CommonHooks; @@ -477,6 +484,26 @@ private InteractionResult directPlayerInteraction(final Player player, final Int return InteractionResult.CONSUME; } + if (usedStack.is(ModTags.poisonous_food)) + { + usedStack.shrink(1); + player.setItemInHand(hand, usedStack); + + if (!level().isClientSide()) + { + getCitizenDiseaseHandler().setDisease(IColonyManager.getInstance().getCompatibilityManager().getRandomDisease()); + playSound(SoundEvents.VILLAGER_HURT, 1.0f, (float) SoundUtils.getRandomPitch(getRandom())); + getCitizenData().markDirty(20); + + MessageUtils.format(MESSAGE_INTERACTION_POISON, this.getCitizenData().getName()) + .withPriority(MessagePriority.DANGER) + .sendTo(player); + } + + interactionCooldown = 20 * 60 * 5; + return InteractionResult.CONSUME; + } + if (getCitizenDiseaseHandler().isSick()) { return null; @@ -551,7 +578,7 @@ private InteractionResult directPlayerInteraction(final Player player, final Int public boolean isInteractionItem(final ItemStack stack) { return ISFOOD.test(stack) || stack.getItem() == Items.BOOK || stack.getItem() == Items.GOLDEN_APPLE || stack.getItem() == Items.CACTUS - || stack.getItem() == Items.GLOWSTONE_DUST; + || stack.getItem() == Items.GLOWSTONE_DUST || stack.is(ModTags.poisonous_food); } /** diff --git a/src/main/java/com/minecolonies/core/entity/citizen/citizenhandlers/CitizenDiseaseHandler.java b/src/main/java/com/minecolonies/core/entity/citizen/citizenhandlers/CitizenDiseaseHandler.java index 41668e3dd14..b1ca192afa4 100755 --- a/src/main/java/com/minecolonies/core/entity/citizen/citizenhandlers/CitizenDiseaseHandler.java +++ b/src/main/java/com/minecolonies/core/entity/citizen/citizenhandlers/CitizenDiseaseHandler.java @@ -108,6 +108,11 @@ public void tick() } } + public void setDisease(final String disease) + { + this.disease = disease; + } + /** * Check if the citizen may become sick. * diff --git a/src/main/java/com/minecolonies/core/generation/defaults/DefaultItemTagsProvider.java b/src/main/java/com/minecolonies/core/generation/defaults/DefaultItemTagsProvider.java index 7fc900b00fe..04af33b764b 100644 --- a/src/main/java/com/minecolonies/core/generation/defaults/DefaultItemTagsProvider.java +++ b/src/main/java/com/minecolonies/core/generation/defaults/DefaultItemTagsProvider.java @@ -171,6 +171,12 @@ protected void addTags(final @NotNull HolderLookup.Provider provider) .add(Items.RAW_COPPER) .add(Items.RAW_GOLD); + tag(ModTags.poisonous_food) + .add(Items.POISONOUS_POTATO) + .add(Items.CHICKEN) + .add(Items.SPIDER_EYE) + .add(Items.ROTTEN_FLESH); + final Item[] paperExtras = getDomumExtra(ExtraBlockType.BASE_PAPER, ExtraBlockType.LIGHT_PAPER); tag(ModTags.crafterIngredient.get(TagConstants.CRAFTING_BAKER)) @@ -268,7 +274,6 @@ protected void addTags(final @NotNull HolderLookup.Provider provider) .add(ModItems.yogurt_with_berries) .add(ModItems.mutton_dinner) .add(ModItems.tortillas) - .add(ModItems.apple_pie) .add(ModItems.spicy_eggplant); tag(ModTags.crafterProductExclusions.get(TagConstants.CRAFTING_COOK)) 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 a8c762568fb..879a2dfea8f 100644 --- a/src/main/resources/assets/minecolonies/lang/manual_en_us.json +++ b/src/main/resources/assets/minecolonies/lang/manual_en_us.json @@ -1757,6 +1757,7 @@ "com.minecolonies.coremod.interaction.notnow": "%s: I can't do that right now", "com.minecolonies.coremod.interaction.ouch": "%s: Oh is that for me... Ouch!", "com.minecolonies.coremod.interaction.visitor.food": "Tasty food? I guess I'll stay a bit longer here", + "com.minecolonies.coremod.interaction.poison": "Ugh! What was that? I'm not feeling very well now.", "com.minecolonies.coremod.gui.townhall.happiness.homelessness": "Housing", "com.minecolonies.coremod.gui.townhall.happiness.unemployment": "Unemployment",