Fixed Server

This commit is contained in:
Ellpeck 2015-10-27 20:58:42 +01:00
parent 9661f9e817
commit 7671b408c8
4 changed files with 25 additions and 27 deletions

View file

@ -86,15 +86,12 @@ public class ItemLaserWrench extends Item implements IActAddItemOrBlock{
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld){
WorldPos coords = ItemPhantomConnector.getStoredPosition(stack);
if(coords != null){
World world = coords.getWorld();
if(world != null){
list.add(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".boundTo.desc")+":");
list.add("X: "+coords.getX());
list.add("Y: "+coords.getY());
list.add("Z: "+coords.getZ());
list.add(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".inWorld.desc")+" "+world.provider.dimensionId);
list.add(EnumChatFormatting.ITALIC+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".clearStorage.desc"));
}
list.add(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".boundTo.desc")+":");
list.add("X: "+coords.getX());
list.add("Y: "+coords.getY());
list.add("Z: "+coords.getZ());
list.add(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".inWorld.desc")+" "+coords.getWorldID());
list.add(EnumChatFormatting.ITALIC+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".clearStorage.desc"));
}
}

View file

@ -29,7 +29,6 @@ import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import java.util.List;
@ -82,8 +81,8 @@ public class ItemPhantomConnector extends Item implements IActAddItemOrBlock{
int x = tag.getInteger("XCoordOfTileStored");
int y = tag.getInteger("YCoordOfTileStored");
int z = tag.getInteger("ZCoordOfTileStored");
World world = DimensionManager.getWorld(tag.getInteger("WorldOfTileStored"));
if(!(x == 0 && y == 0 && z == 0) && world != null){
int world = tag.getInteger("WorldOfTileStored");
if(!(x == 0 && y == 0 && z == 0)){
return new WorldPos(world, x, y, z);
}
}
@ -126,15 +125,12 @@ public class ItemPhantomConnector extends Item implements IActAddItemOrBlock{
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld){
WorldPos coords = getStoredPosition(stack);
if(coords != null){
World world = coords.getWorld();
if(world != null){
list.add(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".boundTo.desc")+":");
list.add("X: "+coords.getX());
list.add("Y: "+coords.getY());
list.add("Z: "+coords.getZ());
list.add(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".inWorld.desc")+" "+world.provider.dimensionId);
list.add(EnumChatFormatting.ITALIC+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".clearStorage.desc"));
}
list.add(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".boundTo.desc")+":");
list.add("X: "+coords.getX());
list.add("Y: "+coords.getY());
list.add("Z: "+coords.getZ());
list.add(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".inWorld.desc")+" "+coords.getWorldID());
list.add(EnumChatFormatting.ITALIC+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".clearStorage.desc"));
}
}

View file

@ -17,8 +17,6 @@ import ellpeck.actuallyadditions.util.WorldUtil;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.ArrayList;
@ -215,11 +213,10 @@ public class LaserRelayConnectionHandler{
public static ConnectionPair readFromNBT(NBTTagCompound compound, String name){
WorldPos[] pos = new WorldPos[2];
for(int i = 0; i < pos.length; i++){
World aWorld = DimensionManager.getWorld(compound.getInteger("world"+name+i));
int anX = compound.getInteger("x"+name+i);
int aY = compound.getInteger("y"+name+i);
int aZ = compound.getInteger("z"+name+i);
pos[i] = new WorldPos(aWorld, anX, aY, aZ);
pos[i] = new WorldPos(compound.getInteger("world"+name+i), anX, aY, aZ);
}
return new ConnectionPair(pos[0], pos[1]);
}
@ -236,7 +233,7 @@ public class LaserRelayConnectionHandler{
public void writeToNBT(NBTTagCompound compound, String name){
for(int i = 0; i < 2; i++){
WorldPos relay = i == 0 ? this.firstRelay : this.secondRelay;
compound.setInteger("world"+name+i, relay.getWorld().provider.dimensionId);
compound.setInteger("world"+name+i, relay.getWorldID());
compound.setInteger("x"+name+i, relay.getX());
compound.setInteger("y"+name+i, relay.getY());
compound.setInteger("z"+name+i, relay.getZ());

View file

@ -26,12 +26,20 @@ public class WorldPos{
private int worldID;
public WorldPos(World world, int x, int y, int z){
this.worldID = world.provider.dimensionId;
this(world.provider.dimensionId, x, y, z);
}
public WorldPos(int worldID, int x, int y, int z){
this.worldID = worldID;
this.x = x;
this.y = y;
this.z = z;
}
public int getWorldID(){
return this.worldID;
}
public TileEntity getTileEntity(){
return this.getWorld() != null ? this.getWorld().getTileEntity(this.x, this.y, this.z) : null;
}