diff --git a/Steven/Common/mod_pocketDim/DimData.java b/Steven/Common/mod_pocketDim/DimData.java deleted file mode 100644 index 6089c05..0000000 --- a/Steven/Common/mod_pocketDim/DimData.java +++ /dev/null @@ -1,194 +0,0 @@ -package Steven.Common.mod_pocketDim; - -import java.awt.List; -import java.io.Serializable; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; -import net.minecraft.util.MathHelper; -import net.minecraft.world.World; - -public class DimData - implements Serializable -{ - public int dimID; - public boolean isPocket; - public int depth; - public World world; - public LinkData exitDimLink; - public boolean hasBeenFilled = false; - public boolean hasDoor = false; - public int dimOrientation; - public boolean isDimRandomRift = false; - public HashMap linksInThisDim = new HashMap(); - HashMap dimX; - HashMap dimY; - - public DimData(int dimID, boolean isPocket, int depth, LinkData exitLinkData) - { - this.dimID = dimID; - this.depth = depth; - this.isPocket = isPocket; - - this.exitDimLink = exitLinkData; - } - - public DimData(int dimID, boolean isPocket, int depth, int exitLinkDimID, int exitX, int exitY, int exitZ) - { - this.dimID = dimID; - this.depth = depth; - this.isPocket = isPocket; - - this.exitDimLink = new LinkData(exitLinkDimID, exitX, exitY, exitZ); - } - - public LinkData findNearestRift(World world, int range, int x, int y, int z) - { - LinkData nearest = null; - float distance = range + 1; - int i = -range; - int j = -range; - int k = -range; - - while (i < range) - { - while (j < range) - { - while (k < range) - { - if ((world.getBlockId(x + i, y + j, z + k) == mod_pocketDim.blockRiftID) && (MathHelper.abs(i) + MathHelper.abs(j) + MathHelper.abs(k) < distance)) - { - if (MathHelper.abs(i) + MathHelper.abs(j) + MathHelper.abs(k) != 0.0F) - { - nearest = findLinkAtCoords(x + i, y + j, z + k); - distance = MathHelper.abs(i) + MathHelper.abs(j) + MathHelper.abs(k); - } - } - - k++; - } - k = -range; - j++; - } - - j = -range; - i++; - } - - return nearest; - } - - public LinkData addLinkToDim(int destinationDimID, int locationXCoord, int locationYCoord, int locationZCoord, int destinationXCoord, int destinationYCoord, int destinationZCoord) - { - if (this.linksInThisDim.containsKey(Integer.valueOf(locationZCoord))) - { - this.dimY = ((HashMap)this.linksInThisDim.get(Integer.valueOf(locationZCoord))); - - if (this.dimY.containsKey(Integer.valueOf(locationYCoord))) - { - this.dimX = ((HashMap)this.dimY.get(Integer.valueOf(locationYCoord))); - } - else - { - this.dimX = new HashMap(); - } - } - else - { - this.dimX = new HashMap(); - this.dimY = new HashMap(); - } - - LinkData linkData = new LinkData(this.dimID, destinationDimID, locationXCoord, locationYCoord, locationZCoord, destinationXCoord, destinationYCoord, destinationZCoord, this.isPocket); - - this.dimX.put(Integer.valueOf(locationXCoord), linkData); - this.dimY.put(Integer.valueOf(locationYCoord), this.dimX); - this.linksInThisDim.put(Integer.valueOf(locationZCoord), this.dimY); - - return linkData; - } - - public void removeLinkAtCoords(int locationID, int locationXCoord, int locationYCoord, int locationZCoord) - { - if (this.linksInThisDim.containsKey(Integer.valueOf(locationZCoord))) - { - this.dimY = ((HashMap)this.linksInThisDim.get(Integer.valueOf(locationZCoord))); - - if (this.dimY.containsKey(Integer.valueOf(locationYCoord))) - { - this.dimX = ((HashMap)this.dimY.get(Integer.valueOf(locationYCoord))); - } - else - { - this.dimX = new HashMap(); - } - } - else - { - this.dimX = new HashMap(); - this.dimY = new HashMap(); - } - - this.dimX.remove(Integer.valueOf(locationXCoord)); - this.dimY.put(Integer.valueOf(locationYCoord), this.dimX); - this.linksInThisDim.put(Integer.valueOf(locationZCoord), this.dimY); - } - - public LinkData findLinkAtCoords(int locationXCoord, int locationYCoord, int locationZCoord) - { - try - { - if (this.linksInThisDim.containsKey(Integer.valueOf(locationZCoord))) - { - this.dimY = ((HashMap)this.linksInThisDim.get(Integer.valueOf(locationZCoord))); - - if (this.dimY.containsKey(Integer.valueOf(locationYCoord))) - { - this.dimX = ((HashMap)this.dimY.get(Integer.valueOf(locationYCoord))); - - if (this.dimX.containsKey(Integer.valueOf(locationXCoord))) - { - return (LinkData)this.dimX.get(Integer.valueOf(locationXCoord)); - } - } - } - - } - catch (Exception E) - { - return null; - } - - return null; - } - - public Collection getAllLinkData() - { - Iterator itr = this.linksInThisDim.keySet().iterator(); - Collection linksInDim = (Collection) new HashSet(); - - while (itr.hasNext()) - { - HashMap first = (HashMap)this.linksInThisDim.get((Integer)itr.next()); - - Iterator itrfirst = first.keySet().iterator(); - - while (itrfirst.hasNext()) - { - HashMap second = (HashMap)first.get((Integer)itrfirst.next()); - - Iterator itrsecond = second.keySet().iterator(); - while (itrsecond.hasNext()) - { - LinkData link = (LinkData)second.get((Integer)itrsecond.next()); - - linksInDim.add(link); - } - } - } - return linksInDim; - } - -} \ No newline at end of file diff --git a/Steven/Common/mod_pocketDim/LinkData.java b/Steven/Common/mod_pocketDim/LinkData.java deleted file mode 100644 index 9264a8f..0000000 --- a/Steven/Common/mod_pocketDim/LinkData.java +++ /dev/null @@ -1,56 +0,0 @@ -package Steven.Common.mod_pocketDim; - -import java.io.PrintStream; -import java.io.Serializable; - -public class LinkData - implements Serializable -{ - public int locXCoord; - public int locYCoord; - public int locZCoord; - public int destXCoord; - public int destYCoord; - public int destZCoord; - public int numberofChildren = 0; - public boolean isLocPocket; - public int linkOrientation; - public int destDimID; - public int locDimID; - public boolean exists = false; - - public LinkData() - { - this.exists = false; - } - - public LinkData(int exitLinkDimID, int exitX, int exitY, int exitZ) - { - this.destDimID = exitLinkDimID; - this.destXCoord = exitX; - this.destYCoord = exitY; - this.destZCoord = exitZ; - } - - public LinkData(int locationDimID, int destinationDimID, int locationXCoord, int locationYCoord, int locationZCoord, int destinationXCoord, int destinationYCoord, int destinationZCoord, boolean isPocket) - { - this.exists = true; - this.locXCoord = locationXCoord; - this.locYCoord = locationYCoord; - this.locZCoord = locationZCoord; - - this.destXCoord = destinationXCoord; - this.destYCoord = destinationYCoord; - this.destZCoord = destinationZCoord; - - this.destDimID = destinationDimID; - this.locDimID = locationDimID; - this.isLocPocket = isPocket; - } - - public void printLinkData() - { - System.out.println(String.valueOf(this.locDimID) + "locDimID " + String.valueOf(this.locXCoord) + "-locXCoord " + String.valueOf(this.locYCoord) + "-locYCoord " + String.valueOf(this.locZCoord) + "-locZCoord "); - System.out.println(String.valueOf(this.destDimID) + "DestDimID " + String.valueOf(this.destXCoord) + "-destXCoord " + String.valueOf(this.destYCoord) + "-destYCoord " + String.valueOf(this.destZCoord) + "-destZCoord "); - } -} \ No newline at end of file diff --git a/Steven/Common/mod_pocketDim/mod_pocketDim.java b/Steven/Common/mod_pocketDim/mod_pocketDim.java deleted file mode 100644 index 7c0d632..0000000 --- a/Steven/Common/mod_pocketDim/mod_pocketDim.java +++ /dev/null @@ -1,6 +0,0 @@ -package Steven.Common.mod_pocketDim; - -public class mod_pocketDim extends StevenDimDoors.mod_pocketDim.mod_pocketDim -{ - -} \ No newline at end of file diff --git a/StevenDimDoors/mod_pocketDim/ExitDoor.java b/StevenDimDoors/mod_pocketDim/ExitDoor.java index 113aea6..e965e28 100644 --- a/StevenDimDoors/mod_pocketDim/ExitDoor.java +++ b/StevenDimDoors/mod_pocketDim/ExitDoor.java @@ -96,30 +96,7 @@ public class ExitDoor extends dimDoor //this.onPoweredBlockChange(par1World, par2, par3, par4, false); } - @Override - public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) - { - int var12 = (int) (MathHelper.floor_double((double)((par5Entity.rotationYaw+90) * 4.0F / 360.0F) + 0.5D) & 3); - - int num = par1World.getBlockMetadata(par2, par3-1, par4); - if(!par1World.isRemote&&(num==5||num==4||num==6||num==7)&&(num-4)==var12&&par1World.getBlockId(par2, par3-1, par4)==mod_pocketDim.ExitDoorID||!par1World.isRemote&&(num==5||num==4||num==6||num==7)&&par1World.getBlockId(par2, par3-1, par4)==mod_pocketDim.ExitDoorID&&!(par5Entity instanceof EntityPlayer) ) - { - - //int destinationID= dimHelper.instance.getDestIDFromCoords(par2, par3, par4, par1World); - - this.onPoweredBlockChange(par1World, par2, par3, par4, false); - - LinkData linkData= dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World); - if(linkData!=null) - { - if(dimHelper.dimList.containsKey(linkData.destDimID)) - dimHelper.instance.teleportToPocket(par1World, linkData, par5Entity); - } - - - - } - } + public int idPicked(World par1World, int par2, int par3, int par4) { diff --git a/StevenDimDoors/mod_pocketDim/LimboProvider.java b/StevenDimDoors/mod_pocketDim/LimboProvider.java index 7fc2c99..b35de3e 100644 --- a/StevenDimDoors/mod_pocketDim/LimboProvider.java +++ b/StevenDimDoors/mod_pocketDim/LimboProvider.java @@ -34,7 +34,7 @@ public class LimboProvider extends WorldProvider public boolean canRespawnHere() { - return mod_pocketDim.hardcoreLimbo; + return mod_pocketDim.hardcoreLimbo&&mod_pocketDim.isLimboActive; } public boolean isBlockHighHumidity(int x, int y, int z) { diff --git a/StevenDimDoors/mod_pocketDim/dimDoor.java b/StevenDimDoors/mod_pocketDim/dimDoor.java index 7bc3876..1313c2a 100644 --- a/StevenDimDoors/mod_pocketDim/dimDoor.java +++ b/StevenDimDoors/mod_pocketDim/dimDoor.java @@ -89,6 +89,8 @@ public class dimDoor extends BlockContainer linkData= dimHelper.instance.getLinkDataFromCoords(par2, par3+1, par4, par1World); } + + if(!par1World.isRemote&&(num==5||num==4||num==6||num==7)&&(num-4)==var12) { diff --git a/StevenDimDoors/mod_pocketDim/dimHelper.java b/StevenDimDoors/mod_pocketDim/dimHelper.java index 9a6f72c..002747b 100644 --- a/StevenDimDoors/mod_pocketDim/dimHelper.java +++ b/StevenDimDoors/mod_pocketDim/dimHelper.java @@ -24,6 +24,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.packet.Packet39AttachEntity; import net.minecraft.network.packet.Packet41EntityEffect; import net.minecraft.network.packet.Packet43Experience; import net.minecraft.network.packet.Packet9Respawn; @@ -37,6 +38,7 @@ import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.storage.ExtendedBlockStorage; import net.minecraftforge.common.DimensionManager; import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.network.PacketDispatcher; import cpw.mods.fml.relauncher.Side; public class dimHelper extends DimensionManager @@ -151,83 +153,118 @@ public class dimHelper extends DimensionManager playerMP.mcServer.getConfigurationManager().transferPlayerToDimension(playerMP, mod_pocketDim.limboDimID, new pocketTeleporter((WorldServer) this.getWorld(mod_pocketDim.limboDimID), linkData)); } - private void teleportEntity(World oldWorld, Entity entity, LinkData link) + private Entity teleportEntity(World oldWorld, Entity entity, LinkData link) //this beautiful teleport method is based off of xCompWiz's teleport function. { + Entity cart; + if(entity.riddenByEntity!=null) + { + cart= entity; + entity=entity.riddenByEntity; + } + else + { + + cart = entity.ridingEntity; + } + if (entity.ridingEntity != null) + { + + entity.mountEntity(entity.ridingEntity); + + cart = teleportEntity(oldWorld, cart, link); + + } + + + + + World newWorld; if(this.getWorld(link.destDimID)==null) { this.initDimension(link.destDimID); } - World newWorld = this.getWorld(link.destDimID); - Entity mount = entity.ridingEntity; - Entity rider = entity.riddenByEntity; - if (entity.ridingEntity != null) - { - entity.mountEntity(null); - mount.riddenByEntity = null; - teleportEntity(oldWorld, mount, link); - } - - if (entity.riddenByEntity != null) - { - rider.mountEntity(null); - entity.riddenByEntity = null; - teleportEntity(oldWorld, rider, link); - } - - boolean changingworlds = entity.worldObj != newWorld; + boolean difDest = link.destDimID != link.locDimID; + + if(difDest) + { + newWorld = this.getWorld(link.destDimID); + } + else + { + newWorld=oldWorld; + } + entity.worldObj.updateEntityWithOptionalForce(entity, false); + if ((entity instanceof EntityPlayerMP)) { + EntityPlayerMP player = (EntityPlayerMP)entity; - player.closeScreen(); - if (changingworlds) + //player.closeScreen(); + + + if (difDest) { player.dimension = link.destDimID; player.playerNetServerHandler.sendPacketToPlayer(new Packet9Respawn(player.dimension, (byte)player.worldObj.difficultySetting, newWorld.getWorldInfo().getTerrainType(), newWorld.getHeight(), player.theItemInWorldManager.getGameType())); - ((WorldServer)entity.worldObj).getPlayerManager().removePlayer(player); + WorldServer.class.cast(entity.worldObj).getPlayerManager().removePlayer(player); } } - if(changingworlds) + + + if(difDest) { + int entX = entity.chunkCoordX; + int entZ = entity.chunkCoordZ; + if ((entity instanceof EntityPlayer)) { EntityPlayer player = (EntityPlayer)entity; - player.closeScreen(); + + //player.closeScreen(); + oldWorld.playerEntities.remove(player); - oldWorld.updateAllPlayersSleepingFlag(); + //oldWorld.updateAllPlayersSleepingFlag(); } - int i = entity.chunkCoordX; - int j = entity.chunkCoordZ; - if ((entity.addedToChunk) && (oldWorld.getChunkProvider().chunkExists(i, j))) + + if ((entity.addedToChunk) && (oldWorld.getChunkProvider().chunkExists(entX, entZ))) { - oldWorld.getChunkFromChunkCoords(i, j).removeEntity(entity); - oldWorld.getChunkFromChunkCoords(i, j).isModified = true; + oldWorld.getChunkFromChunkCoords(entX, entZ).removeEntity(entity); + oldWorld.getChunkFromChunkCoords(entX, entZ).isModified = true; } + oldWorld.loadedEntityList.remove(entity); oldWorld.releaseEntitySkin(entity); + entity.isDead = false; } - ((WorldServer)newWorld).theChunkProviderServer.loadChunk(MathHelper.floor_double(entity.posX) >> 4, MathHelper.floor_double(entity.posZ) >> 4); - + WorldServer.class.cast(newWorld).theChunkProviderServer.loadChunk(MathHelper.floor_double(entity.posX) >> 4, MathHelper.floor_double(entity.posZ) >> 4); + + new pocketTeleporter((WorldServer) newWorld, link).placeInPortal(entity, 0, 0, 0, 0); - if (changingworlds) + if (difDest) { if (!(entity instanceof EntityPlayer)) { NBTTagCompound entityNBT = new NBTTagCompound(); + entity.isDead = false; + entity.addEntityID(entityNBT); + entity.isDead = true; + entity = EntityList.createEntityFromNBT(entityNBT, newWorld); + if (entity == null) { - return; + } } @@ -239,34 +276,41 @@ public class dimHelper extends DimensionManager } - - + new pocketTeleporter((WorldServer) newWorld, link).placeInPortal(entity, 0, 0, 0, 0); + entity.worldObj.updateEntityWithOptionalForce(entity, false); if ((entity instanceof EntityPlayerMP)) { EntityPlayerMP player = (EntityPlayerMP)entity; - if (changingworlds) + if (difDest) { player.mcServer.getConfigurationManager().func_72375_a(player, (WorldServer)newWorld); + + new pocketTeleporter((WorldServer) newWorld, link).placeInPortal(entity, 0, 0, 0, 0); + } } + entity.worldObj.updateEntityWithOptionalForce(entity, false); + - - if (((entity instanceof EntityPlayerMP)) && (changingworlds)) + if (((entity instanceof EntityPlayerMP)) && (difDest)) { EntityPlayerMP player = (EntityPlayerMP)entity; + player.theItemInWorldManager.setWorld((WorldServer)newWorld); + player.mcServer.getConfigurationManager().updateTimeAndWeatherForPlayer(player, (WorldServer)newWorld); player.mcServer.getConfigurationManager().syncPlayerInventory(player); - Iterator var14 = player.getActivePotionEffects().iterator(); - - while (var14.hasNext()) + + for(Object potionEffect : player.getActivePotionEffects()) { - PotionEffect var13 = (PotionEffect)var14.next(); - player.playerNetServerHandler.sendPacketToPlayer(new Packet41EntityEffect(player.entityId, var13)); + PotionEffect effect = (PotionEffect)potionEffect; + player.playerNetServerHandler.sendPacketToPlayer(new Packet41EntityEffect(player.entityId, effect)); + } + player.playerNetServerHandler.sendPacketToPlayer(new Packet43Experience(player.experience, player.experienceTotal, player.experienceLevel)); } @@ -274,24 +318,24 @@ public class dimHelper extends DimensionManager new pocketTeleporter((WorldServer) newWorld, link).placeInPortal(entity, 0, 0, 0, 0); - if ((entity != null) && (mount != null)) + if ((entity != null) && (cart != null)) { - entity.mountEntity(mount); - mount.updateRiderPosition(); + if ((entity instanceof EntityPlayerMP)) { - FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().serverUpdateMountedMovingPlayer((EntityPlayerMP)entity); - } - } - if ((entity != null) && (rider != null)) - { - rider.mountEntity(entity); - entity.updateRiderPosition(); - if ((rider instanceof EntityPlayerMP)) - { - FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().serverUpdateMountedMovingPlayer((EntityPlayerMP)rider); + EntityPlayerMP playerMP = (EntityPlayerMP)entity; + entity.worldObj.updateEntityWithOptionalForce(entity, true); + } + entity.mountEntity(cart); } + + + + return entity; + + + } /** * Primary function used to teleport the player using doors. Performes numerous null checks, and also generates the destination door/pocket if it has not done so already. @@ -365,10 +409,7 @@ public class dimHelper extends DimensionManager } } - if(!world.isRemote) - { - - } + } diff --git a/StevenDimDoors/mod_pocketDim/mod_pocketDim.java b/StevenDimDoors/mod_pocketDim/mod_pocketDim.java index 71b4542..0ed770f 100644 --- a/StevenDimDoors/mod_pocketDim/mod_pocketDim.java +++ b/StevenDimDoors/mod_pocketDim/mod_pocketDim.java @@ -263,7 +263,7 @@ public class mod_pocketDim this.riftsInWorldGen = config.get("BOOLEAN", "Should rifts generate natrually in the world? ", true).getBoolean(true); - this.isLimboActive = false;//config.get("BOOLEAN", "Toggles limbo", true).getBoolean(true); + this.isLimboActive = config.get("BOOLEAN", "Toggles limbo", true).getBoolean(true); this.riftSpreadFactor = config.get("Int", "How many times a rift can spread- 0 prevents rifts from spreading at all. I dont recommend putting it highter than 5, because its rather exponential. ", 3).getInt(); diff --git a/StevenDimDoors/mod_pocketDim/pocketTeleporter.java b/StevenDimDoors/mod_pocketDim/pocketTeleporter.java index 8a604d2..e7aef55 100644 --- a/StevenDimDoors/mod_pocketDim/pocketTeleporter.java +++ b/StevenDimDoors/mod_pocketDim/pocketTeleporter.java @@ -81,6 +81,7 @@ public class pocketTeleporter extends Teleporter } + else if(par1Entity instanceof EntityMinecart) { par1Entity.motionX=0; @@ -91,33 +92,41 @@ public class pocketTeleporter extends Teleporter id=dimHelper.instance.getDestOrientation(sendingLink); - + par1Entity.rotationYaw=(id*90)+90; if(id==2||id==6) { - par1Entity.motionX =2; + this.setEntityPosition(par1Entity, x+1.5, y, z+.5 ); + par1Entity.worldObj.updateEntityWithOptionalForce(par1Entity, false); + par1Entity.motionX =.39; } else if(id==3||id==7) { - par1Entity.motionZ =2; + this.setEntityPosition(par1Entity, x+.5, y, z+1.5 ); + par1Entity.worldObj.updateEntityWithOptionalForce(par1Entity, false); + par1Entity.motionZ =.39; } else if(id==0||id==4) { - par1Entity.motionX =-2; + this.setEntityPosition(par1Entity,x-.5, y, z+.5); + par1Entity.worldObj.updateEntityWithOptionalForce(par1Entity, false); + par1Entity.motionX =-.39; } else if(id==1||id==5) { - par1Entity.motionZ =-2; + this.setEntityPosition(par1Entity,x+.5, y, z-.5); + par1Entity.worldObj.updateEntityWithOptionalForce(par1Entity, false); + par1Entity.motionZ =-.39; } else @@ -126,7 +135,7 @@ public class pocketTeleporter extends Teleporter } - par1Entity.rotationYaw=(id*90)+90; + } @@ -178,7 +187,7 @@ public class pocketTeleporter extends Teleporter } - par1Entity.worldObj.updateEntityWithOptionalForce(par1Entity, false); + } public void setEntityPosition(Entity entity, double x, double y, double z)