net.minecraft.network.play.client.CPacketUseEntity Java Examples
The following examples show how to use
net.minecraft.network.play.client.CPacketUseEntity.
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: KillAuraModule.java From seppuku with GNU General Public License v3.0 | 9 votes |
@Listener public void onWalkingUpdate(EventUpdateWalkingPlayer event) { if (event.getStage() == EventStageable.EventStage.PRE) { final Minecraft mc = Minecraft.getMinecraft(); final Entity target = findTarget(); if (target != null) { final float[] angle = MathUtil.calcAngle(mc.player.getPositionEyes(mc.getRenderPartialTicks()), target.getPositionEyes(mc.getRenderPartialTicks())); Seppuku.INSTANCE.getRotationManager().setPlayerRotations(angle[0], angle[1]); final float ticks = 20.0f - Seppuku.INSTANCE.getTickRateManager().getTickRate(); final boolean canAttack = this.coolDown.getValue() ? (mc.player.getCooledAttackStrength(this.sync.getValue() ? -ticks : 0.0f) >= 1) : true; final ItemStack stack = mc.player.getHeldItem(EnumHand.OFF_HAND); //TODO interp if (this.teleport.getValue()) { Seppuku.INSTANCE.getPositionManager().setPlayerPosition(target.posX, target.posY, target.posZ); } if (canAttack) { if (stack != null && stack.getItem() == Items.SHIELD) { mc.player.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, mc.player.getHorizontalFacing())); } mc.player.connection.sendPacket(new CPacketUseEntity(target)); mc.player.swingArm(EnumHand.MAIN_HAND); mc.player.resetCooldown(); } } } }
Example #2
Source File: CriticalsModule.java From seppuku with GNU General Public License v3.0 | 6 votes |
@Listener public void sendPacket(EventSendPacket event) { if (event.getStage() == EventStageable.EventStage.PRE) { if (event.getPacket() instanceof CPacketUseEntity) { final CPacketUseEntity packet = (CPacketUseEntity) event.getPacket(); if (packet.getAction() == CPacketUseEntity.Action.ATTACK) { final Minecraft mc = Minecraft.getMinecraft(); if (mc.player.onGround && !mc.gameSettings.keyBindJump.isKeyDown() && packet.getEntityFromWorld(mc.world) instanceof EntityLivingBase) { switch (this.mode.getValue()) { case JUMP: mc.player.jump(); break; case PACKET: //TODO make sure u can actually go there mc.player.connection.sendPacket(new CPacketPlayer.Position(mc.player.posX, mc.player.posY + 0.1f, mc.player.posZ, false)); mc.player.connection.sendPacket(new CPacketPlayer.Position(mc.player.posX, mc.player.posY, mc.player.posZ, false)); break; } } } } } }
Example #3
Source File: DupeCommand.java From seppuku with GNU General Public License v3.0 | 6 votes |
@Override public void exec(String input) { if (!this.clamp(input, 1, 1)) { this.printUsage(); return; } final Minecraft mc = Minecraft.getMinecraft(); if(mc.player != null) { for (int i = 0; i <= 45; i++) { mc.playerController.windowClick(mc.player.inventoryContainer.windowId, i, -1, ClickType.THROW, mc.player); } mc.player.connection.sendPacket(new CPacketUseEntity(mc.player)); } }
Example #4
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 #5
Source File: AutoCrystalMod.java From ForgeHax with MIT License | 5 votes |
@SubscribeEvent public void onTick(LocalPlayerUpdateEvent event) { if (getWorld() != null && getLocalPlayer() != null) { // Short-circuit if the timer check will fail if (!timer.hasTimeElapsed(delay.get())) { return; } Vec3d delta = new Vec3d(maxDistance.get(), maxDistance.get(), maxDistance.get()); AxisAlignedBB bb = new AxisAlignedBB( getLocalPlayer().getPositionVector().subtract(delta), getLocalPlayer().getPositionVector().add(delta)); getWorld() .getEntitiesWithinAABB(EntityEnderCrystal.class, bb) .stream() // Re-check timer, since it may have been reset in a previous iteration .filter(__ -> timer.hasTimeElapsed(delay.get())) .filter( e -> e.getPosition().getY() - getLocalPlayer().getPosition().getY() >= minHeight.get()) .filter(playerWithinDistance(maxDistance.get())) .filter(playerWithinDistance(minDistance.get()).negate()) .filter(e -> !checkEnemy.get() || enemyWithinDistance(e, maxEnemyDistance.get())) .forEach( e -> { getNetworkManager().sendPacket(new CPacketUseEntity(e)); getNetworkManager().sendPacket(new CPacketAnimation(EnumHand.MAIN_HAND)); timer.start(); }); } }