Flipped a Table
Replaced several core classes from DD with new classes to enforce integrity checks. Rewriting everything that depended on those classes is a massive undertaking but it should simplify our code and prevent the many bugs we've seen lately. The rewrite isn't done yet, just committing my progress so far.
This commit is contained in:
@@ -9,14 +9,12 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import StevenDimDoors.mod_pocketDim.BlankTeleporter;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.IDimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
public class BlockDimWallPerm extends Block
|
||||
{
|
||||
@@ -45,32 +43,33 @@ public class BlockDimWallPerm extends Block
|
||||
/**
|
||||
* Only matters if the player is in limbo, acts to teleport the player from limbo back to dim 0
|
||||
*/
|
||||
public void onEntityWalking(World par1World, int par2, int par3, int par4, Entity par5Entity)
|
||||
public void onEntityWalking(World par1World, int par2, int par3, int par4, Entity entity)
|
||||
{
|
||||
if(!par1World.isRemote&&par1World.provider.dimensionId==properties.LimboDimensionID)
|
||||
if (!par1World.isRemote && par1World.provider.dimensionId == properties.LimboDimensionID)
|
||||
{
|
||||
Random rand = new Random();
|
||||
|
||||
NewLinkData link=dimHelper.instance.getRandomLinkData(false);
|
||||
if(link==null)
|
||||
IDimLink link = PocketManager.getRandomLinkData(false);
|
||||
if (link == null)
|
||||
{
|
||||
link =new NewLinkData(0,0,0,0);
|
||||
}
|
||||
link.destDimID = 0;
|
||||
link.locDimID = par1World.provider.dimensionId;
|
||||
World overworld = DimensionManager.getWorld(0);
|
||||
|
||||
|
||||
if(dimHelper.getWorld(0)==null)
|
||||
if (overworld == null)
|
||||
{
|
||||
dimHelper.initDimension(0);
|
||||
DimensionManager.initDimension(0);
|
||||
overworld = DimensionManager.getWorld(0);
|
||||
}
|
||||
|
||||
|
||||
if(dimHelper.getWorld(0)!=null&&par5Entity instanceof EntityPlayerMP)
|
||||
|
||||
if (overworld != null && entity instanceof EntityPlayerMP)
|
||||
{
|
||||
par5Entity.fallDistance=0;
|
||||
int x = (link.destXCoord + rand.nextInt(properties.LimboReturnRange)-properties.LimboReturnRange/2);
|
||||
int z = (link.destZCoord + rand.nextInt(properties.LimboReturnRange)-properties.LimboReturnRange/2);
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
player.fallDistance = 0;
|
||||
int x = (link.destXCoord + rand.nextInt(properties.LimboReturnRange) - properties.LimboReturnRange/2);
|
||||
int z = (link.destZCoord + rand.nextInt(properties.LimboReturnRange) - properties.LimboReturnRange/2);
|
||||
|
||||
//make sure I am in the middle of a chunk, and not on a boundary, so it doesn't load the chunk next to me
|
||||
x = x + (x >> 4);
|
||||
@@ -78,46 +77,39 @@ public class BlockDimWallPerm extends Block
|
||||
|
||||
int y = yCoordHelper.getFirstUncovered(0, x, 63, z, true);
|
||||
|
||||
EntityPlayer.class.cast(par5Entity).setPositionAndUpdate( x, y, z );
|
||||
player.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
|
||||
link.destXCoord = x;
|
||||
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),
|
||||
// EntityPlayer.class.cast(par5Entity));
|
||||
|
||||
|
||||
EntityPlayer.class.cast(par5Entity).setPositionAndUpdate( x, y, z );
|
||||
PocketManager.teleportEntity(par1World, player, link);
|
||||
|
||||
player.setPositionAndUpdate( x, y, z );
|
||||
|
||||
// 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+1, z, 0);
|
||||
overworld.setBlockToAir(x, y, z);
|
||||
overworld.setBlockToAir(x, y + 1, z);
|
||||
|
||||
int i=x;
|
||||
int j=y;
|
||||
int k=z;
|
||||
|
||||
|
||||
for(int xc=-3;xc<4;xc++)
|
||||
{
|
||||
for(int zc=-3;zc<4;zc++)
|
||||
{
|
||||
for(int yc=0;yc<200;yc++)
|
||||
{
|
||||
if(yc==0)
|
||||
if (yc==0)
|
||||
{
|
||||
|
||||
if(Math.abs(xc)+Math.abs(zc)<rand.nextInt(3)+2)
|
||||
{
|
||||
dimHelper.getWorld(0).setBlock(i+xc, j-1+yc, k+zc, properties.LimboBlockID);
|
||||
overworld.setBlock(i+xc, j-1+yc, k+zc, properties.LimboBlockID);
|
||||
}
|
||||
else if(Math.abs(xc)+Math.abs(zc)<rand.nextInt(3)+3)
|
||||
|
||||
{
|
||||
dimHelper.getWorld(0).setBlock(i+xc, j-1+yc, k+zc, properties.LimboBlockID,2,0);
|
||||
|
||||
overworld.setBlock(i+xc, j-1+yc, k+zc, properties.LimboBlockID,2,0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,16 +118,9 @@ public class BlockDimWallPerm extends Block
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
{
|
||||
EntityPlayer.class.cast(par5Entity).setPositionAndUpdate( x, y, z );
|
||||
EntityPlayer.class.cast(par5Entity).fallDistance=0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//FIXME: Why do we do this repeatedly? We also set the fall distance at the start...
|
||||
player.setPositionAndUpdate( x, y, z );
|
||||
player.fallDistance = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user