From 8dd1d85e6e85c96dda2dd00cba03f563e33e8083 Mon Sep 17 00:00:00 2001 From: StevenRS11 Date: Mon, 11 Nov 2013 21:49:47 -0500 Subject: [PATCH] Fixed chunkloaders and loading bug --- .../mod_pocketDim/core/DimLink.java | 1 - .../mod_pocketDim/core/PocketManager.java | 4 +- .../tileentities/TileEntityDimDoorGold.java | 94 ++++++++++++------- .../mod_pocketDim/world/PocketBuilder.java | 2 +- 4 files changed, 64 insertions(+), 37 deletions(-) diff --git a/StevenDimDoors/mod_pocketDim/core/DimLink.java b/StevenDimDoors/mod_pocketDim/core/DimLink.java index 9f1369d8..0b89b30e 100644 --- a/StevenDimDoors/mod_pocketDim/core/DimLink.java +++ b/StevenDimDoors/mod_pocketDim/core/DimLink.java @@ -4,7 +4,6 @@ import java.util.LinkedList; import java.util.List; import StevenDimDoors.mod_pocketDim.util.Point4D; -@Deprecated public abstract class DimLink { protected Point4D source; diff --git a/StevenDimDoors/mod_pocketDim/core/PocketManager.java b/StevenDimDoors/mod_pocketDim/core/PocketManager.java index 6a6944b2..52112afe 100644 --- a/StevenDimDoors/mod_pocketDim/core/PocketManager.java +++ b/StevenDimDoors/mod_pocketDim/core/PocketManager.java @@ -272,7 +272,7 @@ public class PocketManager dimData.root=dimData; dimData.parent=dimData; dimData.isFilled=packedData.IsFilled; - + dimData.origin = new Point4D(packedData.Origin.getX(),packedData.Origin.getY(),packedData.Origin.getZ(),packedData.ID); PocketManager.rootDimensions.add(dimData); } else @@ -280,7 +280,7 @@ public class PocketManager InnerDimData test = PocketManager.dimensionData.get(packedData.ParentID); dimData = new InnerDimData(packedData.ID, test,true, packedData.IsDungeon, linkWatcher); dimData.isFilled=packedData.IsFilled; - + dimData.origin = new Point4D(packedData.Origin.getX(),packedData.Origin.getY(),packedData.Origin.getZ(),packedData.ID); dimData.root=PocketManager.getDimensionData(packedData.RootID); if(packedData.DungeonData!=null) diff --git a/StevenDimDoors/mod_pocketDim/tileentities/TileEntityDimDoorGold.java b/StevenDimDoors/mod_pocketDim/tileentities/TileEntityDimDoorGold.java index 6091aedb..248046f5 100644 --- a/StevenDimDoors/mod_pocketDim/tileentities/TileEntityDimDoorGold.java +++ b/StevenDimDoors/mod_pocketDim/tileentities/TileEntityDimDoorGold.java @@ -3,6 +3,7 @@ package StevenDimDoors.mod_pocketDim.tileentities; import StevenDimDoors.mod_pocketDim.IChunkLoader; import StevenDimDoors.mod_pocketDim.mod_pocketDim; import StevenDimDoors.mod_pocketDim.core.PocketManager; +import StevenDimDoors.mod_pocketDim.util.Point4D; import StevenDimDoors.mod_pocketDim.world.PocketBuilder; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.ChunkCoordIntPair; @@ -20,40 +21,67 @@ public class TileEntityDimDoorGold extends TileEntityDimDoor implements IChunkLo return true; } - public void updateEntity() - { - if(PocketManager.getDimensionData(this.worldObj)!=null&&PocketManager.getDimensionData(this.worldObj).isPocketDimension()&&!this.worldObj.isRemote) - { - if(this.chunkTicket==null) - { - chunkTicket = ForgeChunkManager.requestTicket(mod_pocketDim.instance, worldObj, Type.NORMAL); - } - - chunkTicket.getModData().setInteger("goldDimDoorX", xCoord); - chunkTicket.getModData().setInteger("goldDimDoorY", yCoord); - chunkTicket.getModData().setInteger("goldDimDoorZ", zCoord); - ForgeChunkManager.forceChunk(chunkTicket, new ChunkCoordIntPair(xCoord >> 4, zCoord >> 4)); - forceChunkLoading(chunkTicket,this.xCoord,this.zCoord); - } - } - - public void forceChunkLoading(Ticket chunkTicket,int x,int z) - { - if(PocketManager.getDimensionData(chunkTicket.world)==null) - { - return; - } - if(!PocketManager.getDimensionData(chunkTicket.world).isPocketDimension()) - { - return; - } - - for(int chunks = (PocketBuilder.DEFAULT_POCKET_SIZE/16)+1;chunks>0;chunks--) - { - ForgeChunkManager.forceChunk(chunkTicket, new ChunkCoordIntPair((xCoord >> 4)+chunks, (zCoord >> 4)+chunks)); + @Override + public void updateEntity() + { // every tick? + if (PocketManager.getDimensionData(this.worldObj) != null && + PocketManager.getDimensionData(this.worldObj).isPocketDimension() && + !this.worldObj.isRemote) + { + if(PocketManager.getLink(this.xCoord,this.yCoord,this.zCoord,this.worldObj)==null) + { + return; + } + if (this.chunkTicket == null) + { + chunkTicket = ForgeChunkManager.requestTicket(mod_pocketDim.instance, worldObj, Type.NORMAL); + chunkTicket.getModData().setInteger("goldDimDoorX", xCoord); + chunkTicket.getModData().setInteger("goldDimDoorY", yCoord); + chunkTicket.getModData().setInteger("goldDimDoorZ", zCoord); + forceChunkLoading(chunkTicket,this.xCoord,this.zCoord); + } - } - } + } + } + + @Override + public void forceChunkLoading(Ticket chunkTicket,int x,int z) + { + Point4D origin = PocketManager.getDimensionData(this.worldObj).origin(); + int orientation = PocketManager.getDimensionData(this.worldObj).orientation(); + + int xOffset=0; + int zOffset=0; + + switch(orientation) + { + case 0: + xOffset = PocketBuilder.DEFAULT_POCKET_SIZE/2; + break; + case 1: + zOffset = PocketBuilder.DEFAULT_POCKET_SIZE/2; + + break; + case 2: + xOffset = -PocketBuilder.DEFAULT_POCKET_SIZE/2; + + break; + case 3: + zOffset = -PocketBuilder.DEFAULT_POCKET_SIZE/2; + + break; + } + for(int chunkX = -1; chunkX<2;chunkX++) + { + for(int chunkZ = -1; chunkZ<2;chunkZ++) + { + ForgeChunkManager.forceChunk(chunkTicket, new ChunkCoordIntPair((origin.getX()+xOffset >> 4)+chunkX, (origin.getZ()+zOffset >> 4)+chunkZ)); + } + } + + + + } diff --git a/StevenDimDoors/mod_pocketDim/world/PocketBuilder.java b/StevenDimDoors/mod_pocketDim/world/PocketBuilder.java index 88b326a1..1773f32d 100644 --- a/StevenDimDoors/mod_pocketDim/world/PocketBuilder.java +++ b/StevenDimDoors/mod_pocketDim/world/PocketBuilder.java @@ -375,7 +375,7 @@ public class PocketBuilder int orientation = getDoorOrientation(source, properties); //Place a link leading back out of the pocket - DimLink reverseLink = dimension.createLink(source.getX(), destinationY, source.getZ(), LinkTypes.REVERSE); + DimLink reverseLink = dimension.createLink(source.getX(), destinationY, source.getZ(), LinkTypes.REVERSE,(link.orientation()+2)%4); parent.setDestination(reverseLink, source.getX(), source.getY(), source.getZ()); //Build the actual pocket area