Fixed mob spawning issues (maybe) and limbo exit issues.

Signed-off-by: StevenRS11 <stevenrs11@aol.com>
This commit is contained in:
StevenRS11 2013-03-28 21:34:38 -04:00
parent 508e2f3b4d
commit 8ccabfc16e
7 changed files with 81 additions and 25 deletions

View file

@ -51,11 +51,15 @@ public class BlockDimWallPerm extends Block
link =new LinkData(0,0,0,0); link =new LinkData(0,0,0,0);
} }
if(dimHelper.getWorld(0)==null)
if(dimHelper.getWorld(link.destDimID)!=null)
{ {
World world = dimHelper.getWorld(0); dimHelper.initDimension(0);
}
if(dimHelper.getWorld(0)!=null)
{
int x = (link.destXCoord + rand.nextInt(mod_pocketDim.limboExitRange)-mod_pocketDim.limboExitRange/2); int x = (link.destXCoord + rand.nextInt(mod_pocketDim.limboExitRange)-mod_pocketDim.limboExitRange/2);
int z = (link.destZCoord + rand.nextInt(mod_pocketDim.limboExitRange)-mod_pocketDim.limboExitRange/2); int z = (link.destZCoord + rand.nextInt(mod_pocketDim.limboExitRange)-mod_pocketDim.limboExitRange/2);
@ -63,20 +67,56 @@ public class BlockDimWallPerm extends Block
x=x+(x>> 4)+1; //make sure I am in the middle of a chunk, andnot on a boundry, so it doesnt load the chunk next to me x=x+(x>> 4)+1; //make sure I am in the middle of a chunk, andnot on a boundry, so it doesnt load the chunk next to me
z=z+(z>> 4)+1; z=z+(z>> 4)+1;
world.getChunkProvider().loadChunk(x >> 4, z >> 4); dimHelper.getWorld(0).getChunkProvider().loadChunk(x >> 4, z >> 4);
int y = world.getHeightValue(x, z); int y = dimHelper.getWorld(0).getHeightValue(x, z);
//this complicated chunk teleports the player back to the overworld at some random location. Looks funky becaue it has to load the chunk //this complicated chunk teleports the player back to the overworld at some random location. Looks funky becaue it has to load the chunk
dimHelper.instance.teleportToPocket(par1World, dimHelper.instance.teleportToPocket(par1World, new LinkData(par1World.provider.dimensionId,0,x,y,z,link.locXCoord,link.locYCoord,link.locZCoord,link.isLocPocket),
new LinkData(0,0,x,y,z,link.locXCoord,link.locYCoord,link.locZCoord,link.isLocPocket),
EntityPlayer.class.cast(par5Entity)); EntityPlayer.class.cast(par5Entity));
EntityPlayer.class.cast(par5Entity).setPositionAndUpdate( x, y, z ); EntityPlayer.class.cast(par5Entity).setPositionAndUpdate( x, y, z );
//makes sure they can breath when they teleport //makes sure they can breath when they teleport
world.setBlockWithNotify(x, y, z, 0); dimHelper.getWorld(0).setBlockWithNotify(x, y, z, 0);
int i=x;
int j=y-1;
int k=z;
for(int xc=-3;xc<4;xc++)
{
for(int zc=-3;zc<4;zc++)
{
for(int yc=0;yc<200;yc++)
{
if(yc==0&&dimHelper.getWorld(0).isBlockOpaqueCube(i+xc, j-2,k +zc))
{
if(Math.abs(xc)+Math.abs(zc)<rand.nextInt(3)+2)
{
dimHelper.getWorld(0).setBlock(i+xc, j-1+yc, k+zc, mod_pocketDim.blockLimboID);
}
else if(Math.abs(xc)+Math.abs(zc)<rand.nextInt(3)+3)
{
dimHelper.getWorld(0).setBlockAndMetadata(i+xc, j-1+yc, k+zc, mod_pocketDim.blockLimboID,2);
}
}
}
}
}
{
}
} }
} }

View file

@ -49,10 +49,13 @@ public class EventHookContainer
if(!mod_pocketDim.hasInitDims&&event.world.provider.dimensionId==0&&!event.world.isRemote) if(!mod_pocketDim.hasInitDims&&event.world.provider.dimensionId==0&&!event.world.isRemote)
{ {
System.out.println("Registering Pocket Dims");
mod_pocketDim.hasInitDims=true;
dimHelper.instance.unregsisterDims(); dimHelper.instance.unregsisterDims();
dimHelper.dimList.clear(); dimHelper.dimList.clear();
dimHelper.instance.interDimLinkList.clear(); dimHelper.instance.interDimLinkList.clear();
dimHelper.instance.linksForRendering.clear(); dimHelper.instance.linksForRendering.clear();
dimHelper.instance.initPockets(); dimHelper.instance.initPockets();

View file

@ -44,7 +44,7 @@ public class PlayerRespawnTracker implements IPlayerTracker
for(EntityItem drop : mod_pocketDim.limboSpawnInventory) for(EntityItem drop : mod_pocketDim.limboSpawnInventory)
{ {
// player.inventory.addItemStackToInventory(drop.getEntityItem()); player.inventory.addItemStackToInventory(drop.getEntityItem());
} }

View file

@ -848,13 +848,17 @@ public class SchematicLoader
if(world.getBlockId(point.getX(), point.getY(), point.getZ())==mod_pocketDim.ExitDoorID&&world.getBlockId(point.getX(), point.getY()-1, point.getZ())==mod_pocketDim.ExitDoorID&&world.getBlockId(point.getX(), point.getY()-2, point.getZ())==Block.sandStone.blockID) if(world.getBlockId(point.getX(), point.getY(), point.getZ())==mod_pocketDim.ExitDoorID&&world.getBlockId(point.getX(), point.getY()-1, point.getZ())==mod_pocketDim.ExitDoorID&&world.getBlockId(point.getX(), point.getY()-2, point.getZ())==Block.sandStone.blockID)
{ {
World exitWorld = dimHelper.getWorld(dimHelper.dimList.get(world.provider.dimensionId).exitDimLink.destDimID);
if(dimHelper.getWorld(dimHelper.dimList.get(world.provider.dimensionId).exitDimLink.destDimID)==null)
{
dimHelper.initDimension((dimHelper.dimList.get(world.provider.dimensionId).exitDimLink.destDimID));
}
exitWorld.getChunkProvider().loadChunk(point.getX() >> 4, point.getZ() >> 4); dimHelper.getWorld(dimHelper.dimList.get(world.provider.dimensionId).exitDimLink.destDimID).getChunkProvider().loadChunk(point.getX() >> 4, point.getZ() >> 4);
LinkData sideLink = new LinkData(link.destDimID,dimHelper.dimList.get(link.locDimID).exitDimLink.destDimID,point.getX(), point.getY(), point.getZ(),point.getX(), exitWorld.getHeightValue(point.getX(), point.getZ())+1, point.getZ(),true); LinkData sideLink = new LinkData(link.destDimID,dimHelper.dimList.get(link.locDimID).exitDimLink.destDimID,point.getX(), point.getY(), point.getZ(),point.getX(), dimHelper.getWorld(dimHelper.dimList.get(world.provider.dimensionId).exitDimLink.destDimID).getHeightValue(point.getX(), point.getZ())+1, point.getZ(),true);
sideLink.linkOrientation=world.getBlockMetadata(point.getX(), point.getY()-1, point.getZ()); sideLink.linkOrientation=world.getBlockMetadata(point.getX(), point.getY()-1, point.getZ());
dimHelper.instance.createLink(sideLink); dimHelper.instance.createLink(sideLink);
dimHelper.instance.createLink(sideLink.destDimID , sideLink.locDimID, sideLink.destXCoord, sideLink.destYCoord, sideLink.destZCoord, sideLink.locXCoord, sideLink.locYCoord, sideLink.locZCoord, dimHelper.instance.flipDoorMetadata(sideLink.linkOrientation)); dimHelper.instance.createLink(sideLink.destDimID , sideLink.locDimID, sideLink.destXCoord, sideLink.destYCoord, sideLink.destZCoord, sideLink.locXCoord, sideLink.locYCoord, sideLink.locZCoord, dimHelper.instance.flipDoorMetadata(sideLink.linkOrientation));

View file

@ -65,7 +65,7 @@ public class TransientDoor extends ExitDoor
if(dimHelper.dimList.containsKey(linkData.destDimID)) if(dimHelper.dimList.containsKey(linkData.destDimID))
{ {
dimHelper.instance.teleportToPocket(par1World, linkData, par5Entity); dimHelper.instance.teleportToPocket(par1World, linkData, par5Entity);
par1World.setBlockWithNotify(par2, par3, par4, 0); par1World.setBlockWithNotify(par2, par3-1, par4, 0);
} }
} }

View file

@ -99,7 +99,7 @@ public class dimDoor extends BlockContainer
System.out.println(linkData.destDimID);
dimHelper.instance.teleportToPocket(par1World, linkData, par5Entity); dimHelper.instance.teleportToPocket(par1World, linkData, par5Entity);
this.onPoweredBlockChange(par1World, par2, par3, par4, false); this.onPoweredBlockChange(par1World, par2, par3, par4, false);

View file

@ -355,10 +355,6 @@ public class dimHelper extends DimensionManager
int y=linkData.destYCoord; int y=linkData.destYCoord;
int z=linkData.destZCoord; int z=linkData.destZCoord;
if(linkData.destDimID==mod_pocketDim.limboDimID&&entity instanceof EntityPlayerMP)
{
this.teleportToLimbo(world, linkData, EntityPlayerMP.class.cast(entity));
}
int depth= this.getDimDepth(world.provider.dimensionId); int depth= this.getDimDepth(world.provider.dimensionId);
@ -474,6 +470,11 @@ public class dimHelper extends DimensionManager
this.dimList.put(link.locDimID, locationDimData); this.dimList.put(link.locDimID, locationDimData);
link.isLocPocket=false; link.isLocPocket=false;
}
if(!dimList.containsKey(link.destDimID))
{
dimHelper.dimList.put(link.destDimID, new DimData(link.destDimID, false, 0, link.locDimID,link.locXCoord,link.locYCoord,link.locZCoord));
} }
DimData locationDimData= this.dimList.get(link.locDimID); DimData locationDimData= this.dimList.get(link.locDimID);
@ -766,8 +767,12 @@ public class dimHelper extends DimensionManager
this.load(); this.load();
if(!this.dimList.isEmpty()) if(!this.dimList.isEmpty())
{ {
Set allDimIds=dimList.keySet(); Set allDimIds=dimList.keySet();
Iterator itr =allDimIds.iterator(); Iterator itr =allDimIds.iterator();
while(itr.hasNext()) while(itr.hasNext())
{ {
@ -785,6 +790,10 @@ public class dimHelper extends DimensionManager
{ {
System.out.println("Warning- could not register dim "+dimData.depth+" . Probably caused by a version update/save data corruption/other mods. "); System.out.println("Warning- could not register dim "+dimData.depth+" . Probably caused by a version update/save data corruption/other mods. ");
} }
else
{
e.printStackTrace();
}
} }
} }
} }