Fixed a few mods reloading

This commit is contained in:
jaredlll08 committed 2015-04-24 23:25:07 +02:00
1 parent c757841e06
commit 0f461a7815
27 files changed
+1316 -1231

No files matched your search

@@ -17,20 +17,18 @@ import exnihilo.registries.helpers.SiftingResult;
@ZenClass("mods.exnihilo.Sieve")
public class Sieve {
//Adding a Ex Nihilo Sieve recipe
// Adding a Ex Nihilo Sieve recipe
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output, int rarity) {
if (isABlock(input))
{
if (isABlock(input)) {
Block theBlock = Block.getBlockFromItem(toStack(input).getItem());
int theMeta = toStack(input).getItemDamage();
MineTweakerAPI.apply(new Add(theBlock, theMeta, toStack(output).getItem(), toStack(output).getItemDamage(), rarity));
}
}
//Passes the list to the base list implementation, and adds the recipe
private static class Add implements IUndoableAction
{
// Passes the list to the base list implementation, and adds the recipe
private static class Add implements IUndoableAction {
Block source;
int sourceMeta;
Item output;
@@ -59,8 +57,7 @@ public class Sieve {
}
public String describeUndo()
{
public String describeUndo() {
return "Removing ExNihilo Sieve Recipe using " + source.getLocalizedName() + " to get the result of " + output.getUnlocalizedName();
}
@@ -69,46 +66,43 @@ public class Sieve {
}
public void undo() {
if(this.canUndo())
if (this.canUndo())
SieveRegistry.unregisterReward(this.source, this.sourceMeta, this.output, this.outputMeta);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing a Ex Nihilo Sieve recipe
// Removing a Ex Nihilo Sieve recipe
@ZenMethod
public static void removeRecipe(IItemStack input, IItemStack output) {
if (isABlock(input))
{
if (isABlock(input)) {
Block theBlock = Block.getBlockFromItem(toStack(input).getItem());
int theMeta = toStack(input).getItemDamage();
MineTweakerAPI.apply(new Remove(theBlock, theMeta, toStack(output).getItem(), toStack(output).getItemDamage()));
}
}
//TODO: Add other 2 remove methods that exNihilo provided
/*@ZenMethod
public static void removeFirst(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output), Position.FIRST));
}
// TODO: Add other 2 remove methods that exNihilo provided
@ZenMethod
public static void removeLast(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output), Position.LAST));
}*/
/*
* @ZenMethod public static void removeFirst(IItemStack output) {
* MineTweakerAPI.apply(new Remove(toStack(output), Position.FIRST)); }
*
* @ZenMethod public static void removeLast(IItemStack output) {
* MineTweakerAPI.apply(new Remove(toStack(output), Position.LAST)); }
*/
//Removes a recipe, apply is never the same for anything, so will always need to override it
private static class Remove implements IUndoableAction
{
// Removes a recipe, apply is never the same for anything, so will always
// need to override it
private static class Remove implements IUndoableAction {
Block source;
int sourceMeta;
Item output;
int outputMeta;
int rarity;
public Remove(Block source, int sourceMeta, Item output, int outputMeta) {
this.source = source;
this.sourceMeta = sourceMeta;
@@ -118,18 +112,17 @@ public class Sieve {
public void apply() {
ArrayList<SiftingResult> results = SieveRegistry.getSiftingOutput(this.source, this.sourceMeta);
for(SiftingResult res: results)
{
if(res.item.equals(this.source) && res.meta == this.outputMeta)
for (SiftingResult res : results) {
if (res.item.equals(this.source) && res.meta == this.outputMeta)
this.rarity = res.rarity;
}
SieveRegistry.unregisterReward(source, sourceMeta, output, outputMeta);
}
public boolean canUndo() {
return false;
return output != null && source != null;
}
public String describe() {
@@ -146,7 +139,7 @@ public class Sieve {
}
public void undo() {
if(this.canUndo())
if (this.canUndo())
SieveRegistry.register(this.source, this.sourceMeta, this.output, this.outputMeta, rarity);
}
}