Search in sources :

Example 1 with IGateExpansion

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

the class GateExpansionRecipe method generateExampleOutput.

@Override
public List<ItemStack> generateExampleOutput() {
    ArrayList<ItemStack> list = new ArrayList<>();
    ArrayList<IGateExpansion> exps = new ArrayList<>();
    int combinations = recipes.size();
    for (IGateExpansion exp : recipes.keySet()) {
        exps.add(exp);
    }
    for (int i = 0; i < (1 << combinations); i++) {
        for (GateDefinition.GateLogic l : GateDefinition.GateLogic.VALUES) {
            for (GateDefinition.GateMaterial m : GateDefinition.GateMaterial.VALUES) {
                ItemStack s = ItemGate.makeGateItem(m, l);
                for (int j = 0; j < combinations; j++) {
                    if (((i >> j) & 1) != 0) {
                        ItemGate.addGateExpansion(s, exps.get(j));
                    }
                }
                list.add(s);
            }
        }
    }
    return list;
}
Also used : GateDefinition(buildcraft.transport.gates.GateDefinition) ArrayList(java.util.ArrayList) IGateExpansion(buildcraft.api.gates.IGateExpansion) ItemStack(net.minecraft.item.ItemStack)

Example 2 with IGateExpansion

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

the class GateExpansionRecipe method isValidExpansion.

@Override
public boolean isValidExpansion(ItemStack input, ItemStack expansion) {
    if (StackUtil.isMatchingItem(EnumRedstoneChipset.RED.getStack(), expansion, true, true)) {
        return true;
    }
    for (ItemStack s : recipes.values()) {
        if (StackUtil.isMatchingItem(s, expansion, true, true)) {
            IGateExpansion exp = recipes.inverse().get(s);
            if (exp != null) {
                GateDefinition.GateMaterial material = ItemGate.getMaterial(input);
                int numTP = material != null ? material.numTriggerParameters : 0;
                int numAP = material != null ? material.numActionParameters : 0;
                if (exp.canAddToGate(numTP, numAP)) {
                    return true;
                } else {
                    return false;
                }
            }
        }
    }
    return false;
}
Also used : GateDefinition(buildcraft.transport.gates.GateDefinition) IGateExpansion(buildcraft.api.gates.IGateExpansion) ItemStack(net.minecraft.item.ItemStack)

Example 3 with IGateExpansion

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

the class GateItemModel method getState.

private KeyPlugGate getState(ItemStack stack) {
    GateMaterial material = ItemGate.getMaterial(stack);
    GateLogic logic = ItemGate.getLogic(stack);
    Set<IGateExpansion> expansions = ItemGate.getInstalledExpansions(stack);
    // states.add(exp.getRenderState());
    return new KeyPlugGate(EnumFacing.UP, material, logic, false, expansions.toArray(new IGateExpansion[0]));
}
Also used : GateMaterial(buildcraft.transport.gates.GateDefinition.GateMaterial) IGateExpansion(buildcraft.api.gates.IGateExpansion) KeyPlugGate(buildcraft.transport.client.model.key.KeyPlugGate) GateLogic(buildcraft.transport.gates.GateDefinition.GateLogic)

Example 4 with IGateExpansion

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

the class ItemGate method getInstalledExpansions.

public static Set<IGateExpansion> getInstalledExpansions(ItemStack stack) {
    Set<IGateExpansion> expansions = new HashSet<>();
    NBTTagCompound nbt = getNBT(stack);
    if (nbt == null) {
        return expansions;
    }
    try {
        NBTTagList expansionList = nbt.getTagList(NBT_TAG_EX, Constants.NBT.TAG_STRING);
        for (int i = 0; i < expansionList.tagCount(); i++) {
            String exTag = expansionList.getStringTagAt(i);
            IGateExpansion ex = GateExpansions.getExpansion(exTag);
            if (ex != null) {
                expansions.add(ex);
            }
        }
    } catch (RuntimeException error) {
    }
    return expansions;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IGateExpansion(buildcraft.api.gates.IGateExpansion) NBTTagString(net.minecraft.nbt.NBTTagString) HashSet(java.util.HashSet)

Example 5 with IGateExpansion

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

the class ItemGate method addInformation.

@Override
public void addInformation(ItemStack stack, EntityPlayer player, List<String> list, boolean adv) {
    super.addInformation(stack, player, list, adv);
    list.add(LocaleUtil.localize("tip.gate.wires"));
    list.add(LocaleUtil.localize("tip.gate.wires." + getMaterial(stack).getTag()));
    Set<IGateExpansion> expansions = getInstalledExpansions(stack);
    if (!expansions.isEmpty()) {
        list.add(LocaleUtil.localize("tip.gate.expansions"));
        for (IGateExpansion expansion : expansions) {
            list.add(expansion.getDisplayName());
        }
    }
}
Also used : IGateExpansion(buildcraft.api.gates.IGateExpansion)

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