use of net.minecraft.block.BlockCommandBlock in project Overloaded by CJ-MC-Mods.
the class PlayerInteractionUtil method tryHarvestBlock.
public static boolean tryHarvestBlock(EntityPlayerMP player, World world, BlockPos pos) {
int exp = net.minecraftforge.common.ForgeHooks.onBlockBreakEvent(world, player.interactionManager.getGameType(), player, pos);
if (exp == -1) {
return false;
} else {
IBlockState iblockstate = world.getBlockState(pos);
TileEntity tileentity = world.getTileEntity(pos);
Block block = iblockstate.getBlock();
if ((block instanceof BlockCommandBlock || block instanceof BlockStructure) && !player.canUseCommandBlock()) {
world.notifyBlockUpdate(pos, iblockstate, iblockstate, 3);
return false;
} else {
world.playEvent(null, 2001, pos, Block.getStateId(iblockstate));
boolean flag1;
if (player.capabilities.isCreativeMode) {
flag1 = removeBlock(world, pos, player, false);
player.connection.sendPacket(new SPacketBlockChange(world, pos));
} else {
ItemStack itemstack1 = player.getHeldItemMainhand();
ItemStack itemstack2 = itemstack1.isEmpty() ? ItemStack.EMPTY : itemstack1.copy();
boolean flag = iblockstate.getBlock().canHarvestBlock(world, pos, player);
itemstack1.onBlockDestroyed(world, iblockstate, pos, player);
flag1 = removeBlock(world, pos, player, flag);
if (flag1 && flag) {
iblockstate.getBlock().harvestBlock(world, player, pos, iblockstate, tileentity, itemstack2);
}
}
// Drop experience
if (!player.isCreative() && flag1 && exp > 0) {
iblockstate.getBlock().dropXpOnBlockBreak(world, player.getPosition(), exp);
}
return flag1;
}
}
}
Aggregations