Beispiel #1
0
  void a(DataInput datainput) {
    a.clear();
    NBTBase nbtbase;

    for (; (nbtbase = NBTBase.b(datainput)).a() != 0; a.put(nbtbase.c(), nbtbase)) {;
    }
  }
Beispiel #2
0
  public void a(NBTTagCompound nbttagcompound) {
    Collection collection = nbttagcompound.c();
    Iterator iterator = collection.iterator();

    while (iterator.hasNext()) {
      NBTBase nbtbase = (NBTBase) iterator.next();
      String s = nbtbase.getName();
      String s1 = nbttagcompound.getString(nbtbase.getName());

      this.set(s, s1);
    }
  }
Beispiel #3
0
  void a(DataOutput dataoutput) {
    NBTBase nbtbase;

    for (Iterator iterator = a.values().iterator();
        iterator.hasNext();
        NBTBase.a(nbtbase, dataoutput)) {
      nbtbase = (NBTBase) iterator.next();
    }

    dataoutput.writeByte(0);
  }
Beispiel #4
0
  public void a(NBTTagCompound nbttagcompound) {
    this.m(nbttagcompound.getFloat("AbsorptionAmount"));
    if (nbttagcompound.hasKeyOfType("Attributes", 9)
        && this.world != null
        && !this.world.isStatic) {
      GenericAttributes.a(this.bc(), nbttagcompound.getList("Attributes", 10));
    }

    if (nbttagcompound.hasKeyOfType("ActiveEffects", 9)) {
      NBTTagList nbttaglist = nbttagcompound.getList("ActiveEffects", 10);

      for (int i = 0; i < nbttaglist.size(); ++i) {
        NBTTagCompound nbttagcompound1 = nbttaglist.get(i);
        MobEffect mobeffect = MobEffect.b(nbttagcompound1);

        if (mobeffect != null) {
          this.effects.put(Integer.valueOf(mobeffect.getEffectId()), mobeffect);
        }
      }
    }

    if (nbttagcompound.hasKeyOfType("HealF", 99)) {
      this.setHealth(nbttagcompound.getFloat("HealF"));
    } else {
      NBTBase nbtbase = nbttagcompound.get("Health");

      if (nbtbase == null) {
        this.setHealth(this.getMaxHealth());
      } else if (nbtbase.getTypeId() == 5) {
        this.setHealth(((NBTTagFloat) nbtbase).h());
      } else if (nbtbase.getTypeId() == 2) {
        this.setHealth((float) ((NBTTagShort) nbtbase).e());
      }
    }

    this.hurtTicks = nbttagcompound.getShort("HurtTime");
    this.deathTicks = nbttagcompound.getShort("DeathTime");
    this.attackTicks = nbttagcompound.getShort("AttackTime");
  }
Beispiel #5
0
  public void a(NBTTagCompound nbttagcompound) {
    this.m(nbttagcompound.getFloat("AbsorptionAmount"));
    if (nbttagcompound.hasKey("Attributes") && this.world != null && !this.world.isStatic) {
      GenericAttributes.a(
          this.aX(),
          nbttagcompound.getList("Attributes"),
          this.world == null ? null : this.world.getLogger());
    }

    if (nbttagcompound.hasKey("ActiveEffects")) {
      NBTTagList nbttaglist = nbttagcompound.getList("ActiveEffects");

      for (int i = 0; i < nbttaglist.size(); ++i) {
        NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.get(i);
        MobEffect mobeffect = MobEffect.b(nbttagcompound1);

        this.effects.put(Integer.valueOf(mobeffect.getEffectId()), mobeffect);
      }
    }

    // CraftBukkit start
    if (nbttagcompound.hasKey("Bukkit.MaxHealth")) {
      NBTBase nbtbase = nbttagcompound.get("Bukkit.MaxHealth");
      if (nbtbase.getTypeId() == 5) {
        this.getAttributeInstance(GenericAttributes.a)
            .setValue((double) ((NBTTagFloat) nbtbase).data);
      } else if (nbtbase.getTypeId() == 3) {
        this.getAttributeInstance(GenericAttributes.a)
            .setValue((double) ((NBTTagInt) nbtbase).data);
      }
    }
    // CraftBukkit end

    if (nbttagcompound.hasKey("HealF")) {
      this.setHealth(nbttagcompound.getFloat("HealF"));
    } else {
      NBTBase nbtbase = nbttagcompound.get("Health");

      if (nbtbase == null) {
        this.setHealth(this.getMaxHealth());
      } else if (nbtbase.getTypeId() == 5) {
        this.setHealth(((NBTTagFloat) nbtbase).data);
      } else if (nbtbase.getTypeId() == 2) {
        this.setHealth((float) ((NBTTagShort) nbtbase).data);
      }
    }

    this.hurtTicks = nbttagcompound.getShort("HurtTime");
    this.deathTicks = nbttagcompound.getShort("DeathTime");
    this.attackTicks = nbttagcompound.getShort("AttackTime");
  }
 @Override
 public void setTag(NBTBase base) {
   if (!(base instanceof NBTTagCompound)) return;
   NBTTagCompound b = (NBTTagCompound) base;
   NBTTagCompound original = getTag();
   if (!b.has("x")) b.set("x", original.get("x"));
   if (!b.has("y")) b.set("y", original.get("y"));
   if (!b.has("z")) b.set("z", original.get("z"));
   Object tile = null;
   try {
     tile =
         method_getTileEntityAt.invoke(block.getWorld(), block.getX(), block.getY(), block.getZ());
   } catch (Exception e) {
     e.printStackTrace();
   }
   if (tile != null) {
     try {
       method_Write.invoke(tile, base.getHandle());
     } catch (Exception e) {
       e.printStackTrace();
     }
     int maxDist = Bukkit.getServer().getViewDistance() * 32;
     for (Player p : block.getWorld().getPlayers()) {
       if (p.getLocation().distance(block.getLocation()) < maxDist) {
         try {
           Object packet = method_getUpdatePacket.invoke(tile);
           Object mPlayer = method_getHandle.invoke(p);
           if (StaticValues.isMCPC) {
             Object netServerHandler = field_playerNetServerHandler.get(mPlayer);
             method_sendPacketToPlayer.invoke(netServerHandler, packet);
           } else {
             Object connection = field_playerConnection.get(mPlayer);
             method_sendPacket.invoke(connection, packet);
           }
         } catch (Exception e) {
           e.printStackTrace();
         }
       }
     }
   }
 }
Beispiel #7
0
 public void a(String s, NBTBase nbtbase) {
   a.put(s, nbtbase.m(s));
 }