/** * Attacks an entity */ public void attackEntity(EntityPlayer playerIn, Entity targetEntity) { //-ZMod-Ghost-fix if (playerIn == targetEntity) return; //-ZMod-? if (!ZHandle.handle("checkReachUse", targetEntity, true)) return; //------------------------------------------------------------ this.syncCurrentPlayItem(); this.connection.sendPacket(new CPacketUseEntity(targetEntity)); if (this.currentGameType != GameType.SPECTATOR) { playerIn.attackTargetEntityWithCurrentItem(targetEntity); playerIn.resetCooldown(); } }
/** * Handles right clicking an entity, sends a packet to the server. */ public EnumActionResult interactWithEntity(EntityPlayer player, Entity target, EnumHand heldItem) { //-ZMod-?----------------------------------------------------- if (!ZHandle.handle("checkReachUse", target ,true)) return EnumActionResult.FAIL; //------------------------------------------------------------ this.syncCurrentPlayItem(); this.connection.sendPacket(new CPacketUseEntity(target, heldItem)); return this.currentGameType == GameType.SPECTATOR ? EnumActionResult.PASS : player.func_190775_a(target, heldItem); }
/** * Handles right clicking an entity from the entities side, sends a packet to the server. */ public EnumActionResult interactWithEntity(EntityPlayer player, Entity target, RayTraceResult raytrace, EnumHand heldItem) { this.syncCurrentPlayItem(); Vec3d vec3d = new Vec3d(raytrace.hitVec.xCoord - target.posX, raytrace.hitVec.yCoord - target.posY, raytrace.hitVec.zCoord - target.posZ); this.connection.sendPacket(new CPacketUseEntity(target, heldItem, vec3d)); return this.currentGameType == GameType.SPECTATOR ? EnumActionResult.PASS : target.applyPlayerInteraction(player, vec3d, heldItem); }
/** * Attacks an entity */ public void attackEntity(EntityPlayer playerIn, Entity targetEntity) { if(Hacks.findMod(Criticals.class).isEnabled()) Criticals.doCrit(); this.syncCurrentPlayItem(); this.connection.sendPacket(new CPacketUseEntity(targetEntity)); if (this.currentGameType != GameType.SPECTATOR) { playerIn.attackTargetEntityWithCurrentItem(targetEntity); playerIn.resetCooldown(); } }
/** * Handles right clicking an entity, sends a packet to the server. */ public EnumActionResult interactWithEntity(EntityPlayer player, Entity target, EnumHand heldItem) { this.syncCurrentPlayItem(); this.connection.sendPacket(new CPacketUseEntity(target, heldItem)); return this.currentGameType == GameType.SPECTATOR ? EnumActionResult.PASS : player.func_190775_a(target, heldItem); }
/** * Attacks an entity */ public void attackEntity(EntityPlayer playerIn, Entity targetEntity) { this.syncCurrentPlayItem(); this.connection.sendPacket(new CPacketUseEntity(targetEntity)); if (this.currentGameType != GameType.SPECTATOR) { playerIn.attackTargetEntityWithCurrentItem(targetEntity); playerIn.resetCooldown(); } }
/** * Handles right clicking an entity, sends a packet to the server. */ public EnumActionResult interactWithEntity(EntityPlayer player, Entity target, @Nullable ItemStack heldItem, EnumHand hand) { this.syncCurrentPlayItem(); this.connection.sendPacket(new CPacketUseEntity(target, hand)); return this.currentGameType == GameType.SPECTATOR ? EnumActionResult.PASS : player.interact(target, heldItem, hand); }
/** * Handles right clicking an entity from the entities side, sends a packet to the server. */ public EnumActionResult interactWithEntity(EntityPlayer player, Entity target, RayTraceResult raytrace, @Nullable ItemStack heldItem, EnumHand hand) { this.syncCurrentPlayItem(); Vec3d vec3d = new Vec3d(raytrace.hitVec.xCoord - target.posX, raytrace.hitVec.yCoord - target.posY, raytrace.hitVec.zCoord - target.posZ); this.connection.sendPacket(new CPacketUseEntity(target, hand, vec3d)); if(net.minecraftforge.common.ForgeHooks.onInteractEntityAt(player, target, raytrace, player.getHeldItem(hand), hand)) return EnumActionResult.PASS; return this.currentGameType == GameType.SPECTATOR ? EnumActionResult.PASS : target.applyPlayerInteraction(player, vec3d, heldItem, hand); }
public static void sendAttackPacket(Entity entity) { WConnection .sendPacket(new CPacketUseEntity(entity, EnumHand.MAIN_HAND)); }
/** * Processes interactions ((un)leashing, opening command block GUI) and attacks on an entity with players currently * equipped item */ public void processUseEntity(CPacketUseEntity packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld()); WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension); Entity entity = packetIn.getEntityFromWorld(worldserver); this.playerEntity.markPlayerActive(); if (entity != null) { boolean flag = this.playerEntity.canEntityBeSeen(entity); //-ZMod-Dig-reach----------------------------------------------------- // double d0 = 36.0D; double d0 = ZHandle.handle("getPlayerReachUseSq", 36.0D); //-------------------------------------------------------------------- if (!flag) { d0 = 9.0D; } if (this.playerEntity.getDistanceSqToEntity(entity) < d0) { if (packetIn.getAction() == CPacketUseEntity.Action.INTERACT) { EnumHand enumhand = packetIn.getHand(); this.playerEntity.func_190775_a(entity, enumhand); } else if (packetIn.getAction() == CPacketUseEntity.Action.INTERACT_AT) { EnumHand enumhand1 = packetIn.getHand(); entity.applyPlayerInteraction(this.playerEntity, packetIn.getHitVec(), enumhand1); } else if (packetIn.getAction() == CPacketUseEntity.Action.ATTACK) { if (entity instanceof EntityItem || entity instanceof EntityXPOrb || entity instanceof EntityArrow || entity == this.playerEntity) { this.kickPlayerFromServer("Attempting to attack an invalid entity"); this.serverController.logWarning("Player " + this.playerEntity.getName() + " tried to attack an invalid entity"); return; } this.playerEntity.attackTargetEntityWithCurrentItem(entity); } } } }
public ICPacketUseEntity(IEntity entity) { super(new CPacketUseEntity(entity.getEntity())); }
/** * Processes interactions ((un)leashing, opening command block GUI) and attacks on an entity with players currently * equipped item */ public void processUseEntity(CPacketUseEntity packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld()); WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension); Entity entity = packetIn.getEntityFromWorld(worldserver); this.playerEntity.markPlayerActive(); if (entity != null) { boolean flag = this.playerEntity.canEntityBeSeen(entity); double d0 = 36.0D; if (!flag) { d0 = 9.0D; } if (this.playerEntity.getDistanceSqToEntity(entity) < d0) { if (packetIn.getAction() == CPacketUseEntity.Action.INTERACT) { EnumHand enumhand = packetIn.getHand(); this.playerEntity.func_190775_a(entity, enumhand); } else if (packetIn.getAction() == CPacketUseEntity.Action.INTERACT_AT) { EnumHand enumhand1 = packetIn.getHand(); entity.applyPlayerInteraction(this.playerEntity, packetIn.getHitVec(), enumhand1); } else if (packetIn.getAction() == CPacketUseEntity.Action.ATTACK) { if (entity instanceof EntityItem || entity instanceof EntityXPOrb || entity instanceof EntityArrow || entity == this.playerEntity) { this.kickPlayerFromServer("Attempting to attack an invalid entity"); this.serverController.logWarning("Player " + this.playerEntity.getName() + " tried to attack an invalid entity"); return; } this.playerEntity.attackTargetEntityWithCurrentItem(entity); } } } }
/** * Processes interactions ((un)leashing, opening command block GUI) and attacks on an entity with players currently * equipped item */ public void processUseEntity(CPacketUseEntity packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld()); WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension); Entity entity = packetIn.getEntityFromWorld(worldserver); this.playerEntity.markPlayerActive(); if (entity != null) { boolean flag = this.playerEntity.canEntityBeSeen(entity); double d0 = 36.0D; if (!flag) { d0 = 9.0D; } if (this.playerEntity.getDistanceSqToEntity(entity) < d0) { if (packetIn.getAction() == CPacketUseEntity.Action.INTERACT) { EnumHand enumhand = packetIn.getHand(); ItemStack itemstack = this.playerEntity.getHeldItem(enumhand); this.playerEntity.interact(entity, itemstack, enumhand); } else if (packetIn.getAction() == CPacketUseEntity.Action.INTERACT_AT) { EnumHand enumhand1 = packetIn.getHand(); ItemStack itemstack1 = this.playerEntity.getHeldItem(enumhand1); if(net.minecraftforge.common.ForgeHooks.onInteractEntityAt(playerEntity, entity, packetIn.getHitVec(), itemstack1, enumhand1)) return; entity.applyPlayerInteraction(this.playerEntity, packetIn.getHitVec(), itemstack1, enumhand1); } else if (packetIn.getAction() == CPacketUseEntity.Action.ATTACK) { if (entity instanceof EntityItem || entity instanceof EntityXPOrb || entity instanceof EntityArrow || entity == this.playerEntity) { this.kickPlayerFromServer("Attempting to attack an invalid entity"); this.serverController.logWarning("Player " + this.playerEntity.getName() + " tried to attack an invalid entity"); return; } this.playerEntity.attackTargetEntityWithCurrentItem(entity); } } } }
@Override public void processUseEntity(CPacketUseEntity p_147340_1_) { }
@Override public void processUseEntity(@Nonnull CPacketUseEntity p_147340_1_) { }
@Override public void processUseEntity(CPacketUseEntity packetIn) { }
/** * Processes interactions ((un)leashing, opening command block GUI) and attacks on an entity with players currently * equipped item */ void processUseEntity(CPacketUseEntity packetIn);