// This is where you load the data that you saved in writeToNBT
  @Override
  public void readFromNBT(NBTTagCompound nbtTagCompound) {
    super.readFromNBT(
        nbtTagCompound); // The super call is required to save and load the tiles location
    final byte NBT_TYPE_COMPOUND = 10; // See NBTBase.createNewByType() for a listing
    NBTTagList dataForAllSlots = nbtTagCompound.getTagList("Items", NBT_TYPE_COMPOUND);

    Arrays.fill(itemStacks, null); // set all slots to empty
    for (int i = 0; i < dataForAllSlots.tagCount(); ++i) {
      NBTTagCompound dataForOneSlot = dataForAllSlots.getCompoundTagAt(i);
      byte slotNumber = dataForOneSlot.getByte("Slot");
      if (slotNumber >= 0 && slotNumber < this.itemStacks.length) {
        this.itemStacks[slotNumber] = ItemStack.loadItemStackFromNBT(dataForOneSlot);
      }
    }

    // Load everything else.  Trim the arrays (or pad with 0) to make sure they have the correct
    // number of elements
    cookTime = nbtTagCompound.getShort("CookTime");
    burnTimeRemaining =
        Arrays.copyOf(nbtTagCompound.getIntArray("burnTimeRemaining"), FUEL_SLOTS_COUNT);
    burnTimeInitialValue =
        Arrays.copyOf(nbtTagCompound.getIntArray("burnTimeInitial"), FUEL_SLOTS_COUNT);
    cachedNumberOfBurningSlots = -1;
  }
  @Override
  public void readFromNBT(NBTTagCompound NBT) {
    super.readFromNBT(NBT);

    isEmitting = NBT.getBoolean("emit");

    source = NBT.getIntArray("src");
    target = NBT.getIntArray("tg");
  }
  public static FireworkStarPattern getFromCompound(NBTTagCompound compound) {
    FireworkStarPattern pattern = new FireworkStarPattern();

    pattern.type = compound.getByte("Type");
    pattern.hasTrail = compound.getBoolean("Trail");
    pattern.hasFlicker = compound.getBoolean("Flicker");
    pattern.primaryColors = compound.getIntArray("Colors");
    pattern.secondaryColors = compound.getIntArray("FadeColors");

    return pattern;
  }
示例#4
0
  @Override
  public void fromNBT(NBTTagCompound tag) {
    isInstalled = tag.getBoolean("i");

    int[] arr = tag.getIntArray("learned");
    for (int i = 0; i < arr.length; ++i) installedList.add(arr[i]);
  }
示例#5
0
  @Override
  public HashMap getExtendedDetails(World world) {

    HashMap retMap = getBasicDetails(world);

    TileEntity crucible = world.getBlockTileEntity(xCoord, yCoord, zCoord);

    NBTTagCompound compound = this.getTagCompound(crucible);
    retMap.put("Heat", compound.getShort("Heat"));
    retMap.put("Liquid", compound.getBoolean("Liquid"));
    retMap.put("LiquidQty", compound.getShort("liquidQty"));
    int[] tb = compound.getIntArray("Tags");
    EnumTag tag;
    int a = 1;
    HashMap tagMap;
    HashMap tags = new HashMap();
    for (int i = 0; i < tb.length; i++) {
      try {
        if (tb[i] > 0) {
          tagMap = new HashMap();
          tag = EnumTag.get(i);
          tagMap.put("Name", tag.name);
          tagMap.put("Aggro", tag.aggro);
          tagMap.put("Amount", tb[i]);
          tags.put(a, tagMap);
          a++;
        }
      } catch (Exception e) {
      }
    }
    retMap.put("Aspects", tags);

    return retMap;
  }
  @Override
  public void modify(ItemStack[] input, ItemStack tool) {
    NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
    int[] keyPair;
    if (tags.hasKey(key)) {
      keyPair = tags.getIntArray(key);
      if (keyPair[0] % max == 0) {
        keyPair[0] += increase;
        keyPair[1] += max;
        tags.setIntArray(key, keyPair);

        int modifiers = tags.getInteger("Modifiers");
        modifiers -= 1;
        tags.setInteger("Modifiers", modifiers);
      } else {
        keyPair[0] += increase;
        tags.setIntArray(key, keyPair);
      }
      updateModTag(tool, keyPair);
    } else {
      int modifiers = tags.getInteger("Modifiers");
      modifiers -= 1;
      tags.setInteger("Modifiers", modifiers);
      String modName = TextHelper.AQUA + "Void Mod (" + increase + "/" + max + ")";
      int tooltipIndex = addToolTip(tool, tooltipName, modName);
      keyPair = new int[] {increase, max, tooltipIndex};
      tags.setIntArray(key, keyPair);
    }
  }
示例#7
0
  @Override
  public void modify(ItemStack[] input, ItemStack tool) {
    NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
    int increase = matchingAmount(input);
    if (tags.hasKey(key)) {
      int[] keyPair = tags.getIntArray(key);
      if (keyPair[0] == max) {
        keyPair[0] += increase;
        keyPair[1] += max;
        tags.setIntArray(key, keyPair);

        int modifiers = tags.getInteger("Modifiers");
        modifiers -= 1;
        tags.setInteger("Modifiers", modifiers);
      } else {
        keyPair[0] += increase;
        tags.setIntArray(key, keyPair);
      }
      updateModTag(tool, keyPair);
    } else {
      int modifiers = tags.getInteger("Modifiers");
      modifiers -= 1;
      tags.setInteger("Modifiers", modifiers);
      String modName = "\u00a76Blaze (" + increase + "/" + max + ")";
      int tooltipIndex = addToolTip(tool, tooltipName, modName);
      int[] keyPair = new int[] {increase, max, tooltipIndex};
      tags.setIntArray(key, keyPair);
    }

    int fiery = tags.getInteger("Fiery");
    fiery += (increase);
    tags.setInteger("Fiery", fiery);
  }
  @Override
  protected void readSyncTag(NBTTagCompound NBT) {
    super.readSyncTag(NBT);

    extractorCookTime = NBT.getIntArray("CookTime");
    drillTime = NBT.getInteger("drill");
    bedrock = NBT.getBoolean("bedrock");
  }
 @Override
 public void readFromNBT(NBTTagCompound tag) {
   this.type = TargetType.values()[tag.getInteger("t")];
   int[] pos = tag.getIntArray("pos");
   this.setSide(tag.getInteger("s"));
   this.x = pos[0];
   this.y = pos[1];
   this.z = pos[2];
 }
 @Override
 public void readFromNBT(NBTTagCompound tags) {
   super.readFromNBT(tags);
   fuel = tags.getInteger("fuel");
   temperature = tags.getInteger("temperature");
   needsFuel = tags.getBoolean("needsFuel");
   itemTemperatures = tags.getIntArray("itemTemperatures");
   itemTempRequired = tags.getIntArray("itemTempRequired");
 }
示例#11
0
  @Override
  protected boolean canModify(ItemStack tool, ItemStack[] input) {
    NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
    if (!tags.hasKey(key)) return tags.getInteger("Modifiers") > 0;

    int keyPair[] = tags.getIntArray(key);
    if (keyPair[0] + matchingAmount(input) <= keyPair[1]) return true;
    else if (keyPair[0] == keyPair[1]) return tags.getInteger("Modifiers") > 0;
    else return false;
  }
示例#12
0
 private SelectableTiles getController(World world, ItemStack is) {
   NBTTagCompound nbt = is.stackTagCompound;
   if (nbt == null) return null;
   int[] xyz = nbt.getIntArray("locID");
   TileEntity te = world.getBlockTileEntity(xyz[0], xyz[1], xyz[2]);
   if (te instanceof SelectableTiles) {
     RotaryCraft.logger.debug("Read tile " + te + " at " + Arrays.toString(xyz));
     return (SelectableTiles) te;
   }
   return null;
 }
示例#13
0
 public static int[] getIntArraySafe(NBTTagCompound tagCompound, String name) {
   if (!tagCompound.hasKey(name)) {
     return new int[0];
   }
   NBTBase tag = tagCompound.getTag(name);
   if (tag instanceof NBTTagIntArray) {
     return tagCompound.getIntArray(name);
   } else {
     return new int[0];
   }
 }
  @Override
  public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) {
    super.readCustomNBT(nbt, descPacket);
    facing = nbt.getInteger("facing");
    energyStorage.readFromNBT(nbt);

    tank.readFromNBT(nbt.getCompoundTag("tank"));

    this.inventory = Utils.readInventory(nbt.getTagList("inventory", 10), 5);
    this.predictedOutput = Utils.readInventory(nbt.getTagList("predictedOutput", 10), 5);
    process = nbt.getIntArray("process");
  }
  /** Reads the tags from NBT. */
  @Override
  public void readFromNBT(NBTTagCompound tagCompound) {
    super.readFromNBT(tagCompound);

    // Read the energy variables.
    energy = tagCompound.getFloat("Energy");
    energyIn = tagCompound.getFloat("EnergyIn");

    // Read the GUI variables.
    energyGui = tagCompound.getInteger("EnergyGui");

    // Read the state variables.
    isActive = tagCompound.getBoolean("IsActive");
    hasEnergy = tagCompound.getBoolean("HasEnergy");
    usableGenerators = tagCompound.getInteger("UsableGenerators");

    // Read the coordinate arrays.
    int machinesX[] = tagCompound.getIntArray("MachinesHexoriumGeneratorX");
    int machinesY[] = tagCompound.getIntArray("MachinesHexoriumGeneratorY");
    int machinesZ[] = tagCompound.getIntArray("MachinesHexoriumGeneratorZ");
    // Prepare the ArrayList for machines.
    machinesHexoriumGenerator = new ArrayList<HexDevice>();
    // Build the machine list using the coordinate arrays.
    for (int i = 0; i < machinesX.length; i++)
      machinesHexoriumGenerator.add(
          new HexDevice(
              machinesX[i], machinesY[i], machinesZ[i], HexBlocks.blockHexoriumGenerator));

    // Read the items.
    machineItemStacks = new ItemStack[getSizeInventory()];
    NBTTagList tagsItems = tagCompound.getTagList("Items", 10);
    for (int i = 0; i < tagsItems.tagCount(); ++i) {
      NBTTagCompound tagCompound1 = tagsItems.getCompoundTagAt(i);
      byte byte0 = tagCompound1.getByte("Slot");

      if (byte0 >= 0 && byte0 < machineItemStacks.length) {
        machineItemStacks[byte0] = ItemStack.loadItemStackFromNBT(tagCompound1);
      }
    }
  }
 public void readFromNBT(NBTTagCompound tag) {
   name = tag.getString("name");
   value = tag.getInteger("value");
   int[] datas = tag.getIntArray("bb");
   if (datas.length >= 6) {
     bb.min.x = datas[0];
     bb.min.y = datas[1];
     bb.min.z = datas[2];
     bb.max.x = datas[3];
     bb.max.y = datas[4];
     bb.max.z = datas[5];
   }
 }
示例#17
0
  @Override
  protected boolean canModify(ItemStack tool, ItemStack[] input) {
    ToolCore toolItem = (ToolCore) tool.getItem();
    if (!validType(toolItem)) return false;

    NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
    if (!tags.hasKey(key)) return tags.getInteger("Modifiers") > 0;

    int keyPair[] = tags.getIntArray(key);
    if (keyPair[0] + increase <= keyPair[1]) return true;
    else if (keyPair[0] == keyPair[1]) return tags.getInteger("Modifiers") > 0;
    else return false;
  }
 private ArrayList<KeyValuePair<ISpellPart, byte[]>> NBTToISpellPartList(NBTTagCompound compound) {
   int[] ids = compound.getIntArray("group_ids");
   ArrayList<KeyValuePair<ISpellPart, byte[]>> list =
       new ArrayList<KeyValuePair<ISpellPart, byte[]>>();
   for (int i = 0; i < ids.length; ++i) {
     int partID = ids[i];
     ISkillTreeEntry part = SkillManager.instance.getSkill(i);
     byte[] partMeta = compound.getByteArray("meta_" + i);
     if (part instanceof ISpellPart) {
       list.add(new KeyValuePair<ISpellPart, byte[]>((ISpellPart) part, partMeta));
     }
   }
   return list;
 }
 @Override
 public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) {
   if (AdditionalPipes.CHANNEL.equals(packet.channel)) {
     DataInputStream data = new DataInputStream(new ByteArrayInputStream(packet.data));
     byte packetID = -1;
     try {
       packetID = data.readByte();
       switch (packetID) {
         case ADV_WOOD_DATA:
           TileEntity te = getTileEntity(player, data);
           if (te instanceof TileGenericPipe) {
             PipeItemsAdvancedWood pipe = (PipeItemsAdvancedWood) ((TileGenericPipe) te).pipe;
             pipe.transport.exclude = !pipe.transport.exclude;
           }
           break;
         case DIST_PIPE_DATA:
           handleDistPipeData(player, data);
           break;
         case TELE_PIPE_DATA_SET:
           handleTelePipeData(player, data);
           break;
         case CHUNKLOAD_DATA:
           handleChunkLoadData(data);
           break;
         case CHUNKLOAD_REQUEST:
           AdditionalPipes.instance.chunkLoadViewer.sendPersistentChunksToPlayer(
               (EntityPlayerMP) player);
           break;
       }
     } catch (IOException e) {
       AdditionalPipes.instance.logger.log(Level.SEVERE, "Error handling packet " + packetID, e);
     }
   } else if (AdditionalPipes.CHANNELNBT.equals(packet.channel)) {
     NBTTagCompound tag = PacketNBTTagData.getNBTFrom(packet);
     switch (tag.getInteger("id")) {
       case TELE_PIPE_DATA:
         TileEntity te =
             ((EntityPlayer) player)
                 .worldObj.getBlockTileEntity(
                     tag.getInteger("xCoord"), tag.getInteger("yCoord"), tag.getInteger("zCoord"));
         if (te instanceof TileGenericPipe) {
           PipeTeleport pipe = (PipeTeleport) ((TileGenericPipe) te).pipe;
           pipe.owner = tag.getString("owner");
           pipe.network = tag.getIntArray("network");
         }
         break;
     }
   }
 }
  @Override
  public void readFromNBT(NBTTagCompound nbt) {
    super.readFromNBT(nbt);
    if (nbt.getBoolean("hasBridgesInNBT")) {
      fluidBridgesXCoords = nbt.getIntArray("fluidBridgesXCoords");
      fluidBridgesYCoords = nbt.getIntArray("fluidBridgesYCoords");
      fluidBridgesZCoords = nbt.getIntArray("fluidBridgesZCoords");
      shouldReadBridgesFromNBT = true;
    } else {
      shouldReadBridgesFromNBT = false;
    }

    if (nbt.getBoolean("hasFluidsInNBT")) {
      shouldReadFluidsFromNBT = true;
      internalFluidsAmounts = nbt.getIntArray("internalFluidsAmounts");
      internalFluidsIDS = nbt.getIntArray("internalFluidsIDS");
    } else {
      shouldReadFluidsFromNBT = false;
    }

    doneReadingFluidsFromNBT = false;

    justReadNBT = true;
  }
  @Override
  public void readFromNBT(NBTTagCompound tag) {

    super.readFromNBT(tag);
    this.workingTick = tag.getInteger("workingTick");
    this.coordinates = tag.getIntArray("coordinates");
    this.searchingTick = tag.getByte("searchingTick");
    this.coolDown = tag.getInteger("coolDown");

    if (coordinates.length < 3) {
      coordinates = new int[3];
      coordinates[0] = this.xCoord;
      coordinates[1] = this.yCoord;
      coordinates[2] = this.zCoord;
    }
  }
示例#22
0
 public static void loadDimensionDataMap(NBTTagCompound compoundTag) {
   if (compoundTag == null) {
     dimensionMap.clear();
     for (Integer id : dimensions.keySet()) {
       if (id >= 0) {
         dimensionMap.set(id);
       }
     }
   } else {
     int[] intArray = compoundTag.getIntArray("DimensionArray");
     for (int i = 0; i < intArray.length; i++) {
       for (int j = 0; j < Integer.SIZE; j++) {
         dimensionMap.set(i * Integer.SIZE + j, (intArray[i] & (1 << j)) != 0);
       }
     }
   }
 }
示例#23
0
  @Override
  public void modify(ItemStack[] input, ItemStack tool) {
    NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
    if (tags.hasKey(key)) {
      int amount = 24;
      ToolCore toolItem = (ToolCore) tool.getItem();
      if (toolItem.pierceArmor() || !nerfType(toolItem)) amount = 36;

      int[] keyPair = tags.getIntArray(key);

      int leftToBoost = amount - (keyPair[0] % amount);
      if (increase >= leftToBoost) {
        int attack = tags.getInteger("Attack");
        attack += 1;
        tags.setInteger("Attack", attack);
      }

      if (keyPair[0] % max == 0) {
        keyPair[0] += increase;
        keyPair[1] += max;
        tags.setIntArray(key, keyPair);

        int modifiers = tags.getInteger("Modifiers");
        modifiers -= 1;
        tags.setInteger("Modifiers", modifiers);
      } else {
        keyPair[0] += increase;
        tags.setIntArray(key, keyPair);
      }
      updateModTag(tool, keyPair);

    } else {
      int modifiers = tags.getInteger("Modifiers");
      modifiers -= 1;
      tags.setInteger("Modifiers", modifiers);
      String modName = "\u00a7f" + guiType + " (" + increase + "/" + max + ")";
      int tooltipIndex = addToolTip(tool, tooltipName, modName);
      int[] keyPair = new int[] {increase, max, tooltipIndex};
      tags.setIntArray(key, keyPair);

      int attack = tags.getInteger("Attack");
      attack += 1;
      tags.setInteger("Attack", attack);
    }
  }
  private Object readFieldFromTag(NBTTagCompound tag, SavedField field, TypeTagger tagger) {
    if (field == null || field.type == null || field.value == null) {
      return null;
    } else if (field.type.equals(int.class)) {
      return tag.getInteger(field.name);
    } else if (field.type.equals(int[].class)) {
      return tag.getIntArray(field.name);
    } else if (field.type.equals(float.class)) {
      return tag.getFloat(field.name);
    } else if (field.type.equals(double.class)) {
      return tag.getDouble(field.name);
    } else if (field.type.equals(double[].class)) {
      NBTTagList list = tag.getTagList(field.name);
      double[] array = new double[list.tagCount()];
      for (int i = 0; i < array.length; i++) array[i] = ((NBTTagDouble) list.tagAt(i)).data;

      return array;
    } else if (field.type.equals(boolean.class)) {
      return tag.getBoolean(field.name);
    } else if (field.type.equals(boolean[].class)) {
      NBTTagList list = tag.getTagList(field.name);
      boolean[] array = new boolean[list.tagCount()];
      for (int i = 0; i < array.length; i++) array[i] = ((NBTTagByte) list.tagAt(i)).data != 0;

      return array;
    } else if (field.type.equals(String.class)) {
      return tag.getString(field.name);
    } else if (field.type.equals(String[].class)) {
      NBTTagList list = tag.getTagList(field.name);
      String[] array = new String[list.tagCount()];
      for (int i = 0; i < array.length; i++) array[i] = ((NBTTagString) list.tagAt(i)).data;

      return array;
    } else if (field.type.equals(TaggedClass.class)) {
      NBTTagCompound compound = new NBTTagCompound();
      return readClassFromTag(
          compound, DataStorageManager.getTaggerForType(tagger.getTypeOfField(field.name)));
    } else // this should never happen...
    return null;
  }
 @Override
 public void readFromNBT(NBTTagCompound tag) {
   super.readFromNBT(tag);
   _sideColors = tag.getIntArray("sideSubnets");
   if (_sideColors.length == 0) {
     _sideColors = new int[6];
   }
   byte _mode = tag.getByte("mode");
   cableMode = tag.getByteArray("cableMode");
   if (cableMode.length < 6) cableMode = new byte[] {0, 0, 0, 0, 0, 0, 0};
   switch (tag.getByte("v")) {
     case 2:
       cableMode[6] = (byte) (cableMode[6] == 3 ? 1 : 0);
       break;
     case 0:
       if (_mode == 2) _mode = 3;
     case 1:
       cableMode =
           new byte[] {_mode, _mode, _mode, _mode, _mode, _mode, (byte) (_mode == 3 ? 1 : 0)};
       break;
     default:
       break;
   }
 }
示例#26
0
  public void readFromNBT(NBTTagCompound nbt) {
    sizeX = nbt.getInteger("xSize");
    sizeY = nbt.getInteger("ySize");
    sizeZ = nbt.getInteger("zSize");

    blocks = new Block[sizeX][sizeY][sizeZ];
    metas = new short[sizeX][sizeY][sizeZ];

    tileEntities.clear();
    usableTiles.clear();

    int[] blockId = nbt.getIntArray("idList");
    int[] metasId = nbt.getIntArray("metaList");

    for (int x = 0; x < sizeX; x++) {
      for (int y = 0; y < sizeY; y++) {
        for (int z = 0; z < sizeZ; z++) {
          blocks[x][y][z] = Block.getBlockById(blockId[z + (sizeZ * y) + (sizeZ * sizeY * x)]);
          metas[x][y][z] = (short) metasId[z + (sizeZ * y) + (sizeZ * sizeY * x)];
        }
      }
    }

    NBTTagList tileList = nbt.getTagList("tiles", NBT.TAG_COMPOUND);

    for (int i = 0; i < tileList.tagCount(); i++) {

      try {
        TileEntity tile = TileEntity.createAndLoadEntity(tileList.getCompoundTagAt(i));
        tile.setWorldObj(world);

        if (isUsableBlock(tile)) {
          usableTiles.add(tile);
        }

        tileEntities.add(tile);
      } catch (Exception e) {
        AdvancedRocketry.logger.warning("Rocket missing Tile (was a mod removed?)");
      }
    }

    /*for(int x = 0; x < sizeX; x++) {
    	for(int y = 0; y < sizeY; y++) {
    		for(int z = 0; z < sizeZ; z++) {



    			NBTTagCompound tag = (NBTTagCompound)nbt.getTag(String.format("%d.%d.%d", x,y,z));

    			if(!tag.hasKey("block"))
    				continue;
    			int blockId = tag.getInteger("block");
    			blocks[x][y][z] = Block.getBlockById(blockId);
    			metas[x][y][z] = tag.getShort("meta");


    			if(blockId != 0 && blocks[x][y][z] == Blocks.air) {
    				AdvancedRocketry.logger.warning("Removed pre-existing block with id " + blockId + " from a rocket (Was a mod removed?)");
    			}
    			else if(tag.hasKey("tile")) {

    				if(blocks[x][y][z].hasTileEntity(metas[x][y][z])) {
    					TileEntity tile = TileEntity.createAndLoadEntity(tag.getCompoundTag("tile"));
    					tile.setWorldObj(world);

    					tileEntities.add(tile);

    					//Machines would throw a wrench in the works
    					if(isUsableBlock(tile)) {
    						inventories.add((IInventory)tile);
    						usableTiles.add(tile);
    					}
    				}
    			}
    		}
    	}
    }*/

  }
 public static int[] getEffects(ItemStack stack) {
   NBTTagCompound compound = getNBT(stack);
   return compound.getIntArray("Effects");
 }