|
|
@ -90,25 +90,28 @@ public class RedControl implements ModInitializer {
|
|
|
|
//Packets
|
|
|
|
//Packets
|
|
|
|
ServerPlayNetworking.registerGlobalReceiver(RedControlNetworking.CPU_START, ((server, player, handler, buf, responseSender) -> {
|
|
|
|
ServerPlayNetworking.registerGlobalReceiver(RedControlNetworking.CPU_START, ((server, player, handler, buf, responseSender) -> {
|
|
|
|
server.execute(() -> {
|
|
|
|
server.execute(() -> {
|
|
|
|
CpuEntity cpu = (CpuEntity) player.getWorld().getBlockEntity(buf.readBlockPos());
|
|
|
|
BlockPos blockPos = buf.readBlockPos();
|
|
|
|
|
|
|
|
CpuEntity cpu = (CpuEntity) player.getWorld().getBlockEntity(blockPos);
|
|
|
|
cpu.start();
|
|
|
|
cpu.start();
|
|
|
|
LOGGER.info("Starting cpu at " + buf.readBlockPos());
|
|
|
|
LOGGER.info("Starting cpu at {}",blockPos);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
ServerPlayNetworking.registerGlobalReceiver(RedControlNetworking.CPU_STOP, ((server, player, handler, buf, responseSender) -> {
|
|
|
|
ServerPlayNetworking.registerGlobalReceiver(RedControlNetworking.CPU_STOP, ((server, player, handler, buf, responseSender) -> {
|
|
|
|
server.execute(() -> {
|
|
|
|
server.execute(() -> {
|
|
|
|
CpuEntity cpu = (CpuEntity) player.getWorld().getBlockEntity(buf.readBlockPos());
|
|
|
|
BlockPos blockPos = buf.readBlockPos();
|
|
|
|
|
|
|
|
CpuEntity cpu = (CpuEntity) player.getWorld().getBlockEntity(blockPos);
|
|
|
|
cpu.stop();
|
|
|
|
cpu.stop();
|
|
|
|
LOGGER.info("Stopping cpu at " + buf.readBlockPos());
|
|
|
|
LOGGER.info("Stopping cpu at {}",blockPos);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
ServerPlayNetworking.registerGlobalReceiver(RedControlNetworking.CPU_RESET, ((server, player, handler, buf, responseSender) -> {
|
|
|
|
ServerPlayNetworking.registerGlobalReceiver(RedControlNetworking.CPU_RESET, ((server, player, handler, buf, responseSender) -> {
|
|
|
|
server.execute(() -> {
|
|
|
|
server.execute(() -> {
|
|
|
|
CpuEntity cpu = (CpuEntity) player.getWorld().getBlockEntity(buf.readBlockPos());
|
|
|
|
BlockPos blockPos = buf.readBlockPos();
|
|
|
|
|
|
|
|
CpuEntity cpu = (CpuEntity) player.getWorld().getBlockEntity(blockPos);
|
|
|
|
cpu.reset();
|
|
|
|
cpu.reset();
|
|
|
|
LOGGER.info("Resetting cpu at " + buf.readBlockPos());
|
|
|
|
LOGGER.info("Resetting cpu at {}", blockPos);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|