Fixed chunkloaders and loading bug

This commit is contained in:
StevenRS11 2013-11-11 21:49:47 -05:00
parent 5cd5a323e0
commit 8dd1d85e6e
4 changed files with 64 additions and 37 deletions

View file

@ -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;

View file

@ -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)

View file

@ -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));
}
}
}

View file

@ -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