public Packet40EntityMetadata(int p_i5034_1_, DataWatcher p_i5034_2_, boolean p_i5034_3_) {
   this.field_73393_a = p_i5034_1_;
   if (p_i5034_3_) {
     this.field_73392_b = p_i5034_2_.func_75685_c();
   } else {
     this.field_73392_b = p_i5034_2_.func_75688_b();
   }
 }
Esempio n. 2
0
  /** Enable or disable a entity flag, see getEntityFlag to read the know flags. */
  protected void setFlag(int par1, boolean par2) {
    byte byte0 = dataWatcher.getWatchableObjectByte(0);

    if (par2) {
      dataWatcher.updateObject(0, Byte.valueOf((byte) (byte0 | 1 << par1)));
    } else {
      dataWatcher.updateObject(0, Byte.valueOf((byte) (byte0 & ~(1 << par1))));
    }
  }
Esempio n. 3
0
 public void readPacketData(DataInputStream datainputstream) throws IOException {
   entityId = datainputstream.readInt();
   type = datainputstream.readByte();
   xPosition = datainputstream.readInt();
   yPosition = datainputstream.readInt();
   zPosition = datainputstream.readInt();
   yaw = datainputstream.readByte();
   pitch = datainputstream.readByte();
   receivedMetadata = DataWatcher.readWatchableObjects(datainputstream);
 }
Esempio n. 4
0
 public Entity(World par1World) {
   entityId = nextEntityID++;
   renderDistanceWeight = 1.0D;
   preventEntitySpawning = false;
   onGround = false;
   isCollided = false;
   velocityChanged = false;
   field_9293_aM = true;
   isDead = false;
   yOffset = 0.0F;
   width = 0.6F;
   height = 1.8F;
   prevDistanceWalkedModified = 0.0F;
   distanceWalkedModified = 0.0F;
   fallDistance = 0.0F;
   nextStepDistance = 1;
   ySize = 0.0F;
   stepHeight = 0.0F;
   noClip = false;
   entityCollisionReduction = 0.0F;
   rand = new Random();
   ticksExisted = 0;
   fireResistance = 1;
   fire = 0;
   inWater = false;
   heartsLife = 0;
   firstUpdate = true;
   isImmuneToFire = false;
   dataWatcher = new DataWatcher();
   addedToChunk = false;
   worldObj = par1World;
   setPosition(0.0D, 0.0D, 0.0D);
   dataWatcher.addObject(0, Byte.valueOf((byte) 0));
   dataWatcher.addObject(1, Short.valueOf((short) 300));
   entityInit();
 }
Esempio n. 5
0
 public void setAir(int par1) {
   dataWatcher.updateObject(1, Short.valueOf((short) par1));
 }
Esempio n. 6
0
 public int getAir() {
   return dataWatcher.getWatchableObjectShort(1);
 }
Esempio n. 7
0
 /**
  * Return true if the flag is active for the entity. Know flags: 0) is burning; 1) is sneaking; 2)
  * is riding something
  */
 protected boolean getFlag(int par1) {
   return (dataWatcher.getWatchableObjectByte(0) & 1 << par1) != 0;
 }
Esempio n. 8
0
  /** also sends velocity, rotation, and riding info. */
  public void sendLocationToAllClients(List par1List) {
    this.playerEntitiesUpdated = false;

    if (!this.isDataInitialized
        || this.myEntity.getDistanceSq(this.posX, this.posY, this.posZ) > 16.0D) {
      this.posX = this.myEntity.posX;
      this.posY = this.myEntity.posY;
      this.posZ = this.myEntity.posZ;
      this.isDataInitialized = true;
      this.playerEntitiesUpdated = true;
      this.sendEventsToPlayers(par1List);
    }

    if (this.field_85178_v != this.myEntity.ridingEntity) {
      this.field_85178_v = this.myEntity.ridingEntity;
      this.sendPacketToAllTrackingPlayers(
          new Packet39AttachEntity(this.myEntity, this.myEntity.ridingEntity));
    }

    if (this.myEntity instanceof EntityItemFrame && this.ticks % 10 == 0) {
      EntityItemFrame var23 = (EntityItemFrame) this.myEntity;
      ItemStack var24 = var23.getDisplayedItem();

      if (var24 != null && var24.getItem() instanceof ItemMap) {
        MapData var26 = Item.map.getMapData(var24, this.myEntity.worldObj);
        Iterator var29 = par1List.iterator();

        while (var29.hasNext()) {
          EntityPlayer var30 = (EntityPlayer) var29.next();
          EntityPlayerMP var31 = (EntityPlayerMP) var30;
          var26.updateVisiblePlayers(var31, var24);

          if (var31.playerNetServerHandler.packetSize() <= 5) {
            Packet var32 = Item.map.createMapDataPacket(var24, this.myEntity.worldObj, var31);

            if (var32 != null) {
              var31.playerNetServerHandler.sendPacketToPlayer(var32);
            }
          }
        }
      }

      DataWatcher var28 = this.myEntity.getDataWatcher();

      if (var28.hasChanges()) {
        this.sendPacketToAllAssociatedPlayers(
            new Packet40EntityMetadata(this.myEntity.entityId, var28, false));
      }
    } else if (this.ticks++ % this.updateFrequency == 0 || this.myEntity.isAirBorne) {
      int var2;
      int var3;

      if (this.myEntity.ridingEntity == null) {
        ++this.ticksSinceLastForcedTeleport;
        var2 = this.myEntity.myEntitySize.multiplyBy32AndRound(this.myEntity.posX);
        var3 = MathHelper.floor_double(this.myEntity.posY * 32.0D);
        int var4 = this.myEntity.myEntitySize.multiplyBy32AndRound(this.myEntity.posZ);
        int var5 = MathHelper.floor_float(this.myEntity.rotationYaw * 256.0F / 360.0F);
        int var6 = MathHelper.floor_float(this.myEntity.rotationPitch * 256.0F / 360.0F);
        int var7 = var2 - this.lastScaledXPosition;
        int var8 = var3 - this.lastScaledYPosition;
        int var9 = var4 - this.lastScaledZPosition;
        Object var10 = null;
        boolean var11 =
            Math.abs(var7) >= 4
                || Math.abs(var8) >= 4
                || Math.abs(var9) >= 4
                || this.ticks % 60 == 0;
        boolean var12 = Math.abs(var5 - this.lastYaw) >= 4 || Math.abs(var6 - this.lastPitch) >= 4;

        if (var7 >= -128
            && var7 < 128
            && var8 >= -128
            && var8 < 128
            && var9 >= -128
            && var9 < 128
            && this.ticksSinceLastForcedTeleport <= 400
            && !this.ridingEntity) {
          if (var11 && var12) {
            var10 =
                new Packet33RelEntityMoveLook(
                    this.myEntity.entityId,
                    (byte) var7,
                    (byte) var8,
                    (byte) var9,
                    (byte) var5,
                    (byte) var6);
          } else if (var11) {
            var10 =
                new Packet31RelEntityMove(
                    this.myEntity.entityId, (byte) var7, (byte) var8, (byte) var9);
          } else if (var12) {
            var10 = new Packet32EntityLook(this.myEntity.entityId, (byte) var5, (byte) var6);
          }
        } else {
          this.ticksSinceLastForcedTeleport = 0;
          var10 =
              new Packet34EntityTeleport(
                  this.myEntity.entityId, var2, var3, var4, (byte) var5, (byte) var6);
        }

        if (this.sendVelocityUpdates) {
          double var13 = this.myEntity.motionX - this.motionX;
          double var15 = this.myEntity.motionY - this.motionY;
          double var17 = this.myEntity.motionZ - this.motionZ;
          double var19 = 0.02D;
          double var21 = var13 * var13 + var15 * var15 + var17 * var17;

          if (var21 > var19 * var19
              || var21 > 0.0D
                  && this.myEntity.motionX == 0.0D
                  && this.myEntity.motionY == 0.0D
                  && this.myEntity.motionZ == 0.0D) {
            this.motionX = this.myEntity.motionX;
            this.motionY = this.myEntity.motionY;
            this.motionZ = this.myEntity.motionZ;
            this.sendPacketToAllTrackingPlayers(
                new Packet28EntityVelocity(
                    this.myEntity.entityId, this.motionX, this.motionY, this.motionZ));
          }
        }

        if (var10 != null) {
          this.sendPacketToAllTrackingPlayers((Packet) var10);
        }

        DataWatcher var33 = this.myEntity.getDataWatcher();

        if (var33.hasChanges()) {
          this.sendPacketToAllAssociatedPlayers(
              new Packet40EntityMetadata(this.myEntity.entityId, var33, false));
        }

        if (var11) {
          this.lastScaledXPosition = var2;
          this.lastScaledYPosition = var3;
          this.lastScaledZPosition = var4;
        }

        if (var12) {
          this.lastYaw = var5;
          this.lastPitch = var6;
        }

        this.ridingEntity = false;
      } else {
        var2 = MathHelper.floor_float(this.myEntity.rotationYaw * 256.0F / 360.0F);
        var3 = MathHelper.floor_float(this.myEntity.rotationPitch * 256.0F / 360.0F);
        boolean var25 = Math.abs(var2 - this.lastYaw) >= 4 || Math.abs(var3 - this.lastPitch) >= 4;

        if (var25) {
          this.sendPacketToAllTrackingPlayers(
              new Packet32EntityLook(this.myEntity.entityId, (byte) var2, (byte) var3));
          this.lastYaw = var2;
          this.lastPitch = var3;
        }

        this.lastScaledXPosition =
            this.myEntity.myEntitySize.multiplyBy32AndRound(this.myEntity.posX);
        this.lastScaledYPosition = MathHelper.floor_double(this.myEntity.posY * 32.0D);
        this.lastScaledZPosition =
            this.myEntity.myEntitySize.multiplyBy32AndRound(this.myEntity.posZ);
        DataWatcher var27 = this.myEntity.getDataWatcher();

        if (var27.hasChanges()) {
          this.sendPacketToAllAssociatedPlayers(
              new Packet40EntityMetadata(this.myEntity.entityId, var27, false));
        }

        this.ridingEntity = true;
      }

      var2 = MathHelper.floor_float(this.myEntity.setRotationYawHead() * 256.0F / 360.0F);

      if (Math.abs(var2 - this.lastHeadMotion) >= 4) {
        this.sendPacketToAllTrackingPlayers(
            new Packet35EntityHeadRotation(this.myEntity.entityId, (byte) var2));
        this.lastHeadMotion = var2;
      }

      this.myEntity.isAirBorne = false;
    }

    if (this.myEntity.velocityChanged) {
      this.sendPacketToAllAssociatedPlayers(new Packet28EntityVelocity(this.myEntity));
      this.myEntity.velocityChanged = false;
    }
  }
 public void func_73273_a(DataOutputStream p_73273_1_) throws IOException {
   p_73273_1_.writeInt(this.field_73393_a);
   DataWatcher.func_75680_a(this.field_73392_b, p_73273_1_);
 }
 public void func_73267_a(DataInputStream p_73267_1_) throws IOException {
   this.field_73393_a = p_73267_1_.readInt();
   this.field_73392_b = DataWatcher.func_75686_a(p_73267_1_);
 }