optimize WorldPropertyIsOre, fix crash

This commit is contained in:
Adrian 2015-06-18 16:15:44 +02:00
parent 2495ae74a5
commit 1144acd930
2 changed files with 6 additions and 13 deletions

View file

@ -58,21 +58,14 @@ public class WorldPropertyIsOre extends WorldProperty {
if (block == null) {
return false;
} else {
List<ItemStack> toCheck = new ArrayList<ItemStack>();
toCheck.add(new ItemStack(block, 1, meta));
List<ItemStack> itemsDropped = new ArrayList<ItemStack>();
//Check for blocks that drop an item that is an ore
//On the off-chance blockAccess isn't a world, just get the itemstack from the block
if (blockAccess instanceof World) {
itemsDropped.addAll(block.getDrops((World) blockAccess, x, y, z, blockAccess.getBlockMetadata(x, y, z), 0));
//Make sure we grab things like redstone ore
itemsDropped.add(new ItemStack(block, 1, meta));
} else {
ItemStack stack = new ItemStack(block, 1, meta);
itemsDropped.add(stack);
if (block.hasTileEntity(meta) && blockAccess instanceof World) {
toCheck.addAll(block.getDrops((World) blockAccess, x, y, z, blockAccess.getBlockMetadata(x, y, z), 0));
}
for (ItemStack stack : itemsDropped) {
for (ItemStack stack : toCheck) {
if (stack.getItem() != null) {
for (int id : OreDictionary.getOreIDs(stack)) {
if (ores.contains(id)) {

View file

@ -63,7 +63,7 @@ public class TriggerRobotInStation extends BCStatement implements ITriggerIntern
EntityRobot robot = (EntityRobot) station.robotTaking();
if (robot.getDockingStation() == station) {
if (parameters.length > 0) {
if (parameters.length > 0 && parameters[0] != null && parameters[0].getItemStack() != null) {
if (StatementParameterRobot.matches(parameters[0], robot)) {
return true;
}