forked from TAIGA/TAIGA
fixed a potential NPE
This commit is contained in:
@@ -25,41 +25,43 @@ public class TraitFracture extends AbstractTrait {
|
|||||||
float b = 0.99F * calcBonus(tool);
|
float b = 0.99F * calcBonus(tool);
|
||||||
if (!world.isRemote && tool.canHarvestBlock(state) && f <= b) {
|
if (!world.isRemote && tool.canHarvestBlock(state) && f <= b) {
|
||||||
RayTraceResult mop = ((ToolCore) tool.getItem()).rayTrace(world, (EntityPlayer) player, false);
|
RayTraceResult mop = ((ToolCore) tool.getItem()).rayTrace(world, (EntityPlayer) player, false);
|
||||||
for (int i = random.nextInt(9) + 1; i >= 0; i--) {
|
if (mop != null) {
|
||||||
switch (mop.sideHit) {
|
for (int i = random.nextInt(9) + 1; i >= 0; i--) {
|
||||||
case UP:
|
switch (mop.sideHit) {
|
||||||
BlockPos next1 = new BlockPos(pos.getX(), pos.getY() - i, pos.getZ());
|
case UP:
|
||||||
if (tool.canHarvestBlock(world.getBlockState(next1)) && !world.getBlockState(next1).equals(Blocks.BEDROCK.getDefaultState()))
|
BlockPos next1 = new BlockPos(pos.getX(), pos.getY() - i, pos.getZ());
|
||||||
world.destroyBlock(next1, true);
|
if (tool.canHarvestBlock(world.getBlockState(next1)) && !world.getBlockState(next1).equals(Blocks.BEDROCK.getDefaultState()))
|
||||||
break;
|
world.destroyBlock(next1, true);
|
||||||
case DOWN:
|
break;
|
||||||
BlockPos next2 = new BlockPos(pos.getX(), pos.getY() + i, pos.getZ());
|
case DOWN:
|
||||||
if (tool.canHarvestBlock(world.getBlockState(next2)) && !world.getBlockState(next2).equals(Blocks.BEDROCK.getDefaultState()))
|
BlockPos next2 = new BlockPos(pos.getX(), pos.getY() + i, pos.getZ());
|
||||||
world.destroyBlock(next2, true);
|
if (tool.canHarvestBlock(world.getBlockState(next2)) && !world.getBlockState(next2).equals(Blocks.BEDROCK.getDefaultState()))
|
||||||
break;
|
world.destroyBlock(next2, true);
|
||||||
case WEST:
|
break;
|
||||||
BlockPos next3 = new BlockPos(pos.getX() + i, pos.getY(), pos.getZ());
|
case WEST:
|
||||||
if (tool.canHarvestBlock(world.getBlockState(next3)) && !world.getBlockState(next3).equals(Blocks.BEDROCK.getDefaultState()))
|
BlockPos next3 = new BlockPos(pos.getX() + i, pos.getY(), pos.getZ());
|
||||||
world.destroyBlock(next3, true);
|
if (tool.canHarvestBlock(world.getBlockState(next3)) && !world.getBlockState(next3).equals(Blocks.BEDROCK.getDefaultState()))
|
||||||
break;
|
world.destroyBlock(next3, true);
|
||||||
case EAST:
|
break;
|
||||||
BlockPos next4 = new BlockPos(pos.getX() - i, pos.getY(), pos.getZ());
|
case EAST:
|
||||||
if (tool.canHarvestBlock(world.getBlockState(next4)) && !world.getBlockState(next4).equals(Blocks.BEDROCK.getDefaultState()))
|
BlockPos next4 = new BlockPos(pos.getX() - i, pos.getY(), pos.getZ());
|
||||||
world.destroyBlock(next4, true);
|
if (tool.canHarvestBlock(world.getBlockState(next4)) && !world.getBlockState(next4).equals(Blocks.BEDROCK.getDefaultState()))
|
||||||
break;
|
world.destroyBlock(next4, true);
|
||||||
case SOUTH:
|
break;
|
||||||
BlockPos next5 = new BlockPos(pos.getX(), pos.getY(), pos.getZ() - i);
|
case SOUTH:
|
||||||
if (tool.canHarvestBlock(world.getBlockState(next5)) && !world.getBlockState(next5).equals(Blocks.BEDROCK.getDefaultState()))
|
BlockPos next5 = new BlockPos(pos.getX(), pos.getY(), pos.getZ() - i);
|
||||||
world.destroyBlock(next5, true);
|
if (tool.canHarvestBlock(world.getBlockState(next5)) && !world.getBlockState(next5).equals(Blocks.BEDROCK.getDefaultState()))
|
||||||
break;
|
world.destroyBlock(next5, true);
|
||||||
case NORTH:
|
break;
|
||||||
BlockPos next6 = new BlockPos(pos.getX(), pos.getY() - i, pos.getZ() + i);
|
case NORTH:
|
||||||
if (tool.canHarvestBlock(world.getBlockState(next6)) && !world.getBlockState(next6).equals(Blocks.BEDROCK.getDefaultState()))
|
BlockPos next6 = new BlockPos(pos.getX(), pos.getY() - i, pos.getZ() + i);
|
||||||
world.destroyBlock(next6, true);
|
if (tool.canHarvestBlock(world.getBlockState(next6)) && !world.getBlockState(next6).equals(Blocks.BEDROCK.getDefaultState()))
|
||||||
break;
|
world.destroyBlock(next6, true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (random.nextBoolean()) ToolHelper.damageTool(tool, random.nextInt(5), player);
|
||||||
}
|
}
|
||||||
if (random.nextBoolean()) ToolHelper.damageTool(tool, random.nextInt(5), player);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user