示例#1
0
  public void a(NBTTagCompound nbttagcompound) {
    super.a(nbttagcompound);
    NBTTagList nbttaglist = nbttagcompound.getList("Inventory");

    this.inventory.b(nbttaglist);
    this.dimension = nbttagcompound.getInt("Dimension");
    this.sleeping = nbttagcompound.getBoolean("Sleeping");
    this.sleepTicks = nbttagcompound.getShort("SleepTimer");
    this.exp = nbttagcompound.getFloat("XpP");
    this.expLevel = nbttagcompound.getInt("XpLevel");
    this.expTotal = nbttagcompound.getInt("XpTotal");
    if (this.sleeping) {
      this.F =
          new ChunkCoordinates(
              MathHelper.floor(this.locX),
              MathHelper.floor(this.locY),
              MathHelper.floor(this.locZ));
      this.a(true, true, false);
    }

    if (nbttagcompound.hasKey("SpawnX")
        && nbttagcompound.hasKey("SpawnY")
        && nbttagcompound.hasKey("SpawnZ")) {
      this.b =
          new ChunkCoordinates(
              nbttagcompound.getInt("SpawnX"),
              nbttagcompound.getInt("SpawnY"),
              nbttagcompound.getInt("SpawnZ"));
    }

    this.foodData.a(nbttagcompound);
    this.abilities.b(nbttagcompound);
  }
示例#2
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");
  }
示例#3
0
  public void a(NBTTagCompound nbttagcompound) {
    super.a(nbttagcompound);
    this.o(nbttagcompound.getBoolean("EatingHaystack"));
    this.k(nbttagcompound.getBoolean("Bred"));
    this.setHasChest(nbttagcompound.getBoolean("ChestedHorse"));
    this.m(nbttagcompound.getBoolean("HasReproduced"));
    this.setType(nbttagcompound.getInt("Type"));
    this.setVariant(nbttagcompound.getInt("Variant"));
    this.setTemper(nbttagcompound.getInt("Temper"));
    this.setTame(nbttagcompound.getBoolean("Tame"));
    if (nbttagcompound.hasKeyOfType("OwnerUUID", 8)) {
      this.setOwnerUUID(nbttagcompound.getString("OwnerUUID"));
    }
    // CraftBukkit start
    if (nbttagcompound.hasKey("Bukkit.MaxDomestication")) {
      this.maxDomestication = nbttagcompound.getInt("Bukkit.MaxDomestication");
    }
    // CraftBukkit end
    AttributeInstance attributeinstance = this.bb().a("Speed");

    if (attributeinstance != null) {
      this.getAttributeInstance(GenericAttributes.d).setValue(attributeinstance.b() * 0.25D);
    }

    if (this.hasChest()) {
      NBTTagList nbttaglist = nbttagcompound.getList("Items", 10);

      this.loadChest();

      for (int i = 0; i < nbttaglist.size(); ++i) {
        NBTTagCompound nbttagcompound1 = nbttaglist.get(i);
        int j = nbttagcompound1.getByte("Slot") & 255;

        if (j >= 2 && j < this.inventoryChest.getSize()) {
          this.inventoryChest.setItem(j, ItemStack.createStack(nbttagcompound1));
        }
      }
    }

    ItemStack itemstack;

    if (nbttagcompound.hasKeyOfType("ArmorItem", 10)) {
      itemstack = ItemStack.createStack(nbttagcompound.getCompound("ArmorItem"));
      if (itemstack != null && a(itemstack.getItem())) {
        this.inventoryChest.setItem(1, itemstack);
      }
    }

    if (nbttagcompound.hasKeyOfType("SaddleItem", 10)) {
      itemstack = ItemStack.createStack(nbttagcompound.getCompound("SaddleItem"));
      if (itemstack != null && itemstack.getItem() == Items.SADDLE) {
        this.inventoryChest.setItem(0, itemstack);
      }
    } else if (nbttagcompound.getBoolean("Saddle")) {
      this.inventoryChest.setItem(0, new ItemStack(Items.SADDLE));
    }

    this.cO();
  }
  public Location getBedSpawnLocation() {
    NBTTagCompound data = getData();
    if (data == null) return null;

    if (data.hasKey("SpawnX") && data.hasKey("SpawnY") && data.hasKey("SpawnZ")) {
      String spawnWorld = data.getString("SpawnWorld");
      if (spawnWorld.equals("")) {
        spawnWorld = server.getWorlds().get(0).getName();
      }
      return new Location(
          server.getWorld(spawnWorld),
          data.getInt("SpawnX"),
          data.getInt("SpawnY"),
          data.getInt("SpawnZ"));
    }
    return null;
  }
 public void a(NBTTagCompound nbttagcompound) {
   super.a(nbttagcompound);
   if (nbttagcompound.hasKey("playerGameType")) {
     this.playerInteractManager.setGameMode(
         EnumGamemode.a(nbttagcompound.getInt("playerGameType")));
   }
   this.getBukkitEntity().readExtraData(nbttagcompound); // CraftBukkit
 }
示例#6
0
  public void a(NBTTagCompound nbttagcompound) {
    this.d = nbttagcompound.getShort("xTile");
    this.e = nbttagcompound.getShort("yTile");
    this.f = nbttagcompound.getShort("zTile");
    this.g = nbttagcompound.getByte("inTile") & 255;
    this.h = nbttagcompound.getByte("inData") & 255;
    this.shake = nbttagcompound.getByte("shake") & 255;
    this.inGround = nbttagcompound.getByte("inGround") == 1;
    if (nbttagcompound.hasKey("damage")) {
      this.damage = nbttagcompound.getDouble("damage");
    }

    if (nbttagcompound.hasKey("pickup")) {
      this.fromPlayer = nbttagcompound.getByte("pickup");
    } else if (nbttagcompound.hasKey("player")) {
      this.fromPlayer = nbttagcompound.getBoolean("player") ? 1 : 0;
    }
  }
  @Override
  public void a(NBTTagCompound nbttagcompound) {
    super.a(nbttagcompound);
    if (nbttagcompound.hasKey("SkeletonType")) {
      byte b0 = nbttagcompound.getByte("SkeletonType");

      this.setSkeletonType(b0);
    }

    this.m();
  }
示例#8
0
  public void c(NBTTagCompound nbttagcompound) {
    this.id = nbttagcompound.getShort("id");
    this.count = nbttagcompound.getByte("Count");
    this.damage = nbttagcompound.getShort("Damage");
    if (this.damage < 0) {
      this.damage = 0;
    }

    if (nbttagcompound.hasKey("tag")) {
      this.tag = nbttagcompound.getCompound("tag");
    }
  }
  private NBTTagCompound getBukkitData() {
    NBTTagCompound result = getData();

    if (result != null) {
      if (!result.hasKey("bukkit")) {
        result.set("bukkit", new NBTTagCompound());
      }
      result = result.getCompound("bukkit");
    }

    return result;
  }
示例#10
0
  public String getName() {
    String s = this.getItem().l(this);

    if (this.tag != null && this.tag.hasKey("display")) {
      NBTTagCompound nbttagcompound = this.tag.getCompound("display");

      if (nbttagcompound.hasKey("Name")) {
        s = nbttagcompound.getString("Name");
      }
    }

    return s;
  }
示例#11
0
  CraftMetaBook(NBTTagCompound tag) {
    super(tag);

    if (tag.hasKey(BOOK_TITLE.NBT)) {
      this.title = tag.getString(BOOK_TITLE.NBT);
    }

    if (tag.hasKey(BOOK_AUTHOR.NBT)) {
      this.author = tag.getString(BOOK_AUTHOR.NBT);
    }

    if (tag.hasKey(BOOK_PAGES.NBT)) {
      NBTTagList pages = tag.getList(BOOK_PAGES.NBT);
      String[] pageArray = new String[pages.size()];

      for (int i = 0; i < pages.size(); i++) {
        String page = ((NBTTagString) pages.get(i)).data;
        pageArray[i] = page;
      }

      addPage(pageArray);
    }
  }
  public long getLastPlayed() {
    Player player = getPlayer();
    if (player != null) return player.getLastPlayed();

    NBTTagCompound data = getBukkitData();

    if (data != null) {
      if (data.hasKey("lastPlayed")) {
        return data.getLong("lastPlayed");
      } else {
        File file = getDataFile();
        return file.lastModified();
      }
    } else {
      return 0;
    }
  }
  public void a(NBTTagCompound nbttagcompound) {
    this.e = nbttagcompound.getShort("xTile");
    this.f = nbttagcompound.getShort("yTile");
    this.g = nbttagcompound.getShort("zTile");
    this.h = nbttagcompound.getByte("inTile") & 255;
    this.i = nbttagcompound.getByte("inGround") == 1;
    // CraftBukkit start - direction -> power
    if (nbttagcompound.hasKey("power")) {
      NBTTagList nbttaglist = nbttagcompound.getList("power");

      this.dirX = ((NBTTagDouble) nbttaglist.get(0)).data;
      this.dirY = ((NBTTagDouble) nbttaglist.get(1)).data;
      this.dirZ = ((NBTTagDouble) nbttaglist.get(2)).data;
      // CraftBukkit end
    } else {
      this.die();
    }
  }
示例#14
0
  CraftMetaPotion(NBTTagCompound tag) {
    super(tag);

    if (tag.hasKey(POTION_EFFECTS.NBT)) {
      NBTTagList list = tag.getList(POTION_EFFECTS.NBT);
      int length = list.size();
      if (length > 0) {
        customEffects = new ArrayList<PotionEffect>(length);

        for (int i = 0; i < length; i++) {
          NBTTagCompound effect = (NBTTagCompound) list.get(i);
          PotionEffectType type = PotionEffectType.getById(effect.getByte(ID.NBT));
          int amp = effect.getByte(AMPLIFIER.NBT);
          int duration = effect.getInt(DURATION.NBT);
          boolean ambient = effect.getBoolean(AMBIENT.NBT);
          customEffects.add(new PotionEffect(type, duration, amp, ambient));
        }
      }
    }
  }
  public String getName() {
    Player player = getPlayer();
    if (player != null) {
      return player.getName();
    }

    // This might not match lastKnownName but if not it should be more correct
    if (profile.getName() != null) {
      return profile.getName();
    }

    NBTTagCompound data = getBukkitData();

    if (data != null) {
      if (data.hasKey("lastKnownName")) {
        return data.getString("lastKnownName");
      }
    }

    return null;
  }
示例#16
0
  public void a(ItemStack var1) {
    this.patterns = null;
    if (var1.hasTag() && var1.getTag().hasKeyOfType("BlockEntityTag", 10)) {
      NBTTagCompound var2 = var1.getTag().getCompound("BlockEntityTag");
      if (var2.hasKey("Patterns")) {
        this.patterns = (NBTTagList) var2.getList("Patterns", 10).clone();
      }

      if (var2.hasKeyOfType("Base", 99)) {
        this.color = var2.getInt("Base");
      } else {
        this.color = var1.getData() & 15;
      }
    } else {
      this.color = var1.getData() & 15;
    }

    this.h = null;
    this.i = null;
    this.j = "";
    this.g = true;
  }
示例#17
0
 public static int b(ItemStack var0) {
   NBTTagCompound var1 = var0.a("BlockEntityTag", false);
   return var1 != null && var1.hasKey("Base") ? var1.getInt("Base") : var0.getData();
 }
示例#18
0
 public static int c(ItemStack var0) {
   NBTTagCompound var1 = var0.a("BlockEntityTag", false);
   return var1 != null && var1.hasKey("Patterns") ? var1.getList("Patterns", 10).size() : 0;
 }