Add gui and packets for locking the rolling machine. #1412
This commit is contained in:
parent
d8f3a8b9b0
commit
c17f232bf8
6 changed files with 98 additions and 10 deletions
|
@ -0,0 +1,44 @@
|
|||
package techreborn.packets;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
import reborncore.common.network.ExtendedPacketBuffer;
|
||||
import reborncore.common.network.INetworkPacket;
|
||||
import techreborn.tiles.TileRollingMachine;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class PacketRollingMachineLock implements INetworkPacket<PacketRollingMachineLock> {
|
||||
|
||||
BlockPos machinePos;
|
||||
boolean locked;
|
||||
|
||||
public PacketRollingMachineLock(TileRollingMachine machine, boolean locked) {
|
||||
this.machinePos = machine.getPos();
|
||||
this.locked = locked;
|
||||
}
|
||||
|
||||
public PacketRollingMachineLock() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(ExtendedPacketBuffer buffer) throws IOException {
|
||||
buffer.writeBlockPos(machinePos);
|
||||
buffer.writeBoolean(locked);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(ExtendedPacketBuffer buffer) throws IOException {
|
||||
machinePos = buffer.readBlockPos();
|
||||
locked = buffer.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processData(PacketRollingMachineLock message, MessageContext context) {
|
||||
TileEntity tileEntity = context.getServerHandler().player.world.getTileEntity(machinePos);
|
||||
if(tileEntity instanceof TileRollingMachine){
|
||||
((TileRollingMachine) tileEntity).locked = locked;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue