diff --git a/api/buildcraft/api/core/BuildCraftAPI.java b/api/buildcraft/api/core/BuildCraftAPI.java index 736382b9..ce99d7ce 100644 --- a/api/buildcraft/api/core/BuildCraftAPI.java +++ b/api/buildcraft/api/core/BuildCraftAPI.java @@ -23,8 +23,7 @@ public final class BuildCraftAPI { public static IWorldProperty isSoftProperty; public static IWorldProperty isWoodProperty; public static IWorldProperty isLeavesProperty; - public static IWorldProperty isBasicOreProperty; - public static IWorldProperty isExtendedOreProperty; + public static IWorldProperty[] isOreProperty; public static IWorldProperty isHarvestableProperty; public static IWorldProperty isFarmlandProperty; public static IWorldProperty isDirtProperty; diff --git a/common/buildcraft/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java index ada2771a..1a0b47d1 100644 --- a/common/buildcraft/BuildCraftCore.java +++ b/common/buildcraft/BuildCraftCore.java @@ -60,6 +60,7 @@ import buildcraft.api.core.BlockIndex; import buildcraft.api.core.BuildCraftAPI; import buildcraft.api.core.EnumColor; import buildcraft.api.core.IIconProvider; +import buildcraft.api.core.IWorldProperty; import buildcraft.api.core.JavaTools; import buildcraft.api.fuels.BuildcraftFuelRegistry; import buildcraft.api.gates.ActionParameterItemStack; @@ -116,7 +117,7 @@ import buildcraft.core.utils.WorldPropertyIsDirt; import buildcraft.core.utils.WorldPropertyIsFarmland; import buildcraft.core.utils.WorldPropertyIsFluidSource; import buildcraft.core.utils.WorldPropertyIsHarvestable; -import buildcraft.core.utils.WorldPropertyIsLeave; +import buildcraft.core.utils.WorldPropertyIsLeaf; import buildcraft.core.utils.WorldPropertyIsOre; import buildcraft.core.utils.WorldPropertyIsShoveled; import buildcraft.core.utils.WorldPropertyIsSoft; @@ -397,9 +398,11 @@ public class BuildCraftCore extends BuildCraftMod { BuildCraftAPI.isSoftProperty = new WorldPropertyIsSoft(); BuildCraftAPI.isWoodProperty = new WorldPropertyIsWood(); - BuildCraftAPI.isLeavesProperty = new WorldPropertyIsLeave(); - BuildCraftAPI.isBasicOreProperty = new WorldPropertyIsOre(false); - BuildCraftAPI.isExtendedOreProperty = new WorldPropertyIsOre(true); + BuildCraftAPI.isLeavesProperty = new WorldPropertyIsLeaf(); + BuildCraftAPI.isOreProperty = new IWorldProperty[4]; + for (int i = 0; i < BuildCraftAPI.isOreProperty.length; i++) { + BuildCraftAPI.isOreProperty[i] = new WorldPropertyIsOre(i); + } BuildCraftAPI.isHarvestableProperty = new WorldPropertyIsHarvestable(); BuildCraftAPI.isFarmlandProperty = new WorldPropertyIsFarmland(); BuildCraftAPI.isShoveled = new WorldPropertyIsShoveled(); @@ -527,8 +530,9 @@ public class BuildCraftCore extends BuildCraftMod { BuildCraftAPI.isSoftProperty.clear(); BuildCraftAPI.isWoodProperty.clear(); BuildCraftAPI.isLeavesProperty.clear(); - BuildCraftAPI.isBasicOreProperty.clear(); - BuildCraftAPI.isExtendedOreProperty.clear(); + for (int i = 0; i < BuildCraftAPI.isOreProperty.length; i++) { + BuildCraftAPI.isOreProperty[i].clear(); + } BuildCraftAPI.isHarvestableProperty.clear(); BuildCraftAPI.isFarmlandProperty.clear(); BuildCraftAPI.isShoveled.clear(); diff --git a/common/buildcraft/core/robots/boards/BoardRobotMiner.java b/common/buildcraft/core/robots/boards/BoardRobotMiner.java index 4a3d4a8f..4a4d9f45 100755 --- a/common/buildcraft/core/robots/boards/BoardRobotMiner.java +++ b/common/buildcraft/core/robots/boards/BoardRobotMiner.java @@ -21,7 +21,7 @@ import buildcraft.core.robots.AIRobotFetchAndEquipItemStack; public class BoardRobotMiner extends BoardRobotGenericBreakBlock { - private boolean extendedOre = false; + private int harvestLevel = 0; public BoardRobotMiner(EntityRobotBase iRobot) { super(iRobot); @@ -37,8 +37,7 @@ public class BoardRobotMiner extends BoardRobotGenericBreakBlock { if (stack != null && stack.getItem() instanceof ItemPickaxe) { ItemPickaxe pickaxe = (ItemPickaxe) stack.getItem(); - extendedOre = pickaxe.func_150913_i() == Item.ToolMaterial.EMERALD - || pickaxe.func_150913_i() == Item.ToolMaterial.IRON; + harvestLevel = pickaxe.getHarvestLevel(stack, "pickaxe"); } } } @@ -55,11 +54,8 @@ public class BoardRobotMiner extends BoardRobotGenericBreakBlock { @Override public boolean isExpectedBlock(World world, int x, int y, int z) { - if (!extendedOre) { - return BuildCraftAPI.isBasicOreProperty.get(world, x, y, z); - } else { - return BuildCraftAPI.isExtendedOreProperty.get(world, x, y, z); - } + return BuildCraftAPI.isOreProperty[Math.min(BuildCraftAPI.isOreProperty.length, harvestLevel)] + .get(world, x, y, z); } } diff --git a/common/buildcraft/core/statements/StatementParameterRedstoneGateSideOnly.java b/common/buildcraft/core/statements/StatementParameterRedstoneGateSideOnly.java index 8245fee8..b8525b1c 100644 --- a/common/buildcraft/core/statements/StatementParameterRedstoneGateSideOnly.java +++ b/common/buildcraft/core/statements/StatementParameterRedstoneGateSideOnly.java @@ -15,6 +15,10 @@ public class StatementParameterRedstoneGateSideOnly implements @NetworkData public boolean isOn = false; + public StatementParameterRedstoneGateSideOnly() { + + } + @Override public ItemStack getItemStackToDraw() { return null; diff --git a/common/buildcraft/core/utils/BitSetUtils.java b/common/buildcraft/core/utils/BitSetUtils.java index 914d447c..67833c7d 100644 --- a/common/buildcraft/core/utils/BitSetUtils.java +++ b/common/buildcraft/core/utils/BitSetUtils.java @@ -19,7 +19,7 @@ public final class BitSetUtils { } public static byte[] toByteArray(BitSet bits) { - byte[] bytes = new byte[(int) Math.ceil(bits.length() / 8)]; + byte[] bytes = new byte[(bits.length() >> 3) + (bits.length() & 7) == 0 ? 0 : 1]; for (int i = 0; i < bits.length(); i++) { if (bits.get(i)) { bytes[bytes.length - (i >> 3) - 1] |= 1 << (i & 7); diff --git a/common/buildcraft/core/utils/WorldPropertyIsLeave.java b/common/buildcraft/core/utils/WorldPropertyIsLeaf.java similarity index 91% rename from common/buildcraft/core/utils/WorldPropertyIsLeave.java rename to common/buildcraft/core/utils/WorldPropertyIsLeaf.java index def5c648..83095790 100755 --- a/common/buildcraft/core/utils/WorldPropertyIsLeave.java +++ b/common/buildcraft/core/utils/WorldPropertyIsLeaf.java @@ -14,11 +14,11 @@ import net.minecraft.world.IBlockAccess; import net.minecraftforge.oredict.OreDictionary; -public class WorldPropertyIsLeave extends WorldProperty { +public class WorldPropertyIsLeaf extends WorldProperty { private int leavesId = 0; - public WorldPropertyIsLeave() { + public WorldPropertyIsLeaf() { leavesId = OreDictionary.getOreID("treeLeaves"); } diff --git a/common/buildcraft/core/utils/WorldPropertyIsOre.java b/common/buildcraft/core/utils/WorldPropertyIsOre.java index fc0c9fb5..9d830019 100755 --- a/common/buildcraft/core/utils/WorldPropertyIsOre.java +++ b/common/buildcraft/core/utils/WorldPropertyIsOre.java @@ -20,32 +20,21 @@ public class WorldPropertyIsOre extends WorldProperty { public HashSet ores = new HashSet(); - public WorldPropertyIsOre(boolean extendedHarvest) { - ores.add(OreDictionary.getOreID("oreCoal")); - ores.add(OreDictionary.getOreID("oreIron")); - ores.add(OreDictionary.getOreID("oreQuartz")); - - if (extendedHarvest) { - ores.add(OreDictionary.getOreID("oreGold")); - ores.add(OreDictionary.getOreID("oreDiamond")); - ores.add(OreDictionary.getOreID("oreEmerald")); - ores.add(OreDictionary.getOreID("oreLapis")); - ores.add(OreDictionary.getOreID("oreRedstone")); - } - + public WorldPropertyIsOre(int harvestLevel) { for (String oreName : OreDictionary.getOreNames()) { if (oreName.startsWith("ore")) { ArrayList oreStacks = OreDictionary.getOres(oreName); if (oreStacks.size() > 0) { Block block = Block.getBlockFromItem(oreStacks.get(0).getItem()); int meta = oreStacks.get(0).getItemDamage(); - if (meta == OreDictionary.WILDCARD_VALUE) { + if (meta >= 16 || meta < 0) { meta = 0; } if (block == null) { continue; } - if (extendedHarvest) { + if ("pickaxe".equals(block.getHarvestTool(meta)) && + block.getHarvestLevel(meta) <= harvestLevel) { ores.add(OreDictionary.getOreID(oreName)); } } diff --git a/common/buildcraft/transport/TileGenericPipe.java b/common/buildcraft/transport/TileGenericPipe.java index ebd09b76..fa1b2d24 100755 --- a/common/buildcraft/transport/TileGenericPipe.java +++ b/common/buildcraft/transport/TileGenericPipe.java @@ -272,7 +272,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui } if (pipe != null) { - nbt.setInteger("pipeId", Item.itemRegistry.getIDForObject(pipe.item)); + nbt.setInteger("pipeId", Item.getIdFromItem(pipe.item)); pipe.writeToNBT(nbt); } else { nbt.setInteger("pipeId", coreState.pipeId); @@ -303,7 +303,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui } coreState.pipeId = nbt.getInteger("pipeId"); - pipe = BlockGenericPipe.createPipe((Item) Item.itemRegistry.getObjectById(coreState.pipeId)); + pipe = BlockGenericPipe.createPipe((Item) Item.getItemById(coreState.pipeId)); bindPipe(); if (pipe != null) { diff --git a/common/buildcraft/transport/stripes/StripesHandlerBucket.java b/common/buildcraft/transport/stripes/StripesHandlerBucket.java index 2aa781d8..be2104d4 100644 --- a/common/buildcraft/transport/stripes/StripesHandlerBucket.java +++ b/common/buildcraft/transport/stripes/StripesHandlerBucket.java @@ -6,6 +6,7 @@ import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemBucket; import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; @@ -33,7 +34,8 @@ public class StripesHandlerBucket implements IStripesHandler { public boolean handle(World world, int x, int y, int z, ForgeDirection direction, ItemStack stack, EntityPlayer player, IStripesPipe pipe) { - if (world.getBlock(x, y, z) == Blocks.air) { + Block block = world.getBlock(x, y, z); + if (block == Blocks.air) { Block underblock = world.getBlock(x, y - 1, z); boolean rollback = false;