net.minecraft.network.play.client.CPacketEntityAction Java Examples
The following examples show how to use
net.minecraft.network.play.client.CPacketEntityAction.
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 |
private void handlePlaceRequest(final Minecraft minecraft, final PlacementRequest placementRequest) { final BlockPos structurePosition = placementRequest.getStructurePosition(); final IBlockState structureBlockState = minecraft.world.getBlockState(structurePosition); final boolean blockActivated = structureBlockState.getBlock().onBlockActivated(minecraft.world, structurePosition, structureBlockState, minecraft.player, EnumHand.MAIN_HAND, EnumFacing.UP, 0.0f, 0.0f, 0.0f); if (blockActivated) minecraft.player.connection.sendPacket(new CPacketEntityAction(minecraft.player, CPacketEntityAction.Action.START_SNEAKING)); if (minecraft.playerController.processRightClickBlock(minecraft.player, minecraft.world, structurePosition, placementRequest.getPlaceDirection(), Vec3d.ZERO, EnumHand.MAIN_HAND) != EnumActionResult.FAIL) minecraft.player.swingArm(EnumHand.MAIN_HAND); if (blockActivated) minecraft.player.connection.sendPacket(new CPacketEntityAction(minecraft.player, CPacketEntityAction.Action.STOP_SNEAKING)); }
Example #2
Source File: ScaffoldModule.java From seppuku with GNU General Public License v3.0 | 6 votes |
private void placeBlock(BlockPos pos) { final Minecraft mc = Minecraft.getMinecraft(); BlockPos[][] posit = {{pos.add(0, 0, 1), pos.add(0, 0, -1)}, {pos.add(0, 1, 0), pos.add(0, -1, 0)}, {pos.add(1, 0, 0),pos.add(-1, 0, 0)}}; EnumFacing[][] facing = {{EnumFacing.NORTH, EnumFacing.SOUTH}, {EnumFacing.DOWN, EnumFacing.UP}, {EnumFacing.WEST, EnumFacing.EAST}}; // Facing reversed as blocks are placed while facing in the opposite direction for (int i=0; i<6; i++) { final Block block = mc.world.getBlockState(posit[i/2][i%2]).getBlock(); final boolean activated = block.onBlockActivated(mc.world, pos, mc.world.getBlockState(pos), mc.player, EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0); if (block != null && block != Blocks.AIR && !(block instanceof BlockLiquid)) { if (activated) mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING)); if (mc.playerController.processRightClickBlock(mc.player, mc.world, posit[i/2][i%2], facing[i/2][i%2], new Vec3d(0d, 0d, 0d), EnumHand.MAIN_HAND) != EnumActionResult.FAIL) mc.player.swingArm(EnumHand.MAIN_HAND); if (activated) mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING)); } } }
Example #3
Source File: SneakHack.java From ForgeWurst with GNU General Public License v3.0 | 6 votes |
@Override protected void onDisable() { MinecraftForge.EVENT_BUS.unregister(this); switch(mode.getSelected()) { case LEGIT: KeyBindingUtils.resetPressed(mc.gameSettings.keyBindSneak); break; case PACKET: EntityPlayerSP player = WMinecraft.getPlayer(); player.connection.sendPacket( new CPacketEntityAction(player, Action.STOP_SNEAKING)); break; } }
Example #4
Source File: SneakHack.java From ForgeWurst with GNU General Public License v3.0 | 6 votes |
@SubscribeEvent public void onPreMotion(WPreMotionEvent event) { switch(mode.getSelected()) { case LEGIT: KeyBindingUtils.setPressed(mc.gameSettings.keyBindSneak, true); break; case PACKET: KeyBindingUtils.resetPressed(mc.gameSettings.keyBindSneak); EntityPlayerSP player = event.getPlayer(); player.connection.sendPacket( new CPacketEntityAction(player, Action.START_SNEAKING)); player.connection.sendPacket( new CPacketEntityAction(player, Action.STOP_SNEAKING)); break; } }
Example #5
Source File: SneakService.java From ForgeHax with MIT License | 6 votes |
@SubscribeEvent public void onPacketSend(PacketEvent.Outgoing.Pre event) { if (event.getPacket() instanceof CPacketEntityAction) { CPacketEntityAction packet = event.getPacket(); int id = CPacketEntityAction_entityID.get(packet); if (getLocalPlayer().getEntityId() == id && (packet.getAction() == Action.START_SNEAKING || packet.getAction() == Action.STOP_SNEAKING) && !PacketHelper.isIgnored(packet)) { sneakingClient = packet.getAction() == Action.START_SNEAKING; if (isSuppressing()) { event.setCanceled(true); } else { sneakingServer = sneakingClient; } } } }
Example #6
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 #7
Source File: SneakModule.java From seppuku with GNU General Public License v3.0 | 5 votes |
@Override public void onDisable() { super.onDisable(); if (Minecraft.getMinecraft().world != null && !Minecraft.getMinecraft().player.isSneaking()) { Minecraft.getMinecraft().player.connection.sendPacket(new CPacketEntityAction(Minecraft.getMinecraft().player, CPacketEntityAction.Action.STOP_SNEAKING)); } }
Example #8
Source File: SneakModule.java From seppuku with GNU General Public License v3.0 | 5 votes |
@Listener public void onWalkingUpdate(EventUpdateWalkingPlayer event) { final Minecraft mc = Minecraft.getMinecraft(); if (event.getStage() == EventStageable.EventStage.PRE) { switch (this.mode.getValue()) { case VANILLA: mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING)); break; case NCP: if (!mc.player.isSneaking()) { if (this.isMoving()) { mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING)); mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING)); } else { mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING)); } } break; } } else { if (this.mode.getValue() == Mode.NCP) { if (this.isMoving()) { mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING)); } } } }
Example #9
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 #10
Source File: SneakHack.java From ForgeWurst with GNU General Public License v3.0 | 5 votes |
@SubscribeEvent public void onPostMotion(WPostMotionEvent event) { if(mode.getSelected() != Mode.PACKET) return; EntityPlayerSP player = event.getPlayer(); player.connection .sendPacket(new CPacketEntityAction(player, Action.STOP_SNEAKING)); player.connection .sendPacket(new CPacketEntityAction(player, Action.START_SNEAKING)); }
Example #11
Source File: EntityUtils.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
public static boolean setFakedSneakingState(Minecraft mc, boolean sneaking) { if (mc.player != null && mc.player.isSneaking() != sneaking) { CPacketEntityAction.Action action = sneaking ? CPacketEntityAction.Action.START_SNEAKING : CPacketEntityAction.Action.STOP_SNEAKING; mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, action)); mc.player.movementInput.sneak = sneaking; return true; } return false; }
Example #12
Source File: ElytraFlight.java From ForgeHax with MIT License | 5 votes |
@Override protected void onEnabled() { if (fly_on_enable.get()) { MC.addScheduledTask( () -> { if (getLocalPlayer() != null && !getLocalPlayer().isElytraFlying()) { getNetworkManager() .sendPacket(new CPacketEntityAction(getLocalPlayer(), Action.START_FALL_FLYING)); } }); } }
Example #13
Source File: ElytraFlight.java From ForgeHax with MIT License | 5 votes |
@Override public void onDisabled() { flying.disable(); // Are we still here? if (getLocalPlayer() != null) { // Ensure the player starts flying again. getNetworkManager() .sendPacket(new CPacketEntityAction(getLocalPlayer(), Action.START_FALL_FLYING)); } }
Example #14
Source File: FlyMod.java From ForgeHax with MIT License | 4 votes |
@SubscribeEvent public void onLocalPlayerUpdate(LocalPlayerUpdateEvent event) { try { double[] dir = moveLooking(0); double xDir = dir[0]; double zDir = dir[1]; if ((MC.gameSettings.keyBindForward.isKeyDown() || MC.gameSettings.keyBindLeft.isKeyDown() || MC.gameSettings.keyBindRight.isKeyDown() || MC.gameSettings.keyBindBack.isKeyDown()) && !MC.gameSettings.keyBindJump.isKeyDown()) { MC.player.motionX = xDir * 0.26; MC.player.motionZ = zDir * 0.26; } double posX = MC.player.posX + MC.player.motionX; double posY = MC.player.posY + (MC.gameSettings.keyBindJump.isKeyDown() ? (zoomies ? 0.0625 : 0.0624) : 0.00000001) - (MC.gameSettings.keyBindSneak.isKeyDown() ? (zoomies ? 0.0625 : 0.0624) : 0.00000002); double posZ = MC.player.posZ + MC.player.motionX; getNetworkManager() .sendPacket( new CPacketPlayer.PositionRotation( MC.player.posX + MC.player.motionX, MC.player.posY + (MC.gameSettings.keyBindJump.isKeyDown() ? (zoomies ? 0.0625 : 0.0624) : 0.00000001) - (MC.gameSettings.keyBindSneak.isKeyDown() ? (zoomies ? 0.0625 : 0.0624) : 0.00000002), MC.player.posZ + MC.player.motionZ, MC.player.rotationYaw, MC.player.rotationPitch, false)); getNetworkManager() .sendPacket( new CPacketPlayer.PositionRotation( MC.player.posX + MC.player.motionX, 1337 + MC.player.posY, MC.player.posZ + MC.player.motionZ, MC.player.rotationYaw, MC.player.rotationPitch, true)); getNetworkManager().sendPacket(new CPacketEntityAction(MC.player, Action.START_FALL_FLYING)); MC.player.setPosition(posX, posY, posZ); zoomies = !zoomies; MC.player.motionX = 0; MC.player.motionY = 0; MC.player.motionZ = 0; MC.player.noClip = true; } catch (Exception e) { Helper.printStackTrace(e); } }
Example #15
Source File: MixinEntityPlayerSP.java From Valkyrien-Skies with Apache License 2.0 | 4 votes |
/** * @reason is because we need to ensure the CPacketPlayer is always sent no matter what. * @author thebest108 */ @Overwrite private void onUpdateWalkingPlayer() { // ===== Injection code starts here ===== IDraggable draggable = (IDraggable) this; if (draggable.getWorldBelowFeet() != null) { draggable.getWorldBelowFeet().getPhysicsObject().getSubspace() .snapshotSubspacedEntity(thisAsSubspaced); ISubspacedEntityRecord entityRecord = draggable.getWorldBelowFeet().getPhysicsObject() .getSubspace() .getRecordForSubspacedEntity(thisAsSubspaced); SubspacedEntityRecordMessage recordMessage = new SubspacedEntityRecordMessage( entityRecord); ValkyrienSkiesMod.physWrapperNetwork.sendToServer(recordMessage); } // ===== Injection code ends here ===== boolean flag = player.isSprinting(); if (flag != serverSprintState) { if (flag) { player.connection.sendPacket( new CPacketEntityAction(player, CPacketEntityAction.Action.START_SPRINTING)); } else { player.connection.sendPacket( new CPacketEntityAction(player, CPacketEntityAction.Action.STOP_SPRINTING)); } serverSprintState = flag; } boolean flag1 = player.isSneaking(); if (flag1 != serverSneakState) { if (flag1) { player.connection.sendPacket( new CPacketEntityAction(player, CPacketEntityAction.Action.START_SNEAKING)); } else { player.connection.sendPacket( new CPacketEntityAction(player, CPacketEntityAction.Action.STOP_SNEAKING)); } serverSneakState = flag1; } if (isCurrentViewEntity()) { AxisAlignedBB axisalignedbb = player.getEntityBoundingBox(); double d0 = player.posX - lastReportedPosX; double d1 = axisalignedbb.minY - lastReportedPosY; double d2 = player.posZ - lastReportedPosZ; double d3 = (double) (player.rotationYaw - lastReportedYaw); double d4 = (double) (player.rotationPitch - lastReportedPitch); ++positionUpdateTicks; // Always true because why not. boolean flag2 = true; // d0 * d0 + d1 * d1 + d2 * d2 > 9.0E-4D || positionUpdateTicks >= 20; boolean flag3 = true; // d3 != 0.0D || d4 != 0.0D; if (player.isRiding()) { player.connection.sendPacket( new CPacketPlayer.PositionRotation(player.motionX, -999.0D, player.motionZ, player.rotationYaw, player.rotationPitch, player.onGround)); flag2 = false; } else if (flag2 && flag3) { player.connection.sendPacket( new CPacketPlayer.PositionRotation(player.posX, axisalignedbb.minY, player.posZ, player.rotationYaw, player.rotationPitch, player.onGround)); } else if (flag2) { player.connection.sendPacket( new CPacketPlayer.Position(player.posX, axisalignedbb.minY, player.posZ, player.onGround)); } else if (flag3) { player.connection.sendPacket( new CPacketPlayer.Rotation(player.rotationYaw, player.rotationPitch, player.onGround)); } if (flag2) { lastReportedPosX = player.posX; lastReportedPosY = axisalignedbb.minY; lastReportedPosZ = player.posZ; positionUpdateTicks = 0; } if (flag3) { lastReportedYaw = player.rotationYaw; lastReportedPitch = player.rotationPitch; } prevOnGround = player.onGround; autoJumpEnabled = mc.gameSettings.autoJump; } }