This closes #17 and closes #58, I tested and it worked using the script given

Also changes like all packages
inb4 "jared changes a package name in ModTweaker2 breaking compatability
with everything" drama tweet.
This commit is contained in:
jaredlll08 committed 2015-02-20 23:57:32 +02:00
1 parent 4fd2551072
commit ec562b62ea
187 files changed
+977 -991

No files matched your search

@@ -0,0 +1,16 @@
package modtweaker2.mods.exnihilo;
import minetweaker.MineTweakerAPI;
import modtweaker2.mods.exnihilo.handlers.Compost;
import modtweaker2.mods.exnihilo.handlers.Crucible;
import modtweaker2.mods.exnihilo.handlers.Hammer;
import modtweaker2.mods.exnihilo.handlers.Sieve;
public class ExNihilo {
public ExNihilo() {
MineTweakerAPI.registerClass(Compost.class);
MineTweakerAPI.registerClass(Crucible.class);
MineTweakerAPI.registerClass(Hammer.class);
MineTweakerAPI.registerClass(Sieve.class);
}
}
@@ -0,0 +1,56 @@
package modtweaker2.mods.exnihilo.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.util.BaseMapAddition;
import modtweaker2.util.BaseMapRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import exnihilo.registries.CompostRegistry;
import exnihilo.registries.helpers.Color;
import exnihilo.registries.helpers.Compostable;
@ZenClass("mods.exnihilo.Composting")
public class Compost {
//Adding a Ex Nihilo Composting recipe
@ZenMethod
public static void addRecipe(IItemStack input, double value, @Optional String hex) {
hex = (hex == null || hex.equals("")) ? "35A82A" : hex;
MineTweakerAPI.apply(new Add(new Compostable(toStack(input).getItem(), toStack(input).getItemDamage(), Math.min(1.0F, (float) value), new Color(hex))));
}
//Passes the list to the map list implementation, and adds the recipe
private static class Add extends BaseMapAddition {
public Add(Compostable recipe) {
super("ExNihilo Composting", CompostRegistry.entries, recipe.item + ":" + recipe.meta, recipe);
}
@Override
public String getRecipeInfo() {
return new ItemStack(((Compostable) recipe).item, 1, ((Compostable) recipe).meta).getDisplayName();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing a Ex Nihilo Composting recipe
@ZenMethod
public static void removeRecipe(IItemStack input) {
MineTweakerAPI.apply(new Remove(toStack(input)));
}
//Removes a recipe, will always remove the key, so all should be good
private static class Remove extends BaseMapRemoval {
public Remove(ItemStack stack) {
super("ExNihilo Composting", CompostRegistry.entries, stack.getItem() + ":" + stack.getItemDamage(), stack);
}
@Override
public String getRecipeInfo() {
return ((ItemStack) stack).getDisplayName();
}
}
}
@@ -0,0 +1,112 @@
package modtweaker2.mods.exnihilo.handlers;
import static modtweaker2.helpers.InputHelper.isABlock;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toStack;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.util.BaseMapAddition;
import modtweaker2.util.BaseMapRemoval;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import exnihilo.registries.CrucibleRegistry;
import exnihilo.registries.HeatRegistry;
import exnihilo.registries.helpers.HeatSource;
import exnihilo.registries.helpers.Meltable;
@ZenClass("mods.exnihilo.Crucible")
public class Crucible {
/************************************************ Crucible Melting ************************************************/
//Adding a Ex Nihilo Crucible recipe
@ZenMethod
public static void addRecipe(IItemStack input, ILiquidStack fluid) {
if (isABlock(input)) {
Block theBlock = Block.getBlockFromItem(toStack(input).getItem());
int theMeta = toStack(input).getItemDamage();
MineTweakerAPI.apply(new AddRecipe(new Meltable(theBlock, theMeta, 2000, toFluid(fluid).getFluid(), toFluid(fluid).amount, theBlock)));
}
}
//Passes the list to the map list implementation, and adds the recipe
private static class AddRecipe extends BaseMapAddition {
public AddRecipe(Meltable recipe) {
super("ExNihilo Crucible", CrucibleRegistry.entries, recipe.block + ":" + recipe.meta, recipe);
}
@Override
public String getRecipeInfo() {
return new ItemStack(((Meltable) recipe).block, 1, ((Meltable) recipe).meta).getDisplayName();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing a Ex Nihilo Crucible recipe
@ZenMethod
public static void removeRecipe(IItemStack output) {
if (isABlock(output)) {
MineTweakerAPI.apply(new RemoveRecipe(toStack(output)));
}
}
//Removes a recipe, will always remove the key, so all should be good
private static class RemoveRecipe extends BaseMapRemoval {
public RemoveRecipe(ItemStack stack) {
super("ExNihilo Crucible", CrucibleRegistry.entries, Block.getBlockFromItem(stack.getItem()) + ":" + stack.getItemDamage(), stack);
}
@Override
public String getRecipeInfo() {
return ((ItemStack) stack).getDisplayName();
}
}
/********************************************** Crucible Heat Sources **********************************************/
//Adding a Ex Nihilo Crucible heat source
@ZenMethod
public static void addHeatSource(IItemStack input, double value) {
if (isABlock(input)) {
Block theBlock = Block.getBlockFromItem(toStack(input).getItem());
int theMeta = toStack(input).getItemDamage();
MineTweakerAPI.apply(new AddHeatSource(new HeatSource(theBlock, theMeta, (float) value)));
}
}
//Passes the list to the base map implementation, and adds the recipe
private static class AddHeatSource extends BaseMapAddition {
public AddHeatSource(HeatSource recipe) {
super("ExNihilo Crucible - Heat Source", HeatRegistry.entries, recipe.block + ":" + recipe.meta, recipe);
}
@Override
public String getRecipeInfo() {
return new ItemStack(((HeatSource) recipe).block, 1, ((HeatSource) recipe).meta).getDisplayName();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing a Ex Nihilo Crucible heat source
@ZenMethod
public static void removeHeatSource(IItemStack output) {
if (isABlock(output)) {
MineTweakerAPI.apply(new RemoveHeatSource(toStack(output)));
}
}
//Removes a recipe, will always remove the key, so all should be good
private static class RemoveHeatSource extends BaseMapRemoval {
public RemoveHeatSource(ItemStack stack) {
super("ExNihilo Crucible - Heat Source", HeatRegistry.entries, Block.getBlockFromItem(stack.getItem()) + ":" + stack.getItemDamage(), stack);
}
@Override
public String getRecipeInfo() {
return ((ItemStack) stack).getDisplayName();
}
}
}
@@ -0,0 +1,90 @@
package modtweaker2.mods.exnihilo.handlers;
import static modtweaker2.helpers.InputHelper.isABlock;
import static modtweaker2.helpers.InputHelper.toStack;
import java.util.Iterator;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.util.BaseListAddition;
import modtweaker2.util.BaseListRemoval;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import exnihilo.registries.HammerRegistry;
import exnihilo.registries.helpers.Smashable;
@ZenClass("mods.exnihilo.Hammer")
public class Hammer {
// Adding a Ex Nihilo Hammer recipe
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output, double chance, double luck) {
if (isABlock(input)) {
Block theBlock = Block.getBlockFromItem(toStack(input).getItem());
int theMeta = toStack(input).getItemDamage();
MineTweakerAPI.apply(new Add(new Smashable(theBlock, theMeta, toStack(output).getItem(), toStack(output).getItemDamage(), (float) chance, (float) luck)));
}
}
// Passes the list to the base list implementation, and adds the recipe
private static class Add extends BaseListAddition {
public Add(Smashable recipe) {
super("ExNihilo Hammer", HammerRegistry.rewards, recipe);
}
@Override
public String getRecipeInfo() {
return new ItemStack(((Smashable) recipe).source, 1, ((Smashable) recipe).sourceMeta).getDisplayName();
}
}
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Removing a Ex Nihilo Hammer recipe
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
}
// Removes a recipe, apply is never the same for anything, so will always
// need to override it
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("ExNihilo Hammer", HammerRegistry.rewards, stack);
}
// Loops through the registry, to find the item that matches, saves that
// recipe then removes it
@Override
public void apply() {
boolean found = false;
Iterator<Smashable> smashables = HammerRegistry.rewards.iterator();
while (!found && smashables.hasNext()) {
Smashable reward = smashables.next();
if (reward != null && reward.source != null && Block.getBlockFromItem(stack.getItem()) != null)
if (reward.source == Block.getBlockFromItem(stack.getItem())) {
reward.source = Blocks.air;
found = true;
}
}
// for (Smashable r : HammerRegistry.rewards.) {
// ItemStack check = new ItemStack(r.item, 1, r.meta);
// if (check != null && areEqual(check, stack)) {
// recipe = r;
// break;
// }
// }
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}
@@ -0,0 +1,80 @@
package modtweaker2.mods.exnihilo.handlers;
import static modtweaker2.helpers.InputHelper.isABlock;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.util.BaseListAddition;
import modtweaker2.util.BaseMultipleListRemoval;
import modtweaker2.util.BaseMultipleListRemoval.Position;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import exnihilo.registries.SieveRegistry;
import exnihilo.registries.helpers.SiftReward;
@ZenClass("mods.exnihilo.Sieve")
public class Sieve {
//Adding a Ex Nihilo Sieve recipe
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output, int rarity) {
if (isABlock(input)) {
Block theBlock = Block.getBlockFromItem(toStack(input).getItem());
int theMeta = toStack(input).getItemDamage();
MineTweakerAPI.apply(new Add(new SiftReward(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 extends BaseListAddition {
public Add(SiftReward recipe) {
super("ExNihilo Sieve", SieveRegistry.rewards, recipe);
}
@Override
public String getRecipeInfo() {
return new ItemStack(((SiftReward) recipe).source, 1, ((SiftReward) recipe).sourceMeta).getDisplayName();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing a Ex Nihilo Sieve recipe
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output), Position.ALL));
}
@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 extends BaseMultipleListRemoval {
public Remove(ItemStack stack, Position pos) {
super("ExNihilo Sieve", SieveRegistry.rewards, stack, pos);
}
@Override
protected boolean isEqual(Object recipe, Object search) {
SiftReward r = (SiftReward) recipe;
ItemStack c = new ItemStack(r.item, 1, r.meta);
if (c != null && areEqual(c, (ItemStack) search)) {
return true;
} else return false;
}
@Override
public String getRecipeInfo() {
return ((ItemStack) search).getDisplayName();
}
}
}