mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-20 12:19:55 +00:00
Rework vat dump a bit to be more reliable
This commit is contained in:
1 parent
f059381559
commit
4d649aa97c
3 files changed
+55
-8
No files matched your search
@@ -31,7 +31,7 @@ public class BlockVat extends AbstractMachineBlock<TileVat> {
|
||||
|
||||
public static BlockVat create() {
|
||||
PacketHandler.INSTANCE.registerMessage(PacketTanks.class,PacketTanks.class,PacketHandler.nextID(), Side.CLIENT);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketTanks.class,PacketTanks.class,PacketHandler.nextID(), Side.SERVER);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketDumpTank.class,PacketDumpTank.class,PacketHandler.nextID(), Side.SERVER);
|
||||
BlockVat res = new BlockVat();
|
||||
res.init();
|
||||
return res;
|
||||
|
||||
@@ -203,13 +203,7 @@ public class GuiVat extends GuiMachineBase {
|
||||
}
|
||||
|
||||
private void dump(int i) {
|
||||
if (i == 1) {
|
||||
vat.inputTank.setFluid(null);
|
||||
} else if (i == 2) {
|
||||
vat.outputTank.setFluid(null);
|
||||
}
|
||||
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketTanks(vat));
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketDumpTank(vat, i));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package crazypants.enderio.machine.still;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import crazypants.enderio.network.MessageTileEntity;
|
||||
|
||||
public class PacketDumpTank extends MessageTileEntity<TileVat> implements IMessageHandler<PacketDumpTank, IMessage> {
|
||||
|
||||
private int tank;
|
||||
|
||||
public PacketDumpTank() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PacketDumpTank(TileVat te, int tank) {
|
||||
super(te);
|
||||
this.tank = tank;
|
||||
getTank(te).setFluid(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
super.toBytes(buf);
|
||||
buf.writeInt(tank);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
super.fromBytes(buf);
|
||||
tank = buf.readInt();
|
||||
}
|
||||
|
||||
private FluidTank getTank(TileVat te) {
|
||||
if (tank == 1) {
|
||||
return te.inputTank;
|
||||
} else if (tank == 2) {
|
||||
return te.outputTank;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketDumpTank message, MessageContext ctx) {
|
||||
TileVat te = message.getTileEntity(ctx.getServerHandler().playerEntity.worldObj);
|
||||
if (te != null) {
|
||||
message.getTank(te).setFluid(null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user