From c4a1767a5502fa31320014c7e430b4daf7b26930 Mon Sep 17 00:00:00 2001 From: Buuz135 Date: Fri, 4 Dec 2020 18:57:30 +0100 Subject: [PATCH 1/6] Increased Version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index dd81e0d5..be5822ad 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,4 +2,4 @@ # This is required to provide enough memory for the Minecraft decompilation process. org.gradle.jvmargs=-Xmx3G minecraftVersion=1.16.4 -api_version=3.2.1 +api_version=3.2.2 From 0767d7661d58149a4315fba728479e583ba0baef Mon Sep 17 00:00:00 2001 From: Buuz135 Date: Sat, 19 Dec 2020 17:39:19 +0100 Subject: [PATCH 2/6] Increased version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index be5822ad..85968b41 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,4 +2,4 @@ # This is required to provide enough memory for the Minecraft decompilation process. org.gradle.jvmargs=-Xmx3G minecraftVersion=1.16.4 -api_version=3.2.2 +api_version=3.2.3 From 6b12a63b3a023fafdb7f91acd4c9e26a212b7b1d Mon Sep 17 00:00:00 2001 From: Buuz135 Date: Sun, 27 Dec 2020 14:12:08 +0100 Subject: [PATCH 3/6] Increased Version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 85968b41..8d396581 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,4 +2,4 @@ # This is required to provide enough memory for the Minecraft decompilation process. org.gradle.jvmargs=-Xmx3G minecraftVersion=1.16.4 -api_version=3.2.3 +api_version=3.2.4 From 7c5175cd73b55fda1312d684d62c7a8db98e138f Mon Sep 17 00:00:00 2001 From: Buuz135 Date: Sat, 9 Jan 2021 15:21:07 +0100 Subject: [PATCH 4/6] Increased version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 8d396581..a646dc78 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,4 +2,4 @@ # This is required to provide enough memory for the Minecraft decompilation process. org.gradle.jvmargs=-Xmx3G minecraftVersion=1.16.4 -api_version=3.2.4 +api_version=3.2.5 From 02cb642769925f8e6cd19233109ee243fa164ea7 Mon Sep 17 00:00:00 2001 From: Buuz135 Date: Fri, 2 Apr 2021 14:23:04 +0200 Subject: [PATCH 5/6] Improved Teleporting for all entities, closes https://github.com/InnovativeOnlineIndustries/Portality/issues/102 --- .../titanium/util/TeleportationUtils.java | 59 +++++++++++++------ 1 file changed, 42 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/hrznstudio/titanium/util/TeleportationUtils.java b/src/main/java/com/hrznstudio/titanium/util/TeleportationUtils.java index bfc392a0..f1abe691 100644 --- a/src/main/java/com/hrznstudio/titanium/util/TeleportationUtils.java +++ b/src/main/java/com/hrznstudio/titanium/util/TeleportationUtils.java @@ -7,10 +7,14 @@ package com.hrznstudio.titanium.util; +import net.minecraft.block.PortalInfo; import net.minecraft.entity.Entity; -import net.minecraft.server.MinecraftServer; +import net.minecraft.network.play.server.SSetPassengersPacket; import net.minecraft.util.RegistryKey; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; +import net.minecraft.world.server.ServerChunkProvider; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.common.util.ITeleporter; @@ -21,26 +25,47 @@ public class TeleportationUtils { public static Entity teleportEntity(Entity entity, RegistryKey dimension, double xCoord, double yCoord, double zCoord, float yaw, float pitch) { - if (entity == null || entity.world.isRemote) { + return teleportEntityTo(entity, new BlockPos(xCoord, yCoord, zCoord), dimension, yaw ,pitch); + } + + public static Entity teleportEntityTo(Entity entity, BlockPos target, RegistryKey destinationDimension, float yaw, float pitch) { + if (entity.getEntityWorld().getDimensionKey() == destinationDimension) { + entity.rotationYaw = yaw; + entity.rotationPitch = pitch; + entity.setPositionAndUpdate(target.getX() + 0.5, target.getY(), target.getZ() + 0.5); + + if (!entity.getPassengers().isEmpty()) { + //Force re-apply any passengers so that players don't get "stuck" outside what they may be riding + ((ServerChunkProvider) entity.getEntityWorld().getChunkProvider()).sendToAllTracking(entity, new SSetPassengersPacket(entity)); + } return entity; - } + } else { + ServerWorld newWorld = ((ServerWorld) entity.getEntityWorld()).getServer().getWorld(destinationDimension); + if (newWorld != null) { + Vector3d destination = new Vector3d(target.getX() + 0.5, target.getY(), target.getZ() + 0.5); + //Note: We grab the passengers here instead of in placeEntity as changeDimension starts by removing any passengers + List passengers = entity.getPassengers(); + return entity.changeDimension(newWorld, new ITeleporter() { + @Override + public Entity placeEntity(Entity entity, ServerWorld currentWorld, ServerWorld destWorld, float yaw, Function repositionEntity) { + Entity repositionedEntity = repositionEntity.apply(false); + if (repositionedEntity != null) { + //Teleport all passengers to the other dimension and then make them start riding the entity again + for (Entity passenger : passengers) { + teleportPassenger(destWorld, repositionedEntity, passenger); + } + } + return repositionedEntity; + } - MinecraftServer server = entity.getServer(); - List passengers = entity.getPassengers(); - return entity.changeDimension(server.getWorld(dimension), new ITeleporter() { - @Override - public Entity placeEntity(Entity entity, ServerWorld currentWorld, ServerWorld destWorld, float yawE, Function repositionEntity) { - Entity repositionedEntity = repositionEntity.apply(false); - if (repositionedEntity != null){ - repositionedEntity.setPositionAndRotation(xCoord, yCoord, zCoord, yaw, pitch); - repositionedEntity.setPositionAndUpdate(xCoord, yCoord, zCoord); - for (Entity passenger : passengers) { - teleportPassenger(destWorld, repositionedEntity, passenger); + @Override + public PortalInfo getPortalInfo(Entity entity, ServerWorld destWorld, Function defaultPortalInfo) { + return new PortalInfo(destination, entity.getMotion(), pitch, yaw); } - } - return repositionedEntity; + }); } - }); + } + return null; } private static void teleportPassenger(ServerWorld destWorld, Entity repositionedEntity, Entity passenger) { From 5b1f8c9e16a0cf09ca4499970b7654b98baa2a2d Mon Sep 17 00:00:00 2001 From: Buuz135 Date: Fri, 2 Apr 2021 16:08:49 +0200 Subject: [PATCH 6/6] Increased Version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 17611fb4..8885ee86 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,4 +2,4 @@ # This is required to provide enough memory for the Minecraft decompilation process. org.gradle.jvmargs=-Xmx3G minecraftVersion=1.16.5 -api_version=3.2.8 +api_version=3.2.8.1