net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock Java Examples
The following examples show how to use
net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock.
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: NoCrystalModule.java From seppuku with GNU General Public License v3.0 | 5 votes |
private void place (BlockPos pos, EnumFacing direction) { final Block block = mc.world.getBlockState(pos).getBlock(); final boolean activated = block.onBlockActivated(mc.world, pos, mc.world.getBlockState(pos), mc.player, EnumHand.MAIN_HAND, direction, 0, 0, 0); if (activated) { mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING)); } this.mc.player.connection.sendPacket(new CPacketPlayerTryUseItemOnBlock(pos, direction, EnumHand.MAIN_HAND, 0.0F, 0.0F, 0.0F)); if (activated) { mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING)); } }
Example #2
Source File: InteractModule.java From seppuku with GNU General Public License v3.0 | 5 votes |
@Listener public void sendPacket(EventSendPacket event) { if (event.getStage() == EventStageable.EventStage.PRE) { if (event.getPacket() instanceof CPacketPlayerTryUseItemOnBlock) { if (this.clicked) { this.clicked = false; return; } final CPacketPlayerTryUseItemOnBlock packet = (CPacketPlayerTryUseItemOnBlock) event.getPacket(); final Minecraft mc = Minecraft.getMinecraft(); if (mc.currentScreen == null) { final Block block = mc.world.getBlockState(packet.getPos()).getBlock(); if (block.onBlockActivated(mc.world, packet.getPos(), mc.world.getBlockState(packet.getPos()), mc.player, packet.getHand(), packet.getDirection(), packet.getFacingX(), packet.getFacingY(), packet.getFacingZ())) { return; } final BlockPos usable = findUsableBlock(packet.getHand(), packet.getDirection(), packet.getFacingX(), packet.getFacingY(), packet.getFacingZ()); if (usable != null) { mc.player.swingArm(packet.getHand()); mc.player.connection.sendPacket(new CPacketPlayerTryUseItemOnBlock(usable, packet.getDirection(), packet.getHand(), packet.getFacingX(), packet.getFacingY(), packet.getFacingZ())); this.clicked = true; }else{ final Entity usableEntity = findUsableEntity(packet.getHand()); if(usableEntity != null) { mc.player.connection.sendPacket(new CPacketUseEntity(usableEntity, packet.getHand())); this.clicked = true; } } } } } }
Example #3
Source File: SneakModule.java From seppuku with GNU General Public License v3.0 | 5 votes |
@Listener public void sendPacket(EventSendPacket event) { if (event.getStage() == EventStageable.EventStage.PRE) { if (event.getPacket() instanceof CPacketPlayerTryUseItemOnBlock && !Minecraft.getMinecraft().player.isSneaking()) { Minecraft.getMinecraft().player.connection.sendPacket(new CPacketEntityAction(Minecraft.getMinecraft().player, CPacketEntityAction.Action.STOP_SNEAKING)); } } }
Example #4
Source File: BuildHeightModule.java From seppuku with GNU General Public License v3.0 | 5 votes |
@Listener public void sendPacket(EventSendPacket event) { if(event.getStage() == EventStageable.EventStage.PRE) { if(event.getPacket() instanceof CPacketPlayerTryUseItemOnBlock) { final CPacketPlayerTryUseItemOnBlock packet = (CPacketPlayerTryUseItemOnBlock) event.getPacket(); if(packet.getPos().getY() >= 255 && packet.getDirection() == EnumFacing.UP) { packet.placedBlockDirection = EnumFacing.DOWN; } } } }
Example #5
Source File: AntiAfkMod.java From ForgeHax with MIT License | 4 votes |
@Override public void onTick() { if (counter++ % (TPS * MULTIPLIER) == 0) { if (isPlaced()) { getNetworkManager() .sendPacket( new CPacketPlayerDigging( CPacketPlayerDigging.Action.START_DESTROY_BLOCK, getBlockBelow(), EnumFacing.UP)); swingHand(); return; } LocalPlayerInventory.InvItem item = LocalPlayerInventory.getHotbarInventory() .stream() .filter(itm -> itm.getItemStack().getItem() instanceof ItemRedstone) .findAny() .orElse(LocalPlayerInventory.InvItem.EMPTY); if (item.isNull()) { return; } RayTraceResult result = getTraceBelow(); if (result == null) { return; } if (!Blocks.REDSTONE_WIRE.canPlaceBlockAt(getWorld(), result.getBlockPos())) { return; // can't place block } ResetFunction func = LocalPlayerInventory.setSelected(item); LocalPlayerInventory.syncSelected(); getNetworkManager() .sendPacket( new CPacketPlayerTryUseItemOnBlock( result.getBlockPos(), EnumFacing.UP, EnumHand.MAIN_HAND, (float) (result.hitVec.x - result.getBlockPos().getX()), (float) (result.hitVec.y - result.getBlockPos().getY()), (float) (result.hitVec.z - result.getBlockPos().getZ()))); swingHand(); func.revert(); } }