Use recipe handler for templates to prevent sealed drawers from being used.

This commit is contained in:
Justin Aquadro committed 2016-09-19 01:58:41 -04:00
1 parent 2191df7918
commit b33a6be9cb
3 files changed
+71 -3

No files matched your search

+1 -1
View File
@@ -17,7 +17,7 @@ buildscript {
apply plugin: 'forge'
version = "1.7.10-1.10.2"
version = "1.7.10-1.10.3"
group= "com.jaquadro.minecraft.storagedrawers" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "StorageDrawers"
@@ -4,12 +4,14 @@ import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
import com.jaquadro.minecraft.storagedrawers.block.BlockDrawers;
import com.jaquadro.minecraft.storagedrawers.config.ConfigManager;
import com.jaquadro.minecraft.storagedrawers.core.recipe.FallbackShapedOreRecipe;
import com.jaquadro.minecraft.storagedrawers.core.recipe.TemplateRecipe;
import cpw.mods.fml.common.registry.GameRegistry;
import minetweaker.mc1710.recipes.ShapedRecipeOre;
import net.minecraft.block.BlockWood;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.RecipeSorter;
import net.minecraftforge.oredict.ShapedOreRecipe;
@@ -79,8 +81,8 @@ public class ModRecipes
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.controllerSlave), "xxx", "yzy", "xwx",
'x', new ItemStack(Blocks.stone), 'y', Items.comparator, 'z', "drawerBasic", 'w', "ingotGold"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.upgradeTemplate, 2), "xxx", "xyx", "xxx",
'x', "stickWood", 'y', "drawerBasic"));
//GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.upgradeTemplate, 2), "xxx", "xyx", "xxx",
// 'x', "stickWood", 'y', "drawerBasic"));
if (config.cache.enableStorageUpgrades) {
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.upgrade, 1, 2), "xyx", "yzy", "xyx",
@@ -157,5 +159,9 @@ public class ModRecipes
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.trimCustom, config.getBlockRecipeOutput("trim"), 0), "yxy", "xyx", "yxy",
'x', "stickWood", 'y', "plankWood"));
}
RecipeSorter.register("StorageDrawers:UpgradeTemplate", TemplateRecipe.class, RecipeSorter.Category.SHAPED, "after:minecraft:shaped");
CraftingManager.getInstance().getRecipeList().add(new TemplateRecipe());
}
}
@@ -0,0 +1,62 @@
package com.jaquadro.minecraft.storagedrawers.core.recipe;
import com.jaquadro.minecraft.storagedrawers.core.ModItems;
import com.jaquadro.minecraft.storagedrawers.item.ItemDrawers;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
import java.util.List;
public class TemplateRecipe implements IRecipe
{
@Override
public boolean matches (InventoryCrafting inventory, World world) {
return getCraftingResult(inventory) != null;
}
@Override
public ItemStack getCraftingResult (InventoryCrafting inventory) {
List<ItemStack> sticks = OreDictionary.getOres("stickWood");
for (int row = 0; row < 3; row++) {
for (int col = 0; col < 3; col++) {
if (row == 1 && col == 1)
continue;
ItemStack stack = inventory.getStackInRowAndColumn(col, row);
if (stack == null)
return null;
boolean match = false;
for (ItemStack comp : sticks) {
if (comp != null && comp.isItemEqual(stack))
match = true;
}
if (!match)
return null;
}
}
ItemStack center = inventory.getStackInRowAndColumn(1, 1);
if (center == null || !(center.getItem() instanceof ItemDrawers))
return null;
if (center.getTagCompound() != null && center.getTagCompound().hasKey("tile"))
return null;
return getRecipeOutput();
}
@Override
public int getRecipeSize () {
return 9;
}
@Override
public ItemStack getRecipeOutput () {
return new ItemStack(ModItems.upgradeTemplate, 2);
}
}