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;
}
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;
}
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]));
}
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;
}
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());
}
}
}
Aggregations