From 9118584144aef605d557448c44735e764cc4b0e3 Mon Sep 17 00:00:00 2001 From: unilock Date: Thu, 1 Jun 2023 09:53:45 -0400 Subject: [PATCH] Only create Ender Air Bottles when aiming at nothing (HitResult.Type.MISS) Some mods add features that rely on using empty Glass Bottles on *blocks*, not just fluids. This commit allows that to happen by only creating Ender Air Bottles when the player is aiming at *nothing* - not a block *or* a fluid (instead of only checking for fluids) Fixes #4273 Signed-off-by: unilock --- .../botania/common/item/material/EnderAirItem.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 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 9699530589..0c32efc71c 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,7 +8,6 @@ */ 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; @@ -48,7 +47,7 @@ public static InteractionResultHolder onPlayerInteract(Player player, return InteractionResultHolder.pass(stack); } - if ((world.dimension() == Level.END && isClearFromDragonBreath(world, player.getBoundingBox().inflate(3.5)) && notAimingAtFluid(world, player)) + if ((world.dimension() == Level.END && isClearFromDragonBreath(world, player.getBoundingBox().inflate(3.5)) && aimingAtNothing(world, player)) || pickupFromEntity(world, player.getBoundingBox().inflate(1.0))) { if (!world.isClientSide) { @@ -65,13 +64,9 @@ public static InteractionResultHolder onPlayerInteract(Player player, return InteractionResultHolder.pass(stack); } - private static boolean notAimingAtFluid(Level world, Player player) { + private static boolean aimingAtNothing(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; + return hitResult.getType() == HitResult.Type.MISS; } public static boolean isClearFromDragonBreath(Level world, AABB aabb) {