streamlined teleport code
fixed bug with FoR
This commit is contained in:
@@ -2,10 +2,14 @@ package StevenDimDoors.mod_pocketDim;
|
|||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockContainer;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemBlock;
|
import net.minecraft.item.ItemBlock;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
@@ -39,26 +43,42 @@ public class BlockDimWall extends Block
|
|||||||
{
|
{
|
||||||
if(!par1World.isRemote&&entityPlayer.getCurrentEquippedItem()!=null)
|
if(!par1World.isRemote&&entityPlayer.getCurrentEquippedItem()!=null)
|
||||||
{
|
{
|
||||||
|
Item playerEquip = entityPlayer.getCurrentEquippedItem().getItem();
|
||||||
|
|
||||||
|
if(!(playerEquip instanceof ItemBlock))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Block block= Block.blocksList[playerEquip.itemID];
|
||||||
|
if(!Block.isNormalCube(playerEquip.itemID))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(block instanceof BlockContainer)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemBlock)
|
if(entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemBlock)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if(!entityPlayer.capabilities.isCreativeMode)
|
if(!entityPlayer.capabilities.isCreativeMode)
|
||||||
{
|
{
|
||||||
entityPlayer.getCurrentEquippedItem().stackSize--;
|
entityPlayer.getCurrentEquippedItem().stackSize--;
|
||||||
}
|
}
|
||||||
par1World.setBlockAndMetadataWithNotify(par2, par3, par4, entityPlayer.getCurrentEquippedItem().itemID, entityPlayer.getCurrentEquippedItem().getItemDamage());
|
par1World.setBlockAndMetadata(par2, par3, par4, entityPlayer.getCurrentEquippedItem().itemID, entityPlayer.getCurrentEquippedItem().getItemDamage());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if(par1World.isRemote&&entityPlayer.getCurrentEquippedItem()!=null)
|
else
|
||||||
{
|
{
|
||||||
|
return false;
|
||||||
if(entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemBlock)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -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.func_92014_d());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ public class dimHelper extends DimensionManager
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
World newWorld;
|
WorldServer newWorld;
|
||||||
|
|
||||||
if(this.getWorld(link.destDimID)==null)
|
if(this.getWorld(link.destDimID)==null)
|
||||||
{
|
{
|
||||||
@@ -194,7 +194,7 @@ public class dimHelper extends DimensionManager
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
newWorld=oldWorld;
|
newWorld=(WorldServer)oldWorld;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -211,8 +211,32 @@ public class dimHelper extends DimensionManager
|
|||||||
player.dimension = link.destDimID;
|
player.dimension = link.destDimID;
|
||||||
player.playerNetServerHandler.sendPacketToPlayer(new Packet9Respawn(player.dimension, (byte)player.worldObj.difficultySetting, newWorld.getWorldInfo().getTerrainType(), newWorld.getHeight(), player.theItemInWorldManager.getGameType()));
|
player.playerNetServerHandler.sendPacketToPlayer(new Packet9Respawn(player.dimension, (byte)player.worldObj.difficultySetting, newWorld.getWorldInfo().getTerrainType(), newWorld.getHeight(), player.theItemInWorldManager.getGameType()));
|
||||||
|
|
||||||
WorldServer.class.cast(entity.worldObj).getPlayerManager().removePlayer(player);
|
WorldServer.class.cast(oldWorld).removeEntity(player);
|
||||||
|
player.isDead=false;
|
||||||
|
|
||||||
|
oldWorld.playerEntities.remove(player);
|
||||||
|
WorldServer.class.cast(oldWorld).getPlayerManager().removePlayer(player);
|
||||||
|
newWorld.getPlayerManager().addPlayer(player);
|
||||||
|
player.theItemInWorldManager.setWorld(newWorld);
|
||||||
|
|
||||||
|
player.theItemInWorldManager.setWorld((WorldServer)newWorld);
|
||||||
|
|
||||||
|
player.mcServer.getConfigurationManager().updateTimeAndWeatherForPlayer(player, (WorldServer)newWorld);
|
||||||
|
player.mcServer.getConfigurationManager().syncPlayerInventory(player);
|
||||||
|
|
||||||
|
for(Object potionEffect : player.getActivePotionEffects())
|
||||||
|
{
|
||||||
|
PotionEffect effect = (PotionEffect)potionEffect;
|
||||||
|
player.playerNetServerHandler.sendPacketToPlayer(new Packet41EntityEffect(player.entityId, effect));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
player.playerNetServerHandler.sendPacketToPlayer(new Packet43Experience(player.experience, player.experienceTotal, player.experienceLevel));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
WorldServer.class.cast(newWorld).theChunkProviderServer.loadChunk(MathHelper.floor_double(entity.posX) >> 4, MathHelper.floor_double(entity.posZ) >> 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -221,15 +245,7 @@ public class dimHelper extends DimensionManager
|
|||||||
int entX = entity.chunkCoordX;
|
int entX = entity.chunkCoordX;
|
||||||
int entZ = entity.chunkCoordZ;
|
int entZ = entity.chunkCoordZ;
|
||||||
|
|
||||||
if ((entity instanceof EntityPlayer))
|
|
||||||
{
|
|
||||||
EntityPlayer player = (EntityPlayer)entity;
|
|
||||||
|
|
||||||
//player.closeScreen();
|
|
||||||
|
|
||||||
oldWorld.playerEntities.remove(player);
|
|
||||||
//oldWorld.updateAllPlayersSleepingFlag();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((entity.addedToChunk) && (oldWorld.getChunkProvider().chunkExists(entX, entZ)))
|
if ((entity.addedToChunk) && (oldWorld.getChunkProvider().chunkExists(entX, entZ)))
|
||||||
{
|
{
|
||||||
@@ -241,15 +257,7 @@ public class dimHelper extends DimensionManager
|
|||||||
oldWorld.releaseEntitySkin(entity);
|
oldWorld.releaseEntitySkin(entity);
|
||||||
|
|
||||||
entity.isDead = false;
|
entity.isDead = false;
|
||||||
}
|
|
||||||
|
|
||||||
WorldServer.class.cast(newWorld).theChunkProviderServer.loadChunk(MathHelper.floor_double(entity.posX) >> 4, MathHelper.floor_double(entity.posZ) >> 4);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (difDest)
|
|
||||||
{
|
|
||||||
if (!(entity instanceof EntityPlayer))
|
if (!(entity instanceof EntityPlayer))
|
||||||
{
|
{
|
||||||
NBTTagCompound entityNBT = new NBTTagCompound();
|
NBTTagCompound entityNBT = new NBTTagCompound();
|
||||||
@@ -275,41 +283,6 @@ public class dimHelper extends DimensionManager
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ((entity instanceof EntityPlayerMP))
|
|
||||||
{
|
|
||||||
EntityPlayerMP player = (EntityPlayerMP)entity;
|
|
||||||
|
|
||||||
if (difDest)
|
|
||||||
{
|
|
||||||
player.mcServer.getConfigurationManager().func_72375_a(player, (WorldServer)newWorld);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
for(Object potionEffect : player.getActivePotionEffects())
|
|
||||||
{
|
|
||||||
PotionEffect effect = (PotionEffect)potionEffect;
|
|
||||||
player.playerNetServerHandler.sendPacketToPlayer(new Packet41EntityEffect(player.entityId, effect));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
player.playerNetServerHandler.sendPacketToPlayer(new Packet43Experience(player.experience, player.experienceTotal, player.experienceLevel));
|
|
||||||
}
|
|
||||||
|
|
||||||
entity.worldObj.updateEntityWithOptionalForce(entity, false);
|
entity.worldObj.updateEntityWithOptionalForce(entity, false);
|
||||||
|
|
||||||
new pocketTeleporter((WorldServer) newWorld, link).placeInPortal(entity, 0, 0, 0, 0);
|
new pocketTeleporter((WorldServer) newWorld, link).placeInPortal(entity, 0, 0, 0, 0);
|
||||||
@@ -1186,7 +1159,7 @@ public class dimHelper extends DimensionManager
|
|||||||
ArrayList linksInDim=new ArrayList();
|
ArrayList linksInDim=new ArrayList();
|
||||||
for(size--;size>=0;)
|
for(size--;size>=0;)
|
||||||
{
|
{
|
||||||
dimData = dimHelper.dimList.get(rand.nextInt(dimList.size()));
|
dimData = dimHelper.dimList.get(dimList.keySet().toArray()[rand.nextInt(dimList.keySet().size())]);
|
||||||
if(dimData==null)
|
if(dimData==null)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user