CreateMod/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/ConfigureSequencedGearshiftPacket.java
caelwarner 96dc4db6dc
Sequenced Gearshift screen "greys out" when being controlled by a computer
- This is to stop players from trying to using both the builtin sequencing and a computer to control the Sequenced Gearshift at the same time, leading to undefined behaviour
- The "greyed out" screen should have a message added explaining why it's greyed out.
- Added ComputerControllable#isComputerControlled to check if a tile entity is connected to a modem
2022-10-04 21:11:38 -07:00

47 lines
1.2 KiB
Java

package com.simibubi.create.content.contraptions.relays.advanced.sequencer;
import com.simibubi.create.foundation.networking.TileEntityConfigurationPacket;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag;
import net.minecraft.network.FriendlyByteBuf;
public class ConfigureSequencedGearshiftPacket extends TileEntityConfigurationPacket<SequencedGearshiftTileEntity> {
private ListTag instructions;
public ConfigureSequencedGearshiftPacket(BlockPos pos, ListTag instructions) {
super(pos);
this.instructions = instructions;
}
public ConfigureSequencedGearshiftPacket(FriendlyByteBuf buffer) {
super(buffer);
}
@Override
protected void readSettings(FriendlyByteBuf buffer) {
instructions = buffer.readNbt().getList("data", Tag.TAG_COMPOUND);
}
@Override
protected void writeSettings(FriendlyByteBuf buffer) {
CompoundTag tag = new CompoundTag();
tag.put("data", instructions);
buffer.writeNbt(tag);
}
@Override
protected void applySettings(SequencedGearshiftTileEntity te) {
if (te.isComputerControlled(te))
return;
te.run(-1);
te.instructions = Instruction.deserializeAll(instructions);
te.sendData();
}
}