Search in sources :

Example 1 with EnumSnapshotType

use of buildcraft.api.enums.EnumSnapshotType in project BuildCraft by BuildCraft.

the class TileBuilder method readPayload.

@Override
public void readPayload(int id, PacketBufferBC buffer, Side side, MessageContext ctx) throws IOException {
    super.readPayload(id, buffer, side, ctx);
    if (side == Side.CLIENT) {
        if (id == NET_RENDER_DATA) {
            path = new ArrayList<>();
            int pathSize = buffer.readInt();
            if (pathSize != 0) {
                for (int i = 0; i < pathSize; i++) {
                    path.add(MessageUtil.readBlockPos(buffer));
                }
            } else {
                path = null;
            }
            updateBasePoses();
            if (buffer.readBoolean()) {
                snapshotType = buffer.readEnumValue(EnumSnapshotType.class);
                getBuilder().readFromByteBuf(buffer);
            } else {
                snapshotType = null;
            }
            currentBox.readData(buffer);
            readPayload(NET_CAN_EXCAVATE, buffer, side, ctx);
            readPayload(NET_SNAPSHOT_TYPE, buffer, side, ctx);
        }
        if (id == NET_GUI_DATA || id == NET_GUI_TICK) {
            tankManager.readData(buffer);
        }
        if (id == NET_CAN_EXCAVATE) {
            canExcavate = buffer.readBoolean();
        }
        if (id == NET_SNAPSHOT_TYPE) {
            EnumSnapshotType old = snapshotType;
            snapshotType = buffer.readEnumValue(EnumOptionalSnapshotType.class).type;
            if (old != snapshotType) {
                redrawBlock();
            }
        }
    }
    if (side == Side.SERVER) {
        if (id == NET_CAN_EXCAVATE) {
            canExcavate = buffer.readBoolean();
            sendNetworkUpdate(NET_CAN_EXCAVATE);
        }
    }
}
Also used : EnumSnapshotType(buildcraft.api.enums.EnumSnapshotType) Blueprint(buildcraft.builders.snapshot.Blueprint)

Example 2 with EnumSnapshotType

use of buildcraft.api.enums.EnumSnapshotType in project BuildCraft by BuildCraft.

the class Snapshot method readFromNBT.

public static Snapshot readFromNBT(NBTTagCompound nbt) throws InvalidInputDataException {
    NBTBase tag = nbt.getTag("type");
    EnumSnapshotType type = NBTUtilBC.readEnum(tag, EnumSnapshotType.class);
    if (type == null) {
        throw new InvalidInputDataException("Unknown snapshot type " + tag);
    }
    Snapshot snapshot = Snapshot.create(type);
    snapshot.deserializeNBT(nbt);
    return snapshot;
}
Also used : InvalidInputDataException(buildcraft.api.core.InvalidInputDataException) NBTBase(net.minecraft.nbt.NBTBase) EnumSnapshotType(buildcraft.api.enums.EnumSnapshotType)

Aggregations

EnumSnapshotType (buildcraft.api.enums.EnumSnapshotType)2 InvalidInputDataException (buildcraft.api.core.InvalidInputDataException)1 Blueprint (buildcraft.builders.snapshot.Blueprint)1 NBTBase (net.minecraft.nbt.NBTBase)1