various fixes

This commit is contained in:
asiekierka 2014-10-27 12:16:15 +01:00
parent 1e007896e0
commit a5758d1bf1
9 changed files with 31 additions and 37 deletions

View file

@ -23,8 +23,7 @@ public final class BuildCraftAPI {
public static IWorldProperty isSoftProperty; public static IWorldProperty isSoftProperty;
public static IWorldProperty isWoodProperty; public static IWorldProperty isWoodProperty;
public static IWorldProperty isLeavesProperty; public static IWorldProperty isLeavesProperty;
public static IWorldProperty isBasicOreProperty; public static IWorldProperty[] isOreProperty;
public static IWorldProperty isExtendedOreProperty;
public static IWorldProperty isHarvestableProperty; public static IWorldProperty isHarvestableProperty;
public static IWorldProperty isFarmlandProperty; public static IWorldProperty isFarmlandProperty;
public static IWorldProperty isDirtProperty; public static IWorldProperty isDirtProperty;

View file

@ -60,6 +60,7 @@ import buildcraft.api.core.BlockIndex;
import buildcraft.api.core.BuildCraftAPI; import buildcraft.api.core.BuildCraftAPI;
import buildcraft.api.core.EnumColor; import buildcraft.api.core.EnumColor;
import buildcraft.api.core.IIconProvider; import buildcraft.api.core.IIconProvider;
import buildcraft.api.core.IWorldProperty;
import buildcraft.api.core.JavaTools; import buildcraft.api.core.JavaTools;
import buildcraft.api.fuels.BuildcraftFuelRegistry; import buildcraft.api.fuels.BuildcraftFuelRegistry;
import buildcraft.api.gates.ActionParameterItemStack; import buildcraft.api.gates.ActionParameterItemStack;
@ -116,7 +117,7 @@ import buildcraft.core.utils.WorldPropertyIsDirt;
import buildcraft.core.utils.WorldPropertyIsFarmland; import buildcraft.core.utils.WorldPropertyIsFarmland;
import buildcraft.core.utils.WorldPropertyIsFluidSource; import buildcraft.core.utils.WorldPropertyIsFluidSource;
import buildcraft.core.utils.WorldPropertyIsHarvestable; import buildcraft.core.utils.WorldPropertyIsHarvestable;
import buildcraft.core.utils.WorldPropertyIsLeave; import buildcraft.core.utils.WorldPropertyIsLeaf;
import buildcraft.core.utils.WorldPropertyIsOre; import buildcraft.core.utils.WorldPropertyIsOre;
import buildcraft.core.utils.WorldPropertyIsShoveled; import buildcraft.core.utils.WorldPropertyIsShoveled;
import buildcraft.core.utils.WorldPropertyIsSoft; import buildcraft.core.utils.WorldPropertyIsSoft;
@ -397,9 +398,11 @@ public class BuildCraftCore extends BuildCraftMod {
BuildCraftAPI.isSoftProperty = new WorldPropertyIsSoft(); BuildCraftAPI.isSoftProperty = new WorldPropertyIsSoft();
BuildCraftAPI.isWoodProperty = new WorldPropertyIsWood(); BuildCraftAPI.isWoodProperty = new WorldPropertyIsWood();
BuildCraftAPI.isLeavesProperty = new WorldPropertyIsLeave(); BuildCraftAPI.isLeavesProperty = new WorldPropertyIsLeaf();
BuildCraftAPI.isBasicOreProperty = new WorldPropertyIsOre(false); BuildCraftAPI.isOreProperty = new IWorldProperty[4];
BuildCraftAPI.isExtendedOreProperty = new WorldPropertyIsOre(true); for (int i = 0; i < BuildCraftAPI.isOreProperty.length; i++) {
BuildCraftAPI.isOreProperty[i] = new WorldPropertyIsOre(i);
}
BuildCraftAPI.isHarvestableProperty = new WorldPropertyIsHarvestable(); BuildCraftAPI.isHarvestableProperty = new WorldPropertyIsHarvestable();
BuildCraftAPI.isFarmlandProperty = new WorldPropertyIsFarmland(); BuildCraftAPI.isFarmlandProperty = new WorldPropertyIsFarmland();
BuildCraftAPI.isShoveled = new WorldPropertyIsShoveled(); BuildCraftAPI.isShoveled = new WorldPropertyIsShoveled();
@ -527,8 +530,9 @@ public class BuildCraftCore extends BuildCraftMod {
BuildCraftAPI.isSoftProperty.clear(); BuildCraftAPI.isSoftProperty.clear();
BuildCraftAPI.isWoodProperty.clear(); BuildCraftAPI.isWoodProperty.clear();
BuildCraftAPI.isLeavesProperty.clear(); BuildCraftAPI.isLeavesProperty.clear();
BuildCraftAPI.isBasicOreProperty.clear(); for (int i = 0; i < BuildCraftAPI.isOreProperty.length; i++) {
BuildCraftAPI.isExtendedOreProperty.clear(); BuildCraftAPI.isOreProperty[i].clear();
}
BuildCraftAPI.isHarvestableProperty.clear(); BuildCraftAPI.isHarvestableProperty.clear();
BuildCraftAPI.isFarmlandProperty.clear(); BuildCraftAPI.isFarmlandProperty.clear();
BuildCraftAPI.isShoveled.clear(); BuildCraftAPI.isShoveled.clear();

View file

@ -21,7 +21,7 @@ import buildcraft.core.robots.AIRobotFetchAndEquipItemStack;
public class BoardRobotMiner extends BoardRobotGenericBreakBlock { public class BoardRobotMiner extends BoardRobotGenericBreakBlock {
private boolean extendedOre = false; private int harvestLevel = 0;
public BoardRobotMiner(EntityRobotBase iRobot) { public BoardRobotMiner(EntityRobotBase iRobot) {
super(iRobot); super(iRobot);
@ -37,8 +37,7 @@ public class BoardRobotMiner extends BoardRobotGenericBreakBlock {
if (stack != null && stack.getItem() instanceof ItemPickaxe) { if (stack != null && stack.getItem() instanceof ItemPickaxe) {
ItemPickaxe pickaxe = (ItemPickaxe) stack.getItem(); ItemPickaxe pickaxe = (ItemPickaxe) stack.getItem();
extendedOre = pickaxe.func_150913_i() == Item.ToolMaterial.EMERALD harvestLevel = pickaxe.getHarvestLevel(stack, "pickaxe");
|| pickaxe.func_150913_i() == Item.ToolMaterial.IRON;
} }
} }
} }
@ -55,11 +54,8 @@ public class BoardRobotMiner extends BoardRobotGenericBreakBlock {
@Override @Override
public boolean isExpectedBlock(World world, int x, int y, int z) { public boolean isExpectedBlock(World world, int x, int y, int z) {
if (!extendedOre) { return BuildCraftAPI.isOreProperty[Math.min(BuildCraftAPI.isOreProperty.length, harvestLevel)]
return BuildCraftAPI.isBasicOreProperty.get(world, x, y, z); .get(world, x, y, z);
} else {
return BuildCraftAPI.isExtendedOreProperty.get(world, x, y, z);
}
} }
} }

View file

@ -15,6 +15,10 @@ public class StatementParameterRedstoneGateSideOnly implements
@NetworkData @NetworkData
public boolean isOn = false; public boolean isOn = false;
public StatementParameterRedstoneGateSideOnly() {
}
@Override @Override
public ItemStack getItemStackToDraw() { public ItemStack getItemStackToDraw() {
return null; return null;

View file

@ -19,7 +19,7 @@ public final class BitSetUtils {
} }
public static byte[] toByteArray(BitSet bits) { 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++) { for (int i = 0; i < bits.length(); i++) {
if (bits.get(i)) { if (bits.get(i)) {
bytes[bytes.length - (i >> 3) - 1] |= 1 << (i & 7); bytes[bytes.length - (i >> 3) - 1] |= 1 << (i & 7);

View file

@ -14,11 +14,11 @@ import net.minecraft.world.IBlockAccess;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
public class WorldPropertyIsLeave extends WorldProperty { public class WorldPropertyIsLeaf extends WorldProperty {
private int leavesId = 0; private int leavesId = 0;
public WorldPropertyIsLeave() { public WorldPropertyIsLeaf() {
leavesId = OreDictionary.getOreID("treeLeaves"); leavesId = OreDictionary.getOreID("treeLeaves");
} }

View file

@ -20,32 +20,21 @@ public class WorldPropertyIsOre extends WorldProperty {
public HashSet<Integer> ores = new HashSet<Integer>(); public HashSet<Integer> ores = new HashSet<Integer>();
public WorldPropertyIsOre(boolean extendedHarvest) { public WorldPropertyIsOre(int harvestLevel) {
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"));
}
for (String oreName : OreDictionary.getOreNames()) { for (String oreName : OreDictionary.getOreNames()) {
if (oreName.startsWith("ore")) { if (oreName.startsWith("ore")) {
ArrayList<ItemStack> oreStacks = OreDictionary.getOres(oreName); ArrayList<ItemStack> oreStacks = OreDictionary.getOres(oreName);
if (oreStacks.size() > 0) { if (oreStacks.size() > 0) {
Block block = Block.getBlockFromItem(oreStacks.get(0).getItem()); Block block = Block.getBlockFromItem(oreStacks.get(0).getItem());
int meta = oreStacks.get(0).getItemDamage(); int meta = oreStacks.get(0).getItemDamage();
if (meta == OreDictionary.WILDCARD_VALUE) { if (meta >= 16 || meta < 0) {
meta = 0; meta = 0;
} }
if (block == null) { if (block == null) {
continue; continue;
} }
if (extendedHarvest) { if ("pickaxe".equals(block.getHarvestTool(meta)) &&
block.getHarvestLevel(meta) <= harvestLevel) {
ores.add(OreDictionary.getOreID(oreName)); ores.add(OreDictionary.getOreID(oreName));
} }
} }

View file

@ -272,7 +272,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
} }
if (pipe != null) { if (pipe != null) {
nbt.setInteger("pipeId", Item.itemRegistry.getIDForObject(pipe.item)); nbt.setInteger("pipeId", Item.getIdFromItem(pipe.item));
pipe.writeToNBT(nbt); pipe.writeToNBT(nbt);
} else { } else {
nbt.setInteger("pipeId", coreState.pipeId); nbt.setInteger("pipeId", coreState.pipeId);
@ -303,7 +303,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
} }
coreState.pipeId = nbt.getInteger("pipeId"); coreState.pipeId = nbt.getInteger("pipeId");
pipe = BlockGenericPipe.createPipe((Item) Item.itemRegistry.getObjectById(coreState.pipeId)); pipe = BlockGenericPipe.createPipe((Item) Item.getItemById(coreState.pipeId));
bindPipe(); bindPipe();
if (pipe != null) { if (pipe != null) {

View file

@ -6,6 +6,7 @@ import net.minecraft.init.Blocks;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.ItemBucket; import net.minecraft.item.ItemBucket;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid; 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, public boolean handle(World world, int x, int y, int z,
ForgeDirection direction, ItemStack stack, EntityPlayer player, ForgeDirection direction, ItemStack stack, EntityPlayer player,
IStripesPipe pipe) { 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); Block underblock = world.getBlock(x, y - 1, z);
boolean rollback = false; boolean rollback = false;