Inter-dimensional transfer working!
This commit is contained in:
parent
258afcd33f
commit
9e1feca3e8
2 changed files with 125 additions and 102 deletions
|
@ -6,6 +6,7 @@ package resonantinduction.tesla;
|
|||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import resonantinduction.ResonantInduction;
|
||||
|
@ -66,22 +67,23 @@ public class BlockTesla extends BlockBase implements ITileEntityProvider
|
|||
}
|
||||
else if (entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemCoordLink)
|
||||
{
|
||||
if (tileEntity.linkCoord == null)
|
||||
if (tileEntity.linked == null)
|
||||
{
|
||||
ItemCoordLink link = ((ItemCoordLink) entityPlayer.getCurrentEquippedItem().getItem());
|
||||
Vector3 linkVec = link.getLink(entityPlayer.getCurrentEquippedItem());
|
||||
|
||||
if (linkVec != null)
|
||||
{
|
||||
if (linkVec.getTileEntity(world) instanceof TileEntityTesla)
|
||||
{
|
||||
tileEntity.linkCoord = new Vector3(((TileEntityTesla) linkVec.getTileEntity(world)).getTopTelsa());
|
||||
tileEntity.dimID = link.getLinkDim(entityPlayer.getCurrentEquippedItem());
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
int dimID = link.getLinkDim(entityPlayer.getCurrentEquippedItem());
|
||||
World otherWorld = MinecraftServer.getServer().worldServerForDimension(dimID);
|
||||
|
||||
if (linkVec.getTileEntity(otherWorld) instanceof TileEntityTesla)
|
||||
{
|
||||
tileEntity.setLink(new Vector3(((TileEntityTesla) linkVec.getTileEntity(otherWorld)).getTopTelsa()), dimID);
|
||||
|
||||
entityPlayer.addChatMessage("Linked " + this.getLocalizedName() + " with " + " [" + (int) linkVec.x + ", " + (int) linkVec.y + ", " + (int) linkVec.z + "]");
|
||||
}
|
||||
|
||||
link.clearLink(entityPlayer.getCurrentEquippedItem());
|
||||
world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, "ambient.weather.thunder", 5, 1);
|
||||
|
@ -89,9 +91,10 @@ public class BlockTesla extends BlockBase implements ITileEntityProvider
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tileEntity.linkCoord = null;
|
||||
tileEntity.linked = null;
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
|
|
|
@ -62,8 +62,8 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe
|
|||
/**
|
||||
* Quantum Tesla
|
||||
*/
|
||||
public Vector3 linkCoord;
|
||||
public int dimID;
|
||||
public Vector3 linked;
|
||||
public int linkDim;
|
||||
|
||||
/**
|
||||
* Client
|
||||
|
@ -94,21 +94,20 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe
|
|||
/**
|
||||
* Quantum transportation.
|
||||
*/
|
||||
if (this.linkCoord != null)
|
||||
if (this.linked != null)
|
||||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
TileEntity tileEntity = MinecraftServer.getServer().worldServerForDimension(this.dimID).getBlockTileEntity((int) this.linkCoord.x, (int) this.linkCoord.y, (int) this.linkCoord.z);
|
||||
TileEntity tileEntity = MinecraftServer.getServer().worldServerForDimension(this.linkDim).getBlockTileEntity((int) this.linked.x, (int) this.linked.y, (int) this.linked.z);
|
||||
|
||||
if (tileEntity instanceof TileEntityTesla && !tileEntity.isInvalid())
|
||||
{
|
||||
this.transfer(((TileEntityTesla) tileEntity), this.getEnergyStored());
|
||||
}
|
||||
}
|
||||
|
||||
final TileEntityTesla topTesla = this.getTopTelsa();
|
||||
final Vector3 topTeslaVector = new Vector3(topTesla);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
List<ITesla> transferTeslaCoils = new ArrayList<ITesla>();
|
||||
|
||||
|
@ -211,6 +210,7 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.zapCounter++;
|
||||
this.outputBlacklist.clear();
|
||||
|
@ -524,6 +524,12 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe
|
|||
this.dyeID = nbt.getInteger("dyeID");
|
||||
this.canReceive = nbt.getBoolean("canReceive");
|
||||
this.attackEntities = nbt.getBoolean("attackEntities");
|
||||
|
||||
if (nbt.hasKey("link_x") && nbt.hasKey("link_y") && nbt.hasKey("link_z"))
|
||||
{
|
||||
this.linked = new Vector3(nbt.getInteger("link_x"), nbt.getInteger("link_y"), nbt.getInteger("link_z"));
|
||||
this.linkDim = nbt.getInteger("linkDim");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -536,6 +542,20 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe
|
|||
nbt.setInteger("dyeID", this.dyeID);
|
||||
nbt.setBoolean("canReceive", this.canReceive);
|
||||
nbt.setBoolean("attackEntities", this.attackEntities);
|
||||
|
||||
if (this.linked != null)
|
||||
{
|
||||
nbt.setInteger("link_x", (int) this.linked.x);
|
||||
nbt.setInteger("link_y", (int) this.linked.y);
|
||||
nbt.setInteger("link_z", (int) this.linked.z);
|
||||
nbt.setInteger("linkDim", this.linkDim);
|
||||
}
|
||||
}
|
||||
|
||||
public void setLink(Vector3 vector3, int dimID)
|
||||
{
|
||||
this.linked = vector3;
|
||||
this.linkDim = dimID;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue