use of net.minecraft.block.StructureBlock in project VeinMining by TheIllusiveC4.
the class VeinMiningLogic method harvest.
public static boolean harvest(ServerPlayerEntity player, BlockPos pos, BlockPos originPos) {
ServerWorld world = player.getWorld();
BlockState blockState = world.getBlockState(pos);
GameMode gameMode = player.interactionManager.getGameMode();
if (!player.getMainHandStack().getItem().canMine(blockState, world, pos, player)) {
return false;
} else {
BlockEntity blockEntity = world.getBlockEntity(pos);
Block block = blockState.getBlock();
if ((block instanceof CommandBlock || block instanceof StructureBlock || block instanceof JigsawBlock) && !player.isCreativeLevelTwoOp()) {
world.updateListeners(pos, blockState, blockState, 3);
return false;
} else if (player.isBlockBreakingRestricted(world, pos, gameMode)) {
return false;
} else {
block.onBreak(world, pos, blockState, player);
boolean bl = world.removeBlock(pos, false);
if (bl) {
block.onBroken(world, pos, blockState);
}
if (gameMode != GameMode.CREATIVE) {
ItemStack itemStack = player.getMainHandStack();
ItemStack itemStack2 = itemStack.copy();
boolean bl2 = player.canHarvest(blockState);
if (VeinMiningConfig.VeinMining.addToolDamage) {
postMine(itemStack, world, blockState, pos, player);
}
BlockPos spawnPos = VeinMiningConfig.VeinMining.relocateDrops ? originPos : pos;
if (bl && bl2) {
afterBreak(block, world, player, pos, spawnPos, blockState, blockEntity, itemStack2);
}
}
return true;
}
}
}
Aggregations