mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-13 17:28:52 -04:00
Cache item values in RC converters.
This commit is contained in:
parent
17c416007a
commit
ad4787beec
@ -41,7 +41,7 @@ object Mods {
|
||||
val ElectricalAge = new SimpleMod(IDs.ElectricalAge, providesPower = true)
|
||||
val EnderIO = new SimpleMod(IDs.EnderIO, version = "@[2.2,2.3)")
|
||||
val EnderStorage = new SimpleMod(IDs.EnderStorage)
|
||||
val ExtraCells = new SimpleMod(IDs.ExtraCells, version = "@[2.2.73,)")
|
||||
val ExtraCells = new SimpleMod(IDs.ExtraCells, version = "@[2.2.73,)")
|
||||
val Factorization = new SimpleMod(IDs.Factorization, providesPower = true)
|
||||
val Forestry = new SimpleMod(IDs.Forestry)
|
||||
val ForgeMultipart = new SimpleMod(IDs.ForgeMultipart)
|
||||
|
@ -1,6 +1,5 @@
|
||||
package li.cil.oc.integration.rotarycraft;
|
||||
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import li.cil.oc.api.driver.Converter;
|
||||
import net.minecraft.item.Item;
|
||||
@ -11,20 +10,23 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ConverterJetpackItem implements Converter {
|
||||
final Item BedrockJetPack = GameRegistry.findItem("RotaryCraft", "rotarycraft_item_bedpack");
|
||||
final Item SteelJetPack = GameRegistry.findItem("RotaryCraft", "rotarycraft_item_steelpack");
|
||||
final Item JetPack = GameRegistry.findItem("RotaryCraft", "rotarycraft_item_jetpack");
|
||||
|
||||
@Override
|
||||
public void convert(final Object value, final Map<Object, Object> output) {
|
||||
if (value instanceof ItemStack) {
|
||||
final ItemStack stack = (ItemStack) value;
|
||||
final Item item = stack.getItem();
|
||||
if (item.equals(GameRegistry.findItem("RotaryCraft", "rotarycraft_item_bedpack")) ||
|
||||
item.equals(GameRegistry.findItem("RotaryCraft", "rotarycraft_item_steelpack")) ||
|
||||
item.equals(GameRegistry.findItem("RotaryCraft", "rotarycraft_item_jetpack"))) {
|
||||
if (item != null && item == BedrockJetPack || item == SteelJetPack || item == JetPack) {
|
||||
final NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
if (tag != null && tag.hasKey("fuel"))
|
||||
if (tag != null && tag.hasKey("fuel")) {
|
||||
output.put("fuel", stack.stackTagCompound.getInteger("fuel"));
|
||||
else
|
||||
} else {
|
||||
output.put("fuel", 0);
|
||||
}
|
||||
|
||||
if (tag != null && tag.hasKey("liquid")) {
|
||||
output.put("fuelType", tag.getString("liquid"));
|
||||
@ -32,17 +34,18 @@ public class ConverterJetpackItem implements Converter {
|
||||
output.put("fuelType", "empty");
|
||||
}
|
||||
|
||||
if (item.equals(GameRegistry.findItem("RotaryCraft", "rotarycraft_item_bedpack")))
|
||||
if (item == BedrockJetPack) {
|
||||
output.put("chestplateMaterial", "bedrock");
|
||||
else if (item.equals(GameRegistry.findItem("RotaryCraft", "rotarycraft_item_steelpack")))
|
||||
} else if (item == SteelJetPack) {
|
||||
output.put("chestplateMaterial", "steel");
|
||||
else
|
||||
} else {
|
||||
output.put("chestplateMaterial", "none");
|
||||
}
|
||||
|
||||
final HashMap<String, Boolean> upgrades = new HashMap<String, Boolean>();
|
||||
upgrades.put("cooling", tag != null ? tag.getBoolean("cooling") : false);
|
||||
upgrades.put("thrustBoost", tag != null ? tag.getBoolean("jet") : false);
|
||||
upgrades.put("winged", tag != null ? tag.getBoolean("wing") : false);
|
||||
upgrades.put("cooling", tag != null && tag.getBoolean("cooling"));
|
||||
upgrades.put("thrustBoost", tag != null && tag.getBoolean("jet"));
|
||||
upgrades.put("winged", tag != null && tag.getBoolean("wing"));
|
||||
output.put("upgrades", upgrades);
|
||||
}
|
||||
}
|
||||
|
@ -9,22 +9,27 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import java.util.Map;
|
||||
|
||||
public class ConverterPumpItem implements Converter {
|
||||
final Item Pump = GameRegistry.findItem("RotaryCraft", "rotarycraft_item_pump");
|
||||
|
||||
@Override
|
||||
public void convert(final Object value, final Map<Object, Object> output) {
|
||||
if (value instanceof ItemStack) {
|
||||
final ItemStack stack = (ItemStack) value;
|
||||
final Item item = stack.getItem();
|
||||
if (stack.getItem().equals(GameRegistry.findItem("RotaryCraft", "rotarycraft_item_pump"))) {
|
||||
if (item != null && item == Pump) {
|
||||
final NBTTagCompound tag = stack.getTagCompound();
|
||||
if (tag != null && tag.hasKey("liquid"))
|
||||
output.put("liquid", stack.stackTagCompound.getString("liquid"));
|
||||
else
|
||||
output.put("liquid", "empty");
|
||||
|
||||
if (tag != null && tag.hasKey("lvl"))
|
||||
if (tag != null && tag.hasKey("liquid")) {
|
||||
output.put("liquid", stack.stackTagCompound.getString("liquid"));
|
||||
} else {
|
||||
output.put("liquid", "empty");
|
||||
}
|
||||
|
||||
if (tag != null && tag.hasKey("lvl")) {
|
||||
output.put("fluidAmount", stack.stackTagCompound.getInteger("lvl"));
|
||||
else
|
||||
} else {
|
||||
output.put("fluidAmount", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
package li.cil.oc.integration.rotarycraft
|
||||
|
||||
import li.cil.oc.api.Driver
|
||||
import li.cil.oc.integration.{ModProxy, Mods}
|
||||
import li.cil.oc.integration.ModProxy
|
||||
import li.cil.oc.integration.Mods
|
||||
|
||||
object ModRotaryCraft extends ModProxy {
|
||||
override def getMod = Mods.RotaryCraft
|
||||
|
Loading…
x
Reference in New Issue
Block a user