Skip to content

Commit

Permalink
Only create Ender Air Bottles when aiming at nothing (HitResult.Type.…
Browse files Browse the repository at this point in the history
…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 VazkiiMods#4273

Signed-off-by: unilock <[email protected]>
  • Loading branch information
unilock committed Jun 1, 2023
1 parent 92f78d7 commit 9118584
Showing 1 changed file with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -48,7 +47,7 @@ public static InteractionResultHolder<ItemStack> 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) {
Expand All @@ -65,13 +64,9 @@ public static InteractionResultHolder<ItemStack> 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) {
Expand Down

0 comments on commit 9118584

Please sign in to comment.