Natalie's NEI-breaking bug fix #70
@@ -7,14 +7,20 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import StevenDimDoors.mod_pocketDim.blocks.BlockRift;
|
||||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||||
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
||||||
import StevenDimDoors.mod_pocketDim.ticking.MobMonolith;
|
import StevenDimDoors.mod_pocketDim.ticking.MobMonolith;
|
||||||
|
|
||||||
|
import net.minecraft.entity.DataWatcher;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityList;
|
import net.minecraft.entity.EntityList;
|
||||||
import net.minecraft.entity.monster.EntityEnderman;
|
import net.minecraft.entity.monster.EntityEnderman;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.network.INetworkManager;
|
||||||
|
import net.minecraft.network.packet.Packet;
|
||||||
|
import net.minecraft.network.packet.Packet130UpdateSign;
|
||||||
|
import net.minecraft.network.packet.Packet132TileEntityData;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
@@ -35,10 +41,11 @@ public class TileEntityRift extends TileEntity
|
|||||||
|
|
||||||
public HashMap<Integer, double[]> renderingCenters = new HashMap<Integer, double[]>();
|
public HashMap<Integer, double[]> renderingCenters = new HashMap<Integer, double[]>();
|
||||||
public LinkData nearestRiftData;
|
public LinkData nearestRiftData;
|
||||||
Random rand = new Random();
|
Random rand;
|
||||||
|
DataWatcher watcher = new DataWatcher();
|
||||||
|
|
||||||
|
|
||||||
public float age = 0;
|
public int age = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -53,9 +60,16 @@ public class TileEntityRift extends TileEntity
|
|||||||
int x = MathHelper.floor_double(coord[0]+.5);
|
int x = MathHelper.floor_double(coord[0]+.5);
|
||||||
int y = MathHelper.floor_double(coord[1]+.5);
|
int y = MathHelper.floor_double(coord[1]+.5);
|
||||||
int z = MathHelper.floor_double(coord[2]+.5);
|
int z = MathHelper.floor_double(coord[2]+.5);
|
||||||
this.worldObj.setBlockToAir(this.xCoord+x, this.yCoord+y, this.zCoord+z);
|
|
||||||
|
|
||||||
this.worldObj.setBlockToAir(this.xCoord-x, this.yCoord+y, this.zCoord-z);
|
if(!BlockRift.isBlockImmune(worldObj,this.xCoord+x, this.yCoord+y, this.zCoord+z))
|
||||||
|
{
|
||||||
|
this.worldObj.setBlockToAir(this.xCoord+x, this.yCoord+y, this.zCoord+z);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!BlockRift.isBlockImmune(worldObj,this.xCoord-x, this.yCoord-y, this.zCoord-z))
|
||||||
|
{
|
||||||
|
this.worldObj.setBlockToAir(this.xCoord-x, this.yCoord-y, this.zCoord-z);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,9 +91,9 @@ public class TileEntityRift extends TileEntity
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
EntityEnderman enderman = new EntityEnderman(worldObj);
|
EntityEnderman creeper = new EntityEnderman(worldObj);
|
||||||
enderman.setLocationAndAngles(this.xCoord+.5, this.yCoord-1, this.zCoord+.5, 5, 6);
|
creeper.setLocationAndAngles(this.xCoord+.5, this.yCoord-1, this.zCoord+.5, 5, 6);
|
||||||
worldObj.spawnEntityInWorld(enderman);
|
worldObj.spawnEntityInWorld(creeper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -120,12 +134,19 @@ public class TileEntityRift extends TileEntity
|
|||||||
}
|
}
|
||||||
public void updateEntity()
|
public void updateEntity()
|
||||||
{
|
{
|
||||||
|
if(rand == null)
|
||||||
if(rand.nextInt(10)==0)
|
|
||||||
{
|
{
|
||||||
|
rand = new Random();
|
||||||
|
rand.setSeed(this.xCoord+this.yCoord+this.zCoord);
|
||||||
|
|
||||||
|
}
|
||||||
|
if(rand.nextInt(15) == 1)
|
||||||
|
{
|
||||||
|
|
||||||
age = age + 1;
|
age = age + 1;
|
||||||
this.calculateNextRenderQuad(age, rand);
|
this.calculateNextRenderQuad(age, rand);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
this.clearBlocksOnRift();
|
this.clearBlocksOnRift();
|
||||||
this.spawnEndermen();
|
this.spawnEndermen();
|
||||||
@@ -150,30 +171,36 @@ public class TileEntityRift extends TileEntity
|
|||||||
}
|
}
|
||||||
public void calculateNextRenderQuad(float age, Random rand)
|
public void calculateNextRenderQuad(float age, Random rand)
|
||||||
{
|
{
|
||||||
int iteration = MathHelper.floor_double((Math.log(Math.pow(age+1,1.5))));
|
int maxSize = MathHelper.floor_double((Math.log(Math.pow(age+1,2))));
|
||||||
|
int iteration=0;
|
||||||
|
while(iteration< maxSize)
|
||||||
|
{
|
||||||
|
iteration++;
|
||||||
|
|
||||||
|
|
||||||
double fl =Math.log(iteration+1)/(iteration);
|
double fl =Math.log(iteration+1)/(iteration);
|
||||||
double[] coords= new double[4];
|
double[] coords= new double[4];
|
||||||
double noise = ((rand.nextGaussian())/(10)*(iteration+1));
|
double noise = ((rand.nextGaussian())/(2+iteration/3+1));
|
||||||
|
|
||||||
if(!this.renderingCenters.containsKey(iteration-1))
|
if(!this.renderingCenters.containsKey(iteration-1))
|
||||||
{
|
{
|
||||||
if(rand.nextBoolean())
|
if(rand.nextBoolean())
|
||||||
{
|
{
|
||||||
coords[0] = fl*1.5;
|
coords[0] = fl*1.5;
|
||||||
coords[1] = rand.nextGaussian()/10;
|
coords[1] = rand.nextGaussian()/5;
|
||||||
coords[2] = 0;
|
coords[2] = 0;
|
||||||
coords[3] = 1;
|
coords[3] = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
coords[0] = 0;
|
coords[0] = 0;
|
||||||
coords[1] = rand.nextGaussian()/10;
|
coords[1] = rand.nextGaussian()/5;
|
||||||
coords[2] = fl*1.5;
|
coords[2] = fl*1.5;
|
||||||
coords[3] = 0;
|
coords[3] = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
this.renderingCenters.put(iteration-1,coords);
|
this.renderingCenters.put(iteration-1,coords);
|
||||||
|
iteration--;
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(!this.renderingCenters.containsKey(iteration))
|
else if(!this.renderingCenters.containsKey(iteration))
|
||||||
@@ -181,7 +208,7 @@ public class TileEntityRift extends TileEntity
|
|||||||
if(this.renderingCenters.get(iteration-1)[3]==0)
|
if(this.renderingCenters.get(iteration-1)[3]==0)
|
||||||
{
|
{
|
||||||
coords[0]=noise/2+this.renderingCenters.get(iteration-1)[0];
|
coords[0]=noise/2+this.renderingCenters.get(iteration-1)[0];
|
||||||
coords[1]=noise+this.renderingCenters.get(iteration-1)[1];
|
coords[1]=noise/2+this.renderingCenters.get(iteration-1)[1];
|
||||||
coords[2]= this.renderingCenters.get(iteration-1)[2]+fl;
|
coords[2]= this.renderingCenters.get(iteration-1)[2]+fl;
|
||||||
coords[3] = 0;
|
coords[3] = 0;
|
||||||
|
|
||||||
@@ -189,7 +216,7 @@ public class TileEntityRift extends TileEntity
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
coords[0]=this.renderingCenters.get(iteration-1)[0]+fl;
|
coords[0]=this.renderingCenters.get(iteration-1)[0]+fl;
|
||||||
coords[1]=noise+this.renderingCenters.get(iteration-1)[1];
|
coords[1]=noise/2+this.renderingCenters.get(iteration-1)[1];
|
||||||
coords[2]=noise/2+this.renderingCenters.get(iteration-1)[2];
|
coords[2]=noise/2+this.renderingCenters.get(iteration-1)[2];
|
||||||
coords[3] = 1;
|
coords[3] = 1;
|
||||||
|
|
||||||
@@ -199,6 +226,8 @@ public class TileEntityRift extends TileEntity
|
|||||||
this.renderingCenters.put(iteration,coords);
|
this.renderingCenters.put(iteration,coords);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,55 +240,46 @@ public class TileEntityRift extends TileEntity
|
|||||||
public void readFromNBT(NBTTagCompound nbt)
|
public void readFromNBT(NBTTagCompound nbt)
|
||||||
{
|
{
|
||||||
super.readFromNBT(nbt);
|
super.readFromNBT(nbt);
|
||||||
int i = nbt.getInteger(("Size"));
|
this.renderingCenters= new HashMap<Integer, double[]>();
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
this.count=nbt.getInteger("count");
|
this.count=nbt.getInteger("count");
|
||||||
this.count2=nbt.getInteger("count2");
|
this.count2=nbt.getInteger("count2");
|
||||||
|
this.age=nbt.getInteger("age");
|
||||||
this.shouldClose=nbt.getBoolean("shouldClose");
|
this.shouldClose=nbt.getBoolean("shouldClose");
|
||||||
this.age=nbt.getFloat("age");
|
|
||||||
for(int key=0; key<=nbt.getInteger("hashMapSize");key++)
|
|
||||||
{
|
|
||||||
double[] coords = new double[4];
|
|
||||||
|
|
||||||
coords[0]= nbt.getDouble(key+"+0");
|
|
||||||
coords[1]= nbt.getDouble(key+"+1");
|
|
||||||
coords[2]= nbt.getDouble(key+"+2");
|
|
||||||
coords[3]= nbt.getDouble(key+"+3");
|
|
||||||
|
|
||||||
this.renderingCenters.put(key, coords);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound nbt)
|
public void writeToNBT(NBTTagCompound nbt)
|
||||||
{
|
{
|
||||||
int i = 0;
|
|
||||||
super.writeToNBT(nbt);
|
super.writeToNBT(nbt);
|
||||||
|
|
||||||
for(Integer key:this.renderingCenters.keySet())
|
|
||||||
{
|
|
||||||
nbt.setDouble(key+"+0", this.renderingCenters.get(key)[0]);
|
|
||||||
nbt.setDouble(key+"+1", this.renderingCenters.get(key)[1]);
|
|
||||||
nbt.setDouble(key+"+2", this.renderingCenters.get(key)[2]);
|
|
||||||
nbt.setDouble(key+"+3", this.renderingCenters.get(key)[3]);
|
|
||||||
}
|
|
||||||
nbt.setInteger("hashMapSize", this.renderingCenters.size());
|
nbt.setInteger("hashMapSize", this.renderingCenters.size());
|
||||||
|
nbt.setInteger("age", this.age);
|
||||||
nbt.setInteger("count", this.count);
|
nbt.setInteger("count", this.count);
|
||||||
nbt.setInteger("count2", this.count2);
|
nbt.setInteger("count2", this.count2);
|
||||||
nbt.setFloat("age", this.age);
|
|
||||||
|
|
||||||
nbt.setBoolean("shouldClose", this.shouldClose);
|
nbt.setBoolean("shouldClose", this.shouldClose);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Packet getDescriptionPacket() {
|
||||||
|
Packet132TileEntityData packet = new Packet132TileEntityData();
|
||||||
|
packet.actionType = 0;
|
||||||
|
packet.xPosition = xCoord;
|
||||||
|
packet.yPosition = yCoord;
|
||||||
|
packet.zPosition = zCoord;
|
||||||
|
|
||||||
|
NBTTagCompound nbt = new NBTTagCompound();
|
||||||
|
writeToNBT(nbt);
|
||||||
|
packet.customParam1 = nbt;
|
||||||
|
return packet;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt) {
|
||||||
|
readFromNBT(pkt.customParam1);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ public class BlockDimWallPerm extends Block
|
|||||||
{
|
{
|
||||||
link =new LinkData(0,0,0,0);
|
link =new LinkData(0,0,0,0);
|
||||||
}
|
}
|
||||||
|
link.destDimID = 0;
|
||||||
|
link.locDimID = par1World.provider.dimensionId;
|
||||||
|
|
||||||
|
|
||||||
if(dimHelper.getWorld(0)==null)
|
if(dimHelper.getWorld(0)==null)
|
||||||
@@ -74,22 +76,27 @@ public class BlockDimWallPerm extends Block
|
|||||||
x = x + (x >> 4);
|
x = x + (x >> 4);
|
||||||
z = z + (z >> 4);
|
z = z + (z >> 4);
|
||||||
|
|
||||||
int y = yCoordHelper.getFirstUncovered(0, x, 63, z);
|
int y = yCoordHelper.getFirstUncovered(0, x, 63, z, true);
|
||||||
|
|
||||||
EntityPlayer.class.cast(par5Entity).setPositionAndUpdate( x, y, z );
|
EntityPlayer.class.cast(par5Entity).setPositionAndUpdate( x, y, 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
|
||||||
|
link.destXCoord = x;
|
||||||
FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().transferPlayerToDimension((EntityPlayerMP) par5Entity, 0,new BlankTeleporter((WorldServer)par5Entity.worldObj));
|
link.destYCoord = y;
|
||||||
|
link.destZCoord = z;
|
||||||
|
dimHelper.instance.teleportEntity(par1World, par5Entity, link);
|
||||||
|
//FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().transferPlayerToDimension((EntityPlayerMP) par5Entity, 0,new BlankTeleporter((WorldServer)par5Entity.worldObj));
|
||||||
//dimHelper.instance.teleportToPocket(par1World, new LinkData(par1World.provider.dimensionId,0,x,y,z,link.locXCoord,link.locYCoord,link.locZCoord,link.isLocPocket,0),
|
//dimHelper.instance.teleportToPocket(par1World, new LinkData(par1World.provider.dimensionId,0,x,y,z,link.locXCoord,link.locYCoord,link.locZCoord,link.isLocPocket,0),
|
||||||
// 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
|
// Make absolutely sure the player doesn't spawn inside blocks, though to be honest this shouldn't ever have to be a problem...
|
||||||
dimHelper.getWorld(0).setBlock(x, y, z, 0);
|
dimHelper.getWorld(0).setBlock(x, y, z, 0);
|
||||||
|
dimHelper.getWorld(0).setBlock(x, y+1, z, 0);
|
||||||
|
|
||||||
int i=x;
|
int i=x;
|
||||||
int j=y-1;
|
int j=y;
|
||||||
int k=z;
|
int k=z;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ public class BlockRift extends BlockContainer
|
|||||||
if (random.nextInt(MAX_BLOCK_SEARCH_CHANCE) < BLOCK_SEARCH_CHANCE &&
|
if (random.nextInt(MAX_BLOCK_SEARCH_CHANCE) < BLOCK_SEARCH_CHANCE &&
|
||||||
((TileEntityRift) world.getBlockTileEntity(x, y, z)).isNearRift )
|
((TileEntityRift) world.getBlockTileEntity(x, y, z)).isNearRift )
|
||||||
{
|
{
|
||||||
destroyNearbyBlocks(world, x, y, z, random);
|
// destroyNearbyBlocks(world, x, y, z, random);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,28 +102,46 @@ public class dimHelper extends DimensionManager
|
|||||||
else return 1;
|
else return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Entity teleportEntity(World oldWorld, Entity entity, LinkData link) //this beautiful teleport method is based off of xCompWiz's teleport function.
|
// GreyMaria: My god, what a mess. Here, let me clean it up a bit.
|
||||||
|
public Entity teleportEntity(World world, Entity entity, LinkData link) //this beautiful teleport method is based off of xCompWiz's teleport function.
|
||||||
{
|
{
|
||||||
Entity cart=entity.ridingEntity;
|
WorldServer oldWorld = (WorldServer)world;
|
||||||
|
WorldServer newWorld;
|
||||||
|
EntityPlayerMP player = (entity instanceof EntityPlayerMP) ? (EntityPlayerMP)entity : null;
|
||||||
|
|
||||||
|
/*// SPECIAL CASE: Is our link null? If so, we've likely come from Limbo. Ensure this is the case.
|
||||||
|
if(link == null)
|
||||||
|
{
|
||||||
|
if(world.provider.dimensionId == DDProperties.instance().LimboDimensionID)
|
||||||
|
{
|
||||||
|
link = new LinkData(0, 0, 0, 0);
|
||||||
|
// Find destination point.
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
// Is something riding? Handle it first.
|
||||||
if(entity.riddenByEntity != null)
|
if(entity.riddenByEntity != null)
|
||||||
{
|
{
|
||||||
return this.teleportEntity(oldWorld,entity.riddenByEntity, link);
|
return this.teleportEntity(oldWorld,entity.riddenByEntity, link);
|
||||||
}
|
}
|
||||||
|
// Are we riding something? Dismount and tell the mount to go first.
|
||||||
if (entity.ridingEntity != null)
|
Entity cart = entity.ridingEntity;
|
||||||
|
if (cart != null)
|
||||||
{
|
{
|
||||||
entity.mountEntity(null);
|
entity.mountEntity(null);
|
||||||
cart = teleportEntity(oldWorld, cart, link);
|
cart = teleportEntity(oldWorld, cart, link);
|
||||||
|
// We keep track of both so we can remount them on the other side.
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldServer newWorld;
|
// Destination doesn't exist? We need to make it.
|
||||||
|
|
||||||
if(DimensionManager.getWorld(link.destDimID)==null)
|
if(DimensionManager.getWorld(link.destDimID)==null)
|
||||||
{
|
{
|
||||||
DimensionManager.initDimension(link.destDimID);
|
DimensionManager.initDimension(link.destDimID);
|
||||||
}
|
}
|
||||||
boolean difDest = link.destDimID != link.locDimID;
|
|
||||||
|
|
||||||
|
// Determine if our destination's in another realm.
|
||||||
|
boolean difDest = link.destDimID != link.locDimID;
|
||||||
if(difDest)
|
if(difDest)
|
||||||
{
|
{
|
||||||
newWorld = DimensionManager.getWorld(link.destDimID);
|
newWorld = DimensionManager.getWorld(link.destDimID);
|
||||||
@@ -133,40 +151,47 @@ public class dimHelper extends DimensionManager
|
|||||||
newWorld=(WorldServer)oldWorld;
|
newWorld=(WorldServer)oldWorld;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GreyMaria: What is this even accomplishing? We're doing the exact same thing at the end of this all.
|
||||||
|
// TODO Check to see if this is actually vital.
|
||||||
mod_pocketDim.teleporter.placeInPortal(entity, newWorld, link);
|
mod_pocketDim.teleporter.placeInPortal(entity, newWorld, link);
|
||||||
|
|
||||||
if ((entity instanceof EntityPlayerMP))
|
if (difDest) // Are we moving our target to a new dimension?
|
||||||
{
|
{
|
||||||
EntityPlayerMP player = (EntityPlayerMP)entity;
|
if(player != null) // Are we working with a player?
|
||||||
if (difDest)
|
|
||||||
{
|
{
|
||||||
GameRegistry.onPlayerChangedDimension((EntityPlayer)entity);
|
// We need to do all this special stuff to move a player between dimensions.
|
||||||
|
|
||||||
|
// Set the new dimension and inform the client that it's moving to a new world.
|
||||||
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(oldWorld).removeEntity(player);
|
// GreyMaria: Used the safe player entity remover.
|
||||||
|
// This should fix an apparently unreported bug where
|
||||||
|
// the last non-sleeping player leaves the Overworld
|
||||||
|
// for a pocket dimension, causing all sleeping players
|
||||||
|
// to remain asleep instead of progressing to day.
|
||||||
|
oldWorld.removePlayerEntityDangerously(player);
|
||||||
player.isDead=false;
|
player.isDead=false;
|
||||||
|
|
||||||
oldWorld.playerEntities.remove(player);
|
// Creates sanity by ensuring that we're only known to exist where we're supposed to be known to exist.
|
||||||
WorldServer.class.cast(oldWorld).getPlayerManager().removePlayer(player);
|
oldWorld.getPlayerManager().removePlayer(player);
|
||||||
newWorld.getPlayerManager().addPlayer(player);
|
newWorld.getPlayerManager().addPlayer(player);
|
||||||
|
|
||||||
player.theItemInWorldManager.setWorld((WorldServer)newWorld);
|
player.theItemInWorldManager.setWorld((WorldServer)newWorld);
|
||||||
|
|
||||||
|
// Synchronize with the server so the client knows what time it is and what it's holding.
|
||||||
player.mcServer.getConfigurationManager().updateTimeAndWeatherForPlayer(player, (WorldServer)newWorld);
|
player.mcServer.getConfigurationManager().updateTimeAndWeatherForPlayer(player, (WorldServer)newWorld);
|
||||||
player.mcServer.getConfigurationManager().syncPlayerInventory(player);
|
player.mcServer.getConfigurationManager().syncPlayerInventory(player);
|
||||||
|
|
||||||
for(Object potionEffect : player.getActivePotionEffects())
|
for(Object potionEffect : player.getActivePotionEffects())
|
||||||
{
|
{
|
||||||
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)
|
// Creates sanity by removing the entity from its old location's chunk entity list, if applicable.
|
||||||
{
|
|
||||||
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)))
|
||||||
@@ -174,8 +199,10 @@ public class dimHelper extends DimensionManager
|
|||||||
oldWorld.getChunkFromChunkCoords(entX, entZ).removeEntity(entity);
|
oldWorld.getChunkFromChunkCoords(entX, entZ).removeEntity(entity);
|
||||||
oldWorld.getChunkFromChunkCoords(entX, entZ).isModified = true;
|
oldWorld.getChunkFromChunkCoords(entX, entZ).isModified = true;
|
||||||
}
|
}
|
||||||
|
// Memory concerns.
|
||||||
oldWorld.releaseEntitySkin(entity);
|
oldWorld.releaseEntitySkin(entity);
|
||||||
if (!(entity instanceof EntityPlayer))
|
|
||||||
|
if (player == null) // Are we NOT working with a player?
|
||||||
{
|
{
|
||||||
NBTTagCompound entityNBT = new NBTTagCompound();
|
NBTTagCompound entityNBT = new NBTTagCompound();
|
||||||
entity.isDead = false;
|
entity.isDead = false;
|
||||||
@@ -184,25 +211,41 @@ public class dimHelper extends DimensionManager
|
|||||||
entity = EntityList.createEntityFromNBT(entityNBT, newWorld);
|
entity = EntityList.createEntityFromNBT(entityNBT, newWorld);
|
||||||
|
|
||||||
if (entity == null)
|
if (entity == null)
|
||||||
{
|
{ // TODO FIXME IMPLEMENT NULL CHECKS THAT ACTUALLY DO SOMETHING.
|
||||||
|
/*
|
||||||
|
* shit ourselves in an organized fashion, preferably
|
||||||
|
* in a neat pile instead of all over our users' games
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// Finally, respawn the entity in its new home.
|
||||||
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))
|
|
||||||
|
// Hey, remember me? It's time to remount.
|
||||||
|
if (cart != null)
|
||||||
{
|
{
|
||||||
if ((entity instanceof EntityPlayerMP))
|
// Was there a player teleported? If there was, it's important that we update shit.
|
||||||
|
if (player != null)
|
||||||
{
|
{
|
||||||
entity.worldObj.updateEntityWithOptionalForce(entity, true);
|
entity.worldObj.updateEntityWithOptionalForce(entity, true);
|
||||||
}
|
}
|
||||||
entity.mountEntity(cart);
|
entity.mountEntity(cart);
|
||||||
}
|
}
|
||||||
if(entity instanceof EntityPlayerMP)
|
|
||||||
|
// Did we teleport a player? Load the chunk for them.
|
||||||
|
if(player != null)
|
||||||
{
|
{
|
||||||
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);
|
||||||
|
|
||||||
|
// Tell Forge we're moving its players so everyone else knows.
|
||||||
|
// Let's try doing this down here in case this is what's killing NEI.
|
||||||
|
GameRegistry.onPlayerChangedDimension((EntityPlayer)entity);
|
||||||
|
|
||||||
}
|
}
|
||||||
mod_pocketDim.teleporter.placeInPortal(entity, newWorld, link);
|
mod_pocketDim.teleporter.placeInPortal(entity, newWorld, link);
|
||||||
return entity;
|
return entity;
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ public class yCoordHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int getFirstUncovered(int worldID, int x, int yStart, int z)
|
public static int getFirstUncovered(int worldID, int x, int yStart, int z)
|
||||||
|
{ return getFirstUncovered(worldID, x, yStart, z, false); }
|
||||||
|
|
||||||
|
public static int getFirstUncovered(int worldID, int x, int yStart, int z, boolean fromTop)
|
||||||
{
|
{
|
||||||
if (dimHelper.getWorld(worldID) == null ||
|
if (dimHelper.getWorld(worldID) == null ||
|
||||||
dimHelper.getWorld(worldID).provider == null)
|
dimHelper.getWorld(worldID).provider == null)
|
||||||
@@ -28,10 +31,13 @@ public class yCoordHelper
|
|||||||
dimHelper.initDimension(worldID);
|
dimHelper.initDimension(worldID);
|
||||||
}
|
}
|
||||||
|
|
||||||
return yCoordHelper.getFirstUncovered(dimHelper.getWorld(worldID), x, yStart, z);
|
return yCoordHelper.getFirstUncovered(dimHelper.getWorld(worldID), x, yStart, z, fromTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getFirstUncovered(World world, int x, int yStart, int z)
|
public static int getFirstUncovered(World world, int x, int yStart, int z)
|
||||||
|
{ return getFirstUncovered(world, x, yStart, z, false); }
|
||||||
|
|
||||||
|
public static int getFirstUncovered(World world, int x, int yStart, int z, boolean fromTop)
|
||||||
{
|
{
|
||||||
Chunk chunk = world.getChunkProvider().loadChunk(x >> 4, z >> 4);
|
Chunk chunk = world.getChunkProvider().loadChunk(x >> 4, z >> 4);
|
||||||
|
|
||||||
@@ -40,11 +46,22 @@ public class yCoordHelper
|
|||||||
int height = MAXIMUM_UNCOVERED_Y; //world.getHeight();
|
int height = MAXIMUM_UNCOVERED_Y; //world.getHeight();
|
||||||
int y;
|
int y;
|
||||||
|
|
||||||
|
if(!fromTop)
|
||||||
|
{
|
||||||
boolean covered = true;
|
boolean covered = true;
|
||||||
for (y = yStart; y < height && covered; y++)
|
for (y = yStart; y < height && covered; y++)
|
||||||
{
|
{
|
||||||
covered = IsCoveredBlock(chunk, localX, y - 1, localZ) || IsCoveredBlock(chunk, localX, y, localZ);
|
covered = IsCoveredBlock(chunk, localX, y - 1, localZ) || IsCoveredBlock(chunk, localX, y, localZ);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
boolean covered = false;
|
||||||
|
for (y = MAXIMUM_UNCOVERED_Y; y > 1 && !covered; y--)
|
||||||
|
{
|
||||||
|
covered = IsCoveredBlock(chunk, localX, y - 1, localZ);
|
||||||
|
}
|
||||||
|
if (!covered) y = 63;
|
||||||
|
y++;
|
||||||
|
}
|
||||||
|
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class RenderRift extends TileEntitySpecialRenderer
|
|||||||
//GL11.glLogicOp(GL11.GL_INVERT);
|
//GL11.glLogicOp(GL11.GL_INVERT);
|
||||||
// GL11.glEnable(GL11.GL_COLOR_LOGIC_OP);
|
// GL11.glEnable(GL11.GL_COLOR_LOGIC_OP);
|
||||||
|
|
||||||
GL11.glColor4f(.3F, .3F, .3F, .2F);
|
GL11.glColor4f(.3F, .3F, .3F, 1F);
|
||||||
|
|
||||||
GL11.glEnable(GL_BLEND);
|
GL11.glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO);
|
glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO);
|
||||||
@@ -67,8 +67,8 @@ public class RenderRift extends TileEntitySpecialRenderer
|
|||||||
{
|
{
|
||||||
GL11.glBegin(GL11.GL_QUAD_STRIP);
|
GL11.glBegin(GL11.GL_QUAD_STRIP);
|
||||||
|
|
||||||
drawVertex(xWorld+.5, yWorld-Math.log(quads.size()+1)/8, zWorld+.5);
|
drawVertex(xWorld+.5, yWorld-Math.log(Math.pow(quads.size(),2)+1)/14, zWorld+.5);
|
||||||
drawVertex(xWorld+.5, yWorld+Math.log(quads.size()+1)/8, zWorld+.5);
|
drawVertex(xWorld+.5, yWorld+Math.log(Math.pow(quads.size(),2)+1)/14, zWorld+.5);
|
||||||
for(int i = 0;;i++)
|
for(int i = 0;;i++)
|
||||||
{
|
{
|
||||||
if(!quads.containsKey(i))
|
if(!quads.containsKey(i))
|
||||||
@@ -76,7 +76,7 @@ public class RenderRift extends TileEntitySpecialRenderer
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
double[] coords = quads.get(i);
|
double[] coords = quads.get(i);
|
||||||
double width=Math.log(quads.size()-i+1)/8;
|
double width=Math.log(Math.pow(quads.size(),2-Math.log(i+1))+1)/14;
|
||||||
if(coords[3]==0)
|
if(coords[3]==0)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -128,8 +128,8 @@ public class RenderRift extends TileEntitySpecialRenderer
|
|||||||
{
|
{
|
||||||
GL11.glBegin(GL11.GL_QUAD_STRIP);
|
GL11.glBegin(GL11.GL_QUAD_STRIP);
|
||||||
|
|
||||||
drawVertex(xWorld+.5, yWorld+Math.log(quads.size()+1)/8, zWorld+.5);
|
drawVertex(xWorld+.5, yWorld+Math.log(Math.pow(quads.size(),2)+1)/14, zWorld+.5);
|
||||||
drawVertex(xWorld+.5, yWorld-Math.log(quads.size()+1)/8, zWorld+.5);
|
drawVertex(xWorld+.5, yWorld-Math.log(Math.pow(quads.size(),2)+1)/14, zWorld+.5);
|
||||||
for(int i = 0;;i++)
|
for(int i = 0;;i++)
|
||||||
{
|
{
|
||||||
if(!quads.containsKey(i))
|
if(!quads.containsKey(i))
|
||||||
@@ -137,7 +137,7 @@ public class RenderRift extends TileEntitySpecialRenderer
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
double[] coords = quads.get(i);
|
double[] coords = quads.get(i);
|
||||||
double width=Math.log(quads.size()-i+1)/8;
|
double width=Math.log(Math.pow(quads.size(),2-Math.log(i+1))+1)/14;
|
||||||
if(coords[3]==0)
|
if(coords[3]==0)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user