From 3d48daecf1333e263bbd5ae9575cd6111dc2a7a3 Mon Sep 17 00:00:00 2001 From: TheCountryGamer Date: Mon, 15 Sep 2014 13:02:08 -0400 Subject: [PATCH] Update Proxy.java Makes sure the the destination chunk is loaded before teleporting --- src/main/java/com/panicnot42/warpbook/Proxy.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/panicnot42/warpbook/Proxy.java b/src/main/java/com/panicnot42/warpbook/Proxy.java index 55b68b1..6277ed5 100644 --- a/src/main/java/com/panicnot42/warpbook/Proxy.java +++ b/src/main/java/com/panicnot42/warpbook/Proxy.java @@ -61,6 +61,13 @@ public void handleWarp(EntityPlayer player, ItemStack page) NetworkRegistry.TargetPoint oldPoint = new NetworkRegistry.TargetPoint(player.dimension, player.posX, player.posY, player.posZ, 64); NetworkRegistry.TargetPoint newPoint = new NetworkRegistry.TargetPoint(wp.dim, wp.x, wp.y, wp.z, 64); player.addExhaustion(calculateExhaustion(player.getEntityWorld().difficultySetting, WarpBookMod.exhaustionCoefficient, crossDim)); + + net.minecraft.world.Chunk chunk = player.worldObj.getChunkFromBlockCoords(wp.x, wp.z); // get the chunk from x and z coords + if (!chunk.isChunkLoaded()) // will only run if that chunk is not already loaded + { + player.worldObj.getChunkProvider().loadChunk(chunk.xPosition, chunk.zPosition); // load the destination chunk + } + if (crossDim && !player.worldObj.isRemote) transferPlayerToDimension((EntityPlayerMP)player, wp.dim, ((EntityPlayerMP)player).mcServer.getConfigurationManager()); player.setPositionAndUpdate(wp.x - 0.5f, wp.y + 0.5f, wp.z - 0.5f); if (!player.worldObj.isRemote)