Move solderer data to description packet
This commit is contained in:
@@ -37,8 +37,6 @@ public class BlockCable extends BlockMachine {
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, new IProperty[]{
|
||||
DIRECTION,
|
||||
CONNECTED,
|
||||
NORTH,
|
||||
EAST,
|
||||
SOUTH,
|
||||
@@ -50,8 +48,7 @@ public class BlockCable extends BlockMachine {
|
||||
|
||||
@Override
|
||||
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return super.getActualState(state, world, pos)
|
||||
.withProperty(NORTH, hasConnectionWith(world, pos.north()))
|
||||
return state.withProperty(NORTH, hasConnectionWith(world, pos.north()))
|
||||
.withProperty(EAST, hasConnectionWith(world, pos.east()))
|
||||
.withProperty(SOUTH, hasConnectionWith(world, pos.south()))
|
||||
.withProperty(WEST, hasConnectionWith(world, pos.west()))
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
package refinedstorage.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
import refinedstorage.RefinedStorageUtils;
|
||||
import refinedstorage.proxy.ClientProxy;
|
||||
import refinedstorage.tile.solderer.TileSolderer;
|
||||
|
||||
public class MessageSoldererWorkingUpdate implements IMessage, IMessageHandler<MessageSoldererWorkingUpdate, IMessage> {
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
private boolean working;
|
||||
|
||||
public MessageSoldererWorkingUpdate() {
|
||||
}
|
||||
|
||||
public MessageSoldererWorkingUpdate(TileSolderer solderer) {
|
||||
this.x = solderer.getPos().getX();
|
||||
this.y = solderer.getPos().getY();
|
||||
this.z = solderer.getPos().getZ();
|
||||
this.working = solderer.isWorking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
x = buf.readInt();
|
||||
y = buf.readInt();
|
||||
z = buf.readInt();
|
||||
working = buf.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(x);
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
buf.writeBoolean(working);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(MessageSoldererWorkingUpdate message, MessageContext ctx) {
|
||||
BlockPos pos = new BlockPos(message.x, message.y, message.z);
|
||||
|
||||
World world = ClientProxy.getWorld();
|
||||
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
if (tile instanceof TileSolderer) {
|
||||
boolean wasWorking = ((TileSolderer) tile).isWorking();
|
||||
|
||||
((TileSolderer) tile).setWorking(message.working);
|
||||
|
||||
if (wasWorking != message.working) {
|
||||
RefinedStorageUtils.updateBlock(world, pos);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,6 @@ public class CommonProxy {
|
||||
|
||||
RefinedStorage.NETWORK.registerMessage(MessageTileContainerUpdate.class, MessageTileContainerUpdate.class, id++, Side.CLIENT);
|
||||
RefinedStorage.NETWORK.registerMessage(MessageControllerEnergyUpdate.class, MessageControllerEnergyUpdate.class, id++, Side.CLIENT);
|
||||
RefinedStorage.NETWORK.registerMessage(MessageSoldererWorkingUpdate.class, MessageSoldererWorkingUpdate.class, id++, Side.CLIENT);
|
||||
RefinedStorage.NETWORK.registerMessage(MessageDetectorPoweredUpdate.class, MessageDetectorPoweredUpdate.class, id++, Side.CLIENT);
|
||||
RefinedStorage.NETWORK.registerMessage(MessageRedstoneModeUpdate.class, MessageRedstoneModeUpdate.class, id++, Side.SERVER);
|
||||
RefinedStorage.NETWORK.registerMessage(MessageGridStoragePush.class, MessageGridStoragePush.class, id++, Side.SERVER);
|
||||
|
||||
@@ -20,5 +20,4 @@ public class TileCable extends TileMachine {
|
||||
public boolean maySendConnectivityData() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import refinedstorage.RefinedStorageUtils;
|
||||
import refinedstorage.container.ContainerSolderer;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
import refinedstorage.item.ItemUpgrade;
|
||||
import refinedstorage.network.MessageSoldererWorkingUpdate;
|
||||
import refinedstorage.tile.TileMachine;
|
||||
|
||||
public class TileSolderer extends TileMachine implements ISidedInventory {
|
||||
@@ -45,6 +44,8 @@ public class TileSolderer extends TileMachine implements ISidedInventory {
|
||||
public void updateMachine() {
|
||||
ISoldererRecipe newRecipe = SoldererRegistry.getRecipe(inventory);
|
||||
|
||||
boolean wasWorking = working;
|
||||
|
||||
if (newRecipe == null) {
|
||||
reset();
|
||||
} else if (newRecipe != recipe) {
|
||||
@@ -77,8 +78,8 @@ public class TileSolderer extends TileMachine implements ISidedInventory {
|
||||
}
|
||||
}
|
||||
|
||||
if (ticks % 4 == 0) {
|
||||
RefinedStorageUtils.sendToAllAround(worldObj, pos, new MessageSoldererWorkingUpdate(this));
|
||||
if (wasWorking != working) {
|
||||
RefinedStorageUtils.updateBlock(worldObj, pos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,6 +125,20 @@ public class TileSolderer extends TileMachine implements ISidedInventory {
|
||||
nbt.setInteger(NBT_PROGRESS, progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToDescriptionPacketNBT(NBTTagCompound tag) {
|
||||
super.writeToDescriptionPacketNBT(tag);
|
||||
|
||||
tag.setBoolean(NBT_WORKING, working);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromDescriptionPacketNBT(NBTTagCompound tag) {
|
||||
super.readFromDescriptionPacketNBT(tag);
|
||||
|
||||
working = tag.getBoolean(NBT_WORKING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveContainerData(ByteBuf buf) {
|
||||
super.receiveContainerData(buf);
|
||||
|
||||
@@ -56,26 +56,6 @@
|
||||
},
|
||||
"false": {
|
||||
}
|
||||
},
|
||||
"direction": {
|
||||
"north": {
|
||||
},
|
||||
"east": {
|
||||
},
|
||||
"south": {
|
||||
},
|
||||
"west": {
|
||||
},
|
||||
"up": {
|
||||
},
|
||||
"down": {
|
||||
}
|
||||
},
|
||||
"connected": {
|
||||
"true": {
|
||||
},
|
||||
"false": {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user