From c812512abe5fa817c15fc12ea445c1173405a173 Mon Sep 17 00:00:00 2001 From: Flanks255 <32142731+Flanks255@users.noreply.github.com> Date: Tue, 4 Jun 2024 16:38:19 -0500 Subject: [PATCH] Fixed up the teleport staff. --- .../actuallyadditions/mod/items/ItemTeleportStaff.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemTeleportStaff.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemTeleportStaff.java index b3350d7c5..f809a24a0 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemTeleportStaff.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemTeleportStaff.java @@ -10,6 +10,7 @@ package de.ellpeck.actuallyadditions.mod.items; +import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerPlayer; @@ -34,11 +35,15 @@ public class ItemTeleportStaff extends ItemEnergy { ItemStack stack = player.getItemInHand(hand); if (!world.isClientSide) { HitResult rayTraceResult = player.pick(100,1F,false); - if (rayTraceResult.getType() == HitResult.Type.BLOCK || player.getXRot() >= -5) { + if (rayTraceResult.getType() == HitResult.Type.BLOCK || rayTraceResult.getType() == HitResult.Type.MISS) { Vec3 location = rayTraceResult.getLocation(); Vec3 pos = Vec3.atBottomCenterOf(BlockPos.containing(location.x, location.y, location.z)); int baseUse = 200; - int use = baseUse + (int) (baseUse * player.blockPosition().distSqr(BlockPos.containing(pos.x, pos.y, pos.z))); + int use = baseUse + (int) (baseUse * Math.sqrt(player.blockPosition().distManhattan(BlockPos.containing(pos.x, pos.y, pos.z)))); + ActuallyAdditions.LOGGER.info("Use: " + use + " Energy: " + this.getEnergyStored(stack)); + ActuallyAdditions.LOGGER.info("Distance: " + Math.sqrt(player.blockPosition().distSqr(BlockPos.containing(pos.x, pos.y, pos.z)))); + ActuallyAdditions.LOGGER.info("Player: " + player.blockPosition()); + ActuallyAdditions.LOGGER.info("Pos: " + pos); if (this.getEnergyStored(stack) >= use) { ((ServerPlayer) player).connection.teleport(pos.x, pos.y + 1F, pos.z, player.getYRot(), player.getXRot()); player.removeVehicle();