From 67534c81dd63b8df302c2685094ede0273b66bfa Mon Sep 17 00:00:00 2001 From: CreepyCre Date: Wed, 17 Feb 2021 18:20:26 +0100 Subject: [PATCH] fix glitchy same world teleport fix private pocket door in other pocket dimensions --- .../java/org/dimdev/dimdoors/item/ModItems.java | 3 +-- .../rift/targets/PrivatePocketExitTarget.java | 2 +- .../org/dimdev/dimdoors/util/TeleportUtil.java | 17 ++++++++++++++++- .../dimdev/dimdoors/world/ModDimensions.java | 2 +- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/dimdev/dimdoors/item/ModItems.java b/src/main/java/org/dimdev/dimdoors/item/ModItems.java index 1d0faf43..d385b755 100644 --- a/src/main/java/org/dimdev/dimdoors/item/ModItems.java +++ b/src/main/java/org/dimdev/dimdoors/item/ModItems.java @@ -8,7 +8,6 @@ import org.dimdev.dimdoors.block.ModBlocks; import org.dimdev.dimdoors.entity.ModEntityTypes; import org.dimdev.dimdoors.fluid.ModFluids; import org.dimdev.dimdoors.rift.registry.LinkProperties; -import org.dimdev.dimdoors.rift.targets.EscapeTarget; import org.dimdev.dimdoors.rift.targets.PrivatePocketExitTarget; import org.dimdev.dimdoors.rift.targets.PrivatePocketTarget; import org.dimdev.dimdoors.rift.targets.PublicPocketTarget; @@ -53,7 +52,7 @@ public final class ModItems { ModBlocks.QUARTZ_DIMENSIONAL_DOOR, new Item.Settings().group(DIMENSIONAL_DOORS).maxCount(1), rift -> { - if (ModDimensions.isPocketDimension(rift.getWorld())) { + if (ModDimensions.isPrivatePocketDimension(rift.getWorld())) { rift.setDestination(new PrivatePocketExitTarget()); // exit } else { rift.setDestination(new PrivatePocketTarget()); // entrances diff --git a/src/main/java/org/dimdev/dimdoors/rift/targets/PrivatePocketExitTarget.java b/src/main/java/org/dimdev/dimdoors/rift/targets/PrivatePocketExitTarget.java index 33b1cdca..2b0df6d5 100644 --- a/src/main/java/org/dimdev/dimdoors/rift/targets/PrivatePocketExitTarget.java +++ b/src/main/java/org/dimdev/dimdoors/rift/targets/PrivatePocketExitTarget.java @@ -32,7 +32,7 @@ public class PrivatePocketExitTarget extends VirtualTarget implements EntityTarg if (uuid != null) { destLoc = DimensionalRegistry.getRiftRegistry().getPrivatePocketExit(uuid); Pocket pocket = DimensionalRegistry.getPrivateRegistry().getPrivatePocket(uuid); - if (ModDimensions.isPersonalPocketDimension(this.location.getWorld()) && pocket != null && DimensionalRegistry.getPocketDirectory(pocket.getWorld()).getPocketAt(this.location.pos).equals(pocket)) { + if (ModDimensions.isPrivatePocketDimension(this.location.getWorld()) && pocket != null && DimensionalRegistry.getPocketDirectory(pocket.getWorld()).getPocketAt(this.location.pos).equals(pocket)) { DimensionalRegistry.getRiftRegistry().setLastPrivatePocketEntrance(uuid, this.location); // Remember which exit was used for next time the pocket is entered } if (destLoc == null || !(destLoc.getBlockEntity() instanceof RiftBlockEntity)) { diff --git a/src/main/java/org/dimdev/dimdoors/util/TeleportUtil.java b/src/main/java/org/dimdev/dimdoors/util/TeleportUtil.java index 214a1bf0..5b7799c5 100644 --- a/src/main/java/org/dimdev/dimdoors/util/TeleportUtil.java +++ b/src/main/java/org/dimdev/dimdoors/util/TeleportUtil.java @@ -14,7 +14,6 @@ import net.minecraft.world.TeleportTarget; import net.minecraft.world.World; import net.fabricmc.fabric.api.dimension.v1.FabricDimensions; -import org.dimdev.dimdoors.util.math.MathUtil; @SuppressWarnings("deprecation") public final class TeleportUtil { @@ -31,6 +30,13 @@ public final class TeleportUtil { throw new UnsupportedOperationException("Only supported on ServerWorld"); } + if (entity.world.getRegistryKey().equals(world.getRegistryKey())) { + entity.yaw = yaw; + entity.teleport(pos.x, pos.y, pos.z); + + return entity; + } + return FabricDimensions.teleport(entity, (ServerWorld) world, new TeleportTarget(pos, entity.getVelocity(), yaw, entity.getPitch(1.0F))); } @@ -39,6 +45,15 @@ public final class TeleportUtil { throw new UnsupportedOperationException("Only supported on ServerWorld"); } + if (entity.world.getRegistryKey().equals(world.getRegistryKey())) { + entity.yaw = angle.getYaw(); + entity.pitch = angle.getPitch(); + entity.teleport(pos.x, pos.y, pos.z); + entity.setVelocity(velocity); + + return entity; + } + return FabricDimensions.teleport(entity, (ServerWorld) world, new TeleportTarget(pos, velocity, angle.getYaw(), angle.getPitch())); } diff --git a/src/main/java/org/dimdev/dimdoors/world/ModDimensions.java b/src/main/java/org/dimdev/dimdoors/world/ModDimensions.java index 2c9e650f..8780c8c6 100644 --- a/src/main/java/org/dimdev/dimdoors/world/ModDimensions.java +++ b/src/main/java/org/dimdev/dimdoors/world/ModDimensions.java @@ -35,7 +35,7 @@ public final class ModDimensions { return isPocketDimension(world.getRegistryKey()); } - public static boolean isPersonalPocketDimension(World world) { + public static boolean isPrivatePocketDimension(World world) { return world != null && world == PERSONAL_POCKET_DIMENSION; }