From 8a5d1f416cc3c9d8a5a0d9c4f56bbf253b9d6e11 Mon Sep 17 00:00:00 2001 From: Raycoms Date: Wed, 20 Nov 2024 16:51:38 +0100 Subject: [PATCH 1/6] fix 10464 --- .../colony/buildings/modules/RestaurantMenuModule.java | 5 +++++ .../colony/buildings/workerbuildings/BuildingCook.java | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) 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 1f38f027cae..b9aa5f5b7fa 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 @@ -190,6 +190,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 f64b2defdd2..371251c6003 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 @@ -66,7 +66,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)); } /** @@ -90,6 +89,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. * From 8363154306e1295e18e026d3b4c0ed818d965cf8 Mon Sep 17 00:00:00 2001 From: Raycoms Date: Wed, 20 Nov 2024 16:53:12 +0100 Subject: [PATCH 2/6] fix #10469 --- .../minecolonies/data/minecolonies/tags/items/cook_product.json | 1 - .../core/generation/defaults/DefaultItemTagsProvider.java | 1 - 2 files changed, 2 deletions(-) diff --git a/src/datagen/generated/minecolonies/data/minecolonies/tags/items/cook_product.json b/src/datagen/generated/minecolonies/data/minecolonies/tags/items/cook_product.json index cc9ed349941..e6e2e7f4548 100644 --- a/src/datagen/generated/minecolonies/data/minecolonies/tags/items/cook_product.json +++ b/src/datagen/generated/minecolonies/data/minecolonies/tags/items/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/main/java/com/minecolonies/core/generation/defaults/DefaultItemTagsProvider.java b/src/main/java/com/minecolonies/core/generation/defaults/DefaultItemTagsProvider.java index deffb6ebc8e..0f723e22c1b 100644 --- a/src/main/java/com/minecolonies/core/generation/defaults/DefaultItemTagsProvider.java +++ b/src/main/java/com/minecolonies/core/generation/defaults/DefaultItemTagsProvider.java @@ -268,7 +268,6 @@ protected void addTags(final HolderLookup.Provider p_256380_) .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)) From aa7f9397fb9086448b4910cdcecbab0e1b515796 Mon Sep 17 00:00:00 2001 From: Raycoms Date: Wed, 20 Nov 2024 19:28:16 +0100 Subject: [PATCH 3/6] fix #10462 and weird barracks guard sick issues --- .../ICitizenDiseaseHandler.java | 6 + .../buildings/AbstractBuildingGuards.java | 4 +- .../core/colony/events/raid/RaidManager.java | 2 +- .../workers/guard/AbstractEntityAIGuard.java | 18 +- .../core/entity/citizen/EntityCitizen.java | 218 +++++++++++++++++- .../CitizenDiseaseHandler.java | 5 + 6 files changed, 242 insertions(+), 11 deletions(-) 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/core/colony/buildings/AbstractBuildingGuards.java b/src/main/java/com/minecolonies/core/colony/buildings/AbstractBuildingGuards.java index 3ce7cb26014..da7c23b0b24 100755 --- a/src/main/java/com/minecolonies/core/colony/buildings/AbstractBuildingGuards.java +++ b/src/main/java/com/minecolonies/core/colony/buildings/AbstractBuildingGuards.java @@ -394,9 +394,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/events/raid/RaidManager.java b/src/main/java/com/minecolonies/core/colony/events/raid/RaidManager.java index 6afd13e8eb9..49bda098270 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 @@ -893,7 +893,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/guard/AbstractEntityAIGuard.java b/src/main/java/com/minecolonies/core/entity/ai/workers/guard/AbstractEntityAIGuard.java index 449e3cd1adc..f1eae92bf9a 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,13 +586,17 @@ 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) + registerTarget(new AIOneTimeEventTarget(() -> { - worker.isWorkerAtSiteWithMove(currentPatrolPoint, 2); - } + if (getState() == CombatAIStates.NO_TARGET) + { + return decide(); + } + return getState(); + })); } /** 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 973a1fa6ac0..93575a05034 100755 --- a/src/main/java/com/minecolonies/core/entity/citizen/EntityCitizen.java +++ b/src/main/java/com/minecolonies/core/entity/citizen/EntityCitizen.java @@ -74,6 +74,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 +85,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,8 +97,10 @@ 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.minecraft.world.level.material.FluidState; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.Shapes; @@ -131,6 +138,10 @@ @SuppressWarnings({"PMD.ExcessiveImports", "PMD.CouplingBetweenObjects", "PMD.ExcessiveClassLength"}) public class EntityCitizen extends AbstractEntityCitizen implements IThreatTableEntity { + private static final UUID SLOW_FALLING_ID = UUID.fromString("A5B6CF2A-2F7C-31EF-9022-7C3E7D5E6ABA"); + private static final AttributeModifier SLOW_FALLING = new AttributeModifier(SLOW_FALLING_ID, "Slow falling acceleration reduction", -0.07, AttributeModifier.Operation.ADDITION); // Add -0.07 to 0.08 so we get the vanilla default of 0.01 + + /** * Cooldown for calling help, in ticks. */ @@ -486,6 +497,24 @@ private InteractionResult directPlayerInteraction(final Player player, final Int return InteractionResult.CONSUME; } + if (usedStack.getItem() == Items.POISONOUS_POTATO) + { + usedStack.shrink(1); + player.setItemInHand(hand, usedStack); + + if (!level.isClientSide()) + { + if (getRandom().nextInt(3) == 0) + { + getCitizenDiseaseHandler().setDisease(IColonyManager.getInstance().getCompatibilityManager().getRandomDisease()); + playSound(SoundEvents.VILLAGER_HURT, 1.0f, (float) SoundUtils.getRandomPitch(getRandom())); + } + } + + interactionCooldown = 20 * 60 * 5; + return InteractionResult.CONSUME; + } + if (getCitizenDiseaseHandler().isSick()) { return null; @@ -560,7 +589,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.getItem() == Items.POISONOUS_POTATO; } /** @@ -1514,6 +1543,193 @@ private void performMoveAway(@Nullable final Entity attacker) } } + @Override + public void travel(Vec3 p_21280_) + { + if (this.isControlledByLocalInstance()) + { + double d0 = 0.08D; + AttributeInstance gravity = this.getAttribute(net.minecraftforge.common.ForgeMod.ENTITY_GRAVITY.get()); + boolean flag = this.getDeltaMovement().y <= 0.0D; + if (flag && this.hasEffect(MobEffects.SLOW_FALLING)) + { + if (!gravity.hasModifier(SLOW_FALLING)) + { + gravity.addTransientModifier(SLOW_FALLING); + } + } + else if (gravity.hasModifier(SLOW_FALLING)) + { + gravity.removeModifier(SLOW_FALLING); + } + d0 = gravity.getValue(); + + FluidState fluidstate = this.level().getFluidState(this.blockPosition()); + if ((this.isInWater() || (this.isInFluidType(fluidstate) && fluidstate.getFluidType() != net.minecraftforge.common.ForgeMod.LAVA_TYPE.get())) + && this.isAffectedByFluids() && !this.canStandOnFluid(fluidstate)) + { + if (this.isInWater() || (this.isInFluidType(fluidstate) && !this.moveInFluid(fluidstate, p_21280_, d0))) + { + double d9 = this.getY(); + float f4 = this.isSprinting() ? 0.9F : this.getWaterSlowDown(); + float f5 = 0.02F; + float f6 = (float) EnchantmentHelper.getDepthStrider(this); + if (f6 > 3.0F) + { + f6 = 3.0F; + } + + if (!this.onGround()) + { + f6 *= 0.5F; + } + + if (f6 > 0.0F) + { + f4 += (0.54600006F - f4) * f6 / 3.0F; + f5 += (this.getSpeed() - f5) * f6 / 3.0F; + } + + if (this.hasEffect(MobEffects.DOLPHINS_GRACE)) + { + f4 = 0.96F; + } + + f5 *= (float) this.getAttribute(net.minecraftforge.common.ForgeMod.SWIM_SPEED.get()).getValue(); + this.moveRelative(f5, p_21280_); + this.move(MoverType.SELF, this.getDeltaMovement()); + Vec3 vec36 = this.getDeltaMovement(); + if (this.horizontalCollision && this.onClimbable()) + { + // We handle climbing ourselves + return; + } + + this.setDeltaMovement(vec36.multiply((double) f4, (double) 0.8F, (double) f4)); + Vec3 vec32 = this.getFluidFallingAdjustedMovement(d0, flag, this.getDeltaMovement()); + this.setDeltaMovement(vec32); + if (this.horizontalCollision && this.isFree(vec32.x, vec32.y + (double) 0.6F - this.getY() + d9, vec32.z)) + { + this.setDeltaMovement(vec32.x, (double) 0.3F, vec32.z); + } + } + } + else if (this.isInLava() && this.isAffectedByFluids() && !this.canStandOnFluid(fluidstate)) + { + double d8 = this.getY(); + this.moveRelative(0.02F, p_21280_); + this.move(MoverType.SELF, this.getDeltaMovement()); + if (this.getFluidHeight(FluidTags.LAVA) <= this.getFluidJumpThreshold()) + { + this.setDeltaMovement(this.getDeltaMovement().multiply(0.5D, (double) 0.8F, 0.5D)); + Vec3 vec33 = this.getFluidFallingAdjustedMovement(d0, flag, this.getDeltaMovement()); + this.setDeltaMovement(vec33); + } + else + { + this.setDeltaMovement(this.getDeltaMovement().scale(0.5D)); + } + + if (!this.isNoGravity()) + { + this.setDeltaMovement(this.getDeltaMovement().add(0.0D, -d0 / 4.0D, 0.0D)); + } + + Vec3 vec34 = this.getDeltaMovement(); + if (this.horizontalCollision && this.isFree(vec34.x, vec34.y + (double) 0.6F - this.getY() + d8, vec34.z)) + { + this.setDeltaMovement(vec34.x, (double) 0.3F, vec34.z); + } + } + else if (this.isFallFlying()) + { + this.checkSlowFallDistance(); + Vec3 vec3 = this.getDeltaMovement(); + Vec3 vec31 = this.getLookAngle(); + float f = this.getXRot() * ((float) Math.PI / 180F); + double d1 = Math.sqrt(vec31.x * vec31.x + vec31.z * vec31.z); + double d3 = vec3.horizontalDistance(); + double d4 = vec31.length(); + double d5 = Math.cos((double) f); + d5 = d5 * d5 * Math.min(1.0D, d4 / 0.4D); + vec3 = this.getDeltaMovement().add(0.0D, d0 * (-1.0D + d5 * 0.75D), 0.0D); + if (vec3.y < 0.0D && d1 > 0.0D) + { + double d6 = vec3.y * -0.1D * d5; + vec3 = vec3.add(vec31.x * d6 / d1, d6, vec31.z * d6 / d1); + } + + if (f < 0.0F && d1 > 0.0D) + { + double d10 = d3 * (double) (-Mth.sin(f)) * 0.04D; + vec3 = vec3.add(-vec31.x * d10 / d1, d10 * 3.2D, -vec31.z * d10 / d1); + } + + if (d1 > 0.0D) + { + vec3 = vec3.add((vec31.x / d1 * d3 - vec3.x) * 0.1D, 0.0D, (vec31.z / d1 * d3 - vec3.z) * 0.1D); + } + + this.setDeltaMovement(vec3.multiply((double) 0.99F, (double) 0.98F, (double) 0.99F)); + this.move(MoverType.SELF, this.getDeltaMovement()); + if (this.horizontalCollision && !this.level().isClientSide) + { + double d11 = this.getDeltaMovement().horizontalDistance(); + double d7 = d3 - d11; + float f1 = (float) (d7 * 10.0D - 3.0D); + if (f1 > 0.0F) + { + this.playSound(f1 > 4 ? this.getFallSounds().big() : this.getFallSounds().small(), 1.0F, 1.0F); + this.hurt(this.damageSources().flyIntoWall(), f1); + } + } + + if (this.onGround() && !this.level().isClientSide) + { + this.setSharedFlag(7, false); + } + } + else + { + BlockPos blockpos = this.getBlockPosBelowThatAffectsMyMovement(); + float f2 = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getFriction(level(), this.getBlockPosBelowThatAffectsMyMovement(), this); + float f3 = this.onGround() ? f2 * 0.91F : 0.91F; + Vec3 vec35 = this.handleRelativeFrictionAndCalculateMovement(p_21280_, f2); + double d2 = vec35.y; + if (this.hasEffect(MobEffects.LEVITATION)) + { + d2 += (0.05D * (double) (this.getEffect(MobEffects.LEVITATION).getAmplifier() + 1) - vec35.y) * 0.2D; + } + else if (this.level().isClientSide && !this.level().hasChunkAt(blockpos)) + { + if (this.getY() > (double) this.level().getMinBuildHeight()) + { + d2 = -0.1D; + } + else + { + d2 = 0.0D; + } + } + else if (!this.isNoGravity()) + { + d2 -= d0; + } + + if (this.shouldDiscardFriction()) + { + this.setDeltaMovement(vec35.x, d2, vec35.z); + } + else + { + this.setDeltaMovement(vec35.x * (double) f3, d2 * (double) 0.98F, vec35.z * (double) f3); + } + } + } + + this.calculateEntityAnimation(this instanceof FlyingAnimal); + } + @Override public void callForHelp(final Entity attacker, final int guardHelpRange) { 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. * From 8ed5e104611beec11aa56c65f71ddde51001bc3d Mon Sep 17 00:00:00 2001 From: Raycoms Date: Wed, 20 Nov 2024 23:33:59 +0100 Subject: [PATCH 4/6] make it tag based and add msg --- .../data/minecolonies/tags/items/poisonousfood.json | 8 ++++++++ src/main/java/com/minecolonies/api/items/ModTags.java | 2 ++ .../com/minecolonies/api/util/constant/TagConstants.java | 1 + .../api/util/constant/TranslationConstants.java | 2 ++ .../minecolonies/core/entity/citizen/EntityCitizen.java | 8 ++++++-- .../core/generation/defaults/DefaultItemTagsProvider.java | 6 ++++++ .../resources/assets/minecolonies/lang/manual_en_us.json | 1 + 7 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 src/datagen/generated/minecolonies/data/minecolonies/tags/items/poisonousfood.json diff --git a/src/datagen/generated/minecolonies/data/minecolonies/tags/items/poisonousfood.json b/src/datagen/generated/minecolonies/data/minecolonies/tags/items/poisonousfood.json new file mode 100644 index 00000000000..9e58ef6d925 --- /dev/null +++ b/src/datagen/generated/minecolonies/data/minecolonies/tags/items/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/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 04fea8a4853..a9409737970 100755 --- a/src/main/java/com/minecolonies/api/util/constant/TranslationConstants.java +++ b/src/main/java/com/minecolonies/api/util/constant/TranslationConstants.java @@ -632,6 +632,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/entity/citizen/EntityCitizen.java b/src/main/java/com/minecolonies/core/entity/citizen/EntityCitizen.java index 93575a05034..0dfb3e8404d 100755 --- a/src/main/java/com/minecolonies/core/entity/citizen/EntityCitizen.java +++ b/src/main/java/com/minecolonies/core/entity/citizen/EntityCitizen.java @@ -31,6 +31,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; @@ -497,7 +498,7 @@ private InteractionResult directPlayerInteraction(final Player player, final Int return InteractionResult.CONSUME; } - if (usedStack.getItem() == Items.POISONOUS_POTATO) + if (usedStack.is(ModTags.poisonous_food)) { usedStack.shrink(1); player.setItemInHand(hand, usedStack); @@ -509,6 +510,9 @@ private InteractionResult directPlayerInteraction(final Player player, final Int getCitizenDiseaseHandler().setDisease(IColonyManager.getInstance().getCompatibilityManager().getRandomDisease()); playSound(SoundEvents.VILLAGER_HURT, 1.0f, (float) SoundUtils.getRandomPitch(getRandom())); } + MessageUtils.format(MESSAGE_INTERACTION_POISON, this.getCitizenData().getName()) + .withPriority(MessagePriority.DANGER) + .sendTo(player); } interactionCooldown = 20 * 60 * 5; @@ -589,7 +593,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.POISONOUS_POTATO; + || stack.getItem() == Items.GLOWSTONE_DUST || stack.is(ModTags.poisonous_food); } /** 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 0f723e22c1b..532a22de771 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 HolderLookup.Provider p_256380_) .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)) 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 6c9047a6175..368cf13ea8b 100644 --- a/src/main/resources/assets/minecolonies/lang/manual_en_us.json +++ b/src/main/resources/assets/minecolonies/lang/manual_en_us.json @@ -1755,6 +1755,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", From 4a9ca3a2eb4f54953790f922911a2f574041f4f1 Mon Sep 17 00:00:00 2001 From: Raycoms Date: Thu, 21 Nov 2024 13:45:35 +0100 Subject: [PATCH 5/6] some fixes to disease application + empty grave bounding box --- .../minecolonies/core/blocks/BlockMinecoloniesGrave.java | 6 ++++++ .../minecolonies/core/entity/citizen/EntityCitizen.java | 9 ++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/minecolonies/core/blocks/BlockMinecoloniesGrave.java b/src/main/java/com/minecolonies/core/blocks/BlockMinecoloniesGrave.java index 5ef87fbc00a..816c06101b7 100644 --- a/src/main/java/com/minecolonies/core/blocks/BlockMinecoloniesGrave.java +++ b/src/main/java/com/minecolonies/core/blocks/BlockMinecoloniesGrave.java @@ -196,6 +196,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/entity/citizen/EntityCitizen.java b/src/main/java/com/minecolonies/core/entity/citizen/EntityCitizen.java index 0dfb3e8404d..bdc4e9a7655 100755 --- a/src/main/java/com/minecolonies/core/entity/citizen/EntityCitizen.java +++ b/src/main/java/com/minecolonies/core/entity/citizen/EntityCitizen.java @@ -505,11 +505,10 @@ private InteractionResult directPlayerInteraction(final Player player, final Int if (!level.isClientSide()) { - if (getRandom().nextInt(3) == 0) - { - getCitizenDiseaseHandler().setDisease(IColonyManager.getInstance().getCompatibilityManager().getRandomDisease()); - playSound(SoundEvents.VILLAGER_HURT, 1.0f, (float) SoundUtils.getRandomPitch(getRandom())); - } + 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); From 59c4a310c41062fb32346e4603285af660322fb9 Mon Sep 17 00:00:00 2001 From: Raycoms Date: Sun, 24 Nov 2024 10:23:13 +0100 Subject: [PATCH 6/6] remove --- .../core/entity/citizen/EntityCitizen.java | 187 ------------------ 1 file changed, 187 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 bdc4e9a7655..11de28a8eb8 100755 --- a/src/main/java/com/minecolonies/core/entity/citizen/EntityCitizen.java +++ b/src/main/java/com/minecolonies/core/entity/citizen/EntityCitizen.java @@ -1546,193 +1546,6 @@ private void performMoveAway(@Nullable final Entity attacker) } } - @Override - public void travel(Vec3 p_21280_) - { - if (this.isControlledByLocalInstance()) - { - double d0 = 0.08D; - AttributeInstance gravity = this.getAttribute(net.minecraftforge.common.ForgeMod.ENTITY_GRAVITY.get()); - boolean flag = this.getDeltaMovement().y <= 0.0D; - if (flag && this.hasEffect(MobEffects.SLOW_FALLING)) - { - if (!gravity.hasModifier(SLOW_FALLING)) - { - gravity.addTransientModifier(SLOW_FALLING); - } - } - else if (gravity.hasModifier(SLOW_FALLING)) - { - gravity.removeModifier(SLOW_FALLING); - } - d0 = gravity.getValue(); - - FluidState fluidstate = this.level().getFluidState(this.blockPosition()); - if ((this.isInWater() || (this.isInFluidType(fluidstate) && fluidstate.getFluidType() != net.minecraftforge.common.ForgeMod.LAVA_TYPE.get())) - && this.isAffectedByFluids() && !this.canStandOnFluid(fluidstate)) - { - if (this.isInWater() || (this.isInFluidType(fluidstate) && !this.moveInFluid(fluidstate, p_21280_, d0))) - { - double d9 = this.getY(); - float f4 = this.isSprinting() ? 0.9F : this.getWaterSlowDown(); - float f5 = 0.02F; - float f6 = (float) EnchantmentHelper.getDepthStrider(this); - if (f6 > 3.0F) - { - f6 = 3.0F; - } - - if (!this.onGround()) - { - f6 *= 0.5F; - } - - if (f6 > 0.0F) - { - f4 += (0.54600006F - f4) * f6 / 3.0F; - f5 += (this.getSpeed() - f5) * f6 / 3.0F; - } - - if (this.hasEffect(MobEffects.DOLPHINS_GRACE)) - { - f4 = 0.96F; - } - - f5 *= (float) this.getAttribute(net.minecraftforge.common.ForgeMod.SWIM_SPEED.get()).getValue(); - this.moveRelative(f5, p_21280_); - this.move(MoverType.SELF, this.getDeltaMovement()); - Vec3 vec36 = this.getDeltaMovement(); - if (this.horizontalCollision && this.onClimbable()) - { - // We handle climbing ourselves - return; - } - - this.setDeltaMovement(vec36.multiply((double) f4, (double) 0.8F, (double) f4)); - Vec3 vec32 = this.getFluidFallingAdjustedMovement(d0, flag, this.getDeltaMovement()); - this.setDeltaMovement(vec32); - if (this.horizontalCollision && this.isFree(vec32.x, vec32.y + (double) 0.6F - this.getY() + d9, vec32.z)) - { - this.setDeltaMovement(vec32.x, (double) 0.3F, vec32.z); - } - } - } - else if (this.isInLava() && this.isAffectedByFluids() && !this.canStandOnFluid(fluidstate)) - { - double d8 = this.getY(); - this.moveRelative(0.02F, p_21280_); - this.move(MoverType.SELF, this.getDeltaMovement()); - if (this.getFluidHeight(FluidTags.LAVA) <= this.getFluidJumpThreshold()) - { - this.setDeltaMovement(this.getDeltaMovement().multiply(0.5D, (double) 0.8F, 0.5D)); - Vec3 vec33 = this.getFluidFallingAdjustedMovement(d0, flag, this.getDeltaMovement()); - this.setDeltaMovement(vec33); - } - else - { - this.setDeltaMovement(this.getDeltaMovement().scale(0.5D)); - } - - if (!this.isNoGravity()) - { - this.setDeltaMovement(this.getDeltaMovement().add(0.0D, -d0 / 4.0D, 0.0D)); - } - - Vec3 vec34 = this.getDeltaMovement(); - if (this.horizontalCollision && this.isFree(vec34.x, vec34.y + (double) 0.6F - this.getY() + d8, vec34.z)) - { - this.setDeltaMovement(vec34.x, (double) 0.3F, vec34.z); - } - } - else if (this.isFallFlying()) - { - this.checkSlowFallDistance(); - Vec3 vec3 = this.getDeltaMovement(); - Vec3 vec31 = this.getLookAngle(); - float f = this.getXRot() * ((float) Math.PI / 180F); - double d1 = Math.sqrt(vec31.x * vec31.x + vec31.z * vec31.z); - double d3 = vec3.horizontalDistance(); - double d4 = vec31.length(); - double d5 = Math.cos((double) f); - d5 = d5 * d5 * Math.min(1.0D, d4 / 0.4D); - vec3 = this.getDeltaMovement().add(0.0D, d0 * (-1.0D + d5 * 0.75D), 0.0D); - if (vec3.y < 0.0D && d1 > 0.0D) - { - double d6 = vec3.y * -0.1D * d5; - vec3 = vec3.add(vec31.x * d6 / d1, d6, vec31.z * d6 / d1); - } - - if (f < 0.0F && d1 > 0.0D) - { - double d10 = d3 * (double) (-Mth.sin(f)) * 0.04D; - vec3 = vec3.add(-vec31.x * d10 / d1, d10 * 3.2D, -vec31.z * d10 / d1); - } - - if (d1 > 0.0D) - { - vec3 = vec3.add((vec31.x / d1 * d3 - vec3.x) * 0.1D, 0.0D, (vec31.z / d1 * d3 - vec3.z) * 0.1D); - } - - this.setDeltaMovement(vec3.multiply((double) 0.99F, (double) 0.98F, (double) 0.99F)); - this.move(MoverType.SELF, this.getDeltaMovement()); - if (this.horizontalCollision && !this.level().isClientSide) - { - double d11 = this.getDeltaMovement().horizontalDistance(); - double d7 = d3 - d11; - float f1 = (float) (d7 * 10.0D - 3.0D); - if (f1 > 0.0F) - { - this.playSound(f1 > 4 ? this.getFallSounds().big() : this.getFallSounds().small(), 1.0F, 1.0F); - this.hurt(this.damageSources().flyIntoWall(), f1); - } - } - - if (this.onGround() && !this.level().isClientSide) - { - this.setSharedFlag(7, false); - } - } - else - { - BlockPos blockpos = this.getBlockPosBelowThatAffectsMyMovement(); - float f2 = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getFriction(level(), this.getBlockPosBelowThatAffectsMyMovement(), this); - float f3 = this.onGround() ? f2 * 0.91F : 0.91F; - Vec3 vec35 = this.handleRelativeFrictionAndCalculateMovement(p_21280_, f2); - double d2 = vec35.y; - if (this.hasEffect(MobEffects.LEVITATION)) - { - d2 += (0.05D * (double) (this.getEffect(MobEffects.LEVITATION).getAmplifier() + 1) - vec35.y) * 0.2D; - } - else if (this.level().isClientSide && !this.level().hasChunkAt(blockpos)) - { - if (this.getY() > (double) this.level().getMinBuildHeight()) - { - d2 = -0.1D; - } - else - { - d2 = 0.0D; - } - } - else if (!this.isNoGravity()) - { - d2 -= d0; - } - - if (this.shouldDiscardFriction()) - { - this.setDeltaMovement(vec35.x, d2, vec35.z); - } - else - { - this.setDeltaMovement(vec35.x * (double) f3, d2 * (double) 0.98F, vec35.z * (double) f3); - } - } - } - - this.calculateEntityAnimation(this instanceof FlyingAnimal); - } - @Override public void callForHelp(final Entity attacker, final int guardHelpRange) {