diff --git a/src/main/java/cpw/mods/ironchest/ChestChangerType.java b/src/main/java/cpw/mods/ironchest/ChestChangerType.java index e6c6dc7..c4a1f0c 100755 --- a/src/main/java/cpw/mods/ironchest/ChestChangerType.java +++ b/src/main/java/cpw/mods/ironchest/ChestChangerType.java @@ -47,6 +47,10 @@ public enum ChestChangerType { this.descriptiveName = descriptiveName; this.recipe = recipe; } + + public IronChestType getSource(){ + return source; + } public boolean canUpgrade(IronChestType from) { @@ -75,7 +79,7 @@ public enum ChestChangerType { { Object targetMaterial = IronChestType.translateOreName(targetMat); Object sourceMaterial = IronChestType.translateOreName(sourceMat); - IronChestType.addRecipe(new ItemStack(item), recipe, 'm', targetMaterial, 's', sourceMaterial, 'G', Blocks.glass, 'O', Blocks.obsidian); + IronChestType.addRecipe(new ItemStack(item), recipe, 'm', targetMaterial, 's', sourceMaterial, 'G', "blockGlass", 'O', Blocks.obsidian); } } } diff --git a/src/main/java/cpw/mods/ironchest/ItemChestChanger.java b/src/main/java/cpw/mods/ironchest/ItemChestChanger.java index 84ab992..96d048a 100755 --- a/src/main/java/cpw/mods/ironchest/ItemChestChanger.java +++ b/src/main/java/cpw/mods/ironchest/ItemChestChanger.java @@ -10,6 +10,7 @@ ******************************************************************************/ package cpw.mods.ironchest; +import net.minecraft.block.BlockChest; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -38,6 +39,15 @@ public class ItemChestChanger extends Item { if (world.isRemote) return false; + if(this.type.canUpgrade(IronChestType.WOOD)){ + if(!(world.getBlockState(pos).getBlock() instanceof BlockChest)){ + return false; + } + }else{ + if(world.getBlockState(pos) != IronChest.ironChestBlock.getStateFromMeta(IronChestType.valueOf(type.getSource().getName().toUpperCase()).ordinal())){ + return false; + } + } TileEntity te = world.getTileEntity(pos); TileEntityIronChest newchest = new TileEntityIronChest(); ItemStack[] chestContents = new ItemStack[27]; @@ -59,7 +69,7 @@ public class ItemChestChanger extends Item chestContents = new ItemStack[((TileEntityChest) te).getSizeInventory()]; for (int i = 0; i < chestContents.length; i++) chestContents[i] = ((TileEntityChest) te).getStackInSlot(i); - newchest = IronChestType.makeEntity(IronChestType.IRON.ordinal()); + newchest = IronChestType.makeEntity(this.getTargetChestOrdinal(this.type.ordinal())); } }