mirror of
https://github.com/GTNewHorizons/ModTweaker.git
synced 2026-11-21 04:42:20 +00:00
Reworked BaseListRemoval
- Fixed various crashes if no recipes are removed and the undo method is called (e.g. on /mt reload), adding a null object. - Added option to remove more than 1 recipe with BaseListRemoval - Cleanup of some classes which are extending BaseListRemoval
This commit is contained in:
1 parent
8efaa6c92c
commit
de099e4798
40 files changed
+197
-265
No files matched your search
@@ -76,18 +76,15 @@ public class Casting {
|
||||
|
||||
// Removes all matching recipes, apply is never the same for anything, so will always need to override it
|
||||
private static class Remove extends BaseListRemoval {
|
||||
protected final LinkedList<CastingRecipe> removedRecipes;
|
||||
protected final RecipeComponent component;
|
||||
|
||||
public Remove(ItemStack item, ArrayList list, RecipeComponent component) {
|
||||
super("TConstruct Casting", list, item);
|
||||
this.removedRecipes = new LinkedList<CastingRecipe>();
|
||||
this.component = component;
|
||||
}
|
||||
|
||||
public Remove(FluidStack fluid, ArrayList list) {
|
||||
super("TConstruct Casting", list, fluid);
|
||||
this.removedRecipes = new LinkedList<CastingRecipe>();
|
||||
this.component = RecipeComponent.Material;
|
||||
}
|
||||
|
||||
@@ -96,45 +93,32 @@ public class Casting {
|
||||
public void apply() {
|
||||
for (Iterator<CastingRecipe> iterator = ((ArrayList<CastingRecipe>)list).iterator(); iterator.hasNext();) {
|
||||
CastingRecipe r = iterator.next();
|
||||
boolean removeRecipie = false;
|
||||
|
||||
switch(component)
|
||||
{
|
||||
case Cast:
|
||||
if (r.cast != null && areEqual(r.cast, stack)) {
|
||||
removeRecipie = true;
|
||||
recipes.add(r);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case Material:
|
||||
if (r.castingMetal != null && r.castingMetal.isFluidEqual(fluid)) {
|
||||
removeRecipie = true;
|
||||
recipes.add(r);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case Output:
|
||||
if (r.output != null && areEqual(r.output, stack)) {
|
||||
removeRecipie = true;
|
||||
recipes.add(r);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if(removeRecipie) {
|
||||
iterator.remove();
|
||||
removedRecipes.add(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
for(CastingRecipe recipe : removedRecipes) {
|
||||
this.list.add(recipe);
|
||||
}
|
||||
removedRecipes.clear();
|
||||
super.apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -55,12 +55,10 @@ public class Drying {
|
||||
public void apply() {
|
||||
for (DryingRecipe r : (ArrayList<DryingRecipe>) list) {
|
||||
if (r.result != null && areEqual(r.result, stack)) {
|
||||
recipe = r;
|
||||
break;
|
||||
recipes.add(r);
|
||||
}
|
||||
}
|
||||
|
||||
list.remove(recipe);
|
||||
super.apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,12 +29,10 @@ public class Modifiers {
|
||||
public void apply() {
|
||||
for (ItemModifier m : (List<ItemModifier>) list) {
|
||||
if (m.key.equals(check)) {
|
||||
recipe = m;
|
||||
break;
|
||||
recipes. add(m);
|
||||
}
|
||||
}
|
||||
|
||||
list.remove(recipe);
|
||||
super.apply();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,13 +72,10 @@ public class Smeltery {
|
||||
public void apply() {
|
||||
for (AlloyMix r : TConstructHelper.alloys) {
|
||||
if (r.result != null && fluid != null && r.result.getFluid() == fluid.getFluid()) {
|
||||
recipe = r;
|
||||
break;
|
||||
recipes.add(r);
|
||||
}
|
||||
}
|
||||
if (recipe != null)
|
||||
TConstructHelper.alloys.remove(recipe);
|
||||
|
||||
super.apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -98,13 +98,11 @@ public class TiCTweaks {
|
||||
ItemStack clone = new ItemStack(r.item, 1, r.damage);
|
||||
if ((material != null && material.equalsIgnoreCase(r.key)) || (material == null)) {
|
||||
if (clone.isItemEqual(stack)) {
|
||||
recipe = r;
|
||||
break;
|
||||
recipes.add(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PatternBuilder.instance.materials.remove(recipe);
|
||||
super.apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user