From 2b54516bdd096c73e171b7a9df57c554a53bce4b Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Sat, 9 Jan 2016 11:41:16 +0000 Subject: [PATCH] Fixes #321 - And I tested it so I know it works --- src/main/java/techreborn/blocks/BlockOre.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/techreborn/blocks/BlockOre.java b/src/main/java/techreborn/blocks/BlockOre.java index 92170c1b9..96077fa35 100644 --- a/src/main/java/techreborn/blocks/BlockOre.java +++ b/src/main/java/techreborn/blocks/BlockOre.java @@ -27,6 +27,7 @@ import techreborn.init.ModBlocks; import techreborn.items.ItemDusts; import techreborn.items.ItemGems; +import java.security.InvalidParameterException; import java.util.ArrayList; import java.util.List; import java.util.Random; @@ -34,14 +35,12 @@ import java.util.Random; public class BlockOre extends BaseBlock implements IBlockTextureProvider { public static ItemStack getOreByName(String name, int count) { - int index = -1; for (int i = 0; i < types.length; i++) { if (types[i].equals(name)) { - index = i; - break; + return new ItemStack(ModBlocks.ore, count, i); } } - return new ItemStack(ModBlocks.ore, count, index); + throw new InvalidParameterException("The storage block " + name + " could not be found."); } public static ItemStack getOreByName(String name) { @@ -180,12 +179,12 @@ public class BlockOre extends BaseBlock implements IBlockTextureProvider { @Override public int getMetaFromState(IBlockState state) { - return (Integer) state.getValue(METADATA); + return state.getValue(METADATA); } protected BlockState createBlockState() { - METADATA = PropertyInteger.create("Type", 0, types.length); + METADATA = PropertyInteger.create("Type", 0, types.length -1); return new BlockState(this, METADATA); }