use of net.minecraft.network.play.server.SPacketEntityHeadLook in project Minecraft-SlientClient-Hack by YouNeverKnow00.
the class EntityTrackerEntry method updatePlayerList.
public void updatePlayerList(List<EntityPlayer> players) {
this.playerEntitiesUpdated = false;
if (!this.updatedPlayerVisibility || this.trackedEntity.getDistanceSq(this.lastTrackedEntityPosX, this.lastTrackedEntityPosY, this.lastTrackedEntityPosZ) > 16.0D) {
this.lastTrackedEntityPosX = this.trackedEntity.posX;
this.lastTrackedEntityPosY = this.trackedEntity.posY;
this.lastTrackedEntityPosZ = this.trackedEntity.posZ;
this.updatedPlayerVisibility = true;
this.playerEntitiesUpdated = true;
this.updatePlayerEntities(players);
}
List<Entity> list = this.trackedEntity.getPassengers();
if (!list.equals(this.passengers)) {
this.passengers = list;
this.sendPacketToTrackedPlayers(new SPacketSetPassengers(this.trackedEntity));
}
if (this.trackedEntity instanceof EntityItemFrame && this.updateCounter % 10 == 0) {
EntityItemFrame entityitemframe = (EntityItemFrame) this.trackedEntity;
ItemStack itemstack = entityitemframe.getDisplayedItem();
if (itemstack.getItem() instanceof ItemMap) {
MapData mapdata = Items.FILLED_MAP.getMapData(itemstack, this.trackedEntity.world);
for (EntityPlayer entityplayer : players) {
EntityPlayerMP entityplayermp = (EntityPlayerMP) entityplayer;
mapdata.updateVisiblePlayers(entityplayermp, itemstack);
Packet<?> packet = Items.FILLED_MAP.createMapDataPacket(itemstack, this.trackedEntity.world, entityplayermp);
if (packet != null) {
entityplayermp.connection.sendPacket(packet);
}
}
}
this.sendMetadataToAllAssociatedPlayers();
}
if (this.updateCounter % this.updateFrequency == 0 || this.trackedEntity.isAirBorne || this.trackedEntity.getDataManager().isDirty()) {
if (this.trackedEntity.isRiding()) {
int j1 = MathHelper.floor(this.trackedEntity.rotationYaw * 256.0F / 360.0F);
int l1 = MathHelper.floor(this.trackedEntity.rotationPitch * 256.0F / 360.0F);
boolean flag3 = Math.abs(j1 - this.encodedRotationYaw) >= 1 || Math.abs(l1 - this.encodedRotationPitch) >= 1;
if (flag3) {
this.sendPacketToTrackedPlayers(new SPacketEntity.S16PacketEntityLook(this.trackedEntity.getEntityId(), (byte) j1, (byte) l1, this.trackedEntity.onGround));
this.encodedRotationYaw = j1;
this.encodedRotationPitch = l1;
}
this.encodedPosX = EntityTracker.getPositionLong(this.trackedEntity.posX);
this.encodedPosY = EntityTracker.getPositionLong(this.trackedEntity.posY);
this.encodedPosZ = EntityTracker.getPositionLong(this.trackedEntity.posZ);
this.sendMetadataToAllAssociatedPlayers();
this.ridingEntity = true;
} else {
++this.ticksSinceLastForcedTeleport;
long i1 = EntityTracker.getPositionLong(this.trackedEntity.posX);
long i2 = EntityTracker.getPositionLong(this.trackedEntity.posY);
long j2 = EntityTracker.getPositionLong(this.trackedEntity.posZ);
int k2 = MathHelper.floor(this.trackedEntity.rotationYaw * 256.0F / 360.0F);
int i = MathHelper.floor(this.trackedEntity.rotationPitch * 256.0F / 360.0F);
long j = i1 - this.encodedPosX;
long k = i2 - this.encodedPosY;
long l = j2 - this.encodedPosZ;
Packet<?> packet1 = null;
boolean flag = j * j + k * k + l * l >= 128L || this.updateCounter % 60 == 0;
boolean flag1 = Math.abs(k2 - this.encodedRotationYaw) >= 1 || Math.abs(i - this.encodedRotationPitch) >= 1;
if (this.updateCounter > 0 || this.trackedEntity instanceof EntityArrow) {
if (j >= -32768L && j < 32768L && k >= -32768L && k < 32768L && l >= -32768L && l < 32768L && this.ticksSinceLastForcedTeleport <= 400 && !this.ridingEntity && this.onGround == this.trackedEntity.onGround) {
if ((!flag || !flag1) && !(this.trackedEntity instanceof EntityArrow)) {
if (flag) {
packet1 = new SPacketEntity.S15PacketEntityRelMove(this.trackedEntity.getEntityId(), j, k, l, this.trackedEntity.onGround);
} else if (flag1) {
packet1 = new SPacketEntity.S16PacketEntityLook(this.trackedEntity.getEntityId(), (byte) k2, (byte) i, this.trackedEntity.onGround);
}
} else {
packet1 = new SPacketEntity.S17PacketEntityLookMove(this.trackedEntity.getEntityId(), j, k, l, (byte) k2, (byte) i, this.trackedEntity.onGround);
}
} else {
this.onGround = this.trackedEntity.onGround;
this.ticksSinceLastForcedTeleport = 0;
this.resetPlayerVisibility();
packet1 = new SPacketEntityTeleport(this.trackedEntity);
}
}
boolean flag2 = this.sendVelocityUpdates;
if (this.trackedEntity instanceof EntityLivingBase && ((EntityLivingBase) this.trackedEntity).isElytraFlying()) {
flag2 = true;
}
if (flag2 && this.updateCounter > 0) {
double d0 = this.trackedEntity.motionX - this.lastTrackedEntityMotionX;
double d1 = this.trackedEntity.motionY - this.lastTrackedEntityMotionY;
double d2 = this.trackedEntity.motionZ - this.motionZ;
double d3 = 0.02D;
double d4 = d0 * d0 + d1 * d1 + d2 * d2;
if (d4 > 4.0E-4D || d4 > 0.0D && this.trackedEntity.motionX == 0.0D && this.trackedEntity.motionY == 0.0D && this.trackedEntity.motionZ == 0.0D) {
this.lastTrackedEntityMotionX = this.trackedEntity.motionX;
this.lastTrackedEntityMotionY = this.trackedEntity.motionY;
this.motionZ = this.trackedEntity.motionZ;
this.sendPacketToTrackedPlayers(new SPacketEntityVelocity(this.trackedEntity.getEntityId(), this.lastTrackedEntityMotionX, this.lastTrackedEntityMotionY, this.motionZ));
}
}
if (packet1 != null) {
this.sendPacketToTrackedPlayers(packet1);
}
this.sendMetadataToAllAssociatedPlayers();
if (flag) {
this.encodedPosX = i1;
this.encodedPosY = i2;
this.encodedPosZ = j2;
}
if (flag1) {
this.encodedRotationYaw = k2;
this.encodedRotationPitch = i;
}
this.ridingEntity = false;
}
int k1 = MathHelper.floor(this.trackedEntity.getRotationYawHead() * 256.0F / 360.0F);
if (Math.abs(k1 - this.lastHeadMotion) >= 1) {
this.sendPacketToTrackedPlayers(new SPacketEntityHeadLook(this.trackedEntity, (byte) k1));
this.lastHeadMotion = k1;
}
this.trackedEntity.isAirBorne = false;
}
++this.updateCounter;
if (this.trackedEntity.velocityChanged) {
this.sendToTrackingAndSelf(new SPacketEntityVelocity(this.trackedEntity));
this.trackedEntity.velocityChanged = false;
}
}
use of net.minecraft.network.play.server.SPacketEntityHeadLook in project CumServerPro by MCUmbrella.
the class EntityTrackerEntry method updatePlayerList.
public void updatePlayerList(List<EntityPlayer> players) {
this.playerEntitiesUpdated = false;
if (!this.updatedPlayerVisibility || this.trackedEntity.getDistanceSq(this.lastTrackedEntityPosX, this.lastTrackedEntityPosY, this.lastTrackedEntityPosZ) > 16.0D) {
this.lastTrackedEntityPosX = this.trackedEntity.posX;
this.lastTrackedEntityPosY = this.trackedEntity.posY;
this.lastTrackedEntityPosZ = this.trackedEntity.posZ;
this.updatedPlayerVisibility = true;
this.playerEntitiesUpdated = true;
this.updatePlayerEntities(players);
}
List<Entity> list = this.trackedEntity.getPassengers();
if (!list.equals(this.passengers)) {
this.passengers = list;
this.sendToTrackingAndSelf(new SPacketSetPassengers(this.trackedEntity));
}
if (// CraftBukkit - Moved below, should always enter this block
this.trackedEntity instanceof EntityItemFrame) /*&& this.updateCounter % 10 == 0*/
{
EntityItemFrame entityitemframe = (EntityItemFrame) this.trackedEntity;
ItemStack itemstack = entityitemframe.getDisplayedItem();
if (// CraftBukkit - Moved this.updateCounter % 10 logic here so item frames do not enter the other blocks
this.updateCounter % 10 == 0 && itemstack.getItem() instanceof ItemMap) {
MapData mapdata = ((ItemMap) itemstack.getItem()).getMapData(itemstack, this.trackedEntity.world);
for (EntityPlayer entityplayer : trackingPlayers) {
EntityPlayerMP entityplayermp = (EntityPlayerMP) entityplayer;
mapdata.updateVisiblePlayers(entityplayermp, itemstack);
Packet<?> packet = ((ItemMap) itemstack.getItem()).createMapDataPacket(itemstack, this.trackedEntity.world, entityplayermp);
if (packet != null) {
entityplayermp.connection.sendPacket(packet);
}
}
}
this.sendMetadata();
}
if (this.updateCounter % this.updateFrequency == 0 || this.trackedEntity.isAirBorne || this.trackedEntity.getDataManager().isDirty()) {
if (this.trackedEntity.isRiding()) {
int j1 = MathHelper.floor(this.trackedEntity.rotationYaw * 256.0F / 360.0F);
int l1 = MathHelper.floor(this.trackedEntity.rotationPitch * 256.0F / 360.0F);
boolean flag3 = Math.abs(j1 - this.encodedRotationYaw) >= 1 || Math.abs(l1 - this.encodedRotationPitch) >= 1;
if (flag3) {
this.sendPacketToTrackedPlayers(new SPacketEntity.S16PacketEntityLook(this.trackedEntity.getEntityId(), (byte) j1, (byte) l1, this.trackedEntity.onGround));
this.encodedRotationYaw = j1;
this.encodedRotationPitch = l1;
}
this.encodedPosX = EntityTracker.getPositionLong(this.trackedEntity.posX);
this.encodedPosY = EntityTracker.getPositionLong(this.trackedEntity.posY);
this.encodedPosZ = EntityTracker.getPositionLong(this.trackedEntity.posZ);
this.sendMetadata();
this.ridingEntity = true;
} else {
++this.ticksSinceLastForcedTeleport;
long i1 = EntityTracker.getPositionLong(this.trackedEntity.posX);
long i2 = EntityTracker.getPositionLong(this.trackedEntity.posY);
long j2 = EntityTracker.getPositionLong(this.trackedEntity.posZ);
int k2 = MathHelper.floor(this.trackedEntity.rotationYaw * 256.0F / 360.0F);
int i = MathHelper.floor(this.trackedEntity.rotationPitch * 256.0F / 360.0F);
long j = i1 - this.encodedPosX;
long k = i2 - this.encodedPosY;
long l = j2 - this.encodedPosZ;
Packet<?> packet1 = null;
boolean flag = j * j + k * k + l * l >= 128L || this.updateCounter % 60 == 0;
boolean flag1 = Math.abs(k2 - this.encodedRotationYaw) >= 1 || Math.abs(i - this.encodedRotationPitch) >= 1;
// CraftBukkit start - Code moved from below
if (flag) {
this.encodedPosX = i1;
this.encodedPosY = i2;
this.encodedPosZ = j2;
}
if (flag1) {
this.encodedRotationYaw = k2;
this.encodedRotationPitch = i;
}
// CraftBukkit end
if (this.updateCounter > 0 || this.trackedEntity instanceof EntityArrow) {
if (j >= -32768L && j < 32768L && k >= -32768L && k < 32768L && l >= -32768L && l < 32768L && this.ticksSinceLastForcedTeleport <= 400 && !this.ridingEntity && this.onGround == this.trackedEntity.onGround) {
if ((!flag || !flag1) && !(this.trackedEntity instanceof EntityArrow)) {
if (flag) {
packet1 = new SPacketEntity.S15PacketEntityRelMove(this.trackedEntity.getEntityId(), j, k, l, this.trackedEntity.onGround);
} else if (flag1) {
packet1 = new SPacketEntity.S16PacketEntityLook(this.trackedEntity.getEntityId(), (byte) k2, (byte) i, this.trackedEntity.onGround);
}
} else {
packet1 = new SPacketEntity.S17PacketEntityLookMove(this.trackedEntity.getEntityId(), j, k, l, (byte) k2, (byte) i, this.trackedEntity.onGround);
}
} else {
this.onGround = this.trackedEntity.onGround;
this.ticksSinceLastForcedTeleport = 0;
// CraftBukkit start - Refresh list of who can see a player before sending teleport packet
if (this.trackedEntity instanceof EntityPlayer) {
this.updatePlayerEntities(new java.util.ArrayList<>(this.trackingPlayers));
}
// CraftBukkit end
this.resetPlayerVisibility();
packet1 = new SPacketEntityTeleport(this.trackedEntity);
}
}
boolean flag2 = this.sendVelocityUpdates;
if (this.trackedEntity instanceof EntityLivingBase && ((EntityLivingBase) this.trackedEntity).isElytraFlying()) {
flag2 = true;
}
if (flag2 && this.updateCounter > 0) {
double d0 = this.trackedEntity.motionX - this.lastTrackedEntityMotionX;
double d1 = this.trackedEntity.motionY - this.lastTrackedEntityMotionY;
double d2 = this.trackedEntity.motionZ - this.motionZ;
double d3 = 0.02D;
double d4 = d0 * d0 + d1 * d1 + d2 * d2;
if (d4 > 4.0E-4D || d4 > 0.0D && this.trackedEntity.motionX == 0.0D && this.trackedEntity.motionY == 0.0D && this.trackedEntity.motionZ == 0.0D) {
this.lastTrackedEntityMotionX = this.trackedEntity.motionX;
this.lastTrackedEntityMotionY = this.trackedEntity.motionY;
this.motionZ = this.trackedEntity.motionZ;
this.sendPacketToTrackedPlayers(new SPacketEntityVelocity(this.trackedEntity.getEntityId(), this.lastTrackedEntityMotionX, this.lastTrackedEntityMotionY, this.motionZ));
}
}
if (packet1 != null) {
this.sendPacketToTrackedPlayers(packet1);
}
this.sendMetadata();
/* CraftBukkit start - Code moved up
if (flag)
{
this.encodedPosX = i1;
this.encodedPosY = i2;
this.encodedPosZ = j2;
}
if (flag1)
{
this.encodedRotationYaw = k2;
this.encodedRotationPitch = i;
}
// CraftBukkit end */
this.ridingEntity = false;
}
int k1 = MathHelper.floor(this.trackedEntity.getRotationYawHead() * 256.0F / 360.0F);
if (Math.abs(k1 - this.lastHeadMotion) >= 1) {
this.sendPacketToTrackedPlayers(new SPacketEntityHeadLook(this.trackedEntity, (byte) k1));
this.lastHeadMotion = k1;
}
this.trackedEntity.isAirBorne = false;
}
++this.updateCounter;
if (this.trackedEntity.velocityChanged) {
// this.sendToTrackingAndSelf(new SPacketEntityVelocity(this.trackedEntity));
// CraftBukkit start - Create PlayerVelocity event
boolean cancelled = false;
if (this.trackedEntity instanceof EntityPlayer) {
Player player = (Player) this.trackedEntity.getBukkitEntity();
org.bukkit.util.Vector velocity = player.getVelocity();
PlayerVelocityEvent event = new PlayerVelocityEvent(player, velocity.clone());
this.trackedEntity.world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
cancelled = true;
} else if (!velocity.equals(event.getVelocity())) {
player.setVelocity(event.getVelocity());
}
}
if (!cancelled) {
this.sendToTrackingAndSelf(new SPacketEntityVelocity(this.trackedEntity));
}
// CraftBukkit end
this.trackedEntity.velocityChanged = false;
}
}
use of net.minecraft.network.play.server.SPacketEntityHeadLook in project CumServerPro by MCUmbrella.
the class EntityTrackerEntry method updatePlayerEntity.
public void updatePlayerEntity(EntityPlayerMP playerMP) {
if (playerMP != this.trackedEntity) {
if (this.isVisibleTo(playerMP)) {
if (!this.trackingPlayers.contains(playerMP) && (this.isPlayerWatchingThisChunk(playerMP) || this.trackedEntity.forceSpawn)) {
// CraftBukkit start - respect vanish API
if (this.trackedEntity instanceof EntityPlayerMP) {
Player player = ((EntityPlayerMP) this.trackedEntity).getBukkitEntity();
if (!playerMP.getBukkitEntity().canSee(player)) {
return;
}
}
playerMP.entityRemoveQueue.remove(Integer.valueOf(this.trackedEntity.getEntityId()));
// CraftBukkit end
this.trackingPlayers.add(playerMP);
Packet<?> packet = this.createSpawnPacket();
playerMP.connection.sendPacket(packet);
if (!this.trackedEntity.getDataManager().isEmpty()) {
playerMP.connection.sendPacket(new SPacketEntityMetadata(this.trackedEntity.getEntityId(), this.trackedEntity.getDataManager(), true));
}
boolean flag = this.sendVelocityUpdates;
if (this.trackedEntity instanceof EntityLivingBase) {
AttributeMap attributemap = (AttributeMap) ((EntityLivingBase) this.trackedEntity).getAttributeMap();
Collection<IAttributeInstance> collection = attributemap.getWatchedAttributes();
// CraftBukkit start - If sending own attributes send scaled health instead of current maximum health
if (this.trackedEntity.getEntityId() == playerMP.getEntityId()) {
// TODO: Maybe we should check for instanceof before casting to EntityPlayerMP?
((EntityPlayerMP) this.trackedEntity).getBukkitEntity().injectScaledMaxHealth(collection, false);
}
if (!collection.isEmpty()) {
playerMP.connection.sendPacket(new SPacketEntityProperties(this.trackedEntity.getEntityId(), collection));
}
if (((EntityLivingBase) this.trackedEntity).isElytraFlying()) {
flag = true;
}
}
this.lastTrackedEntityMotionX = this.trackedEntity.motionX;
this.lastTrackedEntityMotionY = this.trackedEntity.motionY;
this.motionZ = this.trackedEntity.motionZ;
if (flag && !(packet instanceof SPacketSpawnMob)) {
playerMP.connection.sendPacket(new SPacketEntityVelocity(this.trackedEntity.getEntityId(), this.trackedEntity.motionX, this.trackedEntity.motionY, this.trackedEntity.motionZ));
}
if (this.trackedEntity instanceof EntityLivingBase) {
for (EntityEquipmentSlot entityequipmentslot : EntityEquipmentSlot.values()) {
ItemStack itemstack = ((EntityLivingBase) this.trackedEntity).getItemStackFromSlot(entityequipmentslot);
if (!itemstack.isEmpty()) {
playerMP.connection.sendPacket(new SPacketEntityEquipment(this.trackedEntity.getEntityId(), entityequipmentslot, itemstack));
}
}
}
if (this.trackedEntity instanceof EntityPlayer) {
EntityPlayer entityplayer = (EntityPlayer) this.trackedEntity;
if (entityplayer.isPlayerSleeping()) {
playerMP.connection.sendPacket(new SPacketUseBed(entityplayer, new BlockPos(this.trackedEntity)));
}
}
// CraftBukkit start - Fix for nonsensical head yaw
this.lastHeadMotion = MathHelper.floor(this.trackedEntity.getRotationYawHead() * 256.0F / 360.0F);
this.sendPacketToTrackedPlayers(new SPacketEntityHeadLook(this.trackedEntity, (byte) lastHeadMotion));
if (this.trackedEntity instanceof EntityLivingBase) {
EntityLivingBase entitylivingbase = (EntityLivingBase) this.trackedEntity;
for (PotionEffect potioneffect : entitylivingbase.getActivePotionEffects()) {
playerMP.connection.sendPacket(new SPacketEntityEffect(this.trackedEntity.getEntityId(), potioneffect));
}
}
if (!this.trackedEntity.getPassengers().isEmpty()) {
playerMP.connection.sendPacket(new SPacketSetPassengers(this.trackedEntity));
}
if (this.trackedEntity.isRiding()) {
playerMP.connection.sendPacket(new SPacketSetPassengers(this.trackedEntity.getRidingEntity()));
}
this.trackedEntity.addTrackingPlayer(playerMP);
playerMP.addEntity(this.trackedEntity);
net.minecraftforge.event.ForgeEventFactory.onStartEntityTracking(trackedEntity, playerMP);
}
} else if (this.trackingPlayers.contains(playerMP)) {
this.trackingPlayers.remove(playerMP);
this.trackedEntity.removeTrackingPlayer(playerMP);
playerMP.removeEntity(this.trackedEntity);
net.minecraftforge.event.ForgeEventFactory.onStopEntityTracking(trackedEntity, playerMP);
}
}
}
Aggregations