Broken stuff
This commit is contained in:
parent
cf6a1bf77a
commit
301e8b75c7
13 changed files with 1706 additions and 1615 deletions
|
@ -124,11 +124,9 @@ public class EquivalentExchange3
|
||||||
{
|
{
|
||||||
WorldEventHandler.hasInitilialized = false;
|
WorldEventHandler.hasInitilialized = false;
|
||||||
|
|
||||||
EnergyValueRegistry.getInstance().saveEnergyValueRegistryToFile();
|
EnergyValueRegistry.getInstance().save();
|
||||||
|
|
||||||
TransmutationKnowledgeRegistry.getInstance().saveAll();
|
TransmutationKnowledgeRegistry.getInstance().saveAll();
|
||||||
|
AbilityRegistry.getInstance().save();
|
||||||
AbilityRegistry.getInstance().saveAbilityRegistryToFile();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public EnergyValueRegistry getEnergyValueRegistry()
|
public EnergyValueRegistry getEnergyValueRegistry()
|
||||||
|
|
|
@ -458,7 +458,7 @@ public class EnergyValueRegistry implements INBTTaggable, JsonSerializer<EnergyV
|
||||||
|
|
||||||
// Serialize values to disk
|
// Serialize values to disk
|
||||||
LogHelper.info("Saving energy values to disk");
|
LogHelper.info("Saving energy values to disk");
|
||||||
saveEnergyValueRegistryToFile();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateValueStackMappings()
|
private void generateValueStackMappings()
|
||||||
|
@ -707,7 +707,7 @@ public class EnergyValueRegistry implements INBTTaggable, JsonSerializer<EnergyV
|
||||||
return valueMappings;
|
return valueMappings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveEnergyValueRegistryToFile()
|
public void save()
|
||||||
{
|
{
|
||||||
File energyValuesDataDirectory = new File(FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getSaveHandler().getWorldDirectory(), "data" + File.separator + Reference.LOWERCASE_MOD_ID + File.separator + "energyvalues");
|
File energyValuesDataDirectory = new File(FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getSaveHandler().getWorldDirectory(), "data" + File.separator + Reference.LOWERCASE_MOD_ID + File.separator + "energyvalues");
|
||||||
energyValuesDataDirectory.mkdirs();
|
energyValuesDataDirectory.mkdirs();
|
||||||
|
@ -715,24 +715,39 @@ public class EnergyValueRegistry implements INBTTaggable, JsonSerializer<EnergyV
|
||||||
if (shouldRegenNextRestart)
|
if (shouldRegenNextRestart)
|
||||||
{
|
{
|
||||||
File staticEnergyValuesFile = new File(energyValuesDataDirectory, Files.STATIC_ENERGY_VALUES);
|
File staticEnergyValuesFile = new File(energyValuesDataDirectory, Files.STATIC_ENERGY_VALUES);
|
||||||
|
File staticEnergyValuesJsonFile = new File(energyValuesDataDirectory, Files.STATIC_ENERGY_VALUES_JSON);
|
||||||
File md5EnergyValuesFile = new File(energyValuesDataDirectory, SerializationHelper.getModListMD5() + ".dat");
|
File md5EnergyValuesFile = new File(energyValuesDataDirectory, SerializationHelper.getModListMD5() + ".dat");
|
||||||
|
File md5EnergyValuesJsonFile = new File(energyValuesDataDirectory, SerializationHelper.getModListMD5() + ".json");
|
||||||
|
|
||||||
|
// NBT
|
||||||
if (staticEnergyValuesFile.exists())
|
if (staticEnergyValuesFile.exists())
|
||||||
{
|
{
|
||||||
staticEnergyValuesFile.delete();
|
staticEnergyValuesFile.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (md5EnergyValuesFile.exists())
|
if (md5EnergyValuesFile.exists())
|
||||||
{
|
{
|
||||||
md5EnergyValuesFile.delete();
|
md5EnergyValuesFile.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// JSON
|
||||||
|
if (staticEnergyValuesJsonFile.exists())
|
||||||
|
{
|
||||||
|
staticEnergyValuesJsonFile.delete();
|
||||||
|
}
|
||||||
|
if (md5EnergyValuesJsonFile.exists())
|
||||||
|
{
|
||||||
|
md5EnergyValuesJsonFile.delete();
|
||||||
|
}
|
||||||
|
|
||||||
shouldRegenNextRestart = false;
|
shouldRegenNextRestart = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SerializationHelper.writeNBTToFile(energyValuesDataDirectory, Files.STATIC_ENERGY_VALUES, this);
|
SerializationHelper.writeNBTToFile(energyValuesDataDirectory, Files.STATIC_ENERGY_VALUES, this);
|
||||||
SerializationHelper.writeNBTToFile(energyValuesDataDirectory, SerializationHelper.getModListMD5() + ".dat", this);
|
SerializationHelper.writeNBTToFile(energyValuesDataDirectory, SerializationHelper.getModListMD5() + ".dat", this);
|
||||||
|
|
||||||
|
SerializationHelper.writeEnergyValueStackMapToJsonFile(new File(energyValuesDataDirectory, Files.STATIC_ENERGY_VALUES_JSON), energyValueRegistry.stackMappings);
|
||||||
|
SerializationHelper.writeEnergyValueStackMapToJsonFile(new File(energyValuesDataDirectory, SerializationHelper.getModListMD5() + ".json"), energyValueRegistry.stackMappings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -744,6 +759,9 @@ public class EnergyValueRegistry implements INBTTaggable, JsonSerializer<EnergyV
|
||||||
File staticEnergyValuesFile = new File(energyValuesDataDirectory, Files.STATIC_ENERGY_VALUES);
|
File staticEnergyValuesFile = new File(energyValuesDataDirectory, Files.STATIC_ENERGY_VALUES);
|
||||||
File md5EnergyValuesFile = new File(energyValuesDataDirectory, SerializationHelper.getModListMD5() + ".dat");
|
File md5EnergyValuesFile = new File(energyValuesDataDirectory, SerializationHelper.getModListMD5() + ".dat");
|
||||||
|
|
||||||
|
File staticEnergyValuesJsonFile = new File(energyValuesDataDirectory, Files.STATIC_ENERGY_VALUES_JSON);
|
||||||
|
File md5EnergyValuesJsonFile = new File(energyValuesDataDirectory, SerializationHelper.getModListMD5() + ".json");
|
||||||
|
|
||||||
NBTTagCompound nbtTagCompound = null;
|
NBTTagCompound nbtTagCompound = null;
|
||||||
|
|
||||||
// TODO Re-enable this once the NPE related to mod changes in the serialized value file bug is resolved
|
// TODO Re-enable this once the NPE related to mod changes in the serialized value file bug is resolved
|
||||||
|
|
|
@ -272,27 +272,27 @@ public class WrappedStack implements Comparable<WrappedStack>, JsonDeserializer<
|
||||||
{
|
{
|
||||||
NBTTagCompound wrappedItemTagCompound = new NBTTagCompound();
|
NBTTagCompound wrappedItemTagCompound = new NBTTagCompound();
|
||||||
((ItemStack) wrappedStack.getWrappedObject()).writeToNBT(wrappedItemTagCompound);
|
((ItemStack) wrappedStack.getWrappedObject()).writeToNBT(wrappedItemTagCompound);
|
||||||
wrappedStackTagCompound.setInteger("wrappedStack_type", 0);
|
wrappedStackTagCompound.setInteger("type", 0);
|
||||||
wrappedStackTagCompound.setTag("wrappedStack_data", wrappedItemTagCompound);
|
wrappedStackTagCompound.setTag("objectData", wrappedItemTagCompound);
|
||||||
wrappedStackTagCompound.setInteger("wrappedStack_stackSize", wrappedStack.getStackSize());
|
wrappedStackTagCompound.setInteger("stackSize", wrappedStack.getStackSize());
|
||||||
return wrappedStackTagCompound;
|
return wrappedStackTagCompound;
|
||||||
}
|
}
|
||||||
else if (wrappedStack.getWrappedObject() instanceof OreStack)
|
else if (wrappedStack.getWrappedObject() instanceof OreStack)
|
||||||
{
|
{
|
||||||
NBTTagCompound wrappedOreTagCompound = new NBTTagCompound();
|
NBTTagCompound wrappedOreTagCompound = new NBTTagCompound();
|
||||||
((OreStack) wrappedStack.getWrappedObject()).writeToNBT(wrappedOreTagCompound);
|
((OreStack) wrappedStack.getWrappedObject()).writeToNBT(wrappedOreTagCompound);
|
||||||
wrappedStackTagCompound.setInteger("wrappedStack_type", 1);
|
wrappedStackTagCompound.setInteger("type", 1);
|
||||||
wrappedStackTagCompound.setTag("wrappedStack_data", wrappedOreTagCompound);
|
wrappedStackTagCompound.setTag("objectData", wrappedOreTagCompound);
|
||||||
wrappedStackTagCompound.setInteger("wrappedStack_stackSize", wrappedStack.getStackSize());
|
wrappedStackTagCompound.setInteger("stackSize", wrappedStack.getStackSize());
|
||||||
return wrappedStackTagCompound;
|
return wrappedStackTagCompound;
|
||||||
}
|
}
|
||||||
else if (wrappedStack.getWrappedObject() instanceof FluidStack)
|
else if (wrappedStack.getWrappedObject() instanceof FluidStack)
|
||||||
{
|
{
|
||||||
NBTTagCompound wrappedFluidTagCompound = new NBTTagCompound();
|
NBTTagCompound wrappedFluidTagCompound = new NBTTagCompound();
|
||||||
((FluidStack) wrappedStack.getWrappedObject()).writeToNBT(wrappedFluidTagCompound);
|
((FluidStack) wrappedStack.getWrappedObject()).writeToNBT(wrappedFluidTagCompound);
|
||||||
wrappedStackTagCompound.setInteger("wrappedStack_type", 2);
|
wrappedStackTagCompound.setInteger("type", 2);
|
||||||
wrappedStackTagCompound.setTag("wrappedStack_data", wrappedFluidTagCompound);
|
wrappedStackTagCompound.setTag("objectData", wrappedFluidTagCompound);
|
||||||
wrappedStackTagCompound.setInteger("wrappedStack_stackSize", wrappedStack.getStackSize());
|
wrappedStackTagCompound.setInteger("stackSize", wrappedStack.getStackSize());
|
||||||
return wrappedStackTagCompound;
|
return wrappedStackTagCompound;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -302,24 +302,24 @@ public class WrappedStack implements Comparable<WrappedStack>, JsonDeserializer<
|
||||||
|
|
||||||
public static WrappedStack fromNBTTagCompound(NBTTagCompound nbtTagCompound)
|
public static WrappedStack fromNBTTagCompound(NBTTagCompound nbtTagCompound)
|
||||||
{
|
{
|
||||||
if (nbtTagCompound.hasKey("wrappedStack_type") && nbtTagCompound.hasKey("wrappedStack_data") && nbtTagCompound.hasKey("wrappedStack_stackSize"))
|
if (nbtTagCompound.hasKey("type") && nbtTagCompound.hasKey("objectData") && nbtTagCompound.hasKey("stackSize"))
|
||||||
{
|
{
|
||||||
int objectType = nbtTagCompound.getInteger("wrappedStack_type");
|
int objectType = nbtTagCompound.getInteger("type");
|
||||||
int stackSize = nbtTagCompound.getInteger("wrappedStack_stackSize");
|
int stackSize = nbtTagCompound.getInteger("stackSize");
|
||||||
|
|
||||||
if (objectType == 0)
|
if (objectType == 0)
|
||||||
{
|
{
|
||||||
ItemStack itemStack = ItemStack.loadItemStackFromNBT(nbtTagCompound.getCompoundTag("wrappedStack_data"));
|
ItemStack itemStack = ItemStack.loadItemStackFromNBT(nbtTagCompound.getCompoundTag("objectData"));
|
||||||
return new WrappedStack(itemStack, stackSize);
|
return new WrappedStack(itemStack, stackSize);
|
||||||
}
|
}
|
||||||
else if (objectType == 1)
|
else if (objectType == 1)
|
||||||
{
|
{
|
||||||
OreStack oreStack = OreStack.loadOreStackFromNBT(nbtTagCompound.getCompoundTag("wrappedStack_data"));
|
OreStack oreStack = OreStack.loadOreStackFromNBT(nbtTagCompound.getCompoundTag("objectData"));
|
||||||
return new WrappedStack(oreStack, stackSize);
|
return new WrappedStack(oreStack, stackSize);
|
||||||
}
|
}
|
||||||
else if (objectType == 2)
|
else if (objectType == 2)
|
||||||
{
|
{
|
||||||
FluidStack fluidStack = FluidStack.loadFluidStackFromNBT(nbtTagCompound.getCompoundTag("wrappedStack_data"));
|
FluidStack fluidStack = FluidStack.loadFluidStackFromNBT(nbtTagCompound.getCompoundTag("objectData"));
|
||||||
return new WrappedStack(fluidStack, stackSize);
|
return new WrappedStack(fluidStack, stackSize);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -401,23 +401,23 @@ public class WrappedStack implements Comparable<WrappedStack>, JsonDeserializer<
|
||||||
String objectType = null;
|
String objectType = null;
|
||||||
Object stackObject = null;
|
Object stackObject = null;
|
||||||
|
|
||||||
if (jsonWrappedStack.get("wrappedStack_type") != null)
|
if (jsonWrappedStack.get("type") != null)
|
||||||
{
|
{
|
||||||
objectType = jsonWrappedStack.get("wrappedStack_type").getAsString();
|
objectType = jsonWrappedStack.get("type").getAsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jsonWrappedStack.get("wrappedStack_stackSize") != null)
|
if (jsonWrappedStack.get("stackSize") != null)
|
||||||
{
|
{
|
||||||
stackSize = jsonWrappedStack.get("wrappedStack_stackSize").getAsInt();
|
stackSize = jsonWrappedStack.get("stackSize").getAsInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jsonWrappedStack.get("wrappedStack_data") != null && !jsonWrappedStack.get("wrappedStack_data").isJsonPrimitive())
|
if (jsonWrappedStack.get("objectData") != null && !jsonWrappedStack.get("objectData").isJsonPrimitive())
|
||||||
{
|
{
|
||||||
if (objectType != null)
|
if (objectType != null)
|
||||||
{
|
{
|
||||||
if (objectType.equalsIgnoreCase("ItemStack"))
|
if (objectType.equalsIgnoreCase("ItemStack"))
|
||||||
{
|
{
|
||||||
JsonItemStack jsonItemStack = JsonItemStack.jsonSerializer.fromJson(jsonWrappedStack.get("wrappedStack_data"), JsonItemStack.class);
|
JsonItemStack jsonItemStack = JsonItemStack.jsonSerializer.fromJson(jsonWrappedStack.get("objectData"), JsonItemStack.class);
|
||||||
ItemStack itemStack = null;
|
ItemStack itemStack = null;
|
||||||
Item item = (Item) Item.itemRegistry.getObject(jsonItemStack.itemName);
|
Item item = (Item) Item.itemRegistry.getObject(jsonItemStack.itemName);
|
||||||
if (stackSize > 0 && item != null)
|
if (stackSize > 0 && item != null)
|
||||||
|
@ -432,7 +432,7 @@ public class WrappedStack implements Comparable<WrappedStack>, JsonDeserializer<
|
||||||
}
|
}
|
||||||
else if (objectType.equalsIgnoreCase("OreStack"))
|
else if (objectType.equalsIgnoreCase("OreStack"))
|
||||||
{
|
{
|
||||||
OreStack oreStack = jsonSerializer.fromJson(jsonWrappedStack.get("wrappedStack_data"), OreStack.class);
|
OreStack oreStack = jsonSerializer.fromJson(jsonWrappedStack.get("objectData"), OreStack.class);
|
||||||
|
|
||||||
if (stackSize > 0)
|
if (stackSize > 0)
|
||||||
{
|
{
|
||||||
|
@ -442,7 +442,7 @@ public class WrappedStack implements Comparable<WrappedStack>, JsonDeserializer<
|
||||||
}
|
}
|
||||||
else if (objectType.equalsIgnoreCase("FluidStack"))
|
else if (objectType.equalsIgnoreCase("FluidStack"))
|
||||||
{
|
{
|
||||||
FluidStack fluidStack = jsonSerializer.fromJson(jsonWrappedStack.get("wrappedStack_data"), FluidStack.class);
|
FluidStack fluidStack = jsonSerializer.fromJson(jsonWrappedStack.get("objectData"), FluidStack.class);
|
||||||
|
|
||||||
if (stackSize > 0)
|
if (stackSize > 0)
|
||||||
{
|
{
|
||||||
|
@ -490,8 +490,8 @@ public class WrappedStack implements Comparable<WrappedStack>, JsonDeserializer<
|
||||||
|
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
|
|
||||||
jsonWrappedStack.addProperty("wrappedStack_type", wrappedStack.objectType);
|
jsonWrappedStack.addProperty("type", wrappedStack.objectType);
|
||||||
jsonWrappedStack.addProperty("wrappedStack_stackSize", wrappedStack.stackSize);
|
jsonWrappedStack.addProperty("stackSize", wrappedStack.stackSize);
|
||||||
|
|
||||||
if (wrappedStack.wrappedStack instanceof ItemStack)
|
if (wrappedStack.wrappedStack instanceof ItemStack)
|
||||||
{
|
{
|
||||||
|
@ -502,15 +502,15 @@ public class WrappedStack implements Comparable<WrappedStack>, JsonDeserializer<
|
||||||
{
|
{
|
||||||
jsonItemStack.itemNBTTagCompound = ((ItemStack) wrappedStack.wrappedStack).stackTagCompound;
|
jsonItemStack.itemNBTTagCompound = ((ItemStack) wrappedStack.wrappedStack).stackTagCompound;
|
||||||
}
|
}
|
||||||
jsonWrappedStack.add("wrappedStack_data", JsonItemStack.jsonSerializer.toJsonTree(jsonItemStack, JsonItemStack.class));
|
jsonWrappedStack.add("objectData", JsonItemStack.jsonSerializer.toJsonTree(jsonItemStack, JsonItemStack.class));
|
||||||
}
|
}
|
||||||
else if (wrappedStack.wrappedStack instanceof OreStack)
|
else if (wrappedStack.wrappedStack instanceof OreStack)
|
||||||
{
|
{
|
||||||
jsonWrappedStack.add("wrappedStack_data", gson.toJsonTree(wrappedStack.wrappedStack, OreStack.class));
|
jsonWrappedStack.add("objectData", gson.toJsonTree(wrappedStack.wrappedStack, OreStack.class));
|
||||||
}
|
}
|
||||||
else if (wrappedStack.wrappedStack instanceof FluidStack)
|
else if (wrappedStack.wrappedStack instanceof FluidStack)
|
||||||
{
|
{
|
||||||
jsonWrappedStack.add("wrappedStack_data", gson.toJsonTree(wrappedStack.wrappedStack, FluidStack.class));
|
jsonWrappedStack.add("objectData", gson.toJsonTree(wrappedStack.wrappedStack, FluidStack.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
return jsonWrappedStack;
|
return jsonWrappedStack;
|
||||||
|
|
|
@ -14,7 +14,7 @@ public class AbilityRegistrySerializationHandler
|
||||||
{
|
{
|
||||||
if (FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getWorldTime() % 600 == 0)
|
if (FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getWorldTime() % 600 == 0)
|
||||||
{
|
{
|
||||||
AbilityRegistry.getInstance().saveAbilityRegistryToFile();
|
AbilityRegistry.getInstance().save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,6 +241,13 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (slotIndex >= TileEntityTransmutationTablet.INVENTORY_SIZE && slotIndex < 40)
|
||||||
|
{
|
||||||
|
// if (!this.mergeItemStackFromTransmutationOutput(slotItemStack, TileEntityTransmutationTablet.INVENTORY_SIZE, inventorySlots.size(), false))
|
||||||
|
// {
|
||||||
|
return null;
|
||||||
|
// }
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (slotItemStack.getItem() instanceof ItemAlchemicalTome)
|
if (slotItemStack.getItem() instanceof ItemAlchemicalTome)
|
||||||
|
@ -279,6 +286,21 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen
|
||||||
return itemStack;
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack slotClick(int slotIndex, int mouseButton, int shiftPressed, EntityPlayer entityPlayer)
|
||||||
|
{
|
||||||
|
if (slotIndex < TileEntityTransmutationTablet.INVENTORY_SIZE)
|
||||||
|
{
|
||||||
|
return super.slotClick(slotIndex, mouseButton, shiftPressed, entityPlayer);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return super.slotClick(slotIndex, mouseButton, shiftPressed, entityPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
// return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleElementButtonClick(String elementName, int mouseButton)
|
public void handleElementButtonClick(String elementName, int mouseButton)
|
||||||
{
|
{
|
||||||
|
@ -395,13 +417,14 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen
|
||||||
@Override
|
@Override
|
||||||
public boolean canTakeStack(EntityPlayer entityPlayer)
|
public boolean canTakeStack(EntityPlayer entityPlayer)
|
||||||
{
|
{
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickupFromSlot(EntityPlayer entityPlayer, ItemStack itemStack)
|
public void onPickupFromSlot(EntityPlayer entityPlayer, ItemStack itemStack)
|
||||||
{
|
{
|
||||||
super.onPickupFromSlot(entityPlayer, itemStack);
|
super.onPickupFromSlot(entityPlayer, itemStack);
|
||||||
|
this.containerTransmutationTablet.tileEntityTransmutationTablet.consumeInventoryForEnergyValue(itemStack);
|
||||||
this.containerTransmutationTablet.inventoryTransmutationTablet.setInventorySlotContents(this.getSlotIndex(), new ItemStack(itemStack.getItem(), 1, itemStack.getItemDamage()));
|
this.containerTransmutationTablet.inventoryTransmutationTablet.setInventorySlotContents(this.getSlotIndex(), new ItemStack(itemStack.getItem(), 1, itemStack.getItemDamage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -241,7 +241,7 @@ public class AbilityRegistry implements JsonSerializer<AbilityRegistry>, JsonDes
|
||||||
return jsonAbilityRegistry;
|
return jsonAbilityRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveAbilityRegistryToFile()
|
public void save()
|
||||||
{
|
{
|
||||||
if (abilityDirectory != null)
|
if (abilityDirectory != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,7 +6,7 @@ import java.util.Comparator;
|
||||||
|
|
||||||
public class Comparators
|
public class Comparators
|
||||||
{
|
{
|
||||||
public static final Comparator[] itemComparators = {ItemHelper.displayNameComparator, ItemHelper.energyValueComparator, ItemHelper.idComparator};
|
public static final Comparator[] itemComparators = {ItemHelper.displayNameComparator, ItemHelper.energyValueItemStackComparator, ItemHelper.idComparator};
|
||||||
|
|
||||||
public static Comparator<String> stringComparator = new Comparator<String>()
|
public static Comparator<String> stringComparator = new Comparator<String>()
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,4 +7,5 @@ public class Files
|
||||||
public static final String TEMPLATE_JSON_FILE = "template.json";
|
public static final String TEMPLATE_JSON_FILE = "template.json";
|
||||||
public static final String ABILITIES_JSON_FILE = "abilities.json";
|
public static final String ABILITIES_JSON_FILE = "abilities.json";
|
||||||
public static final String STATIC_ENERGY_VALUES = "energy-values.dat";
|
public static final String STATIC_ENERGY_VALUES = "energy-values.dat";
|
||||||
|
public static final String STATIC_ENERGY_VALUES_JSON = "energy-values.json";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
package com.pahimar.ee3.test;
|
package com.pahimar.ee3.test;
|
||||||
|
|
||||||
|
import com.pahimar.ee3.reference.Reference;
|
||||||
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
public class VanillaEnergyValueTest extends EnergyValueMappingsTestSuite
|
public class VanillaEnergyValueTest extends EnergyValueMappingsTestSuite
|
||||||
{
|
{
|
||||||
public VanillaEnergyValueTest()
|
public VanillaEnergyValueTest()
|
||||||
|
@ -595,4 +599,11 @@ public class VanillaEnergyValueTest extends EnergyValueMappingsTestSuite
|
||||||
add(Items.netherbrick, 1);
|
add(Items.netherbrick, 1);
|
||||||
add(Items.quartz, 256);
|
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"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.pahimar.ee3.tileentity;
|
package com.pahimar.ee3.tileentity;
|
||||||
|
|
||||||
import com.pahimar.ee3.api.EnergyValue;
|
import com.pahimar.ee3.api.EnergyValue;
|
||||||
|
import com.pahimar.ee3.api.EnergyValueRegistryProxy;
|
||||||
import com.pahimar.ee3.block.BlockAshInfusedStoneSlab;
|
import com.pahimar.ee3.block.BlockAshInfusedStoneSlab;
|
||||||
import com.pahimar.ee3.exchange.EnergyValueRegistry;
|
import com.pahimar.ee3.exchange.EnergyValueRegistry;
|
||||||
import com.pahimar.ee3.item.ItemAlchemicalTome;
|
import com.pahimar.ee3.item.ItemAlchemicalTome;
|
||||||
|
@ -59,14 +60,53 @@ public class TileEntityTransmutationTablet extends TileEntityEE implements ISide
|
||||||
return storedEnergyValue;
|
return storedEnergyValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void consumeInventoryForEnergyValue(ItemStack outputItemStack)
|
||||||
|
{
|
||||||
|
EnergyValue outputEnergyValue = EnergyValueRegistryProxy.getEnergyValue(outputItemStack);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Algorithm:
|
||||||
|
*
|
||||||
|
* 1) Check the Stone slot, and attempt to take EMC out of the stone there (til 0)
|
||||||
|
* 2) Search the inventory for items that will most make up the difference, decrement them and consume their EMC
|
||||||
|
* 3) Repeat 2 until Stored EMC > outputItemStack EMC
|
||||||
|
* 4) Profit
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (this.storedEnergyValue.compareTo(outputEnergyValue) >= 0)
|
||||||
|
{
|
||||||
|
this.storedEnergyValue = new EnergyValue(this.storedEnergyValue.getValue() - outputEnergyValue.getValue());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (this.storedEnergyValue.compareTo(outputEnergyValue) < 0)
|
||||||
|
{
|
||||||
|
int candidateSlotIndex = Integer.MIN_VALUE;
|
||||||
|
float candidateEnergyValue = Float.MIN_VALUE;
|
||||||
|
|
||||||
|
for (int i = 0; i < STONE_INDEX; i++)
|
||||||
|
{
|
||||||
|
// Sick as hell algorithm that solves everything and makes me look cool on a skateboard
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.storedEnergyValue.getValue() >= outputEnergyValue.getValue())
|
||||||
|
{
|
||||||
|
this.storedEnergyValue = new EnergyValue(this.storedEnergyValue.getValue() - outputEnergyValue.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateEnergyValueFromInventory();
|
||||||
|
}
|
||||||
|
|
||||||
public void updateEnergyValueFromInventory()
|
public void updateEnergyValueFromInventory()
|
||||||
{
|
{
|
||||||
float newEnergyValue = storedEnergyValue.getValue();
|
float newEnergyValue = storedEnergyValue.getValue();
|
||||||
for (int i = 0; i <= STONE_INDEX; i++)
|
for (int i = 0; i <= STONE_INDEX; i++)
|
||||||
{
|
{
|
||||||
if (inventory[i] != null && EnergyValueRegistry.getInstance().hasEnergyValue(inventory[i]))
|
if (inventory[i] != null && EnergyValueRegistryProxy.hasEnergyValue(inventory[i]))
|
||||||
{
|
{
|
||||||
newEnergyValue += EnergyValueRegistry.getInstance().getEnergyValueForStack(inventory[i]).getValue();
|
newEnergyValue += EnergyValueRegistryProxy.getEnergyValueForStack(inventory[i]).getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.availableEnergyValue = new EnergyValue(newEnergyValue);
|
this.availableEnergyValue = new EnergyValue(newEnergyValue);
|
||||||
|
|
|
@ -120,7 +120,7 @@ public class ItemHelper
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static Comparator<ItemStack> energyValueComparator = new Comparator<ItemStack>()
|
public static Comparator<ItemStack> energyValueItemStackComparator = new Comparator<ItemStack>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public int compare(ItemStack itemStack1, ItemStack itemStack2)
|
public int compare(ItemStack itemStack1, ItemStack itemStack2)
|
||||||
|
|
|
@ -243,7 +243,7 @@ public class SerializationHelper
|
||||||
jsonWriter.beginArray();
|
jsonWriter.beginArray();
|
||||||
for (WrappedStack wrappedStack : energyValueMap.keySet())
|
for (WrappedStack wrappedStack : energyValueMap.keySet())
|
||||||
{
|
{
|
||||||
if (wrappedStack.getWrappedObject() != null)
|
if (wrappedStack != null && wrappedStack.getWrappedObject() != null)
|
||||||
{
|
{
|
||||||
EnergyValueStackMapping.jsonSerializer.toJson(new EnergyValueStackMapping(wrappedStack, energyValueMap.get(wrappedStack)), EnergyValueStackMapping.class, jsonWriter);
|
EnergyValueStackMapping.jsonSerializer.toJson(new EnergyValueStackMapping(wrappedStack, energyValueMap.get(wrappedStack)), EnergyValueStackMapping.class, jsonWriter);
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue