diff --git a/src/main/java/com/pahimar/ee3/EquivalentExchange3.java b/src/main/java/com/pahimar/ee3/EquivalentExchange3.java index 77995311..e8b8394a 100644 --- a/src/main/java/com/pahimar/ee3/EquivalentExchange3.java +++ b/src/main/java/com/pahimar/ee3/EquivalentExchange3.java @@ -3,13 +3,12 @@ import java.io.File; import com.pahimar.ee3.array.AlchemyArrayRegistry; +import com.pahimar.ee3.blacklist.BlacklistRegistry; import com.pahimar.ee3.command.CommandEE; -import com.pahimar.ee3.exchange.CachedOreDictionary; import com.pahimar.ee3.exchange.EnergyValueRegistry; import com.pahimar.ee3.handler.*; import com.pahimar.ee3.init.*; -import com.pahimar.ee3.knowledge.AbilityRegistry; -import com.pahimar.ee3.knowledge.TransmutationKnowledgeRegistry; +import com.pahimar.ee3.knowledge.PlayerKnowledgeRegistry; import com.pahimar.ee3.network.PacketHandler; import com.pahimar.ee3.proxy.IProxy; import com.pahimar.ee3.recipe.AludelRecipeManager; @@ -17,8 +16,9 @@ import com.pahimar.ee3.reference.Files; import com.pahimar.ee3.reference.Messages; import com.pahimar.ee3.reference.Reference; -import com.pahimar.ee3.reference.Settings; -import com.pahimar.ee3.test.EnergyValueMappingsTestSuite; +import com.pahimar.ee3.test.EETestSuite; +import com.pahimar.ee3.test.EnergyValueTestSuite; +import com.pahimar.ee3.test.VanillaTestSuite; import com.pahimar.ee3.util.FluidHelper; import com.pahimar.ee3.util.LogHelper; import com.pahimar.ee3.util.SerializationHelper; @@ -49,6 +49,7 @@ public class EquivalentExchange3 { @EventHandler public void invalidFingerprint(FMLFingerprintViolationEvent event) { + if (Reference.FINGERPRINT.equals("@FINGERPRINT@")) { LogHelper.info(Messages.NO_FINGERPRINT_MESSAGE); } else { @@ -58,20 +59,19 @@ public void invalidFingerprint(FMLFingerprintViolationEvent event) { @EventHandler public void onServerStarting(FMLServerStartingEvent event) { - SerializationHelper.initModDataDirectories(); - - TransmutationKnowledgeRegistry.getInstance(); - AbilityRegistry.getInstance().loadAbilityRegistryFromFile(Settings.Abilities.onlyLoadFile); + Files.updateFileReferences(); + SerializationHelper.initModDataDirectories(); event.registerServerCommand(new CommandEE()); } @EventHandler public void preInit(FMLPreInitializationEvent event) { + ConfigurationHandler.init(event.getSuggestedConfigurationFile()); - Files.Global.init(event); + Files.init(event); PacketHandler.init(); @@ -83,16 +83,20 @@ public void preInit(FMLPreInitializationEvent event) { FluidHelper.registerFluids(); - EnergyValues.addDefaultEnergyValues(); + EnergyValues.init(); AlchemyArrays.registerAlchemyArrays(); } @EventHandler public void init(FMLInitializationEvent event) { + // Register the GUI Handler NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler()); + // Initialize the blacklist registry + BlacklistRegistry.INSTANCE.load(); + // Initialize mod tile entities TileEntities.init(); @@ -114,21 +118,26 @@ public void init(FMLInitializationEvent event) { @EventHandler public void postInit(FMLPostInitializationEvent event) { - CachedOreDictionary.getInstance(); - Abilities.initNotLearnables(); + + Abilities.init(); + + // Initialize our test files + new VanillaTestSuite().build().save(); + new EETestSuite().build().save(); } @EventHandler public void onServerStopping(FMLServerStoppingEvent event) { - WorldEventHandler.hasInitilialized = false; - EnergyValueRegistry.getInstance().save(); - TransmutationKnowledgeRegistry.getInstance().clear(); - AbilityRegistry.getInstance().save(); + WorldEventHandler.hasInitilialized = false; + EnergyValueRegistry.INSTANCE.save(); + PlayerKnowledgeRegistry.INSTANCE.saveAll(); + BlacklistRegistry.INSTANCE.saveAll(); } @EventHandler public void handleMissingMappingEvent(FMLMissingMappingsEvent event) { + for (FMLMissingMappingsEvent.MissingMapping mapping : event.get()) { if (mapping.type == GameRegistry.Type.ITEM) { if (mapping.name.equals("EE3:alchemicalTome")) { @@ -139,38 +148,38 @@ public void handleMissingMappingEvent(FMLMissingMappingsEvent event) { } public EnergyValueRegistry getEnergyValueRegistry() { - return EnergyValueRegistry.getInstance(); + return EnergyValueRegistry.INSTANCE; } public RecipeRegistry getRecipeRegistry() { - return RecipeRegistry.getInstance(); + return RecipeRegistry.INSTANCE; } public AludelRecipeManager getAludelRecipeManager() { return AludelRecipeManager.getInstance(); } - public AbilityRegistry getAbilityRegistry() { - return AbilityRegistry.getInstance(); + public BlacklistRegistry getBlacklistRegistry() { + return BlacklistRegistry.INSTANCE; } public AlchemyArrayRegistry getAlchemyArrayRegistry() { return AlchemyArrayRegistry.getInstance(); } - public TransmutationKnowledgeRegistry getTransmutationKnowledgeRegistry() { - return TransmutationKnowledgeRegistry.getInstance(); + public PlayerKnowledgeRegistry getPlayerKnowledgeRegistry() { + return PlayerKnowledgeRegistry.INSTANCE; } public TileEntityDataHelper getTileEntityDataHelper() { return TileEntityDataHelper.getInstance(); } - public void runEnergyValueMappingTest(File file) { - runEnergyValueMappingTest(file, false); + public void runEnergyValueTestSuite(File file) { + runEnergyValueTestSuite(file, false); } - public void runEnergyValueMappingTest(File file, boolean strict) { - new EnergyValueMappingsTestSuite(file).runTestSuite(strict); + public void runEnergyValueTestSuite(File file, boolean strict) { + new EnergyValueTestSuite(file).run(strict); } } diff --git a/src/main/java/com/pahimar/ee3/api/event/AbilityEvent.java b/src/main/java/com/pahimar/ee3/api/event/AbilityEvent.java index ca4ed024..f79b8cfa 100644 --- a/src/main/java/com/pahimar/ee3/api/event/AbilityEvent.java +++ b/src/main/java/com/pahimar/ee3/api/event/AbilityEvent.java @@ -2,10 +2,18 @@ import cpw.mods.fml.common.eventhandler.Event; +/** + * @deprecated See {@link BlacklistEvent} + */ +@Deprecated public class AbilityEvent extends Event { public final Object object; + /** + * @deprecated See {@link BlacklistEvent} + */ + @Deprecated public AbilityEvent(Object object) { this.object = object; } @@ -15,6 +23,9 @@ public boolean isCancelable() { return true; } + /** + * @deprecated See {@link com.pahimar.ee3.api.event.BlacklistEvent.KnowledgeWhitelistEvent} + */ public static class SetLearnableEvent extends AbilityEvent { public SetLearnableEvent(Object object) { @@ -22,6 +33,9 @@ public SetLearnableEvent(Object object) { } } + /** + * @deprecated See {@link com.pahimar.ee3.api.event.BlacklistEvent.KnowledgeBlacklistEvent} + */ public static class SetNotLearnableEvent extends AbilityEvent { public SetNotLearnableEvent(Object object) { @@ -29,6 +43,9 @@ public SetNotLearnableEvent(Object object) { } } + /** + * @deprecated See {@link com.pahimar.ee3.api.event.BlacklistEvent.ExchangeWhitelistEvent} + */ public static class SetRecoverableEvent extends AbilityEvent { public SetRecoverableEvent(Object object) { @@ -36,6 +53,9 @@ public SetRecoverableEvent(Object object) { } } + /** + * @deprecated See {@link com.pahimar.ee3.api.event.BlacklistEvent.ExchangeBlacklistEvent} + */ public static class SetNotRecoverableEvent extends AbilityEvent { public SetNotRecoverableEvent(Object object) { diff --git a/src/main/java/com/pahimar/ee3/api/event/EnergyValueEvent.java b/src/main/java/com/pahimar/ee3/api/event/EnergyValueEvent.java index d75a2040..36b183e8 100644 --- a/src/main/java/com/pahimar/ee3/api/event/EnergyValueEvent.java +++ b/src/main/java/com/pahimar/ee3/api/event/EnergyValueEvent.java @@ -1,7 +1,5 @@ package com.pahimar.ee3.api.event; -import net.minecraft.entity.player.EntityPlayer; - import com.pahimar.ee3.api.exchange.EnergyValue; import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy; import cpw.mods.fml.common.eventhandler.Event; @@ -10,12 +8,11 @@ public class EnergyValueEvent extends Event { public final Object object; public final EnergyValueRegistryProxy.Phase phase; - public final EntityPlayer entityPlayer; - public EnergyValueEvent(Object object, EnergyValueRegistryProxy.Phase phase, EntityPlayer entityPlayer) { + public EnergyValueEvent(Object object, EnergyValueRegistryProxy.Phase phase) { + this.object = object; this.phase = phase; - this.entityPlayer = entityPlayer; } @Override @@ -27,17 +24,17 @@ public static class SetEnergyValueEvent extends EnergyValueEvent { public final EnergyValue newEnergyValue; - public SetEnergyValueEvent(Object object, EnergyValue newEnergyValue, EnergyValueRegistryProxy.Phase phase, - EntityPlayer entityPlayer) { - super(object, phase, entityPlayer); + public SetEnergyValueEvent(Object object, EnergyValue newEnergyValue, EnergyValueRegistryProxy.Phase phase) { + + super(object, phase); this.newEnergyValue = newEnergyValue; } } public static class RemoveEnergyValueEvent extends EnergyValueEvent { - public RemoveEnergyValueEvent(Object object, EnergyValueRegistryProxy.Phase phase, EntityPlayer entityPlayer) { - super(object, phase, entityPlayer); + public RemoveEnergyValueEvent(Object object, EnergyValueRegistryProxy.Phase phase) { + super(object, phase); } } } diff --git a/src/main/java/com/pahimar/ee3/api/exchange/EnergyValue.java b/src/main/java/com/pahimar/ee3/api/exchange/EnergyValue.java index f28c26a0..23150c7b 100644 --- a/src/main/java/com/pahimar/ee3/api/exchange/EnergyValue.java +++ b/src/main/java/com/pahimar/ee3/api/exchange/EnergyValue.java @@ -1,40 +1,46 @@ package com.pahimar.ee3.api.exchange; -import java.lang.reflect.Type; +import java.math.BigDecimal; +import java.text.DecimalFormat; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ChatComponentText; import net.minecraft.util.IChatComponent; -import com.google.gson.*; +public final class EnergyValue implements Comparable { -public final class EnergyValue - implements Comparable, JsonDeserializer, JsonSerializer { - - private static final Gson jsonSerializer = (new GsonBuilder()) - .registerTypeAdapter(EnergyValue.class, new EnergyValue()).create(); + private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("###,###,###,###,###.###"); private float energyValue; public EnergyValue() { this(0); } - public EnergyValue(float energyValue) { - this.energyValue = energyValue; + public EnergyValue(Number energyValue) { + this.energyValue = energyValue.floatValue(); } - @Override - public boolean equals(Object object) { - return object instanceof EnergyValue && (compareTo((EnergyValue) object) == 0); + public float getValue() { + return this.energyValue; + } + + public IChatComponent getChatComponent() { + return new ChatComponentText("" + this.getValue()); } @Override public String toString() { - return String.format("%s", energyValue); + return DECIMAL_FORMAT.format(energyValue); + } + + @Override + public boolean equals(Object object) { + return object instanceof EnergyValue && (compareTo((EnergyValue) object) == 0); } @Override public int compareTo(EnergyValue energyValue) { + if (energyValue != null) { return Float.compare(this.energyValue, energyValue.getValue()); } else { @@ -42,122 +48,43 @@ public int compareTo(EnergyValue energyValue) { } } - public float getValue() { - return this.energyValue; - } - - public IChatComponent getChatComponent() { - return new ChatComponentText("" + this.getValue()); - } - public NBTTagCompound writeToNBT(NBTTagCompound nbtTagCompound) { nbtTagCompound.setFloat("energyValue", energyValue); return nbtTagCompound; } public void readFromNBT(NBTTagCompound nbtTagCompound) { + if (nbtTagCompound.hasKey("energyValue")) { this.energyValue = nbtTagCompound.getFloat("energyValue"); } } public static NBTTagCompound writeEnergyValueToNBT(EnergyValue energyValue) { + NBTTagCompound nbtTagCompound = new NBTTagCompound(); energyValue.writeToNBT(nbtTagCompound); return nbtTagCompound; } public static EnergyValue loadEnergyValueFromNBT(NBTTagCompound nbtTagCompound) { + if (nbtTagCompound.hasKey("energyValue")) { float energyValue = nbtTagCompound.getFloat("energyValue"); - return new EnergyValue(energyValue); } return null; } - /** - * Deserializes an EmcValue object from the given serialized json String - * - * @param jsonEnergyValue Json encoded String representing a EmcValue object - * @return The EmcValue that was encoded as json, or null if a valid EmcValue could not be decoded from given String - */ - @SuppressWarnings("unused") - public static EnergyValue createFromJson(String jsonEnergyValue) { - try { - return jsonSerializer.fromJson(jsonEnergyValue, EnergyValue.class); - } catch (JsonSyntaxException exception) { - exception.printStackTrace(); - } catch (JsonParseException exception) { - exception.printStackTrace(); - } - - return null; - } - - /** - * Returns this EmcValue as a json serialized String - * - * @return Json serialized String of this EmcValue - */ - public String toJson() { - return jsonSerializer.toJson(this); - } - - /** - * Gson invokes this call-back method during deserialization when it encounters a field of the specified type. - *

- * In the implementation of this call-back method, you should consider invoking - * {@link com.google.gson.JsonDeserializationContext#deserialize(com.google.gson.JsonElement, java.lang.reflect.Type)} - * method to create objects for any non-trivial field of the returned object. However, you should never invoke it on - * the the same type passing {@code jsonElement} since that will cause an infinite loop (Gson will call your - * call-back method again). - * - * @param jsonElement The Json data being deserialized - * @param typeOfT The type of the Object to deserialize to - * @param context - * @return a deserialized object of the specified type typeOfT which is a subclass of {@code T} - * @throws com.google.gson.JsonParseException if jsonElement is not in the expected format of {@code typeofT} - */ - @Override - public EnergyValue deserialize(JsonElement jsonElement, Type typeOfT, JsonDeserializationContext context) - throws JsonParseException { - JsonObject jsonEnergyValue = (JsonObject) jsonElement; - - if (jsonEnergyValue.get("value") != null && jsonEnergyValue.get("value").isJsonPrimitive()) { - float energyValue = jsonEnergyValue.get("value").getAsFloat(); + public static EnergyValue factor(EnergyValue energyValue, Number factor) { - if (Float.compare(energyValue, 0f) >= 0) { - return new EnergyValue(energyValue); - } + if ((Float.compare(factor.floatValue(), 0f) != 0) && (energyValue != null)) { + return new EnergyValue( + new BigDecimal(energyValue.getValue() * 1f / factor.floatValue()) + .setScale(3, BigDecimal.ROUND_HALF_EVEN).floatValue()); + } else { + return null; } - - return null; - } - - /** - * Gson invokes this call-back method during serialization when it encounters a field of the specified type. - *

- *

- * In the implementation of this call-back method, you should consider invoking - * {@link com.google.gson.JsonSerializationContext#serialize(Object, java.lang.reflect.Type)} method to create - * JsonElements for any non-trivial field of the {@code energyValueObject} object. However, you should never invoke - * it on the {@code energyValueObject} object itself since that will cause an infinite loop (Gson will call your - * call-back method again). - *

- * - * @param energyValueObject the object that needs to be converted to Json. - * @param typeOfSrc the actual type (fully genericized version) of the source object. - * @param context - * @return a JsonElement corresponding to the specified object. - */ - @Override - public JsonElement serialize(EnergyValue energyValueObject, Type typeOfSrc, JsonSerializationContext context) { - JsonObject jsonEnergyValue = new JsonObject(); - - jsonEnergyValue.addProperty("value", energyValueObject.energyValue); - - return jsonEnergyValue; } } diff --git a/src/main/java/com/pahimar/ee3/api/exchange/EnergyValueMappingsTester.java b/src/main/java/com/pahimar/ee3/api/exchange/EnergyValueMappingsTester.java index 46999bfe..a51fa668 100644 --- a/src/main/java/com/pahimar/ee3/api/exchange/EnergyValueMappingsTester.java +++ b/src/main/java/com/pahimar/ee3/api/exchange/EnergyValueMappingsTester.java @@ -15,7 +15,7 @@ public static void runTest(File file, boolean strict) { init(); if (ee3Mod != null) { - EE3Wrapper.ee3mod.runEnergyValueMappingTest(file, strict); + EE3Wrapper.ee3mod.runEnergyValueTestSuite(file, strict); } } diff --git a/src/main/java/com/pahimar/ee3/api/exchange/EnergyValueRegistryProxy.java b/src/main/java/com/pahimar/ee3/api/exchange/EnergyValueRegistryProxy.java index 252cd442..33eae06e 100644 --- a/src/main/java/com/pahimar/ee3/api/exchange/EnergyValueRegistryProxy.java +++ b/src/main/java/com/pahimar/ee3/api/exchange/EnergyValueRegistryProxy.java @@ -1,8 +1,12 @@ package com.pahimar.ee3.api.exchange; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; +import java.util.Map; import com.pahimar.ee3.EquivalentExchange3; +import com.pahimar.ee3.exchange.WrappedStack; import cpw.mods.fml.common.Mod; public final class EnergyValueRegistryProxy { @@ -10,56 +14,33 @@ public final class EnergyValueRegistryProxy { @Mod.Instance("EE3") private static Object ee3Mod; - public static void addPreCalculationEnergyValue(Object object, float energyValue) { - addPreCalculationEnergyValue(object, new EnergyValue(energyValue)); + public static Map getPreCalculationEnergyValues() { + return getEnergyValues(Phase.PRE_CALCULATION); } - @Deprecated - public static void addPreAssignedEnergyValue(Object object, float energyValue) { - addPreAssignedEnergyValue(object, new EnergyValue(energyValue)); + public static Map getPostCalculationEnergyValues() { + return getEnergyValues(Phase.POST_CALCULATION); } - public static void addPreCalculationEnergyValue(Object object, EnergyValue energyValue) { - init(); - - if (ee3Mod != null) { - EE3Wrapper.ee3mod.getEnergyValueRegistry().addPreCalculationEnergyValue(object, energyValue); - } + public static Map getEnergyValues() { + return getEnergyValues(Phase.ALL); } - @Deprecated - public static void addPreAssignedEnergyValue(Object object, EnergyValue energyValue) { - init(); + public static Map getEnergyValues(Phase phase) { - if (ee3Mod != null) { - EE3Wrapper.ee3mod.getEnergyValueRegistry().addPreCalculationEnergyValue(object, energyValue); - } - } - - public static void addPostCalculationEnergyValue(Object object, float energyValue) { - addPostCalculationEnergyValue(object, new EnergyValue(energyValue)); - } - - @Deprecated - public static void addPostAssignedEnergyValue(Object object, float energyValue) { - addPostAssignedEnergyValue(object, new EnergyValue(energyValue)); - } - - public static void addPostCalculationEnergyValue(Object object, EnergyValue energyValue) { init(); if (ee3Mod != null) { - EE3Wrapper.ee3mod.getEnergyValueRegistry().addPostCalculationExactEnergyValue(object, energyValue); + if (phase == Phase.PRE_ASSIGNMENT || phase == Phase.PRE_CALCULATION) { + EE3Wrapper.ee3mod.getEnergyValueRegistry().getPreCalculationStackValueMap(); + } else if (phase == Phase.POST_ASSIGNMENT || phase == Phase.POST_CALCULATION) { + EE3Wrapper.ee3mod.getEnergyValueRegistry().getPostCalculationStackValueMap(); + } else if (phase == Phase.ALL) { + EE3Wrapper.ee3mod.getEnergyValueRegistry().getEnergyValues(); + } } - } - - @Deprecated - public static void addPostAssignedEnergyValue(Object object, EnergyValue energyValue) { - init(); - if (ee3Mod != null) { - EE3Wrapper.ee3mod.getEnergyValueRegistry().addPostCalculationExactEnergyValue(object, energyValue); - } + return null; } public static boolean hasEnergyValue(Object object) { @@ -67,6 +48,7 @@ public static boolean hasEnergyValue(Object object) { } public static boolean hasEnergyValue(Object object, boolean strict) { + init(); if (ee3Mod != null) { @@ -81,14 +63,11 @@ public static EnergyValue getEnergyValue(Object object) { } public static EnergyValue getEnergyValue(Object object, boolean strict) { - return getEnergyValue(Phase.ALL, object, strict); - } - public static EnergyValue getEnergyValue(Phase phase, Object object, boolean strict) { init(); if (ee3Mod != null) { - return EE3Wrapper.ee3mod.getEnergyValueRegistry().getEnergyValue(phase, object, strict); + return EE3Wrapper.ee3mod.getEnergyValueRegistry().getEnergyValue(object, strict); } return null; @@ -99,6 +78,7 @@ public static EnergyValue getEnergyValueForStack(Object object) { } public static EnergyValue getEnergyValueForStack(Object object, boolean strict) { + init(); if (ee3Mod != null) { @@ -108,29 +88,128 @@ public static EnergyValue getEnergyValueForStack(Object object, boolean strict) return null; } - public static List getStacksInRange(float start, float finish) { - return getStacksInRange(new EnergyValue(start), new EnergyValue(finish)); + public static List getStacksInRange(Number start, Number finish) { + return getStacksInRange(start, finish); } public static List getStacksInRange(EnergyValue start, EnergyValue finish) { + init(); if (ee3Mod != null) { - return EE3Wrapper.ee3mod.getEnergyValueRegistry().getStacksInRange(start, finish); + return new ArrayList<>(EE3Wrapper.ee3mod.getEnergyValueRegistry().getStacksInRange(start, finish)); } - return null; + return Collections.EMPTY_LIST; } - public static void dumpEnergyValueRegistryToLog() { - dumpEnergyValueRegistryToLog(Phase.ALL); + /** + * + * @deprecated + * @param object + * @param energyValue + */ + @Deprecated + public static void addPreAssignedEnergyValue(Object object, float energyValue) { + setEnergyValue(object, energyValue, Phase.PRE_CALCULATION); } - public static void dumpEnergyValueRegistryToLog(Phase phase) { + /** + * + * @deprecated + * @param object + * @param energyValue + */ + @Deprecated + public static void addPreAssignedEnergyValue(Object object, EnergyValue energyValue) { + setEnergyValue(object, energyValue, Phase.PRE_CALCULATION); + } + + /** + * + * @deprecated + * @param object + * @param energyValue + */ + @Deprecated + public static void addPreCalculationEnergyValue(Object object, float energyValue) { + setEnergyValue(object, energyValue, Phase.PRE_CALCULATION); + } + + /** + * + * @deprecated + * @param object + * @param energyValue + */ + @Deprecated + public static void addPreCalculationEnergyValue(Object object, EnergyValue energyValue) { + setEnergyValue(object, energyValue, Phase.PRE_CALCULATION); + } + + /** + * + * @deprecated + * @param object + * @param energyValue + */ + @Deprecated + public static void addPostAssignedEnergyValue(Object object, float energyValue) { + setEnergyValue(object, energyValue); + } + + /** + * + * @deprecated + * @param object + * @param energyValue + */ + @Deprecated + public static void addPostAssignedEnergyValue(Object object, EnergyValue energyValue) { + setEnergyValue(object, energyValue); + } + + /** + * + * @deprecated + * @param object + * @param energyValue + */ + @Deprecated + public static void addPostCalculationEnergyValue(Object object, float energyValue) { + setEnergyValue(object, energyValue); + } + + /** + * + * @deprecated + * @param object + * @param energyValue + */ + @Deprecated + public static void addPostCalculationEnergyValue(Object object, EnergyValue energyValue) { + setEnergyValue(object, energyValue); + } + + public static void setEnergyValue(Object object, Number energyValue) { + setEnergyValue(object, new EnergyValue(energyValue), Phase.POST_CALCULATION); + } + + public static void setEnergyValue(Object object, EnergyValue energyValue) { + setEnergyValue(object, energyValue, Phase.POST_CALCULATION); + } + + public static void setEnergyValue(Object object, Number energyValue, Phase phase) { + + setEnergyValue(object, new EnergyValue(energyValue), phase); + } + + public static void setEnergyValue(Object object, EnergyValue energyValue, Phase phase) { + init(); if (ee3Mod != null) { - EE3Wrapper.ee3mod.getEnergyValueRegistry().dumpEnergyValueRegistryToLog(phase); + EE3Wrapper.ee3mod.getEnergyValueRegistry().setEnergyValue(object, energyValue, phase); } } @@ -140,30 +219,21 @@ private static class EE3Wrapper { } private static void init() { + if (ee3Mod != null) { EE3Wrapper.ee3mod = (EquivalentExchange3) ee3Mod; } } public enum Phase { - /** - * @Deprecated Use PRE_CALCULATION instead - */ @Deprecated PRE_ASSIGNMENT, - PRE_CALCULATION, - - /** - * @Deprecated Use POST_CALCULATION instead - */ @Deprecated POST_ASSIGNMENT, - POST_CALCULATION, - + @Deprecated RUNTIME, - ALL } } diff --git a/src/main/java/com/pahimar/ee3/api/exchange/IEnergyValueProvider.java b/src/main/java/com/pahimar/ee3/api/exchange/IEnergyValueProvider.java index f3340494..d1d047b1 100644 --- a/src/main/java/com/pahimar/ee3/api/exchange/IEnergyValueProvider.java +++ b/src/main/java/com/pahimar/ee3/api/exchange/IEnergyValueProvider.java @@ -4,5 +4,5 @@ public interface IEnergyValueProvider { - public abstract EnergyValue getEnergyValue(ItemStack itemStack); + EnergyValue getEnergyValue(ItemStack itemStack); } diff --git a/src/main/java/com/pahimar/ee3/api/exchange/RecipeRegistryProxy.java b/src/main/java/com/pahimar/ee3/api/exchange/RecipeRegistryProxy.java index 2c24a60f..077ec8a4 100644 --- a/src/main/java/com/pahimar/ee3/api/exchange/RecipeRegistryProxy.java +++ b/src/main/java/com/pahimar/ee3/api/exchange/RecipeRegistryProxy.java @@ -2,40 +2,31 @@ import java.util.List; -import com.pahimar.ee3.EquivalentExchange3; -import cpw.mods.fml.common.Mod; - +/** + * @deprecated + * @see com.pahimar.ee3.api.recipe.RecipeRegistryProxy + */ +@Deprecated public final class RecipeRegistryProxy { + /** + * + * @deprecated + * @param recipeOutput + * @param recipeInputList + * @see com.pahimar.ee3.api.recipe.RecipeRegistryProxy#addRecipe(Object, List) + */ + @Deprecated public static void addRecipe(Object recipeOutput, List recipeInputList) { - init(); - - // NOOP if EquivalentExchange3 is not present - if (ee3Mod != null) { - EE3Wrapper.ee3mod.getRecipeRegistry().addRecipe(recipeOutput, recipeInputList); - } + com.pahimar.ee3.api.recipe.RecipeRegistryProxy.addRecipe(recipeOutput, recipeInputList); } + /** + * @deprecated + * @see com.pahimar.ee3.api.recipe.RecipeRegistryProxy#dumpRecipeRegistryToLog() + */ + @Deprecated public static void dumpRecipeRegistryToLog() { - init(); - - // NOOP if EquivalentExchange3 is not present - if (ee3Mod != null) { - EE3Wrapper.ee3mod.getRecipeRegistry().dumpRecipeRegistryToLog(); - } - } - - @Mod.Instance("EE3") - private static Object ee3Mod; - - private static class EE3Wrapper { - - private static EquivalentExchange3 ee3mod; - } - - private static void init() { - if (ee3Mod != null) { - EE3Wrapper.ee3mod = (EquivalentExchange3) ee3Mod; - } + com.pahimar.ee3.api.recipe.RecipeRegistryProxy.dumpRecipeRegistryToLog(); } } diff --git a/src/main/java/com/pahimar/ee3/api/knowledge/AbilityRegistryProxy.java b/src/main/java/com/pahimar/ee3/api/knowledge/AbilityRegistryProxy.java index b483c6cc..f4d34f7b 100644 --- a/src/main/java/com/pahimar/ee3/api/knowledge/AbilityRegistryProxy.java +++ b/src/main/java/com/pahimar/ee3/api/knowledge/AbilityRegistryProxy.java @@ -1,86 +1,64 @@ package com.pahimar.ee3.api.knowledge; -import com.pahimar.ee3.EquivalentExchange3; -import cpw.mods.fml.common.Mod; +import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; +@Deprecated public final class AbilityRegistryProxy { - @Mod.Instance("EE3") - private static Object ee3Mod; - + /** + * @deprecated See {@link BlacklistRegistryProxy#isLearnable(Object)} + */ public static boolean isLearnable(Object object) { - init(); - - if (ee3Mod != null) { - return EE3Wrapper.ee3mod.getAbilityRegistry().isLearnable(object); - } - - return false; + return BlacklistRegistryProxy.isLearnable(object); } + /** + * @deprecated See {@link BlacklistRegistryProxy#setAsLearnable(Object)} + */ public static void setAsLearnable(Object object) { - init(); - - if (ee3Mod != null) { - EE3Wrapper.ee3mod.getAbilityRegistry().setAsLearnable(object); - } + BlacklistRegistryProxy.setAsLearnable(object); } + /** + * @deprecated See {@link BlacklistRegistryProxy#setAsNotLearnable(Object)} + */ public static void setAsNotLearnable(Object object) { - init(); - - if (ee3Mod != null) { - EE3Wrapper.ee3mod.getAbilityRegistry().setAsNotLearnable(object); - } + BlacklistRegistryProxy.setAsNotLearnable(object); } + /** + * @deprecated See {@link BlacklistRegistryProxy#isExchangeable(Object)} + */ public static boolean isRecoverable(Object object) { - init(); - - if (ee3Mod != null) { - return EE3Wrapper.ee3mod.getAbilityRegistry().isRecoverable(object); - } - - return false; + return BlacklistRegistryProxy.isExchangeable(object); } + /** + * @deprecated See {@link BlacklistRegistryProxy#setAsExchangeable(Object)} + */ public static void setAsRecoverable(Object object) { - init(); - - if (ee3Mod != null) { - EE3Wrapper.ee3mod.getAbilityRegistry().setAsRecoverable(object); - } + BlacklistRegistryProxy.setAsExchangeable(object); } + /** + * @deprecated See {@link BlacklistRegistryProxy#setAsNotExchangeable(Object)} + */ public static void setAsNotRecoverable(Object object) { - init(); - - if (ee3Mod != null) { - EE3Wrapper.ee3mod.getAbilityRegistry().setAsNotRecoverable(object); - } + BlacklistRegistryProxy.setAsNotExchangeable(object); } + /** + * @deprecated will be removed from EE3 in newer versions of Minecraft + */ public static void dumpAbilityRegistryToLog() { - dumpAbilityRegistryToLog(Abilities.ALL); + // NOOP } + /** + * @deprecated will be removed from EE3 in newer versions of Minecraft + */ public static void dumpAbilityRegistryToLog(Abilities ability) { - init(); - - if (ee3Mod != null) { - EE3Wrapper.ee3mod.getAbilityRegistry().dumpAbilityRegistryToLog(ability); - } - } - - private static class EE3Wrapper { - - private static EquivalentExchange3 ee3mod; - } - - private static void init() { - if (ee3Mod != null) { - EE3Wrapper.ee3mod = (EquivalentExchange3) ee3Mod; - } + // NOOP } public enum Abilities { diff --git a/src/main/java/com/pahimar/ee3/api/knowledge/TransmutationKnowledgeRegistryProxy.java b/src/main/java/com/pahimar/ee3/api/knowledge/TransmutationKnowledgeRegistryProxy.java index 8411ae5f..48772065 100644 --- a/src/main/java/com/pahimar/ee3/api/knowledge/TransmutationKnowledgeRegistryProxy.java +++ b/src/main/java/com/pahimar/ee3/api/knowledge/TransmutationKnowledgeRegistryProxy.java @@ -1,247 +1,133 @@ package com.pahimar.ee3.api.knowledge; +import java.util.Collections; import java.util.Set; import java.util.UUID; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import com.pahimar.ee3.EquivalentExchange3; -import cpw.mods.fml.common.Mod; - +/** + * @deprecated as of API 0.4.0; use {@link PlayerKnowledgeRegistryProxy} instead + * @see PlayerKnowledgeRegistryProxy + */ +@Deprecated public class TransmutationKnowledgeRegistryProxy { + @Deprecated public static boolean doesPlayerKnow(EntityPlayer entityPlayer, ItemStack itemStack) { - init(); - - if (ee3Mod != null) { - return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().doesPlayerKnow(entityPlayer, itemStack); - } - - return false; + return PlayerKnowledgeRegistryProxy.doesPlayerKnow(entityPlayer, itemStack); } + @Deprecated public static boolean doesPlayerKnow(UUID playerUUID, ItemStack itemStack) { - init(); - - if (ee3Mod != null) { - return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().doesPlayerKnow(playerUUID, itemStack); - } - return false; } + @Deprecated public static boolean canPlayerLearn(EntityPlayer entityPlayer, ItemStack itemStack) { - init(); - - if (ee3Mod != null) { - return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().canPlayerLearn(entityPlayer, itemStack); - } - - return false; + return PlayerKnowledgeRegistryProxy.canPlayerLearn(entityPlayer, itemStack); } + @Deprecated public static boolean canPlayerLearn(UUID playerUUID, ItemStack itemStack) { - init(); - - if (ee3Mod != null) { - return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().canPlayerLearn(playerUUID, itemStack); - } - return false; } + @Deprecated public static Set getPlayerKnownTransmutations(EntityPlayer entityPlayer) { - init(); - - if (ee3Mod != null) { - return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().getPlayersKnownTransmutations(entityPlayer); - } - - return null; + return PlayerKnowledgeRegistryProxy.getKnownItemStacks(entityPlayer); } + @Deprecated public static Set getPlayerKnownTransmutations(UUID playerUUID) { - init(); - - if (ee3Mod != null) { - return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().getPlayersKnownTransmutations(playerUUID); - } - - return null; + return Collections.EMPTY_SET; } + @Deprecated public static Set getPlayerKnownTransmutationsFilteredStartsWith(EntityPlayer entityPlayer, String filterString) { - init(); - - if (ee3Mod != null) { - return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry() - .getPlayersKnownTransmutationsFilteredStartsWith(entityPlayer, filterString); - } - - return null; + return PlayerKnowledgeRegistryProxy.getKnownItemStacks(entityPlayer); } + @Deprecated public static Set getPlayerKnownTransmutationsFilteredStartsWith(UUID playerUUID, String filterString) { - init(); - - if (ee3Mod != null) { - return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry() - .getPlayersKnownTransmutationsFilteredStartsWith(playerUUID, filterString); - } - - return null; + return Collections.EMPTY_SET; } + @Deprecated public static Set getPlayerKnownTransmutationsFilteredContains(EntityPlayer entityPlayer, String filterString) { - init(); - - if (ee3Mod != null) { - return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry() - .getPlayersKnownTransmutationsFilteredContains(entityPlayer, filterString); - } - - return null; + return PlayerKnowledgeRegistryProxy.getKnownItemStacks(entityPlayer); } + @Deprecated public static Set getPlayerKnownTransmutationsFilteredContains(UUID playerUUID, String filterString) { - init(); - - if (ee3Mod != null) { - return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry() - .getPlayersKnownTransmutationsFilteredContains(playerUUID, filterString); - } - - return null; + return Collections.EMPTY_SET; } + @Deprecated public static void teachPlayer(EntityPlayer entityPlayer, ItemStack itemStack) { - init(); - - if (ee3Mod != null) { - EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().teachPlayer(entityPlayer, itemStack); - } + PlayerKnowledgeRegistryProxy.teachPlayer(entityPlayer, itemStack); } + @Deprecated public static void teachPlayer(UUID playerUUID, ItemStack itemStack) { - init(); - - if (ee3Mod != null) { - EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().teachPlayer(playerUUID, itemStack); - } + // NOOP } + @Deprecated public static void makePlayerForget(EntityPlayer entityPlayer, ItemStack itemStack) { - init(); - - if (ee3Mod != null) { - EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().makePlayerForget(entityPlayer, itemStack); - } + PlayerKnowledgeRegistryProxy.makePlayerForget(entityPlayer, itemStack); } + @Deprecated public static void makePlayerForget(UUID playerUUID, ItemStack itemStack) { - init(); - - if (ee3Mod != null) { - EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().makePlayerForget(playerUUID, itemStack); - } + // NOOP } + @Deprecated public static void makePlayerForgetEverything(EntityPlayer entityPlayer) { - init(); - - if (ee3Mod != null) { - EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().makePlayerForgetEverything(entityPlayer); - } + PlayerKnowledgeRegistryProxy.makePlayerForgetAll(entityPlayer); } + @Deprecated public static void makePlayerForgetEverything(UUID playerUUID) { - init(); - - if (ee3Mod != null) { - EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().makePlayerForgetEverything(playerUUID); - } + // NOOP } + @Deprecated public static boolean doesTemplateKnow(ItemStack itemStack) { - init(); - - if (ee3Mod != null) { - return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().doesTemplateKnow(itemStack); - } - return false; } + @Deprecated public static Set getTemplateKnownTransmutations() { - init(); - - if (ee3Mod != null) { - return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().getTemplatesKnownTransmutations(); - } - - return null; + return Collections.EMPTY_SET; } + @Deprecated public static Set getTemplateKnownTransmutationsFilteredStartsWith(String filterString) { - init(); - - if (ee3Mod != null) { - return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry() - .getTemplatesKnownTransmutationsFilteredStartsWith(filterString); - } - - return null; + return Collections.EMPTY_SET; } + @Deprecated public static Set getTemplateKnownTransmutationsFilteredContains(String filterString) { - init(); - - if (ee3Mod != null) { - return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry() - .getTemplatesKnownTransmutationsFilteredContains(filterString); - } - - return null; + return Collections.EMPTY_SET; } + @Deprecated public static void teachTemplate(ItemStack itemStack) { - init(); - - if (ee3Mod != null) { - EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().teachTemplate(itemStack); - } + // NOOP } + @Deprecated public static void makeTemplateForget(ItemStack itemStack) { - init(); - - if (ee3Mod != null) { - EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().makeTemplateForget(itemStack); - } + // NOOP } + @Deprecated public static void makeTemplateForgetEverything() { - init(); - - if (ee3Mod != null) { - EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().makeTemplateForgetEverything(); - } - } - - @Mod.Instance("EE3") - private static Object ee3Mod; - - private static class EE3Wrapper { - - private static EquivalentExchange3 ee3mod; - } - - private static void init() { - if (ee3Mod != null) { - EE3Wrapper.ee3mod = (EquivalentExchange3) ee3Mod; - } + // NOOP } } diff --git a/src/main/java/com/pahimar/ee3/array/AlchemyArrayAccelerant.java b/src/main/java/com/pahimar/ee3/array/AlchemyArrayAccelerant.java deleted file mode 100644 index 23908295..00000000 --- a/src/main/java/com/pahimar/ee3/array/AlchemyArrayAccelerant.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.pahimar.ee3.array; - -import com.pahimar.ee3.reference.Names; -import com.pahimar.ee3.reference.Textures; - -public class AlchemyArrayAccelerant extends AlchemyArrayEE { - - public AlchemyArrayAccelerant() { - super(Textures.AlchemyArray.ACCELERANT_ALCHEMY_ARRAY, Names.AlchemyArrays.ACCELERANT_ALCHEMY_ARRAY); - } -} diff --git a/src/main/java/com/pahimar/ee3/array/AlchemyArrayCombustion.java b/src/main/java/com/pahimar/ee3/array/AlchemyArrayCombustion.java deleted file mode 100644 index 514ed979..00000000 --- a/src/main/java/com/pahimar/ee3/array/AlchemyArrayCombustion.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.pahimar.ee3.array; - -import com.pahimar.ee3.reference.Names; -import com.pahimar.ee3.reference.Textures; - -public class AlchemyArrayCombustion extends AlchemyArrayEE { - - public AlchemyArrayCombustion() { - super(Textures.AlchemyArray.COMBUSTION_ALCHEMY_ARRAY, Names.AlchemyArrays.COMBUSTION_ALCHEMY_ARRAY); - } -} diff --git a/src/main/java/com/pahimar/ee3/array/AlchemyArrayConstruction.java b/src/main/java/com/pahimar/ee3/array/AlchemyArrayConstruction.java deleted file mode 100644 index 2198be98..00000000 --- a/src/main/java/com/pahimar/ee3/array/AlchemyArrayConstruction.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.pahimar.ee3.array; - -import com.pahimar.ee3.reference.Names; -import com.pahimar.ee3.reference.Textures; - -public class AlchemyArrayConstruction extends AlchemyArrayEE { - - public AlchemyArrayConstruction() { - super(Textures.AlchemyArray.CONSTRUCTION_ALCHEMY_ARRAY, Names.AlchemyArrays.CONSTRUCTION_ALCHEMY_ARRAY); - } -} diff --git a/src/main/java/com/pahimar/ee3/array/AlchemyArrayConveyor.java b/src/main/java/com/pahimar/ee3/array/AlchemyArrayConveyor.java deleted file mode 100644 index f0de89a1..00000000 --- a/src/main/java/com/pahimar/ee3/array/AlchemyArrayConveyor.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.pahimar.ee3.array; - -import com.pahimar.ee3.reference.Names; -import com.pahimar.ee3.reference.Textures; - -public class AlchemyArrayConveyor extends AlchemyArrayEE { - - public AlchemyArrayConveyor() { - super(Textures.AlchemyArray.CONVEYOR_ALCHEMY_ARRAY, Names.AlchemyArrays.CONVEYOR_ALCHEMY_ARRAY); - } -} diff --git a/src/main/java/com/pahimar/ee3/array/AlchemyArrayDestruction.java b/src/main/java/com/pahimar/ee3/array/AlchemyArrayDestruction.java deleted file mode 100644 index cf28462e..00000000 --- a/src/main/java/com/pahimar/ee3/array/AlchemyArrayDestruction.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.pahimar.ee3.array; - -import com.pahimar.ee3.reference.Names; -import com.pahimar.ee3.reference.Textures; - -public class AlchemyArrayDestruction extends AlchemyArrayEE { - - public AlchemyArrayDestruction() { - super(Textures.AlchemyArray.DESTRUCTION_ALCHEMY_ARRAY, Names.AlchemyArrays.DESTRUCTION_ALCHEMY_ARRAY); - } -} diff --git a/src/main/java/com/pahimar/ee3/array/AlchemyArrayGelid.java b/src/main/java/com/pahimar/ee3/array/AlchemyArrayGelid.java deleted file mode 100644 index 05469b86..00000000 --- a/src/main/java/com/pahimar/ee3/array/AlchemyArrayGelid.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.pahimar.ee3.array; - -import com.pahimar.ee3.reference.Names; -import com.pahimar.ee3.reference.Textures; - -public class AlchemyArrayGelid extends AlchemyArrayEE { - - public AlchemyArrayGelid() { - super(Textures.AlchemyArray.GELID_ALCHEMY_ARRAY, Names.AlchemyArrays.GELID_ALCHEMY_ARRAY); - } -} diff --git a/src/main/java/com/pahimar/ee3/array/AlchemyArrayParthenogenesis.java b/src/main/java/com/pahimar/ee3/array/AlchemyArrayParthenogenesis.java deleted file mode 100644 index de5c522b..00000000 --- a/src/main/java/com/pahimar/ee3/array/AlchemyArrayParthenogenesis.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.pahimar.ee3.array; - -import com.pahimar.ee3.reference.Names; -import com.pahimar.ee3.reference.Textures; - -public class AlchemyArrayParthenogenesis extends AlchemyArrayEE { - - public AlchemyArrayParthenogenesis() { - super(Textures.AlchemyArray.PARTHENOGENESIS_ALCHEMY_ARRAY, Names.AlchemyArrays.PARTHENOGENESIS_ALCHEMY_ARRAY); - } -} diff --git a/src/main/java/com/pahimar/ee3/array/AlchemyArrayTransfiguration.java b/src/main/java/com/pahimar/ee3/array/AlchemyArrayTransfiguration.java deleted file mode 100644 index a438bacd..00000000 --- a/src/main/java/com/pahimar/ee3/array/AlchemyArrayTransfiguration.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.pahimar.ee3.array; - -import com.pahimar.ee3.reference.Names; -import com.pahimar.ee3.reference.Textures; - -public class AlchemyArrayTransfiguration extends AlchemyArrayEE { - - public AlchemyArrayTransfiguration() { - super(Textures.AlchemyArray.TRANSFIGURATION_ALCHEMY_ARRAY, Names.AlchemyArrays.TRANSFIGURATION_ALCHEMY_ARRAY); - } -} diff --git a/src/main/java/com/pahimar/ee3/block/BlockAludel.java b/src/main/java/com/pahimar/ee3/block/BlockAludel.java index 629516cc..c08cb147 100644 --- a/src/main/java/com/pahimar/ee3/block/BlockAludel.java +++ b/src/main/java/com/pahimar/ee3/block/BlockAludel.java @@ -97,6 +97,8 @@ public void randomDisplayTick(World world, int x, int y, int z, Random random) { 0.0D, 0.0D); break; + default: + break; } world.spawnParticle( diff --git a/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiAlchemicalBag.java b/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiAlchemicalBag.java index 461b1649..ec992bc0 100644 --- a/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiAlchemicalBag.java +++ b/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiAlchemicalBag.java @@ -81,7 +81,7 @@ public void onGuiClosed() { if (mc.thePlayer != null) { for (ItemStack itemStack : mc.thePlayer.inventory.mainInventory) { if (itemStack != null) { - if (NBTHelper.hasTag(itemStack, Names.NBT.ALCHEMICAL_BAG_GUI_OPEN)) { + if (NBTHelper.hasKey(itemStack, Names.NBT.ALCHEMICAL_BAG_GUI_OPEN)) { NBTHelper.removeTag(itemStack, Names.NBT.ALCHEMICAL_BAG_GUI_OPEN); } } diff --git a/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiTransmutationTablet.java b/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiTransmutationTablet.java index 4dda544a..5c524ff7 100644 --- a/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiTransmutationTablet.java +++ b/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiTransmutationTablet.java @@ -1,7 +1,5 @@ package com.pahimar.ee3.client.gui.inventory; -import java.text.DecimalFormat; - import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.StatCollector; @@ -27,7 +25,7 @@ @SideOnly(Side.CLIENT) public class GuiTransmutationTablet extends GuiBase { - private TileEntityTransmutationTablet tileEntityTransmutationTablet; + private ContainerTransmutationTablet containerTablet; private ElementTextField searchTextField; private ElementStatefulButton sortOptionButton; @@ -35,8 +33,6 @@ public class GuiTransmutationTablet extends GuiBase { private ElementSlider slider; protected int tickCount; - private static DecimalFormat energyValueDecimalFormat = new DecimalFormat("###,###,###,###,###.###"); - private static final int LEFT_MOUSE_BUTTON = 0; private static final int RIGHT_MOUSE_BUTTON = 1; @@ -52,7 +48,7 @@ public GuiTransmutationTablet(InventoryPlayer inventoryPlayer, super( new ContainerTransmutationTablet(inventoryPlayer, tileEntityTransmutationTablet), Textures.Gui.TRANSMUTATION_TABLET); - this.tileEntityTransmutationTablet = tileEntityTransmutationTablet; + this.containerTablet = (ContainerTransmutationTablet) this.inventorySlots; xSize = 256; ySize = 256; } @@ -177,10 +173,7 @@ protected void drawGuiContainerForegroundLayer(int x, int y) { 142, Integer.parseInt(Colors.PURE_WHITE, 16)); fontRendererObj.drawString( - String.format( - "%s", - energyValueDecimalFormat - .format(tileEntityTransmutationTablet.getAvailableEnergyValue().getValue())), + String.format("%s", containerTablet.getEnergyValue()), 10, 152, Integer.parseInt(Colors.PURE_WHITE, 16)); diff --git a/src/main/java/com/pahimar/ee3/client/handler/ItemTooltipEventHandler.java b/src/main/java/com/pahimar/ee3/client/handler/ItemTooltipEventHandler.java index 8b31bb1e..1edf587c 100644 --- a/src/main/java/com/pahimar/ee3/client/handler/ItemTooltipEventHandler.java +++ b/src/main/java/com/pahimar/ee3/client/handler/ItemTooltipEventHandler.java @@ -1,6 +1,5 @@ package com.pahimar.ee3.client.handler; -import java.text.DecimalFormat; import java.util.UUID; import net.minecraft.util.StatCollector; @@ -11,77 +10,66 @@ import org.lwjgl.input.Keyboard; +import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; import com.pahimar.ee3.api.exchange.EnergyValue; import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy; -import com.pahimar.ee3.api.knowledge.TransmutationKnowledgeRegistryProxy; +import com.pahimar.ee3.api.knowledge.PlayerKnowledgeRegistryProxy; import com.pahimar.ee3.exchange.WrappedStack; import com.pahimar.ee3.inventory.ContainerAlchenomicon; import com.pahimar.ee3.inventory.ContainerResearchStation; import com.pahimar.ee3.inventory.ContainerTransmutationTablet; import com.pahimar.ee3.reference.Messages; import com.pahimar.ee3.util.IOwnable; -import com.pahimar.ee3.util.ItemHelper; +import com.pahimar.ee3.util.ItemStackUtils; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -/** - * Equivalent-Exchange-3 - *

- * ItemTooltipEventHandler - * - * @author pahimar - */ @SideOnly(Side.CLIENT) public class ItemTooltipEventHandler { - private static DecimalFormat energyValueDecimalFormat = new DecimalFormat("###,###,###,###,###.###"); - @SubscribeEvent public void handleItemTooltipEvent(ItemTooltipEvent event) { + if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || (event.entityPlayer != null && (event.entityPlayer.openContainer instanceof ContainerAlchenomicon || event.entityPlayer.openContainer instanceof ContainerTransmutationTablet))) { + WrappedStack wrappedItemStack = WrappedStack.wrap(event.itemStack); EnergyValue energyValue = EnergyValueRegistryProxy.getEnergyValue(wrappedItemStack); + EnergyValue stackEnergyValue = EnergyValueRegistryProxy.getEnergyValueForStack(wrappedItemStack); + + if (energyValue != null && (BlacklistRegistryProxy.isExchangeable(wrappedItemStack) + || BlacklistRegistryProxy.isLearnable(wrappedItemStack))) { - if (energyValue != null) { if (wrappedItemStack.getStackSize() > 1) { - event.toolTip.add( - String.format( - "Exchange Energy (Item): %s", - energyValueDecimalFormat.format(energyValue.getValue()))); // TODO Localize + event.toolTip.add(String.format("Exchange Energy (Item): %s", energyValue)); // TODO Localize event.toolTip.add( String.format( "Exchange Energy (Stack of %s): %s", event.itemStack.stackSize, - energyValueDecimalFormat - .format(wrappedItemStack.getStackSize() * energyValue.getValue()))); // TODO - // Localize + stackEnergyValue)); // TODO Localize } else { - event.toolTip.add( - String.format( - "Exchange Energy: %s", - energyValueDecimalFormat - .format(wrappedItemStack.getStackSize() * energyValue.getValue()))); // TODO - // Localize + + event.toolTip.add(String.format("Exchange Energy: %s", stackEnergyValue)); // TODO Localize + if (FluidContainerRegistry.getFluidForFilledItem(event.itemStack) != null) { + FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(event.itemStack); + EnergyValue fluidStackEnergyValue = EnergyValueRegistryProxy.getEnergyValueForStack(fluidStack); - if (EnergyValueRegistryProxy.getEnergyValueForStack(fluidStack) != null) { - EnergyValue fluidStackEnergyValue = EnergyValueRegistryProxy - .getEnergyValueForStack(fluidStack); + if (fluidStackEnergyValue != null) { event.toolTip.add( String.format( - " - Exchange Energy (%s): %s", + " - Exchange Energy (%smB of %s): %s", + fluidStack.amount, fluidStack.getLocalizedName(), - energyValueDecimalFormat.format(fluidStackEnergyValue.getValue()))); // TODO - // Localize + fluidStackEnergyValue)); // TODO Localize event.toolTip.add( String.format( " - Exchange Energy (Container): %s", - energyValueDecimalFormat.format( + new EnergyValue( energyValue.getValue() - fluidStackEnergyValue.getValue()))); // TODO // Localize } @@ -95,27 +83,26 @@ public void handleItemTooltipEvent(ItemTooltipEvent event) { if (((Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) && (event.entityPlayer != null && event.entityPlayer.openContainer instanceof ContainerResearchStation))) { - if (TransmutationKnowledgeRegistryProxy.doesPlayerKnow(event.entityPlayer, event.itemStack)) { + + if (PlayerKnowledgeRegistryProxy.doesPlayerKnow(event.entityPlayer, event.itemStack)) { event.toolTip.add("You know how to transmute this"); // TODO Localize with better phrasing } } if (event.itemStack.getItem() instanceof IOwnable) { - UUID playerUUID = ItemHelper.getOwnerUUID(event.itemStack); + + UUID playerUUID = ItemStackUtils.getOwnerUUID(event.itemStack); + if (playerUUID != null && UsernameCache.containsUUID(playerUUID)) { event.toolTip.add( StatCollector.translateToLocalFormatted( Messages.Tooltips.ITEM_BELONGS_TO, UsernameCache.getLastKnownUsername(playerUUID))); - } else if (ItemHelper.hasOwnerName(event.itemStack)) { + } else if (ItemStackUtils.getOwnerName(event.itemStack) != null) { event.toolTip.add( StatCollector.translateToLocalFormatted( Messages.Tooltips.ITEM_BELONGS_TO, - ItemHelper.getOwnerName(event.itemStack))); - } else { - if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { - event.toolTip.add(StatCollector.translateToLocal(Messages.Tooltips.ITEM_BELONGS_TO_NO_ONE)); - } + ItemStackUtils.getOwnerName(event.itemStack))); } } } diff --git a/src/main/java/com/pahimar/ee3/client/util/RenderUtils.java b/src/main/java/com/pahimar/ee3/client/util/RenderUtils.java index 47c5243b..cc3657d4 100644 --- a/src/main/java/com/pahimar/ee3/client/util/RenderUtils.java +++ b/src/main/java/com/pahimar/ee3/client/util/RenderUtils.java @@ -14,8 +14,17 @@ public class RenderUtils { + public static void bindTexture(ResourceLocation texture) { + FMLClientHandler.instance().getClient().getTextureManager().bindTexture(texture); + } + + public static int getCenteredTextOffset(FontRenderer fontRenderer, String string, int width) { + return (width - fontRenderer.getStringWidth(string)) / 2; + } + public static void renderItemIntoGUI(FontRenderer fontRenderer, ItemStack itemStack, int x, int y, float opacity, float scale, int zLevel) { + IIcon icon = itemStack.getIconIndex(); GL11.glDisable(GL11.GL_LIGHTING); FMLClientHandler.instance().getClient().renderEngine.bindTexture(TextureMap.locationItemsTexture); @@ -35,6 +44,7 @@ public static void renderItemIntoGUI(FontRenderer fontRenderer, ItemStack itemSt } public static void renderQuad(ResourceLocation texture) { + FMLClientHandler.instance().getClient().renderEngine.bindTexture(texture); Tessellator tessellator = Tessellator.instance; GL11.glEnable(GL12.GL_RESCALE_NORMAL); @@ -52,7 +62,8 @@ public static void renderQuad(ResourceLocation texture) { } public static void renderPulsingQuad(ResourceLocation texture, float maxTransparency) { - float pulseTransparency = getPulseValue() * maxTransparency / 3000f; + + float pulseTransparency = (float) getPulseValue() * maxTransparency; FMLClientHandler.instance().getClient().renderEngine.bindTexture(texture); Tessellator tessellator = Tessellator.instance; GL11.glEnable(GL12.GL_RESCALE_NORMAL); @@ -70,21 +81,7 @@ public static void renderPulsingQuad(ResourceLocation texture, float maxTranspar GL11.glDisable(GL12.GL_RESCALE_NORMAL); } - private static int getPulseValue() { - if (doInc) { - pulse += 50; - } else { - pulse -= 50; - } - if (pulse == 3000) { - doInc = false; - } - if (pulse == 0) { - doInc = true; - } - return pulse; + private static double getPulseValue() { + return (Math.sin(System.nanoTime() / 100f) + 1) / 2; } - - private static int pulse = 0; - private static boolean doInc = true; } diff --git a/src/main/java/com/pahimar/ee3/command/CommandAdmin.java b/src/main/java/com/pahimar/ee3/command/CommandAdmin.java deleted file mode 100644 index 53e8a02a..00000000 --- a/src/main/java/com/pahimar/ee3/command/CommandAdmin.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.pahimar.ee3.command; - -import net.minecraft.command.ICommandSender; -import net.minecraft.entity.player.EntityPlayer; - -import com.pahimar.ee3.EquivalentExchange3; -import com.pahimar.ee3.reference.GUIs; -import com.pahimar.ee3.reference.Messages; -import com.pahimar.ee3.reference.Names; - -public class CommandAdmin extends CommandEE { - - @Override - public String getCommandName() { - return Names.Commands.ADMIN_PANEL; - } - - @Override - public int getRequiredPermissionLevel() { - return 2; - } - - @Override - public String getCommandUsage(ICommandSender commandSender) { - return Messages.Commands.ADMIN_USAGE; - } - - @Override - public void processCommand(ICommandSender commandSender, String[] args) { - EntityPlayer entityPlayer = (EntityPlayer) commandSender; - - entityPlayer.openGui( - EquivalentExchange3.instance, - GUIs.ADMIN_PANEL.ordinal(), - entityPlayer.worldObj, - (int) entityPlayer.posX, - (int) entityPlayer.posY, - (int) entityPlayer.posZ); - } -} diff --git a/src/main/java/com/pahimar/ee3/command/CommandDebug.java b/src/main/java/com/pahimar/ee3/command/CommandDebug.java deleted file mode 100644 index ba4a1aef..00000000 --- a/src/main/java/com/pahimar/ee3/command/CommandDebug.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.pahimar.ee3.command; - -import java.util.List; - -import net.minecraft.command.CommandBase; -import net.minecraft.command.ICommandSender; - -import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy; -import com.pahimar.ee3.reference.Names; - -public class CommandDebug extends CommandBase { - - @Override - public String getCommandName() { - return Names.Commands.DEBUG; - } - - @Override - public int getRequiredPermissionLevel() { - return 2; - } - - @Override - public String getCommandUsage(ICommandSender commandSender) { - return null; - } - - @Override - public void processCommand(ICommandSender commandSender, String[] args) { - EnergyValueRegistryProxy.dumpEnergyValueRegistryToLog(EnergyValueRegistryProxy.Phase.PRE_CALCULATION); - } - - @Override - public List addTabCompletionOptions(ICommandSender commandSender, String[] args) { - return null; - } -} diff --git a/src/main/java/com/pahimar/ee3/command/CommandEE.java b/src/main/java/com/pahimar/ee3/command/CommandEE.java index dfe33ece..f7fabda2 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandEE.java +++ b/src/main/java/com/pahimar/ee3/command/CommandEE.java @@ -5,14 +5,16 @@ import net.minecraft.command.CommandBase; import net.minecraft.command.ICommandSender; +import net.minecraft.command.WrongUsageException; +import com.google.common.base.Joiner; import com.pahimar.ee3.reference.Messages; import com.pahimar.ee3.reference.Names; public class CommandEE extends CommandBase { - private static List modCommands = new ArrayList(); - private static List commands = new ArrayList(); + private static List modCommands = new ArrayList<>(); + private static List commands = new ArrayList<>(); @Override public String getCommandName() { @@ -26,18 +28,29 @@ public String getCommandUsage(ICommandSender commandSender) { @Override public void processCommand(ICommandSender commandSender, String[] args) { + + boolean found = false; + if (args.length >= 1) { + for (CommandBase command : modCommands) { + if (command.getCommandName().equalsIgnoreCase(args[0]) && command.canCommandSenderUseCommand(commandSender)) { + found = true; command.processCommand(commandSender, args); } } } + + if (!found) { + throw new WrongUsageException("Invalid command. Usage: /ee3 " + Joiner.on(" ").join(commands)); + } } @Override public List addTabCompletionOptions(ICommandSender commandSender, String[] args) { + if (args.length == 1) { return getListOfStringsFromIterableMatchingLastWord(args, commands); } else if (args.length >= 2) { @@ -54,24 +67,22 @@ public List addTabCompletionOptions(ICommandSender commandSender, String[] args) static { modCommands.add(new CommandSetEnergyValue()); modCommands.add(new CommandSetEnergyValueCurrentItem()); - modCommands.add(new CommandSyncEnergyValues()); modCommands.add(new CommandPlayerLearnItem()); modCommands.add(new CommandPlayerLearnCurrentItem()); modCommands.add(new CommandPlayerForgetEverything()); modCommands.add(new CommandPlayerForgetItem()); modCommands.add(new CommandPlayerForgetCurrentItem()); - modCommands.add(new CommandTemplateLearnItem()); - modCommands.add(new CommandTemplateLearnCurrentItem()); - modCommands.add(new CommandTemplateForgetEverything()); - modCommands.add(new CommandTemplateForgetItem()); - modCommands.add(new CommandTemplateForgetCurrentItem()); modCommands.add(new CommandSetItemLearnable()); + modCommands.add(new CommandSetCurrentItemLearnable()); modCommands.add(new CommandSetItemNotLearnable()); + modCommands.add(new CommandSetCurrentItemNotLearnable()); modCommands.add(new CommandSetItemRecoverable()); + modCommands.add(new CommandSetCurrentItemRecoverable()); modCommands.add(new CommandSetItemNotRecoverable()); + modCommands.add(new CommandSetCurrentItemNotRecoverable()); + modCommands.add(new CommandSyncEnergyValues()); + modCommands.add(new CommandRegenEnergyValues()); modCommands.add(new CommandRunTest()); - modCommands.add(new CommandDebug()); - modCommands.add(new CommandAdmin()); for (CommandBase commandBase : modCommands) { commands.add(commandBase.getCommandName()); diff --git a/src/main/java/com/pahimar/ee3/command/CommandPlayerForgetCurrentItem.java b/src/main/java/com/pahimar/ee3/command/CommandPlayerForgetCurrentItem.java index e555d3e9..0fc049bd 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandPlayerForgetCurrentItem.java +++ b/src/main/java/com/pahimar/ee3/command/CommandPlayerForgetCurrentItem.java @@ -8,7 +8,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import com.pahimar.ee3.api.knowledge.TransmutationKnowledgeRegistryProxy; +import com.pahimar.ee3.api.knowledge.PlayerKnowledgeRegistryProxy; import com.pahimar.ee3.reference.Messages; import com.pahimar.ee3.reference.Names; import cpw.mods.fml.common.FMLCommonHandler; @@ -40,7 +40,7 @@ public void processCommand(ICommandSender commandSender, String[] args) { if (entityPlayer != null) { ItemStack itemStack = ((EntityPlayer) commandSender).getCurrentEquippedItem(); if (itemStack != null) { - TransmutationKnowledgeRegistryProxy.makePlayerForget(entityPlayer, itemStack); + PlayerKnowledgeRegistryProxy.makePlayerForget(entityPlayer, itemStack); func_152373_a( commandSender, this, diff --git a/src/main/java/com/pahimar/ee3/command/CommandPlayerForgetEverything.java b/src/main/java/com/pahimar/ee3/command/CommandPlayerForgetEverything.java index c6845f76..2f11d0f4 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandPlayerForgetEverything.java +++ b/src/main/java/com/pahimar/ee3/command/CommandPlayerForgetEverything.java @@ -7,7 +7,7 @@ import net.minecraft.command.WrongUsageException; import net.minecraft.entity.player.EntityPlayer; -import com.pahimar.ee3.api.knowledge.TransmutationKnowledgeRegistryProxy; +import com.pahimar.ee3.api.knowledge.PlayerKnowledgeRegistryProxy; import com.pahimar.ee3.reference.Messages; import com.pahimar.ee3.reference.Names; import cpw.mods.fml.common.FMLCommonHandler; @@ -37,7 +37,7 @@ public void processCommand(ICommandSender commandSender, String[] args) { EntityPlayer entityPlayer = getPlayer(commandSender, args[1]); if (entityPlayer != null) { - TransmutationKnowledgeRegistryProxy.makePlayerForgetEverything(entityPlayer); + PlayerKnowledgeRegistryProxy.makePlayerForgetAll(entityPlayer); func_152373_a( commandSender, this, diff --git a/src/main/java/com/pahimar/ee3/command/CommandPlayerForgetItem.java b/src/main/java/com/pahimar/ee3/command/CommandPlayerForgetItem.java index b6c9fe0c..ac21581d 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandPlayerForgetItem.java +++ b/src/main/java/com/pahimar/ee3/command/CommandPlayerForgetItem.java @@ -12,7 +12,7 @@ import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; -import com.pahimar.ee3.api.knowledge.TransmutationKnowledgeRegistryProxy; +import com.pahimar.ee3.api.knowledge.PlayerKnowledgeRegistryProxy; import com.pahimar.ee3.reference.Messages; import com.pahimar.ee3.reference.Names; import cpw.mods.fml.common.FMLCommonHandler; @@ -77,7 +77,7 @@ public void processCommand(ICommandSender commandSender, String[] args) { } } - TransmutationKnowledgeRegistryProxy.makePlayerForget(entityPlayer, itemStack); + PlayerKnowledgeRegistryProxy.makePlayerForget(entityPlayer, itemStack); func_152373_a( commandSender, this, diff --git a/src/main/java/com/pahimar/ee3/command/CommandPlayerLearnCurrentItem.java b/src/main/java/com/pahimar/ee3/command/CommandPlayerLearnCurrentItem.java index b9e49db7..4eab9979 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandPlayerLearnCurrentItem.java +++ b/src/main/java/com/pahimar/ee3/command/CommandPlayerLearnCurrentItem.java @@ -8,8 +8,8 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import com.pahimar.ee3.api.knowledge.TransmutationKnowledgeRegistryProxy; -import com.pahimar.ee3.knowledge.AbilityRegistry; +import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; +import com.pahimar.ee3.api.knowledge.PlayerKnowledgeRegistryProxy; import com.pahimar.ee3.reference.Messages; import com.pahimar.ee3.reference.Names; import cpw.mods.fml.common.FMLCommonHandler; @@ -42,8 +42,8 @@ public void processCommand(ICommandSender commandSender, String[] args) { ItemStack itemStack = ((EntityPlayer) commandSender).getCurrentEquippedItem(); if (itemStack != null) { - if (AbilityRegistry.getInstance().isLearnable(itemStack)) { - TransmutationKnowledgeRegistryProxy.teachPlayer(entityPlayer, itemStack); + if (BlacklistRegistryProxy.isLearnable(itemStack)) { + PlayerKnowledgeRegistryProxy.teachPlayer(entityPlayer, itemStack); func_152373_a( commandSender, this, diff --git a/src/main/java/com/pahimar/ee3/command/CommandPlayerLearnItem.java b/src/main/java/com/pahimar/ee3/command/CommandPlayerLearnItem.java index 67cf26b7..a043ae31 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandPlayerLearnItem.java +++ b/src/main/java/com/pahimar/ee3/command/CommandPlayerLearnItem.java @@ -12,8 +12,8 @@ import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; -import com.pahimar.ee3.api.knowledge.TransmutationKnowledgeRegistryProxy; -import com.pahimar.ee3.knowledge.AbilityRegistry; +import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; +import com.pahimar.ee3.api.knowledge.PlayerKnowledgeRegistryProxy; import com.pahimar.ee3.reference.Messages; import com.pahimar.ee3.reference.Names; import cpw.mods.fml.common.FMLCommonHandler; @@ -78,8 +78,8 @@ public void processCommand(ICommandSender commandSender, String[] args) { } } - if (AbilityRegistry.getInstance().isLearnable(itemStack)) { - TransmutationKnowledgeRegistryProxy.teachPlayer(entityPlayer, itemStack); + if (BlacklistRegistryProxy.isLearnable(itemStack)) { + PlayerKnowledgeRegistryProxy.teachPlayer(entityPlayer, itemStack); func_152373_a( commandSender, this, diff --git a/src/main/java/com/pahimar/ee3/command/CommandRunTest.java b/src/main/java/com/pahimar/ee3/command/CommandRunTest.java index 7b535765..7f316985 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandRunTest.java +++ b/src/main/java/com/pahimar/ee3/command/CommandRunTest.java @@ -8,10 +8,11 @@ import net.minecraft.command.WrongUsageException; import net.minecraft.util.ChatComponentTranslation; +import com.pahimar.ee3.reference.Files; import com.pahimar.ee3.reference.Messages; import com.pahimar.ee3.reference.Names; import com.pahimar.ee3.reference.Reference; -import com.pahimar.ee3.test.EnergyValueMappingsTestSuite; +import com.pahimar.ee3.test.EnergyValueTestSuite; import com.pahimar.ee3.util.LogHelper; import cpw.mods.fml.common.FMLCommonHandler; @@ -34,36 +35,31 @@ public String getCommandUsage(ICommandSender commandSender) { @Override public void processCommand(ICommandSender commandSender, String[] args) { + if (args.length == 2) { - File testCaseDirectory = new File( - FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getSaveHandler() - .getWorldDirectory(), - "data" + File.separator - + Reference.LOWERCASE_MOD_ID - + File.separator - + "energyvalues" - + File.separator - + "testcases"); - testCaseDirectory.mkdirs(); + boolean testFound = false; - for (File testCaseFile : testCaseDirectory.listFiles()) { - if (testCaseFile.isFile() && testCaseFile.getName().equalsIgnoreCase(args[1])) { - testFound = true; - EnergyValueMappingsTestSuite energyValueMappingsTestSuite = new EnergyValueMappingsTestSuite( - testCaseFile); - LogHelper.info(EnergyValueMappingsTestSuite.TEST_MARKER, "BEGIN TEST ({})", testCaseFile.getName()); - energyValueMappingsTestSuite.runTestSuite(); - LogHelper.info(EnergyValueMappingsTestSuite.TEST_MARKER, "END TEST ({})", testCaseFile.getName()); + if (Files.globalTestDirectory != null) { + for (File testCaseFile : Files.globalTestDirectory.listFiles()) { + if (testCaseFile.isFile() && testCaseFile.getName().equalsIgnoreCase(args[1])) { + testFound = true; + EnergyValueTestSuite energyValueTestSuite = new EnergyValueTestSuite(testCaseFile); + LogHelper.info(EnergyValueTestSuite.TEST_MARKER, "BEGIN TEST ({})", testCaseFile.getName()); + energyValueTestSuite.run(); + LogHelper.info(EnergyValueTestSuite.TEST_MARKER, "END TEST ({})", testCaseFile.getName()); + } } - } - if (testFound) { - commandSender - .addChatMessage(new ChatComponentTranslation(Messages.Commands.RUN_TESTS_SUCCESS, args[1])); + if (testFound) { + commandSender + .addChatMessage(new ChatComponentTranslation(Messages.Commands.RUN_TESTS_SUCCESS, args[1])); + } else { + commandSender.addChatMessage( + new ChatComponentTranslation(Messages.Commands.RUN_TESTS_NOT_FOUND, args[1])); + } } else { - commandSender - .addChatMessage(new ChatComponentTranslation(Messages.Commands.RUN_TESTS_NOT_FOUND, args[1])); + throw new WrongUsageException(Messages.Commands.RUN_TEST_USAGE); } } else { throw new WrongUsageException(Messages.Commands.RUN_TEST_USAGE); @@ -72,7 +68,9 @@ public void processCommand(ICommandSender commandSender, String[] args) { @Override public List addTabCompletionOptions(ICommandSender commandSender, String[] args) { + if (args.length == 2) { + File testCaseDirectory = new File( FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getSaveHandler() .getWorldDirectory(), @@ -84,11 +82,13 @@ public List addTabCompletionOptions(ICommandSender commandSender, String[] args) + "testcases"); testCaseDirectory.mkdirs(); - ArrayList fileNames = new ArrayList(); + ArrayList fileNames = new ArrayList<>(); - for (File testCaseFile : testCaseDirectory.listFiles()) { - if (testCaseFile.isFile() && testCaseFile.getAbsolutePath().endsWith(".json")) { - fileNames.add(testCaseFile.getName()); + if (Files.globalTestDirectory != null) { + for (File testCaseFile : Files.globalTestDirectory.listFiles()) { + if (testCaseFile.isFile() && testCaseFile.getAbsolutePath().endsWith(".json")) { + fileNames.add(testCaseFile.getName()); + } } } diff --git a/src/main/java/com/pahimar/ee3/command/CommandSetEnergyValue.java b/src/main/java/com/pahimar/ee3/command/CommandSetEnergyValue.java index 1ee0117b..d5ade189 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandSetEnergyValue.java +++ b/src/main/java/com/pahimar/ee3/command/CommandSetEnergyValue.java @@ -1,7 +1,6 @@ package com.pahimar.ee3.command; import java.util.List; -import java.util.Map; import net.minecraft.command.CommandBase; import net.minecraft.command.ICommandSender; @@ -12,15 +11,16 @@ import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; +import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; import com.pahimar.ee3.api.exchange.EnergyValue; +import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy; import com.pahimar.ee3.exchange.EnergyValueRegistry; import com.pahimar.ee3.exchange.WrappedStack; import com.pahimar.ee3.network.PacketHandler; +import com.pahimar.ee3.network.message.MessageSetBlacklistEntry; import com.pahimar.ee3.network.message.MessageSetEnergyValue; -import com.pahimar.ee3.reference.Files; import com.pahimar.ee3.reference.Messages; import com.pahimar.ee3.reference.Names; -import com.pahimar.ee3.util.SerializationHelper; public class CommandSetEnergyValue extends CommandBase { @@ -85,59 +85,44 @@ public void processCommand(ICommandSender commandSender, String[] args) { WrappedStack wrappedStack = WrappedStack.wrap(itemStack); EnergyValue newEnergyValue = new EnergyValue(energyValue); - if (wrappedStack != null && newEnergyValue != null && Float.compare(newEnergyValue.getValue(), 0) > 0) { - if (args[1].equalsIgnoreCase("pre")) { - EnergyValueRegistry.getInstance().setEnergyValue(wrappedStack, newEnergyValue); - - Map preAssignedValues = SerializationHelper - .readEnergyValueStackMapFromJsonFile(Files.PRE_CALCULATION_ENERGY_VALUES); - preAssignedValues.put(wrappedStack, newEnergyValue); - SerializationHelper - .writeEnergyValueStackMapToJsonFile(Files.PRE_CALCULATION_ENERGY_VALUES, preAssignedValues); - EnergyValueRegistry.getInstance().setShouldRegenNextRestart(true); - } else if (args[1].equalsIgnoreCase("global-pre")) { - EnergyValueRegistry.getInstance().setEnergyValue(wrappedStack, newEnergyValue); - - Map preAssignedValues = SerializationHelper - .readEnergyValueStackMapFromJsonFile(Files.Global.preCalcluationEnergyValueFile); - preAssignedValues.put(wrappedStack, newEnergyValue); - SerializationHelper.writeEnergyValueStackMapToJsonFile( - Files.Global.preCalcluationEnergyValueFile, - preAssignedValues); - EnergyValueRegistry.getInstance().setShouldRegenNextRestart(true); - } else if (args[1].equalsIgnoreCase("post")) { - EnergyValueRegistry.getInstance().setEnergyValue(wrappedStack, newEnergyValue); - - Map postAssignedValues = SerializationHelper - .readEnergyValueStackMapFromJsonFile(Files.POST_CALCULATION_ENERGY_VALUES); - postAssignedValues.put(wrappedStack, newEnergyValue); - SerializationHelper.writeEnergyValueStackMapToJsonFile( - Files.POST_CALCULATION_ENERGY_VALUES, - postAssignedValues); - - PacketHandler.INSTANCE.sendToAll(new MessageSetEnergyValue(wrappedStack, newEnergyValue)); - } else if (args[1].equalsIgnoreCase("global-post")) { - EnergyValueRegistry.getInstance().setEnergyValue(wrappedStack, newEnergyValue); - - Map postAssignedValues = SerializationHelper - .readEnergyValueStackMapFromJsonFile(Files.Global.postCalcluationEnergyValueFile); - postAssignedValues.put(wrappedStack, newEnergyValue); - SerializationHelper.writeEnergyValueStackMapToJsonFile( - Files.Global.postCalcluationEnergyValueFile, - postAssignedValues); - - PacketHandler.INSTANCE.sendToAll(new MessageSetEnergyValue(wrappedStack, newEnergyValue)); - } else { - throw new WrongUsageException(Messages.Commands.SET_ENERGY_VALUE_USAGE); - } + if (wrappedStack != null && newEnergyValue != null) { + if (Float.compare(newEnergyValue.getValue(), 0) > 0) { + + if (args[1].equalsIgnoreCase("pre")) { + EnergyValueRegistryProxy.setEnergyValue( + wrappedStack, + newEnergyValue, + EnergyValueRegistryProxy.Phase.PRE_CALCULATION); + } else if (args[1].equalsIgnoreCase("post")) { + EnergyValueRegistryProxy.setEnergyValue(wrappedStack, newEnergyValue); + PacketHandler.INSTANCE.sendToAll(new MessageSetEnergyValue(wrappedStack, newEnergyValue)); + } else { + throw new WrongUsageException(Messages.Commands.SET_ENERGY_VALUE_USAGE); + } - // Notify admins and log the value change - func_152373_a( - commandSender, - this, - Messages.Commands.SET_ENERGY_VALUE_SUCCESS, - new Object[] { commandSender.getCommandSenderName(), args[1], itemStack.func_151000_E(), - newEnergyValue.getChatComponent() }); + EnergyValueRegistry.INSTANCE.save(); + // Notify admins and log the value change + func_152373_a( + commandSender, + this, + Messages.Commands.SET_ENERGY_VALUE_SUCCESS, + new Object[] { commandSender.getCommandSenderName(), args[1], itemStack.func_151000_E(), + newEnergyValue.getChatComponent() }); + } else if (Float.compare(newEnergyValue.getValue(), 0) == 0) { + + BlacklistRegistryProxy.setAsNotLearnable(wrappedStack); + BlacklistRegistryProxy.setAsNotExchangeable(wrappedStack); + // TODO Remove energy value from EnergyValueRegistry + PacketHandler.INSTANCE.sendToAll( + new MessageSetBlacklistEntry(itemStack, BlacklistRegistryProxy.Blacklist.KNOWLEDGE)); + PacketHandler.INSTANCE.sendToAll( + new MessageSetBlacklistEntry(itemStack, BlacklistRegistryProxy.Blacklist.EXCHANGE)); + func_152373_a( + commandSender, + this, + "%s set %s as not learnable and not exchangeable", + new Object[] { commandSender.getCommandSenderName(), itemStack.func_151000_E() }); + } } else { throw new WrongUsageException(Messages.Commands.SET_ENERGY_VALUE_USAGE); } @@ -147,7 +132,7 @@ public void processCommand(ICommandSender commandSender, String[] args) { @Override public List addTabCompletionOptions(ICommandSender commandSender, String[] args) { if (args.length == 2) { - return getListOfStringsMatchingLastWord(args, "pre", "global-pre", "post", "global-post"); + return getListOfStringsMatchingLastWord(args, "pre", "post"); } else if (args.length == 3) { return getListOfStringsFromIterableMatchingLastWord(args, Item.itemRegistry.getKeys()); } diff --git a/src/main/java/com/pahimar/ee3/command/CommandSetEnergyValueCurrentItem.java b/src/main/java/com/pahimar/ee3/command/CommandSetEnergyValueCurrentItem.java index baa477c9..0580d489 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandSetEnergyValueCurrentItem.java +++ b/src/main/java/com/pahimar/ee3/command/CommandSetEnergyValueCurrentItem.java @@ -1,7 +1,6 @@ package com.pahimar.ee3.command; import java.util.List; -import java.util.Map; import net.minecraft.command.CommandBase; import net.minecraft.command.ICommandSender; @@ -9,15 +8,16 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; import com.pahimar.ee3.api.exchange.EnergyValue; +import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy; import com.pahimar.ee3.exchange.EnergyValueRegistry; import com.pahimar.ee3.exchange.WrappedStack; import com.pahimar.ee3.network.PacketHandler; +import com.pahimar.ee3.network.message.MessageSetBlacklistEntry; import com.pahimar.ee3.network.message.MessageSetEnergyValue; -import com.pahimar.ee3.reference.Files; import com.pahimar.ee3.reference.Messages; import com.pahimar.ee3.reference.Names; -import com.pahimar.ee3.util.SerializationHelper; public class CommandSetEnergyValueCurrentItem extends CommandBase { @@ -53,63 +53,49 @@ public void processCommand(ICommandSender commandSender, String[] args) { WrappedStack wrappedStack = WrappedStack.wrap(itemStack); EnergyValue newEnergyValue = new EnergyValue(energyValue); - if (wrappedStack != null && newEnergyValue != null && Float.compare(newEnergyValue.getValue(), 0) > 0) { - if (args[1].equalsIgnoreCase("pre")) { - EnergyValueRegistry.getInstance().setEnergyValue(wrappedStack, newEnergyValue); - - Map preAssignedValues = SerializationHelper - .readEnergyValueStackMapFromJsonFile(Files.PRE_CALCULATION_ENERGY_VALUES); - preAssignedValues.put(wrappedStack, newEnergyValue); - SerializationHelper.writeEnergyValueStackMapToJsonFile( - Files.PRE_CALCULATION_ENERGY_VALUES, - preAssignedValues); - EnergyValueRegistry.getInstance().setShouldRegenNextRestart(true); - } else if (args[1].equalsIgnoreCase("global-pre")) { - EnergyValueRegistry.getInstance().setEnergyValue(wrappedStack, newEnergyValue); - - Map preAssignedValues = SerializationHelper - .readEnergyValueStackMapFromJsonFile(Files.Global.preCalcluationEnergyValueFile); - preAssignedValues.put(wrappedStack, newEnergyValue); - SerializationHelper.writeEnergyValueStackMapToJsonFile( - Files.Global.preCalcluationEnergyValueFile, - preAssignedValues); - EnergyValueRegistry.getInstance().setShouldRegenNextRestart(true); - } else if (args[1].equalsIgnoreCase("post")) { - EnergyValueRegistry.getInstance().setEnergyValue(wrappedStack, newEnergyValue); - - Map postAssignedValues = SerializationHelper - .readEnergyValueStackMapFromJsonFile(Files.POST_CALCULATION_ENERGY_VALUES); - postAssignedValues.put(wrappedStack, newEnergyValue); - SerializationHelper.writeEnergyValueStackMapToJsonFile( - Files.POST_CALCULATION_ENERGY_VALUES, - postAssignedValues); - - PacketHandler.INSTANCE.sendToAll(new MessageSetEnergyValue(wrappedStack, newEnergyValue)); - } else if (args[1].equalsIgnoreCase("global-post")) { - EnergyValueRegistry.getInstance().setEnergyValue(wrappedStack, newEnergyValue); - - Map postAssignedValues = SerializationHelper - .readEnergyValueStackMapFromJsonFile(Files.Global.postCalcluationEnergyValueFile); - postAssignedValues.put(wrappedStack, newEnergyValue); - SerializationHelper.writeEnergyValueStackMapToJsonFile( - Files.Global.postCalcluationEnergyValueFile, - postAssignedValues); - - PacketHandler.INSTANCE.sendToAll(new MessageSetEnergyValue(wrappedStack, newEnergyValue)); - } else { - throw new WrongUsageException(Messages.Commands.SET_ENERGY_VALUE_CURRENT_ITEM_USAGE); + if (wrappedStack != null && newEnergyValue != null) { + if (Float.compare(newEnergyValue.getValue(), 0) > 0) { + + if (args[1].equalsIgnoreCase("pre")) { + EnergyValueRegistryProxy.setEnergyValue( + wrappedStack, + newEnergyValue, + EnergyValueRegistryProxy.Phase.PRE_CALCULATION); + } else if (args[1].equalsIgnoreCase("post")) { + EnergyValueRegistryProxy.setEnergyValue(wrappedStack, newEnergyValue); + PacketHandler.INSTANCE.sendToAll(new MessageSetEnergyValue(wrappedStack, newEnergyValue)); + } else { + throw new WrongUsageException(Messages.Commands.SET_ENERGY_VALUE_CURRENT_ITEM_USAGE); + } + + // Notify admins and log the value change + func_152373_a( + commandSender, + this, + Messages.Commands.SET_ENERGY_VALUE_CURRENT_ITEM_SUCCESS, + new Object[] { commandSender.getCommandSenderName(), args[1], itemStack.func_151000_E(), + newEnergyValue.getChatComponent() }); + } else if (Float.compare(newEnergyValue.getValue(), 0) == 0) { + + BlacklistRegistryProxy.setAsNotLearnable(wrappedStack); + BlacklistRegistryProxy.setAsNotExchangeable(wrappedStack); + // TODO Remove energy value from EnergyValueRegistry + // TODO Sync change with client + PacketHandler.INSTANCE.sendToAll( + new MessageSetBlacklistEntry(itemStack, BlacklistRegistryProxy.Blacklist.KNOWLEDGE)); + PacketHandler.INSTANCE.sendToAll( + new MessageSetBlacklistEntry(itemStack, BlacklistRegistryProxy.Blacklist.EXCHANGE)); + func_152373_a( + commandSender, + this, + "%s set %s as not learnable and not exchangeable", + new Object[] { commandSender.getCommandSenderName(), itemStack.func_151000_E() }); } - - // Notify admins and log the value change - func_152373_a( - commandSender, - this, - Messages.Commands.SET_ENERGY_VALUE_CURRENT_ITEM_SUCCESS, - new Object[] { commandSender.getCommandSenderName(), args[1], itemStack.func_151000_E(), - newEnergyValue.getChatComponent() }); } else { throw new WrongUsageException(Messages.Commands.SET_ENERGY_VALUE_CURRENT_ITEM_USAGE); } + + EnergyValueRegistry.INSTANCE.save(); } else { throw new WrongUsageException(Messages.Commands.NO_ITEM); } @@ -119,7 +105,7 @@ public void processCommand(ICommandSender commandSender, String[] args) { @Override public List addTabCompletionOptions(ICommandSender commandSender, String[] args) { if (args.length == 2) { - return getListOfStringsMatchingLastWord(args, "pre", "global-pre", "post", "global-post"); + return getListOfStringsMatchingLastWord(args, "pre", "post"); } return null; diff --git a/src/main/java/com/pahimar/ee3/command/CommandSetItemLearnable.java b/src/main/java/com/pahimar/ee3/command/CommandSetItemLearnable.java index 699e872c..28748468 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandSetItemLearnable.java +++ b/src/main/java/com/pahimar/ee3/command/CommandSetItemLearnable.java @@ -11,7 +11,9 @@ import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; -import com.pahimar.ee3.api.knowledge.AbilityRegistryProxy; +import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; +import com.pahimar.ee3.network.PacketHandler; +import com.pahimar.ee3.network.message.MessageSetBlacklistEntry; import com.pahimar.ee3.reference.Messages; import com.pahimar.ee3.reference.Names; @@ -72,7 +74,9 @@ public void processCommand(ICommandSender commandSender, String[] args) { } } - AbilityRegistryProxy.setAsLearnable(itemStack); + BlacklistRegistryProxy.removeFromBlacklist(itemStack, BlacklistRegistryProxy.Blacklist.KNOWLEDGE); + PacketHandler.INSTANCE.sendToAll( + new MessageSetBlacklistEntry(itemStack, BlacklistRegistryProxy.Blacklist.KNOWLEDGE, false)); func_152373_a( commandSender, this, diff --git a/src/main/java/com/pahimar/ee3/command/CommandSetItemNotLearnable.java b/src/main/java/com/pahimar/ee3/command/CommandSetItemNotLearnable.java index b63a33e1..93efea54 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandSetItemNotLearnable.java +++ b/src/main/java/com/pahimar/ee3/command/CommandSetItemNotLearnable.java @@ -11,7 +11,9 @@ import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; -import com.pahimar.ee3.api.knowledge.AbilityRegistryProxy; +import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; +import com.pahimar.ee3.network.PacketHandler; +import com.pahimar.ee3.network.message.MessageSetBlacklistEntry; import com.pahimar.ee3.reference.Messages; import com.pahimar.ee3.reference.Names; @@ -72,7 +74,9 @@ public void processCommand(ICommandSender commandSender, String[] args) { } } - AbilityRegistryProxy.setAsNotLearnable(itemStack); + BlacklistRegistryProxy.addToBlacklist(itemStack, BlacklistRegistryProxy.Blacklist.KNOWLEDGE); + PacketHandler.INSTANCE + .sendToAll(new MessageSetBlacklistEntry(itemStack, BlacklistRegistryProxy.Blacklist.KNOWLEDGE)); func_152373_a( commandSender, this, diff --git a/src/main/java/com/pahimar/ee3/command/CommandSetItemNotRecoverable.java b/src/main/java/com/pahimar/ee3/command/CommandSetItemNotRecoverable.java index 1e91ca81..3c7546f6 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandSetItemNotRecoverable.java +++ b/src/main/java/com/pahimar/ee3/command/CommandSetItemNotRecoverable.java @@ -11,7 +11,9 @@ import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; -import com.pahimar.ee3.api.knowledge.AbilityRegistryProxy; +import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; +import com.pahimar.ee3.network.PacketHandler; +import com.pahimar.ee3.network.message.MessageSetBlacklistEntry; import com.pahimar.ee3.reference.Messages; import com.pahimar.ee3.reference.Names; @@ -72,7 +74,9 @@ public void processCommand(ICommandSender commandSender, String[] args) { } } - AbilityRegistryProxy.setAsNotRecoverable(itemStack); + BlacklistRegistryProxy.addToBlacklist(itemStack, BlacklistRegistryProxy.Blacklist.EXCHANGE); + PacketHandler.INSTANCE + .sendToAll(new MessageSetBlacklistEntry(itemStack, BlacklistRegistryProxy.Blacklist.EXCHANGE)); func_152373_a( commandSender, this, diff --git a/src/main/java/com/pahimar/ee3/command/CommandSetItemRecoverable.java b/src/main/java/com/pahimar/ee3/command/CommandSetItemRecoverable.java index ac7d748a..3569a3e1 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandSetItemRecoverable.java +++ b/src/main/java/com/pahimar/ee3/command/CommandSetItemRecoverable.java @@ -11,7 +11,9 @@ import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; -import com.pahimar.ee3.api.knowledge.AbilityRegistryProxy; +import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; +import com.pahimar.ee3.network.PacketHandler; +import com.pahimar.ee3.network.message.MessageSetBlacklistEntry; import com.pahimar.ee3.reference.Messages; import com.pahimar.ee3.reference.Names; @@ -72,7 +74,9 @@ public void processCommand(ICommandSender commandSender, String[] args) { } } - AbilityRegistryProxy.setAsRecoverable(itemStack); + BlacklistRegistryProxy.removeFromBlacklist(itemStack, BlacklistRegistryProxy.Blacklist.EXCHANGE); + PacketHandler.INSTANCE.sendToAll( + new MessageSetBlacklistEntry(itemStack, BlacklistRegistryProxy.Blacklist.EXCHANGE, true)); func_152373_a( commandSender, this, diff --git a/src/main/java/com/pahimar/ee3/command/CommandSyncEnergyValues.java b/src/main/java/com/pahimar/ee3/command/CommandSyncEnergyValues.java index 43efe62b..25dcb256 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandSyncEnergyValues.java +++ b/src/main/java/com/pahimar/ee3/command/CommandSyncEnergyValues.java @@ -8,20 +8,19 @@ import net.minecraft.command.ICommandSender; import net.minecraft.command.WrongUsageException; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.util.ChatComponentTranslation; import com.pahimar.ee3.exchange.EnergyValueRegistry; +import com.pahimar.ee3.handler.ConfigurationHandler; import com.pahimar.ee3.network.PacketHandler; import com.pahimar.ee3.network.message.MessageSyncEnergyValues; import com.pahimar.ee3.reference.Messages; import com.pahimar.ee3.reference.Names; -import com.pahimar.ee3.reference.Settings; import com.pahimar.ee3.util.LogHelper; public class CommandSyncEnergyValues extends CommandBase { - private static Map requesterMap = new HashMap(); + private static Map requesterMap = new HashMap<>(); @Override public String getCommandName() { @@ -40,30 +39,32 @@ public String getCommandUsage(ICommandSender commandSender) { @Override public void processCommand(ICommandSender commandSender, String[] args) { + boolean shouldSync = true; float coolDown = 0f; UUID commandSenderUUID = ((EntityPlayer) commandSender).getUniqueID(); if (requesterMap.containsKey(commandSenderUUID)) { - long timeDifference = System.currentTimeMillis() - requesterMap.get(commandSenderUUID).longValue(); - if (timeDifference >= (Settings.General.syncThreshold * 1000)) { + + // TODO Switch to nanoTime from currentTimeMillis + long timeDifference = (System.nanoTime() - requesterMap.get(commandSenderUUID).longValue()) / 100000; + + if (timeDifference >= (ConfigurationHandler.Settings.serverSyncThreshold * 1000)) { requesterMap.remove(commandSenderUUID); } else { - coolDown = (Settings.General.syncThreshold * 1000) - timeDifference; + coolDown = (ConfigurationHandler.Settings.serverSyncThreshold * 1000) - timeDifference; shouldSync = false; } } else { - requesterMap.put(commandSenderUUID, System.currentTimeMillis()); + requesterMap.put(commandSenderUUID, System.nanoTime() / 100000); } if (shouldSync) { LogHelper.info( EnergyValueRegistry.ENERGY_VALUE_MARKER, - "Syncing energy values with player '{}' at their request", + "Syncing energy values with all players at {}'s request", commandSender.getCommandSenderName()); - PacketHandler.INSTANCE.sendTo( - new MessageSyncEnergyValues(EnergyValueRegistry.getInstance()), - (EntityPlayerMP) commandSender); + PacketHandler.INSTANCE.sendToAll(new MessageSyncEnergyValues()); commandSender.addChatMessage(new ChatComponentTranslation(Messages.Commands.SYNC_ENERGY_VALUES_SUCCESS)); } else { throw new WrongUsageException( diff --git a/src/main/java/com/pahimar/ee3/command/CommandTemplateForgetCurrentItem.java b/src/main/java/com/pahimar/ee3/command/CommandTemplateForgetCurrentItem.java deleted file mode 100644 index fd4abd9b..00000000 --- a/src/main/java/com/pahimar/ee3/command/CommandTemplateForgetCurrentItem.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.pahimar.ee3.command; - -import net.minecraft.command.CommandBase; -import net.minecraft.command.ICommandSender; -import net.minecraft.command.WrongUsageException; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - -import com.pahimar.ee3.knowledge.TransmutationKnowledgeRegistry; -import com.pahimar.ee3.reference.Messages; -import com.pahimar.ee3.reference.Names; - -public class CommandTemplateForgetCurrentItem extends CommandBase { - - @Override - public String getCommandName() { - return Names.Commands.TEMPLATE_FORGET_CURRENT_ITEM; - } - - @Override - public int getRequiredPermissionLevel() { - return 2; - } - - @Override - public String getCommandUsage(ICommandSender commandSender) { - return Messages.Commands.TEMPLATE_FORGET_CURRENT_ITEM_USAGE; - } - - @Override - public void processCommand(ICommandSender commandSender, String[] args) { - if (args.length < 1) { - throw new WrongUsageException(Messages.Commands.TEMPLATE_FORGET_CURRENT_ITEM_USAGE); - } else { - ItemStack itemStack = ((EntityPlayer) commandSender).getCurrentEquippedItem(); - - if (itemStack != null) { - TransmutationKnowledgeRegistry.getInstance().makeTemplateForget(itemStack); - func_152373_a( - commandSender, - this, - Messages.Commands.TEMPLATE_FORGET_CURRENT_ITEM_SUCCESS, - new Object[] { commandSender.getCommandSenderName(), itemStack.func_151000_E() }); - } else { - throw new WrongUsageException(Messages.Commands.NO_ITEM); - } - } - } -} diff --git a/src/main/java/com/pahimar/ee3/command/CommandTemplateForgetEverything.java b/src/main/java/com/pahimar/ee3/command/CommandTemplateForgetEverything.java deleted file mode 100644 index edae8411..00000000 --- a/src/main/java/com/pahimar/ee3/command/CommandTemplateForgetEverything.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.pahimar.ee3.command; - -import net.minecraft.command.CommandBase; -import net.minecraft.command.ICommandSender; - -import com.pahimar.ee3.knowledge.TransmutationKnowledgeRegistry; -import com.pahimar.ee3.reference.Messages; -import com.pahimar.ee3.reference.Names; - -public class CommandTemplateForgetEverything extends CommandBase { - - @Override - public String getCommandName() { - return Names.Commands.TEMPLATE_FORGET_EVERYTHING; - } - - @Override - public int getRequiredPermissionLevel() { - return 2; - } - - @Override - public String getCommandUsage(ICommandSender commandSender) { - return Messages.Commands.TEMPLATE_FORGET_EVERYTHING_USAGE; - } - - @Override - public void processCommand(ICommandSender commandSender, String[] args) { - TransmutationKnowledgeRegistry.getInstance().makeTemplateForgetEverything(); - func_152373_a( - commandSender, - this, - Messages.Commands.TEMPLATE_FORGET_EVERYTHING_SUCCESS, - new Object[] { commandSender.getCommandSenderName() }); - } -} diff --git a/src/main/java/com/pahimar/ee3/command/CommandTemplateForgetItem.java b/src/main/java/com/pahimar/ee3/command/CommandTemplateForgetItem.java deleted file mode 100644 index f5ecb861..00000000 --- a/src/main/java/com/pahimar/ee3/command/CommandTemplateForgetItem.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.pahimar.ee3.command; - -import java.util.List; - -import net.minecraft.command.CommandBase; -import net.minecraft.command.ICommandSender; -import net.minecraft.command.WrongUsageException; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.JsonToNBT; -import net.minecraft.nbt.NBTBase; -import net.minecraft.nbt.NBTTagCompound; - -import com.pahimar.ee3.knowledge.TransmutationKnowledgeRegistry; -import com.pahimar.ee3.reference.Messages; -import com.pahimar.ee3.reference.Names; - -public class CommandTemplateForgetItem extends CommandBase { - - @Override - public String getCommandName() { - return Names.Commands.TEMPLATE_FORGET_ITEM; - } - - @Override - public int getRequiredPermissionLevel() { - return 2; - } - - @Override - public String getCommandUsage(ICommandSender commandSender) { - return Messages.Commands.TEMPLATE_FORGET_ITEM_USAGE; - } - - @Override - public void processCommand(ICommandSender commandSender, String[] args) { - if (args.length < 2) { - throw new WrongUsageException(Messages.Commands.TEMPLATE_FORGET_ITEM_USAGE); - } else { - Item item = getItemByText(commandSender, args[1]); - int metaData = 0; - - if (args.length >= 3) { - metaData = parseInt(commandSender, args[2]); - } - - ItemStack itemStack = new ItemStack(item, 1, metaData); - - if (args.length >= 4) { - String stringNBTData = func_147178_a(commandSender, args, 3).getUnformattedText(); - - try { - NBTBase nbtBase = JsonToNBT.func_150315_a(stringNBTData); - - if (!(nbtBase instanceof NBTTagCompound)) { - func_152373_a( - commandSender, - this, - Messages.Commands.INVALID_NBT_TAG_ERROR, - new Object[] { "Not a valid tag" }); - return; - } - - itemStack.setTagCompound((NBTTagCompound) nbtBase); - } catch (Exception exception) { - func_152373_a( - commandSender, - this, - Messages.Commands.INVALID_NBT_TAG_ERROR, - new Object[] { exception.getMessage() }); - return; - } - } - - TransmutationKnowledgeRegistry.getInstance().makeTemplateForget(itemStack); - func_152373_a( - commandSender, - this, - Messages.Commands.TEMPLATE_FORGET_ITEM_SUCCESS, - new Object[] { commandSender.getCommandSenderName(), itemStack.func_151000_E() }); - } - } - - @Override - public List addTabCompletionOptions(ICommandSender commandSender, String[] args) { - if (args.length == 2) { - return getListOfStringsFromIterableMatchingLastWord(args, Item.itemRegistry.getKeys()); - } - - return null; - } -} diff --git a/src/main/java/com/pahimar/ee3/command/CommandTemplateLearnCurrentItem.java b/src/main/java/com/pahimar/ee3/command/CommandTemplateLearnCurrentItem.java deleted file mode 100644 index 652f4162..00000000 --- a/src/main/java/com/pahimar/ee3/command/CommandTemplateLearnCurrentItem.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.pahimar.ee3.command; - -import net.minecraft.command.CommandBase; -import net.minecraft.command.ICommandSender; -import net.minecraft.command.WrongUsageException; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - -import com.pahimar.ee3.knowledge.TransmutationKnowledgeRegistry; -import com.pahimar.ee3.reference.Messages; -import com.pahimar.ee3.reference.Names; - -public class CommandTemplateLearnCurrentItem extends CommandBase { - - @Override - public String getCommandName() { - return Names.Commands.TEMPLATE_LEARN_CURRENT_ITEM; - } - - @Override - public int getRequiredPermissionLevel() { - return 2; - } - - @Override - public String getCommandUsage(ICommandSender commandSender) { - return Messages.Commands.TEMPLATE_LEARN_CURRENT_ITEM_USAGE; - } - - @Override - public void processCommand(ICommandSender commandSender, String[] args) { - if (args.length < 1) { - throw new WrongUsageException(Messages.Commands.TEMPLATE_LEARN_CURRENT_ITEM_USAGE); - } else { - ItemStack itemStack = ((EntityPlayer) commandSender).getCurrentEquippedItem(); - - if (itemStack != null) { - TransmutationKnowledgeRegistry.getInstance().teachTemplate(itemStack); - func_152373_a( - commandSender, - this, - Messages.Commands.TEMPLATE_LEARN_CURRENT_ITEM_SUCCESS, - new Object[] { commandSender.getCommandSenderName(), itemStack.func_151000_E() }); - } else { - throw new WrongUsageException(Messages.Commands.NO_ITEM); - } - } - } -} diff --git a/src/main/java/com/pahimar/ee3/command/CommandTemplateLearnItem.java b/src/main/java/com/pahimar/ee3/command/CommandTemplateLearnItem.java deleted file mode 100644 index 8e06061d..00000000 --- a/src/main/java/com/pahimar/ee3/command/CommandTemplateLearnItem.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.pahimar.ee3.command; - -import java.util.List; - -import net.minecraft.command.CommandBase; -import net.minecraft.command.ICommandSender; -import net.minecraft.command.WrongUsageException; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.JsonToNBT; -import net.minecraft.nbt.NBTBase; -import net.minecraft.nbt.NBTTagCompound; - -import com.pahimar.ee3.knowledge.AbilityRegistry; -import com.pahimar.ee3.knowledge.TransmutationKnowledgeRegistry; -import com.pahimar.ee3.reference.Messages; -import com.pahimar.ee3.reference.Names; - -public class CommandTemplateLearnItem extends CommandBase { - - @Override - public String getCommandName() { - return Names.Commands.TEMPLATE_LEARN_ITEM; - } - - @Override - public int getRequiredPermissionLevel() { - return 2; - } - - @Override - public String getCommandUsage(ICommandSender commandSender) { - return Messages.Commands.TEMPLATE_LEARN_ITEM_USAGE; - } - - @Override - public void processCommand(ICommandSender commandSender, String[] args) { - if (args.length < 2) { - throw new WrongUsageException(Messages.Commands.TEMPLATE_LEARN_ITEM_USAGE); - } else { - Item item = getItemByText(commandSender, args[1]); - int metaData = 0; - - if (args.length >= 3) { - metaData = parseInt(commandSender, args[2]); - } - - ItemStack itemStack = new ItemStack(item, 1, metaData); - - if (args.length >= 4) { - String stringNBTData = func_147178_a(commandSender, args, 3).getUnformattedText(); - - try { - NBTBase nbtBase = JsonToNBT.func_150315_a(stringNBTData); - - if (!(nbtBase instanceof NBTTagCompound)) { - func_152373_a( - commandSender, - this, - Messages.Commands.INVALID_NBT_TAG_ERROR, - new Object[] { "Not a valid tag" }); - return; - } - - itemStack.setTagCompound((NBTTagCompound) nbtBase); - } catch (Exception exception) { - func_152373_a( - commandSender, - this, - Messages.Commands.INVALID_NBT_TAG_ERROR, - new Object[] { exception.getMessage() }); - return; - } - } - - if (AbilityRegistry.getInstance().isLearnable(itemStack)) { - TransmutationKnowledgeRegistry.getInstance().teachTemplate(itemStack); - func_152373_a( - commandSender, - this, - Messages.Commands.TEMPLATE_LEARN_ITEM_SUCCESS, - new Object[] { commandSender.getCommandSenderName(), itemStack.func_151000_E() }); - } - } - } - - @Override - public List addTabCompletionOptions(ICommandSender commandSender, String[] args) { - if (args.length == 2) { - return getListOfStringsFromIterableMatchingLastWord(args, Item.itemRegistry.getKeys()); - } - - return null; - } -} diff --git a/src/main/java/com/pahimar/ee3/exchange/CachedOreDictionary.java b/src/main/java/com/pahimar/ee3/exchange/CachedOreDictionary.java deleted file mode 100644 index 2c259502..00000000 --- a/src/main/java/com/pahimar/ee3/exchange/CachedOreDictionary.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.pahimar.ee3.exchange; - -import java.util.*; - -import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.OreDictionary; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.Multimap; -import com.google.common.collect.TreeMultimap; -import com.pahimar.ee3.reference.Comparators; -import com.pahimar.ee3.util.LogHelper; - -public class CachedOreDictionary { - - private static CachedOreDictionary cachedOreDictionary = null; - private ImmutableMap idToNameMap; - private ImmutableMap> oreNameToItemStackMap; - private ImmutableMultimap itemStackToOreNameMap; - - private CachedOreDictionary() { - Map idToOreNameMap = new TreeMap(); - Map> nameToStackMap = new TreeMap>( - Comparators.stringComparator); - Multimap stackToNameMultiMap = TreeMultimap - .create(WrappedStack.comparator, Comparators.stringComparator); - - for (String oreName : OreDictionary.getOreNames()) { - idToOreNameMap.put(OreDictionary.getOreID(oreName), oreName); - - List oreNameItemStacks = OreDictionary.getOres(oreName); - nameToStackMap.put(oreName, oreNameItemStacks); - - for (ItemStack itemStack : oreNameItemStacks) { - stackToNameMultiMap.put(WrappedStack.wrap(itemStack), oreName); - } - } - - idToNameMap = ImmutableMap.copyOf(idToOreNameMap); - oreNameToItemStackMap = ImmutableMap.copyOf(nameToStackMap); - itemStackToOreNameMap = ImmutableMultimap.copyOf(stackToNameMultiMap); - } - - public static CachedOreDictionary getInstance() { - if (cachedOreDictionary == null) { - cachedOreDictionary = new CachedOreDictionary(); - } - - return cachedOreDictionary; - } - - public Set getOreNames() { - return oreNameToItemStackMap.keySet(); - } - - public List getItemStacksForOreName(String oreName) { - if (oreNameToItemStackMap.containsKey(oreName)) { - return oreNameToItemStackMap.get(oreName); - } - - return new ArrayList(); - } - - public List getOreNamesForItemStack(ItemStack itemStack) { - List oreNameList = new ArrayList(); - WrappedStack wrappedStack = WrappedStack.wrap(itemStack); - - if (itemStackToOreNameMap.containsKey(wrappedStack)) { - for (String oreName : itemStackToOreNameMap.get(wrappedStack)) { - oreNameList.add(oreName); - } - } else { - for (WrappedStack wrappedStack1 : itemStackToOreNameMap.keySet()) { - - } - } - - return oreNameList; - } - - public void dumpCachedOreDictionaryToLog() { - for (String oreName : CachedOreDictionary.getInstance().getOreNames()) { - LogHelper.info( - "OreName: {}, ItemStacks: {}", - oreName, - CachedOreDictionary.getInstance().getItemStacksForOreName(oreName)); - } - } -} diff --git a/src/main/java/com/pahimar/ee3/exchange/DynamicEnergyValueInitThread.java b/src/main/java/com/pahimar/ee3/exchange/DynamicEnergyValueInitThread.java deleted file mode 100644 index f153a3ca..00000000 --- a/src/main/java/com/pahimar/ee3/exchange/DynamicEnergyValueInitThread.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.pahimar.ee3.exchange; - -import com.pahimar.ee3.recipe.AludelRecipeManager; -import com.pahimar.ee3.recipe.RecipeRegistry; -import com.pahimar.ee3.util.LogHelper; - -public class DynamicEnergyValueInitThread implements Runnable { - - private static DynamicEnergyValueInitThread instance = new DynamicEnergyValueInitThread(); - - public static void initEnergyValueRegistry() { - new Thread(instance, "DynamicEMC Thread").start(); - } - - @Override - public void run() { - // Add in recipes to the RecipeRegistry *just* before we do calculations - RecipeRegistry.getInstance().registerVanillaRecipes(); - AludelRecipeManager.registerRecipes(); - - long startTime = System.currentTimeMillis(); - EnergyValueRegistry.getInstance().init(); - LogHelper.info( - EnergyValueRegistry.ENERGY_VALUE_MARKER, - "DynamicEMC system initialized after {} ms", - System.currentTimeMillis() - startTime); - } -} diff --git a/src/main/java/com/pahimar/ee3/exchange/EnergyValueRegistry.java b/src/main/java/com/pahimar/ee3/exchange/EnergyValueRegistry.java index baf42b42..b6e47540 100644 --- a/src/main/java/com/pahimar/ee3/exchange/EnergyValueRegistry.java +++ b/src/main/java/com/pahimar/ee3/exchange/EnergyValueRegistry.java @@ -1,27 +1,29 @@ package com.pahimar.ee3.exchange; +import static com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy.Phase; + import java.io.File; -import java.lang.reflect.Type; +import java.io.FileNotFoundException; import java.util.*; +import java.util.stream.Collectors; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.oredict.OreDictionary; import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.MarkerManager; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSortedMap; -import com.google.gson.*; +import com.pahimar.ee3.api.event.EnergyValueEvent; import com.pahimar.ee3.api.exchange.EnergyValue; -import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy; import com.pahimar.ee3.api.exchange.IEnergyValueProvider; +import com.pahimar.ee3.handler.ConfigurationHandler; import com.pahimar.ee3.recipe.RecipeRegistry; -import com.pahimar.ee3.reference.Files; -import com.pahimar.ee3.reference.Reference; -import com.pahimar.ee3.reference.Settings; -import com.pahimar.ee3.util.EnergyValueHelper; +import com.pahimar.ee3.reference.Comparators; +import com.pahimar.ee3.util.FilterUtils; import com.pahimar.ee3.util.LoaderHelper; import com.pahimar.ee3.util.LogHelper; import com.pahimar.ee3.util.SerializationHelper; @@ -29,273 +31,210 @@ import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Loader; -public class EnergyValueRegistry implements JsonSerializer, JsonDeserializer { +public class EnergyValueRegistry { - public static final Marker ENERGY_VALUE_MARKER = MarkerManager.getMarker("EE3_ENERGY_VALUE", LogHelper.MOD_MARKER); - private static final Marker PRE_CALC_MARKER = MarkerManager - .getMarker("EE3_ENERGY_VALUE_PRE_CALC", ENERGY_VALUE_MARKER); - private static final Marker POST_CALC_MARKER = MarkerManager - .getMarker("EE3_ENERGY_VALUE_POST_CALC", ENERGY_VALUE_MARKER); - - private static final Gson JSON_SERIALIZER = (new GsonBuilder()).setPrettyPrinting() - .registerTypeAdapter(EnergyValueRegistry.class, new EnergyValueRegistry()) - .registerTypeAdapter(EnergyValueStackMapping.class, new EnergyValueStackMapping()).create(); - private static EnergyValueRegistry energyValueRegistry = null; - private static Map preCalculationMappings; - private static Map postCalculationMappings; - private boolean shouldRegenNextRestart = false; - private ImmutableSortedMap stackMappings; - private ImmutableSortedMap> valueMappings; - private SortedSet uncomputedStacks; - - private EnergyValueRegistry() {} - - public static EnergyValueRegistry getInstance() { - if (energyValueRegistry == null) { - energyValueRegistry = new EnergyValueRegistry(); - } + public static final EnergyValueRegistry INSTANCE = new EnergyValueRegistry(); - return energyValueRegistry; - } + private ImmutableSortedMap stackValueMap; + private ImmutableSortedMap> valueStackMap; - public void addPreCalculationEnergyValue(Object object, float energyValue) { - addPreCalculationEnergyValue(object, new EnergyValue(energyValue)); - } + private final Map preCalculationStackValueMap; + private final Map postCalculationStackValueMap; + private transient SortedSet uncomputedStacks; + private transient boolean shouldSave; + private transient boolean valuesNeedRegeneration; - public void addPreCalculationEnergyValue(Object object, EnergyValue energyValue) { - if (preCalculationMappings == null) { - preCalculationMappings = new TreeMap(); - } + public static File energyValuesDirectory; + public static File energyValuesFile; + public static File preCalculationValuesFile; + public static File postCalculationValuesFile; - if (WrappedStack.canBeWrapped(object) && energyValue != null && Float.compare(energyValue.getValue(), 0f) > 0) { - WrappedStack wrappedStack = WrappedStack.wrap(object); - - if (wrappedStack.getStackSize() > 0) { - WrappedStack factoredWrappedStack = WrappedStack.wrap(wrappedStack, 1); - EnergyValue factoredEnergyValue = EnergyValueHelper - .factorEnergyValue(energyValue, wrappedStack.getStackSize()); - - if (preCalculationMappings.containsKey(factoredWrappedStack)) { - if (factoredEnergyValue.compareTo(preCalculationMappings.get(factoredWrappedStack)) < 0) { - LogHelper.trace( - PRE_CALC_MARKER, - "[{}] Mod with ID '{}' set a pre-calculation energy value of {} for object {}", - LoaderHelper.getLoaderState(), - Loader.instance().activeModContainer().getModId(), - energyValue, - wrappedStack); - preCalculationMappings.put(factoredWrappedStack, factoredEnergyValue); - } - } else { - LogHelper.trace( - PRE_CALC_MARKER, - "[{}] Mod with ID '{}' set a pre-calculation energy value of {} for object {}", - LoaderHelper.getLoaderState(), - Loader.instance().activeModContainer().getModId(), - energyValue, - wrappedStack); - preCalculationMappings.put(factoredWrappedStack, factoredEnergyValue); - } - } - } - } + public static final Marker ENERGY_VALUE_MARKER = MarkerManager.getMarker("EE3_ENERGY_VALUE", LogHelper.MOD_MARKER); - public void addPostCalculationExactEnergyValue(Object object, float energyValue) { - addPostCalculationExactEnergyValue(object, new EnergyValue(energyValue)); - } + private EnergyValueRegistry() { + + ImmutableSortedMap.Builder stackMapBuilder = ImmutableSortedMap.naturalOrder(); + stackValueMap = stackMapBuilder.build(); + + preCalculationStackValueMap = new TreeMap<>(); + postCalculationStackValueMap = new TreeMap<>(); + uncomputedStacks = new TreeSet<>(); + shouldSave = true; + } + + /** + * Returns an {@link EnergyValue} for a {@link Object} in the provided {@link Map>} of {@link WrappedStack}s mapped + * to EnergyValues + * + *

+ * The order of checking is as follows; + *

+ *
    + *
  1. {@link ItemStack}s whose {@link Item}s implement {@link IEnergyValueProvider}
  2. + *
  3. Direct EnergyValue mapping of the provided Object in the provided Map
  4. + *
  5. The following criteria are only checked (in order) in the event that this is a non-strict query; + *
      + *
    1. ItemStacks that are part of an {@link OreDictionary} entry are checked to see if all Ores + * they are registered to have the same non-null EnergyValue assigned to it + *
        + *
      • e.g., ItemStack X is associated with OreDictionary entries A, B and C. An EnergyValue would be returned for X + * only if A, B and C all had the same non-null EnergyValue
      • + *
      + *
    2. + *
    3. ItemStacks are checked to see if there exist {@link OreDictionary#WILDCARD_VALUE} equivalents
    4. + *
    5. {@link OreStack}s are checked to see if all members of the OreDictionary entry represented by the OreStack + * have the same non-null EnergyValue (similar to the case for ItemStacks above)
    6. + *
    + *
  6. + *
+ * + * @param valueMap a {@link Map} of {@link EnergyValue}'s mapped to {@link WrappedStack}'s + * @param object the {@link Object} that is being checked for a corresponding {@link EnergyValue} + * @param strict whether this is a strict (e.g., only looking for direct value assignment vs associative value + * assignments) query or not + * @return an {@link EnergyValue} if there is one to be found for the provided {@link Object} in the provided Map, + * null otherwise + */ + public static EnergyValue getEnergyValue(Map valueMap, Object object, boolean strict) { - public void addPostCalculationExactEnergyValue(Object object, EnergyValue energyValue) { - if (postCalculationMappings == null) { - postCalculationMappings = new TreeMap(); - } + if (WrappedStack.canBeWrapped(object)) { - if (WrappedStack.canBeWrapped(object) && energyValue != null && Float.compare(energyValue.getValue(), 0f) > 0) { - WrappedStack wrappedStack = WrappedStack.wrap(object); + WrappedStack wrappedStack = WrappedStack.wrap(object, 1); + Object wrappedObject = wrappedStack.getWrappedObject(); - if (wrappedStack.getStackSize() > 0) { - WrappedStack factoredWrappedStack = WrappedStack.wrap(wrappedStack, 1); - EnergyValue factoredEnergyValue = EnergyValueHelper - .factorEnergyValue(energyValue, wrappedStack.getStackSize()); + if (wrappedObject instanceof ItemStack + && ((ItemStack) wrappedObject).getItem() instanceof IEnergyValueProvider + && !strict) { - LogHelper.trace( - POST_CALC_MARKER, - "[{}] Mod with ID '{}' set a post-calculation energy value of {} for object {}", - LoaderHelper.getLoaderState(), - Loader.instance().activeModContainer().getModId(), - energyValue, - wrappedStack); - postCalculationMappings.put(factoredWrappedStack, factoredEnergyValue); + EnergyValue energyValue = ((IEnergyValueProvider) ((ItemStack) wrappedObject).getItem()) + .getEnergyValue(((ItemStack) wrappedObject)); + + if (energyValue != null && Float.compare(energyValue.getValue(), 0f) > 0) { + return energyValue; + } } - } - } - public boolean hasEnergyValue(Object object) { - return hasEnergyValue(object, false); - } + if (valueMap != null && !valueMap.isEmpty()) { - public boolean hasEnergyValue(Object object, boolean strict) { - return getEnergyValue(object, strict) != null; - } + /** + * First check to see if the object is a WILDCARD_VALUE ItemStack, as if it is it will match any similar + * ItemStack. If it is check to see how many objects it matches in the given map. If there is at least + * one similar object found, find the lowest energy value out of all the similar objects + */ + if (wrappedObject instanceof ItemStack + && ((ItemStack) wrappedObject).getItemDamage() == OreDictionary.WILDCARD_VALUE) { - public EnergyValue getEnergyValue(Object object) { - return getEnergyValue(EnergyValueRegistryProxy.Phase.ALL, object, false); - } + Set equivalentStacks = valueMap.keySet().stream().filter(wrappedStack::equals) + .filter(wrappedStack1 -> wrappedStack1.getWrappedObject() instanceof ItemStack) + .filter( + wrappedStack1 -> ((ItemStack) wrappedStack1.getWrappedObject()).getItemDamage() + != OreDictionary.WILDCARD_VALUE) + .collect(Collectors.toCollection(TreeSet::new)); - public EnergyValue getEnergyValue(Object object, boolean strict) { - return getEnergyValue(EnergyValueRegistryProxy.Phase.ALL, object, strict); - } + if (equivalentStacks.size() >= 1) { + EnergyValue lowestValue = null; - public EnergyValue getEnergyValue(EnergyValueRegistryProxy.Phase phase, Object object, boolean strict) { - if (phase == EnergyValueRegistryProxy.Phase.PRE_ASSIGNMENT - || phase == EnergyValueRegistryProxy.Phase.PRE_CALCULATION) { - return getEnergyValueFromMap(preCalculationMappings, object, strict); - } else if (phase == EnergyValueRegistryProxy.Phase.POST_ASSIGNMENT - || phase == EnergyValueRegistryProxy.Phase.POST_CALCULATION) { - return getEnergyValueFromMap(postCalculationMappings, object, strict); - } else { - return getEnergyValueFromMap(energyValueRegistry.stackMappings, object, strict); - } - } + for (WrappedStack wrappedStack1 : equivalentStacks) { + EnergyValue currentValue = getEnergyValue(valueMap, wrappedStack1, strict); - public EnergyValue getEnergyValueForStack(Object object, boolean strict) { - WrappedStack wrappedObject = WrappedStack.wrap(object); + if (lowestValue == null) { + lowestValue = currentValue; + } else if (currentValue.compareTo(lowestValue) < 0) { + lowestValue = currentValue; + } + } - if (wrappedObject != null && getEnergyValue(object, strict) != null) { - return new EnergyValue(getEnergyValue(object, strict).getValue() * wrappedObject.getStackSize()); - } + return lowestValue; + } + } - return null; - } + // Check for an exact mapping + if (valueMap.containsKey(wrappedStack)) { + return valueMap.get(wrappedStack); + } else if (!strict) { - public EnergyValue getEnergyValueFromMap(Map stackEnergyValueMap, Object object) { - return getEnergyValueFromMap(stackEnergyValueMap, object, false); - } + if (wrappedObject instanceof ItemStack) { - public EnergyValue getEnergyValueFromMap(Map stackEnergyValueMap, Object object, - boolean strict) { - if (WrappedStack.canBeWrapped(object)) { - WrappedStack wrappedStackObject = WrappedStack.wrap(object); - WrappedStack unitWrappedStackObject = WrappedStack.wrap(object); - unitWrappedStackObject.setStackSize(1); - Object wrappedObject = wrappedStackObject.getWrappedObject(); - - /** - * In the event that an Item has an IEnergyValueProvider implementation, route the call to the - * implementation - */ - if (wrappedObject instanceof ItemStack - && ((ItemStack) wrappedObject).getItem() instanceof IEnergyValueProvider - && !strict) { - ItemStack itemStack = (ItemStack) wrappedObject; - IEnergyValueProvider iEnergyValueProvider = (IEnergyValueProvider) itemStack.getItem(); - EnergyValue energyValue = iEnergyValueProvider.getEnergyValue(itemStack); + ItemStack unValuedItemStack = ItemStack.copyItemStack((ItemStack) wrappedObject); + EnergyValue minEnergyValue = null; + + int[] oreIds = OreDictionary.getOreIDs(unValuedItemStack); + if (oreIds.length > 0) { - if (energyValue != null && energyValue.getValue() > 0f) { - return energyValue; - } - } else if (stackEnergyValueMap != null) { - /** - * Check for a direct value mapping for the object - */ - if (stackEnergyValueMap.containsKey(unitWrappedStackObject)) { - return stackEnergyValueMap.get(unitWrappedStackObject); - } else if (!strict) { - if (wrappedObject instanceof ItemStack) { - EnergyValue lowestValue = null; - ItemStack wrappedItemStack = (ItemStack) wrappedObject; - - /** - * The ItemStack does not have a direct mapping, so check if it is a member of an OreDictionary - * entry. If it is a member of an OreDictionary entry, check if every ore name it is associated - * with has 1) a direct mapping, and 2) the same mapping value - */ - if (OreDictionary.getOreIDs(wrappedItemStack).length >= 1) { EnergyValue energyValue = null; - boolean allHaveSameValueFlag = true; + boolean allHaveSameValue = true; + + for (int oreId : oreIds) { + String oreName = OreDictionary.getOreName(oreId); + + if (!"Unknown".equalsIgnoreCase(oreName)) { - // Scan all valid ore dictionary values, if they ALL have the same value, then return it - for (int oreID : OreDictionary.getOreIDs(wrappedItemStack)) { - String oreName = OreDictionary.getOreName(oreID); - if (!oreName.equals("Unknown")) { WrappedStack oreStack = WrappedStack.wrap(new OreStack(oreName)); - if (oreStack != null && stackEnergyValueMap.containsKey(oreStack)) { + if (oreStack != null && valueMap.containsKey(oreStack)) { + if (energyValue == null) { - energyValue = stackEnergyValueMap.get(oreStack); - } else if (!energyValue.equals(stackEnergyValueMap.get(oreStack))) { - allHaveSameValueFlag = false; + energyValue = valueMap.get(oreStack); + } else if (!energyValue.equals(valueMap.get(oreStack))) { + allHaveSameValue = false; } } else { - allHaveSameValueFlag = false; + allHaveSameValue = false; } } else { - allHaveSameValueFlag = false; + allHaveSameValue = false; } } - if (energyValue != null && allHaveSameValueFlag) { + if (allHaveSameValue) { return energyValue; } } else { - /** - * Scan the stack value map for ItemStacks that have the same Item. If one is found, check - * if it has a wildcard meta value (and therefore is considered the same). Otherwise, check - * if the ItemStack is "damageable" and calculate the value for the damaged stack. - */ - for (WrappedStack valuedStack : stackEnergyValueMap.keySet()) { - if (valuedStack.getWrappedObject() instanceof ItemStack) { - ItemStack valuedItemStack = (ItemStack) valuedStack.getWrappedObject(); - - if (Item.getIdFromItem(valuedItemStack.getItem()) - == Item.getIdFromItem(wrappedItemStack.getItem())) { + for (WrappedStack valuedWrappedStack : valueMap.keySet()) { + if (valuedWrappedStack.getWrappedObject() instanceof ItemStack) { + if (Item.getIdFromItem( + ((ItemStack) valuedWrappedStack.getWrappedObject()).getItem()) + == Item.getIdFromItem(unValuedItemStack.getItem())) { + + ItemStack valuedItemStack = (ItemStack) valuedWrappedStack.getWrappedObject(); if (valuedItemStack.getItemDamage() == OreDictionary.WILDCARD_VALUE - || wrappedItemStack.getItemDamage() == OreDictionary.WILDCARD_VALUE) { - EnergyValue stackValue = stackEnergyValueMap.get(valuedStack); + || unValuedItemStack.getItemDamage() == OreDictionary.WILDCARD_VALUE) { + + EnergyValue energyValue = valueMap.get(valuedWrappedStack); - if (stackValue.compareTo(lowestValue) < 0) { - lowestValue = stackValue; + if (energyValue.compareTo(minEnergyValue) < 0) { + minEnergyValue = energyValue; } - } else if (wrappedItemStack.getItem().isDamageable() - && wrappedItemStack.isItemDamaged()) { - EnergyValue stackValue = new EnergyValue( - stackEnergyValueMap.get(valuedStack).getValue() - * (1 - (wrappedItemStack.getItemDamage() * 1.0F - / wrappedItemStack.getMaxDamage()))); - - if (stackValue.compareTo(lowestValue) < 0) { - lowestValue = stackValue; - } - } + } } } } - - return lowestValue; } } else if (wrappedObject instanceof OreStack) { + OreStack oreStack = (OreStack) wrappedObject; + List itemStacks = OreDictionary.getOres(oreStack.oreName); + + if (!itemStacks.isEmpty()) { - if (CachedOreDictionary.getInstance().getItemStacksForOreName(oreStack.oreName).size() >= 1) { EnergyValue energyValue = null; - boolean allHaveSameValueFlag = true; + boolean allHaveSameValue = true; - // Scan all valid ore dictionary values, if they ALL have the same value, then return it - for (ItemStack itemStack : CachedOreDictionary.getInstance() - .getItemStacksForOreName(oreStack.oreName)) { - WrappedStack wrappedItemStack = WrappedStack.wrap(itemStack); + for (ItemStack itemStack : itemStacks) { + WrappedStack wrappedItemStack = WrappedStack.wrap(itemStack, 1); - if (wrappedItemStack != null && stackEnergyValueMap.containsKey(wrappedItemStack)) { + if (wrappedItemStack != null && valueMap.containsKey(wrappedItemStack)) { if (energyValue == null) { - energyValue = stackEnergyValueMap.get(wrappedItemStack); - } else if (!energyValue.equals(stackEnergyValueMap.get(wrappedItemStack))) { - allHaveSameValueFlag = false; + energyValue = valueMap.get(wrappedItemStack); + } else if (!energyValue.equals(valueMap.get(wrappedItemStack))) { + allHaveSameValue = false; } } else { - allHaveSameValueFlag = false; + allHaveSameValue = false; } } - if (energyValue != null && allHaveSameValueFlag) { + if (allHaveSameValue) { return energyValue; } } @@ -307,514 +246,666 @@ public EnergyValue getEnergyValueFromMap(Map stackEne return null; } - protected final void init() { - if (!loadEnergyValueRegistryFromFile()) { - runDynamicEnergyValueResolution(); - } - this.shouldRegenNextRestart = false; - } + /** + * Calculates an {@link EnergyValue} for the provided {@link WrappedStack} output from the provided + * {@link Collection} of WrappedStack inputs and {@link Map} of energy value mappings to objects. We calculate the + * energy value for the output by, for each input, summing the input's energy value * the input's stack size. That + * sum is then divided by the stack size of the output. If any of the inputs do not have an energy + * value then no energy value can be calculated for the output - therefore we return null + * + * @param valueMap a {@link Map} of {@link EnergyValue}'s mapped to {@link WrappedStack}'s + * @param wrappedOutput the {@link WrappedStack} output for that the inputs "create" + * @param wrappedInputs a {@link Collection} of {@link WrappedStack}s that "create" the output + * @return an {@link EnergyValue} if there is one that can be calculated, null otherwise + */ + private static EnergyValue computeFromInputs(Map valueMap, WrappedStack wrappedOutput, + Collection wrappedInputs) { - private void runDynamicEnergyValueResolution() { - TreeMap stackValueMap = new TreeMap(); - uncomputedStacks = null; + float sumOfValues = 0f; - // Add in all mod specified pre-calculation values - stackValueMap.putAll(preCalculationMappings); // TODO Logging + for (WrappedStack wrappedInput : wrappedInputs) { - // Add in all global pre-calculation values - LogHelper.trace( - ENERGY_VALUE_MARKER, - "Adding EnergyValue mappings from {}", - Files.Global.preCalcluationEnergyValueFile); - Map globalPreCalculationValueMap = SerializationHelper - .readEnergyValueStackMapFromJsonFile(Files.Global.preCalcluationEnergyValueFile); - for (WrappedStack wrappedStack : globalPreCalculationValueMap.keySet()) { - if (globalPreCalculationValueMap.get(wrappedStack) != null) { - stackValueMap.put(wrappedStack, globalPreCalculationValueMap.get(wrappedStack)); - LogHelper.trace( - ENERGY_VALUE_MARKER, - "Adding EnergyValue {} for {}", - globalPreCalculationValueMap.get(wrappedStack), - wrappedStack); - } - } + EnergyValue inputValue; + int stackSize = Integer.MIN_VALUE; - // Add in all instance pre-calculation values - LogHelper - .trace(ENERGY_VALUE_MARKER, "Adding EnergyValue mappings from {}", Files.PRE_CALCULATION_ENERGY_VALUES); - Map instancePreAssignedValueMap = SerializationHelper - .readEnergyValueStackMapFromJsonFile(Files.PRE_CALCULATION_ENERGY_VALUES); - for (WrappedStack wrappedStack : instancePreAssignedValueMap.keySet()) { - if (instancePreAssignedValueMap.get(wrappedStack) != null) { - stackValueMap.put(wrappedStack, instancePreAssignedValueMap.get(wrappedStack)); - LogHelper.trace( - ENERGY_VALUE_MARKER, - "Adding EnergyValue {} for {}", - instancePreAssignedValueMap.get(wrappedStack), - wrappedStack); - } - } + if (wrappedInput.getWrappedObject() instanceof ItemStack) { - /* - * Auto-assignment - */ - Map computedStackValues; - int passNumber = 0; - long computationStartTime = System.currentTimeMillis(); - long passStartTime; - int passComputedValueCount = 0; - int totalComputedValueCount = 0; - LogHelper.info(ENERGY_VALUE_MARKER, "Beginning dynamic value calculation"); - boolean isFirstPass = true; - while ((isFirstPass || passComputedValueCount > 0) && (passNumber < 16)) { - if (isFirstPass) { - isFirstPass = false; - } - passComputedValueCount = 0; - passStartTime = System.currentTimeMillis(); - passNumber++; + ItemStack inputItemStack = (ItemStack) wrappedInput.getWrappedObject(); - // Compute stack mappings from existing stack mappings - computedStackValues = computeStackMappings(stackValueMap, passNumber); + // Check if we are dealing with a potential fluid + if (FluidContainerRegistry.getFluidForFilledItem(inputItemStack) != null) { - for (WrappedStack keyStack : computedStackValues.keySet()) { - EnergyValue factoredExchangeEnergyValue = null; - WrappedStack factoredKeyStack = null; + if (inputItemStack.getItem().getContainerItem(inputItemStack) != null) { + stackSize = FluidContainerRegistry.getFluidForFilledItem(inputItemStack).amount + * wrappedInput.getStackSize(); + inputValue = getEnergyValue( + valueMap, + FluidContainerRegistry.getFluidForFilledItem(inputItemStack), + false); + } else { + inputValue = getEnergyValue(valueMap, wrappedInput, false); + } + } else if (inputItemStack.getItem().getContainerItem(inputItemStack) != null) { - if (keyStack != null && keyStack.getWrappedObject() != null && keyStack.getStackSize() > 0) { - if (computedStackValues.get(keyStack) != null - && Float.compare(computedStackValues.get(keyStack).getValue(), 0f) > 0) { - factoredExchangeEnergyValue = EnergyValueHelper - .factorEnergyValue(computedStackValues.get(keyStack), keyStack.getStackSize()); - factoredKeyStack = WrappedStack.wrap(keyStack, 1); + ItemStack inputContainerItemStack = inputItemStack.getItem().getContainerItem(inputItemStack); + + if (getEnergyValue(valueMap, inputItemStack, false) != null + && getEnergyValue(valueMap, inputContainerItemStack, false) != null) { + float itemStackValue = getEnergyValue(valueMap, inputItemStack, false).getValue(); + float containerStackValue = getEnergyValue(valueMap, inputContainerItemStack, false).getValue(); + inputValue = new EnergyValue(itemStackValue - containerStackValue); + } else { + inputValue = new EnergyValue(0); } + } else if (!inputItemStack.getItem().doesContainerItemLeaveCraftingGrid(inputItemStack)) { + inputValue = new EnergyValue(0); + } else if (OreDictionary.getOreIDs(inputItemStack).length > 0) { + inputValue = getEnergyValue(valueMap, wrappedInput, true); + } else { + inputValue = getEnergyValue(valueMap, wrappedInput, false); } + } else if (wrappedInput.getWrappedObject() instanceof OreStack) { - if (factoredExchangeEnergyValue != null) { - if (stackValueMap.containsKey(factoredKeyStack)) { - if (factoredExchangeEnergyValue.compareTo(stackValueMap.get(factoredKeyStack)) == -1) { - // LogHelper.trace(String.format("")); TODO Log message - stackValueMap.put(factoredKeyStack, factoredExchangeEnergyValue); - } - } else { - // LogHelper.trace(String.format("")); TODO Log message - stackValueMap.put(factoredKeyStack, factoredExchangeEnergyValue); - passComputedValueCount++; - totalComputedValueCount++; + OreStack inputOreStack = (OreStack) wrappedInput.getWrappedObject(); + inputValue = getEnergyValue(valueMap, wrappedInput, false); + for (ItemStack itemStack : OreDictionary.getOres(inputOreStack.oreName)) { + if (!itemStack.getItem().doesContainerItemLeaveCraftingGrid(itemStack)) { + inputValue = new EnergyValue(0); } } + } else { + inputValue = getEnergyValue(valueMap, wrappedInput, false); } - LogHelper.info( - ENERGY_VALUE_MARKER, - "Pass {}: Calculated {} values for objects in {} ms", - passNumber, - passComputedValueCount, - System.currentTimeMillis() - passStartTime); - } - LogHelper.info( - ENERGY_VALUE_MARKER, - "Finished dynamic value calculation (calculated {} values for objects in {} ms)", - totalComputedValueCount, - System.currentTimeMillis() - computationStartTime); - - // Add in all mod specified post-calculation values - // TODO Logging - if (postCalculationMappings != null) { - for (WrappedStack wrappedStack : postCalculationMappings.keySet()) { - if (postCalculationMappings.get(wrappedStack) != null) { - stackValueMap.put(wrappedStack, postCalculationMappings.get(wrappedStack)); + + if (inputValue != null) { + + if (stackSize == Integer.MIN_VALUE) { + stackSize = wrappedInput.getStackSize(); } - } - } else { - postCalculationMappings = new TreeMap(); - } - // Add in all global post-calculation values - LogHelper.trace( - ENERGY_VALUE_MARKER, - "Adding EnergyValue mappings from {}", - Files.Global.postCalcluationEnergyValueFile); - Map globalPostCalculationValueMap = SerializationHelper - .readEnergyValueStackMapFromJsonFile(Files.Global.postCalcluationEnergyValueFile); - for (WrappedStack wrappedStack : globalPostCalculationValueMap.keySet()) { - if (globalPostCalculationValueMap.get(wrappedStack) != null) { - stackValueMap.put(wrappedStack, globalPostCalculationValueMap.get(wrappedStack)); - LogHelper.trace( - ENERGY_VALUE_MARKER, - "Adding EnergyValue {} for {}", - globalPostCalculationValueMap.get(wrappedStack), - wrappedStack); + sumOfValues += inputValue.getValue() * stackSize; + } else { + return null; } } - // Add in all instance post-calculation values - LogHelper.trace( - ENERGY_VALUE_MARKER, - "Adding EnergyValue mappings from {}", - Files.POST_CALCULATION_ENERGY_VALUES); - Map instancePostCalculationValueMap = SerializationHelper - .readEnergyValueStackMapFromJsonFile(Files.POST_CALCULATION_ENERGY_VALUES); - for (WrappedStack wrappedStack : instancePostCalculationValueMap.keySet()) { - if (instancePostCalculationValueMap.get(wrappedStack) != null) { - stackValueMap.put(wrappedStack, instancePostCalculationValueMap.get(wrappedStack)); - LogHelper.trace( - ENERGY_VALUE_MARKER, - "Adding EnergyValue {} for {}", - instancePreAssignedValueMap.get(wrappedStack), - wrappedStack); - } - } + return EnergyValue.factor(new EnergyValue(sumOfValues), wrappedOutput.getStackSize()); + } - /** - * Finalize the stack to value map - */ - ImmutableSortedMap.Builder stackMappingsBuilder = ImmutableSortedMap.naturalOrder(); - stackMappingsBuilder.putAll(stackValueMap); - stackMappings = stackMappingsBuilder.build(); + /** + * Returns an {@link ImmutableMap} containing the current energy value mappings + * + * @return an {@link ImmutableMap} containing the current energy value mappings + */ + public ImmutableMap getEnergyValues() { + return stackValueMap; + } - /** - * Value map resolution - */ - generateValueStackMappings(); + /** + * Returns a {@link Map} containing the pre-calculation energy value mappings + * + * @return a {link Map} containing the pre-calculation energy value mappings + */ + public Map getPreCalculationStackValueMap() { + return preCalculationStackValueMap; + } - // Serialize values to disk - LogHelper.info(ENERGY_VALUE_MARKER, "Saving energy values to disk"); - save(); + /** + * Returns a {@link Map} containing the post-calculation energy value mappings + * + * @return a {@link Map} containing the post-calculation energy value mappings + */ + public Map getPostCalculationStackValueMap() { + return postCalculationStackValueMap; + } - // TODO Make this make "sense" and also ensure it's added as an option to the debug command - for (WrappedStack wrappedStack : uncomputedStacks) { - if (!hasEnergyValue(wrappedStack)) { - LogHelper.info(ENERGY_VALUE_MARKER, "Unable to compute a value for object '{}'", wrappedStack); - } - } + /** + * Checks if there exists an {@link EnergyValue} associated with the provided {@link Object}. + * + * @param object the {@link Object} that is being checked for a corresponding {@link EnergyValue} + * @return true if the provided object has an energy value, false otherwise + */ + public boolean hasEnergyValue(Object object) { + return hasEnergyValue(object, false); } - private void generateValueStackMappings() { - SortedMap> tempValueMappings = new TreeMap>(); + /** + * Checks if there exists an {@link EnergyValue} associated with the provided {@link Object} + * + * @param object the {@link Object} that is being checked for a corresponding {@link EnergyValue} + * @param strict whether this is a strict (e.g., only looking for direct value assignment vs associative value + * assignments) query or not + * @return true if the provided object has an energy value, false otherwise + */ + public boolean hasEnergyValue(Object object, boolean strict) { + return getEnergyValue(object, strict) != null; + } - for (WrappedStack stack : stackMappings.keySet()) { - if (stack != null) { - EnergyValue value = stackMappings.get(stack); + /** + * Returns an {@link EnergyValue} associated with the provided {@link Object} (if there is one) + * + * @param object the {@link Object} that is being checked for a corresponding {@link EnergyValue} + * @return an {@link EnergyValue} if there is one to be found, null otherwise + */ + public EnergyValue getEnergyValue(Object object) { + return getEnergyValue(object, false); + } - if (value != null) { - if (tempValueMappings.containsKey(value)) { - if (!(tempValueMappings.get(value).contains(stack))) { - tempValueMappings.get(value).add(stack); - } - } else { - tempValueMappings.put(value, new ArrayList(Arrays.asList(stack))); - } - } - } + /** + * Returns an {@link EnergyValue} associated with the provided {@link Object} (if there is one) + * + * @param object the {@link Object} that is being checked for a corresponding {@link EnergyValue} + * @param strict whether this is a strict (e.g., only looking for direct value assignment vs associative value + * assignments) query or not + * @return an {@link EnergyValue} if there is one to be found, null otherwise + */ + public EnergyValue getEnergyValue(Object object, boolean strict) { + return getEnergyValue(stackValueMap, object, strict); + } + + /** + * Returns an {@link EnergyValue} associated with the provided {@link Object} (if there is one) + * + * @param object the {@link Object} that is being checked for a corresponding {@link EnergyValue} + * @param strict whether this is a strict (e.g., only looking for direct value assignment vs associative value + * assignments) query or not + * @return an {@link EnergyValue} if there is one to be found, null otherwise + */ + public EnergyValue getEnergyValueForStack(Object object, boolean strict) { + + WrappedStack wrappedObject = WrappedStack.wrap(object); + EnergyValue energyValue = getEnergyValue(object, strict); + if (wrappedObject != null && energyValue != null) { + return new EnergyValue(energyValue.getValue() * wrappedObject.getStackSize()); } - valueMappings = ImmutableSortedMap.copyOf(tempValueMappings); + + return null; } - private Map computeStackMappings(Map stackValueMappings, - int passCount) { - Map computedStackMap = new TreeMap(); + /** + * TODO Finish JavaDoc + * + * @param start + * @param finish + * @return + */ + public Set getStacksInRange(Number start, Number finish) { + return getStacksInRange(new EnergyValue(start), new EnergyValue(finish)); + } - for (WrappedStack recipeOutput : RecipeRegistry.getInstance().getRecipeMappings().keySet()) { - // TODO Review: possible fault in the logic here that is preventing some values from being assigned? - if (!hasEnergyValue(recipeOutput.getWrappedObject(), false) - && !computedStackMap.containsKey(recipeOutput)) { - EnergyValue lowestValue = null; + /** + * TODO Finish JavaDoc + * + * @param lowerBound + * @param upperBound + * @return + */ + public Set getStacksInRange(EnergyValue lowerBound, EnergyValue upperBound) { - for (List recipeInputs : RecipeRegistry.getInstance().getRecipeMappings() - .get(recipeOutput)) { - EnergyValue computedValue = EnergyValueHelper - .computeEnergyValueFromRecipe(stackValueMappings, recipeOutput, recipeInputs); + Set filteredItemStacks = new TreeSet<>(Comparators.ENERGY_VALUE_ITEM_STACK_COMPARATOR); - if (computedValue != null) { - if (computedValue.compareTo(lowestValue) < 0) { - lowestValue = computedValue; - } - } else { - if (uncomputedStacks == null) { - uncomputedStacks = new TreeSet(); - } + Set greaterThanLowerBound = getStacksInRange(getEnergyValues(), lowerBound, false); + Set lesserThanUpperBound = getStacksInRange(getEnergyValues(), upperBound, true); - uncomputedStacks.add(recipeOutput); - } - } + if (!greaterThanLowerBound.isEmpty() && !lesserThanUpperBound.isEmpty()) { - if ((lowestValue != null) && (lowestValue.getValue() > 0f)) { - computedStackMap.put(WrappedStack.wrap(recipeOutput.getWrappedObject()), lowestValue); + for (ItemStack itemStack : greaterThanLowerBound) { + if (lesserThanUpperBound.contains(itemStack)) { + filteredItemStacks.add(itemStack); } } + } else if (!greaterThanLowerBound.isEmpty()) { + return greaterThanLowerBound; + } else if (!lesserThanUpperBound.isEmpty()) { + return lesserThanUpperBound; } - return computedStackMap; - } + return filteredItemStacks; + } + + /** + * TODO Finish JavaDoc + * + * @param valueMap + * @param energyValueBound + * @param isUpperBound + * @return + */ + private static Set getStacksInRange(Map valueMap, + EnergyValue energyValueBound, boolean isUpperBound) { + + Set itemStacks = filterForItemStacks(valueMap.keySet()); + + if (valueMap != null) { + if (energyValueBound != null) { + if (isUpperBound) { + return FilterUtils.filterByEnergyValue( + valueMap, + itemStacks, + energyValueBound, + FilterUtils.ValueFilterType.VALUE_LOWER_THAN_BOUND, + Comparators.ENERGY_VALUE_ITEM_STACK_COMPARATOR); + } else { + return FilterUtils.filterByEnergyValue( + valueMap, + itemStacks, + energyValueBound, + FilterUtils.ValueFilterType.VALUE_GREATER_THAN_BOUND, + Comparators.ENERGY_VALUE_ITEM_STACK_COMPARATOR); + } + } + } - public List getStacksInRange(int start, int finish) { - return getStacksInRange(new EnergyValue(start), new EnergyValue(finish)); - } + return new TreeSet<>(Collections.EMPTY_SET); + } + + /** + * Sets an {@link EnergyValue} for the provided {@link Object} (if it can be wrapped in a {@link WrappedStack}. + * Depending on whether or not this is a pre-calculation value assignment it's also possible for the calculated + * energy value map to be recomputed to take into account the new mapping. + * + * @param object the object the energy value is being assigned for + * @param energyValue the energy value being setEnergyValue on the object + * @param phase the {@link Phase} of energy value assignment to set this value for + */ + public void setEnergyValue(Object object, EnergyValue energyValue, Phase phase) { + setEnergyValue(object, energyValue, phase, false); + } + + /** + * Sets an {@link EnergyValue} for the provided {@link Object} (if it can be wrapped in a {@link WrappedStack}. + * Depending on whether or not this is a pre-calculation value assignment it's also possible for the calculated + * energy value map to be recomputed to take into account the new mapping. + * + * @param object the object the energy value is being assigned for + * @param energyValue the energy value being setEnergyValue on the object + * @param phase the {@link Phase} of energy value assignment to set this value for + * @param doRegenValues whether or not the energy value map needs recomputing. Only an option if the energy value is + * being assigned in the PRE_CALCULATION phase + */ + public void setEnergyValue(Object object, EnergyValue energyValue, Phase phase, boolean doRegenValues) { - public List getStacksInRange(float start, float finish) { - return getStacksInRange(new EnergyValue(start), new EnergyValue(finish)); - } - - public List getStacksInRange(EnergyValue start, EnergyValue finish) { - List stacksInRange = new ArrayList(); + if (WrappedStack.canBeWrapped(object) && energyValue != null && Float.compare(energyValue.getValue(), 0f) > 0) { - if (valueMappings != null) { - SortedMap> tailMap = energyValueRegistry.valueMappings.tailMap(start); - SortedMap> headMap = energyValueRegistry.valueMappings.headMap(finish); + WrappedStack wrappedStack = WrappedStack.wrap(object, 1); + EnergyValue factoredEnergyValue = EnergyValue.factor(energyValue, wrappedStack.getStackSize()); - SortedMap> smallerMap; - SortedMap> biggerMap; + if (phase == Phase.PRE_CALCULATION) { + if (!FMLCommonHandler.instance().bus().post( + new EnergyValueEvent.SetEnergyValueEvent( + wrappedStack, + factoredEnergyValue, + Phase.PRE_CALCULATION))) { - if (!tailMap.isEmpty() && !headMap.isEmpty()) { + preCalculationStackValueMap.put(wrappedStack, factoredEnergyValue); - if (tailMap.size() <= headMap.size()) { - smallerMap = tailMap; - biggerMap = headMap; - } else { - smallerMap = headMap; - biggerMap = tailMap; + if (doRegenValues) { + compute(); + } else { + valuesNeedRegeneration = true; + } } + } else if (!FMLCommonHandler.instance().bus().post( + new EnergyValueEvent.SetEnergyValueEvent( + wrappedStack, + factoredEnergyValue, + Phase.POST_CALCULATION))) { - for (EnergyValue value : smallerMap.keySet()) { - if (biggerMap.containsKey(value)) { - for (WrappedStack wrappedStack : energyValueRegistry.valueMappings.get(value)) { - if (wrappedStack.getWrappedObject() instanceof ItemStack - || wrappedStack.getWrappedObject() instanceof FluidStack) { - stacksInRange.add(wrappedStack.getWrappedObject()); - } else if (wrappedStack.getWrappedObject() instanceof OreStack) { - for (ItemStack itemStack : OreDictionary - .getOres(((OreStack) wrappedStack.getWrappedObject()).oreName)) { - stacksInRange.add(itemStack); - } + TreeMap valueMap = new TreeMap<>(stackValueMap); + valueMap.put(wrappedStack, energyValue); + ImmutableSortedMap.Builder stackMappingsBuilder = ImmutableSortedMap + .naturalOrder(); + stackValueMap = stackMappingsBuilder.putAll(valueMap).build(); + + postCalculationStackValueMap.put(wrappedStack, factoredEnergyValue); } - } - } - } + + if (ConfigurationHandler.Settings.energyValueDebugLoggingEnabled) { + LogHelper.info( + ENERGY_VALUE_MARKER, + "[{}] Mod '{}' set a {} value of {} on object '{}' with doRegen = {}", + LoaderHelper.getLoaderState(), + Loader.instance().activeModContainer().getModId(), + phase, + energyValue, + wrappedStack, + doRegenValues); } } + } - return stacksInRange; + /** + * TODO Finish JavaDoc + * + * @param shouldSave + */ + public void setShouldSave(boolean shouldSave) { + this.shouldSave = shouldSave; } - public void loadFromMap(Map stackValueMap) { - if (stackValueMap != null) { - ImmutableSortedMap.Builder stackMappingsBuilder = ImmutableSortedMap - .naturalOrder(); - stackMappingsBuilder.putAll(stackValueMap); - stackMappings = stackMappingsBuilder.build(); + /** + * TODO Finish JavaDoc + * + * This is where the magic happens + */ + public void compute() { - /** - * Resolve value stack mappings from the newly loaded stack mappings - */ - generateValueStackMappings(); - } - } + valuesNeedRegeneration = false; - public void setEnergyValue(WrappedStack wrappedStack, EnergyValue energyValue) { - if (wrappedStack != null && energyValue != null && Float.compare(energyValue.getValue(), 0f) > 0) { - TreeMap stackValueMap = new TreeMap(stackMappings); - stackValueMap.put(wrappedStack, energyValue); + // Initialize the "working copy" energy value map + final Map stackValueMap = new TreeMap<>(); + uncomputedStacks = new TreeSet<>(); - ImmutableSortedMap.Builder stackMappingsBuilder = ImmutableSortedMap - .naturalOrder(); - stackMappingsBuilder.putAll(stackValueMap); - stackMappings = stackMappingsBuilder.build(); + // Load in pre calculation value assignments from file + Map fileValueMap = null; + try { + fileValueMap = SerializationHelper.readMapFromFile(preCalculationValuesFile); + } catch (FileNotFoundException e) { + LogHelper.warn( + ENERGY_VALUE_MARKER, + "No pre calculation energy values were loaded from file - could not find {}", + preCalculationValuesFile.getAbsolutePath()); + } + if (fileValueMap != null) { + for (WrappedStack wrappedStack : fileValueMap.keySet()) { + if (wrappedStack != null && wrappedStack.getWrappedObject() != null + && fileValueMap.get(wrappedStack) != null) { + preCalculationStackValueMap.put(wrappedStack, fileValueMap.get(wrappedStack)); + } + } + } - generateValueStackMappings(); + // Add in all pre-calculation energy value mappings + preCalculationStackValueMap.keySet().stream() + .filter( + wrappedStack -> wrappedStack != null && wrappedStack.getWrappedObject() != null + && preCalculationStackValueMap.get(wrappedStack) != null) + .forEach( + wrappedStack -> stackValueMap.put(wrappedStack, preCalculationStackValueMap.get(wrappedStack))); + + // Calculate values from the known methods to create items, and the pre-calculation value mappings + Map computedStackValueMap = calculateStackValueMap(stackValueMap); + for (WrappedStack wrappedStack : computedStackValueMap.keySet()) { + stackValueMap.put(wrappedStack, computedStackValueMap.get(wrappedStack)); + } + // stackValueMap.putAll(calculateStackValueMap(stackValueMap)); + + // Load in post calculation value assignments from file + fileValueMap = null; + try { + fileValueMap = SerializationHelper.readMapFromFile(postCalculationValuesFile); + } catch (FileNotFoundException e) { + LogHelper.warn( + ENERGY_VALUE_MARKER, + "No post calculation energy values were loaded from file - could not find {}", + postCalculationValuesFile.getAbsolutePath()); + } + if (fileValueMap != null) { + for (WrappedStack wrappedStack : fileValueMap.keySet()) { + if (wrappedStack != null && wrappedStack.getWrappedObject() != null + && fileValueMap.get(wrappedStack) != null) { + postCalculationStackValueMap.put(wrappedStack, fileValueMap.get(wrappedStack)); + } + } } - } - public boolean getShouldRegenNextRestart() { - return shouldRegenNextRestart; - } + // Add in all post-calculation energy value mappings + postCalculationStackValueMap.keySet().stream() + .filter( + wrappedStack -> wrappedStack != null && wrappedStack.getWrappedObject() != null + && postCalculationStackValueMap.get(wrappedStack) != null) + .forEach( + wrappedStack -> stackValueMap + .put(wrappedStack, postCalculationStackValueMap.get(wrappedStack))); - public void setShouldRegenNextRestart(boolean shouldRegenNextRestart) { - this.shouldRegenNextRestart = shouldRegenNextRestart; - } + // Bake the final calculated energy value maps + ImmutableSortedMap.Builder stackMappingsBuilder = ImmutableSortedMap.naturalOrder(); + stackMappingsBuilder.putAll(stackValueMap); + this.stackValueMap = stackMappingsBuilder.build(); + calculateValueStackMap(); - public ImmutableSortedMap getStackValueMap() { - return stackMappings; - } + // Save the results to disk + save(); - public ImmutableSortedMap> getValueStackMap() { - return valueMappings; + // Report the objects for which we were unable to compute an energy value for + if (ConfigurationHandler.Settings.energyValueDebugLoggingEnabled) { + uncomputedStacks.stream().filter(wrappedStack -> getEnergyValue(stackValueMap, wrappedStack, false) == null) + .forEach( + wrappedStack -> LogHelper.info( + ENERGY_VALUE_MARKER, + "Unable to compute an energy value for {}", + wrappedStack)); + } } - public void save() { + /** + * + * @param stackValueMap + * @return + */ + private Map calculateStackValueMap(Map stackValueMap) { - File energyValuesDataDirectory = new File( - FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getSaveHandler() - .getWorldDirectory(), - "data" + File.separator + Reference.LOWERCASE_MOD_ID + File.separator + "energyvalues"); - energyValuesDataDirectory.mkdirs(); - - if (shouldRegenNextRestart) { - File staticEnergyValuesJsonFile = new File(energyValuesDataDirectory, Files.STATIC_ENERGY_VALUES_JSON); - File md5EnergyValuesJsonFile = new File( - energyValuesDataDirectory, - SerializationHelper.getModListMD5() + ".json"); - - // JSON - if (staticEnergyValuesJsonFile.exists()) { - staticEnergyValuesJsonFile.delete(); - } - if (md5EnergyValuesJsonFile.exists()) { - md5EnergyValuesJsonFile.delete(); - } + LogHelper.info(ENERGY_VALUE_MARKER, "Beginning energy value calculation"); + long startingTime = System.nanoTime(); - shouldRegenNextRestart = false; - } else { - SerializationHelper.compressEnergyValueStackMapToFile( - new File(energyValuesDataDirectory, Files.STATIC_ENERGY_VALUES_JSON), - energyValueRegistry.stackMappings); - SerializationHelper.compressEnergyValueStackMapToFile( - new File(energyValuesDataDirectory, SerializationHelper.getModListMD5() + ".json.gz"), - energyValueRegistry.stackMappings); - } - } + Map computedMap = new TreeMap<>(stackValueMap); + Map tempComputedMap = new TreeMap<>(); + int passNumber = 0; - public boolean loadEnergyValueRegistryFromFile() { - - File energyValuesDataDirectory = new File( - FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getSaveHandler() - .getWorldDirectory(), - "data" + File.separator + Reference.LOWERCASE_MOD_ID + File.separator + "energyvalues"); - energyValuesDataDirectory.mkdirs(); - - File staticEnergyValuesFile = new File(energyValuesDataDirectory, Files.STATIC_ENERGY_VALUES_JSON); - File md5EnergyValuesFile = new File( - energyValuesDataDirectory, - SerializationHelper.getModListMD5() + ".json.gz"); - - Map stackValueMap = null; - - if (!Settings.DynamicEnergyValueGeneration.regenerateEnergyValuesWhen.equalsIgnoreCase("Always")) { - if (Settings.DynamicEnergyValueGeneration.regenerateEnergyValuesWhen.equalsIgnoreCase("When Mods Change")) { - if (md5EnergyValuesFile.exists()) { - LogHelper.info( - ENERGY_VALUE_MARKER, - "Attempting to load energy values from file: {}", - md5EnergyValuesFile.getAbsolutePath()); - stackValueMap = SerializationHelper.decompressEnergyValueStackMapFromFile(md5EnergyValuesFile); - } - } else if (Settings.DynamicEnergyValueGeneration.regenerateEnergyValuesWhen.equalsIgnoreCase("Never")) { - if (staticEnergyValuesFile.exists()) { - LogHelper.info( - ENERGY_VALUE_MARKER, - "Attempting to load energy values from file: {}", - staticEnergyValuesFile.getAbsolutePath()); - stackValueMap = SerializationHelper.decompressEnergyValueStackMapFromFile(staticEnergyValuesFile); - } else if (md5EnergyValuesFile.exists()) { - LogHelper.info( - ENERGY_VALUE_MARKER, - "Attempting to load energy values from file: {}", - md5EnergyValuesFile.getAbsolutePath()); - stackValueMap = SerializationHelper.decompressEnergyValueStackMapFromFile(md5EnergyValuesFile); + while ((passNumber == 0 || tempComputedMap.size() != computedMap.size()) && passNumber < 16) { + + long passStartTime = System.nanoTime(); + passNumber++; + computedMap.putAll(tempComputedMap); + + tempComputedMap = new TreeMap<>(computedMap); + for (WrappedStack recipeOutput : RecipeRegistry.INSTANCE.getRecipeMappings().keySet()) { + + WrappedStack unitWrappedStack = WrappedStack.wrap(recipeOutput, 1); + // We won't attempt to recalculate values that already have a pre-calculation value assignment + if (!stackValueMap.containsKey(unitWrappedStack)) { + for (Set recipeInputs : RecipeRegistry.INSTANCE.getRecipeMappings() + .get(recipeOutput)) { + + EnergyValue currentOutputValue = getEnergyValue(tempComputedMap, unitWrappedStack, false); + EnergyValue computedOutputValue = computeFromInputs( + tempComputedMap, + recipeOutput, + recipeInputs); + + if (computedOutputValue != null && computedOutputValue.compareTo(currentOutputValue) < 0) { + + uncomputedStacks.remove(unitWrappedStack); + + if (ConfigurationHandler.Settings.energyValueDebugLoggingEnabled) { + LogHelper.info( + ENERGY_VALUE_MARKER, + "Pass {}: Calculated value {} for object {} with recipe inputs {} and output {}", + passNumber, + computedOutputValue, + unitWrappedStack, + recipeInputs, + recipeOutput); + } + + tempComputedMap.put(unitWrappedStack, computedOutputValue); + } else if (computedOutputValue != null) { + uncomputedStacks.add(unitWrappedStack); + } + } } } - if (stackValueMap != null) { - loadFromMap(stackValueMap); - LogHelper.info(ENERGY_VALUE_MARKER, "Successfully loaded energy values from file"); - return true; - } else { - LogHelper.info(ENERGY_VALUE_MARKER, "No energy value file to load values from, generating new values"); - return false; + long passDuration = System.nanoTime() - passStartTime; + if (ConfigurationHandler.Settings.energyValueDebugLoggingEnabled) { + LogHelper.info( + ENERGY_VALUE_MARKER, + "Pass {}: Calculated {} different values for objects in {} ms", + passNumber, + tempComputedMap.size(), + passDuration / 100000); } - } else { - return false; } - } + long endingTime = System.nanoTime() - startingTime; + LogHelper.info( + ENERGY_VALUE_MARKER, + "Finished energy value calculation - calculated {} new values for objects in {} ms", + computedMap.size() - stackValueMap.size(), + endingTime / 100000); - public String toJson() { - return JSON_SERIALIZER.toJson(this); + return computedMap; } - @Override - public EnergyValueRegistry deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) - throws JsonParseException { + private void calculateValueStackMap() { - if (json.isJsonArray()) { - JsonArray jsonArray = (JsonArray) json; - Map stackValueMap = new TreeMap(); - Iterator iterator = jsonArray.iterator(); + SortedMap> tempValueMap = new TreeMap<>(); - while (iterator.hasNext()) { - JsonElement jsonElement = iterator.next(); - EnergyValueStackMapping energyValueStackMapping = new EnergyValueStackMapping() - .deserialize(jsonElement, typeOfT, context); + for (WrappedStack wrappedStack : getEnergyValues().keySet()) { - if (energyValueStackMapping != null) { - stackValueMap.put(energyValueStackMapping.wrappedStack, energyValueStackMapping.energyValue); - } - } + if (wrappedStack != null) { - ImmutableSortedMap.Builder stackMappingsBuilder = ImmutableSortedMap - .naturalOrder(); - stackMappingsBuilder.putAll(stackValueMap); - stackMappings = stackMappingsBuilder.build(); + EnergyValue energyValue = getEnergyValues().get(wrappedStack); - generateValueStackMappings(); + if (energyValue != null) { + if (tempValueMap.containsKey(energyValue)) { + if (!(tempValueMap.get(energyValue).contains(wrappedStack))) { + tempValueMap.get(energyValue).add(wrappedStack); + } + } else { + tempValueMap.put(energyValue, new TreeSet<>(Arrays.asList(wrappedStack))); + } + } + } } - - return null; + valueStackMap = ImmutableSortedMap.copyOf(tempValueMap); } - @Override - public JsonElement serialize(EnergyValueRegistry energyValueRegistry, Type typeOfSrc, - JsonSerializationContext context) { + private static Set filterForItemStacks(Set wrappedStacks) { - JsonArray jsonEnergyValueRegistry = new JsonArray(); + Set itemStacks = new TreeSet<>(Comparators.ID_COMPARATOR); - for (WrappedStack wrappedStack : energyValueRegistry.stackMappings.keySet()) { - jsonEnergyValueRegistry.add( - EnergyValueStackMapping.jsonSerializer.toJsonTree( - new EnergyValueStackMapping( - wrappedStack, - energyValueRegistry.stackMappings.get(wrappedStack)))); + for (WrappedStack wrappedStack : wrappedStacks) { + if (wrappedStack.getWrappedObject() instanceof ItemStack) { + itemStacks.add((ItemStack) wrappedStack.getWrappedObject()); + } else if (wrappedStack.getWrappedObject() instanceof OreStack) { + itemStacks.addAll(OreDictionary.getOres(((OreStack) wrappedStack.getWrappedObject()).oreName)); + } } - return jsonEnergyValueRegistry; + return itemStacks; } - public void dumpEnergyValueRegistryToLog() { - - dumpEnergyValueRegistryToLog(EnergyValueRegistryProxy.Phase.ALL); - } + /** + * Saves the pre-calculation, post-calculation, and calculated energy value maps to disk + */ + public void save() { - public void dumpEnergyValueRegistryToLog(EnergyValueRegistryProxy.Phase phase) { + /** + * If the current values were synched to us from a server, do not save them to disk as they would override the + * local ones + */ + if (shouldSave) { + if (valuesNeedRegeneration) { + if (energyValuesFile.exists()) { + energyValuesFile.delete(); + } + } else { + SerializationHelper.writeMapToFile(stackValueMap, energyValuesFile); + } + } + SerializationHelper.writeMapToFile(preCalculationStackValueMap, preCalculationValuesFile); + SerializationHelper.writeMapToFile(postCalculationStackValueMap, postCalculationValuesFile); + } + + /** + * Loads the pre-calculation, post-calculation, and calculated energy value maps from disk. In the event that either + * the pre/post calculation maps can not be loaded from disk they will be initialized as empty maps. If the + * calculated energy value map can not be loaded from disk then the values will be computed from the pre/post + * calculation maps + */ + public void load() { + + // Load in pre calculation value assignments from file + Map fileValueMap = null; + try { + fileValueMap = SerializationHelper.readMapFromFile(preCalculationValuesFile); + } catch (FileNotFoundException e) { + LogHelper.warn( + ENERGY_VALUE_MARKER, + "No pre calculation energy values were loaded from file - could not find {}", + preCalculationValuesFile.getAbsolutePath()); + } + if (fileValueMap != null) { + for (WrappedStack wrappedStack : fileValueMap.keySet()) { + if (wrappedStack != null && wrappedStack.getWrappedObject() != null + && fileValueMap.get(wrappedStack) != null) { + preCalculationStackValueMap.put(wrappedStack, fileValueMap.get(wrappedStack)); + } + } + } - LogHelper.info(ENERGY_VALUE_MARKER, "BEGIN DUMPING {} ENERGY VALUE MAPPINGS", phase); - if (phase == EnergyValueRegistryProxy.Phase.PRE_ASSIGNMENT - || phase == EnergyValueRegistryProxy.Phase.PRE_CALCULATION) { - for (WrappedStack wrappedStack : this.preCalculationMappings.keySet()) { - LogHelper.info( - ENERGY_VALUE_MARKER, - "Object: {}, Value: {}", - wrappedStack, - EnergyValueRegistry.getInstance().getStackValueMap().get(wrappedStack)); + // Load in post calculation value assignments from file + fileValueMap = null; + try { + fileValueMap = SerializationHelper.readMapFromFile(postCalculationValuesFile); + } catch (FileNotFoundException e) { + LogHelper.warn( + ENERGY_VALUE_MARKER, + "No post calculation energy values were loaded from file - could not find {}", + postCalculationValuesFile.getAbsolutePath()); + } + if (fileValueMap != null) { + for (WrappedStack wrappedStack : fileValueMap.keySet()) { + if (wrappedStack != null && wrappedStack.getWrappedObject() != null + && fileValueMap.get(wrappedStack) != null) { + postCalculationStackValueMap.put(wrappedStack, fileValueMap.get(wrappedStack)); + } } - } else if (phase == EnergyValueRegistryProxy.Phase.POST_ASSIGNMENT - || phase == EnergyValueRegistryProxy.Phase.POST_CALCULATION) { - if (this.postCalculationMappings != null) { - for (WrappedStack wrappedStack : this.postCalculationMappings.keySet()) { - LogHelper.info( - ENERGY_VALUE_MARKER, - "Object: {}, Value: {}", - wrappedStack, - EnergyValueRegistry.getInstance().getStackValueMap().get(wrappedStack)); - } - } - } else - if (phase == EnergyValueRegistryProxy.Phase.ALL) { - for (WrappedStack wrappedStack : EnergyValueRegistry.getInstance().getStackValueMap().keySet()) { - LogHelper.info( - ENERGY_VALUE_MARKER, - "Object: {}, Value: {}", - wrappedStack, - EnergyValueRegistry.getInstance().getStackValueMap().get(wrappedStack)); + } + + // Load the calculated energy values assignments from file + fileValueMap = null; + try { + fileValueMap = SerializationHelper.readMapFromFile(energyValuesFile); + } catch (FileNotFoundException e) { + LogHelper.warn( + "No calculated energy values were loaded from file - could not find {}", + energyValuesFile.getAbsolutePath()); + LogHelper.info("Recomputing energy values", energyValuesFile.getAbsolutePath()); + compute(); + } + if (fileValueMap != null) { + ImmutableSortedMap.Builder stackMapBuilder = ImmutableSortedMap.naturalOrder(); + for (WrappedStack wrappedStack : fileValueMap.keySet()) { + if (wrappedStack != null && wrappedStack.getWrappedObject() != null + && fileValueMap.get(wrappedStack) != null) { + stackMapBuilder.put(wrappedStack, fileValueMap.get(wrappedStack)); } } - LogHelper.info(ENERGY_VALUE_MARKER, "END DUMPING {} ENERGY VALUE MAPPINGS", phase); + stackValueMap = stackMapBuilder.build(); + calculateValueStackMap(); + } + } + + /** + * + * + * @param valueMap + */ + public void load(Map valueMap) { + + if (valueMap != null) { + + setShouldSave(false); + ImmutableSortedMap.Builder stackMappingsBuilder = ImmutableSortedMap + .naturalOrder(); + valueMap.keySet().stream() + .filter( + wrappedStack -> wrappedStack != null && wrappedStack.getWrappedObject() != null + && valueMap.get(wrappedStack) != null) + .forEach(wrappedStack -> stackMappingsBuilder.put(wrappedStack, valueMap.get(wrappedStack))); + stackValueMap = stackMappingsBuilder.build(); + calculateValueStackMap(); + } } } diff --git a/src/main/java/com/pahimar/ee3/exchange/EnergyValueStackMapping.java b/src/main/java/com/pahimar/ee3/exchange/EnergyValueStackMapping.java deleted file mode 100644 index 8e37cd65..00000000 --- a/src/main/java/com/pahimar/ee3/exchange/EnergyValueStackMapping.java +++ /dev/null @@ -1,122 +0,0 @@ -package com.pahimar.ee3.exchange; - -import java.lang.reflect.Type; - -import com.google.gson.*; -import com.pahimar.ee3.api.exchange.EnergyValue; - -public class EnergyValueStackMapping - implements JsonSerializer, JsonDeserializer { - - public static final Gson jsonSerializer = (new GsonBuilder()).setPrettyPrinting() - .registerTypeAdapter(EnergyValueStackMapping.class, new EnergyValueStackMapping()) - .registerTypeAdapter(EnergyValue.class, new EnergyValue()) - .registerTypeAdapter(WrappedStack.class, new WrappedStack()).create(); - - public final WrappedStack wrappedStack; - public final EnergyValue energyValue; - - public EnergyValueStackMapping() { - wrappedStack = null; - energyValue = null; - } - - public EnergyValueStackMapping(WrappedStack wrappedStack, EnergyValue energyValue) { - this.wrappedStack = wrappedStack; - this.energyValue = energyValue; - } - - public static EnergyValueStackMapping createFromJson(String jsonStackValueMapping) { - try { - return jsonSerializer.fromJson(jsonStackValueMapping, EnergyValueStackMapping.class); - } catch (JsonSyntaxException exception) { - exception.printStackTrace(); - } catch (JsonParseException exception) { - exception.printStackTrace(); - } - - return null; - } - - public String toJson() { - return jsonSerializer.toJson(this); - } - - /** - * Gson invokes this call-back method during deserialization when it encounters a field of the specified type. - *

- * In the implementation of this call-back method, you should consider invoking - * {@link com.google.gson.JsonDeserializationContext#deserialize(com.google.gson.JsonElement, java.lang.reflect.Type)} - * method to create objects for any non-trivial field of the returned object. However, you should never invoke it on - * the the same type passing {@code jsonElement} since that will cause an infinite loop (Gson will call your - * call-back method again). - * - * @param jsonElement The Json data being deserialized - * @param typeOfT The type of the Object to deserialize to - * @param context - * @return a deserialized object of the specified type typeOfT which is a subclass of {@code T} - * @throws com.google.gson.JsonParseException if jsonElement is not in the expected format of {@code typeofT} - */ - @Override - public EnergyValueStackMapping deserialize(JsonElement jsonElement, Type typeOfT, - JsonDeserializationContext context) throws JsonParseException { - if (!jsonElement.isJsonPrimitive()) { - JsonObject jsonStackValueMapping = (JsonObject) jsonElement; - - WrappedStack wrappedStack = null; - EnergyValue energyValue = null; - - if (jsonStackValueMapping.get("wrappedStack") != null) { - try { - wrappedStack = new WrappedStack() - .deserialize(jsonStackValueMapping.get("wrappedStack").getAsJsonObject(), typeOfT, context); - } catch (JsonParseException e) { - - } - } - - if (jsonStackValueMapping.get("energyValue") != null) { - try { - energyValue = new EnergyValue() - .deserialize(jsonStackValueMapping.get("energyValue").getAsJsonObject(), typeOfT, context); - } catch (JsonParseException e) { - - } - } - - if (wrappedStack != null && energyValue != null) { - return new EnergyValueStackMapping(wrappedStack, energyValue); - } else { - return null; - } - } - - return null; - } - - /** - * Gson invokes this call-back method during serialization when it encounters a field of the specified type. - *

- *

- * In the implementation of this call-back method, you should consider invoking - * {@link com.google.gson.JsonSerializationContext#serialize(Object, java.lang.reflect.Type)} method to create - * JsonElements for any non-trivial field of the {@code src} object. However, you should never invoke it on the - * {@code src} object itself since that will cause an infinite loop (Gson will call your call-back method again). - *

- * - * @param energyValueStackMapping the object that needs to be converted to Json. - * @param typeOfSrc the actual type (fully genericized version) of the source object. - * @param context - * @return a JsonElement corresponding to the specified object. - */ - @Override - public JsonElement serialize(EnergyValueStackMapping energyValueStackMapping, Type typeOfSrc, - JsonSerializationContext context) { - JsonObject jsonStackValueMapping = new JsonObject(); - - jsonStackValueMapping.add("wrappedStack", jsonSerializer.toJsonTree(energyValueStackMapping.wrappedStack)); - jsonStackValueMapping.add("energyValue", jsonSerializer.toJsonTree(energyValueStackMapping.energyValue)); - - return jsonStackValueMapping; - } -} diff --git a/src/main/java/com/pahimar/ee3/exchange/JsonFluidStack.java b/src/main/java/com/pahimar/ee3/exchange/JsonFluidStack.java deleted file mode 100644 index 2b9c6a59..00000000 --- a/src/main/java/com/pahimar/ee3/exchange/JsonFluidStack.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.pahimar.ee3.exchange; - -import java.lang.reflect.Type; - -import net.minecraft.nbt.JsonToNBT; -import net.minecraft.nbt.NBTBase; -import net.minecraft.nbt.NBTException; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; - -import com.google.gson.*; - -public class JsonFluidStack implements JsonSerializer, JsonDeserializer { - - public static final Gson jsonSerializer = (new GsonBuilder()) - .registerTypeAdapter(JsonFluidStack.class, new JsonFluidStack()).create(); - - public Fluid fluid; - public int amount; - public NBTTagCompound tag; - - public JsonFluidStack() { - this.fluid = null; - this.amount = 0; - this.tag = null; - } - - public JsonFluidStack(FluidStack fluidStack) { - this.fluid = fluidStack.getFluid(); - this.amount = fluidStack.amount; - this.tag = fluidStack.tag; - } - - @Override - public JsonFluidStack deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) - throws JsonParseException { - if (json.isJsonObject()) { - JsonObject jsonObject = (JsonObject) json; - JsonFluidStack jsonFluidStack = new JsonFluidStack(); - - if (jsonObject.has("fluidName")) { - jsonFluidStack.fluid = FluidRegistry.getFluid(jsonObject.get("fluidName").getAsString()); - } else { - throw new JsonParseException(""); // TODO Exception message - } - - if (jsonObject.has("amount")) { - jsonFluidStack.amount = jsonObject.get("amount").getAsInt(); - } else { - throw new JsonParseException(""); // TODO Exception message - } - - if (jsonObject.has("tag")) { - try { - NBTBase nbtBase = JsonToNBT.func_150315_a(jsonObject.get("tag").getAsString()); - - if (nbtBase instanceof NBTTagCompound) { - jsonFluidStack.tag = (NBTTagCompound) nbtBase; - } - } catch (NBTException e) { - throw new JsonParseException(e.getMessage(), e.getCause()); - } - } - - return jsonFluidStack; - } - - return null; - } - - @Override - public JsonElement serialize(JsonFluidStack src, Type typeOfSrc, JsonSerializationContext context) { - JsonObject jsonObject = new JsonObject(); - - jsonObject.addProperty("fluidName", src.fluid.getName()); - jsonObject.addProperty("amount", src.amount); - - if (src.tag != null) { - jsonObject.addProperty("tag", src.tag.toString()); - } - - return jsonObject; - } - - @Override - public String toString() { - return String.format("fluid: %s, amount: %s, tag: %s", fluid, amount, tag); - } -} diff --git a/src/main/java/com/pahimar/ee3/exchange/JsonItemStack.java b/src/main/java/com/pahimar/ee3/exchange/JsonItemStack.java deleted file mode 100644 index cf6b8a83..00000000 --- a/src/main/java/com/pahimar/ee3/exchange/JsonItemStack.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.pahimar.ee3.exchange; - -import java.lang.reflect.Type; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.JsonToNBT; -import net.minecraft.nbt.NBTBase; -import net.minecraft.nbt.NBTException; -import net.minecraft.nbt.NBTTagCompound; - -import com.google.gson.*; - -public class JsonItemStack implements JsonSerializer, JsonDeserializer { - - public static final Gson jsonSerializer = (new GsonBuilder()) - .registerTypeAdapter(JsonItemStack.class, new JsonItemStack()).create(); - - public String itemName; - public int itemDamage; - public NBTTagCompound itemNBTTagCompound; - - public JsonItemStack() { - this.itemName = null; - this.itemDamage = 0; - this.itemNBTTagCompound = null; - } - - public JsonItemStack(ItemStack itemStack) { - this.itemName = Item.itemRegistry.getNameForObject(itemStack.getItem()); - this.itemDamage = itemStack.getItemDamage(); - if (itemStack.stackTagCompound != null) { - this.itemNBTTagCompound = itemStack.getTagCompound(); - } - } - - @Override - public JsonItemStack deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) - throws JsonParseException { - if (json.isJsonObject()) { - JsonObject jsonObject = (JsonObject) json; - JsonItemStack jsonItemStack = new JsonItemStack(); - - if (jsonObject.has("itemName")) { - jsonItemStack.itemName = jsonObject.get("itemName").getAsString(); - } else { - throw new JsonParseException(""); // TODO Exception message - } - - if (jsonObject.has("itemDamage")) { - jsonItemStack.itemDamage = jsonObject.get("itemDamage").getAsInt(); - } else { - throw new JsonParseException(""); // TODO Exception message - } - - if (jsonObject.has("itemNBTTagCompound")) { - try { - NBTBase nbtBase = JsonToNBT.func_150315_a(jsonObject.get("itemNBTTagCompound").getAsString()); - - if (nbtBase instanceof NBTTagCompound) { - jsonItemStack.itemNBTTagCompound = (NBTTagCompound) nbtBase; - } - } catch (NBTException e) { - throw new JsonParseException(e.getMessage(), e.getCause()); - } - } - - return jsonItemStack; - } - - return null; - } - - @Override - public JsonElement serialize(JsonItemStack src, Type typeOfSrc, JsonSerializationContext context) { - JsonObject jsonObject = new JsonObject(); - - jsonObject.addProperty("itemName", src.itemName); - jsonObject.addProperty("itemDamage", src.itemDamage); - - if (src.itemNBTTagCompound != null) { - jsonObject.addProperty("itemNBTTagCompound", src.itemNBTTagCompound.toString()); - } - - return jsonObject; - } - - @Override - public String toString() { - return String.format( - "itemName: %s, itemDamage: %s, itemNBTTagCompound: %s", - itemName, - itemDamage, - itemNBTTagCompound); - } -} diff --git a/src/main/java/com/pahimar/ee3/exchange/OreStack.java b/src/main/java/com/pahimar/ee3/exchange/OreStack.java index b153fe06..6cd5da46 100644 --- a/src/main/java/com/pahimar/ee3/exchange/OreStack.java +++ b/src/main/java/com/pahimar/ee3/exchange/OreStack.java @@ -1,36 +1,36 @@ package com.pahimar.ee3.exchange; -import java.util.*; +import java.util.Arrays; +import java.util.Collection; +import java.util.Comparator; -import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.oredict.OreDictionary; import com.pahimar.ee3.reference.Comparators; +import com.pahimar.ee3.util.FilterUtils; -public class OreStack implements Comparable { +public final class OreStack implements Comparable { public String oreName; public int stackSize; - public static Comparator comparator = new Comparator() { - - @Override - public int compare(OreStack oreStack1, OreStack oreStack2) { - if (oreStack1 != null && oreStack1.oreName != null) { - if (oreStack2 != null && oreStack2.oreName != null) { - if (oreStack1.oreName.equalsIgnoreCase(oreStack2.oreName)) { - return oreStack1.stackSize - oreStack2.stackSize; - } else { - return oreStack1.oreName.compareToIgnoreCase(oreStack2.oreName); - } + + public static Comparator comparator = (oreStack1, oreStack2) -> { + if (oreStack1 != null && oreStack1.oreName != null) { + if (oreStack2 != null && oreStack2.oreName != null) { + if (oreStack1.oreName.equalsIgnoreCase(oreStack2.oreName)) { + return oreStack1.stackSize - oreStack2.stackSize; } else { - return -1; + return oreStack1.oreName.compareToIgnoreCase(oreStack2.oreName); } } else { - if (oreStack2 != null) { - return 1; - } else { - return 0; - } + return -1; + } + } else { + if (oreStack2 != null) { + return 1; + } else { + return 0; } } }; @@ -46,7 +46,13 @@ public OreStack(String oreName, int stackSize) { this.stackSize = stackSize; } + public OreStack(OreStack oreStack) { + this.oreName = oreStack.oreName; + this.stackSize = oreStack.stackSize; + } + public static boolean compareOreNames(OreStack oreStack1, OreStack oreStack2) { + if (oreStack1 != null && oreStack2 != null) { if ((oreStack1.oreName != null) && (oreStack2.oreName != null)) { return oreStack1.oreName.equalsIgnoreCase(oreStack2.oreName); @@ -56,39 +62,17 @@ public static boolean compareOreNames(OreStack oreStack1, OreStack oreStack2) { return false; } - public static OreStack getOreStackFromList(Object... objects) { - return getOreStackFromList(Arrays.asList(objects)); + public static OreStack getOreStackFrom(Object... objects) { + return getOreStackFrom(Arrays.asList(objects)); } - public static OreStack getOreStackFromList(List objectList) { - if (objectList.size() > 0) { - Map oreNameCountMap = new TreeMap(Comparators.stringComparator); - for (Object listElement : objectList) { - if (listElement instanceof ItemStack) { - ItemStack itemStack = (ItemStack) listElement; - - for (String oreName : CachedOreDictionary.getInstance().getOreNamesForItemStack(itemStack)) { - if (oreNameCountMap.containsKey(oreName)) { - oreNameCountMap.put(oreName, oreNameCountMap.get(oreName) + 1); - } else { - oreNameCountMap.put(oreName, 1); - } - } - } - } - - List candidateOreStacks = new ArrayList(); - for (String oreName : oreNameCountMap.keySet()) { - if (oreNameCountMap.get(oreName) == objectList.size()) { - candidateOreStacks.add(new OreStack(oreName)); - } - } + public static OreStack getOreStackFrom(Collection objects) { - if (candidateOreStacks.size() == 1) { - return candidateOreStacks.get(0); + for (String oreName : OreDictionary.getOreNames()) { + if (Comparators.ITEM_STACK_COLLECTION_COMPARATOR + .compare(FilterUtils.filterForItemStacks(objects), OreDictionary.getOres(oreName)) == 0) { + return new OreStack(oreName, 1); } - - return null; } return null; @@ -104,17 +88,20 @@ public boolean equals(Object object) { } public NBTTagCompound writeToNBT(NBTTagCompound nbtTagCompound) { + nbtTagCompound.setString("oreName", oreName); nbtTagCompound.setInteger("stackSize", stackSize); return nbtTagCompound; } public void readFromNBT(NBTTagCompound nbtTagCompound) { + this.oreName = nbtTagCompound.getString("oreName"); this.stackSize = nbtTagCompound.getInteger("stackSize"); } public static OreStack loadOreStackFromNBT(NBTTagCompound nbtTagCompound) { + OreStack oreStack = new OreStack(); oreStack.readFromNBT(nbtTagCompound); return oreStack.oreName != null ? oreStack : null; diff --git a/src/main/java/com/pahimar/ee3/exchange/WrappedStack.java b/src/main/java/com/pahimar/ee3/exchange/WrappedStack.java index 90cfabbf..1d82ccde 100644 --- a/src/main/java/com/pahimar/ee3/exchange/WrappedStack.java +++ b/src/main/java/com/pahimar/ee3/exchange/WrappedStack.java @@ -1,6 +1,5 @@ package com.pahimar.ee3.exchange; -import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Comparator; import java.util.List; @@ -8,31 +7,25 @@ import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; -import com.google.gson.*; import com.pahimar.ee3.util.FluidHelper; -import com.pahimar.ee3.util.ItemHelper; +import com.pahimar.ee3.util.ItemStackUtils; -public class WrappedStack - implements Comparable, JsonDeserializer, JsonSerializer { +public final class WrappedStack implements Comparable { - public static final Gson jsonSerializer = (new GsonBuilder()).setPrettyPrinting() - .registerTypeAdapter(WrappedStack.class, new WrappedStack()).create(); - - private final String objectType; private final Object wrappedStack; private int stackSize; public WrappedStack() { - objectType = null; + stackSize = -1; wrappedStack = null; } private WrappedStack(Object object) { + if (object instanceof Item) { object = new ItemStack((Item) object); } else if (object instanceof Block) { @@ -42,126 +35,122 @@ private WrappedStack(Object object) { } if (object instanceof ItemStack) { + if (((ItemStack) object).getItem() != null) { - ItemStack itemStackObject = (ItemStack) object; - ItemStack itemStack = new ItemStack( - itemStackObject.getItem(), - itemStackObject.stackSize, - itemStackObject.getItemDamage()); - if (itemStackObject.stackTagCompound != null) { - itemStack.stackTagCompound = (NBTTagCompound) itemStackObject.stackTagCompound.copy(); - } - objectType = "itemstack"; - stackSize = itemStack.stackSize; - itemStack.stackSize = 1; - wrappedStack = itemStack; + + stackSize = ((ItemStack) object).stackSize; + wrappedStack = ItemStackUtils.clone((ItemStack) object, 1); } else { - objectType = null; + stackSize = -1; wrappedStack = null; } } else if (object instanceof OreStack) { - OreStack oreStack = (OreStack) object; - objectType = "orestack"; + + OreStack oreStack = new OreStack((OreStack) object); stackSize = oreStack.stackSize; oreStack.stackSize = 1; wrappedStack = oreStack; } else if (object instanceof ArrayList) { + ArrayList objectList = (ArrayList) object; - OreStack possibleOreStack = OreStack.getOreStackFromList(objectList); + OreStack possibleOreStack = OreStack.getOreStackFrom(objectList); if (possibleOreStack != null) { - objectType = "orestack"; + stackSize = possibleOreStack.stackSize; possibleOreStack.stackSize = 1; wrappedStack = possibleOreStack; } else { - objectType = null; + stackSize = -1; wrappedStack = null; } } else if (object instanceof FluidStack) { + FluidStack fluidStack = ((FluidStack) object).copy(); - objectType = "fluidstack"; stackSize = fluidStack.amount; fluidStack.amount = 1; wrappedStack = fluidStack; } else if (object instanceof WrappedStack) { + WrappedStack wrappedStackObject = (WrappedStack) object; if (wrappedStackObject.getWrappedObject() != null) { - this.objectType = wrappedStackObject.objectType; + this.stackSize = wrappedStackObject.stackSize; this.wrappedStack = wrappedStackObject.wrappedStack; } else { - objectType = null; + stackSize = -1; wrappedStack = null; } } else { - objectType = null; + stackSize = -1; wrappedStack = null; } } private WrappedStack(Object object, int stackSize) { + if (object instanceof Item) { + object = new ItemStack((Item) object); } else if (object instanceof Block) { + object = new ItemStack((Block) object); } else if (object instanceof Fluid) { + object = new FluidStack((Fluid) object, 1000); } if (object instanceof ItemStack) { - ItemStack itemStack = ((ItemStack) object).copy(); - objectType = "itemstack"; + this.stackSize = stackSize; - itemStack.stackSize = 1; - wrappedStack = itemStack; + wrappedStack = ItemStackUtils.clone((ItemStack) object, 1); } else if (object instanceof OreStack) { - OreStack oreStack = (OreStack) object; - objectType = "orestack"; + + OreStack oreStack = new OreStack((OreStack) object); this.stackSize = stackSize; oreStack.stackSize = 1; wrappedStack = oreStack; } else if (object instanceof ArrayList) { - ArrayList objectList = (ArrayList) object; - OreStack possibleOreStack = OreStack.getOreStackFromList(objectList); + OreStack possibleOreStack = OreStack.getOreStackFrom((ArrayList) object); if (possibleOreStack != null) { - objectType = "orestack"; + this.stackSize = stackSize; possibleOreStack.stackSize = 1; wrappedStack = possibleOreStack; } else { - objectType = null; + this.stackSize = -1; wrappedStack = null; } } else if (object instanceof FluidStack) { - FluidStack fluidStack = (FluidStack) object; - objectType = "fluidstack"; + + FluidStack fluidStack = ((FluidStack) object).copy(); this.stackSize = stackSize; fluidStack.amount = 1; wrappedStack = fluidStack; } else if (object instanceof WrappedStack) { + WrappedStack wrappedStackObject = (WrappedStack) object; if (wrappedStackObject.getWrappedObject() != null) { - this.objectType = wrappedStackObject.objectType; + this.stackSize = stackSize; this.wrappedStack = wrappedStackObject.wrappedStack; } else { - objectType = null; + this.stackSize = -1; wrappedStack = null; } } else { - objectType = null; + this.stackSize = -1; wrappedStack = null; } @@ -172,18 +161,21 @@ public Object getWrappedObject() { } public static boolean canBeWrapped(Object object) { + if (object instanceof WrappedStack) { return true; } else if (object instanceof Item || object instanceof Block) { return true; } else if (object instanceof ItemStack) { + if (((ItemStack) object).getItem() != null) { return true; } } else if (object instanceof OreStack) { return true; } else if (object instanceof List) { - if (OreStack.getOreStackFromList((List) object) != null) { + + if (OreStack.getOreStackFrom((List) object) != null) { return true; } } else if (object instanceof Fluid || object instanceof FluidStack) { @@ -202,6 +194,7 @@ public void setStackSize(int stackSize) { } public static WrappedStack wrap(Object object) { + if (canBeWrapped(object)) { return new WrappedStack(object); } @@ -210,6 +203,7 @@ public static WrappedStack wrap(Object object) { } public static WrappedStack wrap(Object object, int stackSize) { + if (canBeWrapped(object)) { return new WrappedStack(object, stackSize); } @@ -217,197 +211,19 @@ public static WrappedStack wrap(Object object, int stackSize) { return null; } - public static WrappedStack createFromJson(String jsonWrappedObject) throws JsonParseException { - try { - return jsonSerializer.fromJson(jsonWrappedObject, WrappedStack.class); - } catch (JsonSyntaxException exception) { - exception.printStackTrace(); - } catch (JsonParseException exception) { - exception.printStackTrace(); - } - - return null; - } - - @SuppressWarnings("unused") - public String toJson() { - return jsonSerializer.toJson(this); - } - - /** - * Gson invokes this call-back method during deserialization when it encounters a field of the specified type. - *

- * In the implementation of this call-back method, you should consider invoking - * {@link com.google.gson.JsonDeserializationContext#deserialize(com.google.gson.JsonElement, java.lang.reflect.Type)} - * method to create objects for any non-trivial field of the returned object. However, you should never invoke it on - * the the same type passing {@code jsonElement} since that will cause an infinite loop (Gson will call your - * call-back method again). - * - * @param jsonElement The Json data being deserialized - * @param typeOfT The type of the Object to deserialize to - * @param context - * @return a deserialized object of the specified type typeOfT which is a subclass of {@code T} - * @throws com.google.gson.JsonParseException if jsonElement is not in the expected format of {@code typeofT} - */ - @Override - public WrappedStack deserialize(JsonElement jsonElement, Type typeOfT, JsonDeserializationContext context) - throws JsonParseException { - if (!jsonElement.isJsonPrimitive()) { - JsonObject jsonWrappedStack = (JsonObject) jsonElement; - - int stackSize = 1; - String objectType = null; - Object stackObject = null; - - if (jsonWrappedStack.get("type") != null) { - objectType = jsonWrappedStack.get("type").getAsString(); - } - - if (jsonWrappedStack.get("stackSize") != null) { - stackSize = jsonWrappedStack.get("stackSize").getAsInt(); - } - - if (jsonWrappedStack.get("objectData") != null && !jsonWrappedStack.get("objectData").isJsonPrimitive()) { - if (objectType != null) { - if (objectType.equalsIgnoreCase("ItemStack")) { - JsonItemStack jsonItemStack = JsonItemStack.jsonSerializer - .fromJson(jsonWrappedStack.get("objectData"), JsonItemStack.class); - ItemStack itemStack = null; - Item item = (Item) Item.itemRegistry.getObject(jsonItemStack.itemName); - if (stackSize > 0 && item != null) { - itemStack = new ItemStack(item, stackSize, jsonItemStack.itemDamage); - if (jsonItemStack.itemNBTTagCompound != null) { - itemStack.stackTagCompound = jsonItemStack.itemNBTTagCompound; - } - } - stackObject = itemStack; - } else if (objectType.equalsIgnoreCase("OreStack")) { - OreStack oreStack = jsonSerializer.fromJson(jsonWrappedStack.get("objectData"), OreStack.class); - - if (stackSize > 0) { - oreStack.stackSize = stackSize; - } - stackObject = oreStack; - } else if (objectType.equalsIgnoreCase("FluidStack")) { - JsonFluidStack jsonFluidStack = JsonFluidStack.jsonSerializer - .fromJson(jsonWrappedStack.get("objectData"), JsonFluidStack.class); - FluidStack fluidStack = new FluidStack( - jsonFluidStack.fluid, - jsonFluidStack.amount, - jsonFluidStack.tag); - - if (stackSize > 0) { - fluidStack.amount = stackSize; - } - stackObject = fluidStack; - } - } - } - - if (stackObject != null) { - return new WrappedStack(stackObject); - } else { - throw new JsonParseException( - String.format( - "Unable to parse a wrappable stack object from the provided json: %s", - jsonElement.toString())); - } - } else { - throw new JsonParseException( - String.format( - "Unable to parse a wrappable stack object from the provided json: %s", - jsonElement.toString())); - } - } - - /** - * Gson invokes this call-back method during serialization when it encounters a field of the specified type. - *

- *

- * In the implementation of this call-back method, you should consider invoking - * {@link com.google.gson.JsonSerializationContext#serialize(Object, java.lang.reflect.Type)} method to create - * JsonElements for any non-trivial field of the {@code wrappedStack} object. However, you should never invoke it on - * the {@code wrappedStack} object itself since that will cause an infinite loop (Gson will call your call-back - * method again). - *

- * - * @param wrappedStack the object that needs to be converted to Json. - * @param typeOfSrc the actual type (fully genericized version) of the source object. - * @param context - * @return a JsonElement corresponding to the specified object. - */ - @Override - public JsonElement serialize(WrappedStack wrappedStack, Type typeOfSrc, JsonSerializationContext context) { - JsonObject jsonWrappedStack = new JsonObject(); - - Gson gson = new Gson(); - - jsonWrappedStack.addProperty("type", wrappedStack.objectType); - jsonWrappedStack.addProperty("stackSize", wrappedStack.stackSize); - - if (wrappedStack.wrappedStack instanceof ItemStack) { - JsonItemStack jsonItemStack = new JsonItemStack(); - jsonItemStack.itemName = Item.itemRegistry - .getNameForObject(((ItemStack) wrappedStack.wrappedStack).getItem()); - jsonItemStack.itemDamage = ((ItemStack) wrappedStack.wrappedStack).getItemDamage(); - if (((ItemStack) wrappedStack.wrappedStack).stackTagCompound != null) { - jsonItemStack.itemNBTTagCompound = ((ItemStack) wrappedStack.wrappedStack).stackTagCompound; - } - jsonWrappedStack - .add("objectData", JsonItemStack.jsonSerializer.toJsonTree(jsonItemStack, JsonItemStack.class)); - } else if (wrappedStack.wrappedStack instanceof OreStack) { - jsonWrappedStack.add("objectData", gson.toJsonTree(wrappedStack.wrappedStack, OreStack.class)); - } else if (wrappedStack.wrappedStack instanceof FluidStack) { - JsonFluidStack jsonFluidStack = new JsonFluidStack((FluidStack) wrappedStack.wrappedStack); - jsonWrappedStack - .add("objectData", JsonFluidStack.jsonSerializer.toJsonTree(jsonFluidStack, JsonFluidStack.class)); - } - - return jsonWrappedStack; - } - - /** - * - */ - @Override - public int hashCode() { - int hashCode = 1; - hashCode = (37 * hashCode) + stackSize; - - if (wrappedStack instanceof ItemStack) { - hashCode = (37 * hashCode) + Item.getIdFromItem(((ItemStack) wrappedStack).getItem()); - hashCode = (37 * hashCode) + ((ItemStack) wrappedStack).getItemDamage(); - - if (((ItemStack) wrappedStack).getTagCompound() != null) { - hashCode = (37 * hashCode) + ((ItemStack) wrappedStack).getTagCompound().hashCode(); - } - } else if (wrappedStack instanceof OreStack) { - if (((OreStack) wrappedStack).oreName != null) { - hashCode = (37 * hashCode) + ((OreStack) wrappedStack).oreName.hashCode(); - } - } else if (wrappedStack instanceof FluidStack) { - hashCode = (37 * hashCode) + wrappedStack.hashCode(); - - if (((FluidStack) wrappedStack).tag != null) { - hashCode = (37 * hashCode) + ((FluidStack) wrappedStack).tag.hashCode(); - } - } - - return hashCode; - } - @Override public boolean equals(Object object) { return object instanceof WrappedStack && (this.compareTo((WrappedStack) object) == 0); } - /* + /** * Sort order (class-wise) goes ItemStack, OreStack, EnergyStack, FluidStack, null + * * @see java.lang.Comparable#compareTo(java.lang.Object) */ @Override public int compareTo(WrappedStack wrappedStack) { - return comparator.compare(this, wrappedStack); + return COMPARATOR.compare(this, wrappedStack); } /** @@ -415,11 +231,18 @@ public int compareTo(WrappedStack wrappedStack) { */ @Override public String toString() { + if (wrappedStack instanceof ItemStack) { ItemStack itemStack = (ItemStack) wrappedStack; - String unlocalizedName = ""; + String unlocalizedName = null; try { - unlocalizedName = itemStack.getUnlocalizedName(); + if (itemStack.getItem() != null) { + unlocalizedName = Item.itemRegistry.getNameForObject(itemStack.getItem()); + } + + if (unlocalizedName == null) { + unlocalizedName = itemStack.getUnlocalizedName(); + } } catch (ArrayIndexOutOfBoundsException e) { unlocalizedName = "no-name"; } @@ -436,42 +259,66 @@ public String toString() { } } else if (wrappedStack instanceof OreStack) { OreStack oreStack = (OreStack) wrappedStack; - return String.format("%sxoreStack.%s", stackSize, oreStack.oreName); + return String.format("%sxoreStack[%s]", stackSize, oreStack.oreName); } else if (wrappedStack instanceof FluidStack) { FluidStack fluidStack = (FluidStack) wrappedStack; - return String.format("%sxfluidStack.%s", stackSize, fluidStack.getFluid().getName()); + return String.format("%sxfluidStack[%s]", stackSize, fluidStack.getFluid().getName()); } else { return "null-wrappedstack"; } } - public static Comparator comparator = new Comparator() { + public static final Comparator COMPARATOR = new Comparator() { @Override public int compare(WrappedStack wrappedStack1, WrappedStack wrappedStack2) { if (wrappedStack1.wrappedStack instanceof ItemStack) { + if (wrappedStack2.wrappedStack instanceof ItemStack) { - return ItemHelper + + int compareResult = ItemStackUtils .compare((ItemStack) wrappedStack1.wrappedStack, (ItemStack) wrappedStack2.wrappedStack); + + if (compareResult == 0) { + return wrappedStack1.stackSize - wrappedStack2.stackSize; + } else { + return compareResult; + } } else { return 1; } } else if (wrappedStack1.wrappedStack instanceof OreStack) { + if (wrappedStack2.wrappedStack instanceof ItemStack) { return -1; } else if (wrappedStack2.wrappedStack instanceof OreStack) { - return OreStack + + int compareResult = OreStack .compare((OreStack) wrappedStack1.wrappedStack, (OreStack) wrappedStack2.wrappedStack); + + if (compareResult == 0) { + return wrappedStack1.stackSize - wrappedStack2.stackSize; + } else { + return compareResult; + } } else { return 1; } } else if (wrappedStack1.wrappedStack instanceof FluidStack) { + if (wrappedStack2.wrappedStack instanceof ItemStack || wrappedStack2.wrappedStack instanceof OreStack) { return -1; } else if (wrappedStack2.wrappedStack instanceof FluidStack) { - return FluidHelper + + int compareResult = FluidHelper .compare((FluidStack) wrappedStack1.wrappedStack, (FluidStack) wrappedStack2.wrappedStack); + + if (compareResult == 0) { + return wrappedStack1.stackSize - wrappedStack2.stackSize; + } else { + return compareResult; + } } else { return 1; } diff --git a/src/main/java/com/pahimar/ee3/handler/AbilityRegistrySerializationHandler.java b/src/main/java/com/pahimar/ee3/handler/AbilityRegistrySerializationHandler.java deleted file mode 100644 index 823c6830..00000000 --- a/src/main/java/com/pahimar/ee3/handler/AbilityRegistrySerializationHandler.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.pahimar.ee3.handler; - -import com.pahimar.ee3.knowledge.AbilityRegistry; - -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.TickEvent; - -public class AbilityRegistrySerializationHandler { - - @SubscribeEvent - public void onServerTick(TickEvent.ServerTickEvent event) { - if (event.phase == TickEvent.Phase.END) { - if (FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getWorldTime() % 600 == 0) { - AbilityRegistry.getInstance().save(); - } - } - } -} diff --git a/src/main/java/com/pahimar/ee3/handler/ConfigurationHandler.java b/src/main/java/com/pahimar/ee3/handler/ConfigurationHandler.java index 3aeba3f0..9842e06f 100644 --- a/src/main/java/com/pahimar/ee3/handler/ConfigurationHandler.java +++ b/src/main/java/com/pahimar/ee3/handler/ConfigurationHandler.java @@ -5,9 +5,7 @@ import net.minecraft.util.StatCollector; import net.minecraftforge.common.config.Configuration; -import com.pahimar.ee3.reference.Messages; import com.pahimar.ee3.reference.Reference; -import com.pahimar.ee3.reference.Settings; import com.pahimar.ee3.util.ConfigurationHelper; import cpw.mods.fml.client.event.ConfigChangedEvent; @@ -17,6 +15,11 @@ public class ConfigurationHandler { public static Configuration configuration; + private static final String CATEGORY_SOUND = "general.sound"; + private static final String CATEGORY_ENERGY_VALUE = "general.energy_value"; + private static final String CATEGORY_PLAYER_KNOWLEDGE = "general.player_knowledge"; + private static final String CATEGORY_SERVER = "general.server"; + public static void init(File configFile) { if (configuration == null) { @@ -27,37 +30,46 @@ public static void init(File configFile) { private static void loadConfiguration() { - // TODO Come back and do these constants in logical locations and names - Settings.General.syncThreshold = configuration.getInt( - Messages.Configuration.GENERAL_SYNC_THRESHOLD, - Configuration.CATEGORY_GENERAL, - 5, - 0, - Short.MAX_VALUE, - StatCollector.translateToLocal(Messages.Configuration.GENERAL_SYNC_THRESHOLD_COMMENT), - Messages.Configuration.GENERAL_SYNC_THRESHOLD_LABEL); - Settings.Sounds.soundMode = ConfigurationHelper.getString( + Settings.serverSyncThreshold = configuration.getInt( + Settings.SERVER_SYNC_THRESHOLD_NAME, + CATEGORY_SERVER, + Settings.SERVER_SYNC_THRESHOLD_DEFAULT, + Settings.SERVER_SYNC_THRESHOLD_MIN, + Settings.SERVER_SYNC_THRESHOLD_MAX, + StatCollector.translateToLocal(Settings.SERVER_SYNC_THRESHOLD_COMMENT), + Settings.SERVER_SYNC_THRESHOLD_LABEL); + + Settings.regenerateEnergyValuesWhen = ConfigurationHelper.getString( configuration, - Messages.Configuration.SOUND_MODE, - Configuration.CATEGORY_GENERAL, - "All", - StatCollector.translateToLocal(Messages.Configuration.SOUND_MODE_COMMENT), - new String[] { "All", "Self", "None" }, - Messages.Configuration.SOUND_MODE_LABEL); - Settings.Abilities.onlyLoadFile = configuration.getBoolean( - Messages.Configuration.ABILITIES_ONLY_LOAD_FILE, - Configuration.CATEGORY_GENERAL, - false, - StatCollector.translateToLocal(Messages.Configuration.ABILITIES_ONLY_LOAD_FILE_COMMENT), - Messages.Configuration.ABILITIES_ONLY_LOAD_FILE_LABEL); - Settings.DynamicEnergyValueGeneration.regenerateEnergyValuesWhen = ConfigurationHelper.getString( + Settings.ENERGY_VALUE_REGENERATE_WHEN_NAME, + CATEGORY_ENERGY_VALUE, + Settings.ENERGY_VALUE_REGENERATE_WHEN_DEFAULT, + StatCollector.translateToLocal(Settings.ENERGY_VALUE_REGENERATE_WHEN_COMMENT), + Settings.ENERGY_VALUE_REGENERATE_WHEN_OPTIONS, + Settings.ENERGY_VALUE_REGENERATE_WHEN_LABEL); + + Settings.energyValueDebugLoggingEnabled = configuration.getBoolean( + Settings.ENERGY_VALUE_DEBUG_LOGGING_ENABLED_NAME, + CATEGORY_ENERGY_VALUE, + Settings.ENERGY_VALUE_DEBUG_LOGGING_ENABLED_DEFAULT, + StatCollector.translateToLocal(Settings.ENERGY_VALUE_DEBUG_LOGGING_ENABLED_COMMENT), + Settings.ENERGY_VALUE_DEBUG_LOGGING_ENABLED_LABEL); + + Settings.soundMode = ConfigurationHelper.getString( configuration, - Messages.Configuration.REGENERATE_ENERGYVALUES_WHEN, - Configuration.CATEGORY_GENERAL, - "Always", - StatCollector.translateToLocal(Messages.Configuration.REGENERATE_ENERGYVALUES_WHEN_COMMENT), - new String[] { "Never", "When Mods Change", "Always" }, - Messages.Configuration.REGENERATE_ENERGYVALUES_WHEN_LABEL); + Settings.SOUND_MODE_NAME, + CATEGORY_SOUND, + Settings.SOUND_MODE_DEFAULT, + StatCollector.translateToLocal(Settings.SOUND_MODE_COMMENT), + Settings.SOUND_MODE_OPTIONS, + Settings.SOUND_MODE_LABEL); + + Settings.playerKnowledgeTemplateEnabled = configuration.getBoolean( + Settings.USE_PLAYER_KNOWLEDGE_TEMPLATE_NAME, + CATEGORY_PLAYER_KNOWLEDGE, + Settings.USE_PLAYER_KNOWLEDGE_TEMPLATE_DEFAULT, + StatCollector.translateToLocal(Settings.USE_PLAYER_KNOWLEDGE_TEMPLATE_COMMENT), + Settings.USE_PLAYER_KNOWLEDGE_TEMPLATE_LABEL); if (configuration.hasChanged()) { configuration.save(); @@ -71,4 +83,41 @@ public void onConfigurationChangedEvent(ConfigChangedEvent.OnConfigChangedEvent loadConfiguration(); } } + + public static class Settings { + + public static int serverSyncThreshold; + private static final String SERVER_SYNC_THRESHOLD_NAME = "sync_threshold"; + private static final String SERVER_SYNC_THRESHOLD_LABEL = "server.sync_threshold.label"; + private static final String SERVER_SYNC_THRESHOLD_COMMENT = "server.sync_threshold.comment"; + private static final int SERVER_SYNC_THRESHOLD_DEFAULT = 5; + private static final int SERVER_SYNC_THRESHOLD_MIN = 0; + private static final int SERVER_SYNC_THRESHOLD_MAX = Short.MAX_VALUE; + + public static String regenerateEnergyValuesWhen; + private static final String ENERGY_VALUE_REGENERATE_WHEN_NAME = "regenerate_values_when"; + private static final String ENERGY_VALUE_REGENERATE_WHEN_LABEL = "energy_value.regenerate_values_when.label"; + private static final String ENERGY_VALUE_REGENERATE_WHEN_COMMENT = "energy_value.regenerate_values_when.comment"; + private static final String ENERGY_VALUE_REGENERATE_WHEN_DEFAULT = "As Needed"; + private static final String[] ENERGY_VALUE_REGENERATE_WHEN_OPTIONS = new String[] { "As Needed", "Always" }; + + public static boolean energyValueDebugLoggingEnabled; + private static final String ENERGY_VALUE_DEBUG_LOGGING_ENABLED_NAME = "debug_logging_enabled"; + private static final String ENERGY_VALUE_DEBUG_LOGGING_ENABLED_LABEL = "energy_value.debug_logging_enabled.label"; + private static final String ENERGY_VALUE_DEBUG_LOGGING_ENABLED_COMMENT = "energy_value.debug_logging_enabled.comment"; + private static final boolean ENERGY_VALUE_DEBUG_LOGGING_ENABLED_DEFAULT = false; + + public static String soundMode; + private static final String SOUND_MODE_NAME = "mode"; + private static final String SOUND_MODE_LABEL = "sound.mode.label"; + private static final String SOUND_MODE_COMMENT = "sound.mode.comment"; + private static final String SOUND_MODE_DEFAULT = "All"; + private static final String[] SOUND_MODE_OPTIONS = new String[] { "All", "Self", "None" }; + + public static boolean playerKnowledgeTemplateEnabled; + private static final String USE_PLAYER_KNOWLEDGE_TEMPLATE_NAME = "use_template"; + private static final String USE_PLAYER_KNOWLEDGE_TEMPLATE_LABEL = "player_knowledge.use_template.label"; + private static final String USE_PLAYER_KNOWLEDGE_TEMPLATE_COMMENT = "player_knowledge.use_template.comment"; + private static final boolean USE_PLAYER_KNOWLEDGE_TEMPLATE_DEFAULT = true; + } } diff --git a/src/main/java/com/pahimar/ee3/handler/CraftingHandler.java b/src/main/java/com/pahimar/ee3/handler/CraftingHandler.java index d43dae15..f94f9192 100644 --- a/src/main/java/com/pahimar/ee3/handler/CraftingHandler.java +++ b/src/main/java/com/pahimar/ee3/handler/CraftingHandler.java @@ -4,7 +4,7 @@ import com.pahimar.ee3.item.crafting.RecipesAlchemicalBagDyes; import com.pahimar.ee3.util.IOwnable; -import com.pahimar.ee3.util.ItemHelper; +import com.pahimar.ee3.util.ItemStackUtils; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.PlayerEvent; @@ -19,7 +19,7 @@ public static void init() { @SubscribeEvent public void onItemCraftedEvent(PlayerEvent.ItemCraftedEvent event) { if (event.crafting.getItem() instanceof IOwnable) { - ItemHelper.setOwner(event.crafting, event.player); + ItemStackUtils.setOwner(event.crafting, event.player); } } } diff --git a/src/main/java/com/pahimar/ee3/handler/PlayerEventHandler.java b/src/main/java/com/pahimar/ee3/handler/PlayerEventHandler.java index c9c7f006..0b9afb2b 100644 --- a/src/main/java/com/pahimar/ee3/handler/PlayerEventHandler.java +++ b/src/main/java/com/pahimar/ee3/handler/PlayerEventHandler.java @@ -1,13 +1,13 @@ package com.pahimar.ee3.handler; +import static com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy.Blacklist; + import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.event.entity.player.PlayerEvent; -import com.pahimar.ee3.exchange.EnergyValueRegistry; -import com.pahimar.ee3.knowledge.TransmutationKnowledgeRegistry; import com.pahimar.ee3.network.PacketHandler; import com.pahimar.ee3.network.message.MessageChalkSettings; +import com.pahimar.ee3.network.message.MessageSyncBlacklist; import com.pahimar.ee3.network.message.MessageSyncEnergyValues; import com.pahimar.ee3.settings.ChalkSettings; import com.pahimar.ee3.util.EntityHelper; @@ -15,22 +15,9 @@ public class PlayerEventHandler { - @SubscribeEvent - public void onPlayerLoadFromFileEvent(PlayerEvent.LoadFromFile event) { - if (!event.entityPlayer.worldObj.isRemote) { - TransmutationKnowledgeRegistry.getInstance().loadPlayerFromDiskIfNeeded(event.entityPlayer); - } - } - - @SubscribeEvent - public void onPlayerSaveToFileEvent(PlayerEvent.SaveToFile event) { - if (!event.entityPlayer.worldObj.isRemote) { - TransmutationKnowledgeRegistry.getInstance().savePlayerKnowledgeToDisk(event.entityPlayer); - } - } - @SubscribeEvent public void onPlayerLoggedIn(cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent event) { + if (event.player != null) { NBTTagCompound playerCustomData = EntityHelper.getCustomEntityData(event.player); @@ -41,18 +28,9 @@ public void onPlayerLoggedIn(cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLog EntityHelper.saveCustomEntityData(event.player, playerCustomData); PacketHandler.INSTANCE.sendTo(new MessageChalkSettings(chalkSettings), (EntityPlayerMP) event.player); - TransmutationKnowledgeRegistry.getInstance().loadPlayerFromDiskIfNeeded(event.player); - PacketHandler.INSTANCE.sendTo( - new MessageSyncEnergyValues(EnergyValueRegistry.getInstance()), - (EntityPlayerMP) event.player); - } - - } - - @SubscribeEvent - public void onPlayerLoggedOut(cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedOutEvent event) { - if (!event.player.worldObj.isRemote) { - TransmutationKnowledgeRegistry.getInstance().unloadPlayer(event.player); + PacketHandler.INSTANCE.sendTo(new MessageSyncEnergyValues(), (EntityPlayerMP) event.player); + PacketHandler.INSTANCE.sendTo(new MessageSyncBlacklist(Blacklist.KNOWLEDGE), (EntityPlayerMP) event.player); + PacketHandler.INSTANCE.sendTo(new MessageSyncBlacklist(Blacklist.EXCHANGE), (EntityPlayerMP) event.player); } } } diff --git a/src/main/java/com/pahimar/ee3/handler/WorldEventHandler.java b/src/main/java/com/pahimar/ee3/handler/WorldEventHandler.java index a7f45b14..bafdee73 100644 --- a/src/main/java/com/pahimar/ee3/handler/WorldEventHandler.java +++ b/src/main/java/com/pahimar/ee3/handler/WorldEventHandler.java @@ -2,7 +2,11 @@ import net.minecraftforge.event.world.WorldEvent; -import com.pahimar.ee3.exchange.DynamicEnergyValueInitThread; +import com.pahimar.ee3.exchange.EnergyValueRegistry; +import com.pahimar.ee3.knowledge.PlayerKnowledgeRegistry; +import com.pahimar.ee3.recipe.AludelRecipeManager; +import com.pahimar.ee3.recipe.RecipeRegistry; +import com.pahimar.ee3.util.LogHelper; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.eventhandler.SubscribeEvent; @@ -14,9 +18,26 @@ public class WorldEventHandler { @SubscribeEvent public void onWorldLoadEvent(WorldEvent.Load event) { + if (!hasInitilialized && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { - DynamicEnergyValueInitThread.initEnergyValueRegistry(); + + RecipeRegistry.INSTANCE.registerVanillaRecipes(); + AludelRecipeManager.registerRecipes(); + + long startTime = System.nanoTime(); + if (ConfigurationHandler.Settings.regenerateEnergyValuesWhen.equalsIgnoreCase("As Needed")) { + EnergyValueRegistry.INSTANCE.load(); + } else { + EnergyValueRegistry.INSTANCE.compute(); + } + LogHelper.info( + EnergyValueRegistry.ENERGY_VALUE_MARKER, + "Energy value system initialized {} values after {} ms", + EnergyValueRegistry.INSTANCE.getEnergyValues().size(), + (System.nanoTime() - startTime) / 100000); hasInitilialized = true; + + PlayerKnowledgeRegistry.INSTANCE.load(); } } } diff --git a/src/main/java/com/pahimar/ee3/init/Abilities.java b/src/main/java/com/pahimar/ee3/init/Abilities.java index c56932fc..fdb8586e 100644 --- a/src/main/java/com/pahimar/ee3/init/Abilities.java +++ b/src/main/java/com/pahimar/ee3/init/Abilities.java @@ -4,25 +4,23 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; -import com.pahimar.ee3.api.knowledge.AbilityRegistryProxy; -import com.pahimar.ee3.exchange.CachedOreDictionary; +import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; import com.pahimar.ee3.exchange.OreStack; public class Abilities { - public static void initNotLearnables() { + public static void init() { + for (String oreName : OreDictionary.getOreNames()) { if (oreName.startsWith("ore")) { - for (ItemStack itemStack : CachedOreDictionary.getInstance().getItemStacksForOreName(oreName)) { - AbilityRegistryProxy.setAsNotLearnable(itemStack); - } - AbilityRegistryProxy.setAsNotLearnable(new OreStack(oreName)); + OreDictionary.getOres(oreName).forEach(BlacklistRegistryProxy::setAsNotLearnable); + BlacklistRegistryProxy.setAsNotLearnable(new OreStack(oreName)); } } - AbilityRegistryProxy.setAsNotLearnable(new ItemStack(Blocks.coal_ore)); - AbilityRegistryProxy.setAsNotLearnable(ModItems.shardMinium); - AbilityRegistryProxy.setAsNotLearnable(new ItemStack(ModItems.alchemicalDust, 1, 1)); - AbilityRegistryProxy.setAsNotLearnable(new ItemStack(ModItems.alchemicalDust, 1, 2)); + BlacklistRegistryProxy.setAsNotLearnable(new ItemStack(Blocks.coal_ore)); + BlacklistRegistryProxy.setAsNotLearnable(ModItems.shardMinium); + BlacklistRegistryProxy.setAsNotLearnable(new ItemStack(ModItems.alchemicalDust, 1, 1)); + BlacklistRegistryProxy.setAsNotLearnable(new ItemStack(ModItems.alchemicalDust, 1, 2)); } } diff --git a/src/main/java/com/pahimar/ee3/init/AlchemyArrays.java b/src/main/java/com/pahimar/ee3/init/AlchemyArrays.java index e0957d26..cba93d2f 100644 --- a/src/main/java/com/pahimar/ee3/init/AlchemyArrays.java +++ b/src/main/java/com/pahimar/ee3/init/AlchemyArrays.java @@ -2,29 +2,13 @@ import com.pahimar.ee3.api.array.AlchemyArray; import com.pahimar.ee3.api.array.AlchemyArrayRegistryProxy; -import com.pahimar.ee3.array.*; +import com.pahimar.ee3.array.AlchemyArrayTransmutation; public class AlchemyArrays { - public static final AlchemyArray accelerantAlchemyArray = new AlchemyArrayAccelerant(); - public static final AlchemyArray combustionAlchemyArray = new AlchemyArrayCombustion(); - public static final AlchemyArray constructionAlchemyArray = new AlchemyArrayConstruction(); - public static final AlchemyArray conveyorAlchemyArray = new AlchemyArrayConveyor(); - public static final AlchemyArray destructionAlchemyArray = new AlchemyArrayDestruction(); - public static final AlchemyArray gelidAlchemyArray = new AlchemyArrayGelid(); - public static final AlchemyArray parthenogenesisAlchemyArray = new AlchemyArrayParthenogenesis(); - public static final AlchemyArray transfigurationAlchemyArray = new AlchemyArrayTransfiguration(); public static final AlchemyArray transmutationAlchemyArray = new AlchemyArrayTransmutation(); public static void registerAlchemyArrays() { - AlchemyArrayRegistryProxy.registerAlchemyArray(accelerantAlchemyArray); - AlchemyArrayRegistryProxy.registerAlchemyArray(combustionAlchemyArray); - AlchemyArrayRegistryProxy.registerAlchemyArray(constructionAlchemyArray); - AlchemyArrayRegistryProxy.registerAlchemyArray(conveyorAlchemyArray); - AlchemyArrayRegistryProxy.registerAlchemyArray(destructionAlchemyArray); - AlchemyArrayRegistryProxy.registerAlchemyArray(gelidAlchemyArray); - AlchemyArrayRegistryProxy.registerAlchemyArray(parthenogenesisAlchemyArray); - AlchemyArrayRegistryProxy.registerAlchemyArray(transfigurationAlchemyArray); AlchemyArrayRegistryProxy.registerAlchemyArray(transmutationAlchemyArray); } } diff --git a/src/main/java/com/pahimar/ee3/init/EnergyValues.java b/src/main/java/com/pahimar/ee3/init/EnergyValues.java index b8431c42..6ee54b6e 100644 --- a/src/main/java/com/pahimar/ee3/init/EnergyValues.java +++ b/src/main/java/com/pahimar/ee3/init/EnergyValues.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.init; +import static com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy.Phase; + import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -11,169 +13,186 @@ public class EnergyValues { - public static void addDefaultEnergyValues() { + private static final String[] DYES = { "Black", "Red", "Green", "Brown", "Blue", "Purple", "Cyan", "LightGray", + "Gray", "Pink", "Lime", "Yellow", "LightBlue", "Magenta", "Orange", "White" }; + + public static void init() { + // OreDictionary assignment - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new OreStack("cobblestone"), 1); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new OreStack("dustRedstone"), 32); - String[] dyes = { "Black", "Red", "Green", "Brown", "Blue", "Purple", "Cyan", "LightGray", "Gray", "Pink", - "Lime", "Yellow", "LightBlue", "Magenta", "Orange", "White" }; - for (int i = 0; i < dyes.length; i++) { - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new OreStack("dye" + dyes[i]), 16); + EnergyValueRegistryProxy.setEnergyValue(new OreStack("cobblestone"), 1, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new OreStack("dustRedstone"), 32, Phase.PRE_CALCULATION); + for (int i = 0; i < DYES.length; i++) { + EnergyValueRegistryProxy.setEnergyValue(new OreStack("dye" + DYES[i]), 16, Phase.PRE_CALCULATION); } - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new OreStack("gemDiamond"), 8192); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new OreStack("gemEmerald"), 8192); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new OreStack("gemLapis"), 864); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new OreStack("gemQuartz"), 256); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new OreStack("ingotGold"), 2048); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new OreStack("ingotIron"), 256); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new OreStack("logWood"), 32); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new OreStack("oreCoal"), 32); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new OreStack("oreDiamond"), 8192); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new OreStack("oreEmerald"), 8192); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new OreStack("oreGold"), 2048); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new OreStack("oreIron"), 256); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new OreStack("oreLapis"), 864); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new OreStack("oreQuartz"), 256); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new OreStack("oreRedstone"), 32); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new OreStack("plankWood"), 8); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new OreStack("record"), 2048); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new OreStack("sand"), 1); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new OreStack("sandstone"), 4); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new OreStack("slabWood"), 4); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new OreStack("stairWood"), 12); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new OreStack("stickWood"), 4); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new OreStack("stone"), 1); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new OreStack("treeLeaves"), 1); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new OreStack("treeSapling"), 32); + EnergyValueRegistryProxy.setEnergyValue(new OreStack("gemDiamond"), 8192, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new OreStack("gemEmerald"), 8192, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new OreStack("gemLapis"), 864, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new OreStack("gemQuartz"), 256, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new OreStack("ingotGold"), 2048, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new OreStack("ingotIron"), 256, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new OreStack("logWood"), 32, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new OreStack("oreCoal"), 32, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new OreStack("oreDiamond"), 8192, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new OreStack("oreEmerald"), 8192, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new OreStack("oreGold"), 2048, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new OreStack("oreIron"), 256, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new OreStack("oreLapis"), 864, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new OreStack("oreQuartz"), 256, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new OreStack("oreRedstone"), 32, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new OreStack("plankWood"), 8, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new OreStack("record"), 2048, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new OreStack("sand"), 1, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new OreStack("sandstone"), 4, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new OreStack("slabWood"), 4, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new OreStack("slimeball"), 24, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new OreStack("stairWood"), 12, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new OreStack("stickWood"), 4, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new OreStack("stone"), 1, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new OreStack("treeLeaves"), 1, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new OreStack("treeSapling"), 32, Phase.PRE_CALCULATION); // Fluids - EnergyValueRegistryProxy.addPreAssignedEnergyValue(FluidRegistry.WATER, 1); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(FluidRegistry.LAVA, 64); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(FluidRegistry.getFluid("milk"), 64); + EnergyValueRegistryProxy.setEnergyValue(FluidRegistry.WATER, 0.001, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(FluidRegistry.LAVA, 0.064, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(FluidRegistry.getFluid("milk"), 0.064, Phase.PRE_CALCULATION); /* Building Blocks */ - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Blocks.stone, 1); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Blocks.grass, 1); + EnergyValueRegistryProxy.setEnergyValue(Blocks.stone, 1, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Blocks.grass, 1, Phase.PRE_CALCULATION); EnergyValueRegistryProxy - .addPreAssignedEnergyValue(new ItemStack(Blocks.dirt, 1, OreDictionary.WILDCARD_VALUE), 1); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Blocks.cobblestone, 1); + .setEnergyValue(new ItemStack(Blocks.dirt, 1, OreDictionary.WILDCARD_VALUE), 1, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Blocks.cobblestone, 1, Phase.PRE_CALCULATION); EnergyValueRegistryProxy - .addPreAssignedEnergyValue(new ItemStack(Blocks.sand, 1, OreDictionary.WILDCARD_VALUE), 1); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Blocks.gravel, 4); + .setEnergyValue(new ItemStack(Blocks.sand, 1, OreDictionary.WILDCARD_VALUE), 1, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Blocks.gravel, 4, Phase.PRE_CALCULATION); EnergyValueRegistryProxy - .addPreAssignedEnergyValue(new ItemStack(Blocks.glass, 1, OreDictionary.WILDCARD_VALUE), 1); - EnergyValueRegistryProxy - .addPreAssignedEnergyValue(new ItemStack(Blocks.sandstone, 1, OreDictionary.WILDCARD_VALUE), 4); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Blocks.mossy_cobblestone, 1); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Blocks.obsidian, 64); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Blocks.ice, 1); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Blocks.pumpkin, 144); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Blocks.netherrack, 1); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Blocks.soul_sand, 49); - EnergyValueRegistryProxy - .addPreAssignedEnergyValue(new ItemStack(Blocks.stonebrick, 1, OreDictionary.WILDCARD_VALUE), 1); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Blocks.mycelium, 1); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Blocks.end_stone, 1); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Blocks.hardened_clay, 256); + .setEnergyValue(new ItemStack(Blocks.glass, 1, OreDictionary.WILDCARD_VALUE), 1, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue( + new ItemStack(Blocks.sandstone, 1, OreDictionary.WILDCARD_VALUE), + 4, + Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Blocks.mossy_cobblestone, 1, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Blocks.obsidian, 64, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Blocks.ice, 1, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Blocks.pumpkin, 144, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Blocks.netherrack, 1, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Blocks.soul_sand, 49, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue( + new ItemStack(Blocks.stonebrick, 1, OreDictionary.WILDCARD_VALUE), + 1, + Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Blocks.mycelium, 1, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Blocks.end_stone, 1, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Blocks.hardened_clay, 256, Phase.PRE_CALCULATION); /* Decoration Blocks */ - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Blocks.web, 12); - EnergyValueRegistryProxy - .addPreAssignedEnergyValue(new ItemStack(Blocks.tallgrass, 1, OreDictionary.WILDCARD_VALUE), 1); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Blocks.deadbush, 1); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Blocks.yellow_flower, 16); - EnergyValueRegistryProxy - .addPreAssignedEnergyValue(new ItemStack(Blocks.red_flower, 1, OreDictionary.WILDCARD_VALUE), 16); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Blocks.brown_mushroom, 32); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Blocks.red_mushroom, 32); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Blocks.red_mushroom, 32); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Blocks.snow_layer, 0.125f); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Blocks.cactus, 8); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Blocks.vine, 8); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Blocks.waterlily, 16); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(Blocks.anvil, 1, 1), 5290.667f); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(Blocks.anvil, 1, 2), 2645.333f); - EnergyValueRegistryProxy - .addPreAssignedEnergyValue(new ItemStack(Blocks.double_plant, 1, OreDictionary.WILDCARD_VALUE), 32); + EnergyValueRegistryProxy.setEnergyValue(Blocks.web, 12, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue( + new ItemStack(Blocks.tallgrass, 1, OreDictionary.WILDCARD_VALUE), + 1, + Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Blocks.deadbush, 1, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Blocks.yellow_flower, 16, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue( + new ItemStack(Blocks.red_flower, 1, OreDictionary.WILDCARD_VALUE), + 16, + Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Blocks.brown_mushroom, 32, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Blocks.red_mushroom, 32, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Blocks.red_mushroom, 32, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Blocks.snow_layer, 0.125f, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Blocks.cactus, 8, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Blocks.vine, 8, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Blocks.waterlily, 16, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new ItemStack(Blocks.anvil, 1, 1), 5290.667f, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new ItemStack(Blocks.anvil, 1, 2), 2645.333f, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue( + new ItemStack(Blocks.double_plant, 1, OreDictionary.WILDCARD_VALUE), + 32, + Phase.PRE_CALCULATION); /* Redstone */ - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.redstone, 32); + EnergyValueRegistryProxy.setEnergyValue(Items.redstone, 32, Phase.PRE_CALCULATION); /* Transportation */ - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.saddle, 192); + EnergyValueRegistryProxy.setEnergyValue(Items.saddle, 192, Phase.PRE_CALCULATION); /* Miscellaneous */ - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.snowball, 0.25f); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.slime_ball, 24); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.bone, 48); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.ender_pearl, 1024); + EnergyValueRegistryProxy.setEnergyValue(Items.snowball, 0.25f, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.bone, 48, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.ender_pearl, 1024, Phase.PRE_CALCULATION); /* Foodstuffs */ - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.apple, 24); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.porkchop, 24); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.cooked_porkchop, 24); - EnergyValueRegistryProxy - .addPreAssignedEnergyValue(new ItemStack(Items.fish, 1, OreDictionary.WILDCARD_VALUE), 24); + EnergyValueRegistryProxy.setEnergyValue(Items.apple, 24, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.porkchop, 24, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.cooked_porkchop, 24, Phase.PRE_CALCULATION); EnergyValueRegistryProxy - .addPreAssignedEnergyValue(new ItemStack(Items.cooked_fished, 1, OreDictionary.WILDCARD_VALUE), 24); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.melon, 16); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.beef, 24); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.cooked_beef, 24); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.chicken, 24); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.cooked_chicken, 24); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.rotten_flesh, 24); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.spider_eye, 128); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.carrot, 24); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.potato, 24); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.baked_potato, 24); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.poisonous_potato, 24); + .setEnergyValue(new ItemStack(Items.fish, 1, OreDictionary.WILDCARD_VALUE), 24, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue( + new ItemStack(Items.cooked_fished, 1, OreDictionary.WILDCARD_VALUE), + 24, + Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.melon, 16, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.beef, 24, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.cooked_beef, 24, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.chicken, 24, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.cooked_chicken, 24, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.rotten_flesh, 24, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.spider_eye, 128, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.carrot, 24, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.potato, 24, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.baked_potato, 24, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.poisonous_potato, 24, Phase.PRE_CALCULATION); /* Brewing */ - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.ghast_tear, 4096); + EnergyValueRegistryProxy.setEnergyValue(Items.ghast_tear, 4096, Phase.PRE_CALCULATION); /* Materials */ - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(Items.coal, 1, 0), 32); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(Items.coal, 1, 1), 32); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.diamond, 8192); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.iron_ingot, 256); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.gold_ingot, 2048); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.string, 12); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.feather, 48); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.gunpowder, 192); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.wheat_seeds, 16); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.wheat, 24); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.flint, 4); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.leather, 64); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.brick, 64); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.clay_ball, 64); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.reeds, 32); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.egg, 32); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.glowstone_dust, 384); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(Items.dye, 1, 0), 16); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(Items.dye, 1, 2), 16); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(Items.dye, 1, 3), 16); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(Items.dye, 1, 4), 864); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(Items.dye, 1, 5), 16); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(Items.dye, 1, 6), 16); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.blaze_rod, 1536); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.nether_wart, 24); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.emerald, 8192); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.nether_star, 24576); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.netherbrick, 1); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(Items.quartz, 256); + EnergyValueRegistryProxy.setEnergyValue(new ItemStack(Items.coal, 1, 0), 32, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new ItemStack(Items.coal, 1, 1), 32, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.diamond, 8192, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.iron_ingot, 256, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.gold_ingot, 2048, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.string, 12, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.feather, 48, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.gunpowder, 192, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.wheat_seeds, 16, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.wheat, 24, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.flint, 4, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.leather, 64, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.brick, 64, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.clay_ball, 64, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.reeds, 32, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.egg, 32, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.glowstone_dust, 384, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new ItemStack(Items.dye, 1, 0), 16, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new ItemStack(Items.dye, 1, 2), 16, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new ItemStack(Items.dye, 1, 3), 16, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new ItemStack(Items.dye, 1, 4), 864, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new ItemStack(Items.dye, 1, 5), 16, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(new ItemStack(Items.dye, 1, 6), 16, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.blaze_rod, 1536, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.nether_wart, 24, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.emerald, 8192, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.nether_star, 24576, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.netherbrick, 1, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue(Items.quartz, 256, Phase.PRE_CALCULATION); /* Equivalent Exchange 3 */ /** * Alchemical Dusts */ - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ModItems.alchemicalDust, 1, 0), 1); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ModItems.alchemicalDust, 1, 1), 64); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ModItems.alchemicalDust, 1, 2), 2048); - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ModItems.alchemicalDust, 1, 3), 8192); + EnergyValueRegistryProxy.setEnergyValue(new ItemStack(ModItems.alchemicalDust, 1, 0), 1, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy + .setEnergyValue(new ItemStack(ModItems.alchemicalDust, 1, 1), 64, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy + .setEnergyValue(new ItemStack(ModItems.alchemicalDust, 1, 2), 2048, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy + .setEnergyValue(new ItemStack(ModItems.alchemicalDust, 1, 3), 8192, Phase.PRE_CALCULATION); /** * Minium Shard */ - EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ModItems.shardMinium), 8192); + EnergyValueRegistryProxy.setEnergyValue(new ItemStack(ModItems.shardMinium), 8192, Phase.PRE_CALCULATION); } } diff --git a/src/main/java/com/pahimar/ee3/init/Recipes.java b/src/main/java/com/pahimar/ee3/init/Recipes.java index 63b75375..4ca2b64f 100644 --- a/src/main/java/com/pahimar/ee3/init/Recipes.java +++ b/src/main/java/com/pahimar/ee3/init/Recipes.java @@ -61,17 +61,11 @@ private static void initModRecipes() { 's', new ItemStack(ModBlocks.ashInfusedStoneSlab)); - GameRegistry.addShapedRecipe( - new ItemStack(ModBlocks.chalkBlock), - "bcb", - "cbc", - "bcb", - 'b', + GameRegistry.addShapelessRecipe( + new ItemStack(ModItems.chalk), new ItemStack(Items.dye, 1, 15), - 'c', new ItemStack(Items.clay_ball)); - GameRegistry - .addShapedRecipe(new ItemStack(ModBlocks.chalkBlock), "cc", "cc", 'c', new ItemStack(ModItems.chalk)); + GameRegistry.addShapedRecipe(new ItemStack(ModBlocks.chalkBlock), "cc", "cc", 'c', ModItems.chalk); GameRegistry.addShapedRecipe(new ItemStack(ModBlocks.glassBell), "ggg", "g g", "g g", 'g', Blocks.glass); GameRegistry.addRecipe( @@ -280,6 +274,22 @@ private static void initAludelRecipes() { new ItemStack(ModItems.alchemicalDust, 14, 3)); // Alchemical Chest + AludelRecipeManager.getInstance().addRecipe( + new ItemStack(ModBlocks.alchemicalChest, 1, 0), + new ItemStack(Blocks.chest, 1, OreDictionary.WILDCARD_VALUE), + new ItemStack(ModItems.alchemicalDust, 8, 1)); + AludelRecipeManager.getInstance().addRecipe( + new ItemStack(ModBlocks.alchemicalChest, 1, 0), + new ItemStack(Blocks.trapped_chest, 1, OreDictionary.WILDCARD_VALUE), + new ItemStack(ModItems.alchemicalDust, 8, 1)); + AludelRecipeManager.getInstance().addRecipe( + new ItemStack(ModBlocks.alchemicalChest, 1, 1), + new ItemStack(Blocks.chest, 1, OreDictionary.WILDCARD_VALUE), + new ItemStack(ModItems.alchemicalDust, 8, 2)); + AludelRecipeManager.getInstance().addRecipe( + new ItemStack(ModBlocks.alchemicalChest, 1, 1), + new ItemStack(ModBlocks.alchemicalChest, 1, 0), + new ItemStack(ModItems.alchemicalDust, 8, 2)); AludelRecipeManager.getInstance().addRecipe( new ItemStack(ModBlocks.alchemicalChest, 1, 2), new ItemStack(Blocks.chest, 1, OreDictionary.WILDCARD_VALUE), diff --git a/src/main/java/com/pahimar/ee3/inventory/ContainerAlchemicalBag.java b/src/main/java/com/pahimar/ee3/inventory/ContainerAlchemicalBag.java index 2536d3c6..a28ec050 100644 --- a/src/main/java/com/pahimar/ee3/inventory/ContainerAlchemicalBag.java +++ b/src/main/java/com/pahimar/ee3/inventory/ContainerAlchemicalBag.java @@ -165,7 +165,7 @@ public void onContainerClosed(EntityPlayer entityPlayer) { InventoryPlayer invPlayer = entityPlayer.inventory; for (ItemStack itemStack : invPlayer.mainInventory) { if (itemStack != null) { - if (NBTHelper.hasTag(itemStack, Names.NBT.ALCHEMICAL_BAG_GUI_OPEN)) { + if (NBTHelper.hasKey(itemStack, Names.NBT.ALCHEMICAL_BAG_GUI_OPEN)) { NBTHelper.removeTag(itemStack, Names.NBT.ALCHEMICAL_BAG_GUI_OPEN); } } diff --git a/src/main/java/com/pahimar/ee3/inventory/ContainerAlchenomicon.java b/src/main/java/com/pahimar/ee3/inventory/ContainerAlchenomicon.java index e6f2262b..c4954113 100644 --- a/src/main/java/com/pahimar/ee3/inventory/ContainerAlchenomicon.java +++ b/src/main/java/com/pahimar/ee3/inventory/ContainerAlchenomicon.java @@ -3,20 +3,19 @@ import java.util.ArrayList; import java.util.List; import java.util.TreeSet; -import java.util.UUID; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; +import com.pahimar.ee3.api.knowledge.PlayerKnowledgeRegistryProxy; import com.pahimar.ee3.inventory.element.IElementButtonHandler; import com.pahimar.ee3.inventory.element.IElementTextFieldHandler; import com.pahimar.ee3.item.ItemAlchenomicon; -import com.pahimar.ee3.knowledge.TransmutationKnowledgeRegistry; import com.pahimar.ee3.reference.Comparators; import com.pahimar.ee3.util.FilterUtils; -import com.pahimar.ee3.util.ItemHelper; +import com.pahimar.ee3.util.ItemStackUtils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -32,12 +31,11 @@ public class ContainerAlchenomicon extends ContainerEE implements IElementButton private final static int MAX_COLUMN_INDEX = 5; public ContainerAlchenomicon(EntityPlayer entityPlayer, ItemStack itemStack) { - TreeSet knownTransmutations = new TreeSet(Comparators.displayNameComparator); + TreeSet knownTransmutations = new TreeSet<>(Comparators.DISPLAY_NAME_COMPARATOR); - if (itemStack.getItem() instanceof ItemAlchenomicon && ItemHelper.hasOwnerUUID(itemStack)) { - UUID ownerUUID = ItemHelper.getOwnerUUID(itemStack); - knownTransmutations - .addAll(TransmutationKnowledgeRegistry.getInstance().getPlayersKnownTransmutations(ownerUUID)); + if (itemStack.getItem() instanceof ItemAlchenomicon && ItemStackUtils.getOwnerName(itemStack) != null) { + String playerName = ItemStackUtils.getOwnerName(itemStack); + knownTransmutations.addAll(PlayerKnowledgeRegistryProxy.getKnownItemStacks(playerName)); } inventoryAlchenomicon = new InventoryAlchenomicon(knownTransmutations); @@ -161,11 +159,12 @@ private void updateInventory() { this.requiresUpdate = true; boolean shouldUpdateInventory = false; ItemStack[] newInventory = new ItemStack[80]; - List filteredList = new ArrayList( - FilterUtils.filterByNameContains( + List filteredList = new ArrayList<>( + FilterUtils.filterByDisplayName( inventoryAlchenomicon.getKnownTransmutations(), searchTerm, - Comparators.displayNameComparator)); + FilterUtils.NameFilterType.CONTAINS, + Comparators.DISPLAY_NAME_COMPARATOR)); maxPageOffset = filteredList.size() / 80; if (pageOffset > maxPageOffset) { diff --git a/src/main/java/com/pahimar/ee3/inventory/ContainerEE.java b/src/main/java/com/pahimar/ee3/inventory/ContainerEE.java index 05944ea3..e4cee73e 100644 --- a/src/main/java/com/pahimar/ee3/inventory/ContainerEE.java +++ b/src/main/java/com/pahimar/ee3/inventory/ContainerEE.java @@ -4,7 +4,7 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import com.pahimar.ee3.util.ItemHelper; +import com.pahimar.ee3.util.ItemStackUtils; public abstract class ContainerEE extends Container { @@ -25,7 +25,7 @@ protected boolean mergeItemStack(ItemStack itemStack, int slotMin, int slotMax, slot = (Slot) this.inventorySlots.get(currentSlotIndex); stackInSlot = slot.getStack(); - if (slot.isItemValid(itemStack) && ItemHelper.equalsIgnoreStackSize(itemStack, stackInSlot)) { + if (slot.isItemValid(itemStack) && ItemStackUtils.equalsIgnoreStackSize(itemStack, stackInSlot)) { int combinedStackSize = stackInSlot.stackSize + itemStack.stackSize; int slotStackSizeLimit = Math.min(stackInSlot.getMaxStackSize(), slot.getSlotStackLimit()); @@ -55,9 +55,7 @@ protected boolean mergeItemStack(ItemStack itemStack, int slotMin, int slotMax, if (slot.isItemValid(itemStack) && stackInSlot == null) { slot.putStack( - ItemHelper.cloneItemStack( - itemStack, - Math.min(itemStack.stackSize, slot.getSlotStackLimit()))); + ItemStackUtils.clone(itemStack, Math.min(itemStack.stackSize, slot.getSlotStackLimit()))); slot.onSlotChanged(); if (slot.getStack() != null) { diff --git a/src/main/java/com/pahimar/ee3/inventory/ContainerResearchStation.java b/src/main/java/com/pahimar/ee3/inventory/ContainerResearchStation.java index 017bd072..beeea427 100644 --- a/src/main/java/com/pahimar/ee3/inventory/ContainerResearchStation.java +++ b/src/main/java/com/pahimar/ee3/inventory/ContainerResearchStation.java @@ -6,8 +6,8 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; +import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; import com.pahimar.ee3.item.ItemAlchenomicon; -import com.pahimar.ee3.knowledge.AbilityRegistry; import com.pahimar.ee3.tileentity.TileEntityResearchStation; import cpw.mods.fml.relauncher.Side; @@ -33,7 +33,7 @@ public int getSlotStackLimit() { @Override public boolean isItemValid(ItemStack itemStack) { - return AbilityRegistry.getInstance().isLearnable(itemStack); + return BlacklistRegistryProxy.isLearnable(itemStack); } }); diff --git a/src/main/java/com/pahimar/ee3/inventory/ContainerTransmutationTablet.java b/src/main/java/com/pahimar/ee3/inventory/ContainerTransmutationTablet.java index 84f533c1..99332455 100644 --- a/src/main/java/com/pahimar/ee3/inventory/ContainerTransmutationTablet.java +++ b/src/main/java/com/pahimar/ee3/inventory/ContainerTransmutationTablet.java @@ -8,138 +8,86 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; +import com.pahimar.ee3.api.exchange.EnergyValue; import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy; -import com.pahimar.ee3.exchange.EnergyValueRegistry; +import com.pahimar.ee3.api.knowledge.PlayerKnowledgeRegistryProxy; import com.pahimar.ee3.inventory.element.IElementButtonHandler; import com.pahimar.ee3.inventory.element.IElementSliderHandler; import com.pahimar.ee3.inventory.element.IElementTextFieldHandler; import com.pahimar.ee3.item.ItemAlchenomicon; import com.pahimar.ee3.item.ItemMiniumStone; import com.pahimar.ee3.item.ItemPhilosophersStone; -import com.pahimar.ee3.knowledge.AbilityRegistry; -import com.pahimar.ee3.knowledge.TransmutationKnowledge; -import com.pahimar.ee3.knowledge.TransmutationKnowledgeRegistry; import com.pahimar.ee3.network.PacketHandler; -import com.pahimar.ee3.network.message.MessageTransmutationKnowledgeUpdate; +import com.pahimar.ee3.network.message.MessagePlayerKnowledge; import com.pahimar.ee3.reference.Comparators; import com.pahimar.ee3.tileentity.TileEntityTransmutationTablet; import com.pahimar.ee3.util.FilterUtils; -import com.pahimar.ee3.util.ItemHelper; +import com.pahimar.ee3.util.ItemStackUtils; +import com.pahimar.repackage.cofh.lib.util.helpers.MathHelper; -import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +/** + * FIXME Continue integrating PR#881 + */ public class ContainerTransmutationTablet extends ContainerEE implements IElementTextFieldHandler, IElementSliderHandler, IElementButtonHandler { private InventoryTransmutationTablet inventoryTransmutationTablet; - public final TileEntityTransmutationTablet tileEntityTransmutationTablet; - private float energyValue; + private final TileEntityTransmutationTablet transmutationTablet; + private final World world; + private EnergyValue energyValue; private String searchTerm; - private int sortOption; - private int sortOrder; - private int scrollBarPosition; + private int sortOption, sortOrder, scrollBarPosition; public ContainerTransmutationTablet(InventoryPlayer inventoryPlayer, - TileEntityTransmutationTablet tileEntityTransmutationTablet) { - this.tileEntityTransmutationTablet = tileEntityTransmutationTablet; - - TreeSet knownTransmutations = new TreeSet(Comparators.displayNameComparator); - if (tileEntityTransmutationTablet.getStackInSlot(TileEntityTransmutationTablet.ALCHENOMICON_INDEX) != null) { - ItemStack itemStack = tileEntityTransmutationTablet - .getStackInSlot(TileEntityTransmutationTablet.ALCHENOMICON_INDEX); - if (itemStack.getItem() instanceof ItemAlchenomicon && ItemHelper.hasOwnerUUID(itemStack)) { - knownTransmutations.addAll( - TransmutationKnowledgeRegistry.getInstance() - .getPlayersKnownTransmutations(ItemHelper.getOwnerUUID(itemStack))); - } - } - inventoryTransmutationTablet = new InventoryTransmutationTablet(knownTransmutations); + TileEntityTransmutationTablet transmutationTablet) { + + this.transmutationTablet = transmutationTablet; + this.world = transmutationTablet.getWorldObj(); + + handleTomeSync(transmutationTablet.getStackInSlot(TileEntityTransmutationTablet.ALCHENOMICON_INDEX)); this.sortOption = 0; this.scrollBarPosition = 0; - this.energyValue = tileEntityTransmutationTablet.getAvailableEnergyValue().getValue(); + this.energyValue = transmutationTablet.getAvailableEnergy(); this.addSlotToContainer( - new SlotTabletInput( - this, - tileEntityTransmutationTablet, - TileEntityTransmutationTablet.ITEM_INPUT_1, - 62, - 24)); + new SlotTabletInput(this, transmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_1, 62, 24)); this.addSlotToContainer( - new SlotTabletInput( - this, - tileEntityTransmutationTablet, - TileEntityTransmutationTablet.ITEM_INPUT_2, - 35, - 35)); + new SlotTabletInput(this, transmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_2, 35, 35)); this.addSlotToContainer( - new SlotTabletInput( - this, - tileEntityTransmutationTablet, - TileEntityTransmutationTablet.ITEM_INPUT_3, - 26, - 61)); + new SlotTabletInput(this, transmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_3, 26, 61)); this.addSlotToContainer( - new SlotTabletInput( - this, - tileEntityTransmutationTablet, - TileEntityTransmutationTablet.ITEM_INPUT_4, - 35, - 87)); + new SlotTabletInput(this, transmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_4, 35, 87)); this.addSlotToContainer( - new SlotTabletInput( - this, - tileEntityTransmutationTablet, - TileEntityTransmutationTablet.ITEM_INPUT_5, - 62, - 99)); + new SlotTabletInput(this, transmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_5, 62, 99)); this.addSlotToContainer( - new SlotTabletInput( - this, - tileEntityTransmutationTablet, - TileEntityTransmutationTablet.ITEM_INPUT_6, - 89, - 87)); + new SlotTabletInput(this, transmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_6, 89, 87)); this.addSlotToContainer( - new SlotTabletInput( - this, - tileEntityTransmutationTablet, - TileEntityTransmutationTablet.ITEM_INPUT_7, - 98, - 61)); + new SlotTabletInput(this, transmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_7, 98, 61)); this.addSlotToContainer( - new SlotTabletInput( - this, - tileEntityTransmutationTablet, - TileEntityTransmutationTablet.ITEM_INPUT_8, - 89, - 35)); - this.addSlotToContainer( - new Slot(tileEntityTransmutationTablet, TileEntityTransmutationTablet.STONE_INDEX, 62, 61) { + new SlotTabletInput(this, transmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_8, 89, 35)); + this.addSlotToContainer(new Slot(transmutationTablet, TileEntityTransmutationTablet.STONE_INDEX, 62, 61) { - @Override - public int getSlotStackLimit() { - return 1; - } + @Override + public int getSlotStackLimit() { + return 1; + } - @Override - public boolean isItemValid(ItemStack itemStack) { - return itemStack.getItem() instanceof ItemMiniumStone - || itemStack.getItem() instanceof ItemPhilosophersStone; - } - }); + @Override + public boolean isItemValid(ItemStack itemStack) { + return itemStack.getItem() instanceof ItemMiniumStone + || itemStack.getItem() instanceof ItemPhilosophersStone; + } + }); this.addSlotToContainer( - new SlotAlchenomicon( - this, - tileEntityTransmutationTablet, - TileEntityTransmutationTablet.ALCHENOMICON_INDEX, - 152, - 15)); + new SlotAlchenomicon(transmutationTablet, TileEntityTransmutationTablet.ALCHENOMICON_INDEX, 152, 15)); for (int i = 0; i < 10; i++) { for (int j = 0; j < 3; j++) { @@ -166,42 +114,51 @@ public boolean isItemValid(ItemStack itemStack) { this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 8 + actionBarSlotIndex * 18, 222)); } - this.updateInventory(); + updateInventory(); + } + + public EnergyValue getEnergyValue() { + return energyValue; } @Override public boolean canInteractWith(EntityPlayer entityPlayer) { - return this.tileEntityTransmutationTablet != null && this.tileEntityTransmutationTablet.isStructureValid(); + return transmutationTablet != null && transmutationTablet.isUseableByPlayer(entityPlayer); } @Override public void detectAndSendChanges() { + super.detectAndSendChanges(); + EnergyValue tileEnergyValue = transmutationTablet.getAvailableEnergy(); for (Object crafter : this.crafters) { + ICrafting iCrafting = (ICrafting) crafter; - if (this.energyValue != this.tileEntityTransmutationTablet.getAvailableEnergyValue().getValue()) { - this.energyValue = this.tileEntityTransmutationTablet.getAvailableEnergyValue().getValue(); - this.updateInventory(); - int energyValueAsInt = Float - .floatToRawIntBits(this.tileEntityTransmutationTablet.getAvailableEnergyValue().getValue()); + if (energyValue.compareTo(tileEnergyValue) != 0) { + energyValue = tileEnergyValue; + + int energyValueAsInt = Float.floatToRawIntBits(tileEnergyValue.getValue()); iCrafting.sendProgressBarUpdate(this, 0, energyValueAsInt & 0xffff); iCrafting.sendProgressBarUpdate(this, 1, energyValueAsInt >>> 16); } } + + this.updateInventory(); } @SideOnly(Side.CLIENT) public void updateProgressBar(int valueType, int updatedValue) { + if (valueType == 0) { - int energyValueAsInt = Float.floatToRawIntBits(energyValue); + int energyValueAsInt = Float.floatToRawIntBits(energyValue.getValue()); energyValueAsInt = (energyValueAsInt & 0xffff0000) | updatedValue; - energyValue = Float.intBitsToFloat(energyValueAsInt); + energyValue = new EnergyValue(Float.intBitsToFloat(energyValueAsInt)); } else if (valueType == 1) { - int energyValueAsInt = Float.floatToRawIntBits(energyValue); + int energyValueAsInt = Float.floatToRawIntBits(energyValue.getValue()); energyValueAsInt = (energyValueAsInt & 0xffff) | (updatedValue << 16); - energyValue = Float.intBitsToFloat(energyValueAsInt); + energyValue = new EnergyValue(Float.intBitsToFloat(energyValueAsInt)); } else if (valueType == 2) { sortOption = updatedValue; } else if (valueType == 3) { @@ -215,67 +172,96 @@ public void updateProgressBar(int valueType, int updatedValue) { } } + private void sendKnowledgeToClient(Collection knownItemStacks) { + + PacketHandler.INSTANCE.sendToAllAround( + new MessagePlayerKnowledge(transmutationTablet, knownItemStacks), + new NetworkRegistry.TargetPoint( + world.provider.dimensionId, + transmutationTablet.xCoord, + transmutationTablet.yCoord, + transmutationTablet.zCoord, + 5d)); + } + + private void handleTomeSync(ItemStack itemStack) { + + if (itemStack != null && itemStack.getItem() instanceof ItemAlchenomicon + && ItemStackUtils.getOwnerName(itemStack) != null) { + + if (!world.isRemote) { + + Set knownItemStacks = PlayerKnowledgeRegistryProxy + .getKnownItemStacks(ItemStackUtils.getOwnerName(itemStack)); + inventoryTransmutationTablet = new InventoryTransmutationTablet(knownItemStacks); + sendKnowledgeToClient(knownItemStacks); + } else { + this.inventoryTransmutationTablet = new InventoryTransmutationTablet( + transmutationTablet.getPlayerKnowledge()); + } + } else { + + this.inventoryTransmutationTablet = new InventoryTransmutationTablet(); + if (!world.isRemote) { + sendKnowledgeToClient(null); + } + } + } + @Override public void handleElementTextFieldUpdate(String elementName, String updatedText) { + if (elementName.equalsIgnoreCase("searchField")) { - this.searchTerm = updatedText; + searchTerm = updatedText; updateInventory(); } } @Override public void handleElementSliderUpdate(String elementName, int elementValue) { + if (elementName.equals("scrollBar")) { - this.scrollBarPosition = elementValue; + scrollBarPosition = elementValue; updateInventory(); } } - public void handleTransmutationKnowledgeUpdate(TransmutationKnowledge transmutationKnowledge) { - if (transmutationKnowledge != null) { - this.inventoryTransmutationTablet = new InventoryTransmutationTablet( - transmutationKnowledge.getKnownTransmutations()); - this.updateInventory(); - } - } - private void updateInventory() { - ItemStack[] newInventory = new ItemStack[30]; - - Set filteredSet = FilterUtils - .filterByNameContains(this.inventoryTransmutationTablet.getKnownTransmutations(), searchTerm); - List filteredList = new ArrayList(FilterUtils.filterByEnergyValue(filteredSet, energyValue)); - int adjustedStartIndex = (int) ((scrollBarPosition / 187f) * filteredList.size()); + ItemStack[] newInventory = new ItemStack[30]; - if (sortOption == 0) { - if (sortOrder == 0) { - Collections.sort(filteredList, Comparators.displayNameComparator); - } else { - Collections.sort(filteredList, Comparators.reverseDisplayNameComparator); - } - } else if (sortOption == 1) { - if (sortOrder == 0) { - Collections.sort(filteredList, Comparators.energyValueItemStackComparator); - } else { - Collections.sort(filteredList, Comparators.reverseEnergyValueComparator); - } - } else if (sortOption == 2) { - if (sortOrder == 0) { - Collections.sort(filteredList, Comparators.idComparator); - } else { - Collections.sort(filteredList, Comparators.reverseIdComparator); - } + Set filteredSet = FilterUtils.filterByDisplayName( + inventoryTransmutationTablet.getKnownTransmutations(), + searchTerm, + FilterUtils.NameFilterType.CONTAINS); + List filteredList = new ArrayList<>(FilterUtils.filterByEnergyValue(filteredSet, energyValue)); + + if (sortOption == 0 && sortOrder == 0) { + Collections.sort(filteredList, Comparators.DISPLAY_NAME_COMPARATOR); + } else if (sortOption == 0 && sortOrder == 1) { + Collections.sort(filteredList, Comparators.DISPLAY_NAME_COMPARATOR.reversed()); + } else if (sortOption == 1 && sortOrder == 0) { + Collections.sort(filteredList, Comparators.ENERGY_VALUE_ITEM_STACK_COMPARATOR); + } else if (sortOption == 1 && sortOrder == 1) { + Collections.sort(filteredList, Comparators.ENERGY_VALUE_ITEM_STACK_COMPARATOR.reversed()); + } else if (sortOption == 2 && sortOrder == 0) { + Collections.sort(filteredList, Comparators.ID_COMPARATOR); + } else if (sortOption == 2 && sortOrder == 1) { + Collections.sort(filteredList, Comparators.ID_COMPARATOR.reversed()); } if (filteredList.size() <= 30) { - newInventory = filteredList.toArray(newInventory); - } else if (adjustedStartIndex + 30 <= filteredList.size()) { - newInventory = filteredList.subList(adjustedStartIndex, adjustedStartIndex + 30).toArray(newInventory); - } else { - newInventory = filteredList.subList(filteredList.size() - 30, filteredList.size()).toArray(newInventory); + this.scrollBarPosition = 0; } + int adjustedStartIndex = (int) ((scrollBarPosition / 187f) * filteredList.size()); + adjustedStartIndex -= adjustedStartIndex % 3; // Paginate by 3 elements. + + int startIndex = Math.max(0, Math.min(adjustedStartIndex, filteredList.size() - 30)); + int endIndex = Math.min(adjustedStartIndex + 30, filteredList.size()); + + filteredList.subList(startIndex, endIndex).toArray(newInventory); + for (int i = 0; i < 30; i++) { this.getSlot(i + 10).putStack(newInventory[i]); } @@ -283,10 +269,12 @@ private void updateInventory() { @Override public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) { + ItemStack itemStack = null; Slot slot = (Slot) inventorySlots.get(slotIndex); if (slot != null && slot.getHasStack()) { + ItemStack slotItemStack = slot.getStack(); itemStack = slotItemStack.copy(); @@ -295,6 +283,7 @@ public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) { * first available slot in the entityPlayer's inventory */ if (slotIndex < TileEntityTransmutationTablet.INVENTORY_SIZE) { + if (!this.mergeItemStack( slotItemStack, TileEntityTransmutationTablet.INVENTORY_SIZE, @@ -303,7 +292,8 @@ public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) { return null; } } else if (slotIndex >= TileEntityTransmutationTablet.INVENTORY_SIZE && slotIndex < 40) { - if (!this.mergeTransmutatedItemStack( + + if (!this.mergeTransmutedItemStack( entityPlayer, slot, slotItemStack, @@ -313,7 +303,9 @@ public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) { return null; } } else { + if (slotItemStack.getItem() instanceof ItemAlchenomicon) { + if (!this.mergeItemStack( slotItemStack, TileEntityTransmutationTablet.ALCHENOMICON_INDEX, @@ -323,6 +315,7 @@ public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) { } } else if (slotItemStack.getItem() instanceof ItemMiniumStone || slotItemStack.getItem() instanceof ItemPhilosophersStone) { + if (!this.mergeItemStack( slotItemStack, TileEntityTransmutationTablet.STONE_INDEX, @@ -331,6 +324,7 @@ public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) { return null; } } else { + if (!this.mergeItemStack( slotItemStack, TileEntityTransmutationTablet.ITEM_INPUT_1, @@ -351,106 +345,86 @@ public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) { return itemStack; } - protected boolean mergeTransmutatedItemStack(EntityPlayer entityPlayer, Slot transmutationOutputSlot, + private boolean mergeTransmutedItemStack(EntityPlayer entityPlayer, Slot transmutationOutputSlot, ItemStack itemStack, int slotMin, int slotMax, boolean ascending) { - if (this.tileEntityTransmutationTablet.getAvailableEnergyValue() - .compareTo(EnergyValueRegistryProxy.getEnergyValue(itemStack)) < 0) { + + // Calculate how many items can be transmuted + int numCanTransmute = MathHelper.floor( + this.transmutationTablet.getAvailableEnergy().getValue() + / EnergyValueRegistryProxy.getEnergyValue(itemStack).getValue()); + int numTransmuted = 0; + + ItemStack itemStack1 = itemStack.copy(); + itemStack1.stackSize = Math.min(numCanTransmute, itemStack1.getMaxStackSize()); + + if (numCanTransmute <= 0) { return false; } - transmutationOutputSlot.onPickupFromSlot(entityPlayer, itemStack); - - boolean slotFound = false; int currentSlotIndex = ascending ? slotMax - 1 : slotMin; Slot slot; ItemStack stackInSlot; - if (itemStack.isStackable()) { - while (itemStack.stackSize > 0 - && (!ascending && currentSlotIndex < slotMax || ascending && currentSlotIndex >= slotMin)) { - slot = (Slot) this.inventorySlots.get(currentSlotIndex); - stackInSlot = slot.getStack(); - - if (slot.isItemValid(itemStack) && ItemHelper.equalsIgnoreStackSize(itemStack, stackInSlot)) { - int combinedStackSize = stackInSlot.stackSize + itemStack.stackSize; - int slotStackSizeLimit = Math.min(stackInSlot.getMaxStackSize(), slot.getSlotStackLimit()); - - if (combinedStackSize <= slotStackSizeLimit) { - itemStack.stackSize = 0; - stackInSlot.stackSize = combinedStackSize; - slot.onSlotChanged(); - slotFound = true; - } else if (stackInSlot.stackSize < slotStackSizeLimit) { - itemStack.stackSize -= slotStackSizeLimit - stackInSlot.stackSize; - stackInSlot.stackSize = slotStackSizeLimit; - slot.onSlotChanged(); - slotFound = true; - } - } + while (itemStack1.stackSize > 0 + && (!ascending && currentSlotIndex < slotMax || ascending && currentSlotIndex >= slotMin)) { - currentSlotIndex += ascending ? -1 : 1; - } - } + slot = (Slot) this.inventorySlots.get(currentSlotIndex); + stackInSlot = slot.getStack(); + + if (stackInSlot == null) { - if (itemStack.stackSize > 0) { - currentSlotIndex = ascending ? slotMax - 1 : slotMin; + stackInSlot = itemStack1.copy(); + stackInSlot.stackSize = itemStack1.stackSize; + slot.putStack(stackInSlot); + numTransmuted = itemStack1.stackSize; + itemStack1.stackSize = 0; + slot.onSlotChanged(); + } else if (slot.isItemValid(itemStack1) && ItemStackUtils.equalsIgnoreStackSize(itemStack1, stackInSlot)) { - while (!ascending && currentSlotIndex < slotMax || ascending && currentSlotIndex >= slotMin) { - slot = (Slot) this.inventorySlots.get(currentSlotIndex); - stackInSlot = slot.getStack(); + int slotStackSizeLimit = Math.min(stackInSlot.getMaxStackSize(), slot.getSlotStackLimit()); + int combinedStackSize = stackInSlot.stackSize + itemStack1.stackSize; - if (slot.isItemValid(itemStack) && stackInSlot == null) { - slot.putStack( - ItemHelper.cloneItemStack( - itemStack, - Math.min(itemStack.stackSize, slot.getSlotStackLimit()))); - slot.onSlotChanged(); + if (combinedStackSize <= slotStackSizeLimit) { - if (slot.getStack() != null) { - itemStack.stackSize = 0; - slotFound = true; - } + stackInSlot.stackSize = combinedStackSize; + numTransmuted = itemStack1.stackSize; + itemStack1.stackSize = 0; + slot.onSlotChanged(); + } else if (stackInSlot.stackSize < slotStackSizeLimit) { - break; + itemStack1.stackSize -= slotStackSizeLimit - stackInSlot.stackSize; + stackInSlot.stackSize = slotStackSizeLimit; + numTransmuted = itemStack1.stackSize; + itemStack1.stackSize = 0; + slot.onSlotChanged(); } - - currentSlotIndex += ascending ? -1 : 1; } + + currentSlotIndex += ascending ? -1 : 1; } - itemStack.stackSize = 1; - return slotFound; + + ((SlotTabletOutput) transmutationOutputSlot) + .onShiftPickupFromSlot(entityPlayer, ItemStackUtils.clone(itemStack, numTransmuted)); + + return false; } @Override public void handleElementButtonClick(String elementName, int mouseButton) { + if (elementName.equals("sortOption")) { if (mouseButton == 0) { - if (sortOption == 0) { - sortOption = 1; - } else if (sortOption == 1) { - sortOption = 2; - } else if (sortOption == 2) { - sortOption = 0; - } + sortOption = (sortOption + 1) % 3; } else if (mouseButton == 1) { - if (sortOption == 0) { - sortOption = 2; - } else if (sortOption == 1) { - sortOption = 0; - } else if (sortOption == 2) { - sortOption = 1; - } + sortOption = (sortOption + (3 - 1)) % 3; } } else if (elementName.equals("sortOrder")) { - if (sortOrder == 0) { - sortOrder = 1; - } else if (sortOrder == 1) { - sortOrder = 0; - } + sortOrder = 1 - sortOrder; // Toggle between 0 and 1 } for (Object crafter : this.crafters) { + ICrafting iCrafting = (ICrafting) crafter; iCrafting.sendProgressBarUpdate(this, 2, sortOption); iCrafting.sendProgressBarUpdate(this, 4, sortOrder); @@ -459,22 +433,18 @@ public void handleElementButtonClick(String elementName, int mouseButton) { @Override public ItemStack slotClick(int slot, int button, int flag, EntityPlayer player) { + if (button == 0 && flag == 6) { return null; } + return super.slotClick(slot, button, flag, player); } private class SlotAlchenomicon extends Slot { - private ContainerTransmutationTablet containerTransmutationTablet; - private TileEntityTransmutationTablet tileEntityTransmutationTablet; - - public SlotAlchenomicon(ContainerTransmutationTablet containerTransmutationTablet, IInventory iInventory, - int slotIndex, int x, int y) { + public SlotAlchenomicon(IInventory iInventory, int slotIndex, int x, int y) { super(iInventory, slotIndex, x, y); - this.containerTransmutationTablet = containerTransmutationTablet; - this.tileEntityTransmutationTablet = containerTransmutationTablet.tileEntityTransmutationTablet; } @Override @@ -488,51 +458,11 @@ public boolean isItemValid(ItemStack itemStack) { } @Override - public void onPickupFromSlot(EntityPlayer entityPlayer, ItemStack itemStack) { - super.onPickupFromSlot(entityPlayer, itemStack); - - this.containerTransmutationTablet.inventoryTransmutationTablet = new InventoryTransmutationTablet(); - this.containerTransmutationTablet.updateInventory(); - - if (!this.tileEntityTransmutationTablet.getWorldObj().isRemote && itemStack != null - && itemStack.getItem() instanceof ItemAlchenomicon - && ItemHelper.hasOwnerUUID(itemStack)) { - PacketHandler.INSTANCE.sendToAllAround( - new MessageTransmutationKnowledgeUpdate( - this.containerTransmutationTablet.tileEntityTransmutationTablet, - null), - new NetworkRegistry.TargetPoint( - this.tileEntityTransmutationTablet.getWorldObj().provider.dimensionId, - (double) this.tileEntityTransmutationTablet.xCoord, - (double) this.tileEntityTransmutationTablet.yCoord, - (double) this.tileEntityTransmutationTablet.zCoord, - 5d)); - } - } - - @Override - public void putStack(ItemStack itemStack) { - super.putStack(itemStack); + public void onSlotChanged() { - if (!this.tileEntityTransmutationTablet.getWorldObj().isRemote && itemStack != null - && itemStack.getItem() instanceof ItemAlchenomicon - && ItemHelper.hasOwnerUUID(itemStack)) { - Set knownTransmutations = TransmutationKnowledgeRegistry.getInstance() - .getPlayersKnownTransmutations(ItemHelper.getOwnerUUID(itemStack)); - this.containerTransmutationTablet.inventoryTransmutationTablet = new InventoryTransmutationTablet( - knownTransmutations); - this.containerTransmutationTablet.updateInventory(); - PacketHandler.INSTANCE.sendToAllAround( - new MessageTransmutationKnowledgeUpdate( - this.containerTransmutationTablet.tileEntityTransmutationTablet, - knownTransmutations), - new NetworkRegistry.TargetPoint( - this.tileEntityTransmutationTablet.getWorldObj().provider.dimensionId, - (double) this.tileEntityTransmutationTablet.xCoord, - (double) this.tileEntityTransmutationTablet.yCoord, - (double) this.tileEntityTransmutationTablet.zCoord, - 5d)); - } + super.onSlotChanged(); + handleTomeSync(getStack()); + updateInventory(); } } @@ -542,6 +472,7 @@ private class SlotTabletOutput extends Slot { public SlotTabletOutput(ContainerTransmutationTablet containerTransmutationTablet, IInventory iInventory, int slotIndex, int x, int y) { + super(iInventory, slotIndex, x, y); this.containerTransmutationTablet = containerTransmutationTablet; } @@ -558,21 +489,33 @@ public boolean canTakeStack(EntityPlayer entityPlayer) { @Override public void onPickupFromSlot(EntityPlayer entityPlayer, ItemStack itemStack) { + + super.onPickupFromSlot(entityPlayer, itemStack); + + if (getHasStack()) { + ItemStack unitItemStack = ItemStackUtils.clone(itemStack, 1); + transmutationTablet.consumeInventoryForEnergyValue(unitItemStack); + } + + updateInventory(); + } + + public void onShiftPickupFromSlot(EntityPlayer entityPlayer, ItemStack itemStack) { + super.onPickupFromSlot(entityPlayer, itemStack); - if (this.getHasStack()) { - this.containerTransmutationTablet.tileEntityTransmutationTablet - .consumeInventoryForEnergyValue(itemStack); + if (getHasStack()) { + transmutationTablet.consumeInventoryForEnergyValue(itemStack); } + + updateInventory(); } @Override public void onSlotChanged() { - super.onSlotChanged(); - if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { - this.containerTransmutationTablet.tileEntityTransmutationTablet.updateEnergyValueFromInventory(); - } + super.onSlotChanged(); + transmutationTablet.updateEnergyValueFromInventory(); } @Override @@ -588,27 +531,30 @@ private class SlotTabletInput extends Slot { public SlotTabletInput(ContainerTransmutationTablet containerTransmutationTablet, IInventory iInventory, int slotIndex, int x, int y) { + super(iInventory, slotIndex, x, y); this.containerTransmutationTablet = containerTransmutationTablet; } @Override public boolean isItemValid(ItemStack itemStack) { - return EnergyValueRegistry.getInstance().hasEnergyValue(itemStack) - && AbilityRegistry.getInstance().isRecoverable(itemStack); + return EnergyValueRegistryProxy.hasEnergyValue(itemStack) + && BlacklistRegistryProxy.isExchangeable(itemStack); } @Override public void onPickupFromSlot(EntityPlayer entityPlayer, ItemStack itemStack) { + super.onPickupFromSlot(entityPlayer, itemStack); - this.containerTransmutationTablet.tileEntityTransmutationTablet.updateEnergyValueFromInventory(); + this.containerTransmutationTablet.transmutationTablet.updateEnergyValueFromInventory(); this.containerTransmutationTablet.updateInventory(); } @Override public void putStack(ItemStack itemStack) { + super.putStack(itemStack); - this.containerTransmutationTablet.tileEntityTransmutationTablet.updateEnergyValueFromInventory(); + this.containerTransmutationTablet.transmutationTablet.updateEnergyValueFromInventory(); this.containerTransmutationTablet.updateInventory(); } } diff --git a/src/main/java/com/pahimar/ee3/inventory/InventoryAlchemicalBag.java b/src/main/java/com/pahimar/ee3/inventory/InventoryAlchemicalBag.java index 648a0f9d..e9eb6ed4 100644 --- a/src/main/java/com/pahimar/ee3/inventory/InventoryAlchemicalBag.java +++ b/src/main/java/com/pahimar/ee3/inventory/InventoryAlchemicalBag.java @@ -37,6 +37,7 @@ public InventoryAlchemicalBag(ItemStack itemStack) { } public void onGuiSaved(EntityPlayer entityPlayer) { + parentItemStack = findParentItemStack(entityPlayer); if (parentItemStack != null) { @@ -45,11 +46,15 @@ public void onGuiSaved(EntityPlayer entityPlayer) { } public ItemStack findParentItemStack(EntityPlayer entityPlayer) { + if (NBTHelper.hasUUID(parentItemStack)) { + UUID parentItemStackUUID = new UUID( parentItemStack.getTagCompound().getLong(Names.NBT.UUID_MOST_SIG), parentItemStack.getTagCompound().getLong(Names.NBT.UUID_LEAST_SIG)); + for (int i = 0; i < entityPlayer.inventory.getSizeInventory(); i++) { + ItemStack itemStack = entityPlayer.inventory.getStackInSlot(i); if (NBTHelper.hasUUID(itemStack)) { @@ -73,9 +78,11 @@ public boolean matchesUUID(UUID uuid) { } public void save() { + NBTTagCompound nbtTagCompound = parentItemStack.getTagCompound(); if (nbtTagCompound == null) { + nbtTagCompound = new NBTTagCompound(); UUID uuid = UUID.randomUUID(); diff --git a/src/main/java/com/pahimar/ee3/inventory/InventoryAlchenomicon.java b/src/main/java/com/pahimar/ee3/inventory/InventoryAlchenomicon.java index 33241c98..af4c1be0 100644 --- a/src/main/java/com/pahimar/ee3/inventory/InventoryAlchenomicon.java +++ b/src/main/java/com/pahimar/ee3/inventory/InventoryAlchenomicon.java @@ -20,7 +20,7 @@ public InventoryAlchenomicon(Set knownTransmutations) { if (knownTransmutations != null) { this.knownTransmutations = knownTransmutations; } else { - this.knownTransmutations = new TreeSet(Comparators.idComparator); + this.knownTransmutations = new TreeSet(Comparators.ID_COMPARATOR); } inventory = knownTransmutations.toArray(inventory); } diff --git a/src/main/java/com/pahimar/ee3/inventory/InventoryTransmutationTablet.java b/src/main/java/com/pahimar/ee3/inventory/InventoryTransmutationTablet.java index 1612fd42..e125f83f 100644 --- a/src/main/java/com/pahimar/ee3/inventory/InventoryTransmutationTablet.java +++ b/src/main/java/com/pahimar/ee3/inventory/InventoryTransmutationTablet.java @@ -6,6 +6,7 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; +import com.pahimar.ee3.knowledge.PlayerKnowledge; import com.pahimar.ee3.reference.Comparators; import com.pahimar.ee3.reference.Names; @@ -15,18 +16,25 @@ public class InventoryTransmutationTablet implements IInventory { private Set knownTransmutations; public InventoryTransmutationTablet() { - this(null); + this(Collections.emptySet()); + } + + public InventoryTransmutationTablet(PlayerKnowledge playerKnowledge) { + this(playerKnowledge.getKnownItemStacks()); } public InventoryTransmutationTablet(Collection knownTransmutations) { + inventory = new ItemStack[30]; - this.knownTransmutations = new TreeSet(Comparators.idComparator); + this.knownTransmutations = new TreeSet<>(Comparators.ID_COMPARATOR); + if (knownTransmutations != null) { this.knownTransmutations.addAll(knownTransmutations); } - List knownTransmutationsList = new ArrayList(this.knownTransmutations); + List knownTransmutationsList = new ArrayList<>(this.knownTransmutations); + if (knownTransmutationsList.size() <= 30) { inventory = knownTransmutationsList.toArray(inventory); } else { @@ -47,6 +55,7 @@ public int getSizeInventory() { @Override public ItemStack getStackInSlot(int slotIndex) { + if (slotIndex < getSizeInventory()) { return inventory[slotIndex]; } @@ -60,7 +69,9 @@ public ItemStack getStackInSlot(int slotIndex) { */ @Override public ItemStack decrStackSize(int slotIndex, int decrementAmount) { + ItemStack itemStack = getStackInSlot(slotIndex); + if (itemStack != null) { if (itemStack.stackSize <= decrementAmount) { setInventorySlotContents(slotIndex, null); @@ -80,7 +91,9 @@ public ItemStack decrStackSize(int slotIndex, int decrementAmount) { @Override public ItemStack getStackInSlotOnClosing(int slotIndex) { + if (getStackInSlot(slotIndex) != null) { + ItemStack itemStack = inventory[slotIndex]; inventory[slotIndex] = null; return itemStack; @@ -91,8 +104,11 @@ public ItemStack getStackInSlotOnClosing(int slotIndex) { @Override public void setInventorySlotContents(int slotIndex, ItemStack itemStack) { + if (slotIndex < inventory.length) { + if (itemStack != null) { + ItemStack copiedItemStack = itemStack.copy(); copiedItemStack.stackSize = 1; inventory[slotIndex] = copiedItemStack; diff --git a/src/main/java/com/pahimar/ee3/item/ItemAlchemicalBag.java b/src/main/java/com/pahimar/ee3/item/ItemAlchemicalBag.java index edbe7a15..33202627 100644 --- a/src/main/java/com/pahimar/ee3/item/ItemAlchemicalBag.java +++ b/src/main/java/com/pahimar/ee3/item/ItemAlchemicalBag.java @@ -1,6 +1,7 @@ package com.pahimar.ee3.item; import java.util.List; +import java.util.UUID; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -8,16 +9,18 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import com.pahimar.ee3.EquivalentExchange3; -import com.pahimar.ee3.reference.*; +import com.pahimar.ee3.reference.Colors; +import com.pahimar.ee3.reference.GUIs; +import com.pahimar.ee3.reference.Names; +import com.pahimar.ee3.reference.Textures; import com.pahimar.ee3.util.ColorHelper; import com.pahimar.ee3.util.IOwnable; -import com.pahimar.ee3.util.ItemHelper; +import com.pahimar.ee3.util.ItemStackUtils; import com.pahimar.ee3.util.NBTHelper; import cpw.mods.fml.relauncher.Side; @@ -57,7 +60,7 @@ public void registerIcons(IIconRegister iconRegister) { @Override public IIcon getIcon(ItemStack itemStack, int renderPass) { if (renderPass == 0) { - if (NBTHelper.hasTag(itemStack, Names.NBT.ALCHEMICAL_BAG_GUI_OPEN)) { + if (NBTHelper.hasKey(itemStack, Names.NBT.ALCHEMICAL_BAG_GUI_OPEN)) { return icons[0]; } else { return icons[1]; @@ -82,18 +85,33 @@ public boolean getShareTag() { @Override public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer) { + if (!world.isRemote) { - if (!ItemHelper.hasOwnerUUID(itemStack)) { - ItemHelper.setOwner(itemStack, entityPlayer); - entityPlayer.addChatComponentMessage( - new ChatComponentTranslation( - Messages.OWNER_SET_TO_SELF, - new Object[] { itemStack.func_151000_E() })); + + // Set the owner of the bag if one doesn't exist already + if (ItemStackUtils.getOwnerUUID(itemStack) == null) { + ItemStackUtils.setOwner(itemStack, entityPlayer); + } + + // Set an UUID on the bag if one doesn't exist already + if (NBTHelper.getUUID(itemStack) == null) { + NBTHelper.setUUID(itemStack, UUID.randomUUID()); } - // Set a UUID on the Alchemical Bag, if one doesn't exist already - NBTHelper.setUUID(itemStack); // TODO Do a scan of inventory and if we find a bag with the same UUID, change it's UUID + for (int i = 0; i < entityPlayer.inventory.getSizeInventory(); i++) { + if (entityPlayer.inventory.getStackInSlot(i) != null) { + ItemStack itemStack1 = entityPlayer.inventory.getStackInSlot(i); + + if (itemStack1.getItem() instanceof ItemAlchemicalBag) { + if (NBTHelper.hasUUID(itemStack1) + && NBTHelper.getUUID(itemStack).equals(NBTHelper.getUUID(itemStack1))) { + NBTHelper.setUUID(itemStack1, UUID.randomUUID()); + } + } + } + } + NBTHelper.setBoolean(itemStack, Names.NBT.ALCHEMICAL_BAG_GUI_OPEN, true); entityPlayer.openGui( EquivalentExchange3.instance, diff --git a/src/main/java/com/pahimar/ee3/item/ItemAlchenomicon.java b/src/main/java/com/pahimar/ee3/item/ItemAlchenomicon.java index ab4a28d8..6ee4ffba 100644 --- a/src/main/java/com/pahimar/ee3/item/ItemAlchenomicon.java +++ b/src/main/java/com/pahimar/ee3/item/ItemAlchenomicon.java @@ -14,7 +14,7 @@ import com.pahimar.ee3.reference.Messages; import com.pahimar.ee3.reference.Names; import com.pahimar.ee3.util.IOwnable; -import com.pahimar.ee3.util.ItemHelper; +import com.pahimar.ee3.util.ItemStackUtils; public class ItemAlchenomicon extends ItemEE implements IOwnable, IEnergyValueProvider { @@ -31,8 +31,8 @@ public boolean getShareTag() { @Override public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer) { if (!world.isRemote) { - if (!ItemHelper.hasOwnerUUID(itemStack)) { - ItemHelper.setOwner(itemStack, entityPlayer); + if (ItemStackUtils.getOwnerUUID(itemStack) == null) { + ItemStackUtils.setOwner(itemStack, entityPlayer); entityPlayer.addChatComponentMessage( new ChatComponentTranslation( Messages.OWNER_SET_TO_SELF, diff --git a/src/main/java/com/pahimar/ee3/item/ItemDarkMatterAxe.java b/src/main/java/com/pahimar/ee3/item/ItemDarkMatterAxe.java index 8cff9539..1df3ac3f 100644 --- a/src/main/java/com/pahimar/ee3/item/ItemDarkMatterAxe.java +++ b/src/main/java/com/pahimar/ee3/item/ItemDarkMatterAxe.java @@ -49,7 +49,11 @@ public short getMaxChargeLevel() { @Override public short getChargeLevel(ItemStack itemStack) { - return NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL); + if (NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL) != null) { + return NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL); + } + + return 0; } @Override @@ -61,21 +65,15 @@ public void setChargeLevel(ItemStack itemStack, short chargeLevel) { @Override public void increaseChargeLevel(ItemStack itemStack) { - if (NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL) < this.getMaxChargeLevel()) { - NBTHelper.setShort( - itemStack, - Names.NBT.CHARGE_LEVEL, - (short) (NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL) + 1)); + if (getChargeLevel(itemStack) < this.getMaxChargeLevel()) { + NBTHelper.setShort(itemStack, Names.NBT.CHARGE_LEVEL, (short) (getChargeLevel(itemStack) + 1)); } } @Override public void decreaseChargeLevel(ItemStack itemStack) { - if (NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL) > 0) { - NBTHelper.setShort( - itemStack, - Names.NBT.CHARGE_LEVEL, - (short) (NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL) - 1)); + if (getChargeLevel(itemStack) > 0) { + NBTHelper.setShort(itemStack, Names.NBT.CHARGE_LEVEL, (short) (getChargeLevel(itemStack) - 1)); } } diff --git a/src/main/java/com/pahimar/ee3/item/ItemDarkMatterHoe.java b/src/main/java/com/pahimar/ee3/item/ItemDarkMatterHoe.java index 6d7828a2..77c68bc9 100644 --- a/src/main/java/com/pahimar/ee3/item/ItemDarkMatterHoe.java +++ b/src/main/java/com/pahimar/ee3/item/ItemDarkMatterHoe.java @@ -80,7 +80,11 @@ public short getMaxChargeLevel() { @Override public short getChargeLevel(ItemStack itemStack) { - return NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL); + if (NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL) != null) { + return NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL); + } + + return 0; } @Override @@ -92,21 +96,15 @@ public void setChargeLevel(ItemStack itemStack, short chargeLevel) { @Override public void increaseChargeLevel(ItemStack itemStack) { - if (NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL) < this.getMaxChargeLevel()) { - NBTHelper.setShort( - itemStack, - Names.NBT.CHARGE_LEVEL, - (short) (NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL) + 1)); + if (getChargeLevel(itemStack) < this.getMaxChargeLevel()) { + NBTHelper.setShort(itemStack, Names.NBT.CHARGE_LEVEL, (short) (getChargeLevel(itemStack) + 1)); } } @Override public void decreaseChargeLevel(ItemStack itemStack) { - if (NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL) > 0) { - NBTHelper.setShort( - itemStack, - Names.NBT.CHARGE_LEVEL, - (short) (NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL) - 1)); + if (getChargeLevel(itemStack) > 0) { + NBTHelper.setShort(itemStack, Names.NBT.CHARGE_LEVEL, (short) (getChargeLevel(itemStack) - 1)); } } @@ -150,7 +148,8 @@ public List getAvailableToolModes() { @Override public ToolMode getCurrentToolMode(ItemStack itemStack) { - if (NBTHelper.getShort(itemStack, Names.NBT.MODE) < ToolMode.TYPES.length) { + if (NBTHelper.getShort(itemStack, Names.NBT.MODE) != null + && NBTHelper.getShort(itemStack, Names.NBT.MODE) < ToolMode.TYPES.length) { return ToolMode.TYPES[NBTHelper.getShort(itemStack, Names.NBT.MODE)]; } diff --git a/src/main/java/com/pahimar/ee3/item/ItemDarkMatterPickAxe.java b/src/main/java/com/pahimar/ee3/item/ItemDarkMatterPickAxe.java index 4adc4be6..d71de0d1 100644 --- a/src/main/java/com/pahimar/ee3/item/ItemDarkMatterPickAxe.java +++ b/src/main/java/com/pahimar/ee3/item/ItemDarkMatterPickAxe.java @@ -101,7 +101,11 @@ public short getMaxChargeLevel() { @Override public short getChargeLevel(ItemStack itemStack) { - return NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL); + if (NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL) != null) { + return NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL); + } + + return 0; } @Override @@ -113,21 +117,15 @@ public void setChargeLevel(ItemStack itemStack, short chargeLevel) { @Override public void increaseChargeLevel(ItemStack itemStack) { - if (NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL) < this.getMaxChargeLevel()) { - NBTHelper.setShort( - itemStack, - Names.NBT.CHARGE_LEVEL, - (short) (NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL) + 1)); + if (getChargeLevel(itemStack) < this.getMaxChargeLevel()) { + NBTHelper.setShort(itemStack, Names.NBT.CHARGE_LEVEL, (short) (getChargeLevel(itemStack) + 1)); } } @Override public void decreaseChargeLevel(ItemStack itemStack) { - if (NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL) > 0) { - NBTHelper.setShort( - itemStack, - Names.NBT.CHARGE_LEVEL, - (short) (NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL) - 1)); + if (getChargeLevel(itemStack) > 0) { + NBTHelper.setShort(itemStack, Names.NBT.CHARGE_LEVEL, (short) (getChargeLevel(itemStack) - 1)); } } diff --git a/src/main/java/com/pahimar/ee3/item/ItemDarkMatterShovel.java b/src/main/java/com/pahimar/ee3/item/ItemDarkMatterShovel.java index 6cac14f6..2215bd2f 100644 --- a/src/main/java/com/pahimar/ee3/item/ItemDarkMatterShovel.java +++ b/src/main/java/com/pahimar/ee3/item/ItemDarkMatterShovel.java @@ -45,7 +45,12 @@ public short getMaxChargeLevel() { @Override public short getChargeLevel(ItemStack itemStack) { - return NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL); + + if (NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL) != null) { + return NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL); + } + + return 0; } @Override @@ -57,21 +62,15 @@ public void setChargeLevel(ItemStack itemStack, short chargeLevel) { @Override public void increaseChargeLevel(ItemStack itemStack) { - if (NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL) < this.getMaxChargeLevel()) { - NBTHelper.setShort( - itemStack, - Names.NBT.CHARGE_LEVEL, - (short) (NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL) + 1)); + if (getChargeLevel(itemStack) < this.getMaxChargeLevel()) { + NBTHelper.setShort(itemStack, Names.NBT.CHARGE_LEVEL, (short) (getChargeLevel(itemStack) + 1)); } } @Override public void decreaseChargeLevel(ItemStack itemStack) { - if (NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL) > 0) { - NBTHelper.setShort( - itemStack, - Names.NBT.CHARGE_LEVEL, - (short) (NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL) - 1)); + if (getChargeLevel(itemStack) > 0) { + NBTHelper.setShort(itemStack, Names.NBT.CHARGE_LEVEL, (short) (getChargeLevel(itemStack) - 1)); } } diff --git a/src/main/java/com/pahimar/ee3/item/ItemMiniumStone.java b/src/main/java/com/pahimar/ee3/item/ItemMiniumStone.java index d81433f2..2bc0298c 100644 --- a/src/main/java/com/pahimar/ee3/item/ItemMiniumStone.java +++ b/src/main/java/com/pahimar/ee3/item/ItemMiniumStone.java @@ -43,8 +43,8 @@ public ItemStack getContainerItem(ItemStack itemStack) { @Override @SideOnly(Side.CLIENT) public boolean hasEffect(ItemStack itemStack, int renderPass) { - return NBTHelper.hasTag(itemStack, Names.NBT.CRAFTING_GUI_OPEN) - || NBTHelper.hasTag(itemStack, Names.NBT.TRANSMUTATION_GUI_OPEN); + return NBTHelper.hasKey(itemStack, Names.NBT.CRAFTING_GUI_OPEN) + || NBTHelper.hasKey(itemStack, Names.NBT.TRANSMUTATION_GUI_OPEN); } @Override diff --git a/src/main/java/com/pahimar/ee3/item/ItemToolModalEE.java b/src/main/java/com/pahimar/ee3/item/ItemToolModalEE.java index a1cc9271..9d5b9d7a 100644 --- a/src/main/java/com/pahimar/ee3/item/ItemToolModalEE.java +++ b/src/main/java/com/pahimar/ee3/item/ItemToolModalEE.java @@ -24,7 +24,8 @@ public List getAvailableToolModes() { @Override public ToolMode getCurrentToolMode(ItemStack itemStack) { - if (NBTHelper.getShort(itemStack, Names.NBT.MODE) < ToolMode.TYPES.length) { + if (NBTHelper.getShort(itemStack, Names.NBT.MODE) != null + && NBTHelper.getShort(itemStack, Names.NBT.MODE) < ToolMode.TYPES.length) { return ToolMode.TYPES[NBTHelper.getShort(itemStack, Names.NBT.MODE)]; } diff --git a/src/main/java/com/pahimar/ee3/knowledge/AbilityRegistry.java b/src/main/java/com/pahimar/ee3/knowledge/AbilityRegistry.java deleted file mode 100644 index 7c6df56b..00000000 --- a/src/main/java/com/pahimar/ee3/knowledge/AbilityRegistry.java +++ /dev/null @@ -1,354 +0,0 @@ -package com.pahimar.ee3.knowledge; - -import java.io.*; -import java.lang.reflect.Type; -import java.util.Iterator; -import java.util.Set; -import java.util.TreeSet; - -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.MinecraftForge; - -import org.apache.logging.log4j.Marker; -import org.apache.logging.log4j.MarkerManager; - -import com.google.gson.*; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import com.pahimar.ee3.api.event.AbilityEvent; -import com.pahimar.ee3.api.knowledge.AbilityRegistryProxy; -import com.pahimar.ee3.exchange.EnergyValueRegistry; -import com.pahimar.ee3.exchange.WrappedStack; -import com.pahimar.ee3.reference.Files; -import com.pahimar.ee3.util.LoaderHelper; -import com.pahimar.ee3.util.LogHelper; -import com.pahimar.ee3.util.SerializationHelper; -import cpw.mods.fml.common.Loader; - -public class AbilityRegistry implements JsonSerializer, JsonDeserializer { - - public static final Marker ABILITY_MARKER = MarkerManager.getMarker("EE3_ABILITY", LogHelper.MOD_MARKER); - private static final Marker NOT_LEARABLE_MARKER = MarkerManager - .getMarker("EE3_ABILITY_NOT_LEARNABLE", ABILITY_MARKER); - private static final Marker LEARABLE_MARKER = MarkerManager.getMarker("EE3_ABILITY_LEARNABLE", ABILITY_MARKER); - private static final Marker NOT_RECOVERABLE_MARKER = MarkerManager - .getMarker("EE3_ABILITY_NOT_RECOVERABLE", ABILITY_MARKER); - private static final Marker RECOVERABLE_MARKER = MarkerManager.getMarker("EE3_ABILITY_RECOVERABLE", ABILITY_MARKER); - - private static final Gson jsonSerializer = (new GsonBuilder()).setPrettyPrinting() - .registerTypeAdapter(AbilityRegistry.class, new AbilityRegistry()).create(); - private static AbilityRegistry abilityRegistry = null; - - private static File abilityDirectory; - private boolean hasBeenModified; - private Set notLearnableSet; - private Set notRecoverableSet; - - private AbilityRegistry() { - hasBeenModified = false; - notLearnableSet = new TreeSet(); - notRecoverableSet = new TreeSet(); - } - - public static AbilityRegistry getInstance() { - if (abilityRegistry == null) { - abilityRegistry = new AbilityRegistry(); - abilityRegistry.init(); - } - - return abilityRegistry; - } - - private void init() { - notLearnableSet = new TreeSet(); - notRecoverableSet = new TreeSet(); - } - - public Set getNotLearnableStacks() { - return this.notLearnableSet; - } - - public boolean isLearnable(Object object) { - if (WrappedStack.canBeWrapped(object)) { - WrappedStack wrappedObject = WrappedStack.wrap(object); - - if (object instanceof ItemStack && ((ItemStack) object).isItemDamaged()) { - return false; - } else { - return !notLearnableSet.contains(wrappedObject) - && EnergyValueRegistry.getInstance().hasEnergyValue(wrappedObject); - } - } - - return false; - } - - public void setAsLearnable(Object object) { - if (WrappedStack.canBeWrapped(object)) { - WrappedStack wrappedStack = WrappedStack.wrap(object); - - if (wrappedStack != null && !MinecraftForge.EVENT_BUS.post(new AbilityEvent.SetLearnableEvent(object))) { - if (notLearnableSet.remove(wrappedStack)) { - hasBeenModified = true; - LogHelper.trace( - LEARABLE_MARKER, - "[{}] Mod with ID '{}' set object {} as LEARNABLE", - LoaderHelper.getLoaderState(), - Loader.instance().activeModContainer().getModId(), - wrappedStack); - } - } - } - } - - public void setAsNotLearnable(Object object) { - if (WrappedStack.canBeWrapped(object)) { - WrappedStack wrappedStack = WrappedStack.wrap(object); - - if (wrappedStack != null && !MinecraftForge.EVENT_BUS.post(new AbilityEvent.SetNotLearnableEvent(object))) { - if (notLearnableSet.add(wrappedStack)) { - hasBeenModified = true; - LogHelper.trace( - NOT_LEARABLE_MARKER, - "[{}] Mod with ID '{}' set object {} as NOT LEARNABLE", - LoaderHelper.getLoaderState(), - Loader.instance().activeModContainer().getModId(), - wrappedStack); - } - } - } - } - - public Set getNotRecoverableSet() { - return this.notRecoverableSet; - } - - public boolean isRecoverable(Object object) { - if (WrappedStack.canBeWrapped(object)) { - WrappedStack wrappedObject = WrappedStack.wrap(object); - return !notRecoverableSet.contains(wrappedObject) - && EnergyValueRegistry.getInstance().hasEnergyValue(wrappedObject); - } - - return false; - } - - public void setAsRecoverable(Object object) { - if (WrappedStack.canBeWrapped(object)) { - WrappedStack wrappedStack = WrappedStack.wrap(object); - - if (wrappedStack != null && !MinecraftForge.EVENT_BUS.post(new AbilityEvent.SetRecoverableEvent(object))) { - if (notRecoverableSet.remove(wrappedStack)) { - hasBeenModified = true; - LogHelper.trace( - RECOVERABLE_MARKER, - "[{}] Mod with ID '{}' set object {} as RECOVERABLE", - LoaderHelper.getLoaderState(), - Loader.instance().activeModContainer().getModId(), - wrappedStack); - } - } - } - } - - public void setAsNotRecoverable(Object object) { - if (WrappedStack.canBeWrapped(object)) { - WrappedStack wrappedStack = WrappedStack.wrap(object); - - if (wrappedStack != null - && !MinecraftForge.EVENT_BUS.post(new AbilityEvent.SetNotRecoverableEvent(object))) { - if (notRecoverableSet.add(wrappedStack)) { - hasBeenModified = true; - LogHelper.trace( - NOT_RECOVERABLE_MARKER, - "[{}] Mod with ID '{}' set object {} as NOT RECOVERABLE", - LoaderHelper.getLoaderState(), - Loader.instance().activeModContainer().getModId(), - wrappedStack); - } - } - } - } - - @Override - public String toString() { - StringBuilder stringBuilder = new StringBuilder(); - - stringBuilder.append("Not Learnables: "); - for (WrappedStack wrappedStack : notLearnableSet) { - stringBuilder.append(wrappedStack + " "); - } - stringBuilder.append(", Not Recoverables: "); - for (WrappedStack wrappedStack : notRecoverableSet) { - stringBuilder.append(wrappedStack + " "); - } - - return stringBuilder.toString(); - } - - @Override - public AbilityRegistry deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) - throws JsonParseException { - if (json.isJsonObject()) { - JsonObject jsonObject = (JsonObject) json; - - Set notLearnableStacks = new TreeSet(); - Set notRecoverableStacks = new TreeSet(); - - if (jsonObject.has("notLearnable") && jsonObject.get("notLearnable").isJsonArray()) { - JsonArray jsonArray = (JsonArray) jsonObject.get("notLearnable"); - Iterator iterator = jsonArray.iterator(); - - while (iterator.hasNext()) { - JsonElement jsonElement = iterator.next(); - WrappedStack wrappedStack = WrappedStack.jsonSerializer.fromJson(jsonElement, WrappedStack.class); - - if (wrappedStack != null) { - notLearnableStacks.add(wrappedStack); - } - } - } - - if (jsonObject.has("notRecoverable") && jsonObject.get("notRecoverable").isJsonArray()) { - JsonArray jsonArray = (JsonArray) jsonObject.get("notRecoverable"); - Iterator iterator = jsonArray.iterator(); - - while (iterator.hasNext()) { - JsonElement jsonElement = iterator.next(); - WrappedStack wrappedStack = WrappedStack.jsonSerializer.fromJson(jsonElement, WrappedStack.class); - - if (wrappedStack != null) { - notRecoverableStacks.add(wrappedStack); - } - } - } - - AbilityRegistry abilityRegistry1 = new AbilityRegistry(); - abilityRegistry1.notLearnableSet = notLearnableStacks; - abilityRegistry1.notRecoverableSet = notRecoverableStacks; - return abilityRegistry1; - } - - return null; - } - - @Override - public JsonElement serialize(AbilityRegistry abilityRegistry, Type typeOfSrc, JsonSerializationContext context) { - JsonObject jsonAbilityRegistry = new JsonObject(); - - JsonArray notLearnables = new JsonArray(); - for (WrappedStack wrappedStack : abilityRegistry.getNotLearnableStacks()) { - notLearnables.add(WrappedStack.jsonSerializer.toJsonTree(wrappedStack)); - } - jsonAbilityRegistry.add("notLearnable", notLearnables); - - JsonArray notRecoverables = new JsonArray(); - for (WrappedStack wrappedStack : abilityRegistry.getNotRecoverableSet()) { - notRecoverables.add(WrappedStack.jsonSerializer.toJsonTree(wrappedStack)); - } - jsonAbilityRegistry.add("notRecoverable", notRecoverables); - - return jsonAbilityRegistry; - } - - public void save() { - if (abilityDirectory != null) { - abilityDirectory.mkdirs(); - writeToFile(new File(abilityDirectory, Files.ABILITIES_JSON_FILE)); - } - } - - private void writeToFile(File file) { - JsonWriter jsonWriter; - - if (hasBeenModified) { - try { - jsonWriter = new JsonWriter(new FileWriter(file)); - jsonWriter.setIndent(" "); - jsonSerializer.toJson(this, AbilityRegistry.class, jsonWriter); - jsonWriter.close(); - hasBeenModified = false; - } catch (IOException e) { - e.printStackTrace(); - } - } - } - - public void loadAbilityRegistryFromFile(boolean loadFileOnly) { - if (abilityDirectory != null) { - File abilitiesFile = new File(abilityDirectory, Files.ABILITIES_JSON_FILE); - - if (abilitiesFile.exists()) { - readFromFile(abilitiesFile, loadFileOnly); - } - } else { - abilityDirectory = new File(SerializationHelper.getInstanceDataDirectory(), "abilities"); - abilityDirectory.mkdirs(); - } - } - - private void readFromFile(File file, boolean loadFileOnly) { - JsonReader jsonReader; - - try { - jsonReader = new JsonReader(new FileReader(file)); - AbilityRegistry abilityRegistry1 = jsonSerializer.fromJson(jsonReader, AbilityRegistry.class); - jsonReader.close(); - - if (!loadFileOnly) { - for (WrappedStack wrappedStack : abilityRegistry1.getNotLearnableStacks()) { - if (!this.notLearnableSet.contains(wrappedStack)) { - this.notLearnableSet.add(wrappedStack); - } - } - - for (WrappedStack wrappedStack : abilityRegistry1.getNotRecoverableSet()) { - if (!this.notRecoverableSet.contains(wrappedStack)) { - this.notRecoverableSet.add(wrappedStack); - } - } - } else { - this.notLearnableSet = abilityRegistry1.notLearnableSet; - this.notRecoverableSet = abilityRegistry1.notRecoverableSet; - } - - hasBeenModified = true; - } catch (FileNotFoundException ignored) { - // NOOP - } catch (IOException e) { - e.printStackTrace(); - } - } - - public void dumpAbilityRegistryToLog() { - dumpAbilityRegistryToLog(AbilityRegistryProxy.Abilities.ALL); - } - - public void dumpAbilityRegistryToLog(AbilityRegistryProxy.Abilities abilityType) { - if (abilityType == AbilityRegistryProxy.Abilities.NOT_LEARNABLE) { - if (this.notLearnableSet != null) { - for (WrappedStack wrappedStack : this.notLearnableSet) { - LogHelper.info(NOT_LEARABLE_MARKER, "Not Learnable: {}", wrappedStack); - } - } - } else if (abilityType == AbilityRegistryProxy.Abilities.NOT_RECOVERABLE) { - if (this.notRecoverableSet != null) { - for (WrappedStack wrappedStack : this.notRecoverableSet) { - LogHelper.info(NOT_RECOVERABLE_MARKER, "Not Recoverable: {}", wrappedStack); - } - } - } else if (abilityType == AbilityRegistryProxy.Abilities.ALL) { - if (this.notLearnableSet != null) { - for (WrappedStack wrappedStack : this.notLearnableSet) { - LogHelper.info(NOT_LEARABLE_MARKER, "Not Learnable: {}", wrappedStack); - } - } - - if (this.notRecoverableSet != null) { - for (WrappedStack wrappedStack : this.notRecoverableSet) { - LogHelper.info(NOT_RECOVERABLE_MARKER, "Not Recoverable: {}", wrappedStack); - } - } - } - } -} diff --git a/src/main/java/com/pahimar/ee3/knowledge/TransmutationKnowledge.java b/src/main/java/com/pahimar/ee3/knowledge/TransmutationKnowledge.java deleted file mode 100644 index 62f362c0..00000000 --- a/src/main/java/com/pahimar/ee3/knowledge/TransmutationKnowledge.java +++ /dev/null @@ -1,207 +0,0 @@ -package com.pahimar.ee3.knowledge; - -import java.io.*; -import java.lang.reflect.Type; -import java.util.*; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -import com.google.gson.*; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import com.pahimar.ee3.exchange.JsonItemStack; -import com.pahimar.ee3.reference.Comparators; -import com.pahimar.ee3.util.FilterUtils; -import com.pahimar.ee3.util.ItemHelper; - -public class TransmutationKnowledge - implements JsonSerializer, JsonDeserializer { - - private static final Gson jsonSerializer = (new GsonBuilder()).setPrettyPrinting() - .registerTypeAdapter(TransmutationKnowledge.class, new TransmutationKnowledge()).create(); - private Set knownTransmutations; - private boolean hasBeenModified = false; - - public TransmutationKnowledge() { - this(new TreeSet(Comparators.idComparator)); - } - - public TransmutationKnowledge(Collection knownTransmutations) { - this.knownTransmutations = new TreeSet(Comparators.idComparator); - this.knownTransmutations.addAll(knownTransmutations); - hasBeenModified = false; - } - - public TransmutationKnowledge(ItemStack... knownTransmutations) { - this(Arrays.asList(knownTransmutations)); - } - - public boolean isKnown(ItemStack itemStack) { - ItemStack unitItemStack = itemStack.copy(); - unitItemStack.stackSize = 1; - return this.knownTransmutations.contains(unitItemStack); - } - - public Set getKnownTransmutations() { - return this.knownTransmutations; - } - - public boolean learnTransmutation(ItemStack itemStack) { - ItemStack unitItemStack = itemStack.copy(); - unitItemStack.stackSize = 1; - - if (!this.knownTransmutations.contains(unitItemStack)) { - hasBeenModified = true; - return this.knownTransmutations.add(unitItemStack); - } - - return false; - } - - public boolean forgetTransmutation(ItemStack itemStack) { - ItemStack unitItemStack = itemStack.copy(); - unitItemStack.stackSize = 1; - - if (this.knownTransmutations.contains(unitItemStack)) { - hasBeenModified = true; - return this.knownTransmutations.remove(unitItemStack); - } - - return false; - } - - public void forgetAllTransmutations() { - this.knownTransmutations.clear(); - hasBeenModified = true; - } - - public boolean hasBeenModified() { - return hasBeenModified; - } - - public Set filterByNameStartsWith(String filterString) { - return FilterUtils.filterByNameStartsWith(getKnownTransmutations(), filterString); - } - - public Set filterByNameContains(String filterString) { - return FilterUtils.filterByNameContains(getKnownTransmutations(), filterString); - } - - @Override - public String toString() { - StringBuilder stringBuilder = new StringBuilder(); - - stringBuilder.append("["); - for (ItemStack itemStack : knownTransmutations) { - stringBuilder.append(String.format("%s, ", ItemHelper.toString(itemStack))); - } - stringBuilder.append("]"); - - return stringBuilder.toString(); - } - - public static TransmutationKnowledge createFromJson(String jsonTransmutationKnowledge) throws JsonParseException { - try { - return jsonSerializer.fromJson(jsonTransmutationKnowledge, TransmutationKnowledge.class); - } catch (JsonSyntaxException exception) { - exception.printStackTrace(); - } catch (JsonParseException exception) { - exception.printStackTrace(); - } - - return null; - } - - public String toJson() { - return jsonSerializer.toJson(this); - } - - @Override - public TransmutationKnowledge deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) - throws JsonParseException { - if (json.isJsonObject()) { - JsonObject jsonObject = (JsonObject) json; - - Set itemStacks = new TreeSet(Comparators.idComparator); - - if (jsonObject.has("knownTransmutations") && jsonObject.get("knownTransmutations").isJsonArray()) { - JsonArray jsonArray = (JsonArray) jsonObject.get("knownTransmutations"); - Iterator iterator = jsonArray.iterator(); - - while (iterator.hasNext()) { - JsonElement jsonElement = iterator.next(); - if (jsonElement.isJsonObject()) { - try { - JsonItemStack jsonItemStack = JsonItemStack.jsonSerializer - .fromJson(jsonElement, JsonItemStack.class); - - ItemStack itemStack = null; - Item item = (Item) Item.itemRegistry.getObject(jsonItemStack.itemName); - if (item != null) { - itemStack = new ItemStack(item, 1, jsonItemStack.itemDamage); - if (jsonItemStack.itemNBTTagCompound != null) { - itemStack.stackTagCompound = jsonItemStack.itemNBTTagCompound; - } - } - - if (itemStack != null) { - itemStacks.add(itemStack); - } - } catch (JsonParseException e) {} - } - } - } - - return new TransmutationKnowledge(itemStacks); - } - - return null; - } - - @Override - public JsonElement serialize(TransmutationKnowledge transmutationKnowledge, Type typeOfSrc, - JsonSerializationContext context) { - JsonObject jsonTransmutationKnowledge = new JsonObject(); - - JsonArray knownTransmutations = new JsonArray(); - for (ItemStack itemStack : transmutationKnowledge.getKnownTransmutations()) { - knownTransmutations.add(JsonItemStack.jsonSerializer.toJsonTree(new JsonItemStack(itemStack))); - } - jsonTransmutationKnowledge.add("knownTransmutations", knownTransmutations); - - return jsonTransmutationKnowledge; - } - - public static void writeToFile(File file, TransmutationKnowledge transmutationKnowledge) { - JsonWriter jsonWriter; - - try { - jsonWriter = new JsonWriter(new FileWriter(file)); - jsonWriter.setIndent(" "); - jsonSerializer.toJson(transmutationKnowledge, TransmutationKnowledge.class, jsonWriter); - jsonWriter.close(); - transmutationKnowledge.hasBeenModified = false; - } catch (IOException e) { - e.printStackTrace(); - } - } - - public static TransmutationKnowledge readFromFile(File file) { - JsonReader jsonReader; - - try { - jsonReader = new JsonReader(new FileReader(file)); - TransmutationKnowledge transmutationKnowledge = jsonSerializer - .fromJson(jsonReader, TransmutationKnowledge.class); - jsonReader.close(); - return transmutationKnowledge; - } catch (FileNotFoundException ignored) { - // NOOP - } catch (IOException e) { - e.printStackTrace(); - } - - return null; - } -} diff --git a/src/main/java/com/pahimar/ee3/knowledge/TransmutationKnowledgeRegistry.java b/src/main/java/com/pahimar/ee3/knowledge/TransmutationKnowledgeRegistry.java deleted file mode 100644 index b780e37f..00000000 --- a/src/main/java/com/pahimar/ee3/knowledge/TransmutationKnowledgeRegistry.java +++ /dev/null @@ -1,408 +0,0 @@ -package com.pahimar.ee3.knowledge; - -import java.io.File; -import java.util.HashMap; -import java.util.Set; -import java.util.UUID; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.MinecraftForge; - -import com.pahimar.ee3.api.event.PlayerKnowledgeEvent; -import com.pahimar.ee3.api.event.TemplateKnowledgeEvent; -import com.pahimar.ee3.reference.Files; -import com.pahimar.ee3.util.FilterUtils; -import com.pahimar.ee3.util.SerializationHelper; - -public class TransmutationKnowledgeRegistry { - - private static TransmutationKnowledgeRegistry transmutationKnowledgeRegistry = null; - private static File playerKnowledgeDirectory, dataKnowledgeDirectory; - private static TransmutationKnowledge templateKnowledge; - private static HashMap playerKnowledgeMap; - - private TransmutationKnowledgeRegistry() { - playerKnowledgeDirectory = new File( - SerializationHelper.getInstancePlayerDataDirectory(), - "knowledge" + File.separator + "transmutation"); - playerKnowledgeDirectory.mkdirs(); - - dataKnowledgeDirectory = new File( - SerializationHelper.getInstanceDataDirectory(), - "knowledge" + File.separator + "transmutation"); - dataKnowledgeDirectory.mkdirs(); - - loadTemplateKnowledgeFromDisk(); - - playerKnowledgeMap = new HashMap(); - } - - public static TransmutationKnowledgeRegistry getInstance() { - if (transmutationKnowledgeRegistry == null) { - transmutationKnowledgeRegistry = new TransmutationKnowledgeRegistry(); - } - - return transmutationKnowledgeRegistry; - } - - public TransmutationKnowledge getTemplateKnowledge() { - return templateKnowledge; - } - - /* Template Related Transmutation Knowledge */ - public Set getTemplatesKnownTransmutations() { - if (templateKnowledge == null) { - loadTemplateKnowledgeFromDisk(); - } - - return templateKnowledge.getKnownTransmutations(); - } - - public Set getTemplatesKnownTransmutationsFilteredStartsWith(String filterString) { - if (templateKnowledge == null) { - loadTemplateKnowledgeFromDisk(); - } - - return FilterUtils.filterByNameStartsWith(templateKnowledge.getKnownTransmutations(), filterString); - } - - public Set getTemplatesKnownTransmutationsFilteredContains(String filterString) { - if (templateKnowledge == null) { - loadTemplateKnowledgeFromDisk(); - } - - return FilterUtils.filterByNameContains(templateKnowledge.getKnownTransmutations(), filterString); - } - - public boolean doesTemplateKnow(ItemStack itemStack) { - if (templateKnowledge == null) { - loadTemplateKnowledgeFromDisk(); - } - - return templateKnowledge.isKnown(itemStack); - } - - public boolean canTemplateLearn(ItemStack itemStack) { - if (AbilityRegistry.getInstance().isLearnable(itemStack)) { - if (templateKnowledge == null) { - loadTemplateKnowledgeFromDisk(); - } - return !templateKnowledge.isKnown(itemStack); - } - - return false; - } - - public void teachTemplate(ItemStack itemStack) { - if (templateKnowledge == null) { - loadTemplateKnowledgeFromDisk(); - } - - if (canTemplateLearn(itemStack) - && !MinecraftForge.EVENT_BUS.post(new TemplateKnowledgeEvent.TemplateLearnKnowledgeEvent(itemStack))) { - templateKnowledge.learnTransmutation(itemStack); - saveTemplateKnowledgeToDisk(); - } - } - - public void makeTemplateForget(ItemStack itemStack) { - if (templateKnowledge == null) { - loadTemplateKnowledgeFromDisk(); - } - - if (doesTemplateKnow(itemStack) - && !MinecraftForge.EVENT_BUS.post(new TemplateKnowledgeEvent.TemplateForgetKnowledgeEvent(itemStack))) { - templateKnowledge.forgetTransmutation(itemStack); - saveTemplateKnowledgeToDisk(); - } - } - - public void makeTemplateForgetEverything() { - if (templateKnowledge == null) { - loadTemplateKnowledgeFromDisk(); - } - - if (!MinecraftForge.EVENT_BUS.post(new TemplateKnowledgeEvent.TemplateForgetAllKnowledgeEvent())) { - templateKnowledge.forgetAllTransmutations(); - saveTemplateKnowledgeToDisk(); - } - } - - /* Player Related Transmutation Knowledge */ - public Set getPlayersKnownTransmutations(EntityPlayer entityPlayer) { - if (entityPlayer != null) { - return getPlayersKnownTransmutations(entityPlayer.getUniqueID()); - } - - return null; - } - - public Set getPlayersKnownTransmutations(UUID playerUUID) { - if (playerUUID != null) { - loadPlayerFromDiskIfNeeded(playerUUID); - - if (playerKnowledgeMap.containsKey(playerUUID)) { - return playerKnowledgeMap.get(playerUUID).getKnownTransmutations(); - } - } - - return null; - } - - public Set getPlayersKnownTransmutationsFilteredStartsWith(EntityPlayer entityPlayer, - String startsWith) { - if (entityPlayer != null) { - return getPlayersKnownTransmutationsFilteredStartsWith(entityPlayer.getUniqueID(), startsWith); - } - - return null; - } - - public Set getPlayersKnownTransmutationsFilteredStartsWith(UUID playerUUID, String startsWith) { - if (playerUUID != null) { - loadPlayerFromDiskIfNeeded(playerUUID); - - if (playerKnowledgeMap.containsKey(playerUUID)) { - return playerKnowledgeMap.get(playerUUID).filterByNameStartsWith(startsWith); - } - } - - return null; - } - - public Set getPlayersKnownTransmutationsFilteredContains(EntityPlayer entityPlayer, String contains) { - if (entityPlayer != null) { - return getPlayersKnownTransmutationsFilteredContains(entityPlayer.getUniqueID(), contains); - } - - return null; - } - - public Set getPlayersKnownTransmutationsFilteredContains(UUID playerUUID, String contains) { - if (playerUUID != null) { - loadPlayerFromDiskIfNeeded(playerUUID); - - if (playerKnowledgeMap.containsKey(playerUUID)) { - return playerKnowledgeMap.get(playerUUID).filterByNameContains(contains); - } - } - - return null; - } - - public boolean doesPlayerKnow(EntityPlayer entityPlayer, ItemStack itemStack) { - if (entityPlayer != null && itemStack != null) { - loadPlayerFromDiskIfNeeded(entityPlayer); - - if (playerKnowledgeMap.containsKey(entityPlayer.getUniqueID())) { - return playerKnowledgeMap.get(entityPlayer.getUniqueID()).isKnown(itemStack); - } - } - - return false; - } - - public boolean doesPlayerKnow(UUID playerUUID, ItemStack itemStack) { - if (playerUUID != null && itemStack != null) { - loadPlayerFromDiskIfNeeded(playerUUID); - - if (playerKnowledgeMap.containsKey(playerUUID)) { - return playerKnowledgeMap.get(playerUUID).isKnown(itemStack); - } - } - - return false; - } - - public boolean canPlayerLearn(EntityPlayer entityPlayer, ItemStack itemStack) { - if (entityPlayer != null) { - return canPlayerLearn(entityPlayer.getUniqueID(), itemStack); - } - - return false; - } - - public boolean canPlayerLearn(UUID playerUUID, ItemStack itemStack) { - if (playerUUID != null && itemStack != null) { - if (AbilityRegistry.getInstance().isLearnable(itemStack)) { - loadPlayerFromDiskIfNeeded(playerUUID); - - if (playerKnowledgeMap.containsKey(playerUUID)) { - return !playerKnowledgeMap.get(playerUUID).isKnown(itemStack); - } - } - } - - return false; - } - - public void teachPlayer(EntityPlayer entityPlayer, ItemStack itemStack) { - if (entityPlayer != null) { - teachPlayer(entityPlayer.getUniqueID(), itemStack); - } - } - - public void teachPlayer(UUID playerUUID, ItemStack itemStack) { - if (playerUUID != null && itemStack != null && canPlayerLearn(playerUUID, itemStack)) { - loadPlayerFromDiskIfNeeded(playerUUID); - if (playerKnowledgeMap.containsKey(playerUUID) && !MinecraftForge.EVENT_BUS - .post(new PlayerKnowledgeEvent.PlayerLearnKnowledgeEvent(playerUUID, itemStack))) { - playerKnowledgeMap.get(playerUUID).learnTransmutation(itemStack); - savePlayerKnowledgeToDisk(playerUUID); - } - } - } - - public void makePlayerForget(EntityPlayer entityPlayer, ItemStack itemStack) { - if (entityPlayer != null) { - makePlayerForget(entityPlayer.getUniqueID(), itemStack); - } - } - - public void makePlayerForget(UUID playerUUID, ItemStack itemStack) { - if (playerUUID != null && itemStack != null && doesPlayerKnow(playerUUID, itemStack)) { - loadPlayerFromDiskIfNeeded(playerUUID); - if (playerKnowledgeMap.containsKey(playerUUID) && !MinecraftForge.EVENT_BUS - .post(new PlayerKnowledgeEvent.PlayerForgetKnowledgeEvent(playerUUID, itemStack))) { - playerKnowledgeMap.get(playerUUID).forgetTransmutation(itemStack); - savePlayerKnowledgeToDisk(playerUUID); - } - } - } - - public void makePlayerForgetEverything(EntityPlayer entityPlayer) { - if (entityPlayer != null) { - makePlayerForgetEverything(entityPlayer.getUniqueID()); - } - } - - public void makePlayerForgetEverything(UUID playerUUID) { - if (playerUUID != null) { - loadPlayerFromDiskIfNeeded(playerUUID); - if (playerKnowledgeMap.containsKey(playerUUID) && !MinecraftForge.EVENT_BUS - .post(new PlayerKnowledgeEvent.PlayerForgetAllKnowledgeEvent(playerUUID))) { - playerKnowledgeMap.get(playerUUID).forgetAllTransmutations(); - savePlayerKnowledgeToDisk(playerUUID); - } - } - } - - /* Serialization */ - public void loadTemplateKnowledgeFromDisk() { - if (dataKnowledgeDirectory != null) { - File templateFile = new File(dataKnowledgeDirectory, Files.TEMPLATE_JSON_FILE); - - if (!templateFile.exists()) { - templateKnowledge = new TransmutationKnowledge(); - SerializationHelper.writeTransmutationKnowledgeToFile( - dataKnowledgeDirectory, - Files.TEMPLATE_JSON_FILE, - templateKnowledge); - } else { - templateKnowledge = SerializationHelper - .readTransmutationKnowledgeFromFile(dataKnowledgeDirectory, Files.TEMPLATE_JSON_FILE); - } - } else { - templateKnowledge = new TransmutationKnowledge(); - } - } - - public void saveTemplateKnowledgeToDisk() { - if (dataKnowledgeDirectory != null) { - if (templateKnowledge != null) { - SerializationHelper.writeTransmutationKnowledgeToFile( - dataKnowledgeDirectory, - Files.TEMPLATE_JSON_FILE, - templateKnowledge); - } else { - templateKnowledge = new TransmutationKnowledge(); - SerializationHelper.writeTransmutationKnowledgeToFile( - dataKnowledgeDirectory, - Files.TEMPLATE_JSON_FILE, - templateKnowledge); - } - } - } - - public void loadPlayerFromDiskIfNeeded(EntityPlayer entityPlayer) { - if (entityPlayer != null && entityPlayer.getUniqueID() != null) { - loadPlayerFromDiskIfNeeded(entityPlayer.getUniqueID()); - } - } - - public void loadPlayerFromDiskIfNeeded(UUID playerUUID) { - if (playerUUID != null && playerKnowledgeDirectory != null && !playerKnowledgeMap.containsKey(playerUUID)) { - TransmutationKnowledge playerTransmutationKnowledge = new TransmutationKnowledge(); - - File playerKnowledgeFile = new File(playerKnowledgeDirectory, playerUUID.toString() + ".json"); - - if (playerKnowledgeFile.exists() && playerKnowledgeFile.isFile()) { - playerTransmutationKnowledge = SerializationHelper - .readTransmutationKnowledgeFromFile(playerKnowledgeDirectory, playerUUID.toString() + ".json"); - } - - playerKnowledgeMap.put(playerUUID, playerTransmutationKnowledge); - } - } - - public void unloadPlayer(EntityPlayer entityPlayer) { - if (entityPlayer != null) { - unloadPlayer(entityPlayer.getUniqueID()); - } - } - - public void unloadPlayer(UUID playerUUID) { - if (playerUUID != null) { - if (playerKnowledgeMap.containsKey(playerUUID)) { - savePlayerKnowledgeToDisk(playerUUID); - playerKnowledgeMap.remove(playerUUID); - } - } - } - - public void savePlayerKnowledgeToDisk(EntityPlayer entityPlayer) { - if (entityPlayer != null && entityPlayer.getUniqueID() != null) { - savePlayerKnowledgeToDisk(entityPlayer.getUniqueID()); - } - } - - public void savePlayerKnowledgeToDisk(UUID playerUUID) { - if (playerUUID != null && playerKnowledgeDirectory != null) { - if (playerKnowledgeMap.containsKey(playerUUID) && playerKnowledgeMap.get(playerUUID) != null) { - if (playerKnowledgeMap.get(playerUUID).hasBeenModified()) { - SerializationHelper.writeTransmutationKnowledgeToFile( - playerKnowledgeDirectory, - playerUUID.toString() + ".json", - playerKnowledgeMap.get(playerUUID)); - } - } else { - loadPlayerFromDiskIfNeeded(playerUUID); - SerializationHelper.writeTransmutationKnowledgeToFile( - playerKnowledgeDirectory, - playerUUID.toString() + ".json", - playerKnowledgeMap.get(playerUUID)); - } - } - } - - public void saveAll() { - if (dataKnowledgeDirectory != null) { - saveTemplateKnowledgeToDisk(); - } - - if (playerKnowledgeDirectory != null) { - for (UUID playerUUID : playerKnowledgeMap.keySet()) { - SerializationHelper.writeTransmutationKnowledgeToFile( - playerKnowledgeDirectory, - playerUUID.toString() + ".json", - playerKnowledgeMap.get(playerUUID)); - } - } - } - - public void clear() { - saveAll(); - this.transmutationKnowledgeRegistry = null; - } -} diff --git a/src/main/java/com/pahimar/ee3/nei/CalcinationHandler.java b/src/main/java/com/pahimar/ee3/nei/CalcinationHandler.java deleted file mode 100644 index 68a87e1f..00000000 --- a/src/main/java/com/pahimar/ee3/nei/CalcinationHandler.java +++ /dev/null @@ -1,193 +0,0 @@ -package com.pahimar.ee3.nei; - -import static codechicken.lib.gui.GuiDraw.*; - -import java.awt.*; -import java.text.DecimalFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.StatCollector; - -import org.lwjgl.opengl.GL11; - -import codechicken.nei.NEIServerUtils; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.FurnaceRecipeHandler; -import codechicken.nei.recipe.TemplateRecipeHandler; - -import com.pahimar.ee3.api.exchange.EnergyValue; -import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy; -import com.pahimar.ee3.client.gui.inventory.GuiCalcinator; -import com.pahimar.ee3.item.ItemAlchemicalDust; -import com.pahimar.ee3.reference.Names; -import com.pahimar.ee3.reference.Reference; -import com.pahimar.ee3.reference.Textures; -import com.pahimar.ee3.util.CalcinationHelper; - -public class CalcinationHandler extends TemplateRecipeHandler { - - private static final DecimalFormat energyValueDecimalFormat = new DecimalFormat("###,###,###,###,###.###"); - - public class CachedCalcinationRecipe extends CachedRecipe { - - public List inputs; - public PositionedStack output; - - public EnergyValue minEnergyValue; - public EnergyValue maxEnergyValue; - - public CachedCalcinationRecipe(ItemStack outputDust) { - output = new PositionedStack(outputDust, 101, 19); - - inputs = new ArrayList(); - - minEnergyValue = EnergyValueRegistryProxy.getEnergyValue(outputDust); - maxEnergyValue = (outputDust.getItemDamage() < (ItemAlchemicalDust.getAlchemicalDusts().size() - 1) - ? EnergyValueRegistryProxy - .getEnergyValue(ItemAlchemicalDust.getAlchemicalDusts().get(outputDust.getItemDamage() + 1)) - : new EnergyValue(Float.MAX_VALUE)); - - for (Object obj : EnergyValueRegistryProxy.getStacksInRange(minEnergyValue, maxEnergyValue)) { - if (obj instanceof ItemStack) { - inputs.add(new PositionedStack((ItemStack) obj, 40, 0)); - } - } - } - - public CachedCalcinationRecipe(ItemStack inputStack, ItemStack outputDust) { - inputStack.stackSize = 1; - inputs = Arrays.asList(new PositionedStack[] { new PositionedStack(inputStack, 40, 0) }); - - output = new PositionedStack(outputDust, 101, 19); - - minEnergyValue = EnergyValueRegistryProxy.getEnergyValue(outputDust); - maxEnergyValue = (outputDust.getItemDamage() < (ItemAlchemicalDust.getAlchemicalDusts().size() - 1) - ? EnergyValueRegistryProxy - .getEnergyValue(ItemAlchemicalDust.getAlchemicalDusts().get(outputDust.getItemDamage() + 1)) - : new EnergyValue(Float.MAX_VALUE)); - } - - @Override - public PositionedStack getIngredient() { - return inputs.get((cycleticks / 48) % inputs.size()); - } - - public PositionedStack getOtherStack() { - return new PositionedStack( - FurnaceRecipeHandler.afuels.get((cycleticks / 48) % FurnaceRecipeHandler.afuels.size()).stack.item, - 40, - 45); - } - - @Override - public PositionedStack getResult() { - return output; - } - } - - @Override - public Class getGuiClass() { - return GuiCalcinator.class; - } - - @Override - public String getGuiTexture() { - return Textures.Gui.CALCINATOR.toString(); - } - - @Override - public String getRecipeName() { - return StatCollector.translateToLocal("gui.nei.ee3:calcination"); - } - - public String getRecipeID() { - return Reference.MOD_ID + ":" + Names.Blocks.CALCINATOR; - } - - @Override - public void loadCraftingRecipes(ItemStack result) { - for (ItemStack stack : ItemAlchemicalDust.getAlchemicalDusts()) { - if (NEIServerUtils.areStacksSameTypeCrafting(stack, result)) { - arecipes.add(new CachedCalcinationRecipe(stack)); - } - } - } - - @Override - public void loadCraftingRecipes(String outputId, Object... results) { - if (outputId.equals(getRecipeID())) { - for (ItemStack stack : ItemAlchemicalDust.getAlchemicalDusts()) { - arecipes.add(new CachedCalcinationRecipe(stack)); - } - } else { - super.loadCraftingRecipes(outputId, results); - } - } - - @Override - public void loadTransferRects() { - transferRects.add(new RecipeTransferRect(new Rectangle(39, 20, 18, 18), "fuel")); - transferRects.add(new RecipeTransferRect(new Rectangle(69, 19, 24, 16), getRecipeID())); - } - - @Override - public void loadUsageRecipes(ItemStack ingredient) { - for (ItemStack stack : ItemAlchemicalDust.getAlchemicalDusts()) { - if (NEIServerUtils.areStacksSameTypeCrafting(stack, CalcinationHelper.getCalcinationResult(ingredient))) { - arecipes.add(new CachedCalcinationRecipe(ingredient, stack)); - } - } - - } - - @Override - public int recipiesPerPage() { - return 1; - } - - @Override - public void drawBackground(int recipe) { - GL11.glColor4f(1, 1, 1, 1); - changeTexture(getGuiTexture()); - drawTexturedModalRect(14, -3, 19, 7, 143, 68); - } - - @Override - public void drawExtras(int recipe) { - drawProgressBar(41, 23, 176, 0, 14, 14, 48, 7); - drawProgressBar(70, 20, 176, 14, 24, 16, 48, 0); - CachedCalcinationRecipe cRecipe = (CachedCalcinationRecipe) arecipes.get(recipe); - drawStringC(StatCollector.translateToLocal("gui.nei.ee3:calcination.tooltip.1"), 83, 75, 0x404040, false); - drawStringC(cRecipe.getResult().item.getDisplayName() + ":", 83, 85, 0x404040, false); - - if (cRecipe != null && cRecipe.minEnergyValue != null - && cRecipe.maxEnergyValue != null - && EnergyValueRegistryProxy.getEnergyValue( - ItemAlchemicalDust.getAlchemicalDusts().get(ItemAlchemicalDust.getAlchemicalDusts().size() - 1)) - != null) { - drawStringC( - StatCollector - .translateToLocalFormatted( - "gui.nei.ee3:calcination.tooltip.2", - (cRecipe.minEnergyValue.getValue() > 1 - ? energyValueDecimalFormat.format(cRecipe.minEnergyValue.getValue()) - : "0"), - (cRecipe.maxEnergyValue.getValue() <= EnergyValueRegistryProxy - .getEnergyValue( - ItemAlchemicalDust.getAlchemicalDusts() - .get(ItemAlchemicalDust.getAlchemicalDusts().size() - 1)) - .getValue() - ? energyValueDecimalFormat.format(cRecipe.maxEnergyValue.getValue()) - : "\u221E")), - 83, - 95, - 0x404040, - false); - } - } - -} diff --git a/src/main/java/com/pahimar/ee3/nei/NEIConfig.java b/src/main/java/com/pahimar/ee3/nei/NEIConfig.java index 4de4f9e0..9bfe41fe 100644 --- a/src/main/java/com/pahimar/ee3/nei/NEIConfig.java +++ b/src/main/java/com/pahimar/ee3/nei/NEIConfig.java @@ -23,14 +23,10 @@ public String getVersion() { @Override public void loadConfig() { AludelRecipeHandler aludelRecipeHandler = new AludelRecipeHandler(); - CalcinationHandler calcinationHandler = new CalcinationHandler(); API.registerRecipeHandler(aludelRecipeHandler); API.registerUsageHandler(aludelRecipeHandler); - API.registerRecipeHandler(calcinationHandler); - API.registerUsageHandler(calcinationHandler); - API.hideItem(new ItemStack(ModBlocks.transmutationTablet)); API.hideItem(new ItemStack(ModBlocks.dummyArray)); API.hideItem(new ItemStack(ModBlocks.alchemyArray)); diff --git a/src/main/java/com/pahimar/ee3/network/PacketHandler.java b/src/main/java/com/pahimar/ee3/network/PacketHandler.java index 688ddf9a..65498cd2 100644 --- a/src/main/java/com/pahimar/ee3/network/PacketHandler.java +++ b/src/main/java/com/pahimar/ee3/network/PacketHandler.java @@ -41,15 +41,13 @@ public static void init() { Side.CLIENT); INSTANCE.registerMessage(MessageSingleParticleEvent.class, MessageSingleParticleEvent.class, 14, Side.CLIENT); INSTANCE.registerMessage(MessageSliderElementUpdated.class, MessageSliderElementUpdated.class, 15, Side.SERVER); - INSTANCE.registerMessage( - MessageTransmutationKnowledgeUpdate.class, - MessageTransmutationKnowledgeUpdate.class, - 16, - Side.CLIENT); + INSTANCE.registerMessage(MessagePlayerKnowledge.class, MessagePlayerKnowledge.class, 16, Side.CLIENT); INSTANCE.registerMessage( MessageTileEntityResearchStation.class, MessageTileEntityResearchStation.class, 17, Side.CLIENT); + INSTANCE.registerMessage(MessageSyncBlacklist.class, MessageSyncBlacklist.class, 18, Side.CLIENT); + INSTANCE.registerMessage(MessageSetBlacklistEntry.class, MessageSetBlacklistEntry.class, 19, Side.CLIENT); } } diff --git a/src/main/java/com/pahimar/ee3/network/message/MessageGuiElementClicked.java b/src/main/java/com/pahimar/ee3/network/message/MessageGuiElementClicked.java index 632be9e1..acb6a5e0 100644 --- a/src/main/java/com/pahimar/ee3/network/message/MessageGuiElementClicked.java +++ b/src/main/java/com/pahimar/ee3/network/message/MessageGuiElementClicked.java @@ -14,17 +14,17 @@ public class MessageGuiElementClicked implements IMessage, IMessageHandler { - public EnergyValueStackMapping energyValueStackMapping; + public Map energyValueMap; public MessageSetEnergyValue() {} public MessageSetEnergyValue(WrappedStack wrappedStack, EnergyValue energyValue) { - this.energyValueStackMapping = new EnergyValueStackMapping(wrappedStack, energyValue); + + this.energyValueMap = new TreeMap<>(); + if (wrappedStack != null && wrappedStack.getWrappedObject() != null && energyValue != null) { + this.energyValueMap.put(wrappedStack, energyValue); + } + } + + public MessageSetEnergyValue(Map energyValueMap) { + this.energyValueMap = energyValueMap; } @Override public void fromBytes(ByteBuf buf) { - byte[] compressedEnergyValueStackMapping = null; - int energyValueStackMappingByteCount = buf.readInt(); - if (energyValueStackMappingByteCount > 0) { - compressedEnergyValueStackMapping = buf.readBytes(energyValueStackMappingByteCount).array(); - } + int compressedJsonLength = buf.readInt(); + + if (compressedJsonLength != 0) { + byte[] compressedValueMap = buf.readBytes(compressedJsonLength).array(); + + if (compressedValueMap != null) { - if (compressedEnergyValueStackMapping != null) { - String decompressedEnergyValueStackMapping = CompressionHelper - .decompressStringFromByteArray(compressedEnergyValueStackMapping); - this.energyValueStackMapping = EnergyValueStackMapping.createFromJson(decompressedEnergyValueStackMapping); + String jsonString = CompressionHelper.decompress(compressedValueMap); + + try { + energyValueMap = SerializationHelper.GSON + .fromJson(jsonString, SerializationHelper.ENERGY_VALUE_MAP_TYPE); + } catch (JsonParseException e) { + LogHelper.warn("Failed to read energy value map from server"); + energyValueMap = null; + } + } else { + energyValueMap = null; + } + } else { + energyValueMap = null; } } @Override public void toBytes(ByteBuf buf) { - byte[] compressedBytes = null; - String jsonEnergyValueStackMapping = this.energyValueStackMapping.toJson(); - if (jsonEnergyValueStackMapping != null) { - compressedBytes = CompressionHelper.compressStringToByteArray(jsonEnergyValueStackMapping); - } + if (energyValueMap != null) { + + byte[] compressedValueMap = CompressionHelper.compress( + SerializationHelper.GSON.toJson(energyValueMap, SerializationHelper.ENERGY_VALUE_MAP_TYPE)); - if (compressedBytes != null) { - buf.writeInt(compressedBytes.length); - buf.writeBytes(compressedBytes); + if (compressedValueMap != null) { + buf.writeInt(compressedValueMap.length); + buf.writeBytes(compressedValueMap); + } else { + buf.writeInt(0); + } } else { buf.writeInt(0); } @@ -57,20 +83,19 @@ public void toBytes(ByteBuf buf) { @Override public IMessage onMessage(MessageSetEnergyValue message, MessageContext ctx) { - if (message.energyValueStackMapping != null && message.energyValueStackMapping.wrappedStack != null - && message.energyValueStackMapping.energyValue != null) { - EnergyValueRegistry.getInstance().setEnergyValue( - message.energyValueStackMapping.wrappedStack, - message.energyValueStackMapping.energyValue); - LogHelper.info( - EnergyValueRegistry.ENERGY_VALUE_MARKER, - "Client successfully received new EnergyValue '{}' for object '{}'", - message.energyValueStackMapping.wrappedStack, - message.energyValueStackMapping.energyValue); - } else { - LogHelper.info( - EnergyValueRegistry.ENERGY_VALUE_MARKER, - "Client failed to receive new EnergyValue from server"); + + if (message.energyValueMap != null) { + for (WrappedStack wrappedStack : message.energyValueMap.keySet()) { + + EnergyValue energyValue = message.energyValueMap.get(wrappedStack); + EnergyValueRegistryProxy.setEnergyValue(wrappedStack, energyValue); + EnergyValueRegistry.INSTANCE.setShouldSave(false); + LogHelper.info( + EnergyValueRegistry.ENERGY_VALUE_MARKER, + "Client successfully received new energy value '{}' for object '{}'", + energyValue, + wrappedStack); + } } return null; diff --git a/src/main/java/com/pahimar/ee3/network/message/MessageSoundEvent.java b/src/main/java/com/pahimar/ee3/network/message/MessageSoundEvent.java index d044ff14..2ea094f8 100644 --- a/src/main/java/com/pahimar/ee3/network/message/MessageSoundEvent.java +++ b/src/main/java/com/pahimar/ee3/network/message/MessageSoundEvent.java @@ -5,7 +5,7 @@ import net.minecraft.entity.player.EntityPlayer; import com.pahimar.ee3.EquivalentExchange3; -import com.pahimar.ee3.reference.Settings; +import com.pahimar.ee3.handler.ConfigurationHandler; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.common.network.simpleimpl.IMessage; @@ -76,10 +76,10 @@ public void toBytes(ByteBuf byteBuf) { public IMessage onMessage(MessageSoundEvent event, MessageContext context) { UUID originUUID = new UUID(event.mostSigUUID, event.leastSigUUID); - if (Settings.Sounds.soundMode.equalsIgnoreCase("All")) { + if (ConfigurationHandler.Settings.soundMode.equalsIgnoreCase("All")) { EquivalentExchange3.proxy .playSound(event.soundName, event.xCoord, event.yCoord, event.zCoord, event.volume, event.pitch); - } else if (Settings.Sounds.soundMode.equalsIgnoreCase("Self")) { + } else if (ConfigurationHandler.Settings.soundMode.equalsIgnoreCase("Self")) { if (FMLClientHandler.instance().getClient().thePlayer.getUniqueID().equals(originUUID)) { EquivalentExchange3.proxy.playSound( event.soundName, diff --git a/src/main/java/com/pahimar/ee3/network/message/MessageSyncEnergyValues.java b/src/main/java/com/pahimar/ee3/network/message/MessageSyncEnergyValues.java index e1eacd66..e578ed61 100644 --- a/src/main/java/com/pahimar/ee3/network/message/MessageSyncEnergyValues.java +++ b/src/main/java/com/pahimar/ee3/network/message/MessageSyncEnergyValues.java @@ -1,17 +1,14 @@ package com.pahimar.ee3.network.message; -import java.io.IOException; -import java.io.StringReader; import java.util.Map; -import java.util.TreeMap; -import com.google.gson.stream.JsonReader; +import com.google.gson.JsonParseException; import com.pahimar.ee3.api.exchange.EnergyValue; import com.pahimar.ee3.exchange.EnergyValueRegistry; -import com.pahimar.ee3.exchange.EnergyValueStackMapping; import com.pahimar.ee3.exchange.WrappedStack; import com.pahimar.ee3.util.CompressionHelper; import com.pahimar.ee3.util.LogHelper; +import com.pahimar.ee3.util.SerializationHelper; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; @@ -20,12 +17,10 @@ public class MessageSyncEnergyValues implements IMessage, IMessageHandler { - public String jsonEnergyValueRegistry; + public Map valueMap; - public MessageSyncEnergyValues() {} - - public MessageSyncEnergyValues(EnergyValueRegistry energyValueRegistry) { - this.jsonEnergyValueRegistry = energyValueRegistry.toJson(); + public MessageSyncEnergyValues() { + this.valueMap = EnergyValueRegistry.INSTANCE.getEnergyValues(); } /** @@ -35,15 +30,27 @@ public MessageSyncEnergyValues(EnergyValueRegistry energyValueRegistry) { */ @Override public void fromBytes(ByteBuf buf) { - byte[] compressedBytes = null; - int readableBytes = buf.readInt(); - if (readableBytes > 0) { - compressedBytes = buf.readBytes(readableBytes).array(); - } + int compressedJsonLength = buf.readInt(); + + if (compressedJsonLength != 0) { + byte[] compressedValueMap = buf.readBytes(compressedJsonLength).array(); + + if (compressedValueMap != null) { - if (compressedBytes != null) { - this.jsonEnergyValueRegistry = CompressionHelper.decompressStringFromByteArray(compressedBytes); + String jsonString = CompressionHelper.decompress(compressedValueMap); + + try { + valueMap = SerializationHelper.GSON.fromJson(jsonString, SerializationHelper.ENERGY_VALUE_MAP_TYPE); + } catch (JsonParseException e) { + LogHelper.warn("Failed to read energy value map from server"); + valueMap = null; + } + } else { + valueMap = null; + } + } else { + valueMap = null; } } @@ -54,15 +61,18 @@ public void fromBytes(ByteBuf buf) { */ @Override public void toBytes(ByteBuf buf) { - byte[] compressedBytes = null; - if (jsonEnergyValueRegistry != null) { - compressedBytes = CompressionHelper.compressStringToByteArray(jsonEnergyValueRegistry); - } + if (valueMap != null) { + + byte[] compressedValueMap = CompressionHelper + .compress(SerializationHelper.GSON.toJson(valueMap, SerializationHelper.ENERGY_VALUE_MAP_TYPE)); - if (compressedBytes != null) { - buf.writeInt(compressedBytes.length); - buf.writeBytes(compressedBytes); + if (compressedValueMap != null) { + buf.writeInt(compressedValueMap.length); + buf.writeBytes(compressedValueMap); + } else { + buf.writeInt(0); + } } else { buf.writeInt(0); } @@ -78,34 +88,17 @@ public void toBytes(ByteBuf buf) { */ @Override public IMessage onMessage(MessageSyncEnergyValues message, MessageContext ctx) { - if (message.jsonEnergyValueRegistry != null) { - Map energyValueStackMap = new TreeMap(); - - try { - JsonReader jsonReader = new JsonReader(new StringReader(message.jsonEnergyValueRegistry)); - jsonReader.beginArray(); - while (jsonReader.hasNext()) { - EnergyValueStackMapping energyValueStackMapping = EnergyValueStackMapping.jsonSerializer - .fromJson(jsonReader, EnergyValueStackMapping.class); - if (energyValueStackMapping != null) { - energyValueStackMap - .put(energyValueStackMapping.wrappedStack, energyValueStackMapping.energyValue); - } - } - jsonReader.endArray(); - jsonReader.close(); - } catch (IOException e) { - e.printStackTrace(); - } - EnergyValueRegistry.getInstance().loadFromMap(energyValueStackMap); + if (message.valueMap != null) { + EnergyValueRegistry.INSTANCE.load(message.valueMap); LogHelper.info( EnergyValueRegistry.ENERGY_VALUE_MARKER, - "Client successfully received EnergyValues from server"); + "Client successfully received {} energy values from server", + message.valueMap.size()); } else { LogHelper.info( EnergyValueRegistry.ENERGY_VALUE_MARKER, - "Client failed to receive EnergyValues from server - falling back to local EnergyValues"); + "Client failed to receive energy values from server - falling back to local values"); } return null; diff --git a/src/main/java/com/pahimar/ee3/network/message/MessageTileEntityTransmutationTablet.java b/src/main/java/com/pahimar/ee3/network/message/MessageTileEntityTransmutationTablet.java index a20ae79a..4d45a5c6 100644 --- a/src/main/java/com/pahimar/ee3/network/message/MessageTileEntityTransmutationTablet.java +++ b/src/main/java/com/pahimar/ee3/network/message/MessageTileEntityTransmutationTablet.java @@ -7,7 +7,6 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import com.pahimar.ee3.tileentity.TileEntityAlchemyArray; import com.pahimar.ee3.tileentity.TileEntityTransmutationTablet; import cpw.mods.fml.client.FMLClientHandler; @@ -21,17 +20,17 @@ public class MessageTileEntityTransmutationTablet public NBTTagCompound tileEntityTransmutationTabletNBT; - public MessageTileEntityTransmutationTablet() { - - } + public MessageTileEntityTransmutationTablet() {} public MessageTileEntityTransmutationTablet(TileEntityTransmutationTablet tileEntityTransmutationTablet) { + tileEntityTransmutationTabletNBT = new NBTTagCompound(); tileEntityTransmutationTablet.writeToNBT(tileEntityTransmutationTabletNBT); } @Override public void fromBytes(ByteBuf buf) { + byte[] compressedNBT = null; int readableBytes = buf.readInt(); @@ -40,6 +39,7 @@ public void fromBytes(ByteBuf buf) { } if (compressedNBT != null) { + try { this.tileEntityTransmutationTabletNBT = CompressedStreamTools .readCompressed(new ByteArrayInputStream(compressedNBT)); @@ -51,6 +51,7 @@ public void fromBytes(ByteBuf buf) { @Override public void toBytes(ByteBuf buf) { + byte[] compressedNBT = null; try { @@ -71,22 +72,24 @@ public void toBytes(ByteBuf buf) { @Override public IMessage onMessage(MessageTileEntityTransmutationTablet message, MessageContext ctx) { + if (message.tileEntityTransmutationTabletNBT != null) { - TileEntityAlchemyArray tileEntityAlchemyArray = new TileEntityAlchemyArray(); - tileEntityAlchemyArray.readFromNBT(message.tileEntityTransmutationTabletNBT); + + TileEntityTransmutationTablet tileEntityTransmutationTablet = new TileEntityTransmutationTablet(); + tileEntityTransmutationTablet.readFromNBT(message.tileEntityTransmutationTabletNBT); TileEntity tileEntity = FMLClientHandler.instance().getClient().theWorld.getTileEntity( - tileEntityAlchemyArray.xCoord, - tileEntityAlchemyArray.yCoord, - tileEntityAlchemyArray.zCoord); + tileEntityTransmutationTablet.xCoord, + tileEntityTransmutationTablet.yCoord, + tileEntityTransmutationTablet.zCoord); if (tileEntity instanceof TileEntityTransmutationTablet) { tileEntity.readFromNBT(message.tileEntityTransmutationTabletNBT); // NAME UPDATE FMLClientHandler.instance().getClient().theWorld.func_147451_t( - tileEntityAlchemyArray.xCoord, - tileEntityAlchemyArray.yCoord, - tileEntityAlchemyArray.zCoord); + tileEntityTransmutationTablet.xCoord, + tileEntityTransmutationTablet.yCoord, + tileEntityTransmutationTablet.zCoord); } } diff --git a/src/main/java/com/pahimar/ee3/network/message/MessageTransmutationKnowledgeUpdate.java b/src/main/java/com/pahimar/ee3/network/message/MessageTransmutationKnowledgeUpdate.java deleted file mode 100644 index 7bb7bfd7..00000000 --- a/src/main/java/com/pahimar/ee3/network/message/MessageTransmutationKnowledgeUpdate.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.pahimar.ee3.network.message; - -import java.util.Collection; - -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.item.ItemStack; - -import com.pahimar.ee3.inventory.ContainerTransmutationTablet; -import com.pahimar.ee3.knowledge.TransmutationKnowledge; -import com.pahimar.ee3.tileentity.TileEntityTransmutationTablet; -import com.pahimar.ee3.util.CompressionHelper; - -import cpw.mods.fml.client.FMLClientHandler; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -import io.netty.buffer.ByteBuf; - -public class MessageTransmutationKnowledgeUpdate - implements IMessage, IMessageHandler { - - public int xCoord, yCoord, zCoord; - public TransmutationKnowledge transmutationKnowledge; - - public MessageTransmutationKnowledgeUpdate() { - - } - - public MessageTransmutationKnowledgeUpdate(TileEntityTransmutationTablet tileEntityTransmutationTablet, - Collection knownTransmutationsCollection) { - if (tileEntityTransmutationTablet != null) { - this.xCoord = tileEntityTransmutationTablet.xCoord; - this.yCoord = tileEntityTransmutationTablet.yCoord; - this.zCoord = tileEntityTransmutationTablet.zCoord; - } else { - this.xCoord = 0; - this.yCoord = Integer.MIN_VALUE; - this.zCoord = 0; - } - - if (knownTransmutationsCollection != null) { - this.transmutationKnowledge = new TransmutationKnowledge(knownTransmutationsCollection); - } else { - this.transmutationKnowledge = new TransmutationKnowledge(); - } - } - - public MessageTransmutationKnowledgeUpdate(int xCoord, int yCoord, int zCoord, - Collection knownTransmutationsCollection) { - this.xCoord = xCoord; - this.yCoord = yCoord; - this.zCoord = zCoord; - - if (knownTransmutationsCollection != null) { - this.transmutationKnowledge = new TransmutationKnowledge(knownTransmutationsCollection); - } else { - this.transmutationKnowledge = new TransmutationKnowledge(); - } - } - - @Override - public void fromBytes(ByteBuf buf) { - this.xCoord = buf.readInt(); - this.yCoord = buf.readInt(); - this.zCoord = buf.readInt(); - - byte[] compressedString = null; - int readableBytes = buf.readInt(); - - if (readableBytes > 0) { - compressedString = buf.readBytes(readableBytes).array(); - } - - if (compressedString != null) { - String uncompressedString = CompressionHelper.decompressStringFromByteArray(compressedString); - this.transmutationKnowledge = TransmutationKnowledge.createFromJson(uncompressedString); - } - } - - @Override - public void toBytes(ByteBuf buf) { - buf.writeInt(xCoord); - buf.writeInt(yCoord); - buf.writeInt(zCoord); - - byte[] compressedString = null; - - if (transmutationKnowledge != null) { - compressedString = CompressionHelper.compressStringToByteArray(transmutationKnowledge.toJson()); - } - - if (compressedString != null) { - buf.writeInt(compressedString.length); - buf.writeBytes(compressedString); - } else { - buf.writeInt(0); - } - } - - @Override - public IMessage onMessage(MessageTransmutationKnowledgeUpdate message, MessageContext ctx) { - if (message.yCoord != Integer.MIN_VALUE) { - if (FMLClientHandler.instance().getClient().currentScreen instanceof GuiContainer) { - GuiContainer guiContainer = (GuiContainer) FMLClientHandler.instance().getClient().currentScreen; - - if (guiContainer.inventorySlots instanceof ContainerTransmutationTablet) { - if (FMLClientHandler.instance().getWorldClient().getTileEntity( - message.xCoord, - message.yCoord, - message.zCoord) instanceof TileEntityTransmutationTablet) { - ((ContainerTransmutationTablet) guiContainer.inventorySlots) - .handleTransmutationKnowledgeUpdate(message.transmutationKnowledge); - } - } - } - } - - return null; - } -} diff --git a/src/main/java/com/pahimar/ee3/proxy/CommonProxy.java b/src/main/java/com/pahimar/ee3/proxy/CommonProxy.java index 8741afa9..8b55a400 100644 --- a/src/main/java/com/pahimar/ee3/proxy/CommonProxy.java +++ b/src/main/java/com/pahimar/ee3/proxy/CommonProxy.java @@ -13,7 +13,6 @@ public void registerEventHandlers() { PlayerEventHandler playerEventHandler = new PlayerEventHandler(); FMLCommonHandler.instance().bus().register(new ConfigurationHandler()); - FMLCommonHandler.instance().bus().register(new AbilityRegistrySerializationHandler()); FMLCommonHandler.instance().bus().register(itemEventHandler); MinecraftForge.EVENT_BUS.register(itemEventHandler); MinecraftForge.EVENT_BUS.register(new WorldEventHandler()); diff --git a/src/main/java/com/pahimar/ee3/recipe/AludelRecipeManager.java b/src/main/java/com/pahimar/ee3/recipe/AludelRecipeManager.java index 50084adf..d73d1a77 100644 --- a/src/main/java/com/pahimar/ee3/recipe/AludelRecipeManager.java +++ b/src/main/java/com/pahimar/ee3/recipe/AludelRecipeManager.java @@ -6,7 +6,7 @@ import net.minecraft.item.ItemStack; import com.google.common.collect.ImmutableList; -import com.pahimar.ee3.api.exchange.RecipeRegistryProxy; +import com.pahimar.ee3.api.recipe.RecipeRegistryProxy; import com.pahimar.ee3.item.crafting.RecipeAludel; import com.pahimar.ee3.util.LoaderHelper; import com.pahimar.ee3.util.LogHelper; @@ -45,7 +45,7 @@ public void addRecipe(RecipeAludel recipeAludel) { if (!aludelRecipes.contains(recipeAludel)) { LogHelper.trace( RecipeRegistry.RECIPE_MARKER, - "[{}] Mod with ID '%s' added Aludel recipe '%s'", + "[{}] Mod with ID '{}' added Aludel recipe '{}'", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), recipeAludel); diff --git a/src/main/java/com/pahimar/ee3/recipe/RecipeRegistry.java b/src/main/java/com/pahimar/ee3/recipe/RecipeRegistry.java index a68e8a2c..ab435c6d 100644 --- a/src/main/java/com/pahimar/ee3/recipe/RecipeRegistry.java +++ b/src/main/java/com/pahimar/ee3/recipe/RecipeRegistry.java @@ -1,15 +1,17 @@ package com.pahimar.ee3.recipe; -import java.util.ArrayList; -import java.util.List; +import java.util.Collection; +import java.util.Set; +import java.util.TreeSet; import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.MarkerManager; -import com.google.common.collect.HashMultimap; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.Multimap; +import com.google.common.collect.TreeMultimap; import com.pahimar.ee3.exchange.WrappedStack; +import com.pahimar.ee3.reference.Comparators; import com.pahimar.ee3.util.LoaderHelper; import com.pahimar.ee3.util.LogHelper; import cpw.mods.fml.common.Loader; @@ -17,25 +19,16 @@ public class RecipeRegistry { public static final Marker RECIPE_MARKER = MarkerManager.getMarker("EE3_RECIPE", LogHelper.MOD_MARKER); - private static RecipeRegistry recipeRegistry = null; + public static final RecipeRegistry INSTANCE = new RecipeRegistry(); - private Multimap> recipeMap; - private ImmutableMultimap> immutableRecipeMap; + private Multimap> recipeMap; + private ImmutableMultimap> immutableRecipeMap; private RecipeRegistry() { - recipeMap = HashMultimap.create(); // TODO Switch this to a TreeMultimap + recipeMap = TreeMultimap.create(WrappedStack.COMPARATOR, Comparators.WRAPPED_STACK_SET_COMPARATOR); } - public static RecipeRegistry getInstance() { - - if (recipeRegistry == null) { - recipeRegistry = new RecipeRegistry(); - } - - return recipeRegistry; - } - - public void addRecipe(Object recipeOutput, List recipeInputList) { + public void addRecipe(Object recipeOutput, Collection recipeInputList) { // Wrap the recipe output WrappedStack wrappedRecipeOutput = WrappedStack.wrap(recipeOutput); @@ -43,10 +36,13 @@ public void addRecipe(Object recipeOutput, List recipeInputList) { return; } - List wrappedRecipeInputList = new ArrayList(); + Set wrappedRecipeInputList = new TreeSet<>(); StringBuilder stringBuilder = new StringBuilder(); + for (Object recipeInputObject : recipeInputList) { + WrappedStack wrappedInputObject = WrappedStack.wrap(recipeInputObject); + if (wrappedInputObject != null) { wrappedRecipeInputList.add(wrappedInputObject); stringBuilder.append(wrappedInputObject); @@ -56,8 +52,16 @@ public void addRecipe(Object recipeOutput, List recipeInputList) { } } + // Check to see if we already have this recipe in the map + boolean existsAlready = false; + for (Set recipeInputs : recipeMap.get(wrappedRecipeOutput)) { + if (recipeInputs.containsAll(wrappedRecipeInputList) && wrappedRecipeInputList.containsAll(recipeInputs)) { + existsAlready = true; + } + } + // Add the recipe mapping only if we don't already have it - if (!recipeMap.get(wrappedRecipeOutput).contains(wrappedRecipeInputList)) { + if (!existsAlready) { LogHelper.trace( RECIPE_MARKER, "[{}] Mod with ID '{}' added recipe (Output: {}, Inputs: {})", @@ -70,15 +74,16 @@ public void addRecipe(Object recipeOutput, List recipeInputList) { } public void registerVanillaRecipes() { - RecipesVanilla.registerRecipes(); - RecipesFluidContainers.registerRecipes(); - RecipesPotions.registerRecipes(); + + new RecipesVanilla().registerRecipes(); + new RecipesFluidContainers().registerRecipes(); + new RecipesPotions().registerRecipes(); } - public Multimap> getRecipeMappings() { + public Multimap> getRecipeMappings() { if (immutableRecipeMap == null) { - immutableRecipeMap = ImmutableMultimap.copyOf(recipeRegistry.recipeMap); + immutableRecipeMap = ImmutableMultimap.copyOf(INSTANCE.recipeMap); } return immutableRecipeMap; @@ -89,7 +94,7 @@ public void dumpRecipeRegistryToLog() { for (WrappedStack wrappedStack : getRecipeMappings().keySet()) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(String.format("Output: %s, Inputs: ", wrappedStack.toString())); - for (List listStacks : getRecipeMappings().get(wrappedStack)) { + for (Set listStacks : getRecipeMappings().get(wrappedStack)) { for (WrappedStack listStack : listStacks) { stringBuilder.append(listStack.toString() + " "); } diff --git a/src/main/java/com/pahimar/ee3/recipe/RecipesFluidContainers.java b/src/main/java/com/pahimar/ee3/recipe/RecipesFluidContainers.java index 1b4dffba..2cc55314 100644 --- a/src/main/java/com/pahimar/ee3/recipe/RecipesFluidContainers.java +++ b/src/main/java/com/pahimar/ee3/recipe/RecipesFluidContainers.java @@ -1,22 +1,21 @@ package com.pahimar.ee3.recipe; -import java.util.Arrays; - import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; -import com.pahimar.ee3.api.exchange.RecipeRegistryProxy; +import com.pahimar.ee3.api.recipe.RecipeRegistryProxy; public class RecipesFluidContainers { - public static void registerRecipes() { + public void registerRecipes() { + for (FluidContainerData fluidContainerData : FluidContainerRegistry.getRegisteredFluidContainerData()) { - if (fluidContainerData.fluid != null) { - if (fluidContainerData.filledContainer != null && fluidContainerData.emptyContainer != null) { - RecipeRegistryProxy.addRecipe( - fluidContainerData.filledContainer.copy(), - Arrays.asList(fluidContainerData.fluid.copy(), fluidContainerData.emptyContainer.copy())); - } + if (fluidContainerData.fluid != null && fluidContainerData.filledContainer != null + && fluidContainerData.emptyContainer != null) { + RecipeRegistryProxy.addRecipe( + fluidContainerData.filledContainer.copy(), + fluidContainerData.fluid.copy(), + fluidContainerData.emptyContainer.copy()); } } } diff --git a/src/main/java/com/pahimar/ee3/recipe/RecipesPotions.java b/src/main/java/com/pahimar/ee3/recipe/RecipesPotions.java index a6003628..1aafb2dd 100644 --- a/src/main/java/com/pahimar/ee3/recipe/RecipesPotions.java +++ b/src/main/java/com/pahimar/ee3/recipe/RecipesPotions.java @@ -1,12 +1,10 @@ package com.pahimar.ee3.recipe; -import java.util.Arrays; - import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; -import com.pahimar.ee3.api.exchange.RecipeRegistryProxy; +import com.pahimar.ee3.api.recipe.RecipeRegistryProxy; import com.pahimar.ee3.exchange.WrappedStack; public class RecipesPotions { @@ -217,339 +215,231 @@ public class RecipesPotions { private static WrappedStack potionInvisibilitySplashExtendedOutput = WrappedStack .wrap(new ItemStack(Items.potionitem, 3, 16462)); - public static void registerRecipes() { - RecipeRegistryProxy.addRecipe(bottleWater, Arrays.asList(bottleEmpty, reagentWater)); + public void registerRecipes() { - RecipeRegistryProxy.addRecipe(potionAwkwardOutput, Arrays.asList(bottleWater, reagentNetherWart)); + RecipeRegistryProxy.addRecipe(bottleWater, bottleEmpty, reagentWater); - RecipeRegistryProxy.addRecipe(potionNightVisionOutput, Arrays.asList(potionAwkward, reagentGoldenCarrot)); - RecipeRegistryProxy - .addRecipe(potionNightVisionOutput, Arrays.asList(potionNightVisionExtended, reagentGlowstoneDust)); - RecipeRegistryProxy.addRecipe( - potionNightVisionSplashOutput, - Arrays.asList(potionNightVisionSplashExtended, reagentGlowstoneDust)); - RecipeRegistryProxy - .addRecipe(potionNightVisionSplashOutput, Arrays.asList(potionNightVision, reagentGunpowder)); + RecipeRegistryProxy.addRecipe(potionAwkwardOutput, bottleWater, reagentNetherWart); + RecipeRegistryProxy.addRecipe(potionNightVisionOutput, potionAwkward, reagentGoldenCarrot); + RecipeRegistryProxy.addRecipe(potionNightVisionOutput, potionNightVisionExtended, reagentGlowstoneDust); RecipeRegistryProxy - .addRecipe(potionNightVisionExtendedOutput, Arrays.asList(potionNightVision, reagentRedstoneDust)); - RecipeRegistryProxy.addRecipe( - potionNightVisionSplashExtendedOutput, - Arrays.asList(potionNightVisionSplash, reagentRedstoneDust)); - RecipeRegistryProxy.addRecipe( - potionNightVisionSplashExtendedOutput, - Arrays.asList(potionNightVisionExtended, reagentGunpowder)); + .addRecipe(potionNightVisionSplashOutput, potionNightVisionSplashExtended, reagentGlowstoneDust); + RecipeRegistryProxy.addRecipe(potionNightVisionSplashOutput, potionNightVision, reagentGunpowder); + RecipeRegistryProxy.addRecipe(potionNightVisionExtendedOutput, potionNightVision, reagentRedstoneDust); RecipeRegistryProxy - .addRecipe(potionInvisibilityOutput, Arrays.asList(potionNightVision, reagentFermentedSpiderEye)); + .addRecipe(potionNightVisionSplashExtendedOutput, potionNightVisionSplash, reagentRedstoneDust); RecipeRegistryProxy - .addRecipe(potionInvisibilityOutput, Arrays.asList(potionInvisibilityExtended, reagentGlowstoneDust)); - RecipeRegistryProxy.addRecipe( - potionInvisibilitySplashOutput, - Arrays.asList(potionNightVisionSplash, reagentFermentedSpiderEye)); - RecipeRegistryProxy.addRecipe( - potionInvisibilitySplashOutput, - Arrays.asList(potionInvisibilitySplashExtended, reagentGlowstoneDust)); + .addRecipe(potionNightVisionSplashExtendedOutput, potionNightVisionExtended, reagentGunpowder); + + RecipeRegistryProxy.addRecipe(potionInvisibilityOutput, potionNightVision, reagentFermentedSpiderEye); + RecipeRegistryProxy.addRecipe(potionInvisibilityOutput, potionInvisibilityExtended, reagentGlowstoneDust); + RecipeRegistryProxy + .addRecipe(potionInvisibilitySplashOutput, potionNightVisionSplash, reagentFermentedSpiderEye); RecipeRegistryProxy - .addRecipe(potionInvisibilitySplashOutput, Arrays.asList(potionInvisibility, reagentGunpowder)); + .addRecipe(potionInvisibilitySplashOutput, potionInvisibilitySplashExtended, reagentGlowstoneDust); + RecipeRegistryProxy.addRecipe(potionInvisibilitySplashOutput, potionInvisibility, reagentGunpowder); + RecipeRegistryProxy.addRecipe(potionInvisibilityExtendedOutput, potionInvisibility, reagentRedstoneDust); RecipeRegistryProxy - .addRecipe(potionInvisibilityExtendedOutput, Arrays.asList(potionInvisibility, reagentRedstoneDust)); - RecipeRegistryProxy.addRecipe( - potionInvisibilityExtendedOutput, - Arrays.asList(potionNightVisionExtended, reagentFermentedSpiderEye)); - RecipeRegistryProxy.addRecipe( - potionInvisibilitySplashExtendedOutput, - Arrays.asList(potionInvisibilitySplash, reagentRedstoneDust)); - RecipeRegistryProxy.addRecipe( - potionInvisibilitySplashExtendedOutput, - Arrays.asList(potionNightVisionSplashExtended, reagentFermentedSpiderEye)); + .addRecipe(potionInvisibilityExtendedOutput, potionNightVisionExtended, reagentFermentedSpiderEye); + RecipeRegistryProxy + .addRecipe(potionInvisibilitySplashExtendedOutput, potionInvisibilitySplash, reagentRedstoneDust); RecipeRegistryProxy.addRecipe( potionInvisibilitySplashExtendedOutput, - Arrays.asList(potionInvisibilityExtended, reagentGunpowder)); - - RecipeRegistryProxy.addRecipe(potionFireResistOutput, Arrays.asList(potionAwkward, reagentMagmaCream)); + potionNightVisionSplashExtended, + reagentFermentedSpiderEye); RecipeRegistryProxy - .addRecipe(potionFireResistOutput, Arrays.asList(potionFireResistExtended, reagentGlowstoneDust)); - RecipeRegistryProxy.addRecipe( - potionFireResistSplashOutput, - Arrays.asList(potionFireResistSplashExtended, reagentGlowstoneDust)); - RecipeRegistryProxy.addRecipe(potionFireResistSplashOutput, Arrays.asList(potionFireResist, reagentGunpowder)); + .addRecipe(potionInvisibilitySplashExtendedOutput, potionInvisibilityExtended, reagentGunpowder); + RecipeRegistryProxy.addRecipe(potionFireResistOutput, potionAwkward, reagentMagmaCream); + RecipeRegistryProxy.addRecipe(potionFireResistOutput, potionFireResistExtended, reagentGlowstoneDust); RecipeRegistryProxy - .addRecipe(potionFireResistExtendedOutput, Arrays.asList(potionFireResist, reagentRedstoneDust)); - RecipeRegistryProxy.addRecipe( - potionFireResistSplashExtendedOutput, - Arrays.asList(potionFireResistSplash, reagentRedstoneDust)); - RecipeRegistryProxy.addRecipe( - potionFireResistSplashExtendedOutput, - Arrays.asList(potionFireResistExtended, reagentGunpowder)); + .addRecipe(potionFireResistSplashOutput, potionFireResistSplashExtended, reagentGlowstoneDust); + RecipeRegistryProxy.addRecipe(potionFireResistSplashOutput, potionFireResist, reagentGunpowder); - RecipeRegistryProxy.addRecipe(potionSlownessOutput, Arrays.asList(potionFireResist, reagentFermentedSpiderEye)); - RecipeRegistryProxy - .addRecipe(potionSlownessOutput, Arrays.asList(potionSlownessExtended, reagentGlowstoneDust)); - RecipeRegistryProxy.addRecipe(potionSlownessOutput, Arrays.asList(potionSwiftness, reagentFermentedSpiderEye)); + RecipeRegistryProxy.addRecipe(potionFireResistExtendedOutput, potionFireResist, reagentRedstoneDust); RecipeRegistryProxy - .addRecipe(potionSlownessOutput, Arrays.asList(potionSwiftnessExtended, reagentFermentedSpiderEye)); - RecipeRegistryProxy.addRecipe( - potionSlownessSplashOutput, - Arrays.asList(potionFireResistSplash, reagentFermentedSpiderEye)); - RecipeRegistryProxy.addRecipe( - potionSlownessSplashOutput, - Arrays.asList(potionSlownessSplashExtended, reagentGlowstoneDust)); + .addRecipe(potionFireResistSplashExtendedOutput, potionFireResistSplash, reagentRedstoneDust); + RecipeRegistryProxy.addRecipe(potionFireResistSplashExtendedOutput, potionFireResistExtended, reagentGunpowder); + + RecipeRegistryProxy.addRecipe(potionSlownessOutput, potionFireResist, reagentFermentedSpiderEye); + RecipeRegistryProxy.addRecipe(potionSlownessOutput, potionSlownessExtended, reagentGlowstoneDust); + RecipeRegistryProxy.addRecipe(potionSlownessOutput, potionSwiftness, reagentFermentedSpiderEye); + RecipeRegistryProxy.addRecipe(potionSlownessOutput, potionSwiftnessExtended, reagentFermentedSpiderEye); + RecipeRegistryProxy.addRecipe(potionSlownessSplashOutput, potionFireResistSplash, reagentFermentedSpiderEye); + RecipeRegistryProxy.addRecipe(potionSlownessSplashOutput, potionSlownessSplashExtended, reagentGlowstoneDust); + RecipeRegistryProxy.addRecipe(potionSlownessSplashOutput, potionSwiftnessSplash, reagentFermentedSpiderEye); RecipeRegistryProxy - .addRecipe(potionSlownessSplashOutput, Arrays.asList(potionSwiftnessSplash, reagentFermentedSpiderEye)); - RecipeRegistryProxy.addRecipe( - potionSlownessSplashOutput, - Arrays.asList(potionSwiftnessSplashExtended, reagentFermentedSpiderEye)); - RecipeRegistryProxy.addRecipe(potionSlownessSplashOutput, Arrays.asList(potionSlowness, reagentGunpowder)); + .addRecipe(potionSlownessSplashOutput, potionSwiftnessSplashExtended, reagentFermentedSpiderEye); + RecipeRegistryProxy.addRecipe(potionSlownessSplashOutput, potionSlowness, reagentGunpowder); - RecipeRegistryProxy.addRecipe( - potionSlownessExtendedOutput, - Arrays.asList(potionFireResistExtended, reagentFermentedSpiderEye)); - RecipeRegistryProxy.addRecipe( - potionSlownessExtendedOutput, - Arrays.asList(potionSwiftnessEnhanced, reagentFermentedSpiderEye)); + RecipeRegistryProxy + .addRecipe(potionSlownessExtendedOutput, potionFireResistExtended, reagentFermentedSpiderEye); + RecipeRegistryProxy.addRecipe(potionSlownessExtendedOutput, potionSwiftnessEnhanced, reagentFermentedSpiderEye); RecipeRegistryProxy.addRecipe( potionSlownessSplashExtendedOutput, - Arrays.asList(potionFireResistSplashExtended, reagentFermentedSpiderEye)); + potionFireResistSplashExtended, + reagentFermentedSpiderEye); RecipeRegistryProxy.addRecipe( potionSlownessSplashExtendedOutput, - Arrays.asList(potionSwiftnessSplashEnhanced, reagentFermentedSpiderEye)); - RecipeRegistryProxy - .addRecipe(potionSlownessSplashExtendedOutput, Arrays.asList(potionSlownessExtended, reagentGunpowder)); + potionSwiftnessSplashEnhanced, + reagentFermentedSpiderEye); + RecipeRegistryProxy.addRecipe(potionSlownessSplashExtendedOutput, potionSlownessExtended, reagentGunpowder); - RecipeRegistryProxy.addRecipe(potionSwiftnessOutput, Arrays.asList(potionAwkward, reagentSugar)); - RecipeRegistryProxy.addRecipe(potionSwiftnessSplashOutput, Arrays.asList(potionSwiftness, reagentGunpowder)); + RecipeRegistryProxy.addRecipe(potionSwiftnessOutput, potionAwkward, reagentSugar); + RecipeRegistryProxy.addRecipe(potionSwiftnessSplashOutput, potionSwiftness, reagentGunpowder); + RecipeRegistryProxy.addRecipe(potionSwiftnessExtendedOutput, potionSwiftness, reagentRedstoneDust); + RecipeRegistryProxy.addRecipe(potionSwiftnessExtendedOutput, potionSwiftnessEnhanced, reagentRedstoneDust); + RecipeRegistryProxy.addRecipe(potionSwiftnessSplashExtendedOutput, potionSwiftnessSplash, reagentRedstoneDust); RecipeRegistryProxy - .addRecipe(potionSwiftnessExtendedOutput, Arrays.asList(potionSwiftness, reagentRedstoneDust)); - RecipeRegistryProxy - .addRecipe(potionSwiftnessExtendedOutput, Arrays.asList(potionSwiftnessEnhanced, reagentRedstoneDust)); - RecipeRegistryProxy.addRecipe( - potionSwiftnessSplashExtendedOutput, - Arrays.asList(potionSwiftnessSplash, reagentRedstoneDust)); - RecipeRegistryProxy.addRecipe( - potionSwiftnessSplashExtendedOutput, - Arrays.asList(potionSwiftnessSplashEnhanced, reagentRedstoneDust)); - RecipeRegistryProxy.addRecipe( - potionSwiftnessSplashExtendedOutput, - Arrays.asList(potionSwiftnessExtended, reagentGunpowder)); + .addRecipe(potionSwiftnessSplashExtendedOutput, potionSwiftnessSplashEnhanced, reagentRedstoneDust); + RecipeRegistryProxy.addRecipe(potionSwiftnessSplashExtendedOutput, potionSwiftnessExtended, reagentGunpowder); + RecipeRegistryProxy.addRecipe(potionSwiftnessEnhancedOutput, potionSwiftness, reagentGlowstoneDust); + RecipeRegistryProxy.addRecipe(potionSwiftnessEnhancedOutput, potionSwiftnessExtended, reagentGlowstoneDust); + RecipeRegistryProxy.addRecipe(potionSwiftnessSplashEnhancedOutput, potionSwiftnessSplash, reagentGlowstoneDust); RecipeRegistryProxy - .addRecipe(potionSwiftnessEnhancedOutput, Arrays.asList(potionSwiftness, reagentGlowstoneDust)); - RecipeRegistryProxy - .addRecipe(potionSwiftnessEnhancedOutput, Arrays.asList(potionSwiftnessExtended, reagentGlowstoneDust)); - RecipeRegistryProxy.addRecipe( - potionSwiftnessSplashEnhancedOutput, - Arrays.asList(potionSwiftnessSplash, reagentGlowstoneDust)); - RecipeRegistryProxy.addRecipe( - potionSwiftnessSplashEnhancedOutput, - Arrays.asList(potionSwiftnessSplashExtended, reagentGlowstoneDust)); - RecipeRegistryProxy.addRecipe( - potionSwiftnessSplashEnhancedOutput, - Arrays.asList(potionSwiftnessEnhanced, reagentGunpowder)); + .addRecipe(potionSwiftnessSplashEnhancedOutput, potionSwiftnessSplashExtended, reagentGlowstoneDust); + RecipeRegistryProxy.addRecipe(potionSwiftnessSplashEnhancedOutput, potionSwiftnessEnhanced, reagentGunpowder); - RecipeRegistryProxy.addRecipe(potionHealingOutput, Arrays.asList(potionAwkward, reagentGlisteringMelon)); - RecipeRegistryProxy.addRecipe(potionHealingOutput, Arrays.asList(potionHealingEnhanced, reagentRedstoneDust)); - RecipeRegistryProxy - .addRecipe(potionHealingSplashOutput, Arrays.asList(potionHealingSplashEnhanced, reagentRedstoneDust)); - RecipeRegistryProxy.addRecipe(potionHealingSplashOutput, Arrays.asList(potionHealing, reagentGunpowder)); + RecipeRegistryProxy.addRecipe(potionHealingOutput, potionAwkward, reagentGlisteringMelon); + RecipeRegistryProxy.addRecipe(potionHealingOutput, potionHealingEnhanced, reagentRedstoneDust); + RecipeRegistryProxy.addRecipe(potionHealingSplashOutput, potionHealingSplashEnhanced, reagentRedstoneDust); + RecipeRegistryProxy.addRecipe(potionHealingSplashOutput, potionHealing, reagentGunpowder); - RecipeRegistryProxy.addRecipe(potionHealingEnhancedOutput, Arrays.asList(potionHealing, reagentGlowstoneDust)); - RecipeRegistryProxy - .addRecipe(potionHealingSplashEnhancedOutput, Arrays.asList(potionHealingSplash, reagentGlowstoneDust)); - RecipeRegistryProxy - .addRecipe(potionHealingSplashEnhancedOutput, Arrays.asList(potionHealingEnhanced, reagentGunpowder)); + RecipeRegistryProxy.addRecipe(potionHealingEnhancedOutput, potionHealing, reagentGlowstoneDust); + RecipeRegistryProxy.addRecipe(potionHealingSplashEnhancedOutput, potionHealingSplash, reagentGlowstoneDust); + RecipeRegistryProxy.addRecipe(potionHealingSplashEnhancedOutput, potionHealingEnhanced, reagentGunpowder); - RecipeRegistryProxy.addRecipe(potionHarmingOutput, Arrays.asList(potionHealing, reagentFermentedSpiderEye)); - RecipeRegistryProxy.addRecipe(potionHarmingOutput, Arrays.asList(potionPoison, reagentFermentedSpiderEye)); - RecipeRegistryProxy - .addRecipe(potionHarmingOutput, Arrays.asList(potionPoisonExtended, reagentFermentedSpiderEye)); - RecipeRegistryProxy.addRecipe(potionHarmingOutput, Arrays.asList(potionHarmingEnhanced, reagentRedstoneDust)); - RecipeRegistryProxy - .addRecipe(potionHarmingSplashOutput, Arrays.asList(potionHealingSplash, reagentFermentedSpiderEye)); - RecipeRegistryProxy - .addRecipe(potionHarmingSplashOutput, Arrays.asList(potionPoisonSplash, reagentFermentedSpiderEye)); - RecipeRegistryProxy.addRecipe( - potionHarmingSplashOutput, - Arrays.asList(potionPoisonSplashExtended, reagentFermentedSpiderEye)); - RecipeRegistryProxy - .addRecipe(potionHarmingSplashOutput, Arrays.asList(potionHarmingSplashEnhanced, reagentRedstoneDust)); - RecipeRegistryProxy.addRecipe(potionHarmingSplashOutput, Arrays.asList(potionHarming, reagentGunpowder)); + RecipeRegistryProxy.addRecipe(potionHarmingOutput, potionHealing, reagentFermentedSpiderEye); + RecipeRegistryProxy.addRecipe(potionHarmingOutput, potionPoison, reagentFermentedSpiderEye); + RecipeRegistryProxy.addRecipe(potionHarmingOutput, potionPoisonExtended, reagentFermentedSpiderEye); + RecipeRegistryProxy.addRecipe(potionHarmingOutput, potionHarmingEnhanced, reagentRedstoneDust); + RecipeRegistryProxy.addRecipe(potionHarmingSplashOutput, potionHealingSplash, reagentFermentedSpiderEye); + RecipeRegistryProxy.addRecipe(potionHarmingSplashOutput, potionPoisonSplash, reagentFermentedSpiderEye); + RecipeRegistryProxy.addRecipe(potionHarmingSplashOutput, potionPoisonSplashExtended, reagentFermentedSpiderEye); + RecipeRegistryProxy.addRecipe(potionHarmingSplashOutput, potionHarmingSplashEnhanced, reagentRedstoneDust); + RecipeRegistryProxy.addRecipe(potionHarmingSplashOutput, potionHarming, reagentGunpowder); - RecipeRegistryProxy.addRecipe( - potionHarmingEnhancedOutput, - Arrays.asList(potionHealingEnhanced, reagentFermentedSpiderEye)); - RecipeRegistryProxy.addRecipe(potionHarmingEnhancedOutput, Arrays.asList(potionHarming, reagentGlowstoneDust)); + RecipeRegistryProxy.addRecipe(potionHarmingEnhancedOutput, potionHealingEnhanced, reagentFermentedSpiderEye); + RecipeRegistryProxy.addRecipe(potionHarmingEnhancedOutput, potionHarming, reagentGlowstoneDust); + RecipeRegistryProxy.addRecipe(potionHarmingEnhancedOutput, potionPoisonEnhanced, reagentFermentedSpiderEye); RecipeRegistryProxy - .addRecipe(potionHarmingEnhancedOutput, Arrays.asList(potionPoisonEnhanced, reagentFermentedSpiderEye)); - RecipeRegistryProxy.addRecipe( - potionHarmingSplashEnhancedOutput, - Arrays.asList(potionHealingSplashEnhanced, reagentFermentedSpiderEye)); - RecipeRegistryProxy - .addRecipe(potionHarmingSplashEnhancedOutput, Arrays.asList(potionHarmingSplash, reagentGlowstoneDust)); - RecipeRegistryProxy.addRecipe( - potionHarmingSplashEnhancedOutput, - Arrays.asList(potionPoisonSplashEnhanced, reagentFermentedSpiderEye)); + .addRecipe(potionHarmingSplashEnhancedOutput, potionHealingSplashEnhanced, reagentFermentedSpiderEye); + RecipeRegistryProxy.addRecipe(potionHarmingSplashEnhancedOutput, potionHarmingSplash, reagentGlowstoneDust); RecipeRegistryProxy - .addRecipe(potionHarmingSplashEnhancedOutput, Arrays.asList(potionHarmingEnhanced, reagentGunpowder)); + .addRecipe(potionHarmingSplashEnhancedOutput, potionPoisonSplashEnhanced, reagentFermentedSpiderEye); + RecipeRegistryProxy.addRecipe(potionHarmingSplashEnhancedOutput, potionHarmingEnhanced, reagentGunpowder); - RecipeRegistryProxy.addRecipe(potionPoisonOutput, Arrays.asList(potionAwkward, reagentSpiderEye)); - RecipeRegistryProxy.addRecipe(potionPoisonSplashOutput, Arrays.asList(potionPoison, reagentGunpowder)); + RecipeRegistryProxy.addRecipe(potionPoisonOutput, potionAwkward, reagentSpiderEye); + RecipeRegistryProxy.addRecipe(potionPoisonSplashOutput, potionPoison, reagentGunpowder); + RecipeRegistryProxy.addRecipe(potionPoisonExtendedOutput, potionPoisonExtended, reagentRedstoneDust); + RecipeRegistryProxy.addRecipe(potionPoisonExtendedOutput, potionPoisonEnhanced, reagentRedstoneDust); RecipeRegistryProxy - .addRecipe(potionPoisonExtendedOutput, Arrays.asList(potionPoisonExtended, reagentRedstoneDust)); + .addRecipe(potionPoisonSplashExtendedOutput, potionPoisonSplashExtended, reagentRedstoneDust); RecipeRegistryProxy - .addRecipe(potionPoisonExtendedOutput, Arrays.asList(potionPoisonEnhanced, reagentRedstoneDust)); - RecipeRegistryProxy.addRecipe( - potionPoisonSplashExtendedOutput, - Arrays.asList(potionPoisonSplashExtended, reagentRedstoneDust)); - RecipeRegistryProxy.addRecipe( - potionPoisonSplashExtendedOutput, - Arrays.asList(potionPoisonSplashEnhanced, reagentRedstoneDust)); - RecipeRegistryProxy - .addRecipe(potionPoisonSplashExtendedOutput, Arrays.asList(potionPoisonExtended, reagentGunpowder)); + .addRecipe(potionPoisonSplashExtendedOutput, potionPoisonSplashEnhanced, reagentRedstoneDust); + RecipeRegistryProxy.addRecipe(potionPoisonSplashExtendedOutput, potionPoisonExtended, reagentGunpowder); - RecipeRegistryProxy.addRecipe(potionPoisonEnhancedOutput, Arrays.asList(potionPoison, reagentGlowstoneDust)); - RecipeRegistryProxy - .addRecipe(potionPoisonEnhancedOutput, Arrays.asList(potionPoisonExtended, reagentGlowstoneDust)); - RecipeRegistryProxy - .addRecipe(potionPoisonSplashEnhancedOutput, Arrays.asList(potionPoisonSplash, reagentGlowstoneDust)); - RecipeRegistryProxy.addRecipe( - potionPoisonSplashEnhancedOutput, - Arrays.asList(potionPoisonSplashExtended, reagentGlowstoneDust)); + RecipeRegistryProxy.addRecipe(potionPoisonEnhancedOutput, potionPoison, reagentGlowstoneDust); + RecipeRegistryProxy.addRecipe(potionPoisonEnhancedOutput, potionPoisonExtended, reagentGlowstoneDust); + RecipeRegistryProxy.addRecipe(potionPoisonSplashEnhancedOutput, potionPoisonSplash, reagentGlowstoneDust); RecipeRegistryProxy - .addRecipe(potionPoisonSplashEnhancedOutput, Arrays.asList(potionPoisonEnhanced, reagentGunpowder)); + .addRecipe(potionPoisonSplashEnhancedOutput, potionPoisonSplashExtended, reagentGlowstoneDust); + RecipeRegistryProxy.addRecipe(potionPoisonSplashEnhancedOutput, potionPoisonEnhanced, reagentGunpowder); - RecipeRegistryProxy.addRecipe(potionRegenerationOutput, Arrays.asList(potionAwkward, reagentGhastTear)); - RecipeRegistryProxy - .addRecipe(potionRegenerationSplashOutput, Arrays.asList(potionRegeneration, reagentGunpowder)); + RecipeRegistryProxy.addRecipe(potionRegenerationOutput, potionAwkward, reagentGhastTear); + RecipeRegistryProxy.addRecipe(potionRegenerationSplashOutput, potionRegeneration, reagentGunpowder); + RecipeRegistryProxy.addRecipe(potionRegenerationExtendedOutput, potionRegeneration, reagentRedstoneDust); RecipeRegistryProxy - .addRecipe(potionRegenerationExtendedOutput, Arrays.asList(potionRegeneration, reagentRedstoneDust)); - RecipeRegistryProxy.addRecipe( - potionRegenerationExtendedOutput, - Arrays.asList(potionRegenerationEnhanced, reagentRedstoneDust)); - RecipeRegistryProxy.addRecipe( - potionRegenerationSplashExtendedOutput, - Arrays.asList(potionRegenerationSplash, reagentRedstoneDust)); - RecipeRegistryProxy.addRecipe( - potionRegenerationSplashExtendedOutput, - Arrays.asList(potionRegenerationSplashEnhanced, reagentRedstoneDust)); + .addRecipe(potionRegenerationExtendedOutput, potionRegenerationEnhanced, reagentRedstoneDust); + RecipeRegistryProxy + .addRecipe(potionRegenerationSplashExtendedOutput, potionRegenerationSplash, reagentRedstoneDust); RecipeRegistryProxy.addRecipe( potionRegenerationSplashExtendedOutput, - Arrays.asList(potionRegenerationExtended, reagentGunpowder)); - + potionRegenerationSplashEnhanced, + reagentRedstoneDust); RecipeRegistryProxy - .addRecipe(potionRegenerationEnhancedOutput, Arrays.asList(potionRegeneration, reagentGlowstoneDust)); - RecipeRegistryProxy.addRecipe( - potionRegenerationEnhancedOutput, - Arrays.asList(potionRegenerationExtended, reagentGlowstoneDust)); - RecipeRegistryProxy.addRecipe( - potionRegenerationSplashEnhancedOutput, - Arrays.asList(potionRegenerationSplash, reagentGlowstoneDust)); - RecipeRegistryProxy.addRecipe( - potionRegenerationSplashEnhancedOutput, - Arrays.asList(potionRegenerationSplashExtended, reagentGlowstoneDust)); - RecipeRegistryProxy.addRecipe( - potionRegenerationSplashEnhancedOutput, - Arrays.asList(potionRegenerationEnhanced, reagentGunpowder)); + .addRecipe(potionRegenerationSplashExtendedOutput, potionRegenerationExtended, reagentGunpowder); - RecipeRegistryProxy.addRecipe(potionWeaknessOutput, Arrays.asList(potionAwkward, reagentFermentedSpiderEye)); + RecipeRegistryProxy.addRecipe(potionRegenerationEnhancedOutput, potionRegeneration, reagentGlowstoneDust); RecipeRegistryProxy - .addRecipe(potionWeaknessOutput, Arrays.asList(potionRegeneration, reagentFermentedSpiderEye)); + .addRecipe(potionRegenerationEnhancedOutput, potionRegenerationExtended, reagentGlowstoneDust); RecipeRegistryProxy - .addRecipe(potionWeaknessOutput, Arrays.asList(potionRegenerationEnhanced, reagentFermentedSpiderEye)); - RecipeRegistryProxy.addRecipe(potionWeaknessOutput, Arrays.asList(potionStrength, reagentFermentedSpiderEye)); - RecipeRegistryProxy - .addRecipe(potionWeaknessOutput, Arrays.asList(potionStrengthEnhanced, reagentFermentedSpiderEye)); - RecipeRegistryProxy.addRecipe(potionWeaknessOutput, Arrays.asList(potionMundane, reagentFermentedSpiderEye)); - RecipeRegistryProxy - .addRecipe(potionWeaknessOutput, Arrays.asList(potionWeaknessExtended, reagentGlowstoneDust)); - RecipeRegistryProxy.addRecipe( - potionWeaknessSplashOutput, - Arrays.asList(potionRegenerationSplash, reagentFermentedSpiderEye)); + .addRecipe(potionRegenerationSplashEnhancedOutput, potionRegenerationSplash, reagentGlowstoneDust); RecipeRegistryProxy.addRecipe( - potionWeaknessSplashOutput, - Arrays.asList(potionRegenerationSplashEnhanced, reagentFermentedSpiderEye)); + potionRegenerationSplashEnhancedOutput, + potionRegenerationSplashExtended, + reagentGlowstoneDust); RecipeRegistryProxy - .addRecipe(potionWeaknessSplashOutput, Arrays.asList(potionStrengthSplash, reagentFermentedSpiderEye)); - RecipeRegistryProxy.addRecipe( - potionWeaknessSplashOutput, - Arrays.asList(potionStrengthSplashEnhanced, reagentFermentedSpiderEye)); + .addRecipe(potionRegenerationSplashEnhancedOutput, potionRegenerationEnhanced, reagentGunpowder); + + RecipeRegistryProxy.addRecipe(potionWeaknessOutput, potionAwkward, reagentFermentedSpiderEye); + RecipeRegistryProxy.addRecipe(potionWeaknessOutput, potionRegeneration, reagentFermentedSpiderEye); + RecipeRegistryProxy.addRecipe(potionWeaknessOutput, potionRegenerationEnhanced, reagentFermentedSpiderEye); + RecipeRegistryProxy.addRecipe(potionWeaknessOutput, potionStrength, reagentFermentedSpiderEye); + RecipeRegistryProxy.addRecipe(potionWeaknessOutput, potionStrengthEnhanced, reagentFermentedSpiderEye); + RecipeRegistryProxy.addRecipe(potionWeaknessOutput, potionMundane, reagentFermentedSpiderEye); + RecipeRegistryProxy.addRecipe(potionWeaknessOutput, potionWeaknessExtended, reagentGlowstoneDust); + RecipeRegistryProxy.addRecipe(potionWeaknessSplashOutput, potionRegenerationSplash, reagentFermentedSpiderEye); RecipeRegistryProxy - .addRecipe(potionWeaknessSplashOutput, Arrays.asList(potionMundaneSplash, reagentFermentedSpiderEye)); - RecipeRegistryProxy.addRecipe( - potionWeaknessSplashOutput, - Arrays.asList(potionWeaknessSplashExtended, reagentGlowstoneDust)); - RecipeRegistryProxy.addRecipe(potionWeaknessSplashOutput, Arrays.asList(potionWeakness, reagentGunpowder)); + .addRecipe(potionWeaknessSplashOutput, potionRegenerationSplashEnhanced, reagentFermentedSpiderEye); + RecipeRegistryProxy.addRecipe(potionWeaknessSplashOutput, potionStrengthSplash, reagentFermentedSpiderEye); + RecipeRegistryProxy + .addRecipe(potionWeaknessSplashOutput, potionStrengthSplashEnhanced, reagentFermentedSpiderEye); + RecipeRegistryProxy.addRecipe(potionWeaknessSplashOutput, potionMundaneSplash, reagentFermentedSpiderEye); + RecipeRegistryProxy.addRecipe(potionWeaknessSplashOutput, potionWeaknessSplashExtended, reagentGlowstoneDust); + RecipeRegistryProxy.addRecipe(potionWeaknessSplashOutput, potionWeakness, reagentGunpowder); - RecipeRegistryProxy.addRecipe(potionWeaknessExtendedOutput, Arrays.asList(potionWeakness, reagentRedstoneDust)); - RecipeRegistryProxy.addRecipe( - potionWeaknessExtendedOutput, - Arrays.asList(potionRegenerationExtended, reagentFermentedSpiderEye)); - RecipeRegistryProxy.addRecipe( - potionWeaknessExtendedOutput, - Arrays.asList(potionStrengthExtended, reagentFermentedSpiderEye)); - RecipeRegistryProxy.addRecipe( - potionWeaknessExtendedOutput, - Arrays.asList(potionMundaneExtended, reagentFermentedSpiderEye)); - RecipeRegistryProxy.addRecipe( - potionWeaknessSplashExtendedOutput, - Arrays.asList(potionWeaknessSplash, reagentRedstoneDust)); - RecipeRegistryProxy.addRecipe( - potionWeaknessSplashExtendedOutput, - Arrays.asList(potionRegenerationSplashExtended, reagentFermentedSpiderEye)); - RecipeRegistryProxy.addRecipe( - potionWeaknessSplashExtendedOutput, - Arrays.asList(potionStrengthSplashExtended, reagentFermentedSpiderEye)); + RecipeRegistryProxy.addRecipe(potionWeaknessExtendedOutput, potionWeakness, reagentRedstoneDust); + RecipeRegistryProxy + .addRecipe(potionWeaknessExtendedOutput, potionRegenerationExtended, reagentFermentedSpiderEye); + RecipeRegistryProxy.addRecipe(potionWeaknessExtendedOutput, potionStrengthExtended, reagentFermentedSpiderEye); + RecipeRegistryProxy.addRecipe(potionWeaknessExtendedOutput, potionMundaneExtended, reagentFermentedSpiderEye); + RecipeRegistryProxy.addRecipe(potionWeaknessSplashExtendedOutput, potionWeaknessSplash, reagentRedstoneDust); RecipeRegistryProxy.addRecipe( potionWeaknessSplashExtendedOutput, - Arrays.asList(potionMundaneSplashExtended, reagentFermentedSpiderEye)); + potionRegenerationSplashExtended, + reagentFermentedSpiderEye); RecipeRegistryProxy - .addRecipe(potionWeaknessSplashExtendedOutput, Arrays.asList(potionWeaknessExtended, reagentGunpowder)); + .addRecipe(potionWeaknessSplashExtendedOutput, potionStrengthSplashExtended, reagentFermentedSpiderEye); + RecipeRegistryProxy + .addRecipe(potionWeaknessSplashExtendedOutput, potionMundaneSplashExtended, reagentFermentedSpiderEye); + RecipeRegistryProxy.addRecipe(potionWeaknessSplashExtendedOutput, potionWeaknessExtended, reagentGunpowder); - RecipeRegistryProxy.addRecipe(potionStrengthOutput, Arrays.asList(potionAwkward, reagentBlazePowder)); - RecipeRegistryProxy.addRecipe(potionStrengthSplashOutput, Arrays.asList(potionStrength, reagentGunpowder)); + RecipeRegistryProxy.addRecipe(potionStrengthOutput, potionAwkward, reagentBlazePowder); + RecipeRegistryProxy.addRecipe(potionStrengthSplashOutput, potionStrength, reagentGunpowder); + RecipeRegistryProxy.addRecipe(potionStrengthEnhancedOutput, potionStrength, reagentGlowstoneDust); + RecipeRegistryProxy.addRecipe(potionStrengthEnhancedOutput, potionStrengthExtended, reagentGlowstoneDust); + RecipeRegistryProxy.addRecipe(potionStrengthSplashEnhancedOutput, potionStrengthSplash, reagentGlowstoneDust); RecipeRegistryProxy - .addRecipe(potionStrengthEnhancedOutput, Arrays.asList(potionStrength, reagentGlowstoneDust)); - RecipeRegistryProxy - .addRecipe(potionStrengthEnhancedOutput, Arrays.asList(potionStrengthExtended, reagentGlowstoneDust)); - RecipeRegistryProxy.addRecipe( - potionStrengthSplashEnhancedOutput, - Arrays.asList(potionStrengthSplash, reagentGlowstoneDust)); - RecipeRegistryProxy.addRecipe( - potionStrengthSplashEnhancedOutput, - Arrays.asList(potionStrengthSplashExtended, reagentGlowstoneDust)); - RecipeRegistryProxy - .addRecipe(potionStrengthSplashEnhancedOutput, Arrays.asList(potionStrengthEnhanced, reagentGunpowder)); + .addRecipe(potionStrengthSplashEnhancedOutput, potionStrengthSplashExtended, reagentGlowstoneDust); + RecipeRegistryProxy.addRecipe(potionStrengthSplashEnhancedOutput, potionStrengthEnhanced, reagentGunpowder); - RecipeRegistryProxy.addRecipe(potionStrengthExtendedOutput, Arrays.asList(potionStrength, reagentRedstoneDust)); - RecipeRegistryProxy - .addRecipe(potionStrengthExtendedOutput, Arrays.asList(potionStrengthEnhanced, reagentRedstoneDust)); - RecipeRegistryProxy.addRecipe( - potionStrengthSplashExtendedOutput, - Arrays.asList(potionStrengthSplash, reagentRedstoneDust)); - RecipeRegistryProxy.addRecipe( - potionStrengthSplashExtendedOutput, - Arrays.asList(potionStrengthSplashEnhanced, reagentRedstoneDust)); + RecipeRegistryProxy.addRecipe(potionStrengthExtendedOutput, potionStrength, reagentRedstoneDust); + RecipeRegistryProxy.addRecipe(potionStrengthExtendedOutput, potionStrengthEnhanced, reagentRedstoneDust); + RecipeRegistryProxy.addRecipe(potionStrengthSplashExtendedOutput, potionStrengthSplash, reagentRedstoneDust); RecipeRegistryProxy - .addRecipe(potionStrengthSplashExtendedOutput, Arrays.asList(potionStrengthExtended, reagentGunpowder)); + .addRecipe(potionStrengthSplashExtendedOutput, potionStrengthSplashEnhanced, reagentRedstoneDust); + RecipeRegistryProxy.addRecipe(potionStrengthSplashExtendedOutput, potionStrengthExtended, reagentGunpowder); - RecipeRegistryProxy.addRecipe(potionThickOutput, Arrays.asList(bottleWater, reagentGlowstoneDust)); + RecipeRegistryProxy.addRecipe(potionThickOutput, bottleWater, reagentGlowstoneDust); - RecipeRegistryProxy.addRecipe(potionMundaneOutput, Arrays.asList(bottleWater, reagentSugar)); - RecipeRegistryProxy.addRecipe(potionMundaneOutput, Arrays.asList(bottleWater, reagentGlisteringMelon)); - RecipeRegistryProxy.addRecipe(potionMundaneOutput, Arrays.asList(bottleWater, reagentSpiderEye)); - RecipeRegistryProxy.addRecipe(potionMundaneOutput, Arrays.asList(bottleWater, reagentBlazePowder)); - RecipeRegistryProxy.addRecipe(potionMundaneOutput, Arrays.asList(bottleWater, reagentMagmaCream)); - RecipeRegistryProxy.addRecipe(potionMundaneOutput, Arrays.asList(bottleWater, reagentGhastTear)); - RecipeRegistryProxy.addRecipe(potionMundaneSplashOutput, Arrays.asList(potionMundane, reagentGunpowder)); + RecipeRegistryProxy.addRecipe(potionMundaneOutput, bottleWater, reagentSugar); + RecipeRegistryProxy.addRecipe(potionMundaneOutput, bottleWater, reagentGlisteringMelon); + RecipeRegistryProxy.addRecipe(potionMundaneOutput, bottleWater, reagentSpiderEye); + RecipeRegistryProxy.addRecipe(potionMundaneOutput, bottleWater, reagentBlazePowder); + RecipeRegistryProxy.addRecipe(potionMundaneOutput, bottleWater, reagentMagmaCream); + RecipeRegistryProxy.addRecipe(potionMundaneOutput, bottleWater, reagentGhastTear); + RecipeRegistryProxy.addRecipe(potionMundaneSplashOutput, potionMundane, reagentGunpowder); - RecipeRegistryProxy.addRecipe(potionMundaneExtendedOutput, Arrays.asList(bottleWater, reagentRedstoneDust)); - RecipeRegistryProxy - .addRecipe(potionMundaneSplashExtendedOutput, Arrays.asList(potionMundaneExtended, reagentGunpowder)); + RecipeRegistryProxy.addRecipe(potionMundaneExtendedOutput, bottleWater, reagentRedstoneDust); + RecipeRegistryProxy.addRecipe(potionMundaneSplashExtendedOutput, potionMundaneExtended, reagentGunpowder); } } diff --git a/src/main/java/com/pahimar/ee3/recipe/RecipesVanilla.java b/src/main/java/com/pahimar/ee3/recipe/RecipesVanilla.java index c63dcd9b..8df03887 100644 --- a/src/main/java/com/pahimar/ee3/recipe/RecipesVanilla.java +++ b/src/main/java/com/pahimar/ee3/recipe/RecipesVanilla.java @@ -13,18 +13,18 @@ import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; -import com.pahimar.ee3.api.exchange.RecipeRegistryProxy; +import com.pahimar.ee3.api.recipe.RecipeRegistryProxy; import com.pahimar.ee3.exchange.OreStack; import com.pahimar.ee3.exchange.WrappedStack; import com.pahimar.ee3.util.RecipeHelper; public class RecipesVanilla { - public static void registerRecipes() { + public void registerRecipes() { + for (Object recipeObject : CraftingManager.getInstance().getRecipeList()) { - /** - * Vanilla - */ + + // Vanilla if (recipeObject instanceof ShapedRecipes || recipeObject instanceof ShapelessRecipes || recipeObject instanceof ShapedOreRecipe || recipeObject instanceof ShapelessOreRecipe) { @@ -32,6 +32,7 @@ public static void registerRecipes() { ItemStack recipeOutput = recipe.getRecipeOutput(); if (recipeOutput != null) { + List recipeInputs = RecipeHelper.getRecipeInputs(recipe); if (!recipeInputs.isEmpty()) { @@ -42,17 +43,6 @@ public static void registerRecipes() { } // Fixes for OreDictionary entries that may not exist (because the OreDictionary entry has nothing in it) - RecipeRegistryProxy - .addRecipe(new ItemStack(Blocks.wool, 1, 11), Arrays.asList(new OreStack("dyeBlue"), Blocks.wool)); - RecipeRegistryProxy.addRecipe( - new ItemStack(Blocks.stained_hardened_clay, 8, 11), - Arrays.asList(new OreStack("dyeBlue"), new ItemStack(Blocks.hardened_clay, 8))); - RecipeRegistryProxy.addRecipe( - new ItemStack(Blocks.stained_glass, 8, OreDictionary.WILDCARD_VALUE), - Arrays.asList(new OreStack("dye"), new ItemStack(Blocks.glass, 8, OreDictionary.WILDCARD_VALUE))); - RecipeRegistryProxy.addRecipe( - new ItemStack(Blocks.stained_glass_pane, 16, OreDictionary.WILDCARD_VALUE), - Arrays.asList(new ItemStack(Blocks.stained_glass, 6, OreDictionary.WILDCARD_VALUE))); RecipeRegistryProxy.addRecipe( new ItemStack(Blocks.daylight_detector), Arrays.asList( diff --git a/src/main/java/com/pahimar/ee3/reference/Comparators.java b/src/main/java/com/pahimar/ee3/reference/Comparators.java index b623ffb2..3215214b 100644 --- a/src/main/java/com/pahimar/ee3/reference/Comparators.java +++ b/src/main/java/com/pahimar/ee3/reference/Comparators.java @@ -1,60 +1,125 @@ package com.pahimar.ee3.reference; +import java.util.Collection; import java.util.Comparator; +import java.util.Set; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; -import com.pahimar.ee3.exchange.EnergyValueRegistry; +import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy; +import com.pahimar.ee3.exchange.WrappedStack; public class Comparators { - public static Comparator stringComparator = new Comparator() { + public static final Comparator> ITEM_STACK_COLLECTION_COMPARATOR = new Comparator>() { @Override - public int compare(String string1, String string2) { - return string1.compareToIgnoreCase(string2); + public int compare(Collection o1, Collection o2) { + + if (o1 != null && o2 != null) { + if (o1.size() == o2.size()) { + if (o1.containsAll(o2)) { + if (o2.containsAll(o1)) { + return 0; + } else { + return 1; + } + } else { + return -1; + } + } else { + return o1.size() - o2.size(); + } + } else if (o1 != null) { + return -1; + } else if (o2 != null) { + return 1; + } else { + return 0; + } } }; - public static Comparator idComparator = new Comparator() { + public static final Comparator> WRAPPED_STACK_SET_COMPARATOR = new Comparator>() { + + @Override + public int compare(Set collection1, Set collection2) { + if (collection1 != null && collection2 != null) { + if (collection1.size() == collection2.size()) { + if (collection1.containsAll(collection2)) { + if (collection2.containsAll(collection1)) { + return 0; + } else { + return 1; + } + } else { + return -1; + } + } else { + return collection1.size() - collection2.size(); + } + } else if (collection1 != null) { + return -1; + } else if (collection2 != null) { + return 1; + } else { + return 0; + } + } + }; + + public static final Comparator STRING_COMPARATOR = String::compareToIgnoreCase; + + public static final Comparator ID_COMPARATOR = new Comparator() { + + @Override public int compare(ItemStack itemStack1, ItemStack itemStack2) { + if (itemStack1 != null && itemStack2 != null) { - // Sort on itemID - if (Item.getIdFromItem(itemStack1.getItem()) - Item.getIdFromItem(itemStack2.getItem()) == 0) { - // Sort on item - if (itemStack1.getItem() == itemStack2.getItem()) { - // Then sort on meta - if ((itemStack1.getItemDamage() == itemStack2.getItemDamage()) - || itemStack1.getItemDamage() == OreDictionary.WILDCARD_VALUE - || itemStack2.getItemDamage() == OreDictionary.WILDCARD_VALUE) { - // Then sort on NBT - if (itemStack1.hasTagCompound() && itemStack2.hasTagCompound()) { - // Then sort on stack size - if (ItemStack.areItemStackTagsEqual(itemStack1, itemStack2)) { - return (itemStack1.stackSize - itemStack2.stackSize); + if (itemStack1.getItem() != null && itemStack2.getItem() != null) { + // Sort on id + if (Item.getIdFromItem(itemStack1.getItem()) - Item.getIdFromItem(itemStack2.getItem()) == 0) { + // Sort on item + if (itemStack1.getItem() == itemStack2.getItem()) { + // Then sort on meta + if ((itemStack1.getItemDamage() == itemStack2.getItemDamage()) + || itemStack1.getItemDamage() == OreDictionary.WILDCARD_VALUE + || itemStack2.getItemDamage() == OreDictionary.WILDCARD_VALUE) { + // Then sort on NBT + if (itemStack1.hasTagCompound() && itemStack2.hasTagCompound()) { + // Then sort on stack size + if (ItemStack.areItemStackTagsEqual(itemStack1, itemStack2)) { + return (itemStack1.stackSize - itemStack2.stackSize); + } else { + return (itemStack1.getTagCompound().hashCode() + - itemStack2.getTagCompound().hashCode()); + } + } else if (!(itemStack1.hasTagCompound()) && itemStack2.hasTagCompound()) { + return -1; + } else if (itemStack1.hasTagCompound() && !(itemStack2.hasTagCompound())) { + return 1; } else { - return (itemStack1.getTagCompound().hashCode() - - itemStack2.getTagCompound().hashCode()); + return (itemStack1.stackSize - itemStack2.stackSize); } - } else if (!(itemStack1.hasTagCompound()) && itemStack2.hasTagCompound()) { - return -1; - } else if (itemStack1.hasTagCompound() && !(itemStack2.hasTagCompound())) { - return 1; } else { - return (itemStack1.stackSize - itemStack2.stackSize); + return (itemStack1.getItemDamage() - itemStack2.getItemDamage()); } } else { - return (itemStack1.getItemDamage() - itemStack2.getItemDamage()); + return itemStack1.getItem().getUnlocalizedName(itemStack1) + .compareToIgnoreCase(itemStack2.getItem().getUnlocalizedName(itemStack2)); } } else { - return itemStack1.getItem().getUnlocalizedName(itemStack1) - .compareToIgnoreCase(itemStack2.getItem().getUnlocalizedName(itemStack2)); + return Item.getIdFromItem(itemStack1.getItem()) - Item.getIdFromItem(itemStack2.getItem()); } + } else if (itemStack1.getItem() != null) { + return -1; + } else if (itemStack2.getItem() != null) { + return 1; } else { - return Item.getIdFromItem(itemStack1.getItem()) - Item.getIdFromItem(itemStack2.getItem()); + return 0; } } else if (itemStack1 != null) { return -1; @@ -66,20 +131,13 @@ public int compare(ItemStack itemStack1, ItemStack itemStack2) { } }; - public static Comparator reverseIdComparator = new Comparator() { + public static final Comparator DISPLAY_NAME_COMPARATOR = new Comparator() { @Override - public int compare(ItemStack itemStack1, ItemStack itemStack2) { - return idComparator.compare(itemStack1, itemStack2) * -1; - } - }; - - public static Comparator displayNameComparator = new Comparator() { - public int compare(ItemStack itemStack1, ItemStack itemStack2) { if (itemStack1 != null && itemStack2 != null) { if (itemStack1.getDisplayName().equalsIgnoreCase(itemStack2.getDisplayName())) { - return idComparator.compare(itemStack1, itemStack2); + return ID_COMPARATOR.compare(itemStack1, itemStack2); } else { return itemStack1.getDisplayName().compareToIgnoreCase(itemStack2.getDisplayName()); } @@ -93,26 +151,18 @@ public int compare(ItemStack itemStack1, ItemStack itemStack2) { } }; - public static Comparator reverseDisplayNameComparator = new Comparator() { - - @Override - public int compare(ItemStack itemStack1, ItemStack itemStack2) { - return displayNameComparator.compare(itemStack1, itemStack2) * -1; - } - }; - - public static Comparator energyValueItemStackComparator = new Comparator() { + public static final Comparator ENERGY_VALUE_ITEM_STACK_COMPARATOR = new Comparator() { @Override public int compare(ItemStack itemStack1, ItemStack itemStack2) { if (itemStack1 != null && itemStack2 != null) { - if (EnergyValueRegistry.getInstance().hasEnergyValue(itemStack1) - && EnergyValueRegistry.getInstance().hasEnergyValue(itemStack2)) { + if (EnergyValueRegistryProxy.hasEnergyValue(itemStack1) + && EnergyValueRegistryProxy.hasEnergyValue(itemStack2)) { return Float.compare( - EnergyValueRegistry.getInstance().getEnergyValue(itemStack1).getValue(), - EnergyValueRegistry.getInstance().getEnergyValue(itemStack2).getValue()); + EnergyValueRegistryProxy.getEnergyValue(itemStack1).getValue(), + EnergyValueRegistryProxy.getEnergyValue(itemStack2).getValue()); } else { - return idComparator.compare(itemStack1, itemStack2); + return ID_COMPARATOR.compare(itemStack1, itemStack2); } } else if (itemStack1 != null) { return -1; @@ -123,12 +173,4 @@ public int compare(ItemStack itemStack1, ItemStack itemStack2) { } } }; - - public static Comparator reverseEnergyValueComparator = new Comparator() { - - @Override - public int compare(ItemStack itemStack1, ItemStack itemStack2) { - return energyValueItemStackComparator.compare(itemStack1, itemStack2) * -1; - } - }; } diff --git a/src/main/java/com/pahimar/ee3/reference/Files.java b/src/main/java/com/pahimar/ee3/reference/Files.java index 918ef277..d18a3d41 100644 --- a/src/main/java/com/pahimar/ee3/reference/Files.java +++ b/src/main/java/com/pahimar/ee3/reference/Files.java @@ -2,45 +2,73 @@ import java.io.File; +import com.pahimar.ee3.blacklist.BlacklistRegistry; +import com.pahimar.ee3.exchange.EnergyValueRegistry; +import com.pahimar.ee3.knowledge.PlayerKnowledgeRegistry; + +import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.event.FMLPreInitializationEvent; public class Files { - public static final String PRE_CALCULATION_ENERGY_VALUES = "pre-calculation-energy-values.json"; - public static final String POST_CALCULATION_ENERGY_VALUES = "post-calculation-energy-values.json"; - public static final String TEMPLATE_JSON_FILE = "template.json"; - public static final String ABILITIES_JSON_FILE = "abilities.json"; - public static final String STATIC_ENERGY_VALUES_JSON = "energy-values.json.gz"; + public static File globalDataDirectory; + public static File globalTestDirectory; + public static File playerDataDirectory; + + private static final String ENERGY_VALUES_JSON_FILENAME = "energy-values.json"; + private static final String PRE_CALCULATION_ENERGY_VALUES_FILENAME = "pre-calculation-energy-values.json"; + private static final String POST_CALCULATION_ENERGY_VALUES_FILENAME = "post-calculation-energy-values.json"; - public static class Global { + public static final String TEMPLATE_PLAYER_KNOWLEDGE_FILENAME = "template-player-knowledge.json"; - public static File dataDirectory; + public static final String KNOWLEDGE_BLACKLIST_FILENAME = "knowledge-blacklist.json"; + public static final String EXCHANGE_BLACKLIST_FILENAME = "exchange-blacklist.json"; - public static File preCalcluationEnergyValueFile; - public static File postCalcluationEnergyValueFile; + public static void init(FMLPreInitializationEvent event) { - public static File abilityFile; + globalDataDirectory = new File( + event.getModConfigurationDirectory().getParentFile(), + "data" + File.separator + Reference.LOWERCASE_MOD_ID); + globalTestDirectory = new File(globalDataDirectory, "tests"); + globalTestDirectory.mkdirs(); - public static File templateTransmutationKnowledgeFile; + EnergyValueRegistry.energyValuesDirectory = new File(globalDataDirectory, "energy-values"); + EnergyValueRegistry.energyValuesDirectory.mkdirs(); + EnergyValueRegistry.energyValuesFile = new File( + EnergyValueRegistry.energyValuesDirectory, + ENERGY_VALUES_JSON_FILENAME); + EnergyValueRegistry.preCalculationValuesFile = new File( + EnergyValueRegistry.energyValuesDirectory, + PRE_CALCULATION_ENERGY_VALUES_FILENAME); + EnergyValueRegistry.postCalculationValuesFile = new File( + EnergyValueRegistry.energyValuesDirectory, + POST_CALCULATION_ENERGY_VALUES_FILENAME); - public static void init(FMLPreInitializationEvent event) { - dataDirectory = new File( - event.getModConfigurationDirectory().getParentFile(), - "data" + File.separator + Reference.LOWERCASE_MOD_ID); - dataDirectory.mkdirs(); + File templatePlayerKnowledgeDirectory = new File( + globalDataDirectory, + "knowledge" + File.separator + "transmutation"); + templatePlayerKnowledgeDirectory.mkdirs(); + PlayerKnowledgeRegistry.templatePlayerKnowledgeFile = new File( + templatePlayerKnowledgeDirectory, + TEMPLATE_PLAYER_KNOWLEDGE_FILENAME); - File energyValueDataDirectory = new File(dataDirectory, "energyvalues"); - energyValueDataDirectory.mkdirs(); - preCalcluationEnergyValueFile = new File(energyValueDataDirectory, PRE_CALCULATION_ENERGY_VALUES); - postCalcluationEnergyValueFile = new File(energyValueDataDirectory, POST_CALCULATION_ENERGY_VALUES); + BlacklistRegistry.knowledgeBlacklistFile = new File( + globalDataDirectory, + "blacklist" + File.separator + KNOWLEDGE_BLACKLIST_FILENAME); + BlacklistRegistry.exchangeBlacklistFile = new File( + globalDataDirectory, + "blacklist" + File.separator + EXCHANGE_BLACKLIST_FILENAME); + } - File abilityDataDirectory = new File(dataDirectory, "abilities"); - abilityDataDirectory.mkdirs(); - abilityFile = new File(abilityDataDirectory, ABILITIES_JSON_FILE); + /** + * Updates the references to the instance specific EE3 data directories, creating them if they don't already exist + */ + public static void updateFileReferences() { - File knowledgeDataDirectory = new File(dataDirectory, "knowledge"); - knowledgeDataDirectory.mkdirs(); - templateTransmutationKnowledgeFile = new File(knowledgeDataDirectory, TEMPLATE_JSON_FILE); - } + playerDataDirectory = new File( + FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getSaveHandler() + .getWorldDirectory(), + "playerdata" + File.separator + Reference.LOWERCASE_MOD_ID); + playerDataDirectory.mkdirs(); } } diff --git a/src/main/java/com/pahimar/ee3/reference/Messages.java b/src/main/java/com/pahimar/ee3/reference/Messages.java index a78be2e6..23bfdd75 100644 --- a/src/main/java/com/pahimar/ee3/reference/Messages.java +++ b/src/main/java/com/pahimar/ee3/reference/Messages.java @@ -54,19 +54,19 @@ public static final class Commands { + Names.Commands.SET_ENERGY_VALUE_CURRENT_ITEM + ".success"; - public static final String SYNC_ENERGY_VALUES_USAGE = COMMAND_PREFIX + Names.Commands.SYNC_ENERGY_VALUES + public static final String REGEN_ENERGY_VALUES_USAGE = COMMAND_PREFIX + Names.Commands.REGEN_ENERGY_VALUES + ".usage"; - public static final String SYNC_ENERGY_VALUES_SUCCESS = COMMAND_PREFIX + Names.Commands.SYNC_ENERGY_VALUES + public static final String REGEN_ENERGY_VALUES_SUCCESS = COMMAND_PREFIX + Names.Commands.REGEN_ENERGY_VALUES + ".success"; - public static final String SYNC_ENERGY_VALUES_DENIED = COMMAND_PREFIX + Names.Commands.SYNC_ENERGY_VALUES + public static final String REGEN_ENERGY_VALUES_DENIED = COMMAND_PREFIX + Names.Commands.REGEN_ENERGY_VALUES + ".denied"; - public static final String PLAYER_LEARN_EVERYTHING_USAGE = COMMAND_PREFIX - + Names.Commands.PLAYER_LEARN_EVERYTHING + public static final String SYNC_ENERGY_VALUES_USAGE = COMMAND_PREFIX + Names.Commands.SYNC_ENERGY_VALUES + ".usage"; - public static final String PLAYER_LEARN_EVERYTHING_SUCCESS = COMMAND_PREFIX - + Names.Commands.PLAYER_LEARN_EVERYTHING + public static final String SYNC_ENERGY_VALUES_SUCCESS = COMMAND_PREFIX + Names.Commands.SYNC_ENERGY_VALUES + ".success"; + public static final String SYNC_ENERGY_VALUES_DENIED = COMMAND_PREFIX + Names.Commands.SYNC_ENERGY_VALUES + + ".denied"; public static final String PLAYER_LEARN_ITEM_USAGE = COMMAND_PREFIX + Names.Commands.PLAYER_LEARN_ITEM + ".usage"; @@ -99,90 +99,77 @@ public static final class Commands { + Names.Commands.PLAYER_FORGET_CURRENT_ITEM + ".success"; - public static final String TEMPLATE_LEARN_EVERYTHING_USAGE = COMMAND_PREFIX - + Names.Commands.TEMPLATE_LEARN_EVERYTHING - + ".usage"; - public static final String TEMPLATE_LEARN_EVERYTHING_SUCCESS = COMMAND_PREFIX - + Names.Commands.TEMPLATE_LEARN_EVERYTHING - + ".success"; - - public static final String TEMPLATE_LEARN_ITEM_USAGE = COMMAND_PREFIX + Names.Commands.TEMPLATE_LEARN_ITEM - + ".usage"; - public static final String TEMPLATE_LEARN_ITEM_SUCCESS = COMMAND_PREFIX + Names.Commands.TEMPLATE_LEARN_ITEM - + ".success"; - - public static final String TEMPLATE_LEARN_CURRENT_ITEM_USAGE = COMMAND_PREFIX - + Names.Commands.TEMPLATE_LEARN_CURRENT_ITEM + public static final String SET_ITEM_LEARNABLE_USAGE = COMMAND_PREFIX + Names.Commands.SET_ITEM_LEARNABLE + ".usage"; - public static final String TEMPLATE_LEARN_CURRENT_ITEM_SUCCESS = COMMAND_PREFIX - + Names.Commands.TEMPLATE_LEARN_CURRENT_ITEM + public static final String SET_ITEM_LEARNABLE_SUCCESS = COMMAND_PREFIX + Names.Commands.SET_ITEM_LEARNABLE + ".success"; - public static final String TEMPLATE_FORGET_EVERYTHING_USAGE = COMMAND_PREFIX - + Names.Commands.TEMPLATE_FORGET_EVERYTHING + public static final String SET_CURRENT_ITEM_LEARNABLE_USAGE = COMMAND_PREFIX + Names.Commands.SET_ITEM_LEARNABLE + ".usage"; - public static final String TEMPLATE_FORGET_EVERYTHING_SUCCESS = COMMAND_PREFIX - + Names.Commands.TEMPLATE_FORGET_EVERYTHING + public static final String SET_CURRENT_ITEM_LEARNABLE_SUCCESS = COMMAND_PREFIX + + Names.Commands.SET_ITEM_LEARNABLE + ".success"; + public static final String SET_CURRENT_ITEM_LEARNABLE_NO_EFFECT = COMMAND_PREFIX + + Names.Commands.SET_ITEM_LEARNABLE + + ".no-effect"; - public static final String TEMPLATE_FORGET_ITEM_USAGE = COMMAND_PREFIX + Names.Commands.TEMPLATE_FORGET_ITEM + public static final String SET_ITEM_NOT_LEARNABLE_USAGE = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_LEARNABLE + ".usage"; - public static final String TEMPLATE_FORGET_ITEM_SUCCESS = COMMAND_PREFIX + Names.Commands.TEMPLATE_FORGET_ITEM + public static final String SET_ITEM_NOT_LEARNABLE_SUCCESS = COMMAND_PREFIX + + Names.Commands.SET_ITEM_NOT_LEARNABLE + ".success"; - public static final String TEMPLATE_FORGET_CURRENT_ITEM_USAGE = COMMAND_PREFIX - + Names.Commands.TEMPLATE_FORGET_CURRENT_ITEM + public static final String SET_CURRENT_ITEM_NOT_LEARNABLE_USAGE = COMMAND_PREFIX + + Names.Commands.SET_ITEM_NOT_LEARNABLE + ".usage"; - public static final String TEMPLATE_FORGET_CURRENT_ITEM_SUCCESS = COMMAND_PREFIX - + Names.Commands.TEMPLATE_FORGET_CURRENT_ITEM + public static final String SET_CURRENT_ITEM_NOT_LEARNABLE_SUCCESS = COMMAND_PREFIX + + Names.Commands.SET_ITEM_NOT_LEARNABLE + ".success"; + public static final String SET_CURRENT_ITEM_NOT_LEARNABLE_NO_EFFECT = COMMAND_PREFIX + + Names.Commands.SET_ITEM_NOT_LEARNABLE + + ".no-effect"; - public static final String SET_ITEM_LEARNABLE_USAGE = COMMAND_PREFIX + Names.Commands.SET_ITEM_LEARNABLE + public static final String SET_ITEM_RECOVERABLE_USAGE = COMMAND_PREFIX + Names.Commands.SET_ITEM_RECOVERABLE + ".usage"; - public static final String SET_ITEM_LEARNABLE_SUCCESS = COMMAND_PREFIX + Names.Commands.SET_ITEM_LEARNABLE + public static final String SET_ITEM_RECOVERABLE_SUCCESS = COMMAND_PREFIX + Names.Commands.SET_ITEM_RECOVERABLE + ".success"; - public static final String SET_ITEM_NOT_LEARNABLE_USAGE = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_LEARNABLE + public static final String SET_CURRENT_ITEM_RECOVERABLE_USAGE = COMMAND_PREFIX + + Names.Commands.SET_ITEM_RECOVERABLE + ".usage"; - public static final String SET_ITEM_NOT_LEARNABLE_SUCCESS = COMMAND_PREFIX - + Names.Commands.SET_ITEM_NOT_LEARNABLE + public static final String SET_CURRENT_ITEM_RECOVERABLE_SUCCESS = COMMAND_PREFIX + + Names.Commands.SET_ITEM_RECOVERABLE + ".success"; + public static final String SET_CURRENT_ITEM_RECOVERABLE_NO_EFFECT = COMMAND_PREFIX + + Names.Commands.SET_ITEM_RECOVERABLE + + ".no-effect"; - public static final String SET_ITEM_RECOVERABLE_USAGE = COMMAND_PREFIX + Names.Commands.SET_ITEM_RECOVERABLE + public static final String SET_ITEM_NOT_RECOVERABLE_USAGE = COMMAND_PREFIX + + Names.Commands.SET_ITEM_NOT_RECOVERABLE + ".usage"; - public static final String SET_ITEM_RECOVERABLE_SUCCESS = COMMAND_PREFIX + Names.Commands.SET_ITEM_RECOVERABLE + public static final String SET_ITEM_NOT_RECOVERABLE_SUCCESS = COMMAND_PREFIX + + Names.Commands.SET_ITEM_NOT_RECOVERABLE + ".success"; - public static final String SET_ITEM_NOT_RECOVERABLE_USAGE = COMMAND_PREFIX + public static final String SET_CURRENT_ITEM_NOT_RECOVERABLE_USAGE = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_RECOVERABLE + ".usage"; - public static final String SET_ITEM_NOT_RECOVERABLE_SUCCESS = COMMAND_PREFIX + public static final String SET_CURRENT_ITEM_NOT_RECOVERABLE_SUCCESS = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_RECOVERABLE + ".success"; + public static final String SET_CURRENT_ITEM_NOT_RECOVERABLE_NO_EFFECT = COMMAND_PREFIX + + Names.Commands.SET_ITEM_NOT_RECOVERABLE + + ".no-effect"; public static final String RUN_TEST_USAGE = COMMAND_PREFIX + Names.Commands.RUN_TEST + ".usage"; public static final String RUN_TESTS_SUCCESS = COMMAND_PREFIX + Names.Commands.RUN_TEST + ".success"; public static final String RUN_TESTS_NOT_FOUND = COMMAND_PREFIX + Names.Commands.RUN_TEST + ".notfound"; + public static final String RUN_TESTS_DIR_NOT_FOUND = COMMAND_PREFIX + Names.Commands.RUN_TEST + ".dir-notfound"; public static final String ADMIN_USAGE = COMMAND_PREFIX + Names.Commands.ADMIN_PANEL + ".usage"; } public static final class Configuration { - public static final String GENERAL_SYNC_THRESHOLD = "sync.threshold"; - public static final String GENERAL_SYNC_THRESHOLD_LABEL = "general.sync.threshold.label"; - public static final String GENERAL_SYNC_THRESHOLD_COMMENT = "general.sync.threshold.comment"; - - public static final String SOUND_MODE = "soundMode"; - public static final String SOUND_MODE_LABEL = "general.sound.soundMode.label"; - public static final String SOUND_MODE_COMMENT = "general.sound.soundMode.comment"; - - public static final String ABILITIES_ONLY_LOAD_FILE = "abilities.onlyLoadFile"; - public static final String ABILITIES_ONLY_LOAD_FILE_LABEL = "general.abilities.onlyLoadFile.label"; - public static final String ABILITIES_ONLY_LOAD_FILE_COMMENT = "general.abilities.onlyLoadFile.comment"; - - public static final String REGENERATE_ENERGYVALUES_WHEN = "energyvalues.regenerateEnergyValuesWhen"; - public static final String REGENERATE_ENERGYVALUES_WHEN_LABEL = "general.energyvalues.regenerateEnergyValuesWhen.label"; - public static final String REGENERATE_ENERGYVALUES_WHEN_COMMENT = "general.energyvalues.regenerateEnergyValuesWhen.comment"; } } diff --git a/src/main/java/com/pahimar/ee3/reference/Names.java b/src/main/java/com/pahimar/ee3/reference/Names.java index 92499f42..fba8bea2 100644 --- a/src/main/java/com/pahimar/ee3/reference/Names.java +++ b/src/main/java/com/pahimar/ee3/reference/Names.java @@ -140,6 +140,7 @@ public static final class Commands { public static final String BASE_COMMAND = Reference.LOWERCASE_MOD_ID; public static final String SET_ENERGY_VALUE = "set-energy-value"; public static final String SET_ENERGY_VALUE_CURRENT_ITEM = "set-energy-value-current-item"; + public static final String REGEN_ENERGY_VALUES = "regen-energy-values"; public static final String SYNC_ENERGY_VALUES = "sync-energy-values"; public static final String PLAYER_LEARN_EVERYTHING = "player-learn-everything"; public static final String PLAYER_LEARN_ITEM = "player-learn-item"; @@ -147,16 +148,14 @@ public static final class Commands { public static final String PLAYER_FORGET_EVERYTHING = "player-forget-everything"; public static final String PLAYER_FORGET_ITEM = "player-forget-item"; public static final String PLAYER_FORGET_CURRENT_ITEM = "player-forget-current-item"; - public static final String TEMPLATE_LEARN_EVERYTHING = "template-learn-everything"; - public static final String TEMPLATE_LEARN_ITEM = "template-learn-item"; - public static final String TEMPLATE_LEARN_CURRENT_ITEM = "template-learn-current-item"; - public static final String TEMPLATE_FORGET_EVERYTHING = "template-forget-everything"; - public static final String TEMPLATE_FORGET_ITEM = "template-forget-item"; - public static final String TEMPLATE_FORGET_CURRENT_ITEM = "template-forget-current-item"; public static final String SET_ITEM_LEARNABLE = "set-item-learnable"; + public static final String SET_CURRENT_ITEM_LEARNABLE = "set-current-item-learnable"; public static final String SET_ITEM_NOT_LEARNABLE = "set-item-not-learnable"; + public static final String SET_CURRENT_ITEM_NOT_LEARNABLE = "set-current-item-not-learnable"; public static final String SET_ITEM_RECOVERABLE = "set-item-recoverable"; + public static final String SET_CURRENT_ITEM_RECOVERABLE = "set-current-item-recoverable"; public static final String SET_ITEM_NOT_RECOVERABLE = "set-item-not-recoverable"; + public static final String SET_CURRENT_ITEM_NOT_RECOVERABLE = "set-current-item-not-recoverable"; public static final String RUN_TEST = "run-tests"; public static final String DEBUG = "debug"; public static final String ADMIN_PANEL = "admin"; diff --git a/src/main/java/com/pahimar/ee3/reference/Settings.java b/src/main/java/com/pahimar/ee3/reference/Settings.java deleted file mode 100644 index d3244332..00000000 --- a/src/main/java/com/pahimar/ee3/reference/Settings.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.pahimar.ee3.reference; - -public class Settings { - - public static class General { - - public static int syncThreshold; - } - - public static class Sounds { - - public static String soundMode; - } - - public static class Abilities { - - public static boolean onlyLoadFile; - } - - public static class DynamicEnergyValueGeneration { - - public static String regenerateEnergyValuesWhen; - } -} diff --git a/src/main/java/com/pahimar/ee3/reference/Tests.java b/src/main/java/com/pahimar/ee3/reference/Tests.java deleted file mode 100644 index efafe25f..00000000 --- a/src/main/java/com/pahimar/ee3/reference/Tests.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.pahimar.ee3.reference; - -import com.pahimar.ee3.test.EnergyValueMappingsTestSuite; -import com.pahimar.ee3.test.VanillaEnergyValueTest; - -public class Tests { - - public static final EnergyValueMappingsTestSuite vanillaEnergyValueTest = new VanillaEnergyValueTest(); -} diff --git a/src/main/java/com/pahimar/ee3/test/EnergyValueMappingsTestSuite.java b/src/main/java/com/pahimar/ee3/test/EnergyValueMappingsTestSuite.java deleted file mode 100644 index f300460a..00000000 --- a/src/main/java/com/pahimar/ee3/test/EnergyValueMappingsTestSuite.java +++ /dev/null @@ -1,136 +0,0 @@ -package com.pahimar.ee3.test; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -import org.apache.logging.log4j.Marker; -import org.apache.logging.log4j.MarkerManager; - -import com.pahimar.ee3.api.exchange.EnergyValue; -import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy; -import com.pahimar.ee3.exchange.WrappedStack; -import com.pahimar.ee3.util.LogHelper; -import com.pahimar.ee3.util.SerializationHelper; - -public class EnergyValueMappingsTestSuite { - - public static final Marker TEST_MARKER = MarkerManager.getMarker("EE3_TEST", LogHelper.MOD_MARKER); - private static final Marker SUCCESS_MARKER = MarkerManager.getMarker("EE3_TEST_SUCCESS", TEST_MARKER); - private static final Marker FAILURE_MARKER = MarkerManager.getMarker("EE3_TEST_FAILURE", TEST_MARKER); - - Map testSuiteValueMap; - - public EnergyValueMappingsTestSuite() { - testSuiteValueMap = new TreeMap(); - } - - public EnergyValueMappingsTestSuite(File jsonFile) { - if (jsonFile != null && jsonFile.exists() && jsonFile.isFile()) { - testSuiteValueMap = SerializationHelper.readEnergyValueStackMapFromJsonFile(jsonFile); - } - } - - public void add(Object object, Object value) { - if (WrappedStack.canBeWrapped(object)) { - if (value instanceof Number) { - Number number = (Number) value; - WrappedStack wrappedStack = WrappedStack.wrap(object); - wrappedStack.setStackSize(1); - testSuiteValueMap.put(wrappedStack, new EnergyValue(number.floatValue())); - } else if (value == null) { - WrappedStack wrappedStack = WrappedStack.wrap(object); - wrappedStack.setStackSize(1); - testSuiteValueMap.put(wrappedStack, null); - } - } - } - - public void remove(Object object) { - if (WrappedStack.canBeWrapped(object)) { - WrappedStack wrappedStack = WrappedStack.wrap(object); - wrappedStack.setStackSize(1); - testSuiteValueMap.remove(wrappedStack); - } - } - - public void loadTestSuite(File jsonFile) { - if (jsonFile != null && jsonFile.exists() && jsonFile.isFile()) { - testSuiteValueMap = SerializationHelper.readEnergyValueStackMapFromJsonFile(jsonFile); - } - } - - public void saveTestSuite(File jsonFile) { - if (jsonFile != null) { - SerializationHelper.writeEnergyValueStackMapToJsonFile(jsonFile, testSuiteValueMap); - } - } - - public void runTestSuite() { - runTestSuite(false); - } - - public void runTestSuite(boolean strict) { - List successMessages = new ArrayList(); - List failureMessages = new ArrayList(); - for (WrappedStack wrappedStack : testSuiteValueMap.keySet()) { - EnergyValue registryEnergyValue = EnergyValueRegistryProxy.getEnergyValue(wrappedStack, strict); - EnergyValue testSuiteEnergryValue = testSuiteValueMap.get(wrappedStack); - - if (registryEnergyValue == null && testSuiteEnergryValue == null) { - /** - * Success - anticipated that no value was found and no value was found - */ - successMessages.add( - String.format( - "SUCCESS: Object '%s' had the expected energy value [Expected (%s), Found (%s)]", - wrappedStack, - testSuiteEnergryValue, - registryEnergyValue)); - } else if (registryEnergyValue == null) { - /** - * Failure - anticipated that a value would be found but no value was found - */ - failureMessages.add( - String.format( - "FAILURE: Object '%s' did not have the expected energy value [Expected (%s), Found (%s)]", - wrappedStack, - testSuiteEnergryValue, - registryEnergyValue)); - } else if (registryEnergyValue != null && testSuiteEnergryValue != null) { - if (registryEnergyValue.equals(testSuiteEnergryValue)) { - /** - * Success - anticipated that a specific value would be found and the anticipated value was found - */ - successMessages.add( - String.format( - "SUCCESS: Object '%s' had the expected energy value [Expected (%s), Found (%s)]", - wrappedStack, - testSuiteEnergryValue, - registryEnergyValue)); - } else { - /** - * Failure - anticipated that a specific value would be found and while a value was found it was not - * the anticipated one - */ - failureMessages.add( - String.format( - "FAILURE: Object '%s' did not have the expected energy value [Expected (%s), Found (%s)]", - wrappedStack, - testSuiteEnergryValue, - registryEnergyValue)); - } - } - } - - for (String successMessage : successMessages) { - LogHelper.info(SUCCESS_MARKER, successMessage); - } - - for (String failureMessage : failureMessages) { - LogHelper.warn(FAILURE_MARKER, failureMessage); - } - } -} diff --git a/src/main/java/com/pahimar/ee3/test/VanillaEnergyValueTest.java b/src/main/java/com/pahimar/ee3/test/VanillaEnergyValueTest.java deleted file mode 100644 index 6604a01e..00000000 --- a/src/main/java/com/pahimar/ee3/test/VanillaEnergyValueTest.java +++ /dev/null @@ -1,605 +0,0 @@ -package com.pahimar.ee3.test; - -import java.io.File; - -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.OreDictionary; - -import com.pahimar.ee3.reference.Reference; -import cpw.mods.fml.common.FMLCommonHandler; - -public class VanillaEnergyValueTest extends EnergyValueMappingsTestSuite { - - public VanillaEnergyValueTest() { - buildTestSuite(); - } - - private void buildTestSuite() { - addBuildingBlocksTabTestCases(); - addDecorationBlocksTabTestCases(); - addRedstoneTabTestCases(); - addTransportationTabTestCases(); - addMiscellaneousTabTestCases(); - addFoodstuffsTabTestCases(); - addToolsTabTestCases(); - addCombatTabTestCases(); - addBrewingTabTestCases(); - addMaterialsTabTestCases(); - } - - private void addBuildingBlocksTabTestCases() { - add(Blocks.stone, 1); - add(Blocks.grass, 1); - add(Blocks.dirt, 1); - add(new ItemStack(Blocks.dirt, 1, 2), 1); - add(Blocks.cobblestone, 1); - add(new ItemStack(Blocks.planks, 1, 0), 8); - add(new ItemStack(Blocks.planks, 1, 1), 8); - add(new ItemStack(Blocks.planks, 1, 2), 8); - add(new ItemStack(Blocks.planks, 1, 3), 8); - add(new ItemStack(Blocks.planks, 1, 4), 8); - add(new ItemStack(Blocks.planks, 1, 5), 8); - add(Blocks.bedrock, null); - add(Blocks.sand, 1); - add(Blocks.gravel, 4); - add(Blocks.gold_ore, 2048); - add(Blocks.iron_ore, 256); - add(Blocks.coal_ore, 32); - add(new ItemStack(Blocks.log, 1, 0), 32); - add(new ItemStack(Blocks.log, 1, 1), 32); - add(new ItemStack(Blocks.log, 1, 2), 32); - add(new ItemStack(Blocks.log, 1, 3), 32); - add(Blocks.sponge, null); - add(Blocks.glass, 1); - add(Blocks.lapis_ore, 864); - add(Blocks.lapis_block, 9 * 864); - add(new ItemStack(Blocks.sandstone, 1, 0), 4); - add(new ItemStack(Blocks.sandstone, 1, 1), 4); - add(new ItemStack(Blocks.sandstone, 1, 2), 4); - add(new ItemStack(Blocks.wool, 1, 0), 48); - add(new ItemStack(Blocks.wool, 1, 1), 64); - add(new ItemStack(Blocks.wool, 1, 2), 64); - add(new ItemStack(Blocks.wool, 1, 3), 64); - add(new ItemStack(Blocks.wool, 1, 4), 64); - add(new ItemStack(Blocks.wool, 1, 5), 64); - add(new ItemStack(Blocks.wool, 1, 6), 64); - add(new ItemStack(Blocks.wool, 1, 7), 64); - add(new ItemStack(Blocks.wool, 1, 8), 64); - add(new ItemStack(Blocks.wool, 1, 9), 64); - add(new ItemStack(Blocks.wool, 1, 10), 64); - add(new ItemStack(Blocks.wool, 1, 11), 64); - add(new ItemStack(Blocks.wool, 1, 12), 64); - add(new ItemStack(Blocks.wool, 1, 13), 64); - add(new ItemStack(Blocks.wool, 1, 14), 64); - add(new ItemStack(Blocks.wool, 1, 15), 64); - add(Blocks.gold_block, 9 * 2048); - add(Blocks.iron_block, 9 * 256); - add(new ItemStack(Blocks.stone_slab, 1, 0), 0.5); - add(new ItemStack(Blocks.stone_slab, 1, 1), 2); - add(new ItemStack(Blocks.stone_slab, 1, 3), 0.5); - add(new ItemStack(Blocks.stone_slab, 1, 4), 128); - add(new ItemStack(Blocks.stone_slab, 1, 5), 0.5); - add(new ItemStack(Blocks.stone_slab, 1, 6), 2); - add(new ItemStack(Blocks.stone_slab, 1, 7), 512); - add(Blocks.brick_block, 256); - add(Blocks.bookshelf, 528); - add(Blocks.mossy_cobblestone, 1); - add(Blocks.obsidian, 64); - add(Blocks.oak_stairs, 12); - add(Blocks.diamond_ore, 8192); - add(Blocks.diamond_block, 9 * 8192); - add(Blocks.stone_stairs, 1.5); - add(Blocks.redstone_ore, 32); - add(Blocks.ice, 1); - add(Blocks.snow, 1); - add(Blocks.clay, 256); - add(Blocks.pumpkin, 144); - add(Blocks.netherrack, 1); - add(Blocks.soul_sand, 49); - add(Blocks.glowstone, 1536); - add(Blocks.lit_pumpkin, 153); - add(new ItemStack(Blocks.stained_glass, 1, 0), 3); - add(new ItemStack(Blocks.stained_glass, 1, 1), 3); - add(new ItemStack(Blocks.stained_glass, 1, 2), 3); - add(new ItemStack(Blocks.stained_glass, 1, 3), 3); - add(new ItemStack(Blocks.stained_glass, 1, 4), 3); - add(new ItemStack(Blocks.stained_glass, 1, 5), 3); - add(new ItemStack(Blocks.stained_glass, 1, 6), 3); - add(new ItemStack(Blocks.stained_glass, 1, 7), 3); - add(new ItemStack(Blocks.stained_glass, 1, 8), 3); - add(new ItemStack(Blocks.stained_glass, 1, 9), 3); - add(new ItemStack(Blocks.stained_glass, 1, 10), 3); - add(new ItemStack(Blocks.stained_glass, 1, 11), 3); - add(new ItemStack(Blocks.stained_glass, 1, 12), 3); - add(new ItemStack(Blocks.stained_glass, 1, 13), 3); - add(new ItemStack(Blocks.stained_glass, 1, 14), 3); - add(new ItemStack(Blocks.stained_glass, 1, 15), 3); - add(new ItemStack(Blocks.stonebrick, 1, 0), 1); - add(new ItemStack(Blocks.stonebrick, 1, 1), 1); - add(new ItemStack(Blocks.stonebrick, 1, 2), 1); - add(new ItemStack(Blocks.stonebrick, 1, 3), 1); - add(Blocks.melon_block, 144); - add(Blocks.brick_stairs, 384); - add(Blocks.stone_brick_stairs, 1.5); - add(Blocks.mycelium, 1); - add(Blocks.nether_brick, 4); - add(Blocks.nether_brick_stairs, 6); - add(Blocks.end_stone, 1); - add(new ItemStack(Blocks.wooden_slab, 1, 0), 4); - add(new ItemStack(Blocks.wooden_slab, 1, 1), 4); - add(new ItemStack(Blocks.wooden_slab, 1, 2), 4); - add(new ItemStack(Blocks.wooden_slab, 1, 3), 4); - add(new ItemStack(Blocks.wooden_slab, 1, 4), 4); - add(new ItemStack(Blocks.wooden_slab, 1, 5), 4); - add(Blocks.sandstone_stairs, 6); - add(Blocks.emerald_ore, 8192); - add(Blocks.emerald_block, 9 * 8192); - add(Blocks.spruce_stairs, 12); - add(Blocks.birch_stairs, 12); - add(Blocks.jungle_stairs, 12); - add(new ItemStack(Blocks.cobblestone_wall, 1, 0), 1); - add(new ItemStack(Blocks.cobblestone_wall, 1, 1), 1); - add(Blocks.quartz_ore, 256); - add(new ItemStack(Blocks.quartz_block, 1, 0), 1024); - add(new ItemStack(Blocks.quartz_block, 1, 1), 1024); - add(new ItemStack(Blocks.quartz_block, 1, 2), 1024); - add(Blocks.quartz_stairs, 1536); - add(new ItemStack(Blocks.stained_hardened_clay, 1, 0), 258); - add(new ItemStack(Blocks.stained_hardened_clay, 1, 1), 258); - add(new ItemStack(Blocks.stained_hardened_clay, 1, 2), 258); - add(new ItemStack(Blocks.stained_hardened_clay, 1, 3), 258); - add(new ItemStack(Blocks.stained_hardened_clay, 1, 4), 258); - add(new ItemStack(Blocks.stained_hardened_clay, 1, 5), 258); - add(new ItemStack(Blocks.stained_hardened_clay, 1, 6), 258); - add(new ItemStack(Blocks.stained_hardened_clay, 1, 7), 258); - add(new ItemStack(Blocks.stained_hardened_clay, 1, 8), 258); - add(new ItemStack(Blocks.stained_hardened_clay, 1, 9), 258); - add(new ItemStack(Blocks.stained_hardened_clay, 1, 10), 258); - add(new ItemStack(Blocks.stained_hardened_clay, 1, 11), 258); - add(new ItemStack(Blocks.stained_hardened_clay, 1, 12), 258); - add(new ItemStack(Blocks.stained_hardened_clay, 1, 13), 258); - add(new ItemStack(Blocks.stained_hardened_clay, 1, 14), 258); - add(new ItemStack(Blocks.stained_hardened_clay, 1, 15), 258); - add(new ItemStack(Blocks.log2, 1, 0), 32); - add(new ItemStack(Blocks.log2, 1, 1), 32); - add(Blocks.acacia_stairs, 12); - add(Blocks.dark_oak_stairs, 12); - add(Blocks.hay_block, 216); - add(Blocks.hardened_clay, 256); - add(Blocks.coal_block, 288); - add(Blocks.packed_ice, null); - } - - private void addDecorationBlocksTabTestCases() { - add(new ItemStack(Blocks.sapling, 1, 0), 32); - add(new ItemStack(Blocks.sapling, 1, 1), 32); - add(new ItemStack(Blocks.sapling, 1, 2), 32); - add(new ItemStack(Blocks.sapling, 1, 3), 32); - add(new ItemStack(Blocks.sapling, 1, 4), 32); - add(new ItemStack(Blocks.sapling, 1, 5), 32); - add(new ItemStack(Blocks.leaves, 1, 0), 1); - add(new ItemStack(Blocks.leaves, 1, 1), 1); - add(new ItemStack(Blocks.leaves, 1, 2), 1); - add(new ItemStack(Blocks.leaves, 1, 3), 1); - add(Blocks.web, 12); - add(new ItemStack(Blocks.tallgrass, 1, 0), 1); - add(new ItemStack(Blocks.tallgrass, 1, 1), 1); - add(Blocks.deadbush, 1); - add(Blocks.yellow_flower, 16); - add(new ItemStack(Blocks.red_flower, 1, 0), 16); - add(new ItemStack(Blocks.red_flower, 1, 1), 16); - add(new ItemStack(Blocks.red_flower, 1, 2), 16); - add(new ItemStack(Blocks.red_flower, 1, 3), 16); - add(new ItemStack(Blocks.red_flower, 1, 4), 16); - add(new ItemStack(Blocks.red_flower, 1, 5), 16); - add(new ItemStack(Blocks.red_flower, 1, 6), 16); - add(new ItemStack(Blocks.red_flower, 1, 7), 16); - add(new ItemStack(Blocks.red_flower, 1, 8), 16); - add(Blocks.brown_mushroom, 32); - add(Blocks.red_mushroom, 32); - add(Blocks.torch, 9); - add(Blocks.chest, 64); - add(Blocks.crafting_table, 32); - add(Blocks.furnace, 8); - add(Blocks.ladder, 9.333); - add(Blocks.snow_layer, 0.125); - add(Blocks.cactus, 8); - add(Blocks.jukebox, 8256); - add(Blocks.fence, 12); - add(new ItemStack(Blocks.monster_egg, 1, 0), null); - add(new ItemStack(Blocks.monster_egg, 1, 1), null); - add(new ItemStack(Blocks.monster_egg, 1, 2), null); - add(new ItemStack(Blocks.monster_egg, 1, 3), null); - add(new ItemStack(Blocks.monster_egg, 1, 4), null); - add(new ItemStack(Blocks.monster_egg, 1, 5), null); - add(Blocks.iron_bars, 96); - add(Blocks.glass_pane, 0.375); - add(Blocks.vine, 8); - add(Blocks.waterlily, 16); - add(Blocks.nether_brick_fence, 4); - add(Blocks.enchanting_table, 16800); - add(Blocks.end_portal_frame, null); - add(Blocks.ender_chest, 2304); - add(new ItemStack(Blocks.anvil, 1, 0), 7936); - add(new ItemStack(Blocks.anvil, 1, 1), 5290.667); - add(new ItemStack(Blocks.anvil, 1, 2), 2645.333); - add(Blocks.trapped_chest, 198); - add(new ItemStack(Blocks.stained_glass_pane, 1, 0), 1.125); - add(new ItemStack(Blocks.stained_glass_pane, 1, 1), 1.125); - add(new ItemStack(Blocks.stained_glass_pane, 1, 2), 1.125); - add(new ItemStack(Blocks.stained_glass_pane, 1, 3), 1.125); - add(new ItemStack(Blocks.stained_glass_pane, 1, 4), 1.125); - add(new ItemStack(Blocks.stained_glass_pane, 1, 5), 1.125); - add(new ItemStack(Blocks.stained_glass_pane, 1, 6), 1.125); - add(new ItemStack(Blocks.stained_glass_pane, 1, 7), 1.125); - add(new ItemStack(Blocks.stained_glass_pane, 1, 8), 1.125); - add(new ItemStack(Blocks.stained_glass_pane, 1, 9), 1.125); - add(new ItemStack(Blocks.stained_glass_pane, 1, 10), 1.125); - add(new ItemStack(Blocks.stained_glass_pane, 1, 11), 1.125); - add(new ItemStack(Blocks.stained_glass_pane, 1, 12), 1.125); - add(new ItemStack(Blocks.stained_glass_pane, 1, 13), 1.125); - add(new ItemStack(Blocks.stained_glass_pane, 1, 14), 1.125); - add(new ItemStack(Blocks.stained_glass_pane, 1, 15), 1.125); - add(new ItemStack(Blocks.leaves2, 1, 0), 1); - add(new ItemStack(Blocks.leaves2, 1, 1), 1); - add(new ItemStack(Blocks.carpet, 1, 0), 32); - add(new ItemStack(Blocks.carpet, 1, 1), 42.667); - add(new ItemStack(Blocks.carpet, 1, 2), 42.667); - add(new ItemStack(Blocks.carpet, 1, 3), 42.667); - add(new ItemStack(Blocks.carpet, 1, 4), 42.667); - add(new ItemStack(Blocks.carpet, 1, 5), 42.667); - add(new ItemStack(Blocks.carpet, 1, 6), 42.667); - add(new ItemStack(Blocks.carpet, 1, 7), 42.667); - add(new ItemStack(Blocks.carpet, 1, 8), 42.667); - add(new ItemStack(Blocks.carpet, 1, 9), 42.667); - add(new ItemStack(Blocks.carpet, 1, 10), 42.667); - add(new ItemStack(Blocks.carpet, 1, 11), 42.667); - add(new ItemStack(Blocks.carpet, 1, 12), 42.667); - add(new ItemStack(Blocks.carpet, 1, 13), 42.667); - add(new ItemStack(Blocks.carpet, 1, 14), 42.667); - add(new ItemStack(Blocks.carpet, 1, 15), 42.667); - add(new ItemStack(Blocks.carpet, 1, 15), 42.667); - add(new ItemStack(Blocks.double_plant, 1, 0), 32); - add(new ItemStack(Blocks.double_plant, 1, 1), 32); - add(new ItemStack(Blocks.double_plant, 1, 2), 32); - add(new ItemStack(Blocks.double_plant, 1, 3), 32); - add(new ItemStack(Blocks.double_plant, 1, 4), 32); - add(new ItemStack(Blocks.double_plant, 1, 5), 32); - add(Items.painting, 80); - add(Items.sign, 17.333); - add(Items.flower_pot, 192); - add(new ItemStack(Blocks.skull, 1, 0), null); - add(new ItemStack(Blocks.skull, 1, 1), null); - add(new ItemStack(Blocks.skull, 1, 2), null); - add(new ItemStack(Blocks.skull, 1, 3), null); - add(new ItemStack(Blocks.skull, 1, 4), null); - } - - private void addRedstoneTabTestCases() { - add(Blocks.dispenser, 87); - add(Blocks.noteblock, 96); - add(Blocks.sticky_piston, 340); - add(Blocks.piston, 316); - add(Blocks.tnt, 964); - add(Blocks.lever, 5); - add(Blocks.stone_pressure_plate, 2); - add(Blocks.wooden_pressure_plate, 16); - add(Blocks.redstone_torch, 36); - add(Blocks.stone_button, 1); - add(Blocks.trapdoor, 24); - add(Blocks.fence_gate, 32); - add(Blocks.redstone_lamp, 1664); - add(Blocks.tripwire_hook, 134); - add(Blocks.wooden_button, 8); - add(Blocks.light_weighted_pressure_plate, 4096); - add(Blocks.heavy_weighted_pressure_plate, 512); - add(Blocks.daylight_detector, 783); - add(Blocks.redstone_block, 288); - add(Blocks.hopper, 1344); - add(Blocks.dropper, 39); - add(Items.wooden_door, 48); - add(Items.iron_door, 1536); - add(Items.redstone, 32); - add(Items.repeater, 107); - add(Items.comparator, 367); - } - - private void addTransportationTabTestCases() { - add(Blocks.golden_rail, 2054); - add(Blocks.detector_rail, 261.667); - add(Blocks.rail, 96.25); - add(Blocks.activator_rail, 263.333); - add(Items.minecart, 1280); - add(Items.saddle, 192); - add(Items.boat, 40); - add(Items.chest_minecart, 1344); - add(Items.furnace_minecart, 1288); - add(Items.carrot_on_a_stick, 60); - add(Items.tnt_minecart, 2244); - add(Items.hopper_minecart, 2624); - } - - private void addMiscellaneousTabTestCases() { - add(Blocks.beacon, 24773); - add(Items.bucket, 768); - add(Items.water_bucket, 769); - add(Items.lava_bucket, 832); - add(Items.snowball, 0.25); - add(Items.milk_bucket, 832); - add(Items.paper, 32); - add(Items.book, 160); - add(Items.slime_ball, 24); - add(Items.bone, 48); - add(Items.ender_pearl, 1024); - add(Items.ender_eye, 1792); - add(new ItemStack(Items.spawn_egg, 1, 50), null); - add(new ItemStack(Items.spawn_egg, 1, 51), null); - add(new ItemStack(Items.spawn_egg, 1, 52), null); - add(new ItemStack(Items.spawn_egg, 1, 54), null); - add(new ItemStack(Items.spawn_egg, 1, 55), null); - add(new ItemStack(Items.spawn_egg, 1, 56), null); - add(new ItemStack(Items.spawn_egg, 1, 57), null); - add(new ItemStack(Items.spawn_egg, 1, 58), null); - add(new ItemStack(Items.spawn_egg, 1, 59), null); - add(new ItemStack(Items.spawn_egg, 1, 60), null); - add(new ItemStack(Items.spawn_egg, 1, 61), null); - add(new ItemStack(Items.spawn_egg, 1, 62), null); - add(new ItemStack(Items.spawn_egg, 1, 65), null); - add(new ItemStack(Items.spawn_egg, 1, 66), null); - add(new ItemStack(Items.spawn_egg, 1, 90), null); - add(new ItemStack(Items.spawn_egg, 1, 91), null); - add(new ItemStack(Items.spawn_egg, 1, 92), null); - add(new ItemStack(Items.spawn_egg, 1, 93), null); - add(new ItemStack(Items.spawn_egg, 1, 94), null); - add(new ItemStack(Items.spawn_egg, 1, 95), null); - add(new ItemStack(Items.spawn_egg, 1, 96), null); - add(new ItemStack(Items.spawn_egg, 1, 98), null); - add(new ItemStack(Items.spawn_egg, 1, 100), null); - add(new ItemStack(Items.spawn_egg, 1, 120), null); - add(new ItemStack(Items.spawn_egg, 1, 97), null); - add(new ItemStack(Items.spawn_egg, 1, 99), null); - add(Items.experience_bottle, null); - add(Items.fire_charge, 330.667); - add(Items.writable_book, 224); - add(Items.map, 1312); - add(Items.firework_charge, null); - add(Items.iron_horse_armor, null); - add(Items.golden_horse_armor, null); - add(Items.diamond_horse_armor, null); - add(Items.record_13, 2048); - add(Items.record_cat, 2048); - add(Items.record_blocks, 2048); - add(Items.record_chirp, 2048); - add(Items.record_far, 2048); - add(Items.record_mellohi, 2048); - add(Items.record_stal, 2048); - add(Items.record_strad, 2048); - add(Items.record_ward, 2048); - add(Items.record_11, 2048); - add(Items.record_wait, 2048); - } - - private void addFoodstuffsTabTestCases() { - add(Items.apple, 24); - add(Items.mushroom_stew, 70); - add(Items.bread, 72); - add(Items.porkchop, 24); - add(Items.cooked_porkchop, 24); - add(new ItemStack(Items.golden_apple, 1, 0), 16408); - add(new ItemStack(Items.golden_apple, 1, 1), 147480); - add(new ItemStack(Items.fish, 1, 0), 24); - add(new ItemStack(Items.fish, 1, 1), 24); - add(new ItemStack(Items.fish, 1, 2), 24); - add(new ItemStack(Items.fish, 1, 3), 24); - add(new ItemStack(Items.cooked_fished, 1, 0), 24); - add(new ItemStack(Items.cooked_fished, 1, 1), 24); - add(Items.cake, 360); - add(Items.cookie, 8); - add(Items.melon, 16); - add(Items.beef, 24); - add(Items.cooked_beef, 24); - add(Items.chicken, 24); - add(Items.cooked_chicken, 24); - add(Items.rotten_flesh, 24); - add(Items.spider_eye, 128); - add(Items.carrot, 24); - add(Items.potato, 24); - add(Items.baked_potato, 24); - add(Items.poisonous_potato, 24); - add(Items.golden_carrot, 1844.448); - add(Items.pumpkin_pie, 208); - } - - private void addToolsTabTestCases() { - add(Items.iron_shovel, 264); - add(Items.iron_pickaxe, 776); - add(Items.iron_axe, 776); - add(Items.flint_and_steel, 260); - add(Items.wooden_shovel, 16); - add(Items.wooden_pickaxe, 32); - add(Items.wooden_axe, 32); - add(Items.stone_shovel, 9); - add(Items.stone_pickaxe, 11); - add(Items.stone_axe, 11); - add(Items.diamond_shovel, 8200); - add(Items.diamond_pickaxe, 24584); - add(Items.diamond_axe, 24584); - add(Items.golden_shovel, 2056); - add(Items.golden_pickaxe, 6152); - add(Items.golden_axe, 6152); - add(Items.wooden_hoe, 24); - add(Items.stone_hoe, 10); - add(Items.iron_hoe, 520); - add(Items.diamond_hoe, 16392); - add(Items.golden_hoe, 4104); - add(Items.compass, 1056); - add(Items.fishing_rod, 36); - add(Items.clock, 8224); - add(Items.shears, 512); - add(Items.lead, 36); - add(Items.name_tag, null); - add(new ItemStack(Items.enchanted_book, 1, OreDictionary.WILDCARD_VALUE), null); - } - - private void addCombatTabTestCases() { - add(Items.bow, 48); - add(Items.arrow, 14); - add(Items.iron_sword, 516); - add(Items.wooden_sword, 20); - add(Items.stone_sword, 6); - add(Items.diamond_sword, 16388); - add(Items.golden_sword, 4100); - add(Items.leather_helmet, 320); - add(Items.leather_chestplate, 512); - add(Items.leather_leggings, 448); - add(Items.leather_boots, 256); - add(Items.chainmail_helmet, null); - add(Items.chainmail_chestplate, null); - add(Items.chainmail_leggings, null); - add(Items.chainmail_boots, null); - add(Items.iron_helmet, 1280); - add(Items.iron_chestplate, 2048); - add(Items.iron_leggings, 1792); - add(Items.iron_boots, 1024); - add(Items.diamond_helmet, 40960); - add(Items.diamond_chestplate, 65536); - add(Items.diamond_leggings, 57344); - add(Items.diamond_boots, 32768); - add(Items.golden_helmet, 10240); - add(Items.golden_chestplate, 16384); - add(Items.golden_leggings, 14336); - add(Items.golden_boots, 8192); - } - - private void addBrewingTabTestCases() { - add(Items.ghast_tear, 4096); - add(new ItemStack(Items.potionitem, 1, 0), 2); - add(new ItemStack(Items.potionitem, 1, 16), 8.667); - add(new ItemStack(Items.potionitem, 1, 8193), 1368.222); - add(new ItemStack(Items.potionitem, 1, 8225), 163.064); - add(new ItemStack(Items.potionitem, 1, 8257), 76.151); - add(new ItemStack(Items.potionitem, 1, 16385), 520.074); - add(new ItemStack(Items.potionitem, 1, 16417), 129.484); - add(new ItemStack(Items.potionitem, 1, 16449), 63.509); - add(new ItemStack(Items.potionitem, 1, 8194), 13.556); - add(new ItemStack(Items.potionitem, 1, 8226), 132.519); - add(new ItemStack(Items.potionitem, 1, 8258), 15.185); - add(new ItemStack(Items.potionitem, 1, 16386), 68.519); - add(new ItemStack(Items.potionitem, 1, 16418), 108.173); - add(new ItemStack(Items.potionitem, 1, 16450), 33.506); - add(new ItemStack(Items.potionitem, 1, 8227), null); - add(new ItemStack(Items.potionitem, 1, 8259), null); - add(new ItemStack(Items.potionitem, 1, 16419), null); - add(new ItemStack(Items.potionitem, 1, 16451), null); - add(new ItemStack(Items.potionitem, 1, 8196), 45.556); - add(new ItemStack(Items.potionitem, 1, 8228), 138.044); - add(new ItemStack(Items.potionitem, 1, 8260), 20.711); - add(new ItemStack(Items.potionitem, 1, 16388), 79.185); - add(new ItemStack(Items.potionitem, 1, 16420), 111.728); - add(new ItemStack(Items.potionitem, 1, 16452), 26.636); - add(new ItemStack(Items.potionitem, 1, 8261), null); - add(new ItemStack(Items.potionitem, 1, 8229), 168.557); - add(new ItemStack(Items.potionitem, 1, 16453), null); - add(new ItemStack(Items.potionitem, 1, 16421), 120.186); - add(new ItemStack(Items.potionitem, 1, 8230), null); - add(new ItemStack(Items.potionitem, 1, 8262), 77.396); - add(new ItemStack(Items.potionitem, 1, 16422), null); - add(new ItemStack(Items.potionitem, 1, 16454), 54.243); - add(new ItemStack(Items.potionitem, 1, 8232), null); - add(new ItemStack(Items.potionitem, 1, 8264), 32.963); - add(new ItemStack(Items.potionitem, 1, 16424), null); - add(new ItemStack(Items.potionitem, 1, 16456), 39.432); - add(new ItemStack(Items.potionitem, 1, 8201), 258.889); - add(new ItemStack(Items.potionitem, 1, 8233), 149.369); - add(new ItemStack(Items.potionitem, 1, 8265), 62.455); - add(new ItemStack(Items.potionitem, 1, 16393), 150.296); - add(new ItemStack(Items.potionitem, 1, 16425), 115.789); - add(new ItemStack(Items.potionitem, 1, 16457), 49.813); - add(new ItemStack(Items.potionitem, 1, 8234), null); - add(new ItemStack(Items.potionitem, 1, 8266), 85.468); - add(new ItemStack(Items.potionitem, 1, 16426), null); - add(new ItemStack(Items.potionitem, 1, 16458), 84.551); - add(new ItemStack(Items.potionitem, 1, 8268), null); - add(new ItemStack(Items.potionitem, 1, 8236), 111.728); - add(new ItemStack(Items.potionitem, 1, 16460), null); - add(new ItemStack(Items.potionitem, 1, 16428), 101.243); - add(new ItemStack(Items.potionitem, 1, 8237), null); - add(new ItemStack(Items.potionitem, 1, 8269), null); - add(new ItemStack(Items.potionitem, 1, 16429), null); - add(new ItemStack(Items.potionitem, 1, 16461), null); - add(new ItemStack(Items.potionitem, 1, 8238), null); - add(new ItemStack(Items.potionitem, 1, 8270), 54.243); - add(new ItemStack(Items.potionitem, 1, 16430), null); - add(new ItemStack(Items.potionitem, 1, 16462), 61.989); - add(Items.glass_bottle, 1); - add(Items.fermented_spider_eye, 192); - add(Items.blaze_powder, 768); - add(Items.magma_cream, 792); - add(Items.brewing_stand, 1539); - add(Items.speckled_melon, 1836.448); - } - - private void addMaterialsTabTestCases() { - add(new ItemStack(Items.coal, 1, 0), 32); - add(new ItemStack(Items.coal, 1, 1), 32); - add(Items.diamond, 8192); - add(Items.iron_ingot, 256); - add(Items.gold_ingot, 2048); - add(Items.stick, 4); - add(Items.bowl, 6); - add(Items.string, 12); - add(Items.feather, 48); - add(Items.gunpowder, 192); - add(Items.wheat_seeds, 16); - add(Items.wheat, 24); - add(Items.flint, 4); - add(Items.leather, 64); - add(Items.brick, 64); - add(Items.clay_ball, 64); - add(Items.reeds, 32); - add(Items.egg, 32); - add(Items.glowstone_dust, 384); - add(new ItemStack(Items.dye, 1, 0), 16); - add(new ItemStack(Items.dye, 1, 1), 16); - add(new ItemStack(Items.dye, 1, 2), 16); - add(new ItemStack(Items.dye, 1, 3), 16); - add(new ItemStack(Items.dye, 1, 4), 864); - add(new ItemStack(Items.dye, 1, 5), 16); - add(new ItemStack(Items.dye, 1, 6), 16); - add(new ItemStack(Items.dye, 1, 7), 16); - add(new ItemStack(Items.dye, 1, 8), 16); - add(new ItemStack(Items.dye, 1, 9), 16); - add(new ItemStack(Items.dye, 1, 10), 16); - add(new ItemStack(Items.dye, 1, 11), 16); - add(new ItemStack(Items.dye, 1, 12), 16); - add(new ItemStack(Items.dye, 1, 13), 16); - add(new ItemStack(Items.dye, 1, 14), 16); - add(new ItemStack(Items.dye, 1, 15), 16); - add(Items.sugar, 32); - add(Items.pumpkin_seeds, 36); - add(Items.melon_seeds, 16); - add(Items.blaze_rod, 1536); - add(Items.gold_nugget, 227.556); - add(Items.nether_wart, 24); - add(Items.emerald, 8192); - add(Items.nether_star, 24576); - add(Items.netherbrick, 1); - add(Items.quartz, 256); - } - - public void save() { - File energyValuesDataDirectory = new File( - FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getSaveHandler() - .getWorldDirectory(), - "data" + File.separator - + Reference.LOWERCASE_MOD_ID - + File.separator - + "energyvalues" - + File.separator - + "testcases"); - energyValuesDataDirectory.mkdirs(); - this.saveTestSuite(new File(energyValuesDataDirectory, "minecraft-v1710-vanilla-test-suite.json")); - } -} diff --git a/src/main/java/com/pahimar/ee3/tileentity/TileEntityCalcinator.java b/src/main/java/com/pahimar/ee3/tileentity/TileEntityCalcinator.java index 8333ab89..14656d6a 100644 --- a/src/main/java/com/pahimar/ee3/tileentity/TileEntityCalcinator.java +++ b/src/main/java/com/pahimar/ee3/tileentity/TileEntityCalcinator.java @@ -57,11 +57,13 @@ public static boolean suckInItems(TileEntityCalcinator tileEntityCalcinator) { public int[] getAccessibleSlotsFromSide(int side) { return side == ForgeDirection.DOWN.ordinal() ? new int[] { FUEL_INVENTORY_INDEX, OUTPUT_LEFT_INVENTORY_INDEX, OUTPUT_RIGHT_INVENTORY_INDEX } - : new int[] { INPUT_INVENTORY_INDEX, OUTPUT_LEFT_INVENTORY_INDEX, OUTPUT_RIGHT_INVENTORY_INDEX }; + : new int[] { FUEL_INVENTORY_INDEX, INPUT_INVENTORY_INDEX, OUTPUT_LEFT_INVENTORY_INDEX, + OUTPUT_RIGHT_INVENTORY_INDEX }; } @Override public boolean canInsertItem(int slotIndex, ItemStack itemStack, int side) { + return isItemValidForSlot(slotIndex, itemStack); } @@ -170,6 +172,15 @@ public void closeInventory() { @Override public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) { + + if (itemStack != null) { + if (slotIndex == FUEL_INVENTORY_INDEX) { + return TileEntityFurnace.isItemFuel(itemStack); + } else if (slotIndex == INPUT_INVENTORY_INDEX) { + return true; + } + } + return false; } diff --git a/src/main/java/com/pahimar/ee3/tileentity/TileEntityResearchStation.java b/src/main/java/com/pahimar/ee3/tileentity/TileEntityResearchStation.java index 8f5d360c..bda1c9ba 100644 --- a/src/main/java/com/pahimar/ee3/tileentity/TileEntityResearchStation.java +++ b/src/main/java/com/pahimar/ee3/tileentity/TileEntityResearchStation.java @@ -1,7 +1,5 @@ package com.pahimar.ee3.tileentity; -import java.util.UUID; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -9,12 +7,12 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.network.Packet; -import com.pahimar.ee3.api.knowledge.TransmutationKnowledgeRegistryProxy; -import com.pahimar.ee3.knowledge.AbilityRegistry; +import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; +import com.pahimar.ee3.api.knowledge.PlayerKnowledgeRegistryProxy; import com.pahimar.ee3.network.PacketHandler; import com.pahimar.ee3.network.message.MessageTileEntityResearchStation; import com.pahimar.ee3.reference.Names; -import com.pahimar.ee3.util.ItemHelper; +import com.pahimar.ee3.util.ItemStackUtils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -111,7 +109,7 @@ public void closeInventory() { @Override public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) { - return slotIndex == ITEM_SLOT_INVENTORY_INDEX && AbilityRegistry.getInstance().isLearnable(itemStack); + return slotIndex == ITEM_SLOT_INVENTORY_INDEX && BlacklistRegistryProxy.isLearnable(itemStack); } @Override @@ -161,7 +159,8 @@ public int getLearnProgressScaled(int scale) { @Override public void updateEntity() { - if (!this.worldObj.isRemote) { + if (!this.worldObj.isRemote && inventory[ALCHENOMICON_SLOT_INVENTORY_INDEX] != null + && inventory[ITEM_SLOT_INVENTORY_INDEX] != null) { // Continue "cooking" the same item, if we can if (this.canLearnItemStack()) { this.itemLearnTime++; @@ -180,10 +179,10 @@ public void updateEntity() { private boolean canLearnItemStack() { ItemStack alchenomicon = inventory[ALCHENOMICON_SLOT_INVENTORY_INDEX]; - UUID playerUUID = ItemHelper.getOwnerUUID(alchenomicon); + String playerName = ItemStackUtils.getOwnerName(alchenomicon); - if (alchenomicon != null && playerUUID != null) { - return TransmutationKnowledgeRegistryProxy.canPlayerLearn(playerUUID, inventory[ITEM_SLOT_INVENTORY_INDEX]); + if (alchenomicon != null && playerName != null) { + return PlayerKnowledgeRegistryProxy.canPlayerLearn(playerName, inventory[ITEM_SLOT_INVENTORY_INDEX]); } return false; @@ -191,10 +190,10 @@ private boolean canLearnItemStack() { private boolean isItemStackKnown() { ItemStack alchenomicon = inventory[ALCHENOMICON_SLOT_INVENTORY_INDEX]; - UUID playerUUID = ItemHelper.getOwnerUUID(alchenomicon); + String playerName = ItemStackUtils.getOwnerName(alchenomicon); - if (alchenomicon != null && playerUUID != null) { - return TransmutationKnowledgeRegistryProxy.doesPlayerKnow(playerUUID, inventory[ITEM_SLOT_INVENTORY_INDEX]); + if (alchenomicon != null && playerName != null) { + return PlayerKnowledgeRegistryProxy.doesPlayerKnow(playerName, inventory[ITEM_SLOT_INVENTORY_INDEX]); } return false; @@ -202,8 +201,8 @@ private boolean isItemStackKnown() { private void learnItemStack() { if (this.canLearnItemStack()) { - TransmutationKnowledgeRegistryProxy.teachPlayer( - ItemHelper.getOwnerUUID(inventory[ALCHENOMICON_SLOT_INVENTORY_INDEX]), + PlayerKnowledgeRegistryProxy.teachPlayer( + ItemStackUtils.getOwnerName(inventory[ALCHENOMICON_SLOT_INVENTORY_INDEX]), inventory[ITEM_SLOT_INVENTORY_INDEX]); this.inventory[ITEM_SLOT_INVENTORY_INDEX].stackSize--; diff --git a/src/main/java/com/pahimar/ee3/tileentity/TileEntityTransmutationTablet.java b/src/main/java/com/pahimar/ee3/tileentity/TileEntityTransmutationTablet.java index f113f73b..89cea22a 100644 --- a/src/main/java/com/pahimar/ee3/tileentity/TileEntityTransmutationTablet.java +++ b/src/main/java/com/pahimar/ee3/tileentity/TileEntityTransmutationTablet.java @@ -1,5 +1,8 @@ package com.pahimar.ee3.tileentity; +import java.util.Collections; +import java.util.Set; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; @@ -9,14 +12,14 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraftforge.common.util.ForgeDirection; +import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; import com.pahimar.ee3.api.exchange.EnergyValue; import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy; import com.pahimar.ee3.block.BlockAshInfusedStoneSlab; -import com.pahimar.ee3.exchange.EnergyValueRegistry; import com.pahimar.ee3.item.ItemAlchenomicon; import com.pahimar.ee3.item.ItemMiniumStone; import com.pahimar.ee3.item.ItemPhilosophersStone; -import com.pahimar.ee3.knowledge.AbilityRegistry; +import com.pahimar.ee3.knowledge.PlayerKnowledge; import com.pahimar.ee3.network.PacketHandler; import com.pahimar.ee3.network.message.MessageTileEntityTransmutationTablet; import com.pahimar.ee3.reference.Names; @@ -38,29 +41,55 @@ public class TileEntityTransmutationTablet extends TileEntityEE implements ISide public static final int STONE_INDEX = 8; public static final int ALCHENOMICON_INDEX = 9; - private EnergyValue storedEnergyValue; - private EnergyValue availableEnergyValue; + private EnergyValue storedEnergy, availableEnergy; private ForgeDirection rotation; private ItemStack[] inventory; + public PlayerKnowledge playerKnowledge; public TileEntityTransmutationTablet() { + super(); rotation = ForgeDirection.UNKNOWN; - availableEnergyValue = new EnergyValue(0); - storedEnergyValue = new EnergyValue(0); + availableEnergy = new EnergyValue(0); + storedEnergy = new EnergyValue(0); inventory = new ItemStack[INVENTORY_SIZE]; } - public EnergyValue getAvailableEnergyValue() { - return availableEnergyValue; + public EnergyValue getAvailableEnergy() { + return availableEnergy; + } + + public EnergyValue getStoredEnergy() { + return storedEnergy; + } + + public ForgeDirection getRotation() { + return rotation; + } + + public void setRotation(ForgeDirection rotation) { + this.rotation = rotation; + } + + public Set getPlayerKnowledge() { + + if (playerKnowledge != null) { + return playerKnowledge.getKnownItemStacks(); + } else { + return Collections.emptySet(); + } } - public EnergyValue getStoredEnergyValue() { - return storedEnergyValue; + public void handlePlayerKnowledgeUpdate(PlayerKnowledge playerKnowledge) { + this.playerKnowledge = playerKnowledge; } + /** + * https://github.com/pahimar/Equivalent-Exchange-3/issues/1062 + */ public void consumeInventoryForEnergyValue(ItemStack outputItemStack) { - EnergyValue outputEnergyValue = EnergyValueRegistryProxy.getEnergyValue(outputItemStack); + + EnergyValue outputEnergyValue = EnergyValueRegistryProxy.getEnergyValueForStack(outputItemStack); /** * Algorithm: @@ -70,25 +99,27 @@ public void consumeInventoryForEnergyValue(ItemStack outputItemStack) { * EMC > outputItemStack EMC 4) Profit */ - if (this.storedEnergyValue.compareTo(outputEnergyValue) >= 0) { - this.storedEnergyValue = new EnergyValue(this.storedEnergyValue.getValue() - outputEnergyValue.getValue()); + if (this.storedEnergy.compareTo(outputEnergyValue) >= 0) { + this.storedEnergy = new EnergyValue(this.storedEnergy.getValue() - outputEnergyValue.getValue()); } else { - while (this.storedEnergyValue.compareTo(outputEnergyValue) < 0 - && this.availableEnergyValue.compareTo(outputEnergyValue) >= 0) { + + while (this.storedEnergy.compareTo(outputEnergyValue) < 0 + && this.availableEnergy.compareTo(outputEnergyValue) >= 0) { + for (int i = 0; i < STONE_INDEX; i++) { + ItemStack stackInSlot = getStackInSlot(i); if (stackInSlot != null && EnergyValueRegistryProxy.hasEnergyValue(stackInSlot)) { - this.storedEnergyValue = new EnergyValue( - this.storedEnergyValue.getValue() + this.storedEnergy = new EnergyValue( + this.storedEnergy.getValue() + EnergyValueRegistryProxy.getEnergyValue(stackInSlot).getValue()); decrStackSize(i, 1); } } } - if (this.storedEnergyValue.getValue() >= outputEnergyValue.getValue()) { - this.storedEnergyValue = new EnergyValue( - this.storedEnergyValue.getValue() - outputEnergyValue.getValue()); + if (this.storedEnergy.getValue() >= outputEnergyValue.getValue()) { + this.storedEnergy = new EnergyValue(this.storedEnergy.getValue() - outputEnergyValue.getValue()); } } @@ -96,21 +127,14 @@ public void consumeInventoryForEnergyValue(ItemStack outputItemStack) { } public void updateEnergyValueFromInventory() { - float newEnergyValue = storedEnergyValue.getValue(); + + float newEnergyValue = storedEnergy.getValue(); for (int i = 0; i <= STONE_INDEX; i++) { if (inventory[i] != null && EnergyValueRegistryProxy.hasEnergyValue(inventory[i])) { newEnergyValue += EnergyValueRegistryProxy.getEnergyValueForStack(inventory[i]).getValue(); } } - this.availableEnergyValue = new EnergyValue(newEnergyValue); - } - - public ForgeDirection getRotation() { - return rotation; - } - - public void setRotation(ForgeDirection rotation) { - this.rotation = rotation; + this.availableEnergy = new EnergyValue(newEnergyValue); } @Override @@ -121,6 +145,7 @@ public AxisAlignedBB getRenderBoundingBox() { } public boolean isStructureValid() { + return ((worldObj.getBlock(xCoord - 1, yCoord, zCoord - 1) instanceof BlockAshInfusedStoneSlab && worldObj.getBlockMetadata(xCoord - 1, yCoord, zCoord - 1) == 1) && (worldObj.getBlock(xCoord, yCoord, zCoord - 1) instanceof BlockAshInfusedStoneSlab @@ -141,6 +166,7 @@ public boolean isStructureValid() { @Override public void updateEntity() { + super.updateEntity(); updateEnergyValueFromInventory(); } @@ -152,6 +178,7 @@ public Packet getDescriptionPacket() { @Override public void readFromNBT(NBTTagCompound nbtTagCompound) { + super.readFromNBT(nbtTagCompound); rotation = ForgeDirection.getOrientation(nbtTagCompound.getInteger("rotation")); @@ -166,16 +193,17 @@ public void readFromNBT(NBTTagCompound nbtTagCompound) { } } - NBTTagCompound energyValueTagCompound = nbtTagCompound.getCompoundTag("storedEnergyValue"); + NBTTagCompound energyValueTagCompound = nbtTagCompound.getCompoundTag("storedEnergy"); if (!energyValueTagCompound.hasNoTags()) { - storedEnergyValue = EnergyValue.loadEnergyValueFromNBT(energyValueTagCompound); + storedEnergy = EnergyValue.loadEnergyValueFromNBT(energyValueTagCompound); } else { - storedEnergyValue = new EnergyValue(0); + storedEnergy = new EnergyValue(0); } } @Override public void writeToNBT(NBTTagCompound nbtTagCompound) { + super.writeToNBT(nbtTagCompound); nbtTagCompound.setInteger("rotation", rotation.ordinal()); @@ -192,10 +220,10 @@ public void writeToNBT(NBTTagCompound nbtTagCompound) { nbtTagCompound.setTag(Names.NBT.ITEMS, tagList); NBTTagCompound energyValueTagCompound = new NBTTagCompound(); - if (storedEnergyValue != null) { - storedEnergyValue.writeToNBT(energyValueTagCompound); + if (storedEnergy != null) { + storedEnergy.writeToNBT(energyValueTagCompound); } - nbtTagCompound.setTag("storedEnergyValue", energyValueTagCompound); + nbtTagCompound.setTag("storedEnergy", energyValueTagCompound); } @Override @@ -263,7 +291,7 @@ public int getInventoryStackLimit() { @Override public boolean isUseableByPlayer(EntityPlayer entityPlayer) { - return this.worldObj.getTileEntity(xCoord, yCoord, zCoord) == this + return this.worldObj.getTileEntity(xCoord, yCoord, zCoord) == this && isStructureValid() && entityPlayer.getDistanceSq((double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D) <= 64D; } @@ -280,8 +308,8 @@ public void closeInventory() { @Override public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) { - if (slotIndex < STONE_INDEX && EnergyValueRegistry.getInstance().hasEnergyValue(itemStack) - && AbilityRegistry.getInstance().isRecoverable(itemStack)) { + if (slotIndex < STONE_INDEX && EnergyValueRegistryProxy.hasEnergyValue(itemStack) + && BlacklistRegistryProxy.isExchangeable(itemStack)) { return true; } else if (slotIndex == STONE_INDEX && (itemStack.getItem() instanceof ItemMiniumStone || itemStack.getItem() instanceof ItemPhilosophersStone)) { diff --git a/src/main/java/com/pahimar/ee3/util/CompressionHelper.java b/src/main/java/com/pahimar/ee3/util/CompressionHelper.java index 7a35b608..3152cfe3 100644 --- a/src/main/java/com/pahimar/ee3/util/CompressionHelper.java +++ b/src/main/java/com/pahimar/ee3/util/CompressionHelper.java @@ -1,17 +1,23 @@ package com.pahimar.ee3.util; import java.io.*; +import java.nio.charset.StandardCharsets; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; public class CompressionHelper { - public static byte[] compressStringToByteArray(String uncompressedString) { + /** + * + * @param uncompressedString + * @return + */ + public static byte[] compress(String uncompressedString) { + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - GZIPOutputStream gzipOutputStream; - try { - gzipOutputStream = new GZIPOutputStream(byteArrayOutputStream); - gzipOutputStream.write(uncompressedString.getBytes("UTF-8")); + + try (GZIPOutputStream gzipOutputStream = new GZIPOutputStream(byteArrayOutputStream)) { + gzipOutputStream.write(uncompressedString.getBytes(StandardCharsets.UTF_8)); gzipOutputStream.close(); } catch (IOException e) { e.printStackTrace(); @@ -20,19 +26,26 @@ public static byte[] compressStringToByteArray(String uncompressedString) { return byteArrayOutputStream.toByteArray(); } - public static String decompressStringFromByteArray(byte[] compressedString) { - StringBuilder stringBuilder = new StringBuilder(); - try { - GZIPInputStream gzipInputStream = new GZIPInputStream(new ByteArrayInputStream(compressedString)); - BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(gzipInputStream, "UTF-8")); + /** + * + * @param compressedString + * @return + */ + public static String decompress(byte[] compressedString) { - String line; + StringBuilder stringBuilder = new StringBuilder(); + String line; + try (BufferedReader bufferedReader = new BufferedReader( + new InputStreamReader( + new GZIPInputStream(new ByteArrayInputStream(compressedString)), + StandardCharsets.UTF_8))) { while ((line = bufferedReader.readLine()) != null) { stringBuilder.append(line); } } catch (IOException e) { e.printStackTrace(); } + return stringBuilder.toString(); } } diff --git a/src/main/java/com/pahimar/ee3/util/DebugUtils.java b/src/main/java/com/pahimar/ee3/util/DebugUtils.java index 57d16d1f..d2ad36a6 100644 --- a/src/main/java/com/pahimar/ee3/util/DebugUtils.java +++ b/src/main/java/com/pahimar/ee3/util/DebugUtils.java @@ -18,7 +18,7 @@ public static void dumpSortedOreDictionaryNames() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(String.format("Ore: %s, ItemStacks: ", oreName)); for (ItemStack itemStack : OreDictionary.getOres(oreName)) { - stringBuilder.append(String.format("%s ", ItemHelper.toString(itemStack))); + stringBuilder.append(String.format("%s ", ItemStackUtils.toString(itemStack))); } LogHelper.info(stringBuilder.toString()); } diff --git a/src/main/java/com/pahimar/ee3/util/EnergyValueHelper.java b/src/main/java/com/pahimar/ee3/util/EnergyValueHelper.java deleted file mode 100644 index a514e30b..00000000 --- a/src/main/java/com/pahimar/ee3/util/EnergyValueHelper.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.pahimar.ee3.util; - -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; - -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidContainerRegistry; -import net.minecraftforge.oredict.OreDictionary; - -import com.pahimar.ee3.api.exchange.EnergyValue; -import com.pahimar.ee3.exchange.EnergyValueRegistry; -import com.pahimar.ee3.exchange.OreStack; -import com.pahimar.ee3.exchange.WrappedStack; - -public class EnergyValueHelper { - - public static EnergyValue computeEnergyValueFromRecipe(Map stackValueMappings, - WrappedStack outputStack, List inputStacks) { - float computedValue = 0f; - - for (WrappedStack wrappedStack : inputStacks) { - EnergyValue wrappedStackValue; - int stackSize = -1; - if (wrappedStack.getWrappedObject() instanceof ItemStack) { - ItemStack itemStack = (ItemStack) wrappedStack.getWrappedObject(); - - // Check if we are dealing with a potential fluid - if (FluidContainerRegistry.getFluidForFilledItem(itemStack) != null) { - if (itemStack.getItem().getContainerItem(itemStack) != null) { - stackSize = FluidContainerRegistry.getFluidForFilledItem(itemStack).amount - * wrappedStack.getStackSize(); - wrappedStackValue = EnergyValueRegistry.getInstance().getEnergyValueFromMap( - stackValueMappings, - FluidContainerRegistry.getFluidForFilledItem(itemStack)); - } else { - wrappedStackValue = EnergyValueRegistry.getInstance() - .getEnergyValueFromMap(stackValueMappings, wrappedStack); - } - } else if (itemStack.getItem().getContainerItem(itemStack) != null) { - ItemStack containerItemStack = itemStack.getItem().getContainerItem(itemStack); - - if (EnergyValueRegistry.getInstance().hasEnergyValue(itemStack) - && EnergyValueRegistry.getInstance().hasEnergyValue(containerItemStack)) { - float itemStackValue = EnergyValueRegistry.getInstance() - .getEnergyValueFromMap(stackValueMappings, itemStack).getValue(); - float containerStackValue = EnergyValueRegistry.getInstance() - .getEnergyValueFromMap(stackValueMappings, containerItemStack).getValue(); - wrappedStackValue = new EnergyValue(itemStackValue - containerStackValue); - } else { - wrappedStackValue = new EnergyValue(0); - } - } else if (!itemStack.getItem().doesContainerItemLeaveCraftingGrid(itemStack)) { - wrappedStackValue = new EnergyValue(0); - } else if (OreDictionary.getOreIDs(itemStack).length > 0) { - wrappedStackValue = EnergyValueRegistry.getInstance() - .getEnergyValueFromMap(stackValueMappings, wrappedStack, true); - } else { - wrappedStackValue = EnergyValueRegistry.getInstance() - .getEnergyValueFromMap(stackValueMappings, wrappedStack); - } - } else if (wrappedStack.getWrappedObject() instanceof OreStack) { - OreStack oreStack = (OreStack) wrappedStack.getWrappedObject(); - wrappedStackValue = EnergyValueRegistry.getInstance() - .getEnergyValueFromMap(stackValueMappings, wrappedStack); - for (ItemStack itemStack : OreDictionary.getOres(oreStack.oreName)) { - if (!itemStack.getItem().doesContainerItemLeaveCraftingGrid(itemStack)) { - wrappedStackValue = new EnergyValue(0); - } - } - } else { - wrappedStackValue = EnergyValueRegistry.getInstance() - .getEnergyValueFromMap(stackValueMappings, wrappedStack); - } - - if (wrappedStackValue != null) { - if (stackSize == -1) { - stackSize = wrappedStack.getStackSize(); - } - - computedValue += wrappedStackValue.getValue() * stackSize; - } else { - return null; - } - } - - return factorEnergyValue(new EnergyValue(computedValue), outputStack.getStackSize()); - } - - public static EnergyValue factorEnergyValue(EnergyValue energyValue, int factor) { - return factorEnergyValue(energyValue, (float) factor); - } - - public static EnergyValue factorEnergyValue(EnergyValue energyValue, float factor) { - if ((Float.compare(factor, 0f) != 0) && (energyValue != null)) { - return new EnergyValue( - new BigDecimal(energyValue.getValue() * 1f / factor).setScale(3, BigDecimal.ROUND_HALF_EVEN) - .floatValue()); - } else { - return null; - } - } -} diff --git a/src/main/java/com/pahimar/ee3/util/FilterUtils.java b/src/main/java/com/pahimar/ee3/util/FilterUtils.java index ceb7cf29..cdb47712 100644 --- a/src/main/java/com/pahimar/ee3/util/FilterUtils.java +++ b/src/main/java/com/pahimar/ee3/util/FilterUtils.java @@ -2,127 +2,146 @@ import java.util.*; -import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import com.pahimar.ee3.api.exchange.EnergyValue; -import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy; +import com.pahimar.ee3.exchange.EnergyValueRegistry; +import com.pahimar.ee3.exchange.WrappedStack; import com.pahimar.ee3.reference.Comparators; public class FilterUtils { - public static Set filterForItemBlock(Set unfilteredItemStackSet) { - return filterForItemBlock(unfilteredItemStackSet, Comparators.idComparator); + public static Set filterByDisplayName(Set itemStacks, String filterString) { + return filterByDisplayName(itemStacks, filterString, NameFilterType.STARTS_WITH, null); } - public static Set filterForItemBlock(Set unfilteredItemStackSet, Comparator comparator) { - Set itemBlockOnlySet = new TreeSet(comparator); - - for (ItemStack itemStack : unfilteredItemStackSet) { - if (itemStack.getItem() instanceof ItemBlock) { - itemBlockOnlySet.add(itemStack); - } - } - - return itemBlockOnlySet; + public static Set filterByDisplayName(Set itemStacks, String filterString, + NameFilterType filterType) { + return filterByDisplayName(itemStacks, filterString, filterType, null); } - public static Set filterByNameStartsWith(Set unfilteredItemStackSet, String filterString) { - return filterByNameStartsWith(unfilteredItemStackSet, filterString, Comparators.idComparator); - } - - public static Set filterByNameStartsWith(Set unfilteredItemStackSet, String filterString, - Comparator comparator) { - Set nameSortedSet = new TreeSet(comparator); + public static Set filterByDisplayName(Collection itemStacks, String filterString, + NameFilterType filterType, Comparator comparator) { - for (ItemStack itemStack : unfilteredItemStackSet) { - String itemDisplayName = itemStack.getDisplayName().toLowerCase(); + Set filteredSet = (comparator != null ? new TreeSet<>(comparator) + : new TreeSet<>(Comparators.DISPLAY_NAME_COMPARATOR)); - if (filterString != null) { - if (itemDisplayName.startsWith(filterString.toLowerCase())) { - nameSortedSet.add(itemStack); - } + if (itemStacks != null) { + if (filterString == null || filterString.isEmpty()) { + filteredSet.addAll(itemStacks); } else { - nameSortedSet.add(itemStack); - } - } - - return nameSortedSet; - } + for (ItemStack itemStack : itemStacks) { - public static Set filterByNameContains(Collection unfilteredCollection, String filterString) { - Set nameSortedSet = new HashSet(); + String itemDisplayName = itemStack.getDisplayName().toLowerCase(); - for (ItemStack itemStack : unfilteredCollection) { - String itemDisplayName = itemStack.getDisplayName().toLowerCase(); - - if (filterString != null) { - if (itemDisplayName.contains(filterString.toLowerCase())) { - nameSortedSet.add(itemStack); + if (filterType == NameFilterType.STARTS_WITH + && itemDisplayName.startsWith(filterString.toLowerCase())) { + filteredSet.add(itemStack); + } else if (filterType == NameFilterType.CONTAINS + && itemDisplayName.contains(filterString.toLowerCase())) { + filteredSet.add(itemStack); + } } - } else { - nameSortedSet.add(itemStack); } } - return nameSortedSet; + return filteredSet; } - public static Set filterByNameContains(Collection unfilteredCollection, String filterString, - Comparator comparator) { - Set nameSortedSet = new TreeSet(comparator); + public static Set filterByEnergyValue(Collection itemStacks, Number valueBound) { + return filterByEnergyValue( + itemStacks, + new EnergyValue(valueBound.floatValue()), + ValueFilterType.VALUE_LOWER_THAN_BOUND, + null); + } - for (ItemStack itemStack : unfilteredCollection) { - String itemDisplayName = itemStack.getDisplayName().toLowerCase(); + public static Set filterByEnergyValue(Collection itemStacks, EnergyValue valueBound) { + return filterByEnergyValue(itemStacks, valueBound, ValueFilterType.VALUE_LOWER_THAN_BOUND, null); + } - if (filterString != null) { - if (itemDisplayName.contains(filterString.toLowerCase())) { - nameSortedSet.add(itemStack); - } - } else { - nameSortedSet.add(itemStack); - } - } + public static Set filterByEnergyValue(Collection itemStacks, Number valueBound, + ValueFilterType filterType) { + return filterByEnergyValue(itemStacks, new EnergyValue(valueBound.floatValue()), filterType, null); + } - return nameSortedSet; + public static Set filterByEnergyValue(Collection itemStacks, EnergyValue valueBound, + ValueFilterType filterType) { + return filterByEnergyValue(itemStacks, valueBound, filterType, null); } - public static Set filterByEnergyValue(Collection unfilteredCollection, - EnergyValue energyValue) { - return filterByEnergyValue(unfilteredCollection, energyValue.getValue()); + public static Set filterByEnergyValue(Collection itemStacks, Number valueBound, + ValueFilterType filterType, Comparator comparator) { + return filterByEnergyValue( + EnergyValueRegistry.INSTANCE.getEnergyValues(), + itemStacks, + new EnergyValue(valueBound.floatValue()), + filterType, + comparator); } - public static Set filterByEnergyValue(Collection unfilteredCollection, - EnergyValue energyValue, Comparator comparator) { - return filterByEnergyValue(unfilteredCollection, energyValue.getValue(), comparator); + public static Set filterByEnergyValue(Collection itemStacks, EnergyValue valueBound, + ValueFilterType filterType, Comparator comparator) { + return filterByEnergyValue( + EnergyValueRegistry.INSTANCE.getEnergyValues(), + itemStacks, + valueBound, + filterType, + comparator); } - public static Set filterByEnergyValue(Collection unfilteredCollection, float energyValue) { - Set sortedSet = new HashSet(); + public static Set filterByEnergyValue(Map valueMap, + Collection itemStacks, EnergyValue valueBound, ValueFilterType filterType, + Comparator comparator) { + + Set filteredSet = (comparator != null ? new TreeSet<>(comparator) + : new TreeSet<>(Comparators.DISPLAY_NAME_COMPARATOR)); - for (ItemStack itemStack : unfilteredCollection) { - if (energyValue > 0f && EnergyValueRegistryProxy.hasEnergyValue(itemStack)) { - if (EnergyValueRegistryProxy.getEnergyValue(itemStack).getValue() <= energyValue) { - sortedSet.add(itemStack); + if (itemStacks != null) { + + if (valueBound == null) { + filteredSet.addAll(itemStacks); + } else { + for (ItemStack itemStack : itemStacks) { + + EnergyValue energyValue = EnergyValueRegistry.INSTANCE.getEnergyValue(valueMap, itemStack, false); + + if (energyValue != null && Float.compare(energyValue.getValue(), 0) > 0) { + if (filterType == ValueFilterType.VALUE_LOWER_THAN_BOUND + && energyValue.compareTo(valueBound) <= 0) { + filteredSet.add(itemStack); + } else if (filterType == ValueFilterType.VALUE_GREATER_THAN_BOUND + && energyValue.compareTo(valueBound) >= 0) { + filteredSet.add(itemStack); + } + } } } } - return sortedSet; + return filteredSet; } - public static Set filterByEnergyValue(Collection unfilteredCollection, float energyValue, - Comparator comparator) { - Set sortedSet = new TreeSet(comparator); + public static Collection filterForItemStacks(Collection objects) { - for (ItemStack itemStack : unfilteredCollection) { - if (energyValue > 0f && EnergyValueRegistryProxy.hasEnergyValue(itemStack)) { - if (EnergyValueRegistryProxy.getEnergyValue(itemStack).getValue() <= energyValue) { - sortedSet.add(itemStack); - } + Set itemStacks = new TreeSet<>(Comparators.ID_COMPARATOR); + + for (Object object : objects) { + if (object instanceof ItemStack) { + itemStacks.add((ItemStack) object); } } - return sortedSet; + return itemStacks; + } + + public enum NameFilterType { + STARTS_WITH, + CONTAINS + } + + public enum ValueFilterType { + VALUE_GREATER_THAN_BOUND, + VALUE_LOWER_THAN_BOUND } } diff --git a/src/main/java/com/pahimar/ee3/util/FluidHelper.java b/src/main/java/com/pahimar/ee3/util/FluidHelper.java index 58930304..2db52c28 100644 --- a/src/main/java/com/pahimar/ee3/util/FluidHelper.java +++ b/src/main/java/com/pahimar/ee3/util/FluidHelper.java @@ -13,50 +13,61 @@ public class FluidHelper { - public static Comparator comparator = new Comparator() { + public static final Comparator COMPARATOR = new Comparator() { + @Override public int compare(FluidStack fluidStack1, FluidStack fluidStack2) { - if (fluidStack1 != null) { - if (fluidStack2 != null) { - // if (fluidStack1.fluidID == fluidStack2.fluidID) - if (FluidRegistry.getFluidID(fluidStack1.getFluid()) - == FluidRegistry.getFluidID(fluidStack2.getFluid())) { - if (fluidStack1.amount == fluidStack2.amount) { - if (fluidStack1.tag != null) { - if (fluidStack2.tag != null) { - return (fluidStack1.tag.hashCode() - fluidStack2.tag.hashCode()); - } else { + if (fluidStack1 != null && fluidStack2 != null) { + if (fluidStack1.getFluid() != null && fluidStack2.getFluid() != null) { + if (FluidRegistry.getFluidName(fluidStack1) != null + && FluidRegistry.getFluidName(fluidStack2) != null) { + if (FluidRegistry.getFluidName(fluidStack1) + .equalsIgnoreCase(FluidRegistry.getFluidName(fluidStack2))) { + if (fluidStack1.amount == fluidStack2.amount) { + if (fluidStack1.tag != null && fluidStack2.tag != null) { + return fluidStack1.tag.hashCode() - fluidStack2.tag.hashCode(); + } else if (fluidStack1.tag != null) { return -1; - } - } else { - if (fluidStack2.tag != null) { + } else if (fluidStack2.tag != null) { return 1; } else { return 0; } + } else { + return fluidStack1.amount - fluidStack2.amount; } } else { - return (fluidStack1.amount - fluidStack2.amount); + return FluidRegistry.getFluidName(fluidStack1) + .compareToIgnoreCase(FluidRegistry.getFluidName(fluidStack2)); } + } else if (FluidRegistry.getFluidName(fluidStack1) != null) { + return -1; + } else if (FluidRegistry.getFluidName(fluidStack2) != null) { + return 1; } else { - return (FluidRegistry.getFluidID(fluidStack1.getFluid()) - - FluidRegistry.getFluidID(fluidStack2.getFluid())); + return 0; } - } else { + + } else if (fluidStack1.getFluid() != null) { return -1; - } - } else { - if (fluidStack2 != null) { + } else if (fluidStack2.getFluid() != null) { return 1; } else { return 0; } + } else if (fluidStack1 != null) { + return -1; + } else if (fluidStack2 != null) { + return 1; + } else { + return 0; } } }; public static void registerFluids() { + // Register Milk in the FluidRegistry if it hasn't already been done if (!FluidRegistry.isFluidRegistered("milk")) { Fluid milk = new Fluid("milk").setUnlocalizedName(Names.Fluids.MILK); @@ -70,10 +81,11 @@ public static void registerFluids() { } public static int compare(FluidStack fluidStack1, FluidStack fluidStack2) { - return comparator.compare(fluidStack1, fluidStack2); + return COMPARATOR.compare(fluidStack1, fluidStack2); } public static String toString(FluidStack fluidStack) { + if (fluidStack != null) { return String.format("%sxfluidStack.%s", fluidStack.amount, fluidStack.getFluid().getName()); } diff --git a/src/main/java/com/pahimar/ee3/util/ItemHelper.java b/src/main/java/com/pahimar/ee3/util/ItemHelper.java deleted file mode 100644 index 6f068135..00000000 --- a/src/main/java/com/pahimar/ee3/util/ItemHelper.java +++ /dev/null @@ -1,134 +0,0 @@ -package com.pahimar.ee3.util; - -import java.util.UUID; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -import com.pahimar.ee3.reference.Comparators; -import com.pahimar.ee3.reference.Names; - -public class ItemHelper { - - public static ItemStack cloneItemStack(ItemStack itemStack, int stackSize) { - ItemStack clonedItemStack = itemStack.copy(); - clonedItemStack.stackSize = stackSize; - return clonedItemStack; - } - - /** - * Compares two ItemStacks for equality, testing itemID, metaData, stackSize, and their NBTTagCompounds (if they are - * present) - * - * @param first The first ItemStack being tested for equality - * @param second The second ItemStack being tested for equality - * @return true if the two ItemStacks are equivalent, false otherwise - */ - public static boolean equals(ItemStack first, ItemStack second) { - return (Comparators.idComparator.compare(first, second) == 0); - } - - public static boolean equalsIgnoreStackSize(ItemStack itemStack1, ItemStack itemStack2) { - if (itemStack1 != null && itemStack2 != null) { - // Sort on itemID - if (Item.getIdFromItem(itemStack1.getItem()) - Item.getIdFromItem(itemStack2.getItem()) == 0) { - // Sort on item - if (itemStack1.getItem() == itemStack2.getItem()) { - // Then sort on meta - if (itemStack1.getItemDamage() == itemStack2.getItemDamage()) { - // Then sort on NBT - if (itemStack1.hasTagCompound() && itemStack2.hasTagCompound()) { - // Then sort on stack size - if (ItemStack.areItemStackTagsEqual(itemStack1, itemStack2)) { - return true; - } - } else if (!itemStack1.hasTagCompound() && !itemStack2.hasTagCompound()) { - return true; - } - } - } - } - } - - return false; - } - - public static int compare(ItemStack itemStack1, ItemStack itemStack2) { - return Comparators.idComparator.compare(itemStack1, itemStack2); - } - - public static String toString(ItemStack itemStack) { - if (itemStack != null) { - if (itemStack.hasTagCompound()) { - return String.format( - "%sxitemStack[%s@%s:%s]", - itemStack.stackSize, - itemStack.getUnlocalizedName(), - itemStack.getItemDamage(), - itemStack.getTagCompound()); - } else { - return String.format( - "%sxitemStack[%s@%s]", - itemStack.stackSize, - itemStack.getUnlocalizedName(), - itemStack.getItemDamage()); - } - } - - return "null"; - } - - public static boolean hasOwner(ItemStack itemStack) { - return (NBTHelper.hasTag(itemStack, Names.NBT.OWNER_UUID_MOST_SIG) - && NBTHelper.hasTag(itemStack, Names.NBT.OWNER_UUID_LEAST_SIG)) - || NBTHelper.hasTag(itemStack, Names.NBT.OWNER); - } - - public static boolean hasOwnerUUID(ItemStack itemStack) { - return NBTHelper.hasTag(itemStack, Names.NBT.OWNER_UUID_MOST_SIG) - && NBTHelper.hasTag(itemStack, Names.NBT.OWNER_UUID_LEAST_SIG); - } - - public static boolean hasOwnerName(ItemStack itemStack) { - return NBTHelper.hasTag(itemStack, Names.NBT.OWNER); - } - - public static String getOwnerName(ItemStack itemStack) { - if (NBTHelper.hasTag(itemStack, Names.NBT.OWNER)) { - return NBTHelper.getString(itemStack, Names.NBT.OWNER); - } - - return null; - } - - public static UUID getOwnerUUID(ItemStack itemStack) { - if (NBTHelper.hasTag(itemStack, Names.NBT.OWNER_UUID_MOST_SIG) - && NBTHelper.hasTag(itemStack, Names.NBT.OWNER_UUID_LEAST_SIG)) { - return new UUID( - NBTHelper.getLong(itemStack, Names.NBT.OWNER_UUID_MOST_SIG), - NBTHelper.getLong(itemStack, Names.NBT.OWNER_UUID_LEAST_SIG)); - } - - return null; - } - - public static void setOwner(ItemStack itemStack, EntityPlayer entityPlayer) { - setOwnerName(itemStack, entityPlayer); - setOwnerUUID(itemStack, entityPlayer); - } - - public static void setOwnerUUID(ItemStack itemStack, EntityPlayer entityPlayer) { - NBTHelper - .setLong(itemStack, Names.NBT.OWNER_UUID_MOST_SIG, entityPlayer.getUniqueID().getMostSignificantBits()); - NBTHelper.setLong( - itemStack, - Names.NBT.OWNER_UUID_LEAST_SIG, - entityPlayer.getUniqueID().getLeastSignificantBits()); - } - - public static void setOwnerName(ItemStack itemStack, EntityPlayer entityPlayer) { - NBTHelper.setString(itemStack, Names.NBT.OWNER, entityPlayer.getDisplayName()); - } - -} diff --git a/src/main/java/com/pahimar/ee3/util/NBTHelper.java b/src/main/java/com/pahimar/ee3/util/NBTHelper.java index c19c0350..4b568f18 100644 --- a/src/main/java/com/pahimar/ee3/util/NBTHelper.java +++ b/src/main/java/com/pahimar/ee3/util/NBTHelper.java @@ -3,226 +3,273 @@ import java.util.UUID; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; +import net.minecraft.nbt.*; import com.pahimar.ee3.reference.Names; public class NBTHelper { public static void clearStatefulNBTTags(ItemStack itemStack) { - if (NBTHelper.hasTag(itemStack, Names.NBT.CRAFTING_GUI_OPEN)) { + + if (NBTHelper.hasKey(itemStack, Names.NBT.CRAFTING_GUI_OPEN)) { NBTHelper.removeTag(itemStack, Names.NBT.CRAFTING_GUI_OPEN); - } else if (NBTHelper.hasTag(itemStack, Names.NBT.TRANSMUTATION_GUI_OPEN)) { + } else if (NBTHelper.hasKey(itemStack, Names.NBT.TRANSMUTATION_GUI_OPEN)) { NBTHelper.removeTag(itemStack, Names.NBT.TRANSMUTATION_GUI_OPEN); - } else if (NBTHelper.hasTag(itemStack, Names.NBT.ALCHEMICAL_BAG_GUI_OPEN)) { + } else if (NBTHelper.hasKey(itemStack, Names.NBT.ALCHEMICAL_BAG_GUI_OPEN)) { NBTHelper.removeTag(itemStack, Names.NBT.ALCHEMICAL_BAG_GUI_OPEN); } } - public static boolean hasTag(ItemStack itemStack, String keyName) { + public static boolean hasKey(ItemStack itemStack, String keyName) { return itemStack != null && itemStack.stackTagCompound != null && itemStack.stackTagCompound.hasKey(keyName); } public static void removeTag(ItemStack itemStack, String keyName) { - if (itemStack.stackTagCompound != null) { + + if (itemStack != null && itemStack.stackTagCompound != null && keyName != null && !keyName.isEmpty()) { itemStack.stackTagCompound.removeTag(keyName); } } public static boolean hasUUID(ItemStack itemStack) { - return hasTag(itemStack, Names.NBT.UUID_MOST_SIG) && hasTag(itemStack, Names.NBT.UUID_LEAST_SIG); + return getLong(itemStack, Names.NBT.UUID_MOST_SIG) != null + && getLong(itemStack, Names.NBT.UUID_LEAST_SIG) != null; } - public static void setUUID(ItemStack itemStack) { - initNBTTagCompound(itemStack); + public static UUID getUUID(ItemStack itemStack) { - // Set a UUID on the Alchemical Bag, if one doesn't exist already - if (!hasTag(itemStack, Names.NBT.UUID_MOST_SIG) && !hasTag(itemStack, Names.NBT.UUID_LEAST_SIG)) { - UUID itemUUID = UUID.randomUUID(); - setLong(itemStack, Names.NBT.UUID_MOST_SIG, itemUUID.getMostSignificantBits()); - setLong(itemStack, Names.NBT.UUID_LEAST_SIG, itemUUID.getLeastSignificantBits()); + if (hasUUID(itemStack)) { + return new UUID(getLong(itemStack, Names.NBT.UUID_MOST_SIG), getLong(itemStack, Names.NBT.UUID_LEAST_SIG)); + } + + return null; + } + + public static void setUUID(ItemStack itemStack, UUID uuid) { + + if (itemStack != null) { + + initNBTTagCompound(itemStack); + + if (uuid == null) { + uuid = UUID.randomUUID(); + } + + setLong(itemStack, Names.NBT.UUID_MOST_SIG, uuid.getMostSignificantBits()); + setLong(itemStack, Names.NBT.UUID_LEAST_SIG, uuid.getLeastSignificantBits()); } } /** - * Initializes the NBT Tag Compound for the given ItemStack if it is null + * Initializes the NBT Tag Compound for the given ItemStack * * @param itemStack The ItemStack for which its NBT Tag Compound is being checked for initialization */ private static void initNBTTagCompound(ItemStack itemStack) { - if (itemStack.stackTagCompound == null) { + + if (itemStack != null && itemStack.stackTagCompound == null) { itemStack.setTagCompound(new NBTTagCompound()); } } - public static void setLong(ItemStack itemStack, String keyName, long keyValue) { - initNBTTagCompound(itemStack); - - itemStack.stackTagCompound.setLong(keyName, keyValue); - } - // String public static String getString(ItemStack itemStack, String keyName) { - initNBTTagCompound(itemStack); - if (!itemStack.stackTagCompound.hasKey(keyName)) { - setString(itemStack, keyName, ""); + if (hasKey(itemStack, keyName)) { + if (itemStack.getTagCompound().getTag(keyName) instanceof NBTTagString) { + return itemStack.stackTagCompound.getString(keyName); + } } - return itemStack.stackTagCompound.getString(keyName); + return null; } public static void setString(ItemStack itemStack, String keyName, String keyValue) { - initNBTTagCompound(itemStack); - itemStack.stackTagCompound.setString(keyName, keyValue); + if (itemStack != null && keyName != null && !keyName.isEmpty()) { + initNBTTagCompound(itemStack); + itemStack.stackTagCompound.setString(keyName, keyValue); + } } // boolean - public static boolean getBoolean(ItemStack itemStack, String keyName) { - initNBTTagCompound(itemStack); + public static Boolean getBoolean(ItemStack itemStack, String keyName) { - if (!itemStack.stackTagCompound.hasKey(keyName)) { - setBoolean(itemStack, keyName, false); + if (hasKey(itemStack, keyName)) { + if (itemStack.getTagCompound().getTag(keyName) instanceof NBTTagByte) { + itemStack.stackTagCompound.getBoolean(keyName); + } } - return itemStack.stackTagCompound.getBoolean(keyName); + return null; } public static void setBoolean(ItemStack itemStack, String keyName, boolean keyValue) { - initNBTTagCompound(itemStack); - itemStack.stackTagCompound.setBoolean(keyName, keyValue); + if (itemStack != null && keyName != null && !keyName.isEmpty()) { + initNBTTagCompound(itemStack); + itemStack.stackTagCompound.setBoolean(keyName, keyValue); + } } // byte - public static byte getByte(ItemStack itemStack, String keyName) { - initNBTTagCompound(itemStack); + public static Byte getByte(ItemStack itemStack, String keyName) { - if (!itemStack.stackTagCompound.hasKey(keyName)) { - setByte(itemStack, keyName, (byte) 0); + if (hasKey(itemStack, keyName)) { + if (itemStack.getTagCompound().getTag(keyName) instanceof NBTTagByte) { + return itemStack.stackTagCompound.getByte(keyName); + } } - return itemStack.stackTagCompound.getByte(keyName); + return null; } public static void setByte(ItemStack itemStack, String keyName, byte keyValue) { - initNBTTagCompound(itemStack); - itemStack.stackTagCompound.setByte(keyName, keyValue); + if (itemStack != null && keyName != null && !keyName.isEmpty()) { + initNBTTagCompound(itemStack); + itemStack.stackTagCompound.setByte(keyName, keyValue); + } } // short - public static short getShort(ItemStack itemStack, String keyName) { - initNBTTagCompound(itemStack); + public static Short getShort(ItemStack itemStack, String keyName) { - if (!itemStack.stackTagCompound.hasKey(keyName)) { - setShort(itemStack, keyName, (short) 0); + if (hasKey(itemStack, keyName)) { + if (itemStack.getTagCompound().getTag(keyName) instanceof NBTTagShort) { + return itemStack.stackTagCompound.getShort(keyName); + } } - return itemStack.stackTagCompound.getShort(keyName); + return null; } public static void setShort(ItemStack itemStack, String keyName, short keyValue) { - initNBTTagCompound(itemStack); - itemStack.stackTagCompound.setShort(keyName, keyValue); + if (itemStack != null && keyName != null && !keyName.isEmpty()) { + initNBTTagCompound(itemStack); + itemStack.stackTagCompound.setShort(keyName, keyValue); + } } // int - public static int getInt(ItemStack itemStack, String keyName) { - initNBTTagCompound(itemStack); + public static Integer getInteger(ItemStack itemStack, String keyName) { - if (!itemStack.stackTagCompound.hasKey(keyName)) { - setInteger(itemStack, keyName, 0); + if (hasKey(itemStack, keyName)) { + if (itemStack.getTagCompound().getTag(keyName) instanceof NBTTagInt) { + return itemStack.stackTagCompound.getInteger(keyName); + } } - return itemStack.stackTagCompound.getInteger(keyName); + return null; } public static void setInteger(ItemStack itemStack, String keyName, int keyValue) { - initNBTTagCompound(itemStack); - itemStack.stackTagCompound.setInteger(keyName, keyValue); + if (itemStack != null && keyName != null && !keyName.isEmpty()) { + initNBTTagCompound(itemStack); + itemStack.stackTagCompound.setInteger(keyName, keyValue); + } } // long - public static long getLong(ItemStack itemStack, String keyName) { - initNBTTagCompound(itemStack); + public static Long getLong(ItemStack itemStack, String keyName) { - if (!itemStack.stackTagCompound.hasKey(keyName)) { - setLong(itemStack, keyName, 0); + if (hasKey(itemStack, keyName)) { + if (itemStack.getTagCompound().getTag(keyName) instanceof NBTTagLong) { + return itemStack.stackTagCompound.getLong(keyName); + } } - return itemStack.stackTagCompound.getLong(keyName); + return null; + } + + public static void setLong(ItemStack itemStack, String keyName, long keyValue) { + + if (itemStack != null && keyName != null && !keyName.isEmpty()) { + + initNBTTagCompound(itemStack); + itemStack.stackTagCompound.setLong(keyName, keyValue); + } } // float - public static float getFloat(ItemStack itemStack, String keyName) { - initNBTTagCompound(itemStack); + public static Float getFloat(ItemStack itemStack, String keyName) { - if (!itemStack.stackTagCompound.hasKey(keyName)) { - setFloat(itemStack, keyName, 0); + if (hasKey(itemStack, keyName)) { + if (itemStack.getTagCompound().getTag(keyName) instanceof NBTTagFloat) { + return itemStack.stackTagCompound.getFloat(keyName); + } } - return itemStack.stackTagCompound.getFloat(keyName); + return null; } public static void setFloat(ItemStack itemStack, String keyName, float keyValue) { - initNBTTagCompound(itemStack); - itemStack.stackTagCompound.setFloat(keyName, keyValue); + if (itemStack != null && keyName != null && !keyName.isEmpty()) { + initNBTTagCompound(itemStack); + itemStack.stackTagCompound.setFloat(keyName, keyValue); + } } // double - public static double getDouble(ItemStack itemStack, String keyName) { - initNBTTagCompound(itemStack); + public static Double getDouble(ItemStack itemStack, String keyName) { - if (!itemStack.stackTagCompound.hasKey(keyName)) { - setDouble(itemStack, keyName, 0); + if (hasKey(itemStack, keyName)) { + if (itemStack.getTagCompound().getTag(keyName) instanceof NBTTagDouble) { + return itemStack.stackTagCompound.getDouble(keyName); + } } - return itemStack.stackTagCompound.getDouble(keyName); + return null; } public static void setDouble(ItemStack itemStack, String keyName, double keyValue) { - initNBTTagCompound(itemStack); - itemStack.stackTagCompound.setDouble(keyName, keyValue); + if (itemStack != null && keyName != null && !keyName.isEmpty()) { + initNBTTagCompound(itemStack); + itemStack.stackTagCompound.setDouble(keyName, keyValue); + } } // tag list public static NBTTagList getTagList(ItemStack itemStack, String keyName, int nbtBaseType) { - initNBTTagCompound(itemStack); - if (!itemStack.stackTagCompound.hasKey(keyName)) { - setTagList(itemStack, keyName, new NBTTagList()); + if (hasKey(itemStack, keyName)) { + if (itemStack.getTagCompound().getTag(keyName) instanceof NBTTagList) { + return itemStack.stackTagCompound.getTagList(keyName, nbtBaseType); + } } - return itemStack.stackTagCompound.getTagList(keyName, nbtBaseType); + return null; } public static void setTagList(ItemStack itemStack, String keyName, NBTTagList nbtTagList) { - initNBTTagCompound(itemStack); - itemStack.stackTagCompound.setTag(keyName, nbtTagList); + if (itemStack != null && keyName != null && !keyName.isEmpty()) { + initNBTTagCompound(itemStack); + itemStack.stackTagCompound.setTag(keyName, nbtTagList); + } } // tag compound public static NBTTagCompound getTagCompound(ItemStack itemStack, String keyName) { - initNBTTagCompound(itemStack); - if (!itemStack.stackTagCompound.hasKey(keyName)) { - setTagCompound(itemStack, keyName, new NBTTagCompound()); + if (hasKey(itemStack, keyName)) { + if (itemStack.getTagCompound().getTag(keyName) instanceof NBTTagCompound) { + return itemStack.stackTagCompound.getCompoundTag(keyName); + } } - return itemStack.stackTagCompound.getCompoundTag(keyName); + return null; } public static void setTagCompound(ItemStack itemStack, String keyName, NBTTagCompound nbtTagCompound) { - initNBTTagCompound(itemStack); - itemStack.stackTagCompound.setTag(keyName, nbtTagCompound); + if (itemStack != null && keyName != null && !keyName.isEmpty()) { + initNBTTagCompound(itemStack); + itemStack.stackTagCompound.setTag(keyName, nbtTagCompound); + } } } diff --git a/src/main/java/com/pahimar/ee3/util/RecipeHelper.java b/src/main/java/com/pahimar/ee3/util/RecipeHelper.java index af186d80..de5d8e41 100644 --- a/src/main/java/com/pahimar/ee3/util/RecipeHelper.java +++ b/src/main/java/com/pahimar/ee3/util/RecipeHelper.java @@ -137,7 +137,7 @@ public static List collateInputStacks(List uncollatedStacks) { if (collatedStack.getWrappedObject() != null) { if (stack.getWrappedObject() instanceof ItemStack && collatedStack.getWrappedObject() instanceof ItemStack) { - if (ItemHelper.equals( + if (ItemStackUtils.equals( (ItemStack) stack.getWrappedObject(), (ItemStack) collatedStack.getWrappedObject())) { collatedStack.setStackSize(collatedStack.getStackSize() + stack.getStackSize()); @@ -174,6 +174,7 @@ public static List collateInputStacks(List uncollatedStacks) { * @param objects a list of recipe inputs for an OreDictionary recipe * @return true if there exists no "invalid" (empty) OreDictionary entries in the provided list of recipe inputs */ + // FIXME This is not working as intended private static boolean validateOreDictionaryRecipe(List objects) { for (Object object : objects) { if (object != null) { diff --git a/src/main/java/com/pahimar/ee3/util/SerializationHelper.java b/src/main/java/com/pahimar/ee3/util/SerializationHelper.java index 993775ba..acd175c4 100644 --- a/src/main/java/com/pahimar/ee3/util/SerializationHelper.java +++ b/src/main/java/com/pahimar/ee3/util/SerializationHelper.java @@ -1,29 +1,39 @@ package com.pahimar.ee3.util; import java.io.*; -import java.util.*; - -import net.minecraft.nbt.CompressedStreamTools; -import net.minecraft.nbt.NBTTagCompound; - -import org.apache.commons.codec.digest.DigestUtils; - -import com.google.common.io.Files; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; +import java.lang.reflect.Type; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; +import java.util.TreeSet; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import com.google.common.reflect.TypeToken; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; import com.pahimar.ee3.api.exchange.EnergyValue; -import com.pahimar.ee3.exchange.EnergyValueRegistry; -import com.pahimar.ee3.exchange.EnergyValueStackMapping; +import com.pahimar.ee3.exchange.OreStack; import com.pahimar.ee3.exchange.WrappedStack; -import com.pahimar.ee3.knowledge.TransmutationKnowledge; +import com.pahimar.ee3.knowledge.PlayerKnowledge; import com.pahimar.ee3.reference.Reference; - +import com.pahimar.ee3.util.serialize.*; import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.ModContainer; public class SerializationHelper { + public static final Type ENERGY_VALUE_MAP_TYPE = new TypeToken>() {}.getType(); + public static final Type WRAPPED_STACK_SET_TYPE = new TypeToken>() {}.getType(); + public static final Gson GSON = new GsonBuilder().setPrettyPrinting().enableComplexMapKeySerialization() + .registerTypeAdapter(ItemStack.class, new ItemStackSerializer()) + .registerTypeAdapter(OreStack.class, new OreStackSerializer()) + .registerTypeAdapter(FluidStack.class, new FluidStackSerializer()) + .registerTypeAdapter(WrappedStack.class, new WrappedStackSerializer()) + .registerTypeAdapter(PlayerKnowledge.class, new PlayerKnowledgeSerializer()) + .registerTypeAdapter(ENERGY_VALUE_MAP_TYPE, new EnergyValueMapSerializer()).create(); + private static File instanceDataDirectory; private static File instancePlayerDataDirectory; @@ -32,24 +42,19 @@ public class SerializationHelper { * * @return */ + @Deprecated public static File getInstanceDataDirectory() { return instanceDataDirectory; } /** - * Returns a File reference to the mod specific directory in the playerdata directory + * TODO Move this to {@link com.pahimar.ee3.reference.Files} * - * @return - */ - public static File getInstancePlayerDataDirectory() { - return instancePlayerDataDirectory; - } - - /** * Creates (if one does not exist already) and initializes a mod specific File reference inside of the current * world's playerdata directory */ public static void initModDataDirectories() { + instanceDataDirectory = new File( FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getSaveHandler() .getWorldDirectory(), @@ -63,247 +68,92 @@ public static void initModDataDirectories() { instancePlayerDataDirectory.mkdirs(); } - public static String getModListMD5() { - List modList = new ArrayList(); + public static Set readSetFromFile(File file) { - for (ModContainer modContainer : Loader.instance().getModList()) { - modList.add( - "[" + modContainer - .getModId() + "-" + modContainer.getName() + "-" + modContainer.getVersion() + "]"); - } + Set wrappedStackSet = new TreeSet<>(); - Collections.sort(modList); - - StringBuilder modListString = new StringBuilder(); - for (String modEntry : modList) { - modListString.append(modEntry); - } - - return DigestUtils.md5Hex(modListString.toString()); - } - - public static NBTTagCompound readNBTFromFile(File nbtEncodedFile) { - if (nbtEncodedFile.exists() && nbtEncodedFile.isFile()) { - try { - return CompressedStreamTools.readCompressed(new FileInputStream(nbtEncodedFile)); - } catch (IOException e) { - e.printStackTrace(); - } + try { + wrappedStackSet = GSON.fromJson(readJsonFile(file), WRAPPED_STACK_SET_TYPE); + } catch (JsonParseException exception) { + LogHelper.error("Unable to parse contents from file '{}'", file.getAbsoluteFile()); + } catch (FileNotFoundException e) { + LogHelper.warn("Unable to find file '{}'", file.getAbsoluteFile()); } - return null; + return wrappedStackSet; } - public static void writeNBTToFile(File directory, String fileName, INBTTaggable nbtTaggable) { - writeNBTToFile(directory, fileName, nbtTaggable, false); + public static void writeSetToFile(Set wrappedStackSet, File file) { + writeJsonFile(file, GSON.toJson(wrappedStackSet)); } - public static void writeNBTToFile(File directory, String fileName, INBTTaggable nbtTaggable, - boolean verboseLogging) { - if (directory != null && fileName != null && nbtTaggable != null) { - if (!directory.exists()) { - directory.mkdirs(); - } - - NBTTagCompound nbtTagCompound = new NBTTagCompound(); - nbtTaggable.writeToNBT(nbtTagCompound); - - try { - File file1 = new File(directory, fileName + ".tmp"); - File file2 = new File(directory, fileName); - CompressedStreamTools.writeCompressed(nbtTagCompound, new FileOutputStream(file1)); + public static Map readMapFromFile(File file) throws FileNotFoundException { - if (file2.exists()) { - file2.delete(); - } - - file1.renameTo(file2); - - if (verboseLogging) { - LogHelper.info( - "Successfully saved {} to file: {}", - nbtTaggable.getTagLabel(), - file2.getAbsolutePath()); - } - } catch (Exception exception) { - LogHelper.warn( - "Failed to save {} to file: {}{}{}", - nbtTaggable.getTagLabel(), - directory.getAbsolutePath(), - File.separator, - fileName); - exception.printStackTrace(); - } - } - } + Map valueMap = new TreeMap<>(); - public static TransmutationKnowledge readTransmutationKnowledgeFromFile(File directory, String fileName) { - if (!directory.exists()) { - directory.mkdirs(); + try { + valueMap = GSON.fromJson(readJsonFile(file), ENERGY_VALUE_MAP_TYPE); + } catch (JsonParseException exception) { + // TODO Better logging of the exception (failed parsing so no values loaded) } - return TransmutationKnowledge.readFromFile(new File(directory, fileName)); + return valueMap; } - public static void writeTransmutationKnowledgeToFile(File directory, String fileName, - TransmutationKnowledge transmutationKnowledge) { - writeTransmutationKnowledgeToFile(directory, fileName, transmutationKnowledge, false); + public static void writeMapToFile(Map valueMap, File file) { + writeJsonFile(file, GSON.toJson(valueMap, ENERGY_VALUE_MAP_TYPE)); } - public static void writeTransmutationKnowledgeToFile(File directory, String fileName, - TransmutationKnowledge transmutationKnowledge, boolean verboseLogging) { - if (directory != null && fileName != null) { - if (!directory.exists()) { - directory.mkdirs(); - } + public static String readJsonFile(File file) throws FileNotFoundException { - if (transmutationKnowledge == null) { - transmutationKnowledge = new TransmutationKnowledge(); - } - - try { - File file1 = new File(directory, fileName + ".tmp"); - File file2 = new File(directory, fileName); - TransmutationKnowledge.writeToFile(file1, transmutationKnowledge); + StringBuilder jsonStringBuilder = new StringBuilder(); + if (file != null) { + try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) { - if (file2.exists()) { - file2.delete(); + jsonStringBuilder = new StringBuilder(); + String line; + while ((line = bufferedReader.readLine()) != null) { + jsonStringBuilder.append(line); } - - file1.renameTo(file2); - - if (verboseLogging) { - LogHelper.info("Successfully saved TransmutationKnowledge to file: {}", file2.getAbsolutePath()); + } catch (IOException exception) { + if (exception instanceof FileNotFoundException) { + throw (FileNotFoundException) exception; + } else { + exception.printStackTrace(); // TODO Better logging of the exception } - } catch (Exception exception) { - exception.printStackTrace(); - LogHelper.error( - "Failed to save TransmutationKnowledge to file: {}{}", - directory.getAbsolutePath(), - fileName); } } + return jsonStringBuilder.toString(); } - public static Map readEnergyValueStackMapFromJsonFile(String fileName) { - File energyValuesDataDirectory = new File( - FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getSaveHandler() - .getWorldDirectory(), - "data" + File.separator + Reference.LOWERCASE_MOD_ID + File.separator + "energyvalues"); - return readEnergyValueStackMapFromJsonFile(new File(energyValuesDataDirectory, fileName)); - } - - public static Map readEnergyValueStackMapFromJsonFile(File jsonFile) { - Map energyValueStackMap = new TreeMap(); - JsonReader jsonReader; - - try { - jsonReader = new JsonReader(new FileReader(jsonFile)); - jsonReader.beginArray(); - while (jsonReader.hasNext()) { - EnergyValueStackMapping energyValueStackMapping = EnergyValueStackMapping.jsonSerializer - .fromJson(jsonReader, EnergyValueStackMapping.class); - if (energyValueStackMapping != null) { - energyValueStackMap.put(energyValueStackMapping.wrappedStack, energyValueStackMapping.energyValue); - } - } - jsonReader.endArray(); - jsonReader.close(); - } catch (FileNotFoundException ignored) {} catch (IOException e) { - e.printStackTrace(); - } + public static void writeJsonFile(File file, String fileContents) { - return energyValueStackMap; - } - - public static void writeEnergyValueStackMapToJsonFile(String fileName, - Map energyValueMap) { - File energyValuesDataDirectory = new File( - FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getSaveHandler() - .getWorldDirectory(), - "data" + File.separator + Reference.LOWERCASE_MOD_ID + File.separator + "energyvalues"); - writeEnergyValueStackMapToJsonFile(new File(energyValuesDataDirectory, fileName), energyValueMap); - } + if (file != null) { - public static void writeEnergyValueStackMapToJsonFile(File jsonFile, - Map energyValueMap) { - JsonWriter jsonWriter; + file.getParentFile().mkdirs(); + File tempFile = new File(file.getAbsolutePath() + "_tmp"); - try { - jsonWriter = new JsonWriter(new FileWriter(jsonFile)); - jsonWriter.setIndent(" "); - jsonWriter.beginArray(); - for (WrappedStack wrappedStack : energyValueMap.keySet()) { - if (wrappedStack != null && wrappedStack.getWrappedObject() != null) { - EnergyValueStackMapping.jsonSerializer.toJson( - new EnergyValueStackMapping(wrappedStack, energyValueMap.get(wrappedStack)), - EnergyValueStackMapping.class, - jsonWriter); - } + if (tempFile.exists()) { + tempFile.delete(); } - jsonWriter.endArray(); - jsonWriter.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - public static void compressEnergyValueStackMapToFile(String fileName, - Map energyValueMap) { - File energyValuesDataDirectory = new File( - FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getSaveHandler() - .getWorldDirectory(), - "data" + File.separator + Reference.LOWERCASE_MOD_ID + File.separator + "energyvalues"); - compressEnergyValueStackMapToFile(new File(energyValuesDataDirectory, fileName), energyValueMap); - } - - public static void compressEnergyValueStackMapToFile(File file, Map energyValueMap) { - try { - byte[] energyValueRegistryArray = CompressionHelper - .compressStringToByteArray(EnergyValueRegistry.getInstance().toJson()); - FileOutputStream fos = new FileOutputStream(file); - fos.write(energyValueRegistryArray); - fos.close(); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - } + try (BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(tempFile))) { - public static Map decompressEnergyValueStackMapFromFile(String fileName) { - File energyValuesDataDirectory = new File( - FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getSaveHandler() - .getWorldDirectory(), - "data" + File.separator + Reference.LOWERCASE_MOD_ID + File.separator + "energyvalues"); - return decompressEnergyValueStackMapFromFile(new File(energyValuesDataDirectory, fileName)); - } + bufferedWriter.write(fileContents); + bufferedWriter.close(); + } catch (IOException exception) { + exception.printStackTrace(); // TODO Better logging of the exception + } - public static Map decompressEnergyValueStackMapFromFile(File file) { - Map energyValueStackMap = new TreeMap(); + if (file.exists()) { + file.delete(); + } - try { - String jsonEnergyValueStackMap = CompressionHelper.decompressStringFromByteArray(Files.toByteArray(file)); - JsonReader jsonReader = new JsonReader(new StringReader(jsonEnergyValueStackMap)); - jsonReader.beginArray(); - while (jsonReader.hasNext()) { - EnergyValueStackMapping energyValueStackMapping = EnergyValueStackMapping.jsonSerializer - .fromJson(jsonReader, EnergyValueStackMapping.class); - if (energyValueStackMapping != null) { - energyValueStackMap.put(energyValueStackMapping.wrappedStack, energyValueStackMapping.energyValue); - } + if (file.exists()) { + LogHelper.warn("Failed to delete " + file); + } else { + tempFile.renameTo(file); } - jsonReader.endArray(); - jsonReader.close(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); } - - return energyValueStackMap; } } diff --git a/src/main/resources/assets/ee3/lang/en_US.lang b/src/main/resources/assets/ee3/lang/en_US.lang index 4ab11adf..093f6e9e 100644 --- a/src/main/resources/assets/ee3/lang/en_US.lang +++ b/src/main/resources/assets/ee3/lang/en_US.lang @@ -1,15 +1,24 @@ -# Configuration -general.sync.threshold.label=Sync Threshold -general.sync.threshold.comment=The number of seconds a player must wait before they can sync their Energy Values with the server again - -general.sound.soundMode.label=Sounds -general.sound.soundMode.comment='All' plays mod sounds from all players, 'Self' only plays mod sounds from you, and 'None' plays no mod sounds - -general.abilities.onlyLoadFile.label=Only load Abilities file -general.abilities.onlyLoadFile.comment=Setting this to true means that Abilities are initially only loaded from file, rather than from both file and from other mods - -general.energyvalues.regenerateEnergyValuesWhen.label=Regenerate EnergyValues -general.energyvalues.regenerateEnergyValuesWhen.comment=When to regenerate EnergyValues. Options are "Always" (every time Minecraft starts), "When Mods Change" (when mods are added, removed, or updated) or "Never" (only generate the first time). +# Configuration (Energy Value Options) +energy_value=Energy Value Options +energy_value.regenerate_values_when.label=Regenerate Energy Values When +energy_value.regenerate_values_when.comment=When to regenerate energy values for objects. Options are "Always" (every time Minecraft starts) or "As Needed" (whenever the mod cannot the calculated energy values file). +energy_value.debug_logging_enabled.label=Enable Debug Logging +energy_value.debug_logging_enabled.comment=Additional debug logging for when energy values are calculated for objects + +# Configuration (Sound Options) +sound=Sound Options +sound.mode.label=Play Sounds Only From +sound.mode.comment='All' plays mod sounds from all players, 'Self' only plays mod sounds from you, and 'None' does not play any mod sounds + +# Configuration (Player Knowledge Options) +player_knowledge=Player Knowledge Options +player_knowledge.use_template.label=Use Knowledge Template +player_knowledge.use_template.comment=Whether or not to use the player knowledge template. The template allows players to start with some items already researched + +# Server Options +server=Server Options +server.sync_threshold.label=Sync Threshold +server.sync_threshold.comment=The number of seconds a player must wait before they can sync their energy values for objects with the server again # Keys key.categories.ee3=Equivalent Exchange 3 @@ -80,7 +89,7 @@ tile.ee3:alchemicalFuelBlock.alchemicalCoal.name=Block of Alchemical Coal tile.ee3:alchemicalFuelBlock.mobiusFuel.name=Block of Mobius Fuel tile.ee3:alchemicalFuelBlock.aeternalisFuel.name=Block of Aeternalis Fuel tile.ee3:aludel.name=Aludel Base -tile.ee3:calcinator.name=Calcinator +tile.ee3:calcinator.name=Calciner tile.ee3:chalk.name=Chalk tile.ee3:glassBell.name=Glass Bell tile.ee3:researchStation.name=Research Station @@ -119,9 +128,6 @@ container.ee3:alchenomicon.noTransmutationsKnown=No known transmutations container.ee3:transmutationAlchemyArray=Transmutation Square [WIP] # NEI -gui.nei.ee3:calcination=Calcination -gui.nei.ee3:calcination.tooltip.1=Energy values needed to calcine -gui.nei.ee3:calcination.tooltip.2=From %s to %s gui.nei.ee3:aludel=Aludel # Commands @@ -133,6 +139,9 @@ commands.ee3.set-energy-value.usage=/ee3 set-energy-value commands.ee3.set-energy-value-current-item.success=%s set a %s EnergyValue of %s to %s +commands.ee3.regen-energy-values.usage=/ee3 regen-energy-values +commands.ee3.regen-energy-values.success=Successfully recalculated energy values +commands.ee3.regen-energy-values.denied=Please wait %s more seconds and try again commands.ee3.sync-energy-values.usage=/ee3 sync-energy-values commands.ee3.sync-energy-values.success=Successfully synchronized energy values with the server commands.ee3.sync-energy-values.denied=Please wait %s more seconds and try again @@ -146,28 +155,30 @@ commands.ee3.player-forget-item.usage=/ee3 player-forget-item commands.ee3.player-forget-current-item.success=%s made %s forget how to transmute %s -commands.ee3.template-learn-item.usage=/ee3 template-learn-item [dataTag] -commands.ee3.template-learn-item.success=%s taught the knowledge template how to transmute %s -commands.ee3.template-learn-current-item.usage=/ee3 template-learn-current-item -commands.ee3.template-learn-current-item.success=%s taught the knowledge template how to transmute %s -commands.ee3.template-forget-everything.usage=/ee3 template-forget-everything -commands.ee3.template-forget-everything.success=%s made the knowledge template forget how to transmute everything -commands.ee3.template-forget-item.usage=/ee3 template-forget-item [dataTag] -commands.ee3.template-forget-item.success=%s made the knowledge template forget how to transmute %s -commands.ee3.template-forget-current-item.usage=/ee3 template-forget-current-item -commands.ee3.template-forget-current-item.success=%s made the knowledge template forget how to transmute %s commands.ee3.set-item-learnable.usage=/ee3 set-item-learnable [dataTag] commands.ee3.set-item-learnable.success=%s set %s as learnable for transmutations +commands.ee3.set-current-item-learnable.usage=/ee3 set-current-item-learnable +commands.ee3.set-current-item-learnable.success=%s set %s as learnable for transmutations +commands.ee3.set-current-item-learnable.no-effect=%s is already learnable commands.ee3.set-item-not-learnable.usage=/ee3 set-item-not-learnable [dataTag] commands.ee3.set-item-not-learnable.success=%s set %s as not learnable for transmutations +commands.ee3.set-current-item-not-learnable.usage=/ee3 set-current-item-not-learnable +commands.ee3.set-current-item-not-learnable.success=%s set %s as not learnable for transmutations +commands.ee3.set-current-item-not-learnable.no-effect=%s is already not learnable commands.ee3.set-item-recoverable.usage=/ee3 set-item-recoverable [dataTag] commands.ee3.set-item-recoverable.success=%s set %s as being able to have its energy value recovered +commands.ee3.set-current-item-recoverable.usage=/ee3 set-current-item-recoverable +commands.ee3.set-current-item-recoverable.success=%s set %s as being able to have its energy value recovered +commands.ee3.set-current-item-recoverable.no-effect=%s is already exchangeable commands.ee3.set-item-not-recoverable.usage=/ee3 set-item-not-recoverable [dataTag] commands.ee3.set-item-not-recoverable.success=%s set %s as not being able to have its energy value recovered +commands.ee3.set-current-item-not-recoverable.usage=/ee3 set-current-item-not-recoverable +commands.ee3.set-current-item-not-recoverable.success=%s set %s as not being able to have its energy value recovered +commands.ee3.set-current-item-not-recoverable.no-effect=%s is already not exchangeable commands.ee3.run-tests.usage=/ee3 run-tests commands.ee3.run-tests.success=Executed test file '%s', check server log for results commands.ee3.run-tests.notfound=Test file '%s' was not found! -commands.ee3.admin.usage=/ee3 admin +commands.ee3.run-tests.dir-notfound=Test directory was not found! # Tooltips tooltip.ee3:belongsTo=Belongs to %s diff --git a/src/main/resources/assets/ee3/textures/arrays/arrayAccelerant.png b/src/main/resources/assets/ee3/textures/arrays/arrayAccelerant.png deleted file mode 100644 index f907609f..00000000 Binary files a/src/main/resources/assets/ee3/textures/arrays/arrayAccelerant.png and /dev/null differ diff --git a/src/main/resources/assets/ee3/textures/arrays/arrayCombustion.png b/src/main/resources/assets/ee3/textures/arrays/arrayCombustion.png deleted file mode 100644 index f4976bc9..00000000 Binary files a/src/main/resources/assets/ee3/textures/arrays/arrayCombustion.png and /dev/null differ diff --git a/src/main/resources/assets/ee3/textures/arrays/arrayConstruction.png b/src/main/resources/assets/ee3/textures/arrays/arrayConstruction.png deleted file mode 100644 index ea94a600..00000000 Binary files a/src/main/resources/assets/ee3/textures/arrays/arrayConstruction.png and /dev/null differ diff --git a/src/main/resources/assets/ee3/textures/arrays/arrayConveyor.png b/src/main/resources/assets/ee3/textures/arrays/arrayConveyor.png deleted file mode 100644 index 310c32f4..00000000 Binary files a/src/main/resources/assets/ee3/textures/arrays/arrayConveyor.png and /dev/null differ diff --git a/src/main/resources/assets/ee3/textures/arrays/arrayDestruction.png b/src/main/resources/assets/ee3/textures/arrays/arrayDestruction.png deleted file mode 100644 index a987e5af..00000000 Binary files a/src/main/resources/assets/ee3/textures/arrays/arrayDestruction.png and /dev/null differ diff --git a/src/main/resources/assets/ee3/textures/arrays/arrayGelid.png b/src/main/resources/assets/ee3/textures/arrays/arrayGelid.png deleted file mode 100644 index 5159f4f9..00000000 Binary files a/src/main/resources/assets/ee3/textures/arrays/arrayGelid.png and /dev/null differ diff --git a/src/main/resources/assets/ee3/textures/arrays/arrayParthenogenesis.png b/src/main/resources/assets/ee3/textures/arrays/arrayParthenogenesis.png deleted file mode 100644 index 38386a1d..00000000 Binary files a/src/main/resources/assets/ee3/textures/arrays/arrayParthenogenesis.png and /dev/null differ diff --git a/src/main/resources/assets/ee3/textures/arrays/arrayTransfiguration.png b/src/main/resources/assets/ee3/textures/arrays/arrayTransfiguration.png deleted file mode 100644 index 6118a1cd..00000000 Binary files a/src/main/resources/assets/ee3/textures/arrays/arrayTransfiguration.png and /dev/null differ diff --git a/src/main/resources/assets/ee3/textures/arrays/arrayTransmutation.png b/src/main/resources/assets/ee3/textures/arrays/arrayTransmutation.png index 596571d2..0e441b5c 100644 Binary files a/src/main/resources/assets/ee3/textures/arrays/arrayTransmutation.png and b/src/main/resources/assets/ee3/textures/arrays/arrayTransmutation.png differ diff --git a/src/test/resources/minecraft-v1710-vanilla-test-suite.json b/src/test/resources/minecraft-v1710-vanilla-test-suite.json index 7ab89864..f47981bd 100644 --- a/src/test/resources/minecraft-v1710-vanilla-test-suite.json +++ b/src/test/resources/minecraft-v1710-vanilla-test-suite.json @@ -1,6613 +1,2931 @@ [ - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stone", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:grass", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:dirt", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:dirt", - "itemDamage": 2 - } - }, - "energyValue": { - "value": 1.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:cobblestone", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:planks", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 8.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:planks", - "itemDamage": 1 - } - }, - "energyValue": { - "value": 8.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:planks", - "itemDamage": 2 - } - }, - "energyValue": { - "value": 8.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:planks", - "itemDamage": 3 - } - }, - "energyValue": { - "value": 8.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:planks", - "itemDamage": 4 - } - }, - "energyValue": { - "value": 8.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:planks", - "itemDamage": 5 - } - }, - "energyValue": { - "value": 8.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:sapling", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:sapling", - "itemDamage": 1 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:sapling", - "itemDamage": 2 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:sapling", - "itemDamage": 3 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:sapling", - "itemDamage": 4 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:sapling", - "itemDamage": 5 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:bedrock", - "itemDamage": 0 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:sand", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:gravel", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 4.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:gold_ore", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 2048.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:iron_ore", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 256.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:coal_ore", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:log", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:log", - "itemDamage": 1 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:log", - "itemDamage": 2 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:log", - "itemDamage": 3 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:leaves", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:leaves", - "itemDamage": 1 - } - }, - "energyValue": { - "value": 1.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:leaves", - "itemDamage": 2 - } - }, - "energyValue": { - "value": 1.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:leaves", - "itemDamage": 3 - } - }, - "energyValue": { - "value": 1.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:sponge", - "itemDamage": 0 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:glass", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:lapis_ore", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 864.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:lapis_block", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 7776.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:dispenser", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 87.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:sandstone", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 4.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:sandstone", - "itemDamage": 1 - } - }, - "energyValue": { - "value": 4.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:sandstone", - "itemDamage": 2 - } - }, - "energyValue": { - "value": 4.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:noteblock", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 96.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:golden_rail", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 2054.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:detector_rail", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 261.667 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:sticky_piston", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 340.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:web", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 12.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:tallgrass", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:tallgrass", - "itemDamage": 1 - } - }, - "energyValue": { - "value": 1.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:deadbush", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:piston", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 316.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wool", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 48.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wool", - "itemDamage": 1 - } - }, - "energyValue": { - "value": 64.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wool", - "itemDamage": 2 - } - }, - "energyValue": { - "value": 64.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wool", - "itemDamage": 3 - } - }, - "energyValue": { - "value": 64.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wool", - "itemDamage": 4 - } - }, - "energyValue": { - "value": 64.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wool", - "itemDamage": 5 - } - }, - "energyValue": { - "value": 64.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wool", - "itemDamage": 6 - } - }, - "energyValue": { - "value": 64.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wool", - "itemDamage": 7 - } - }, - "energyValue": { - "value": 64.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wool", - "itemDamage": 8 - } - }, - "energyValue": { - "value": 64.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wool", - "itemDamage": 9 - } - }, - "energyValue": { - "value": 64.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wool", - "itemDamage": 10 - } - }, - "energyValue": { - "value": 64.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wool", - "itemDamage": 11 - } - }, - "energyValue": { - "value": 64.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wool", - "itemDamage": 12 - } - }, - "energyValue": { - "value": 64.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wool", - "itemDamage": 13 - } - }, - "energyValue": { - "value": 64.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wool", - "itemDamage": 14 - } - }, - "energyValue": { - "value": 64.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wool", - "itemDamage": 15 - } - }, - "energyValue": { - "value": 64.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:yellow_flower", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 16.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:red_flower", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 16.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:red_flower", - "itemDamage": 1 - } - }, - "energyValue": { - "value": 16.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:red_flower", - "itemDamage": 2 - } - }, - "energyValue": { - "value": 16.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:red_flower", - "itemDamage": 3 - } - }, - "energyValue": { - "value": 16.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:red_flower", - "itemDamage": 4 - } - }, - "energyValue": { - "value": 16.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:red_flower", - "itemDamage": 5 - } - }, - "energyValue": { - "value": 16.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:red_flower", - "itemDamage": 6 - } - }, - "energyValue": { - "value": 16.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:red_flower", - "itemDamage": 7 - } - }, - "energyValue": { - "value": 16.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:red_flower", - "itemDamage": 8 - } - }, - "energyValue": { - "value": 16.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:brown_mushroom", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:red_mushroom", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:gold_block", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 18432.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:iron_block", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 2304.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stone_slab", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 0.5 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stone_slab", - "itemDamage": 1 - } - }, - "energyValue": { - "value": 2.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stone_slab", - "itemDamage": 3 - } - }, - "energyValue": { - "value": 0.5 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stone_slab", - "itemDamage": 4 - } - }, - "energyValue": { - "value": 128.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stone_slab", - "itemDamage": 5 - } - }, - "energyValue": { - "value": 0.5 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stone_slab", - "itemDamage": 6 - } - }, - "energyValue": { - "value": 2.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stone_slab", - "itemDamage": 7 - } - }, - "energyValue": { - "value": 512.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:brick_block", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 256.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:tnt", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 964.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:bookshelf", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 528.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:mossy_cobblestone", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:obsidian", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 64.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:torch", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 9.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:oak_stairs", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 12.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:chest", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 64.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:diamond_ore", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 8192.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:diamond_block", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 73728.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:crafting_table", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:furnace", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 8.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:ladder", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 9.333 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:rail", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 96.25 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stone_stairs", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1.5 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:lever", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 5.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stone_pressure_plate", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 2.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wooden_pressure_plate", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 16.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:redstone_ore", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:redstone_torch", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 36.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stone_button", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:snow_layer", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 0.125 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:ice", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:snow", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:cactus", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 8.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:clay", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 256.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:jukebox", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 8256.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:fence", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 12.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:pumpkin", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 144.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:netherrack", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:soul_sand", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 49.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:glowstone", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1536.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:lit_pumpkin", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 153.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 3.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass", - "itemDamage": 1 - } - }, - "energyValue": { - "value": 3.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass", - "itemDamage": 2 - } - }, - "energyValue": { - "value": 3.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass", - "itemDamage": 3 - } - }, - "energyValue": { - "value": 3.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass", - "itemDamage": 4 - } - }, - "energyValue": { - "value": 3.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass", - "itemDamage": 5 - } - }, - "energyValue": { - "value": 3.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass", - "itemDamage": 6 - } - }, - "energyValue": { - "value": 3.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass", - "itemDamage": 7 - } - }, - "energyValue": { - "value": 3.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass", - "itemDamage": 8 - } - }, - "energyValue": { - "value": 3.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass", - "itemDamage": 9 - } - }, - "energyValue": { - "value": 3.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass", - "itemDamage": 10 - } - }, - "energyValue": { - "value": 3.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass", - "itemDamage": 11 - } - }, - "energyValue": { - "value": 3.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass", - "itemDamage": 12 - } - }, - "energyValue": { - "value": 3.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass", - "itemDamage": 13 - } - }, - "energyValue": { - "value": 3.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass", - "itemDamage": 14 - } - }, - "energyValue": { - "value": 3.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass", - "itemDamage": 15 - } - }, - "energyValue": { - "value": 3.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:trapdoor", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 24.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:monster_egg", - "itemDamage": 0 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:monster_egg", - "itemDamage": 1 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:monster_egg", - "itemDamage": 2 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:monster_egg", - "itemDamage": 3 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:monster_egg", - "itemDamage": 4 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:monster_egg", - "itemDamage": 5 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stonebrick", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stonebrick", - "itemDamage": 1 - } - }, - "energyValue": { - "value": 1.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stonebrick", - "itemDamage": 2 - } - }, - "energyValue": { - "value": 1.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stonebrick", - "itemDamage": 3 - } - }, - "energyValue": { - "value": 1.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:iron_bars", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 96.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:glass_pane", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 0.375 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:melon_block", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 144.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:vine", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 8.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:fence_gate", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:brick_stairs", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 384.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stone_brick_stairs", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1.5 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:mycelium", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:waterlily", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 16.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:nether_brick", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 4.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:nether_brick_fence", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 4.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:nether_brick_stairs", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 6.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:enchanting_table", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 16800.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:end_portal_frame", - "itemDamage": 0 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:end_stone", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:redstone_lamp", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1664.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wooden_slab", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 4.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wooden_slab", - "itemDamage": 1 - } - }, - "energyValue": { - "value": 4.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wooden_slab", - "itemDamage": 2 - } - }, - "energyValue": { - "value": 4.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wooden_slab", - "itemDamage": 3 - } - }, - "energyValue": { - "value": 4.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wooden_slab", - "itemDamage": 4 - } - }, - "energyValue": { - "value": 4.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wooden_slab", - "itemDamage": 5 - } - }, - "energyValue": { - "value": 4.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:sandstone_stairs", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 6.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:emerald_ore", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 8192.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:ender_chest", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 2304.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:tripwire_hook", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 134.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:emerald_block", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 73728.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:spruce_stairs", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 12.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:birch_stairs", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 12.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:jungle_stairs", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 12.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:beacon", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 24773.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:cobblestone_wall", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:cobblestone_wall", - "itemDamage": 1 - } - }, - "energyValue": { - "value": 1.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wooden_button", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 8.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:anvil", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 7936.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:anvil", - "itemDamage": 1 - } - }, - "energyValue": { - "value": 5290.667 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:anvil", - "itemDamage": 2 - } - }, - "energyValue": { - "value": 2645.333 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:trapped_chest", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 198.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:light_weighted_pressure_plate", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 4096.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:heavy_weighted_pressure_plate", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 512.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:daylight_detector", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 783.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:redstone_block", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 288.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:quartz_ore", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 256.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:hopper", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1344.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:quartz_block", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1024.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:quartz_block", - "itemDamage": 1 - } - }, - "energyValue": { - "value": 1024.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:quartz_block", - "itemDamage": 2 - } - }, - "energyValue": { - "value": 1024.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:quartz_stairs", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1536.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:activator_rail", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 263.333 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:dropper", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 39.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_hardened_clay", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 258.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_hardened_clay", - "itemDamage": 1 - } - }, - "energyValue": { - "value": 258.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_hardened_clay", - "itemDamage": 2 - } - }, - "energyValue": { - "value": 258.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_hardened_clay", - "itemDamage": 3 - } - }, - "energyValue": { - "value": 258.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_hardened_clay", - "itemDamage": 4 - } - }, - "energyValue": { - "value": 258.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_hardened_clay", - "itemDamage": 5 - } - }, - "energyValue": { - "value": 258.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_hardened_clay", - "itemDamage": 6 - } - }, - "energyValue": { - "value": 258.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_hardened_clay", - "itemDamage": 7 - } - }, - "energyValue": { - "value": 258.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_hardened_clay", - "itemDamage": 8 - } - }, - "energyValue": { - "value": 258.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_hardened_clay", - "itemDamage": 9 - } - }, - "energyValue": { - "value": 258.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_hardened_clay", - "itemDamage": 10 - } - }, - "energyValue": { - "value": 258.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_hardened_clay", - "itemDamage": 11 - } - }, - "energyValue": { - "value": 258.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_hardened_clay", - "itemDamage": 12 - } - }, - "energyValue": { - "value": 258.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_hardened_clay", - "itemDamage": 13 - } - }, - "energyValue": { - "value": 258.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_hardened_clay", - "itemDamage": 14 - } - }, - "energyValue": { - "value": 258.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_hardened_clay", - "itemDamage": 15 - } - }, - "energyValue": { - "value": 258.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass_pane", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1.125 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass_pane", - "itemDamage": 1 - } - }, - "energyValue": { - "value": 1.125 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass_pane", - "itemDamage": 2 - } - }, - "energyValue": { - "value": 1.125 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass_pane", - "itemDamage": 3 - } - }, - "energyValue": { - "value": 1.125 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass_pane", - "itemDamage": 4 - } - }, - "energyValue": { - "value": 1.125 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass_pane", - "itemDamage": 5 - } - }, - "energyValue": { - "value": 1.125 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass_pane", - "itemDamage": 6 - } - }, - "energyValue": { - "value": 1.125 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass_pane", - "itemDamage": 7 - } - }, - "energyValue": { - "value": 1.125 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass_pane", - "itemDamage": 8 - } - }, - "energyValue": { - "value": 1.125 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass_pane", - "itemDamage": 9 - } - }, - "energyValue": { - "value": 1.125 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass_pane", - "itemDamage": 10 - } - }, - "energyValue": { - "value": 1.125 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass_pane", - "itemDamage": 11 - } - }, - "energyValue": { - "value": 1.125 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass_pane", - "itemDamage": 12 - } - }, - "energyValue": { - "value": 1.125 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass_pane", - "itemDamage": 13 - } - }, - "energyValue": { - "value": 1.125 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass_pane", - "itemDamage": 14 - } - }, - "energyValue": { - "value": 1.125 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stained_glass_pane", - "itemDamage": 15 - } - }, - "energyValue": { - "value": 1.125 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:leaves2", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:leaves2", - "itemDamage": 1 - } - }, - "energyValue": { - "value": 1.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:log2", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:log2", - "itemDamage": 1 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:acacia_stairs", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 12.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:dark_oak_stairs", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 12.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:hay_block", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 216.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:carpet", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:carpet", - "itemDamage": 1 - } - }, - "energyValue": { - "value": 42.667 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:carpet", - "itemDamage": 2 - } - }, - "energyValue": { - "value": 42.667 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:carpet", - "itemDamage": 3 - } - }, - "energyValue": { - "value": 42.667 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:carpet", - "itemDamage": 4 - } - }, - "energyValue": { - "value": 42.667 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:carpet", - "itemDamage": 5 - } - }, - "energyValue": { - "value": 42.667 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:carpet", - "itemDamage": 6 - } - }, - "energyValue": { - "value": 42.667 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:carpet", - "itemDamage": 7 - } - }, - "energyValue": { - "value": 42.667 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:carpet", - "itemDamage": 8 - } - }, - "energyValue": { - "value": 42.667 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:carpet", - "itemDamage": 9 - } - }, - "energyValue": { - "value": 42.667 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:carpet", - "itemDamage": 10 - } - }, - "energyValue": { - "value": 42.667 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:carpet", - "itemDamage": 11 - } - }, - "energyValue": { - "value": 42.667 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:carpet", - "itemDamage": 12 - } - }, - "energyValue": { - "value": 42.667 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:carpet", - "itemDamage": 13 - } - }, - "energyValue": { - "value": 42.667 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:carpet", - "itemDamage": 14 - } - }, - "energyValue": { - "value": 42.667 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:carpet", - "itemDamage": 15 - } - }, - "energyValue": { - "value": 42.667 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:hardened_clay", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 256.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:coal_block", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 288.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:packed_ice", - "itemDamage": 0 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:double_plant", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:double_plant", - "itemDamage": 1 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:double_plant", - "itemDamage": 2 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:double_plant", - "itemDamage": 3 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:double_plant", - "itemDamage": 4 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:double_plant", - "itemDamage": 5 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:iron_shovel", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 264.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:iron_pickaxe", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 776.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:iron_axe", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 776.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:flint_and_steel", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 260.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:apple", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 24.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:bow", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 48.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:arrow", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 14.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:coal", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:coal", - "itemDamage": 1 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:diamond", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 8192.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:iron_ingot", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 256.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:gold_ingot", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 2048.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:iron_sword", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 516.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wooden_sword", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 20.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wooden_shovel", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 16.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wooden_pickaxe", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wooden_axe", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stone_sword", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 6.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stone_shovel", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 9.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stone_pickaxe", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 11.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stone_axe", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 11.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:diamond_sword", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 16388.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:diamond_shovel", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 8200.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:diamond_pickaxe", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 24584.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:diamond_axe", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 24584.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stick", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 4.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:bowl", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 6.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:mushroom_stew", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 70.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:golden_sword", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 4100.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:golden_shovel", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 2056.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:golden_pickaxe", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 6152.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:golden_axe", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 6152.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:string", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 12.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:feather", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 48.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:gunpowder", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 192.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wooden_hoe", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 24.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:stone_hoe", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 10.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:iron_hoe", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 520.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:diamond_hoe", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 16392.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:golden_hoe", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 4104.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wheat_seeds", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 16.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wheat", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 24.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:bread", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 72.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:leather_helmet", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 320.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:leather_chestplate", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 512.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:leather_leggings", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 448.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:leather_boots", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 256.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:chainmail_helmet", - "itemDamage": 0 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:chainmail_chestplate", - "itemDamage": 0 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:chainmail_leggings", - "itemDamage": 0 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:chainmail_boots", - "itemDamage": 0 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:iron_helmet", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1280.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:iron_chestplate", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 2048.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:iron_leggings", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1792.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:iron_boots", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1024.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:diamond_helmet", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 40960.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:diamond_chestplate", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 65536.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:diamond_leggings", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 57344.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:diamond_boots", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 32768.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:golden_helmet", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 10240.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:golden_chestplate", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 16384.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:golden_leggings", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 14336.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:golden_boots", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 8192.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:flint", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 4.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:porkchop", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 24.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:cooked_porkchop", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 24.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:painting", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 80.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:golden_apple", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 16408.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:golden_apple", - "itemDamage": 1 - } - }, - "energyValue": { - "value": 147480.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:sign", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 17.333 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:wooden_door", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 48.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:bucket", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 768.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:water_bucket", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 769.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:lava_bucket", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 832.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:minecart", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1280.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:saddle", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 192.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:iron_door", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1536.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:redstone", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:snowball", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 0.25 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:boat", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 40.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:leather", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 64.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:milk_bucket", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 832.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:brick", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 64.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:clay_ball", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 64.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:reeds", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:paper", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:book", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 160.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:slime_ball", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 24.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:chest_minecart", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1344.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:furnace_minecart", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1288.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:egg", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:compass", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1056.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:fishing_rod", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 36.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:clock", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 8224.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:glowstone_dust", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 384.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:fish", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 24.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:fish", - "itemDamage": 1 - } - }, - "energyValue": { - "value": 24.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:fish", - "itemDamage": 2 - } - }, - "energyValue": { - "value": 24.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:fish", - "itemDamage": 3 - } - }, - "energyValue": { - "value": 24.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:cooked_fished", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 24.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:cooked_fished", - "itemDamage": 1 - } - }, - "energyValue": { - "value": 24.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:dye", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 16.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:dye", - "itemDamage": 1 - } - }, - "energyValue": { - "value": 16.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:dye", - "itemDamage": 2 - } - }, - "energyValue": { - "value": 16.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:dye", - "itemDamage": 3 - } - }, - "energyValue": { - "value": 16.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:dye", - "itemDamage": 4 - } - }, - "energyValue": { - "value": 864.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:dye", - "itemDamage": 5 - } - }, - "energyValue": { - "value": 16.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:dye", - "itemDamage": 6 - } - }, - "energyValue": { - "value": 16.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:dye", - "itemDamage": 7 - } - }, - "energyValue": { - "value": 16.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:dye", - "itemDamage": 8 - } - }, - "energyValue": { - "value": 16.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:dye", - "itemDamage": 9 - } - }, - "energyValue": { - "value": 16.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:dye", - "itemDamage": 10 - } - }, - "energyValue": { - "value": 16.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:dye", - "itemDamage": 11 - } - }, - "energyValue": { - "value": 16.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:dye", - "itemDamage": 12 - } - }, - "energyValue": { - "value": 16.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:dye", - "itemDamage": 13 - } - }, - "energyValue": { - "value": 16.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:dye", - "itemDamage": 14 - } - }, - "energyValue": { - "value": 16.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:dye", - "itemDamage": 15 - } - }, - "energyValue": { - "value": 16.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:bone", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 48.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:sugar", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 32.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:cake", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 360.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:repeater", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 107.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:cookie", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 8.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:shears", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 512.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:melon", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 16.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:pumpkin_seeds", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 36.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:melon_seeds", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 16.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:beef", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 24.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:cooked_beef", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 24.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:chicken", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 24.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:cooked_chicken", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 24.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:rotten_flesh", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 24.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:ender_pearl", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1024.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:blaze_rod", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1536.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:ghast_tear", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 4096.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:gold_nugget", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 227.556 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:nether_wart", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 24.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 2.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 16 - } - }, - "energyValue": { - "value": 8.667 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 8193 - } - }, - "energyValue": { - "value": 1368.222 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 8194 - } - }, - "energyValue": { - "value": 13.556 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 8196 - } - }, - "energyValue": { - "value": 45.556 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 8201 - } - }, - "energyValue": { - "value": 258.889 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 8225 - } - }, - "energyValue": { - "value": 163.064 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 8226 - } - }, - "energyValue": { - "value": 132.519 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 8227 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 8228 - } - }, - "energyValue": { - "value": 138.044 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 8229 - } - }, - "energyValue": { - "value": 168.557 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 8230 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 8232 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 8233 - } - }, - "energyValue": { - "value": 149.369 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 8234 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 8236 - } - }, - "energyValue": { - "value": 111.728 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 8237 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 8238 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 8257 - } - }, - "energyValue": { - "value": 76.151 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 8258 - } - }, - "energyValue": { - "value": 15.185 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 8259 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 8260 - } - }, - "energyValue": { - "value": 20.711 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 8261 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 8262 - } - }, - "energyValue": { - "value": 77.396 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 8264 - } - }, - "energyValue": { - "value": 32.963 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 8265 - } - }, - "energyValue": { - "value": 62.455 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 8266 - } - }, - "energyValue": { - "value": 85.468 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 8268 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 8269 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 8270 - } - }, - "energyValue": { - "value": 54.243 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 16385 - } - }, - "energyValue": { - "value": 520.074 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 16386 - } - }, - "energyValue": { - "value": 68.519 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 16388 - } - }, - "energyValue": { - "value": 79.185 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 16393 - } - }, - "energyValue": { - "value": 150.296 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 16417 - } - }, - "energyValue": { - "value": 129.484 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 16418 - } - }, - "energyValue": { - "value": 108.173 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 16419 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 16420 - } - }, - "energyValue": { - "value": 111.728 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 16421 - } - }, - "energyValue": { - "value": 120.186 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 16422 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 16424 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 16425 - } - }, - "energyValue": { - "value": 115.789 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 16426 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 16428 - } - }, - "energyValue": { - "value": 101.243 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 16429 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 16430 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 16449 - } - }, - "energyValue": { - "value": 63.509 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 16450 - } - }, - "energyValue": { - "value": 33.506 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 16451 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 16452 - } - }, - "energyValue": { - "value": 26.636 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 16453 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 16454 - } - }, - "energyValue": { - "value": 54.243 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 16456 - } - }, - "energyValue": { - "value": 39.432 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 16457 - } - }, - "energyValue": { - "value": 49.813 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 16458 - } - }, - "energyValue": { - "value": 84.551 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 16460 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 16461 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potion", - "itemDamage": 16462 - } - }, - "energyValue": { - "value": 61.989 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:glass_bottle", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:spider_eye", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 128.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:fermented_spider_eye", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 192.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:blaze_powder", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 768.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:magma_cream", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 792.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:brewing_stand", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1539.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:ender_eye", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1792.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:speckled_melon", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1836.448 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:spawn_egg", - "itemDamage": 50 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:spawn_egg", - "itemDamage": 51 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:spawn_egg", - "itemDamage": 52 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:spawn_egg", - "itemDamage": 54 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:spawn_egg", - "itemDamage": 55 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:spawn_egg", - "itemDamage": 56 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:spawn_egg", - "itemDamage": 57 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:spawn_egg", - "itemDamage": 58 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:spawn_egg", - "itemDamage": 59 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:spawn_egg", - "itemDamage": 60 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:spawn_egg", - "itemDamage": 61 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:spawn_egg", - "itemDamage": 62 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:spawn_egg", - "itemDamage": 65 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:spawn_egg", - "itemDamage": 66 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:spawn_egg", - "itemDamage": 90 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:spawn_egg", - "itemDamage": 91 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:spawn_egg", - "itemDamage": 92 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:spawn_egg", - "itemDamage": 93 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:spawn_egg", - "itemDamage": 94 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:spawn_egg", - "itemDamage": 95 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:spawn_egg", - "itemDamage": 96 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:spawn_egg", - "itemDamage": 97 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:spawn_egg", - "itemDamage": 98 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:spawn_egg", - "itemDamage": 99 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:spawn_egg", - "itemDamage": 100 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:spawn_egg", - "itemDamage": 120 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:experience_bottle", - "itemDamage": 0 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:fire_charge", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 330.667 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:writable_book", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 224.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:emerald", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 8192.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:flower_pot", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 192.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:carrot", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 24.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:potato", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 24.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:baked_potato", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 24.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:poisonous_potato", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 24.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:map", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1312.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:golden_carrot", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1844.448 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:carrot_on_a_stick", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 60.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:nether_star", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 24576.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:pumpkin_pie", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 208.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:firework_charge", - "itemDamage": 0 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:enchanted_book", - "itemDamage": 32767 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:comparator", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 367.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:netherbrick", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 1.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:quartz", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 256.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:tnt_minecart", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 2244.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:hopper_minecart", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 2624.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:iron_horse_armor", - "itemDamage": 0 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:golden_horse_armor", - "itemDamage": 0 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:diamond_horse_armor", - "itemDamage": 0 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:lead", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 36.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:name_tag", - "itemDamage": 0 - } - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:record_13", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 2048.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:record_cat", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 2048.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:record_blocks", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 2048.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:record_chirp", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 2048.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:record_far", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 2048.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:record_mellohi", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 2048.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:record_stal", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 2048.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:record_strad", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 2048.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:record_ward", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 2048.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:record_11", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 2048.0 - } - }, - { - "wrappedStack": { - "type": "itemstack", - "stackSize": 1, - "objectData": { - "itemName": "minecraft:record_wait", - "itemDamage": 0 - } - }, - "energyValue": { - "value": 2048.0 - } - } + { + "itemstack": { + "name": "minecraft:stone" + }, + "energyValue": 1.0 + }, + { + "itemstack": { + "name": "minecraft:grass" + }, + "energyValue": 1.0 + }, + { + "itemstack": { + "name": "minecraft:dirt" + }, + "energyValue": 1.0 + }, + { + "itemstack": { + "name": "minecraft:dirt", + "metaValue": 2 + }, + "energyValue": 1.0 + }, + { + "itemstack": { + "name": "minecraft:cobblestone" + }, + "energyValue": 1.0 + }, + { + "itemstack": { + "name": "minecraft:planks" + }, + "energyValue": 8.0 + }, + { + "itemstack": { + "name": "minecraft:planks", + "metaValue": 1 + }, + "energyValue": 8.0 + }, + { + "itemstack": { + "name": "minecraft:planks", + "metaValue": 2 + }, + "energyValue": 8.0 + }, + { + "itemstack": { + "name": "minecraft:planks", + "metaValue": 3 + }, + "energyValue": 8.0 + }, + { + "itemstack": { + "name": "minecraft:planks", + "metaValue": 4 + }, + "energyValue": 8.0 + }, + { + "itemstack": { + "name": "minecraft:planks", + "metaValue": 5 + }, + "energyValue": 8.0 + }, + { + "itemstack": { + "name": "minecraft:sapling" + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:sapling", + "metaValue": 1 + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:sapling", + "metaValue": 2 + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:sapling", + "metaValue": 3 + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:sapling", + "metaValue": 4 + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:sapling", + "metaValue": 5 + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:sand" + }, + "energyValue": 1.0 + }, + { + "itemstack": { + "name": "minecraft:gravel" + }, + "energyValue": 4.0 + }, + { + "itemstack": { + "name": "minecraft:gold_ore" + }, + "energyValue": 2048.0 + }, + { + "itemstack": { + "name": "minecraft:iron_ore" + }, + "energyValue": 256.0 + }, + { + "itemstack": { + "name": "minecraft:coal_ore" + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:log" + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:log", + "metaValue": 1 + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:log", + "metaValue": 2 + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:log", + "metaValue": 3 + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:leaves" + }, + "energyValue": 1.0 + }, + { + "itemstack": { + "name": "minecraft:leaves", + "metaValue": 1 + }, + "energyValue": 1.0 + }, + { + "itemstack": { + "name": "minecraft:leaves", + "metaValue": 2 + }, + "energyValue": 1.0 + }, + { + "itemstack": { + "name": "minecraft:leaves", + "metaValue": 3 + }, + "energyValue": 1.0 + }, + { + "itemstack": { + "name": "minecraft:glass" + }, + "energyValue": 1.0 + }, + { + "itemstack": { + "name": "minecraft:lapis_ore" + }, + "energyValue": 864.0 + }, + { + "itemstack": { + "name": "minecraft:lapis_block" + }, + "energyValue": 7776.0 + }, + { + "itemstack": { + "name": "minecraft:dispenser" + }, + "energyValue": 87.0 + }, + { + "itemstack": { + "name": "minecraft:sandstone" + }, + "energyValue": 4.0 + }, + { + "itemstack": { + "name": "minecraft:sandstone", + "metaValue": 1 + }, + "energyValue": 4.0 + }, + { + "itemstack": { + "name": "minecraft:sandstone", + "metaValue": 2 + }, + "energyValue": 4.0 + }, + { + "itemstack": { + "name": "minecraft:noteblock" + }, + "energyValue": 96.0 + }, + { + "itemstack": { + "name": "minecraft:golden_rail" + }, + "energyValue": 2054.0 + }, + { + "itemstack": { + "name": "minecraft:detector_rail" + }, + "energyValue": 261.667 + }, + { + "itemstack": { + "name": "minecraft:sticky_piston" + }, + "energyValue": 340.0 + }, + { + "itemstack": { + "name": "minecraft:web" + }, + "energyValue": 12.0 + }, + { + "itemstack": { + "name": "minecraft:tallgrass" + }, + "energyValue": 1.0 + }, + { + "itemstack": { + "name": "minecraft:tallgrass", + "metaValue": 1 + }, + "energyValue": 1.0 + }, + { + "itemstack": { + "name": "minecraft:deadbush" + }, + "energyValue": 1.0 + }, + { + "itemstack": { + "name": "minecraft:piston" + }, + "energyValue": 316.0 + }, + { + "itemstack": { + "name": "minecraft:wool" + }, + "energyValue": 48.0 + }, + { + "itemstack": { + "name": "minecraft:wool", + "metaValue": 1 + }, + "energyValue": 64.0 + }, + { + "itemstack": { + "name": "minecraft:wool", + "metaValue": 2 + }, + "energyValue": 64.0 + }, + { + "itemstack": { + "name": "minecraft:wool", + "metaValue": 3 + }, + "energyValue": 64.0 + }, + { + "itemstack": { + "name": "minecraft:wool", + "metaValue": 4 + }, + "energyValue": 64.0 + }, + { + "itemstack": { + "name": "minecraft:wool", + "metaValue": 5 + }, + "energyValue": 64.0 + }, + { + "itemstack": { + "name": "minecraft:wool", + "metaValue": 6 + }, + "energyValue": 64.0 + }, + { + "itemstack": { + "name": "minecraft:wool", + "metaValue": 7 + }, + "energyValue": 64.0 + }, + { + "itemstack": { + "name": "minecraft:wool", + "metaValue": 8 + }, + "energyValue": 64.0 + }, + { + "itemstack": { + "name": "minecraft:wool", + "metaValue": 9 + }, + "energyValue": 64.0 + }, + { + "itemstack": { + "name": "minecraft:wool", + "metaValue": 10 + }, + "energyValue": 64.0 + }, + { + "itemstack": { + "name": "minecraft:wool", + "metaValue": 11 + }, + "energyValue": 64.0 + }, + { + "itemstack": { + "name": "minecraft:wool", + "metaValue": 12 + }, + "energyValue": 64.0 + }, + { + "itemstack": { + "name": "minecraft:wool", + "metaValue": 13 + }, + "energyValue": 64.0 + }, + { + "itemstack": { + "name": "minecraft:wool", + "metaValue": 14 + }, + "energyValue": 64.0 + }, + { + "itemstack": { + "name": "minecraft:wool", + "metaValue": 15 + }, + "energyValue": 64.0 + }, + { + "itemstack": { + "name": "minecraft:yellow_flower" + }, + "energyValue": 16.0 + }, + { + "itemstack": { + "name": "minecraft:red_flower" + }, + "energyValue": 16.0 + }, + { + "itemstack": { + "name": "minecraft:red_flower", + "metaValue": 1 + }, + "energyValue": 16.0 + }, + { + "itemstack": { + "name": "minecraft:red_flower", + "metaValue": 2 + }, + "energyValue": 16.0 + }, + { + "itemstack": { + "name": "minecraft:red_flower", + "metaValue": 3 + }, + "energyValue": 16.0 + }, + { + "itemstack": { + "name": "minecraft:red_flower", + "metaValue": 4 + }, + "energyValue": 16.0 + }, + { + "itemstack": { + "name": "minecraft:red_flower", + "metaValue": 5 + }, + "energyValue": 16.0 + }, + { + "itemstack": { + "name": "minecraft:red_flower", + "metaValue": 6 + }, + "energyValue": 16.0 + }, + { + "itemstack": { + "name": "minecraft:red_flower", + "metaValue": 7 + }, + "energyValue": 16.0 + }, + { + "itemstack": { + "name": "minecraft:red_flower", + "metaValue": 8 + }, + "energyValue": 16.0 + }, + { + "itemstack": { + "name": "minecraft:brown_mushroom" + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:red_mushroom" + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:gold_block" + }, + "energyValue": 18432.0 + }, + { + "itemstack": { + "name": "minecraft:iron_block" + }, + "energyValue": 2304.0 + }, + { + "itemstack": { + "name": "minecraft:stone_slab" + }, + "energyValue": 0.5 + }, + { + "itemstack": { + "name": "minecraft:stone_slab", + "metaValue": 1 + }, + "energyValue": 2.0 + }, + { + "itemstack": { + "name": "minecraft:stone_slab", + "metaValue": 3 + }, + "energyValue": 0.5 + }, + { + "itemstack": { + "name": "minecraft:stone_slab", + "metaValue": 4 + }, + "energyValue": 128.0 + }, + { + "itemstack": { + "name": "minecraft:stone_slab", + "metaValue": 5 + }, + "energyValue": 0.5 + }, + { + "itemstack": { + "name": "minecraft:stone_slab", + "metaValue": 6 + }, + "energyValue": 2.0 + }, + { + "itemstack": { + "name": "minecraft:stone_slab", + "metaValue": 7 + }, + "energyValue": 512.0 + }, + { + "itemstack": { + "name": "minecraft:brick_block" + }, + "energyValue": 256.0 + }, + { + "itemstack": { + "name": "minecraft:tnt" + }, + "energyValue": 964.0 + }, + { + "itemstack": { + "name": "minecraft:bookshelf" + }, + "energyValue": 528.0 + }, + { + "itemstack": { + "name": "minecraft:mossy_cobblestone" + }, + "energyValue": 1.0 + }, + { + "itemstack": { + "name": "minecraft:obsidian" + }, + "energyValue": 64.0 + }, + { + "itemstack": { + "name": "minecraft:torch" + }, + "energyValue": 9.0 + }, + { + "itemstack": { + "name": "minecraft:oak_stairs" + }, + "energyValue": 12.0 + }, + { + "itemstack": { + "name": "minecraft:chest" + }, + "energyValue": 64.0 + }, + { + "itemstack": { + "name": "minecraft:diamond_ore" + }, + "energyValue": 8192.0 + }, + { + "itemstack": { + "name": "minecraft:diamond_block" + }, + "energyValue": 73728.0 + }, + { + "itemstack": { + "name": "minecraft:crafting_table" + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:furnace" + }, + "energyValue": 8.0 + }, + { + "itemstack": { + "name": "minecraft:ladder" + }, + "energyValue": 9.333 + }, + { + "itemstack": { + "name": "minecraft:rail" + }, + "energyValue": 96.25 + }, + { + "itemstack": { + "name": "minecraft:stone_stairs" + }, + "energyValue": 1.5 + }, + { + "itemstack": { + "name": "minecraft:lever" + }, + "energyValue": 5.0 + }, + { + "itemstack": { + "name": "minecraft:stone_pressure_plate" + }, + "energyValue": 2.0 + }, + { + "itemstack": { + "name": "minecraft:wooden_pressure_plate" + }, + "energyValue": 16.0 + }, + { + "itemstack": { + "name": "minecraft:redstone_ore" + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:redstone_torch" + }, + "energyValue": 36.0 + }, + { + "itemstack": { + "name": "minecraft:stone_button" + }, + "energyValue": 1.0 + }, + { + "itemstack": { + "name": "minecraft:snow_layer" + }, + "energyValue": 0.125 + }, + { + "itemstack": { + "name": "minecraft:ice" + }, + "energyValue": 1.0 + }, + { + "itemstack": { + "name": "minecraft:snow" + }, + "energyValue": 1.0 + }, + { + "itemstack": { + "name": "minecraft:cactus" + }, + "energyValue": 8.0 + }, + { + "itemstack": { + "name": "minecraft:clay" + }, + "energyValue": 256.0 + }, + { + "itemstack": { + "name": "minecraft:jukebox" + }, + "energyValue": 8256.0 + }, + { + "itemstack": { + "name": "minecraft:fence" + }, + "energyValue": 12.0 + }, + { + "itemstack": { + "name": "minecraft:pumpkin" + }, + "energyValue": 144.0 + }, + { + "itemstack": { + "name": "minecraft:netherrack" + }, + "energyValue": 1.0 + }, + { + "itemstack": { + "name": "minecraft:soul_sand" + }, + "energyValue": 49.0 + }, + { + "itemstack": { + "name": "minecraft:glowstone" + }, + "energyValue": 1536.0 + }, + { + "itemstack": { + "name": "minecraft:lit_pumpkin" + }, + "energyValue": 153.0 + }, + { + "itemstack": { + "name": "minecraft:stained_glass" + }, + "energyValue": 3.0 + }, + { + "itemstack": { + "name": "minecraft:stained_glass", + "metaValue": 1 + }, + "energyValue": 3.0 + }, + { + "itemstack": { + "name": "minecraft:stained_glass", + "metaValue": 2 + }, + "energyValue": 3.0 + }, + { + "itemstack": { + "name": "minecraft:stained_glass", + "metaValue": 3 + }, + "energyValue": 3.0 + }, + { + "itemstack": { + "name": "minecraft:stained_glass", + "metaValue": 4 + }, + "energyValue": 3.0 + }, + { + "itemstack": { + "name": "minecraft:stained_glass", + "metaValue": 5 + }, + "energyValue": 3.0 + }, + { + "itemstack": { + "name": "minecraft:stained_glass", + "metaValue": 6 + }, + "energyValue": 3.0 + }, + { + "itemstack": { + "name": "minecraft:stained_glass", + "metaValue": 7 + }, + "energyValue": 3.0 + }, + { + "itemstack": { + "name": "minecraft:stained_glass", + "metaValue": 8 + }, + "energyValue": 3.0 + }, + { + "itemstack": { + "name": "minecraft:stained_glass", + "metaValue": 9 + }, + "energyValue": 3.0 + }, + { + "itemstack": { + "name": "minecraft:stained_glass", + "metaValue": 10 + }, + "energyValue": 3.0 + }, + { + "itemstack": { + "name": "minecraft:stained_glass", + "metaValue": 11 + }, + "energyValue": 3.0 + }, + { + "itemstack": { + "name": "minecraft:stained_glass", + "metaValue": 12 + }, + "energyValue": 3.0 + }, + { + "itemstack": { + "name": "minecraft:stained_glass", + "metaValue": 13 + }, + "energyValue": 3.0 + }, + { + "itemstack": { + "name": "minecraft:stained_glass", + "metaValue": 14 + }, + "energyValue": 3.0 + }, + { + "itemstack": { + "name": "minecraft:stained_glass", + "metaValue": 15 + }, + "energyValue": 3.0 + }, + { + "itemstack": { + "name": "minecraft:trapdoor" + }, + "energyValue": 24.0 + }, + { + "itemstack": { + "name": "minecraft:stonebrick" + }, + "energyValue": 1.0 + }, + { + "itemstack": { + "name": "minecraft:stonebrick", + "metaValue": 1 + }, + "energyValue": 1.0 + }, + { + "itemstack": { + "name": "minecraft:stonebrick", + "metaValue": 2 + }, + "energyValue": 1.0 + }, + { + "itemstack": { + "name": "minecraft:stonebrick", + "metaValue": 3 + }, + "energyValue": 1.0 + }, + { + "itemstack": { + "name": "minecraft:iron_bars" + }, + "energyValue": 96.0 + }, + { + "itemstack": { + "name": "minecraft:glass_pane" + }, + "energyValue": 0.375 + }, + { + "itemstack": { + "name": "minecraft:melon_block" + }, + "energyValue": 144.0 + }, + { + "itemstack": { + "name": "minecraft:vine" + }, + "energyValue": 8.0 + }, + { + "itemstack": { + "name": "minecraft:fence_gate" + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:brick_stairs" + }, + "energyValue": 384.0 + }, + { + "itemstack": { + "name": "minecraft:stone_brick_stairs" + }, + "energyValue": 1.5 + }, + { + "itemstack": { + "name": "minecraft:mycelium" + }, + "energyValue": 1.0 + }, + { + "itemstack": { + "name": "minecraft:waterlily" + }, + "energyValue": 16.0 + }, + { + "itemstack": { + "name": "minecraft:nether_brick" + }, + "energyValue": 4.0 + }, + { + "itemstack": { + "name": "minecraft:nether_brick_fence" + }, + "energyValue": 4.0 + }, + { + "itemstack": { + "name": "minecraft:nether_brick_stairs" + }, + "energyValue": 6.0 + }, + { + "itemstack": { + "name": "minecraft:enchanting_table" + }, + "energyValue": 16800.0 + }, + { + "itemstack": { + "name": "minecraft:end_stone" + }, + "energyValue": 1.0 + }, + { + "itemstack": { + "name": "minecraft:redstone_lamp" + }, + "energyValue": 1664.0 + }, + { + "itemstack": { + "name": "minecraft:wooden_slab" + }, + "energyValue": 4.0 + }, + { + "itemstack": { + "name": "minecraft:wooden_slab", + "metaValue": 1 + }, + "energyValue": 4.0 + }, + { + "itemstack": { + "name": "minecraft:wooden_slab", + "metaValue": 2 + }, + "energyValue": 4.0 + }, + { + "itemstack": { + "name": "minecraft:wooden_slab", + "metaValue": 3 + }, + "energyValue": 4.0 + }, + { + "itemstack": { + "name": "minecraft:wooden_slab", + "metaValue": 4 + }, + "energyValue": 4.0 + }, + { + "itemstack": { + "name": "minecraft:wooden_slab", + "metaValue": 5 + }, + "energyValue": 4.0 + }, + { + "itemstack": { + "name": "minecraft:sandstone_stairs" + }, + "energyValue": 6.0 + }, + { + "itemstack": { + "name": "minecraft:emerald_ore" + }, + "energyValue": 8192.0 + }, + { + "itemstack": { + "name": "minecraft:ender_chest" + }, + "energyValue": 2304.0 + }, + { + "itemstack": { + "name": "minecraft:tripwire_hook" + }, + "energyValue": 134.0 + }, + { + "itemstack": { + "name": "minecraft:emerald_block" + }, + "energyValue": 73728.0 + }, + { + "itemstack": { + "name": "minecraft:spruce_stairs" + }, + "energyValue": 12.0 + }, + { + "itemstack": { + "name": "minecraft:birch_stairs" + }, + "energyValue": 12.0 + }, + { + "itemstack": { + "name": "minecraft:jungle_stairs" + }, + "energyValue": 12.0 + }, + { + "itemstack": { + "name": "minecraft:beacon" + }, + "energyValue": 24773.0 + }, + { + "itemstack": { + "name": "minecraft:cobblestone_wall" + }, + "energyValue": 1.0 + }, + { + "itemstack": { + "name": "minecraft:cobblestone_wall", + "metaValue": 1 + }, + "energyValue": 1.0 + }, + { + "itemstack": { + "name": "minecraft:wooden_button" + }, + "energyValue": 8.0 + }, + { + "itemstack": { + "name": "minecraft:anvil" + }, + "energyValue": 7936.0 + }, + { + "itemstack": { + "name": "minecraft:anvil", + "metaValue": 1 + }, + "energyValue": 5290.667 + }, + { + "itemstack": { + "name": "minecraft:anvil", + "metaValue": 2 + }, + "energyValue": 2645.333 + }, + { + "itemstack": { + "name": "minecraft:trapped_chest" + }, + "energyValue": 198.0 + }, + { + "itemstack": { + "name": "minecraft:light_weighted_pressure_plate" + }, + "energyValue": 4096.0 + }, + { + "itemstack": { + "name": "minecraft:heavy_weighted_pressure_plate" + }, + "energyValue": 512.0 + }, + { + "itemstack": { + "name": "minecraft:daylight_detector" + }, + "energyValue": 783.0 + }, + { + "itemstack": { + "name": "minecraft:redstone_block" + }, + "energyValue": 288.0 + }, + { + "itemstack": { + "name": "minecraft:quartz_ore" + }, + "energyValue": 256.0 + }, + { + "itemstack": { + "name": "minecraft:hopper" + }, + "energyValue": 1344.0 + }, + { + "itemstack": { + "name": "minecraft:quartz_block" + }, + "energyValue": 1024.0 + }, + { + "itemstack": { + "name": "minecraft:quartz_block", + "metaValue": 1 + }, + "energyValue": 1024.0 + }, + { + "itemstack": { + "name": "minecraft:quartz_block", + "metaValue": 2 + }, + "energyValue": 1024.0 + }, + { + "itemstack": { + "name": "minecraft:quartz_stairs" + }, + "energyValue": 1536.0 + }, + { + "itemstack": { + "name": "minecraft:activator_rail" + }, + "energyValue": 263.333 + }, + { + "itemstack": { + "name": "minecraft:dropper" + }, + "energyValue": 39.0 + }, + { + "itemstack": { + "name": "minecraft:stained_hardened_clay" + }, + "energyValue": 258.0 + }, + { + "itemstack": { + "name": "minecraft:stained_hardened_clay", + "metaValue": 1 + }, + "energyValue": 258.0 + }, + { + "itemstack": { + "name": "minecraft:stained_hardened_clay", + "metaValue": 2 + }, + "energyValue": 258.0 + }, + { + "itemstack": { + "name": "minecraft:stained_hardened_clay", + "metaValue": 3 + }, + "energyValue": 258.0 + }, + { + "itemstack": { + "name": "minecraft:stained_hardened_clay", + "metaValue": 4 + }, + "energyValue": 258.0 + }, + { + "itemstack": { + "name": "minecraft:stained_hardened_clay", + "metaValue": 5 + }, + "energyValue": 258.0 + }, + { + "itemstack": { + "name": "minecraft:stained_hardened_clay", + "metaValue": 6 + }, + "energyValue": 258.0 + }, + { + "itemstack": { + "name": "minecraft:stained_hardened_clay", + "metaValue": 7 + }, + "energyValue": 258.0 + }, + { + "itemstack": { + "name": "minecraft:stained_hardened_clay", + "metaValue": 8 + }, + "energyValue": 258.0 + }, + { + "itemstack": { + "name": "minecraft:stained_hardened_clay", + "metaValue": 9 + }, + "energyValue": 258.0 + }, + { + "itemstack": { + "name": "minecraft:stained_hardened_clay", + "metaValue": 10 + }, + "energyValue": 258.0 + }, + { + "itemstack": { + "name": "minecraft:stained_hardened_clay", + "metaValue": 11 + }, + "energyValue": 258.0 + }, + { + "itemstack": { + "name": "minecraft:stained_hardened_clay", + "metaValue": 12 + }, + "energyValue": 258.0 + }, + { + "itemstack": { + "name": "minecraft:stained_hardened_clay", + "metaValue": 13 + }, + "energyValue": 258.0 + }, + { + "itemstack": { + "name": "minecraft:stained_hardened_clay", + "metaValue": 14 + }, + "energyValue": 258.0 + }, + { + "itemstack": { + "name": "minecraft:stained_hardened_clay", + "metaValue": 15 + }, + "energyValue": 258.0 + }, + { + "itemstack": { + "name": "minecraft:stained_glass_pane" + }, + "energyValue": 1.125 + }, + { + "itemstack": { + "name": "minecraft:stained_glass_pane", + "metaValue": 1 + }, + "energyValue": 1.125 + }, + { + "itemstack": { + "name": "minecraft:stained_glass_pane", + "metaValue": 2 + }, + "energyValue": 1.125 + }, + { + "itemstack": { + "name": "minecraft:stained_glass_pane", + "metaValue": 3 + }, + "energyValue": 1.125 + }, + { + "itemstack": { + "name": "minecraft:stained_glass_pane", + "metaValue": 4 + }, + "energyValue": 1.125 + }, + { + "itemstack": { + "name": "minecraft:stained_glass_pane", + "metaValue": 5 + }, + "energyValue": 1.125 + }, + { + "itemstack": { + "name": "minecraft:stained_glass_pane", + "metaValue": 6 + }, + "energyValue": 1.125 + }, + { + "itemstack": { + "name": "minecraft:stained_glass_pane", + "metaValue": 7 + }, + "energyValue": 1.125 + }, + { + "itemstack": { + "name": "minecraft:stained_glass_pane", + "metaValue": 8 + }, + "energyValue": 1.125 + }, + { + "itemstack": { + "name": "minecraft:stained_glass_pane", + "metaValue": 9 + }, + "energyValue": 1.125 + }, + { + "itemstack": { + "name": "minecraft:stained_glass_pane", + "metaValue": 10 + }, + "energyValue": 1.125 + }, + { + "itemstack": { + "name": "minecraft:stained_glass_pane", + "metaValue": 11 + }, + "energyValue": 1.125 + }, + { + "itemstack": { + "name": "minecraft:stained_glass_pane", + "metaValue": 12 + }, + "energyValue": 1.125 + }, + { + "itemstack": { + "name": "minecraft:stained_glass_pane", + "metaValue": 13 + }, + "energyValue": 1.125 + }, + { + "itemstack": { + "name": "minecraft:stained_glass_pane", + "metaValue": 14 + }, + "energyValue": 1.125 + }, + { + "itemstack": { + "name": "minecraft:stained_glass_pane", + "metaValue": 15 + }, + "energyValue": 1.125 + }, + { + "itemstack": { + "name": "minecraft:leaves2" + }, + "energyValue": 1.0 + }, + { + "itemstack": { + "name": "minecraft:leaves2", + "metaValue": 1 + }, + "energyValue": 1.0 + }, + { + "itemstack": { + "name": "minecraft:log2" + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:log2", + "metaValue": 1 + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:acacia_stairs" + }, + "energyValue": 12.0 + }, + { + "itemstack": { + "name": "minecraft:dark_oak_stairs" + }, + "energyValue": 12.0 + }, + { + "itemstack": { + "name": "minecraft:hay_block" + }, + "energyValue": 216.0 + }, + { + "itemstack": { + "name": "minecraft:carpet" + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:carpet", + "metaValue": 1 + }, + "energyValue": 42.667 + }, + { + "itemstack": { + "name": "minecraft:carpet", + "metaValue": 2 + }, + "energyValue": 42.667 + }, + { + "itemstack": { + "name": "minecraft:carpet", + "metaValue": 3 + }, + "energyValue": 42.667 + }, + { + "itemstack": { + "name": "minecraft:carpet", + "metaValue": 4 + }, + "energyValue": 42.667 + }, + { + "itemstack": { + "name": "minecraft:carpet", + "metaValue": 5 + }, + "energyValue": 42.667 + }, + { + "itemstack": { + "name": "minecraft:carpet", + "metaValue": 6 + }, + "energyValue": 42.667 + }, + { + "itemstack": { + "name": "minecraft:carpet", + "metaValue": 7 + }, + "energyValue": 42.667 + }, + { + "itemstack": { + "name": "minecraft:carpet", + "metaValue": 8 + }, + "energyValue": 42.667 + }, + { + "itemstack": { + "name": "minecraft:carpet", + "metaValue": 9 + }, + "energyValue": 42.667 + }, + { + "itemstack": { + "name": "minecraft:carpet", + "metaValue": 10 + }, + "energyValue": 42.667 + }, + { + "itemstack": { + "name": "minecraft:carpet", + "metaValue": 11 + }, + "energyValue": 42.667 + }, + { + "itemstack": { + "name": "minecraft:carpet", + "metaValue": 12 + }, + "energyValue": 42.667 + }, + { + "itemstack": { + "name": "minecraft:carpet", + "metaValue": 13 + }, + "energyValue": 42.667 + }, + { + "itemstack": { + "name": "minecraft:carpet", + "metaValue": 14 + }, + "energyValue": 42.667 + }, + { + "itemstack": { + "name": "minecraft:carpet", + "metaValue": 15 + }, + "energyValue": 42.667 + }, + { + "itemstack": { + "name": "minecraft:hardened_clay" + }, + "energyValue": 256.0 + }, + { + "itemstack": { + "name": "minecraft:coal_block" + }, + "energyValue": 288.0 + }, + { + "itemstack": { + "name": "minecraft:double_plant" + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:double_plant", + "metaValue": 1 + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:double_plant", + "metaValue": 2 + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:double_plant", + "metaValue": 3 + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:double_plant", + "metaValue": 4 + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:double_plant", + "metaValue": 5 + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:iron_shovel" + }, + "energyValue": 264.0 + }, + { + "itemstack": { + "name": "minecraft:iron_pickaxe" + }, + "energyValue": 776.0 + }, + { + "itemstack": { + "name": "minecraft:iron_axe" + }, + "energyValue": 776.0 + }, + { + "itemstack": { + "name": "minecraft:flint_and_steel" + }, + "energyValue": 260.0 + }, + { + "itemstack": { + "name": "minecraft:apple" + }, + "energyValue": 24.0 + }, + { + "itemstack": { + "name": "minecraft:bow" + }, + "energyValue": 48.0 + }, + { + "itemstack": { + "name": "minecraft:arrow" + }, + "energyValue": 14.0 + }, + { + "itemstack": { + "name": "minecraft:coal" + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:coal", + "metaValue": 1 + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:diamond" + }, + "energyValue": 8192.0 + }, + { + "itemstack": { + "name": "minecraft:iron_ingot" + }, + "energyValue": 256.0 + }, + { + "itemstack": { + "name": "minecraft:gold_ingot" + }, + "energyValue": 2048.0 + }, + { + "itemstack": { + "name": "minecraft:iron_sword" + }, + "energyValue": 516.0 + }, + { + "itemstack": { + "name": "minecraft:wooden_sword" + }, + "energyValue": 20.0 + }, + { + "itemstack": { + "name": "minecraft:wooden_shovel" + }, + "energyValue": 16.0 + }, + { + "itemstack": { + "name": "minecraft:wooden_pickaxe" + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:wooden_axe" + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:stone_sword" + }, + "energyValue": 6.0 + }, + { + "itemstack": { + "name": "minecraft:stone_shovel" + }, + "energyValue": 9.0 + }, + { + "itemstack": { + "name": "minecraft:stone_pickaxe" + }, + "energyValue": 11.0 + }, + { + "itemstack": { + "name": "minecraft:stone_axe" + }, + "energyValue": 11.0 + }, + { + "itemstack": { + "name": "minecraft:diamond_sword" + }, + "energyValue": 16388.0 + }, + { + "itemstack": { + "name": "minecraft:diamond_shovel" + }, + "energyValue": 8200.0 + }, + { + "itemstack": { + "name": "minecraft:diamond_pickaxe" + }, + "energyValue": 24584.0 + }, + { + "itemstack": { + "name": "minecraft:diamond_axe" + }, + "energyValue": 24584.0 + }, + { + "itemstack": { + "name": "minecraft:stick" + }, + "energyValue": 4.0 + }, + { + "itemstack": { + "name": "minecraft:bowl" + }, + "energyValue": 6.0 + }, + { + "itemstack": { + "name": "minecraft:mushroom_stew" + }, + "energyValue": 70.0 + }, + { + "itemstack": { + "name": "minecraft:golden_sword" + }, + "energyValue": 4100.0 + }, + { + "itemstack": { + "name": "minecraft:golden_shovel" + }, + "energyValue": 2056.0 + }, + { + "itemstack": { + "name": "minecraft:golden_pickaxe" + }, + "energyValue": 6152.0 + }, + { + "itemstack": { + "name": "minecraft:golden_axe" + }, + "energyValue": 6152.0 + }, + { + "itemstack": { + "name": "minecraft:string" + }, + "energyValue": 12.0 + }, + { + "itemstack": { + "name": "minecraft:feather" + }, + "energyValue": 48.0 + }, + { + "itemstack": { + "name": "minecraft:gunpowder" + }, + "energyValue": 192.0 + }, + { + "itemstack": { + "name": "minecraft:wooden_hoe" + }, + "energyValue": 24.0 + }, + { + "itemstack": { + "name": "minecraft:stone_hoe" + }, + "energyValue": 10.0 + }, + { + "itemstack": { + "name": "minecraft:iron_hoe" + }, + "energyValue": 520.0 + }, + { + "itemstack": { + "name": "minecraft:diamond_hoe" + }, + "energyValue": 16392.0 + }, + { + "itemstack": { + "name": "minecraft:golden_hoe" + }, + "energyValue": 4104.0 + }, + { + "itemstack": { + "name": "minecraft:wheat_seeds" + }, + "energyValue": 16.0 + }, + { + "itemstack": { + "name": "minecraft:wheat" + }, + "energyValue": 24.0 + }, + { + "itemstack": { + "name": "minecraft:bread" + }, + "energyValue": 72.0 + }, + { + "itemstack": { + "name": "minecraft:leather_helmet" + }, + "energyValue": 320.0 + }, + { + "itemstack": { + "name": "minecraft:leather_chestplate" + }, + "energyValue": 512.0 + }, + { + "itemstack": { + "name": "minecraft:leather_leggings" + }, + "energyValue": 448.0 + }, + { + "itemstack": { + "name": "minecraft:leather_boots" + }, + "energyValue": 256.0 + }, + { + "itemstack": { + "name": "minecraft:iron_helmet" + }, + "energyValue": 1280.0 + }, + { + "itemstack": { + "name": "minecraft:iron_chestplate" + }, + "energyValue": 2048.0 + }, + { + "itemstack": { + "name": "minecraft:iron_leggings" + }, + "energyValue": 1792.0 + }, + { + "itemstack": { + "name": "minecraft:iron_boots" + }, + "energyValue": 1024.0 + }, + { + "itemstack": { + "name": "minecraft:diamond_helmet" + }, + "energyValue": 40960.0 + }, + { + "itemstack": { + "name": "minecraft:diamond_chestplate" + }, + "energyValue": 65536.0 + }, + { + "itemstack": { + "name": "minecraft:diamond_leggings" + }, + "energyValue": 57344.0 + }, + { + "itemstack": { + "name": "minecraft:diamond_boots" + }, + "energyValue": 32768.0 + }, + { + "itemstack": { + "name": "minecraft:golden_helmet" + }, + "energyValue": 10240.0 + }, + { + "itemstack": { + "name": "minecraft:golden_chestplate" + }, + "energyValue": 16384.0 + }, + { + "itemstack": { + "name": "minecraft:golden_leggings" + }, + "energyValue": 14336.0 + }, + { + "itemstack": { + "name": "minecraft:golden_boots" + }, + "energyValue": 8192.0 + }, + { + "itemstack": { + "name": "minecraft:flint" + }, + "energyValue": 4.0 + }, + { + "itemstack": { + "name": "minecraft:porkchop" + }, + "energyValue": 24.0 + }, + { + "itemstack": { + "name": "minecraft:cooked_porkchop" + }, + "energyValue": 24.0 + }, + { + "itemstack": { + "name": "minecraft:painting" + }, + "energyValue": 80.0 + }, + { + "itemstack": { + "name": "minecraft:golden_apple" + }, + "energyValue": 16408.0 + }, + { + "itemstack": { + "name": "minecraft:golden_apple", + "metaValue": 1 + }, + "energyValue": 147480.0 + }, + { + "itemstack": { + "name": "minecraft:sign" + }, + "energyValue": 17.333 + }, + { + "itemstack": { + "name": "minecraft:wooden_door" + }, + "energyValue": 48.0 + }, + { + "itemstack": { + "name": "minecraft:bucket" + }, + "energyValue": 768.0 + }, + { + "itemstack": { + "name": "minecraft:water_bucket" + }, + "energyValue": 769.0 + }, + { + "itemstack": { + "name": "minecraft:lava_bucket" + }, + "energyValue": 832.0 + }, + { + "itemstack": { + "name": "minecraft:minecart" + }, + "energyValue": 1280.0 + }, + { + "itemstack": { + "name": "minecraft:saddle" + }, + "energyValue": 192.0 + }, + { + "itemstack": { + "name": "minecraft:iron_door" + }, + "energyValue": 1536.0 + }, + { + "itemstack": { + "name": "minecraft:redstone" + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:snowball" + }, + "energyValue": 0.25 + }, + { + "itemstack": { + "name": "minecraft:boat" + }, + "energyValue": 40.0 + }, + { + "itemstack": { + "name": "minecraft:leather" + }, + "energyValue": 64.0 + }, + { + "itemstack": { + "name": "minecraft:milk_bucket" + }, + "energyValue": 832.0 + }, + { + "itemstack": { + "name": "minecraft:brick" + }, + "energyValue": 64.0 + }, + { + "itemstack": { + "name": "minecraft:clay_ball" + }, + "energyValue": 64.0 + }, + { + "itemstack": { + "name": "minecraft:reeds" + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:paper" + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:book" + }, + "energyValue": 160.0 + }, + { + "itemstack": { + "name": "minecraft:slime_ball" + }, + "energyValue": 24.0 + }, + { + "itemstack": { + "name": "minecraft:chest_minecart" + }, + "energyValue": 1344.0 + }, + { + "itemstack": { + "name": "minecraft:furnace_minecart" + }, + "energyValue": 1288.0 + }, + { + "itemstack": { + "name": "minecraft:egg" + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:compass" + }, + "energyValue": 1056.0 + }, + { + "itemstack": { + "name": "minecraft:fishing_rod" + }, + "energyValue": 36.0 + }, + { + "itemstack": { + "name": "minecraft:clock" + }, + "energyValue": 8224.0 + }, + { + "itemstack": { + "name": "minecraft:glowstone_dust" + }, + "energyValue": 384.0 + }, + { + "itemstack": { + "name": "minecraft:fish" + }, + "energyValue": 24.0 + }, + { + "itemstack": { + "name": "minecraft:fish", + "metaValue": 1 + }, + "energyValue": 24.0 + }, + { + "itemstack": { + "name": "minecraft:fish", + "metaValue": 2 + }, + "energyValue": 24.0 + }, + { + "itemstack": { + "name": "minecraft:fish", + "metaValue": 3 + }, + "energyValue": 24.0 + }, + { + "itemstack": { + "name": "minecraft:cooked_fished" + }, + "energyValue": 24.0 + }, + { + "itemstack": { + "name": "minecraft:cooked_fished", + "metaValue": 1 + }, + "energyValue": 24.0 + }, + { + "itemstack": { + "name": "minecraft:dye" + }, + "energyValue": 16.0 + }, + { + "itemstack": { + "name": "minecraft:dye", + "metaValue": 1 + }, + "energyValue": 16.0 + }, + { + "itemstack": { + "name": "minecraft:dye", + "metaValue": 2 + }, + "energyValue": 16.0 + }, + { + "itemstack": { + "name": "minecraft:dye", + "metaValue": 3 + }, + "energyValue": 16.0 + }, + { + "itemstack": { + "name": "minecraft:dye", + "metaValue": 4 + }, + "energyValue": 864.0 + }, + { + "itemstack": { + "name": "minecraft:dye", + "metaValue": 5 + }, + "energyValue": 16.0 + }, + { + "itemstack": { + "name": "minecraft:dye", + "metaValue": 6 + }, + "energyValue": 16.0 + }, + { + "itemstack": { + "name": "minecraft:dye", + "metaValue": 7 + }, + "energyValue": 16.0 + }, + { + "itemstack": { + "name": "minecraft:dye", + "metaValue": 8 + }, + "energyValue": 16.0 + }, + { + "itemstack": { + "name": "minecraft:dye", + "metaValue": 9 + }, + "energyValue": 16.0 + }, + { + "itemstack": { + "name": "minecraft:dye", + "metaValue": 10 + }, + "energyValue": 16.0 + }, + { + "itemstack": { + "name": "minecraft:dye", + "metaValue": 11 + }, + "energyValue": 16.0 + }, + { + "itemstack": { + "name": "minecraft:dye", + "metaValue": 12 + }, + "energyValue": 16.0 + }, + { + "itemstack": { + "name": "minecraft:dye", + "metaValue": 13 + }, + "energyValue": 16.0 + }, + { + "itemstack": { + "name": "minecraft:dye", + "metaValue": 14 + }, + "energyValue": 16.0 + }, + { + "itemstack": { + "name": "minecraft:dye", + "metaValue": 15 + }, + "energyValue": 16.0 + }, + { + "itemstack": { + "name": "minecraft:bone" + }, + "energyValue": 48.0 + }, + { + "itemstack": { + "name": "minecraft:sugar" + }, + "energyValue": 32.0 + }, + { + "itemstack": { + "name": "minecraft:cake" + }, + "energyValue": 360.0 + }, + { + "itemstack": { + "name": "minecraft:repeater" + }, + "energyValue": 107.0 + }, + { + "itemstack": { + "name": "minecraft:cookie" + }, + "energyValue": 8.0 + }, + { + "itemstack": { + "name": "minecraft:shears" + }, + "energyValue": 512.0 + }, + { + "itemstack": { + "name": "minecraft:melon" + }, + "energyValue": 16.0 + }, + { + "itemstack": { + "name": "minecraft:pumpkin_seeds" + }, + "energyValue": 36.0 + }, + { + "itemstack": { + "name": "minecraft:melon_seeds" + }, + "energyValue": 16.0 + }, + { + "itemstack": { + "name": "minecraft:beef" + }, + "energyValue": 24.0 + }, + { + "itemstack": { + "name": "minecraft:cooked_beef" + }, + "energyValue": 24.0 + }, + { + "itemstack": { + "name": "minecraft:chicken" + }, + "energyValue": 24.0 + }, + { + "itemstack": { + "name": "minecraft:cooked_chicken" + }, + "energyValue": 24.0 + }, + { + "itemstack": { + "name": "minecraft:rotten_flesh" + }, + "energyValue": 24.0 + }, + { + "itemstack": { + "name": "minecraft:ender_pearl" + }, + "energyValue": 1024.0 + }, + { + "itemstack": { + "name": "minecraft:blaze_rod" + }, + "energyValue": 1536.0 + }, + { + "itemstack": { + "name": "minecraft:ghast_tear" + }, + "energyValue": 4096.0 + }, + { + "itemstack": { + "name": "minecraft:gold_nugget" + }, + "energyValue": 227.556 + }, + { + "itemstack": { + "name": "minecraft:nether_wart" + }, + "energyValue": 24.0 + }, + { + "itemstack": { + "name": "minecraft:potion" + }, + "energyValue": 2.0 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 16 + }, + "energyValue": 8.667 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 8193 + }, + "energyValue": 1368.222 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 8194 + }, + "energyValue": 13.556 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 8196 + }, + "energyValue": 45.556 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 8201 + }, + "energyValue": 258.889 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 8225 + }, + "energyValue": 163.064 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 8226 + }, + "energyValue": 132.519 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 8228 + }, + "energyValue": 138.044 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 8229 + }, + "energyValue": 168.557 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 8233 + }, + "energyValue": 149.369 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 8236 + }, + "energyValue": 111.728 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 8257 + }, + "energyValue": 76.151 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 8258 + }, + "energyValue": 15.185 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 8260 + }, + "energyValue": 20.711 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 8262 + }, + "energyValue": 77.396 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 8264 + }, + "energyValue": 32.963 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 8265 + }, + "energyValue": 62.455 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 8266 + }, + "energyValue": 85.468 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 8270 + }, + "energyValue": 54.243 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 16385 + }, + "energyValue": 520.074 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 16386 + }, + "energyValue": 68.519 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 16388 + }, + "energyValue": 79.185 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 16393 + }, + "energyValue": 150.296 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 16417 + }, + "energyValue": 129.484 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 16418 + }, + "energyValue": 108.173 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 16420 + }, + "energyValue": 111.728 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 16421 + }, + "energyValue": 120.186 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 16425 + }, + "energyValue": 115.789 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 16428 + }, + "energyValue": 101.243 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 16449 + }, + "energyValue": 63.509 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 16450 + }, + "energyValue": 33.506 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 16452 + }, + "energyValue": 26.636 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 16454 + }, + "energyValue": 54.243 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 16456 + }, + "energyValue": 39.432 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 16457 + }, + "energyValue": 49.813 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 16458 + }, + "energyValue": 84.551 + }, + { + "itemstack": { + "name": "minecraft:potion", + "metaValue": 16462 + }, + "energyValue": 61.989 + }, + { + "itemstack": { + "name": "minecraft:glass_bottle" + }, + "energyValue": 1.0 + }, + { + "itemstack": { + "name": "minecraft:spider_eye" + }, + "energyValue": 128.0 + }, + { + "itemstack": { + "name": "minecraft:fermented_spider_eye" + }, + "energyValue": 192.0 + }, + { + "itemstack": { + "name": "minecraft:blaze_powder" + }, + "energyValue": 768.0 + }, + { + "itemstack": { + "name": "minecraft:magma_cream" + }, + "energyValue": 792.0 + }, + { + "itemstack": { + "name": "minecraft:brewing_stand" + }, + "energyValue": 1539.0 + }, + { + "itemstack": { + "name": "minecraft:ender_eye" + }, + "energyValue": 1792.0 + }, + { + "itemstack": { + "name": "minecraft:speckled_melon" + }, + "energyValue": 1836.448 + }, + { + "itemstack": { + "name": "minecraft:fire_charge" + }, + "energyValue": 330.667 + }, + { + "itemstack": { + "name": "minecraft:writable_book" + }, + "energyValue": 224.0 + }, + { + "itemstack": { + "name": "minecraft:emerald" + }, + "energyValue": 8192.0 + }, + { + "itemstack": { + "name": "minecraft:flower_pot" + }, + "energyValue": 192.0 + }, + { + "itemstack": { + "name": "minecraft:carrot" + }, + "energyValue": 24.0 + }, + { + "itemstack": { + "name": "minecraft:potato" + }, + "energyValue": 24.0 + }, + { + "itemstack": { + "name": "minecraft:baked_potato" + }, + "energyValue": 24.0 + }, + { + "itemstack": { + "name": "minecraft:poisonous_potato" + }, + "energyValue": 24.0 + }, + { + "itemstack": { + "name": "minecraft:map" + }, + "energyValue": 1312.0 + }, + { + "itemstack": { + "name": "minecraft:golden_carrot" + }, + "energyValue": 1844.448 + }, + { + "itemstack": { + "name": "minecraft:carrot_on_a_stick" + }, + "energyValue": 60.0 + }, + { + "itemstack": { + "name": "minecraft:nether_star" + }, + "energyValue": 24576.0 + }, + { + "itemstack": { + "name": "minecraft:pumpkin_pie" + }, + "energyValue": 208.0 + }, + { + "itemstack": { + "name": "minecraft:comparator" + }, + "energyValue": 367.0 + }, + { + "itemstack": { + "name": "minecraft:netherbrick" + }, + "energyValue": 1.0 + }, + { + "itemstack": { + "name": "minecraft:quartz" + }, + "energyValue": 256.0 + }, + { + "itemstack": { + "name": "minecraft:tnt_minecart" + }, + "energyValue": 2244.0 + }, + { + "itemstack": { + "name": "minecraft:hopper_minecart" + }, + "energyValue": 2624.0 + }, + { + "itemstack": { + "name": "minecraft:lead" + }, + "energyValue": 36.0 + }, + { + "itemstack": { + "name": "minecraft:record_13" + }, + "energyValue": 2048.0 + }, + { + "itemstack": { + "name": "minecraft:record_cat" + }, + "energyValue": 2048.0 + }, + { + "itemstack": { + "name": "minecraft:record_blocks" + }, + "energyValue": 2048.0 + }, + { + "itemstack": { + "name": "minecraft:record_chirp" + }, + "energyValue": 2048.0 + }, + { + "itemstack": { + "name": "minecraft:record_far" + }, + "energyValue": 2048.0 + }, + { + "itemstack": { + "name": "minecraft:record_mellohi" + }, + "energyValue": 2048.0 + }, + { + "itemstack": { + "name": "minecraft:record_stal" + }, + "energyValue": 2048.0 + }, + { + "itemstack": { + "name": "minecraft:record_strad" + }, + "energyValue": 2048.0 + }, + { + "itemstack": { + "name": "minecraft:record_ward" + }, + "energyValue": 2048.0 + }, + { + "itemstack": { + "name": "minecraft:record_11" + }, + "energyValue": 2048.0 + }, + { + "itemstack": { + "name": "minecraft:record_wait" + }, + "energyValue": 2048.0 + } ] \ No newline at end of file