/** * Sets the velocity of the specified entity to the specified value */ public void handleEntityVelocity(S12PacketEntityVelocity packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityID()); if (Minecraft.getMinecraft().thePlayer == entity) { EventPlayerVelocity eventPlayerVelocity = new EventPlayerVelocity(100, 100); eventPlayerVelocity.call(); if (eventPlayerVelocity.isCancelled()) { return; } } else if (entity != null) { entity.setVelocity((packetIn.getMotionX() * 100 / 100) / 8000.0D, (packetIn.getMotionY() * 100 / 100) / 8000.0D, (packetIn.getMotionZ() * 100 / 100) / 8000.0D); } }
/** * Sets the velocity of the specified entity to the specified value */ public void handleEntityVelocity(S12PacketEntityVelocity p_147244_1_) { final EventPacketReceive eventPacket = new EventPacketReceive(p_147244_1_); eventPacket.onEvent(); if(eventPacket.isCancelled()){ eventPacket.setCancelled(false); return; } Entity var2 = this.clientWorldController.getEntityByID(p_147244_1_.func_149412_c()); if (var2 != null) { var2.setVelocity((double)p_147244_1_.func_149411_d() / 8000.0D, (double)p_147244_1_.func_149410_e() / 8000.0D, (double)p_147244_1_.func_149409_f() / 8000.0D); } }
/** * Sets the velocity of the specified entity to the specified value */ public void handleEntityVelocity(S12PacketEntityVelocity packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityID()); if (entity != null) { entity.setVelocity((double)packetIn.getMotionX() / 8000.0D, (double)packetIn.getMotionY() / 8000.0D, (double)packetIn.getMotionZ() / 8000.0D); } }
@EventTarget private void onPacketReceive(PacketReceiveEvent event) { S12PacketEntityVelocity packet; if (event.packet instanceof S12PacketEntityVelocity && this.mc.theWorld.getEntityByID((packet = (S12PacketEntityVelocity)event.packet).getEntityID()) == this.mc.thePlayer) { if (this.percent > 0.0) { packet.motionX = (int)((double)packet.motionX * (this.percent / 100.0)); packet.motionY = (int)((double)packet.motionY * (this.percent / 100.0)); packet.motionZ = (int)((double)packet.motionZ * (this.percent / 100.0)); } else { event.setCancelled(true); } } }
@Override public void onPacketReceive(EventPacketReceive event){ Packet eventPacket = event.getPacket(); if(eventPacket instanceof S12PacketEntityVelocity){ event.setCancelled(true); } }
public void handleEntityVelocity(S12PacketEntityVelocity p_147244_1_) { Entity entity = this.clientWorldController.getEntityByID(p_147244_1_.func_149412_c()); if (entity != null) { entity.setVelocity((double)p_147244_1_.func_149411_d() / 8000.0D, (double)p_147244_1_.func_149410_e() / 8000.0D, (double)p_147244_1_.func_149409_f() / 8000.0D); } }
@Override protected void onImpact(MovingObjectPosition mop) { if (mop.typeOfHit == MovingObjectType.BLOCK) { BlockPos pos = mop.getBlockPos(); Material m = worldObj.getBlockState(pos).getBlock().getMaterial(); if (m == Material.leaves) { if (!worldObj.isRemote && canGrief && Config.canDekuDenude()) { worldObj.destroyBlock(pos, true); } } else if (m.blocksMovement()) { if (mop.sideHit == EnumFacing.UP) { posY = pos.getY() + 1; rotationPitch = 0.0F; motionY = 0.0D; } else { setDead(); releaseDrops(); } } } else if (mop.entityHit != null && (mop.entityHit != getThrower() || ticksExisted >= 5)) { if (getDamage() > 0.0F && !affectedEntities.contains(mop.entityHit.getEntityId())) { mop.entityHit.attackEntityFrom(getDamageSource(), getDamage()); affectedEntities.add(mop.entityHit.getEntityId()); } if (!(mop.entityHit instanceof EntityLivingBase) || rand.nextFloat() > ((EntityLivingBase) mop.entityHit).getAttributeMap().getAttributeInstance(SharedMonsterAttributes.knockbackResistance).getAttributeValue()) { mop.entityHit.motionX = this.motionX * 1.8D; mop.entityHit.motionY = this.motionY + 0.5D; mop.entityHit.motionZ = this.motionZ * 1.8D; mop.entityHit.rotationYaw += 30.0F * this.ticksExisted; if (mop.entityHit instanceof EntityPlayerMP && !worldObj.isRemote) { ((EntityPlayerMP) mop.entityHit).playerNetServerHandler.sendPacket(new S12PacketEntityVelocity(mop.entityHit)); } } } }
/** * Called on the server from {@link DashImpactPacket} to process the impact data from the client * @param player Player's motionX and motionZ have been set by the packet, so the values may be used * @param mop Null assumes a block was hit (none of the block data is needed, so it is not sent), * or a valid MovingObjectPosition for the entity hit */ public void onImpact(World world, EntityPlayer player, MovingObjectPosition mop) { if (mop != null && mop.typeOfHit == MovingObjectType.ENTITY) { target = mop.entityHit; double dist = target.getDistance(initialPosition.xCoord, initialPosition.yCoord, initialPosition.zCoord); // Subtract half the width for each entity to account for their bounding box size dist -= (target.width / 2.0F) + (player.width / 2.0F); // Base player speed is 0.1D; heavy boots = 0.04D, pegasus = 0.13D double speed = player.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.movementSpeed).getAttributeValue(); double sf = (1.0D + (speed - BASE_MOVE)); // speed factor if (speed > 0.075D && dist > getMinDistance() && player.getDistanceSqToEntity(target) < 6.0D) { float dmg = (float) getDamage() + (float)((dist / 2.0D) - 2.0D); impactTime = 5; // time player will be immune to damage from the target entity target.attackEntityFrom(DamageUtils.causeNonSwordDamage(player), (float)(dmg * sf * sf)); double resist = 1.0D; if (target instanceof EntityLivingBase) { resist -= ((EntityLivingBase) target).getEntityAttribute(SharedMonsterAttributes.knockbackResistance).getAttributeValue(); } double k = sf * resist * (distance / 3.0F) * 0.6000000238418579D; target.addVelocity(player.motionX * k * (0.2D + (0.1D * level)), 0.1D + k * (level * 0.025D), player.motionZ * k * (0.2D + (0.1D * level))); // if player, send velocity update to client if (target instanceof EntityPlayerMP && !player.worldObj.isRemote) { ((EntityPlayerMP) target).playerNetServerHandler.sendPacket(new S12PacketEntityVelocity(target)); } } } WorldUtils.playSoundAtEntity(player, Sounds.SLAM, 0.4F, 0.5F); setNotDashing(); }
public int getPacketVelocityEntityId(S12PacketEntityVelocity p){ return p.func_149412_c(); }
public int getXMovePacketVel(S12PacketEntityVelocity p){ return p.func_149411_d(); }
public int getYMovePacketVel(S12PacketEntityVelocity p){ return p.func_149410_e(); }
public int getZMovePacketVel(S12PacketEntityVelocity p){ return p.func_149409_f(); }
@Override public Packet entityVelocity(int entityID, double motX, double motY, double motZ) { return (Packet) new S12PacketEntityVelocity(entityID, motX, motY, motZ); }
/** * Sets the velocity of the specified entity to the specified value */ void handleEntityVelocity(S12PacketEntityVelocity packetIn);
/** * Sets the velocity of the specified entity to the specified value */ void handleEntityVelocity(S12PacketEntityVelocity var1);
void handleEntityVelocity(S12PacketEntityVelocity p_147244_1_);