net.minecraft.network.play.server.SPacketBlockChange Java Examples
The following examples show how to use
net.minecraft.network.play.server.SPacketBlockChange.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ObsidianReplaceModule.java From seppuku with GNU General Public License v3.0 | 6 votes |
@Listener public void onReceivePacket(final EventReceivePacket event) { if (event.getStage() != EventStageable.EventStage.POST) return; if (freeCamModule != null && freeCamModule.isEnabled()) return; final Minecraft minecraft = Minecraft.getMinecraft(); if (event.getPacket() instanceof SPacketBlockChange) { final SPacketBlockChange blockChange = (SPacketBlockChange) event.getPacket(); if (blockChange.getBlockState().getBlock() instanceof BlockAir) { final BlockPos blockPosition = blockChange.getBlockPosition(); final double playerToBlockDistance = calculateVecDistance( minecraft.player.getPositionEyes(1.0f), blockPosition); if (playerToBlockDistance <= getReachDistance(minecraft)) buildPlacementRequest(minecraft, blockPosition); } } }
Example #2
Source File: DiamondTofuToolHandler.java From TofuCraftReload with MIT License | 5 votes |
private boolean canBreakExtraBlock(ItemStack stack, World world, EntityPlayer player, BlockPos pos, BlockPos refPos) { if (world.isAirBlock(pos)) { return false; } IBlockState state = world.getBlockState(pos); Block block = state.getBlock(); if (tool.getDestroySpeed(stack, state) <= 1.0F) return false; IBlockState refState = world.getBlockState(refPos); float refStrength = ForgeHooks.blockStrength(refState, player, world, refPos); float strength = ForgeHooks.blockStrength(state, player, world, pos); if (!ForgeHooks.canHarvestBlock(block, player, world, pos) || refStrength / strength > 10f) { return false; } if (player.capabilities.isCreativeMode) { block.onBlockHarvested(world, pos, state, player); if (block.removedByPlayer(state, world, pos, player, false)) { block.onBlockDestroyedByPlayer(world, pos, state); } // send update to client if (!world.isRemote) { if (player instanceof EntityPlayerMP && ((EntityPlayerMP) player).connection != null) { ((EntityPlayerMP) player).connection.sendPacket(new SPacketBlockChange(world, pos)); } } return false; } return true; }