use of mekanism.common.tile.component.TileComponentEjector in project Mekanism by mekanism.
the class PacketConfigurationUpdate method handle.
@Override
public void handle(NetworkEvent.Context context) {
PlayerEntity player = context.getSender();
if (player == null) {
return;
}
TileEntity tile = WorldUtils.getTileEntity(player.level, pos);
if (tile instanceof ISideConfiguration) {
ISideConfiguration config = (ISideConfiguration) tile;
if (packetType == ConfigurationPacket.EJECT) {
ConfigInfo info = config.getConfig().getConfig(transmission);
if (info != null) {
info.setEjecting(!info.isEjecting());
WorldUtils.saveChunk(tile);
}
} else if (packetType == ConfigurationPacket.CLEAR_ALL) {
TileComponentConfig configComponent = config.getConfig();
ConfigInfo info = configComponent.getConfig(transmission);
if (info != null) {
for (RelativeSide side : EnumUtils.SIDES) {
if (info.isSideEnabled(side) && info.getDataType(side) != DataType.NONE) {
info.setDataType(DataType.NONE, side);
configComponent.sideChanged(transmission, side);
}
}
}
} else if (packetType == ConfigurationPacket.SIDE_DATA) {
TileComponentConfig configComponent = config.getConfig();
ConfigInfo info = configComponent.getConfig(transmission);
if (info != null) {
DataType type = info.getDataType(inputSide);
boolean changed = false;
if (clickType == 0) {
changed = type != info.incrementDataType(inputSide);
} else if (clickType == 1) {
changed = type != info.decrementDataType(inputSide);
} else if (clickType == 2 && type != DataType.NONE) {
// We only need to update it if we are changing it to none
changed = true;
info.setDataType(DataType.NONE, inputSide);
}
if (changed) {
configComponent.sideChanged(transmission, inputSide);
}
}
} else if (packetType == ConfigurationPacket.EJECT_COLOR) {
TileComponentEjector ejector = config.getEjector();
if (clickType == 0) {
ejector.setOutputColor(TransporterUtils.increment(ejector.getOutputColor()));
} else if (clickType == 1) {
ejector.setOutputColor(TransporterUtils.decrement(ejector.getOutputColor()));
} else if (clickType == 2) {
ejector.setOutputColor(null);
}
} else if (packetType == ConfigurationPacket.INPUT_COLOR) {
TileComponentEjector ejector = config.getEjector();
if (clickType == 0) {
ejector.setInputColor(inputSide, TransporterUtils.increment(ejector.getInputColor(inputSide)));
} else if (clickType == 1) {
ejector.setInputColor(inputSide, TransporterUtils.decrement(ejector.getInputColor(inputSide)));
} else if (clickType == 2) {
ejector.setInputColor(inputSide, null);
}
} else if (packetType == ConfigurationPacket.STRICT_INPUT) {
TileComponentEjector ejector = config.getEjector();
ejector.setStrictInput(!ejector.hasStrictInput());
}
}
}
Aggregations