Files
CraftTweaker/MineTweaker3-MC1102-Mod-IC2/src/main/java/minetweaker/mods/ic2/machines/Recycler.java
T
2019-10-19 23:49:58 +02:00

72 lines
1.9 KiB
Java

package minetweaker.mods.ic2.machines;
import ic2.api.recipe.Recipes;
import minetweaker.*;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.*;
import minetweaker.mods.ic2.IC2RecipeInput;
import stanhebben.zenscript.annotations.*;
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
/**
* @author Stan
*/
@ZenClass("mods.ic2.Recycler")
@ModOnly("IC2")
public class Recycler {
@ZenMethod
public static void addBlacklist(IIngredient ingredient) {
MineTweakerAPI.apply(new AddBlacklistAction(ingredient));
}
@ZenMethod
public static boolean isBlacklisted(IItemStack item) {
return Recipes.recyclerBlacklist.contains(getItemStack(item));
}
private static class AddBlacklistAction extends OneWayAction {
private IIngredient ingredient;
public AddBlacklistAction(IIngredient ingredient) {
this.ingredient = ingredient;
}
@Override
public void apply() {
Recipes.recyclerBlacklist.add(new IC2RecipeInput(ingredient));
}
@Override
public String describe() {
return "Adding " + ingredient + " to the recycler blacklist";
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public int hashCode() {
int hash = 3;
hash = 29 * hash + (this.ingredient != null ? this.ingredient.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object obj) {
if(obj == null) {
return false;
}
if(getClass() != obj.getClass()) {
return false;
}
final AddBlacklistAction other = (AddBlacklistAction) obj;
return !(this.ingredient != other.ingredient && (this.ingredient == null || !this.ingredient.equals(other.ingredient)));
}
}
}