Fixed /dd-rift orientation funkyness.

This commit is contained in:
StevenRS11 2013-07-30 20:15:55 -04:00
parent 9c3013899f
commit c87e572136
2 changed files with 55 additions and 142 deletions

View file

@ -167,17 +167,11 @@ public class dimHelper extends DimensionManager
newWorld=(WorldServer)oldWorld; newWorld=(WorldServer)oldWorld;
} }
mod_pocketDim.teleporter.placeInPortal(entity, newWorld, link);
mod_pocketDim.teleporter.placeInPortal(entity, newWorld, link);
if ((entity instanceof EntityPlayerMP)) if ((entity instanceof EntityPlayerMP))
{ {
EntityPlayerMP player = (EntityPlayerMP)entity; EntityPlayerMP player = (EntityPlayerMP)entity;
//player.closeScreen();
if (difDest) if (difDest)
{ {
GameRegistry.onPlayerChangedDimension((EntityPlayer)entity); GameRegistry.onPlayerChangedDimension((EntityPlayer)entity);
@ -201,45 +195,26 @@ public class dimHelper extends DimensionManager
{ {
PotionEffect effect = (PotionEffect)potionEffect; PotionEffect effect = (PotionEffect)potionEffect;
player.playerNetServerHandler.sendPacketToPlayer(new Packet41EntityEffect(player.entityId, effect)); player.playerNetServerHandler.sendPacketToPlayer(new Packet41EntityEffect(player.entityId, effect));
} }
player.playerNetServerHandler.sendPacketToPlayer(new Packet43Experience(player.experience, player.experienceTotal, player.experienceLevel)); player.playerNetServerHandler.sendPacketToPlayer(new Packet43Experience(player.experience, player.experienceTotal, player.experienceLevel));
} }
} }
if(difDest) if(difDest)
{ {
int entX = entity.chunkCoordX; int entX = entity.chunkCoordX;
int entZ = entity.chunkCoordZ; int entZ = entity.chunkCoordZ;
if ((entity.addedToChunk) && (oldWorld.getChunkProvider().chunkExists(entX, entZ))) if ((entity.addedToChunk) && (oldWorld.getChunkProvider().chunkExists(entX, entZ)))
{ {
oldWorld.getChunkFromChunkCoords(entX, entZ).removeEntity(entity); oldWorld.getChunkFromChunkCoords(entX, entZ).removeEntity(entity);
oldWorld.getChunkFromChunkCoords(entX, entZ).isModified = true; oldWorld.getChunkFromChunkCoords(entX, entZ).isModified = true;
} }
oldWorld.releaseEntitySkin(entity); oldWorld.releaseEntitySkin(entity);
// entity.isDead = false;
if (!(entity instanceof EntityPlayer)) if (!(entity instanceof EntityPlayer))
{ {
NBTTagCompound entityNBT = new NBTTagCompound(); NBTTagCompound entityNBT = new NBTTagCompound();
entity.isDead = false; entity.isDead = false;
entity.addEntityID(entityNBT); entity.addEntityID(entityNBT);
entity.isDead = true; entity.isDead = true;
entity = EntityList.createEntityFromNBT(entityNBT, newWorld); entity = EntityList.createEntityFromNBT(entityNBT, newWorld);
if (entity == null) if (entity == null)
@ -247,37 +222,24 @@ public class dimHelper extends DimensionManager
} }
} }
newWorld.spawnEntityInWorld(entity); newWorld.spawnEntityInWorld(entity);
entity.setWorld(newWorld); entity.setWorld(newWorld);
} }
entity.worldObj.updateEntityWithOptionalForce(entity, false); entity.worldObj.updateEntityWithOptionalForce(entity, false);
if ((entity != null) && (cart != null)) if ((entity != null) && (cart != null))
{ {
if ((entity instanceof EntityPlayerMP)) if ((entity instanceof EntityPlayerMP))
{ {
EntityPlayerMP playerMP = (EntityPlayerMP)entity; EntityPlayerMP playerMP = (EntityPlayerMP)entity;
entity.worldObj.updateEntityWithOptionalForce(entity, true); entity.worldObj.updateEntityWithOptionalForce(entity, true);
} }
entity.mountEntity(cart); entity.mountEntity(cart);
} }
if(entity instanceof EntityPlayerMP) if(entity instanceof EntityPlayerMP)
{ {
WorldServer.class.cast(newWorld).getChunkProvider().loadChunk(MathHelper.floor_double(entity.posX) >> 4, MathHelper.floor_double(entity.posZ) >> 4); WorldServer.class.cast(newWorld).getChunkProvider().loadChunk(MathHelper.floor_double(entity.posX) >> 4, MathHelper.floor_double(entity.posZ) >> 4);
} }
mod_pocketDim.teleporter.placeInPortal(entity, newWorld, link); mod_pocketDim.teleporter.placeInPortal(entity, newWorld, link);
return entity; return entity;
} }
@ -311,6 +273,7 @@ public class dimHelper extends DimensionManager
if(this.dimList.containsKey(destinationID) && this.dimList.containsKey(world.provider.dimensionId)) if(this.dimList.containsKey(destinationID) && this.dimList.containsKey(world.provider.dimensionId))
{ {
this.generatePocket(linkData); this.generatePocket(linkData);
if(mod_pocketDim.teleTimer==0||entity instanceof EntityPlayer) if(mod_pocketDim.teleTimer==0||entity instanceof EntityPlayer)
{ {
mod_pocketDim.teleTimer=2+rand.nextInt(2); mod_pocketDim.teleTimer=2+rand.nextInt(2);
@ -319,19 +282,12 @@ public class dimHelper extends DimensionManager
{ {
return; return;
} }
if(!world.isRemote) if(!world.isRemote)
{ {
entity = this.teleportEntity(world, entity, linkData); entity = this.teleportEntity(world, entity, linkData);
} }
entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, "mob.endermen.portal", 1.0F, 1.0F); entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, "mob.endermen.portal", 1.0F, 1.0F);
int playerXCoord=MathHelper.floor_double(entity.posX); int playerXCoord=MathHelper.floor_double(entity.posX);
int playerYCoord=MathHelper.floor_double(entity.posY); int playerYCoord=MathHelper.floor_double(entity.posY);
int playerZCoord=MathHelper.floor_double(entity.posZ); int playerZCoord=MathHelper.floor_double(entity.posZ);
@ -350,16 +306,12 @@ public class dimHelper extends DimensionManager
} }
} }
} }
if(entity.worldObj.getBlockId(playerXCoord, playerYCoord-1,playerZCoord )==Block.lavaStill.blockID) if(entity.worldObj.getBlockId(playerXCoord, playerYCoord-1,playerZCoord )==Block.lavaStill.blockID)
{ {
entity.worldObj.setBlock(playerXCoord, playerYCoord-1, playerZCoord, properties.FabricBlockID); entity.worldObj.setBlock(playerXCoord, playerYCoord-1, playerZCoord, properties.FabricBlockID);
} }
this.generateDoor(world,linkData); this.generateDoor(world,linkData);
if(Block.blocksList.length>=entity.worldObj.getBlockId(playerXCoord,playerYCoord+1,playerZCoord)&&!entity.worldObj.isAirBlock(playerXCoord,playerYCoord+1,playerZCoord)) if(Block.blocksList.length>=entity.worldObj.getBlockId(playerXCoord,playerYCoord+1,playerZCoord)&&!entity.worldObj.isAirBlock(playerXCoord,playerYCoord+1,playerZCoord))
{ {
if(Block.blocksList[entity.worldObj.getBlockId(playerXCoord,playerYCoord+1,playerZCoord)].isOpaqueCube()&&!mod_pocketDim.blocksImmuneToRift.contains(entity.worldObj.getBlockId(playerXCoord,playerYCoord+1,playerZCoord))) if(Block.blocksList[entity.worldObj.getBlockId(playerXCoord,playerYCoord+1,playerZCoord)].isOpaqueCube()&&!mod_pocketDim.blocksImmuneToRift.contains(entity.worldObj.getBlockId(playerXCoord,playerYCoord+1,playerZCoord)))
@ -372,7 +324,6 @@ public class dimHelper extends DimensionManager
if(Block.blocksList[entity.worldObj.getBlockId(playerXCoord,playerYCoord,playerZCoord)].isOpaqueCube()&&!mod_pocketDim.blocksImmuneToRift.contains(entity.worldObj.getBlockId(playerXCoord,playerYCoord,playerZCoord))) if(Block.blocksList[entity.worldObj.getBlockId(playerXCoord,playerYCoord,playerZCoord)].isOpaqueCube()&&!mod_pocketDim.blocksImmuneToRift.contains(entity.worldObj.getBlockId(playerXCoord,playerYCoord,playerZCoord)))
{ {
entity.worldObj.setBlock(playerXCoord,playerYCoord,playerZCoord,0); entity.worldObj.setBlock(playerXCoord,playerYCoord,playerZCoord,0);
} }
} }
} }
@ -385,11 +336,8 @@ public class dimHelper extends DimensionManager
} }
} }
return; return;
} }
/** /**
* Creates a link at the location, pointing to the destination. Does NOT create a pair, so must be called twice. * Creates a link at the location, pointing to the destination. Does NOT create a pair, so must be called twice.
* @param locationDimID * @param locationDimID
@ -408,7 +356,6 @@ public class dimHelper extends DimensionManager
if(this.getLinkDataFromCoords(locationXCoord, locationYCoord, locationZCoord, locationDimID)!=null) if(this.getLinkDataFromCoords(locationXCoord, locationYCoord, locationZCoord, locationDimID)!=null)
{ {
return this.createLink(locationDimID, destinationDimID, locationXCoord, locationYCoord, locationZCoord, destinationXCoord, destinationYCoord, destinationZCoord, this.getLinkDataFromCoords(locationXCoord, locationYCoord, locationZCoord, locationDimID).linkOrientation); return this.createLink(locationDimID, destinationDimID, locationXCoord, locationYCoord, locationZCoord, destinationXCoord, destinationYCoord, destinationZCoord, this.getLinkDataFromCoords(locationXCoord, locationYCoord, locationZCoord, locationDimID).linkOrientation);
} }
else else
{ {
@ -436,7 +383,6 @@ public class dimHelper extends DimensionManager
return this.createLink(linkData); return this.createLink(linkData);
} }
public LinkData createLink(LinkData link) public LinkData createLink(LinkData link)
{ {
DDProperties properties = DDProperties.instance(); DDProperties properties = DDProperties.instance();
@ -446,52 +392,29 @@ public class dimHelper extends DimensionManager
DimData locationDimData= new DimData(link.locDimID, false, 0, link.locDimID,link.locXCoord,link.locYCoord,link.locZCoord); DimData locationDimData= new DimData(link.locDimID, false, 0, link.locDimID,link.locXCoord,link.locYCoord,link.locZCoord);
this.dimList.put(link.locDimID, locationDimData); this.dimList.put(link.locDimID, locationDimData);
link.isLocPocket=false; link.isLocPocket=false;
} }
if(!dimList.containsKey(link.destDimID)) if(!dimList.containsKey(link.destDimID))
{ {
dimHelper.dimList.put(link.destDimID, new DimData(link.destDimID, false, 0, link.locDimID,link.locXCoord,link.locYCoord,link.locZCoord)); 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);
link.isLocPocket=locationDimData.isPocket; link.isLocPocket=locationDimData.isPocket;
locationDimData.addLinkToDim(link); locationDimData.addLinkToDim(link);
//this.linksForRendering.add(link);
if(dimHelper.getWorld(link.locDimID)!=null) if(dimHelper.getWorld(link.locDimID)!=null)
{ {
//World world =dimHelper.getWorld(link.locDimID);
int blocktoReplace = dimHelper.getWorld(link.locDimID).getBlockId(link.locXCoord, link.locYCoord, link.locZCoord); int blocktoReplace = dimHelper.getWorld(link.locDimID).getBlockId(link.locXCoord, link.locYCoord, link.locZCoord);
if(!mod_pocketDim.blocksImmuneToRift.contains(blocktoReplace)) if(!mod_pocketDim.blocksImmuneToRift.contains(blocktoReplace))
{ {
dimHelper.getWorld(link.locDimID).setBlock(link.locXCoord, link.locYCoord, link.locZCoord, properties.RiftBlockID); dimHelper.getWorld(link.locDimID).setBlock(link.locXCoord, link.locYCoord, link.locZCoord, properties.RiftBlockID);
} }
} }
//Notifies other players that a link has been created. //Notifies other players that a link has been created.
if(FMLCommonHandler.instance().getEffectiveSide()==Side.SERVER) if(FMLCommonHandler.instance().getEffectiveSide()==Side.SERVER)
{ {
// System.out.println("Sending link creation packet with orientation "+link.linkOrientation);
PacketHandler.onLinkCreatedPacket(link); PacketHandler.onLinkCreatedPacket(link);
} }
return link; return link;
} }
public int getDestOrientation(LinkData link) public int getDestOrientation(LinkData link)
@ -506,7 +429,6 @@ public class dimHelper extends DimensionManager
else else
{ {
//System.out.println("Cant find destination link"); //System.out.println("Cant find destination link");
return 0; return 0;
} }
} }
@ -517,10 +439,8 @@ public class dimHelper extends DimensionManager
} }
} }
public void removeLink(LinkData link) public void removeLink(LinkData link)
{ {
this.removeLink(link.locDimID, link.locXCoord, link.locYCoord, link.locZCoord); this.removeLink(link.locDimID, link.locXCoord, link.locYCoord, link.locZCoord);
} }
@ -533,34 +453,24 @@ public class dimHelper extends DimensionManager
*/ */
public void removeLink( int locationDimID, int locationXCoord, int locationYCoord, int locationZCoord) public void removeLink( int locationDimID, int locationXCoord, int locationYCoord, int locationZCoord)
{ {
if(!this.dimList.containsKey(locationDimID)) if(!this.dimList.containsKey(locationDimID))
{ {
DimData locationDimData= new DimData(locationDimID, false, 0, locationDimID,locationXCoord,locationYCoord,locationZCoord); DimData locationDimData= new DimData(locationDimID, false, 0, locationDimID,locationXCoord,locationYCoord,locationZCoord);
this.dimList.put(locationDimID, locationDimData); this.dimList.put(locationDimID, locationDimData);
} }
LinkData link = this.getLinkDataFromCoords(locationXCoord, locationYCoord, locationZCoord, locationDimID); LinkData link = this.getLinkDataFromCoords(locationXCoord, locationYCoord, locationZCoord, locationDimID);
// this.linksForRendering.remove(link);
this.dimList.get(locationDimID).removeLinkAtCoords(link); this.dimList.get(locationDimID).removeLinkAtCoords(link);
//updates clients that a rift has been removed //updates clients that a rift has been removed
if(FMLCommonHandler.instance().getEffectiveSide()==Side.SERVER) if(FMLCommonHandler.instance().getEffectiveSide()==Side.SERVER)
{ {
PacketHandler.onLinkRemovedPacket(link); PacketHandler.onLinkRemovedPacket(link);
this.save(); this.save();
} }
} }
public LinkData findNearestRift(World world, int x, int y, int z, int range) public LinkData findNearestRift(World world, int x, int y, int z, int range)
{ {
return this.dimList.get(world).findNearestRift(world, range, x, y, z); return this.dimList.get(world).findNearestRift(world, range, x, y, z);
} }
/** /**
* generates a door based on what door was used to teleport. Only funtions once per linking. * generates a door based on what door was used to teleport. Only funtions once per linking.
* @param world- door * @param world- door
@ -580,22 +490,13 @@ public class dimHelper extends DimensionManager
if(!incLink.hasGennedDoor) if(!incLink.hasGennedDoor)
{ {
int destinationID = incLink.destDimID; int destinationID = incLink.destDimID;
DimData data = this.dimList.get(destinationID); DimData data = this.dimList.get(destinationID);
int id =world.getBlockId(locX, locY, locZ); int id =world.getBlockId(locX, locY, locZ);
if(id==properties.WarpDoorID||id==properties.DimensionalDoorID||id==properties.TransientDoorID) if(id==properties.WarpDoorID||id==properties.DimensionalDoorID||id==properties.TransientDoorID)
{ {
int doorTypeToPlace=id; int doorTypeToPlace=id;
// World destWorld = this.getWorld(destinationID);
if(this.getWorld(destinationID)==null) if(this.getWorld(destinationID)==null)
{ {
this.initDimension(destinationID); this.initDimension(destinationID);
@ -608,8 +509,6 @@ public class dimHelper extends DimensionManager
destOrientation = destLink.linkOrientation; destOrientation = destLink.linkOrientation;
destLink.hasGennedDoor=true; destLink.hasGennedDoor=true;
} }
int blockToReplace= this.getWorld(destinationID).getBlockId(destX, destY, destZ); int blockToReplace= this.getWorld(destinationID).getBlockId(destX, destY, destZ);
if(blockToReplace!=properties.DimensionalDoorID&&blockToReplace!=properties.WarpDoorID&&blockToReplace != properties.TransientDoorID) if(blockToReplace!=properties.DimensionalDoorID&&blockToReplace!=properties.WarpDoorID&&blockToReplace != properties.TransientDoorID)
{ {
@ -617,9 +516,6 @@ public class dimHelper extends DimensionManager
this.getWorld(destinationID).setBlock(destX, destY, destZ, doorTypeToPlace,8,2); this.getWorld(destinationID).setBlock(destX, destY, destZ, doorTypeToPlace,8,2);
// System.out.println("Genned door"); // System.out.println("Genned door");
} }
incLink.hasGennedDoor=true; incLink.hasGennedDoor=true;
} }
} }
@ -642,10 +538,8 @@ public class dimHelper extends DimensionManager
public void generatePocket(LinkData incomingLink) public void generatePocket(LinkData incomingLink)
{ {
DDProperties properties = DDProperties.instance(); DDProperties properties = DDProperties.instance();
try try
{ {
if(this.getWorld(incomingLink.destDimID)==null) if(this.getWorld(incomingLink.destDimID)==null)
{ {
this.initDimension(incomingLink.destDimID); this.initDimension(incomingLink.destDimID);
@ -707,8 +601,6 @@ public class dimHelper extends DimensionManager
if(!this.getWorld(incomingLink.destDimID).isRemote) if(!this.getWorld(incomingLink.destDimID).isRemote)
{ {
int xCount=-searchRadius; int xCount=-searchRadius;
int yCount=-searchRadius; int yCount=-searchRadius;
int zCount=-searchRadius; int zCount=-searchRadius;
@ -719,13 +611,11 @@ public class dimHelper extends DimensionManager
{ {
while(zCount<=searchRadius) while(zCount<=searchRadius)
{ {
if((Math.abs(xCount)>=15||Math.abs(yCount)>=15||Math.abs(zCount)>=15)&&this.getWorld(incomingLink.destDimID).isAirBlock( x+xCount, y+yCount, z+zCount)&&((yCount+y)>0)) if((Math.abs(xCount)>=15||Math.abs(yCount)>=15||Math.abs(zCount)>=15)&&this.getWorld(incomingLink.destDimID).isAirBlock( x+xCount, y+yCount, z+zCount)&&((yCount+y)>0))
{ {
if(Math.abs(xCount)>=19||Math.abs(yCount)>=19||Math.abs(zCount)>=19) if(Math.abs(xCount)>=19||Math.abs(yCount)>=19||Math.abs(zCount)>=19)
{ {
this.setBlockDirectly(this.getWorld(incomingLink.destDimID), x+xCount, y+yCount, z+zCount,properties.PermaFabricBlockID,0); this.setBlockDirectly(this.getWorld(incomingLink.destDimID), x+xCount, y+yCount, z+zCount,properties.PermaFabricBlockID,0);
} }
else else
{ {
@ -739,7 +629,6 @@ public class dimHelper extends DimensionManager
} }
} }
} }
zCount++; zCount++;
} }
zCount=-searchRadius; zCount=-searchRadius;
@ -764,17 +653,11 @@ public class dimHelper extends DimensionManager
public void initPockets() public void initPockets()
{ {
DDProperties properties = DDProperties.instance(); DDProperties properties = DDProperties.instance();
mod_pocketDim.hasInitDims=true; mod_pocketDim.hasInitDims=true;
this.load(); this.load();
if(!dimHelper.dimList.isEmpty()) if(!dimHelper.dimList.isEmpty())
{ {
Set allDimIds=dimList.keySet(); Set allDimIds=dimList.keySet();
Iterator itr =allDimIds.iterator(); Iterator itr =allDimIds.iterator();
while(itr.hasNext()) while(itr.hasNext())
{ {
@ -804,7 +687,6 @@ public class dimHelper extends DimensionManager
public boolean resetPocket(DimData dimData) public boolean resetPocket(DimData dimData)
{ {
//TODO: Should we add a check to see if the dimension is currently loaded? How could we check that? ~SenseiKiwi
if (!dimData.isPocket || getWorld(dimData.dimID) != null) if (!dimData.isPocket || getWorld(dimData.dimID) != null)
{ {
return false; return false;
@ -827,9 +709,9 @@ public class dimHelper extends DimensionManager
public boolean pruneDimension(DimData dimData, boolean deleteFolder) public boolean pruneDimension(DimData dimData, boolean deleteFolder)
{ {
//TODO: Should we add a check to see if the dimension is currently loaded? How could we check that? ~SenseiKiwi
//TODO: All the logic for checking that this is an isolated pocket should be moved in here. //TODO: All the logic for checking that this is an isolated pocket should be moved in here.
if (!dimData.isPocket || getWorld(dimData.dimID) != null) if (!dimData.isPocket || getWorld(dimData.dimID) != null)//Checks to see if the pocket is loaded or isnt actually a pocket.
{ {
return false; return false;
} }
@ -852,7 +734,6 @@ public class dimHelper extends DimensionManager
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())
{ {
@ -869,11 +750,8 @@ public class dimHelper extends DimensionManager
} }
// initDimension(dimData.dimID); // initDimension(dimData.dimID);
} }
} }
} }
} }
/** /**
@ -1407,5 +1285,28 @@ public class dimHelper extends DimensionManager
this.dimList.put(world.provider.dimensionId, new DimData(world.provider.dimensionId, false, 0,0,world.provider.getSpawnPoint().posX,world.provider.getSpawnPoint().posY,world.provider.getSpawnPoint().posZ)); this.dimList.put(world.provider.dimensionId, new DimData(world.provider.dimensionId, false, 0,0,world.provider.getSpawnPoint().posX,world.provider.getSpawnPoint().posY,world.provider.getSpawnPoint().posZ));
} }
public DimData getDimData(World world)
{
if(this.dimList.containsKey(world.provider.dimensionId))
{
return this.dimList.get(world.provider.dimensionId);
}
else
{
return null;
}
}
public DimData getDimData(int dimID)
{
if(this.dimList.containsKey(dimID))
{
return this.dimList.get(dimID);
}
else
{
return null;
}
}
} }

View file

@ -40,8 +40,20 @@ public class pocketTeleporter
int id; int id;
//TODO Temporary workaround for mismatched door/rift metadata cases. Gives priority to the door.
id=dimHelper.instance.getDestOrientation(sendingLink); id=dimHelper.instance.getDestOrientation(sendingLink);
int receivingDoorMeta=world.getBlockMetadata(link.destXCoord, link.destYCoord-1, link.destZCoord);
int recevingDoorID=world.getBlockId(link.destXCoord, link.destYCoord, link.destZCoord);
if(receivingDoorMeta!=id)
{
if(recevingDoorID==mod_pocketDim.dimDoor.blockID||recevingDoorID==mod_pocketDim.ExitDoor.blockID)
{
dimHelper.instance.getLinkDataFromCoords(link.destXCoord, link.destYCoord, link.destZCoord, world).linkOrientation=receivingDoorMeta;
id=receivingDoorMeta;
}
}
if(par1Entity instanceof EntityPlayer) if(par1Entity instanceof EntityPlayer)