Search in sources :

Example 11 with IGateExpansion

use of buildcraft.api.gates.IGateExpansion in project BuildCraft by BuildCraft.

the class GatePluggable method writeToNBT.

@Override
public void writeToNBT(NBTTagCompound nbt) {
    nbt.setByte(ItemGate.NBT_TAG_MAT, (byte) material.ordinal());
    nbt.setByte(ItemGate.NBT_TAG_LOGIC, (byte) logic.ordinal());
    NBTTagList expansionsList = nbt.getTagList(ItemGate.NBT_TAG_EX, Constants.NBT.TAG_STRING);
    for (IGateExpansion expansion : expansions) {
        expansionsList.appendTag(new NBTTagString(expansion.getUniqueIdentifier()));
    }
    nbt.setTag(ItemGate.NBT_TAG_EX, expansionsList);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) IGateExpansion(buildcraft.api.gates.IGateExpansion) NBTTagString(net.minecraft.nbt.NBTTagString)

Example 12 with IGateExpansion

use of buildcraft.api.gates.IGateExpansion in project BuildCraft by BuildCraft.

the class GatePluggable method writeData.

@Override
public void writeData(ByteBuf buf) {
    isLit = realGate != null ? realGate.isGateActive() : false;
    isPulsing = realGate != null ? realGate.isGatePulsing() : false;
    buf.writeByte(material.ordinal());
    buf.writeByte(logic.ordinal());
    buf.writeBoolean(isLit);
    buf.writeBoolean(isPulsing);
    final int expansionsSize = expansions.length;
    buf.writeShort(expansionsSize);
    for (IGateExpansion expansion : expansions) {
        buf.writeShort(GateExpansions.getExpansionID(expansion));
    }
}
Also used : IGateExpansion(buildcraft.api.gates.IGateExpansion)

Example 13 with IGateExpansion

use of buildcraft.api.gates.IGateExpansion in project BuildCraft by BuildCraft.

the class TileGenericPipe method syncGateExpansions.

private void syncGateExpansions() {
    resyncGateExpansions = false;
    for (int i = 0; i < EnumFacing.VALUES.length; i++) {
        Gate gate = pipe.gates[i];
        if (gate == null) {
            continue;
        }
        GatePluggable gatePluggable = (GatePluggable) sideProperties.pluggables[i];
        if (gatePluggable.getExpansions().length > 0) {
            for (IGateExpansion expansion : gatePluggable.getExpansions()) {
                if (expansion != null) {
                    if (!gate.expansions.containsKey(expansion)) {
                        gate.addGateExpansion(expansion);
                    }
                } else {
                    resyncGateExpansions = true;
                }
            }
        }
    }
}
Also used : IGateExpansion(buildcraft.api.gates.IGateExpansion) GatePluggable(buildcraft.transport.gates.GatePluggable)

Aggregations

IGateExpansion (buildcraft.api.gates.IGateExpansion)13 ItemStack (net.minecraft.item.ItemStack)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 GateLogic (buildcraft.transport.gates.GateDefinition.GateLogic)3 GateMaterial (buildcraft.transport.gates.GateDefinition.GateMaterial)3 NBTTagList (net.minecraft.nbt.NBTTagList)3 Gate (buildcraft.transport.Gate)2 KeyPlugGate (buildcraft.transport.client.model.key.KeyPlugGate)2 GateDefinition (buildcraft.transport.gates.GateDefinition)2 NBTTagString (net.minecraft.nbt.NBTTagString)2 GateExpansionController (buildcraft.api.gates.GateExpansionController)1 TileGenericPipe (buildcraft.transport.TileGenericPipe)1 GatePluggable (buildcraft.transport.gates.GatePluggable)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 EnumFacing (net.minecraft.util.EnumFacing)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1