Fixed chunk loaders and dim loading bug
This commit is contained in:
parent
c2bab6cc93
commit
c48e2307c7
3 changed files with 58 additions and 30 deletions
|
@ -271,6 +271,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);
|
||||
}
|
||||
|
@ -279,7 +280,8 @@ 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)
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
package StevenDimDoors.mod_pocketDim.tileentities;
|
||||
|
||||
import java.awt.List;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.IChunkLoader;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
import StevenDimDoors.mod_pocketDim.world.PocketBuilder;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.ChunkCoordIntPair;
|
||||
import net.minecraftforge.common.ForgeChunkManager;
|
||||
|
@ -29,49 +32,72 @@ public class TileEntityDimDoorGold extends TileEntityDimDoor implements IChunkLo
|
|||
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);
|
||||
}
|
||||
|
||||
for(Object chunk : this.chunkTicket.getChunkList())
|
||||
{
|
||||
for(int x = 0; x<16;x++)
|
||||
{
|
||||
for(int z = 0; z<16;z++)
|
||||
{
|
||||
this.worldObj.setBlock(((ChunkCoordIntPair)chunk).chunkXPos*16 + x, this.yCoord-2, ((ChunkCoordIntPair)chunk).chunkZPos*16 + z, Block.glowStone.blockID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forceChunkLoading(Ticket chunkTicket,int x,int z)
|
||||
{
|
||||
NewDimData data = PocketManager.getDimensionData(chunkTicket.world);
|
||||
if (data == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!data.isPocketDimension())
|
||||
{
|
||||
return;
|
||||
}
|
||||
Point4D origin = PocketManager.getDimensionData(this.worldObj).origin();
|
||||
int orientation = PocketManager.getDimensionData(this.worldObj).orientation();
|
||||
|
||||
Point4D origin = data.origin();
|
||||
switch (data.orientation())
|
||||
{
|
||||
int xOffset=0;
|
||||
int zOffset=0;
|
||||
|
||||
}
|
||||
//TODO fix this
|
||||
for(int chunksX = (PocketBuilder.DEFAULT_POCKET_SIZE/16) + 1; chunksX > 0; --chunksX)
|
||||
switch(orientation)
|
||||
{
|
||||
ForgeChunkManager.forceChunk(chunkTicket, new ChunkCoordIntPair((xCoord >> 4) + chunksX,
|
||||
(zCoord >> 4)));
|
||||
|
||||
for(int chunksZ = (PocketBuilder.DEFAULT_POCKET_SIZE/16) + 1; chunksZ > 0; --chunksZ)
|
||||
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((xCoord >> 4),
|
||||
(zCoord >> 4) + chunksZ));
|
||||
}
|
||||
}
|
||||
ForgeChunkManager.forceChunk(chunkTicket, new ChunkCoordIntPair((origin.getX()+xOffset >> 4)+chunkX, (origin.getZ()+zOffset >> 4)+chunkZ));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -376,7 +376,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
|
||||
|
|
Loading…
Reference in a new issue