From ecb8d46f507be37efa6320901f101e7620571c1c Mon Sep 17 00:00:00 2001 From: Michael Hillcox Date: Sat, 9 Mar 2024 00:13:27 +0000 Subject: [PATCH] fix: no more bad trace --- .../mod/items/ItemWaterBowl.java | 4 +-- .../actuallyadditions/mod/util/WorldUtil.java | 32 ------------------- 2 files changed, 2 insertions(+), 34 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterBowl.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterBowl.java index 2373b4921..9547e60f1 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterBowl.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterBowl.java @@ -50,7 +50,7 @@ public class ItemWaterBowl extends ItemBase { if (event.getLevel() != null) { if (CommonConfig.Other.WATER_BOWL.get()) { if (StackUtil.isValid(event.getItemStack()) && event.getItemStack().getItem() == Items.BOWL) { - HitResult rayTrace = WorldUtil.getNearestBlockWithDefaultReachDistance(event.getLevel(), event.getEntity(), true, false, false); + HitResult rayTrace = event.getEntity().pick(8f, 1f, true); if (rayTrace.getType() != HitResult.Type.BLOCK) { return; } @@ -91,7 +91,7 @@ public class ItemWaterBowl extends ItemBase { public InteractionResultHolder use(Level world, Player player, InteractionHand hand) { ItemStack stack = player.getItemInHand(hand); - HitResult trace = WorldUtil.getNearestBlockWithDefaultReachDistance(world, player); + HitResult trace = player.pick(8.0D, 1.0F, false); InteractionResultHolder result = EventHooks.onBucketUse(player, world, stack, trace); if (result != null) { return result; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java index c135916c4..298d4c087 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java @@ -244,38 +244,6 @@ public final class WorldUtil { return blocks; } - public static HitResult getNearestPositionWithAir(Level level, Player player, int reach) { - return getMovingObjectPosWithReachDistance(level, player, reach, false, false, true); - } - - private static HitResult getMovingObjectPosWithReachDistance(Level level, Player player, double distance, boolean p1, boolean p2, boolean p3) { - float f = player.getXRot(); - float f1 = player.getYRot(); - double d0 = player.position().x; - double d1 = player.position().y + player.getEyeHeight(); - double d2 = player.position().z; - Vec3 vec3 = new Vec3(d0, d1, d2); - float f2 = Mth.cos(-f1 * 0.017453292F - (float) Math.PI); - float f3 = Mth.sin(-f1 * 0.017453292F - (float) Math.PI); - float f4 = -Mth.cos(-f * 0.017453292F); - float f5 = Mth.sin(-f * 0.017453292F); - float f6 = f3 * f4; - float f7 = f2 * f4; - Vec3 vec31 = vec3.add(f6 * distance, f5 * distance, f7 * distance); - //return world.clipWithInteractionOverride(vec3, vec31, p1, p2, p3); //TODO - - return new BlockHitResult(Vec3.ZERO, Direction.DOWN, BlockPos.ZERO, false); - } - - public static HitResult getNearestBlockWithDefaultReachDistance(Level level, Player player) { - return getNearestBlockWithDefaultReachDistance(level, player, false, true, false); - } - - public static HitResult getNearestBlockWithDefaultReachDistance(Level level, Player player, boolean stopOnLiquids, boolean ignoreBlockWithoutBoundingBox, boolean returnLastUncollidableBlock) { - return new BlockHitResult(Vec3.ZERO, Direction.DOWN, BlockPos.ZERO, false); //TODO - //return getMovingObjectPosWithReachDistance(world, player, player.getAttribute(PlayerEntity.REACH_DISTANCE).getAttributeValue(), stopOnLiquids, ignoreBlockWithoutBoundingBox, returnLastUncollidableBlock); - } - public static void setHandItemWithoutAnnoyingSound(Player player, InteractionHand hand, ItemStack stack) { if (hand == InteractionHand.MAIN_HAND) { player.getInventory().items.set(player.getInventory().selected, stack);