use of buildcraft.transport.gates.GateDefinition.GateLogic 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.transport.gates.GateDefinition.GateLogic in project BuildCraft by BuildCraft.
the class ItemGate method getSubItems.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List itemList) {
for (GateMaterial material : GateMaterial.VALUES) {
for (GateLogic logic : GateLogic.VALUES) {
if (material == GateMaterial.REDSTONE && logic == GateLogic.OR) {
continue;
}
itemList.add(makeGateItem(material, logic));
ItemStack stackAllExpansion = makeGateItem(material, logic);
for (IGateExpansion exp : GateExpansions.getExpansions()) {
if (exp.canAddToGate(material.numTriggerParameters, material.numActionParameters)) {
ItemStack stackExpansion = makeGateItem(material, logic);
addGateExpansion(stackExpansion, exp);
addGateExpansion(stackAllExpansion, exp);
itemList.add(stackExpansion);
}
}
itemList.add(stackAllExpansion);
}
}
}
use of buildcraft.transport.gates.GateDefinition.GateLogic in project BuildCraft by BuildCraft.
the class GateFactory method makeGate.
public static Gate makeGate(Pipe<?> pipe, NBTTagCompound nbt) {
GateMaterial material = GateMaterial.REDSTONE;
GateLogic logic = GateLogic.AND;
EnumFacing direction = null;
// Legacy Support
if (nbt.hasKey("Kind")) {
int kind = nbt.getInteger("Kind");
switch(kind) {
case 1:
case 2:
material = GateMaterial.IRON;
break;
case 3:
case 4:
material = GateMaterial.GOLD;
break;
case 5:
case 6:
material = GateMaterial.DIAMOND;
break;
}
switch(kind) {
case 2:
case 4:
case 6:
logic = GateLogic.OR;
break;
}
}
if (nbt.hasKey("material")) {
try {
material = GateMaterial.valueOf(nbt.getString("material"));
} catch (IllegalArgumentException ex) {
return null;
}
}
if (nbt.hasKey("logic")) {
try {
logic = GateLogic.valueOf(nbt.getString("logic"));
} catch (IllegalArgumentException ex) {
return null;
}
}
if (nbt.hasKey("direction")) {
direction = EnumFacing.getFront(nbt.getInteger("direction"));
}
Gate gate = makeGate(pipe, material, logic, direction);
gate.readFromNBT(nbt);
// Legacy support
if (nbt.hasKey("Pulser")) {
NBTTagCompound pulsarTag = nbt.getCompoundTag("Pulser");
GateExpansionController pulsarCon = GateExpansionPulsar.INSTANCE.makeController(pipe.container);
pulsarCon.readFromNBT(pulsarTag);
gate.expansions.put(GateExpansionPulsar.INSTANCE, pulsarCon);
}
NBTTagList exList = nbt.getTagList("expansions", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < exList.tagCount(); i++) {
NBTTagCompound conNBT = exList.getCompoundTagAt(i);
IGateExpansion ex = GateExpansions.getExpansion(conNBT.getString("type"));
if (ex != null) {
GateExpansionController con = ex.makeController(pipe.container);
con.readFromNBT(conNBT.getCompoundTag("data"));
gate.expansions.put(ex, con);
}
}
return gate;
}
Aggregations