From c8169fff887c7f53d45330e987e51354f2be58d7 Mon Sep 17 00:00:00 2001 From: Raycoms Date: Mon, 9 Sep 2024 12:20:44 +0200 Subject: [PATCH] fix some porting issues --- .../registry/ColonyEventTypeRegistryEntry.java | 4 ++-- .../core/colony/managers/EventManager.java | 2 +- .../core/entity/ai/minimal/EntityAIEatTask.java | 8 +------- .../core/entity/ai/workers/guard/DruidCombatAI.java | 4 ++-- .../core/entity/citizen/EntityCitizen.java | 11 ++++------- .../core/entity/visitor/VisitorCitizen.java | 11 ++--------- .../core/items/ItemScepterLumberjack.java | 2 +- 7 files changed, 13 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/minecolonies/api/colony/colonyEvents/registry/ColonyEventTypeRegistryEntry.java b/src/main/java/com/minecolonies/api/colony/colonyEvents/registry/ColonyEventTypeRegistryEntry.java index 7c0db17b931..fbd65201cb3 100755 --- a/src/main/java/com/minecolonies/api/colony/colonyEvents/registry/ColonyEventTypeRegistryEntry.java +++ b/src/main/java/com/minecolonies/api/colony/colonyEvents/registry/ColonyEventTypeRegistryEntry.java @@ -50,9 +50,9 @@ public ColonyEventTypeRegistryEntry(@NotNull final TriFunction effect; - final ItemStack stack = new ItemStack(Items.SPLASH_POTION); + final ItemStack stack = Items.SPLASH_POTION.getDefaultInstance(); boolean gotMaterial = false; BiPredicate predicate; if (user.getCitizenColonyHandler().getColony().getResearchManager().getResearchEffects().getEffectStrength(DRUID_USE_POTIONS) > 0 @@ -151,7 +151,7 @@ protected void doAttack(final LivingEntity target) predicate = (entity, eff) -> !AbstractEntityAIGuard.isAttackableTarget(user, entity); } - stack.set(DataComponents.POTION_CONTENTS, new PotionContents(Holder.direct(new Potion(new MobEffectInstance(effect, time, gotMaterial ? 2 : 0))))); + stack.set(DataComponents.POTION_CONTENTS, PotionContents.EMPTY.withEffectAdded((new MobEffectInstance(effect, time, gotMaterial ? 2 : 0)))); DruidPotionEntity.throwPotionAt(stack, target, user, user.getCommandSenderWorld(), POTION_VELOCITY, inaccuracy, predicate); if (gotMaterial) 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 2be1d2f2077..b2dccc56243 100755 --- a/src/main/java/com/minecolonies/core/entity/citizen/EntityCitizen.java +++ b/src/main/java/com/minecolonies/core/entity/citizen/EntityCitizen.java @@ -593,12 +593,11 @@ private void childFoodInteraction(final ItemStack usedStack, final Player player if (!level().isClientSide()) { - ItemStackUtils.consumeFood(usedStack, this, player.getInventory()); addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SPEED, 300)); playSound(SoundEvents.GENERIC_EAT, 1.5f, (float) SoundUtils.getRandomPitch(getRandom())); - new ItemParticleEffectMessage(usedStack, getX(), getY(), getZ(), getXRot(), getYRot(), getEyeHeight()) - .sendToTrackingEntity(this); + new ItemParticleEffectMessage(usedStack, getX(), getY(), getZ(), getXRot(), getYRot(), getEyeHeight()).sendToTrackingEntity(this); + ItemStackUtils.consumeFood(usedStack, this, player.getInventory()); } } else @@ -626,12 +625,10 @@ private void eatFoodInteraction(final ItemStack usedStack, final Player player, { if (!level().isClientSide()) { - ItemStackUtils.consumeFood(usedStack, this, player.getInventory()); - playSound(SoundEvents.GENERIC_EAT, 1.5f, (float) SoundUtils.getRandomPitch(getRandom())); // Position needs to be centered on citizen, Eat AI wrong too? - new ItemParticleEffectMessage(usedStack, getX(), getY(), getZ(), getXRot(), getYRot(), getEyeHeight()) - .sendToTrackingEntity(this); + new ItemParticleEffectMessage(usedStack, getX(), getY(), getZ(), getXRot(), getYRot(), getEyeHeight()).sendToTrackingEntity(this); + ItemStackUtils.consumeFood(usedStack, this, player.getInventory()); } interactionCooldown = 100; diff --git a/src/main/java/com/minecolonies/core/entity/visitor/VisitorCitizen.java b/src/main/java/com/minecolonies/core/entity/visitor/VisitorCitizen.java index 9e7b52840c7..5a60061c280 100644 --- a/src/main/java/com/minecolonies/core/entity/visitor/VisitorCitizen.java +++ b/src/main/java/com/minecolonies/core/entity/visitor/VisitorCitizen.java @@ -513,16 +513,9 @@ private InteractionResult directPlayerInteraction(final Player player, final Int { if (!level().isClientSide()) { - ItemStackUtils.consumeFood(usedStack, this, player.getInventory()); playSound(SoundEvents.GENERIC_EAT, 1.5f, (float) SoundUtils.getRandomPitch(getRandom())); - new ItemParticleEffectMessage(usedStack, - getX(), - getY(), - getZ(), - getXRot(), - getYRot(), - getEyeHeight()).sendToTrackingEntity(this); - + new ItemParticleEffectMessage(usedStack, getX(), getY(), getZ(), getXRot(), getYRot(), getEyeHeight()).sendToTrackingEntity(this); + ItemStackUtils.consumeFood(usedStack, this, player.getInventory()); MessageUtils.forCitizen(this, MESSAGE_INTERACTION_VISITOR_FOOD).sendTo(player); } return InteractionResult.CONSUME; diff --git a/src/main/java/com/minecolonies/core/items/ItemScepterLumberjack.java b/src/main/java/com/minecolonies/core/items/ItemScepterLumberjack.java index f10cecae24e..d165704618d 100644 --- a/src/main/java/com/minecolonies/core/items/ItemScepterLumberjack.java +++ b/src/main/java/com/minecolonies/core/items/ItemScepterLumberjack.java @@ -131,7 +131,7 @@ public List getOverlayBoxes(@NotNull final Level world, @NotNull fin { final OverlayBox anchorBox = new OverlayBox(buildingId.id(), RED_OVERLAY, 0.02f, true); - if (box != null) + if (box != null && box.getA() != null && box.getB() != null) { final AABB bounds = AABB.encapsulatingFullBlocks(box.getA(), box.getB().offset(1, 1, 1)).inflate(1); // inflate(1) is due to implementation of BlockPosUtil.isInArea