mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
fix: no more bad trace
This commit is contained in:
parent
d1438dd67e
commit
ecb8d46f50
2 changed files with 2 additions and 34 deletions
|
@ -50,7 +50,7 @@ public class ItemWaterBowl extends ItemBase {
|
||||||
if (event.getLevel() != null) {
|
if (event.getLevel() != null) {
|
||||||
if (CommonConfig.Other.WATER_BOWL.get()) {
|
if (CommonConfig.Other.WATER_BOWL.get()) {
|
||||||
if (StackUtil.isValid(event.getItemStack()) && event.getItemStack().getItem() == Items.BOWL) {
|
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) {
|
if (rayTrace.getType() != HitResult.Type.BLOCK) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ public class ItemWaterBowl extends ItemBase {
|
||||||
public InteractionResultHolder<ItemStack> use(Level world, Player player, InteractionHand hand) {
|
public InteractionResultHolder<ItemStack> use(Level world, Player player, InteractionHand hand) {
|
||||||
ItemStack stack = player.getItemInHand(hand);
|
ItemStack stack = player.getItemInHand(hand);
|
||||||
|
|
||||||
HitResult trace = WorldUtil.getNearestBlockWithDefaultReachDistance(world, player);
|
HitResult trace = player.pick(8.0D, 1.0F, false);
|
||||||
InteractionResultHolder<ItemStack> result = EventHooks.onBucketUse(player, world, stack, trace);
|
InteractionResultHolder<ItemStack> result = EventHooks.onBucketUse(player, world, stack, trace);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -244,38 +244,6 @@ public final class WorldUtil {
|
||||||
return blocks;
|
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) {
|
public static void setHandItemWithoutAnnoyingSound(Player player, InteractionHand hand, ItemStack stack) {
|
||||||
if (hand == InteractionHand.MAIN_HAND) {
|
if (hand == InteractionHand.MAIN_HAND) {
|
||||||
player.getInventory().items.set(player.getInventory().selected, stack);
|
player.getInventory().items.set(player.getInventory().selected, stack);
|
||||||
|
|
Loading…
Reference in a new issue