diff --git a/build.properties b/build.properties index e0aca65..165e025 100644 --- a/build.properties +++ b/build.properties @@ -1,2 +1,2 @@ minecraft_version=1.7.2 -forge_version=10.12.1.1060 \ No newline at end of file +forge_version=10.12.1.1072 \ No newline at end of file diff --git a/src/mantle/utils/RecipeRemover.java b/src/mantle/utils/RecipeRemover.java new file mode 100644 index 0000000..5f281be --- /dev/null +++ b/src/mantle/utils/RecipeRemover.java @@ -0,0 +1,107 @@ +package mantle.utils; + +import java.util.List; +import java.util.Map; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.FurnaceRecipes; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.item.crafting.ShapedRecipes; +import net.minecraft.item.crafting.ShapelessRecipes; +import net.minecraftforge.common.ChestGenHooks; + +@SuppressWarnings("unchecked") +public class RecipeRemover +{ + public static void removeShapedRecipes (List removelist) + { + for (ItemStack stack : removelist) + removeShapedRecipe(stack); + } + + public static void removeAnyRecipe (ItemStack resultItem) + { + List recipes = CraftingManager.getInstance().getRecipeList(); + for (int i = 0; i < recipes.size(); i++) + { + IRecipe tmpRecipe = recipes.get(i); + ItemStack recipeResult = tmpRecipe.getRecipeOutput(); + if (ItemStack.areItemStacksEqual(resultItem, recipeResult)) + { + recipes.remove(i--); + } + } + } + + public static void removeShapedRecipe (ItemStack resultItem) + { + List recipes = CraftingManager.getInstance().getRecipeList(); + for (int i = 0; i < recipes.size(); i++) + { + IRecipe tmpRecipe = recipes.get(i); + if (tmpRecipe instanceof ShapedRecipes) + { + ShapedRecipes recipe = (ShapedRecipes) tmpRecipe; + ItemStack recipeResult = recipe.getRecipeOutput(); + + if (ItemStack.areItemStacksEqual(resultItem, recipeResult)) + { + recipes.remove(i--); + } + } + } + } + + public static void removeShapelessRecipe (ItemStack resultItem) + { + List recipes = CraftingManager.getInstance().getRecipeList(); + for (int i = 0; i < recipes.size(); i++) + { + IRecipe tmpRecipe = recipes.get(i); + if (tmpRecipe instanceof ShapelessRecipes) + { + ShapelessRecipes recipe = (ShapelessRecipes) tmpRecipe; + ItemStack recipeResult = recipe.getRecipeOutput(); + + if (ItemStack.areItemStacksEqual(resultItem, recipeResult)) + { + recipes.remove(i--); + } + } + } + } + + public static void removeFurnaceRecipe (ItemStack resultItem) + { + Map recipes = FurnaceRecipes.smelting().getSmeltingList(); + recipes.remove(resultItem); + } + + public static void removeFurnaceRecipe (Item i, int metadata) + { + removeFurnaceRecipe(new ItemStack(i, 1, metadata)); + } + + public static void removeFurnaceRecipe (Item i) + { + removeFurnaceRecipe(new ItemStack(i, 1, 32767)); + } + + //removes from all vanilla worldgen chests :D + public static void removeFromChests (ItemStack resultItem) + { + ChestGenHooks.getInfo(ChestGenHooks.BONUS_CHEST).removeItem(resultItem); + ChestGenHooks.getInfo(ChestGenHooks.VILLAGE_BLACKSMITH).removeItem(resultItem); + ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).removeItem(resultItem); + ChestGenHooks.getInfo(ChestGenHooks.MINESHAFT_CORRIDOR).removeItem(resultItem); + ChestGenHooks.getInfo(ChestGenHooks.PYRAMID_DESERT_CHEST).removeItem(resultItem); + ChestGenHooks.getInfo(ChestGenHooks.PYRAMID_JUNGLE_CHEST).removeItem(resultItem); + ChestGenHooks.getInfo(ChestGenHooks.PYRAMID_JUNGLE_DISPENSER).removeItem(resultItem); + ChestGenHooks.getInfo(ChestGenHooks.STRONGHOLD_CORRIDOR).removeItem(resultItem); + ChestGenHooks.getInfo(ChestGenHooks.STRONGHOLD_CROSSING).removeItem(resultItem); + ChestGenHooks.getInfo(ChestGenHooks.STRONGHOLD_LIBRARY).removeItem(resultItem); + + } +} diff --git a/src/mantle/world/CoordTuple.java b/src/mantle/world/CoordTuple.java index ac19dae..45274ae 100644 --- a/src/mantle/world/CoordTuple.java +++ b/src/mantle/world/CoordTuple.java @@ -78,16 +78,89 @@ public class CoordTuple implements Comparable return 0; } - public int getDistanceFrom(CoordTuple tuple) - { - return getDistanceFrom(tuple.x, tuple.y, tuple.z); - } - - public int getDistanceFrom (int x1, int y1, int z1) - { - int xPos = x - x1; - int yPos = y - y1; - int zPos = z - z1; - return xPos * xPos + yPos * yPos + zPos * zPos; - } + + public static CoordTuple up (int x, int y, int z) + { + return new CoordTuple(x, y + 1, z); + } + + public static CoordTuple down (int x, int y, int z) + { + return new CoordTuple(x, y - 1, z); + } + + public static CoordTuple north (int x, int y, int z) + { + return new CoordTuple(x, y, z - 1); + } + + public static CoordTuple south (int x, int y, int z) + { + return new CoordTuple(x, y, z + 1); + } + + public static CoordTuple east (int x, int y, int z) + { + return new CoordTuple(x + 1, y, z); + } + + public static CoordTuple west (int x, int y, int z) + { + return new CoordTuple(x - 1, y, z); + } + + public static CoordTuple inFront (int x, int y, int z, int meta) + { + switch (meta) + { + case 0: + return down(x, y, z); + case 1: + return up(x, y, z); + case 2: + return north(x, y, z); + case 3: + return south(x, y, z); + case 4: + return west(x, y, z); + case 5: + return east(x, y, z); + default: + return new CoordTuple(x, y, z); + } + } + + public static CoordTuple behind (int x, int y, int z, int meta) + { + switch (meta) + { + case 1: + return down(x, y, z); + case 0: + return up(x, y, z); + case 3: + return north(x, y, z); + case 2: + return south(x, y, z); + case 5: + return west(x, y, z); + case 4: + return east(x, y, z); + default: + return new CoordTuple(x, y, z); + } + } + + public int getDistanceFrom (CoordTuple tuple) + { + return getDistanceFrom(tuple.x, tuple.y, tuple.z); + } + + public int getDistanceFrom (int x1, int y1, int z1) + { + int xPos = x - x1; + int yPos = y - y1; + int zPos = z - z1; + return xPos * xPos + yPos * yPos + zPos * zPos; + } }