diff --git a/src/main/java/com/thebrokenrail/energonrelics/block/portal/EnergyTeleporter.java b/src/main/java/com/thebrokenrail/energonrelics/block/portal/EnergyTeleporter.java index 334bbe1..64fb48c 100644 --- a/src/main/java/com/thebrokenrail/energonrelics/block/portal/EnergyTeleporter.java +++ b/src/main/java/com/thebrokenrail/energonrelics/block/portal/EnergyTeleporter.java @@ -13,7 +13,6 @@ import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.Heightmap; @@ -54,30 +53,13 @@ class EnergyTeleporter { } private static int convertY(int y, int oldHeight, int newHeight) { + int newY = (int) (((float) y / (float) oldHeight) * (float) newHeight); + int bottomPadding = HardcodedConfig.ENERGY_PORTAL_Y_PADDING; int topPadding = bottomPadding + HardcodedConfig.ENERGY_PORTAL_Y_PADDING_EXTRA_TOP; + newY = Math.max(bottomPadding, Math.min(topPadding, newY)); - int oldMax = oldHeight - topPadding; - - y = MathHelper.clamp(y, bottomPadding, oldMax); - - int totalPadding = bottomPadding + topPadding; - int oldPaddedHeight = oldHeight - totalPadding; - int newPaddedHeight = newHeight - totalPadding; - - float multiplier = (float) newPaddedHeight / (float) oldPaddedHeight; - - y = y - bottomPadding; - - y = (int) (y * multiplier); - - int newMax = newHeight - topPadding; - - y = y + bottomPadding; - - y = MathHelper.clamp(y, bottomPadding, newMax); - - return y; + return newY; } private static void teleportWithMultiplier(ServerWorld world, Entity entity, BlockPos center, Vec3d offset, RegistryKey toKey, double multiplier) {