From 92f78d7a3142ae3b99062930a69882f89af7f2b6 Mon Sep 17 00:00:00 2001 From: TheRealWormbo Date: Thu, 13 Apr 2023 17:02:04 +0200 Subject: [PATCH] Fix water bottle filling not working in the end dimension While in the End, don't attempt to pick up ender air while looking at fluids. This more generic approach will disallow ender air bottling while looking at lava, even if attempting to use a bottle this way wouldn't do anything by default, but it's less likely to cause issues with other mods that attempt to bottle fluids from the world. --- .../common/item/material/EnderAirItem.java | 19 +++++++++++++++++-- web/changelog.md | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Xplat/src/main/java/vazkii/botania/common/item/material/EnderAirItem.java b/Xplat/src/main/java/vazkii/botania/common/item/material/EnderAirItem.java index 126dd333b5..9699530589 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/material/EnderAirItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/material/EnderAirItem.java @@ -8,6 +8,7 @@ */ package vazkii.botania.common.item.material; +import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; @@ -19,8 +20,12 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; +import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.Level; +import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; import org.jetbrains.annotations.NotNull; @@ -43,7 +48,7 @@ public static InteractionResultHolder onPlayerInteract(Player player, return InteractionResultHolder.pass(stack); } - if ((world.dimension() == Level.END && isClearFromDragonBreath(world, player.getBoundingBox().inflate(3.5))) + if ((world.dimension() == Level.END && isClearFromDragonBreath(world, player.getBoundingBox().inflate(3.5)) && notAimingAtFluid(world, player)) || pickupFromEntity(world, player.getBoundingBox().inflate(1.0))) { if (!world.isClientSide) { @@ -51,14 +56,24 @@ public static InteractionResultHolder onPlayerInteract(Player player, player.getInventory().placeItemBackInInventory(enderAir); stack.shrink(1); world.playSound(null, player.blockPosition(), SoundEvents.ITEM_PICKUP, SoundSource.NEUTRAL, 0.5F, 1F); + world.gameEvent(player, GameEvent.FLUID_PICKUP, player.position()); } - return InteractionResultHolder.success(stack); + return InteractionResultHolder.sidedSuccess(stack, world.isClientSide()); } return InteractionResultHolder.pass(stack); } + private static boolean notAimingAtFluid(Level world, Player player) { + BlockHitResult hitResult = getPlayerPOVHitResult(world, player, ClipContext.Fluid.ANY); + if (hitResult.getType() == HitResult.Type.BLOCK) { + BlockPos pos = hitResult.getBlockPos(); + return world.mayInteract(player, pos) && world.getFluidState(pos).isEmpty(); + } + return true; + } + public static boolean isClearFromDragonBreath(Level world, AABB aabb) { List list = world.getEntitiesOfClass(AreaEffectCloud.class, aabb, entity -> entity != null && entity.isAlive() diff --git a/web/changelog.md b/web/changelog.md index 62b5a0f94e..6eda0c226c 100644 --- a/web/changelog.md +++ b/web/changelog.md @@ -35,6 +35,7 @@ and start a new "Upcoming" section. * Fix: Made Teru Teru Bozu truely happy during clear weather again (Wormbo) * Fix: Leaves placed by Worldshaper's Astrolabe no longer decay * Fix: Some items being missing from Forge equipment tags and Fabric bow tag +* Fix: Using an empty bottle in the end will not attempt to pick up Ender Air if the player is aiming at a liquid (Wormbo) * Fix: Horn of the Canopy breaking persistent leaves * Fix: Thermalily not updating comparators properly * Fix: Kindle Lens not creating Soul Fire when it should