Esempio n. 1
0
  public void importOldChunkTileEntities() {
    File file = wc.downloadSaveHandler.getSaveDirectory();
    if (wc.worldProvider instanceof WorldProviderHell) {
      file = new File(file, "DIM-1");
      file.mkdirs();
    }

    java.io.DataInputStream datainputstream =
        RegionFileCache.getChunkInputStream(file, xPosition, zPosition);
    NBTTagCompound nbttagcompound;
    if (datainputstream != null) {
      try {
        nbttagcompound = CompressedStreamTools.func_1141_a(datainputstream);
      } catch (IOException e) {
        return;
      }
    } else return;

    if (!nbttagcompound.hasKey("Level")) return;

    NBTTagList nbttaglist1 = nbttagcompound.getCompoundTag("Level").getTagList("TileEntities");
    if (nbttaglist1 != null) {
      for (int l = 0; l < nbttaglist1.tagCount(); l++) {
        NBTTagCompound nbttagcompound2 = (NBTTagCompound) nbttaglist1.tagAt(l);
        TileEntity te = TileEntity.createAndLoadEntity(nbttagcompound2);
        if (te != null) {
          ChunkPosition cp = new ChunkPosition(te.xCoord & 0xf, te.yCoord, te.zCoord & 0xf);
          newChunkTileEntityMap.put(cp, te);
        }
      }
    }
  }
Esempio n. 2
0
  /** (abstract) Protected helper method to read subclass entity data from NBT. */
  public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
    this.xTile = par1NBTTagCompound.getShort("xTile");
    this.yTile = par1NBTTagCompound.getShort("yTile");
    this.zTile = par1NBTTagCompound.getShort("zTile");
    this.inTile = par1NBTTagCompound.getByte("inTile") & 255;
    this.inGround = par1NBTTagCompound.getByte("inGround") == 1;

    if (par1NBTTagCompound.hasKey("direction")) {
      NBTTagList var2 = par1NBTTagCompound.getTagList("direction");
      this.motionX = ((NBTTagDouble) var2.tagAt(0)).data;
      this.motionY = ((NBTTagDouble) var2.tagAt(1)).data;
      this.motionZ = ((NBTTagDouble) var2.tagAt(2)).data;
    } else {
      this.setDead();
    }
  }
 protected void func_96500_c(NBTTagList par1NBTTagList) {
   for (int var2 = 0; var2 < par1NBTTagList.tagCount(); ++var2) {
     NBTTagCompound var3 = (NBTTagCompound) par1NBTTagList.tagAt(var2);
     ScoreObjective var4 = this.field_96507_a.func_96518_b(var3.getString("Objective"));
     Score var5 = this.field_96507_a.func_96529_a(var3.getString("Name"), var4);
     var5.func_96647_c(var3.getInteger("Score"));
   }
 }
 protected void func_96501_b(NBTTagList par1NBTTagList) {
   for (int var2 = 0; var2 < par1NBTTagList.tagCount(); ++var2) {
     NBTTagCompound var3 = (NBTTagCompound) par1NBTTagList.tagAt(var2);
     ScoreObjectiveCriteria var4 =
         (ScoreObjectiveCriteria)
             ScoreObjectiveCriteria.field_96643_a.get(var3.getString("CriteriaName"));
     ScoreObjective var5 = this.field_96507_a.func_96535_a(var3.getString("Name"), var4);
     var5.func_96681_a(var3.getString("DisplayName"));
   }
 }
Esempio n. 5
0
  /** Reads the entity from NBT (calls an abstract helper method to read specialized data) */
  public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
    NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Pos");
    NBTTagList nbttaglist1 = par1NBTTagCompound.getTagList("Motion");
    NBTTagList nbttaglist2 = par1NBTTagCompound.getTagList("Rotation");
    motionX = ((NBTTagDouble) nbttaglist1.tagAt(0)).data;
    motionY = ((NBTTagDouble) nbttaglist1.tagAt(1)).data;
    motionZ = ((NBTTagDouble) nbttaglist1.tagAt(2)).data;

    if (Math.abs(motionX) > 10D) {
      motionX = 0.0D;
    }

    if (Math.abs(motionY) > 10D) {
      motionY = 0.0D;
    }

    if (Math.abs(motionZ) > 10D) {
      motionZ = 0.0D;
    }

    prevPosX = lastTickPosX = posX = ((NBTTagDouble) nbttaglist.tagAt(0)).data;
    prevPosY = lastTickPosY = posY = ((NBTTagDouble) nbttaglist.tagAt(1)).data;
    prevPosZ = lastTickPosZ = posZ = ((NBTTagDouble) nbttaglist.tagAt(2)).data;
    prevRotationYaw = rotationYaw = ((NBTTagFloat) nbttaglist2.tagAt(0)).data;
    prevRotationPitch = rotationPitch = ((NBTTagFloat) nbttaglist2.tagAt(1)).data;
    fallDistance = par1NBTTagCompound.getFloat("FallDistance");
    fire = par1NBTTagCompound.getShort("Fire");
    setAir(par1NBTTagCompound.getShort("Air"));
    onGround = par1NBTTagCompound.getBoolean("OnGround");
    setPosition(posX, posY, posZ);
    setRotation(rotationYaw, rotationPitch);
    readEntityFromNBT(par1NBTTagCompound);
  }
 public void readFromNBT(NBTTagCompound nbttagcompound) {
   super.readFromNBT(nbttagcompound);
   woodType = nbttagcompound.getByte("woodType");
   NBTTagList nbttaglist = nbttagcompound.getTagList("Items");
   storage = new ItemStack[getSizeInventory()];
   for (int i = 0; i < nbttaglist.tagCount(); i++) {
     NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i);
     byte byte0 = nbttagcompound1.getByte("Slot");
     if (byte0 >= 0 && byte0 < storage.length) {
       storage[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
     }
   }
 }
Esempio n. 7
0
  public void readFromNBT(NBTTagCompound nbttagcompound) {
    super.readFromNBT(nbttagcompound);
    // timeleft = nbttagcompound.getInteger("timeleft");

    NBTTagList nbttaglist = nbttagcompound.getTagList("Items");
    metalItemStacks = new ItemStack[getSizeInventory()];
    for (int i = 0; i < nbttaglist.tagCount(); i++) {
      NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i);
      byte byte0 = nbttagcompound1.getByte("Slot");
      if (byte0 >= 0 && byte0 < metalItemStacks.length) {
        metalItemStacks[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
      }
    }
  }
  /** Return the enchantments for the specified stack. */
  public static Map getEnchantments(ItemStack par0ItemStack) {
    LinkedHashMap var1 = new LinkedHashMap();
    NBTTagList var2 = par0ItemStack.getEnchantmentTagList();

    if (var2 != null) {
      for (int var3 = 0; var3 < var2.tagCount(); ++var3) {
        short var4 = ((NBTTagCompound) var2.tagAt(var3)).getShort("id");
        short var5 = ((NBTTagCompound) var2.tagAt(var3)).getShort("lvl");
        var1.put(Integer.valueOf(var4), Integer.valueOf(var5));
      }
    }

    return var1;
  }
  public void readFromNBT(NBTTagCompound nbttagcompound) {
    super.readFromNBT(nbttagcompound);
    NBTTagList nbttaglist = nbttagcompound.getTagList("Items");
    furnaceItemStacks = new ItemStack[getSizeInventory()];
    for (int i = 0; i < nbttaglist.tagCount(); i++) {
      NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i);
      byte byte0 = nbttagcompound1.getByte("Slot");
      if (byte0 >= 0 && byte0 < furnaceItemStacks.length) {
        furnaceItemStacks[byte0] = new ItemStack(nbttagcompound1);
      }
    }

    furnaceBurnTime = nbttagcompound.getShort("BurnTime");
    furnaceCookTime = nbttagcompound.getShort("CookTime");
    currentItemBurnTime = getItemBurnTime(furnaceItemStacks[1]);
  }
  /** Executes the enchantment modifier on the ItemStack passed. */
  private static void applyEnchantmentModifier(
      IEnchantmentModifier par0IEnchantmentModifier, ItemStack par1ItemStack) {
    if (par1ItemStack != null) {
      NBTTagList var2 = par1ItemStack.getEnchantmentTagList();

      if (var2 != null) {
        for (int var3 = 0; var3 < var2.tagCount(); ++var3) {
          short var4 = ((NBTTagCompound) var2.tagAt(var3)).getShort("id");
          short var5 = ((NBTTagCompound) var2.tagAt(var3)).getShort("lvl");

          if (Enchantment.enchantmentsList[var4] != null) {
            par0IEnchantmentModifier.calculateModifier(Enchantment.enchantmentsList[var4], var5);
          }
        }
      }
    }
  }
 public void readFromNBT(NBTTagList nbttaglist) {
   mainInventory = new ItemStack[36];
   armorInventory = new ItemStack[4];
   for (int i = 0; i < nbttaglist.tagCount(); i++) {
     NBTTagCompound nbttagcompound = (NBTTagCompound) nbttaglist.tagAt(i);
     int j = nbttagcompound.getByte("Slot") & 0xff;
     ItemStack itemstack = new ItemStack(nbttagcompound);
     if (itemstack.getItem() == null) {
       continue;
     }
     if (j >= 0 && j < mainInventory.length) {
       mainInventory[j] = itemstack;
     }
     if (j >= 100 && j < armorInventory.length + 100) {
       armorInventory[j - 100] = itemstack;
     }
   }
 }
Esempio n. 12
0
  /** Reads a tile entity from NBT. */
  public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
    super.readFromNBT(par1NBTTagCompound);
    NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
    this.combinerItemStacks = new ItemStack[this.getSizeInventory()];

    for (int var3 = 0; var3 < var2.tagCount(); ++var3) {
      NBTTagCompound var4 = (NBTTagCompound) var2.tagAt(var3);
      byte var5 = var4.getByte("Slot");

      if (var5 >= 0 && var5 < this.combinerItemStacks.length) {
        this.combinerItemStacks[var5] = ItemStack.loadItemStackFromNBT(var4);
      }
    }

    this.combinerBurnTime = par1NBTTagCompound.getShort("BurnTime");
    this.combinerCookTime = par1NBTTagCompound.getShort("CookTime");
    this.currentItemBurnTime = getItemBurnTime(this.combinerItemStacks[1]);
  }
  protected void func_96498_a(NBTTagList par1NBTTagList) {
    for (int var2 = 0; var2 < par1NBTTagList.tagCount(); ++var2) {
      NBTTagCompound var3 = (NBTTagCompound) par1NBTTagList.tagAt(var2);
      ScorePlayerTeam var4 = this.field_96507_a.func_96527_f(var3.getString("Name"));
      var4.func_96664_a(var3.getString("DisplayName"));
      var4.func_96666_b(var3.getString("Prefix"));
      var4.func_96662_c(var3.getString("Suffix"));

      if (var3.hasKey("AllowFriendlyFire")) {
        var4.func_96660_a(var3.getBoolean("AllowFriendlyFire"));
      }

      if (var3.hasKey("SeeFriendlyInvisibles")) {
        var4.func_98300_b(var3.getBoolean("SeeFriendlyInvisibles"));
      }

      this.func_96502_a(var4, var3.getTagList("Players"));
    }
  }
  /** Reads a tile entity from NBT. */
  public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
    super.readFromNBT(par1NBTTagCompound);
    NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
    this.brewingItemStacks = new ItemStack[this.getSizeInventory()];

    for (int var3 = 0; var3 < var2.tagCount(); ++var3) {
      NBTTagCompound var4 = (NBTTagCompound) var2.tagAt(var3);
      byte var5 = var4.getByte("Slot");

      if (var5 >= 0 && var5 < this.brewingItemStacks.length) {
        this.brewingItemStacks[var5] = ItemStack.loadItemStackFromNBT(var4);
      }
    }

    this.brewTime = par1NBTTagCompound.getShort("BrewTime");

    if (par1NBTTagCompound.hasKey("CustomName")) {
      this.field_94132_e = par1NBTTagCompound.getString("CustomName");
    }
  }
Esempio n. 15
0
  /** Reads from the given tag list and fills the slots in the inventory with the correct items. */
  public void readFromNBT(NBTTagList par1NBTTagList) {
    this.mainInventory = new ItemStack[36];
    this.armorInventory = new ItemStack[4];

    for (int var2 = 0; var2 < par1NBTTagList.tagCount(); ++var2) {
      NBTTagCompound var3 = (NBTTagCompound) par1NBTTagList.tagAt(var2);
      int var4 = var3.getByte("Slot") & 255;
      ItemStack var5 = ItemStack.loadItemStackFromNBT(var3);

      if (var5 != null) {
        if (var4 >= 0 && var4 < this.mainInventory.length) {
          this.mainInventory[var4] = var5;
        }

        if (var4 >= 100 && var4 < this.armorInventory.length + 100) {
          this.armorInventory[var4 - 100] = var5;
        }
      }
    }
  }
  /** (abstract) Protected helper method to read subclass entity data from NBT. */
  protected void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
    minecartType = par1NBTTagCompound.getInteger("Type");

    if (minecartType == 2) {
      pushX = par1NBTTagCompound.getDouble("PushX");
      pushZ = par1NBTTagCompound.getDouble("PushZ");
      fuel = par1NBTTagCompound.getShort("Fuel");
    } else if (minecartType == 1) {
      NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Items");
      cargoItems = new ItemStack[getSizeInventory()];

      for (int i = 0; i < nbttaglist.tagCount(); i++) {
        NBTTagCompound nbttagcompound = (NBTTagCompound) nbttaglist.tagAt(i);
        int j = nbttagcompound.getByte("Slot") & 0xff;

        if (j >= 0 && j < cargoItems.length) {
          cargoItems[j] = ItemStack.loadItemStackFromNBT(nbttagcompound);
        }
      }
    }
  }
Esempio n. 17
0
  /** (abstract) Protected helper method to read subclass entity data from NBT. */
  protected void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
    this.minecartType = par1NBTTagCompound.getInteger("Type");

    if (this.minecartType == 2) {
      this.pushX = par1NBTTagCompound.getDouble("PushX");
      this.pushZ = par1NBTTagCompound.getDouble("PushZ");
      this.fuel = par1NBTTagCompound.getShort("Fuel");
    } else if (this.minecartType == 1) {
      NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
      this.cargoItems = new ItemStack[this.getSizeInventory()];

      for (int var3 = 0; var3 < var2.tagCount(); ++var3) {
        NBTTagCompound var4 = (NBTTagCompound) var2.tagAt(var3);
        int var5 = var4.getByte("Slot") & 255;

        if (var5 >= 0 && var5 < this.cargoItems.length) {
          this.cargoItems[var5] = ItemStack.loadItemStackFromNBT(var4);
        }
      }
    }
  }
  /** Returns the level of enchantment on the ItemStack passed. */
  public static int getEnchantmentLevel(int par0, ItemStack par1ItemStack) {
    if (par1ItemStack == null) {
      return 0;
    } else {
      NBTTagList var2 = par1ItemStack.getEnchantmentTagList();

      if (var2 == null) {
        return 0;
      } else {
        for (int var3 = 0; var3 < var2.tagCount(); ++var3) {
          short var4 = ((NBTTagCompound) var2.tagAt(var3)).getShort("id");
          short var5 = ((NBTTagCompound) var2.tagAt(var3)).getShort("lvl");

          if (var4 == par0) {
            return var5;
          }
        }

        return 0;
      }
    }
  }
 protected void func_96502_a(ScorePlayerTeam par1ScorePlayerTeam, NBTTagList par2NBTTagList) {
   for (int var3 = 0; var3 < par2NBTTagList.tagCount(); ++var3) {
     this.field_96507_a.func_96521_a(
         ((NBTTagString) par2NBTTagList.tagAt(var3)).data, par1ScorePlayerTeam);
   }
 }
Esempio n. 20
0
  /** reads in data from the NBTTagCompound into this MapDataBase */
  public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
    // DEBUG
    System.out.println(
        "MapData.readFromNBT() - "
            + cpw.mods.fml.common.FMLCommonHandler.instance().getEffectiveSide());

    NBTBase dimension = par1NBTTagCompound.getTag("dimension");

    if (dimension instanceof NBTTagByte) {
      this.dimension = ((NBTTagByte) dimension).data;
    } else {
      this.dimension = ((NBTTagInt) dimension).data;
    }

    this.xCenter = par1NBTTagCompound.getInteger("xCenter");
    this.zCenter = par1NBTTagCompound.getInteger("zCenter");
    this.scale = par1NBTTagCompound.getByte("scale");

    if (this.scale < 0) {
      this.scale = 0;
    }

    if (this.scale > 4) {
      this.scale = 4;
    }

    short short1 = par1NBTTagCompound.getShort("width");
    short short2 = par1NBTTagCompound.getShort("height");

    if (short1 == 128 && short2 == 128) {
      this.colors = par1NBTTagCompound.getByteArray("colors");
    } else {
      byte[] abyte = par1NBTTagCompound.getByteArray("colors");
      this.colors = new byte[16384];
      int i = (128 - short1) / 2;
      int j = (128 - short2) / 2;

      for (int k = 0; k < short2; ++k) {
        int l = k + j;

        if (l >= 0 || l < 128) {
          for (int i1 = 0; i1 < short1; ++i1) {
            int j1 = i1 + i;

            if (j1 >= 0 || j1 < 128) {
              this.colors[j1 + l * 128] = abyte[i1 + k * short1];
            }
          }
        }
      }
    }

    // CartoCraft - Loads custom icons
    // OBS: This part is in SERVER, the info will need to be sent to clients
    NBTTagList iconTagList = par1NBTTagCompound.getTagList("customIcons");
    if (iconTagList != null) {

      System.out.println("Found customIcons TagList! " + iconTagList.tagCount());

      for (int i = 0; i < iconTagList.tagCount(); i++) {
        NBTTagCompound iconTagCompound = (NBTTagCompound) iconTagList.tagAt(i);
        byte iconNum = iconTagCompound.getByte("icon");
        byte x = iconTagCompound.getByte("xPos");
        byte z = iconTagCompound.getByte("zPos");
        String iconKey = getCustomIconKey(x, z);

        System.out.println(
            "    Adding icon ["
                + iconNum
                + "] at ["
                + x
                + "],["
                + z
                + "] with key ["
                + iconKey
                + "]");
        this.customIcons.put(iconKey, new MapCoord(this, iconNum, x, z, (byte) 0));
      }
    }
  }