Finished dim door rail compatability
todo- rift blade sound
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user