mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-24 22:04:49 +00:00
Apply various common one-to-one replacements
More work on common too. network package now done.
This commit is contained in:
1 parent
a0114b5112
commit
a80f724cc2
189 files changed
+1586
-1634
No files matched your search
@@ -12,28 +12,25 @@ import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class TileEntityBoundingBlock extends TileEntity implements ITileNetwork
|
||||
{
|
||||
public int mainX;
|
||||
public int mainY;
|
||||
public int mainZ;
|
||||
public BlockPos mainPos;
|
||||
|
||||
public boolean receivedCoords;
|
||||
|
||||
public boolean prevPower;
|
||||
public int prevPower;
|
||||
|
||||
public void setMainLocation(int x, int y, int z)
|
||||
public void setMainLocation(BlockPos pos)
|
||||
{
|
||||
receivedCoords = true;
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
mainX = x;
|
||||
mainY = y;
|
||||
mainZ = z;
|
||||
mainPos = pos;
|
||||
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this)));
|
||||
}
|
||||
@@ -50,25 +47,19 @@ public class TileEntityBoundingBlock extends TileEntity implements ITileNetwork
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onNeighborChange(Block block)
|
||||
{
|
||||
TileEntity tile = worldObj.getTileEntity(mainX, mainY, mainZ);
|
||||
TileEntity tile = worldObj.getTileEntity(mainPos);
|
||||
|
||||
if(tile instanceof TileEntityBasicBlock)
|
||||
{
|
||||
TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)tile;
|
||||
|
||||
boolean power = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord);
|
||||
int power = worldObj.isBlockIndirectlyGettingPowered(getPos());
|
||||
|
||||
if(prevPower != power)
|
||||
{
|
||||
if(power)
|
||||
if(power > 0)
|
||||
{
|
||||
onPower();
|
||||
}
|
||||
@@ -89,10 +80,8 @@ public class TileEntityBoundingBlock extends TileEntity implements ITileNetwork
|
||||
@Override
|
||||
public void handlePacketData(ByteBuf dataStream)
|
||||
{
|
||||
mainX = dataStream.readInt();
|
||||
mainY = dataStream.readInt();
|
||||
mainZ = dataStream.readInt();
|
||||
prevPower = dataStream.readBoolean();
|
||||
mainPos = new BlockPos(dataStream.readInt(), dataStream.readInt(), dataStream.readInt());
|
||||
prevPower = dataStream.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -100,10 +89,8 @@ public class TileEntityBoundingBlock extends TileEntity implements ITileNetwork
|
||||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
mainX = nbtTags.getInteger("mainX");
|
||||
mainY = nbtTags.getInteger("mainY");
|
||||
mainZ = nbtTags.getInteger("mainZ");
|
||||
prevPower = nbtTags.getBoolean("prevPower");
|
||||
mainPos = new BlockPos(nbtTags.getInteger("mainX"), nbtTags.getInteger("mainY"), nbtTags.getInteger("mainZ"));
|
||||
prevPower = nbtTags.getInteger("prevPower");
|
||||
receivedCoords = nbtTags.getBoolean("receivedCoords");
|
||||
}
|
||||
|
||||
@@ -112,19 +99,19 @@ public class TileEntityBoundingBlock extends TileEntity implements ITileNetwork
|
||||
{
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
nbtTags.setInteger("mainX", mainX);
|
||||
nbtTags.setInteger("mainY", mainY);
|
||||
nbtTags.setInteger("mainZ", mainZ);
|
||||
nbtTags.setBoolean("prevPower", prevPower);
|
||||
nbtTags.setInteger("mainX", mainPos.getX());
|
||||
nbtTags.setInteger("mainY", mainPos.getY());
|
||||
nbtTags.setInteger("mainZ", mainPos.getZ());
|
||||
nbtTags.setInteger("prevPower", prevPower);
|
||||
nbtTags.setBoolean("receivedCoords", receivedCoords);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList getNetworkedData(ArrayList data)
|
||||
{
|
||||
data.add(mainX);
|
||||
data.add(mainY);
|
||||
data.add(mainZ);
|
||||
data.add(mainPos.getX());
|
||||
data.add(mainPos.getY());
|
||||
data.add(mainPos.getZ());
|
||||
data.add(prevPower);
|
||||
|
||||
return data;
|
||||
|
||||
Reference in new issue
Block a user