コード例 #1
0
  @Override
  public void writeToNBT(NBTTagCompound nbtTags) {
    super.writeToNBT(nbtTags);

    nbtTags.setBoolean("finishedCalc", finishedCalc);

    if (fluidTank.getFluid() != null) {
      nbtTags.setTag("fluidTank", fluidTank.writeToNBT(new NBTTagCompound()));
    }

    NBTTagList activeList = new NBTTagList();

    for (Coord4D wrapper : activeNodes) {
      NBTTagCompound tagCompound = new NBTTagCompound();
      wrapper.write(tagCompound);
      activeList.appendTag(tagCompound);
    }

    if (activeList.tagCount() != 0) {
      nbtTags.setTag("activeNodes", activeList);
    }

    NBTTagList usedList = new NBTTagList();

    for (Coord4D obj : usedNodes) {
      activeList.appendTag(obj.write(new NBTTagCompound()));
    }

    if (activeList.tagCount() != 0) {
      nbtTags.setTag("usedNodes", usedList);
    }
  }
コード例 #2
0
  @Override
  public void writeToNBT(final NBTTagCompound tag) {
    super.writeToNBT(tag);

    final NBTTagCompound inventoriesTag = new NBTTagCompound();
    final NBTTagCompound ownerTag = new NBTTagCompound();

    for (final Entry<String, Map<Integer, ItemStack>> inventoryEntry :
        this.inventories.entrySet()) {
      final NBTTagList inventoryTag = new NBTTagList();

      for (final Entry<Integer, ItemStack> slotEntry : inventoryEntry.getValue().entrySet()) {
        final NBTTagCompound slotTag = new NBTTagCompound();

        slotEntry.getValue().writeToNBT(slotTag);
        slotTag.setByte("slot", slotEntry.getKey().byteValue());

        inventoryTag.appendTag(slotTag);
      }

      inventoriesTag.setTag(inventoryEntry.getKey(), inventoryTag);
    }

    NBTUtil.writeGameProfile(ownerTag, this.owner);

    tag.setLong("age", this.age);
    tag.setTag("inventories", inventoriesTag);
    tag.setTag("owner", ownerTag);
  }
コード例 #3
0
  @Override
  public void writeToNBT(NBTTagCompound nbt, MappingRegistry registry) {
    nbt.setByte("mode", (byte) mode.ordinal());
    nbt.setInteger("x", x);
    nbt.setInteger("y", y);
    nbt.setInteger("z", z);

    if (schematic != null) {
      NBTTagCompound schematicNBT = new NBTTagCompound();
      SchematicFactory.getFactory(schematic.getClass())
          .saveSchematicToWorldNBT(schematicNBT, schematic, registry);
      nbt.setTag("schematic", schematicNBT);
    }

    NBTTagList nbtStacks = new NBTTagList();

    if (stackConsumed != null) {
      for (ItemStack stack : stackConsumed) {
        NBTTagCompound nbtStack = new NBTTagCompound();
        stack.writeToNBT(nbtStack);
        nbtStacks.appendTag(nbtStack);
      }
    }

    nbt.setTag("stackConsumed", nbtStacks);
  }
コード例 #4
0
ファイル: Pipe.java プロジェクト: binnie567/BuildCraft
  public void writeToNBT(NBTTagCompound nbttagcompound) {
    transport.writeToNBT(nbttagcompound);
    logic.writeToNBT(nbttagcompound);

    // Save pulser if any
    if (gate != null) {
      NBTTagCompound nbttagcompoundC = new NBTTagCompound();
      gate.writeToNBT(nbttagcompoundC);
      nbttagcompound.setTag("Gate", nbttagcompoundC);
      // Wire states are stored for pipes with gates only
      for (int i = 0; i < 4; ++i)
        nbttagcompound.setBoolean("wireState[" + i + "]", broadcastSignal[i]);
      nbttagcompound.setBoolean("redstoneState", broadcastRedstone);
    }

    for (int i = 0; i < 4; ++i) nbttagcompound.setBoolean("wireSet[" + i + "]", wireSet[i]);

    for (int i = 0; i < 8; ++i) {
      nbttagcompound.setInteger(
          "action[" + i + "]", activatedActions[i] != null ? activatedActions[i].getId() : 0);
      nbttagcompound.setInteger(
          "trigger[" + i + "]", activatedTriggers[i] != null ? activatedTriggers[i].getId() : 0);
    }

    for (int i = 0; i < 8; ++i)
      if (triggerParameters[i] != null) {
        NBTTagCompound cpt = new NBTTagCompound();
        triggerParameters[i].writeToNBT(cpt);
        nbttagcompound.setTag("triggerParameters[" + i + "]", cpt);
      }
  }
コード例 #5
0
  @Override
  public void writeToNBT(NBTTagCompound nbtTags) {
    super.writeToNBT(nbtTags);

    if (fluidTank.getFluid() != null) {
      nbtTags.setTag("fluidTank", fluidTank.writeToNBT(new NBTTagCompound()));
    }

    NBTTagList recurringList = new NBTTagList();

    for (Object3D wrapper : recurringNodes) {
      NBTTagCompound tagCompound = new NBTTagCompound();
      wrapper.write(tagCompound);
      recurringList.appendTag(tagCompound);
    }

    if (recurringList.tagCount() != 0) {
      nbtTags.setTag("recurringNodes", recurringList);
    }

    NBTTagList cleaningList = new NBTTagList();

    for (Object3D obj : cleaningNodes) {
      cleaningList.appendTag(obj.write(new NBTTagCompound()));
    }

    if (cleaningList.tagCount() != 0) {
      nbtTags.setTag("cleaningNodes", cleaningList);
    }
  }
コード例 #6
0
  public void writeToNBT(NBTTagCompound p_98280_1_) {
    p_98280_1_.setString("EntityId", this.getEntityNameToSpawn());
    p_98280_1_.setShort("Delay", (short) this.spawnDelay);
    p_98280_1_.setShort("MinSpawnDelay", (short) this.minSpawnDelay);
    p_98280_1_.setShort("MaxSpawnDelay", (short) this.maxSpawnDelay);
    p_98280_1_.setShort("SpawnCount", (short) this.spawnCount);
    p_98280_1_.setShort("MaxNearbyEntities", (short) this.maxNearbyEntities);
    p_98280_1_.setShort("RequiredPlayerRange", (short) this.activatingRangeFromPlayer);
    p_98280_1_.setShort("SpawnRange", (short) this.spawnRange);

    if (this.getRandomMinecart() != null) {
      p_98280_1_.setTag("SpawnData", this.getRandomMinecart().field_98222_b.copy());
    }

    if (this.getRandomMinecart() != null
        || this.minecartToSpawn != null && this.minecartToSpawn.size() > 0) {
      NBTTagList var2 = new NBTTagList();

      if (this.minecartToSpawn != null && this.minecartToSpawn.size() > 0) {
        Iterator var3 = this.minecartToSpawn.iterator();

        while (var3.hasNext()) {
          MobSpawnerBaseLogic.WeightedRandomMinecart var4 =
              (MobSpawnerBaseLogic.WeightedRandomMinecart) var3.next();
          var2.appendTag(var4.func_98220_a());
        }
      } else {
        var2.appendTag(this.getRandomMinecart().func_98220_a());
      }

      p_98280_1_.setTag("SpawnPotentials", var2);
    }
  }
コード例 #7
0
ファイル: BlockCrucible.java プロジェクト: Jee-Host/TFCraft
  public NBTTagCompound writeCrucibleToNBT(TECrucible te) {
    NBTTagCompound nbt = new NBTTagCompound();

    nbt.setInteger("temp", te.temperature);

    NBTTagList nbttaglist = new NBTTagList();
    Iterator iter = te.metals.values().iterator();
    while (iter.hasNext()) {
      MetalPair m = (MetalPair) iter.next();
      if (m != null) {
        NBTTagCompound nbttagcompound1 = new NBTTagCompound();
        nbttagcompound1.setInteger("ID", m.type.IngotID);
        nbttagcompound1.setFloat("AmountF", m.amount);
        nbttaglist.appendTag(nbttagcompound1);
      }
    }
    nbt.setTag("Metals", nbttaglist);

    nbttaglist = new NBTTagList();
    for (int i = 0; i < te.storage.length; i++) {
      if (te.storage[i] != null) {
        NBTTagCompound nbttagcompound1 = new NBTTagCompound();
        nbttagcompound1.setByte("Slot", (byte) i);
        te.storage[i].writeToNBT(nbttagcompound1);
        nbttaglist.appendTag(nbttagcompound1);
      }
    }

    nbt.setTag("Items", nbttaglist);

    return nbt;
  }
コード例 #8
0
  public void writeToNBT(NBTTagCompound nbt) {
    super.writeToNBT(nbt);

    NBTTagCompound energyTag = new NBTTagCompound();
    this.storage.writeToNBT(energyTag);
    nbt.setTag("storage", energyTag);
    nbt.setBoolean("flag", this.flag);
    nbt.setBoolean("flag1", this.flag1);
    NBTTagList list = new NBTTagList();

    for (int i = 0; i < this.slots.length; ++i) {
      if (this.slots[i] != null) {
        NBTTagCompound compound = new NBTTagCompound();
        compound.setByte("Slot", (byte) i);
        this.slots[i].writeToNBT(compound);
        list.appendTag(compound);
      }
    }

    nbt.setTag("Items", list);

    if (this.isInventoryNameLocalized()) {
      nbt.setString("CustomName", this.localizedName);
    }
  }
コード例 #9
0
  // This is where you save any data that you don't want to lose when the tile entity unloads
  // In this case, it saves the state of the furnace (burn time etc) and the itemstacks stored in
  // the fuel, input, and output slots
  @Override
  public void writeToNBT(NBTTagCompound parentNBTTagCompound) {
    super.writeToNBT(
        parentNBTTagCompound); // The super call is required to save and load the tiles location

    //		// Save the stored item stacks

    // to use an analogy with Java, this code generates an array of hashmaps
    // The itemStack in each slot is converted to an NBTTagCompound, which is effectively a hashmap
    // of key->value pairs such
    //   as slot=1, id=2353, count=1, etc
    // Each of these NBTTagCompound are then inserted into NBTTagList, which is similar to an array.
    NBTTagList dataForAllSlots = new NBTTagList();
    for (int i = 0; i < this.itemStacks.length; ++i) {
      if (this.itemStacks[i] != null) {
        NBTTagCompound dataForThisSlot = new NBTTagCompound();
        dataForThisSlot.setByte("Slot", (byte) i);
        this.itemStacks[i].writeToNBT(dataForThisSlot);
        dataForAllSlots.appendTag(dataForThisSlot);
      }
    }
    // the array of hashmaps is then inserted into the parent hashmap for the container
    parentNBTTagCompound.setTag("Items", dataForAllSlots);

    // Save everything else
    parentNBTTagCompound.setShort("CookTime", cookTime);
    parentNBTTagCompound.setTag("burnTimeRemaining", new NBTTagIntArray(burnTimeRemaining));
    parentNBTTagCompound.setTag("burnTimeInitial", new NBTTagIntArray(burnTimeInitialValue));
  }
コード例 #10
0
  @Override
  public NBTTagCompound writeToNBT(NBTTagCompound compound) {
    super.writeToNBT(compound);

    if (this instanceof IStructurePart) {
      if (((IStructurePart) this).getStructure() != null) {
        compound.setInteger(
            CoreReferences.NBT.StructureData.DIMENSION, getWorld().provider.getDimension());
        compound.setTag(
            CoreReferences.NBT.STRUCTURE,
            ((IStructurePart) this).getStructure().getMasterLocation().toCompound());
      }
    }

    if (getState().requiresNBTStorage())
      compound.setTag(CoreReferences.NBT.STATE, this.getState().writeToNBTTagCompound());

    if (this instanceof IItemStorage)
      compound.setTag(CoreReferences.NBT.INVENTORY, this.writeInventoryToCompound());

    if (this instanceof IFluidContainingEntity)
      compound.setTag(CoreReferences.NBT.FLUIDS, this.writeFluidsToCompound());

    if (this.hasCustomName()) {
      compound.setString(CoreReferences.NBT.NAME, name);
    }

    return compound;
  }
コード例 #11
0
ファイル: TileEntityAltar.java プロジェクト: Giliod/Roots
 @Override
 public NBTTagCompound writeToNBT(NBTTagCompound tag) {
   super.writeToNBT(tag);
   if (inventory.size() > 0) {
     NBTTagList list = new NBTTagList();
     for (int i = 0; i < inventory.size(); i++) {;
       if (inventory.get(i) != null) {
         list.appendTag(inventory.get(i).writeToNBT(new NBTTagCompound()));
       }
     }
     tag.setTag("inventory", list);
   }
   if (incenses.size() > 0) {
     NBTTagList list = new NBTTagList();
     for (int i = 0; i < incenses.size(); i++) {;
       if (incenses.get(i) != null) {
         list.appendTag(incenses.get(i).writeToNBT(new NBTTagCompound()));
       }
     }
     tag.setTag("incenses", list);
   }
   if (ritualName != null) {
     tag.setString("ritualName", ritualName);
   }
   tag.setInteger("progress", progress);
   return tag;
 }
	@Override
	public void writeToNBT(NBTTagCompound tag)
	{
		super.writeToNBT(tag);
		NBTTagList nbttaglist;
		if (_inventory.length > 0)
		{
			nbttaglist = new NBTTagList();
			for(int i = 0; i < _inventory.length; i++)
			{
				if (_inventory[i] != null && _inventory[i].stackSize > 0)
				{
					NBTTagCompound slot = new NBTTagCompound();
					slot.setByte("Slot", (byte)i);
					_inventory[i].writeToNBT(slot);
					nbttaglist.appendTag(slot);
				}
			}
			tag.setTag("Items", nbttaglist);
		}
		
		IFluidTank[] _tanks = getTanks();
		if (_tanks.length > 0)
		{
			NBTTagList tanks = new NBTTagList();
			for(int i = 0, n = _tanks.length; i < n; i++)
			{
				if(_tanks[i].getFluid() != null)
				{
					NBTTagCompound nbttagcompound1 = new NBTTagCompound();
					nbttagcompound1.setByte("Tank", (byte)i);
					
					FluidStack l = _tanks[i].getFluid();
					l.writeToNBT(nbttagcompound1);
					tanks.appendTag(nbttagcompound1);
				}
			}
			tag.setTag("mTanks", tanks);
		}
		
		if (this.isInvNameLocalized())
		{
			NBTTagCompound display = new NBTTagCompound();
			display.setString("Name", getInvName());
			tag.setCompoundTag("display", display);
		}
		
		if (failedDrops != null)
		{
			nbttaglist = new NBTTagList();
			for (ItemStack item : failedDrops)
			{
				NBTTagCompound nbttagcompound1 = new NBTTagCompound();
				item.writeToNBT(nbttagcompound1);
				nbttaglist.appendTag(nbttagcompound1);
			}
			tag.setTag("DropItems", nbttaglist);
		}
	}
コード例 #13
0
 private NBTTagList getNBTRecipes(EntityPlayer ep) {
   String key = "recipes";
   NBTTagCompound tag = this.getNBT(ep);
   if (!tag.hasKey(key)) tag.setTag(key, new NBTTagList());
   NBTTagList li = tag.getTagList(key, NBTTypes.INT.ID);
   tag.setTag(key, li);
   return li;
 }
コード例 #14
0
  /*
  public Collection<CastingRecipe> getRecipesPerformed(EntityPlayer ep) {
  	Collection<CastingRecipe> c = new HashSet();
  	NBTTagList li = this.getNBTRecipes(ep);
  	for (Object o : li.tagList) {
  		NBTTagCompound tag = (NBTTagCompound)o;
  		ItemStack is = ItemStack.loadItemStackFromNBT(tag);
  		c.addAll(RecipesCastingTable.instance.getAllRecipesMaking(is));
  	}
  	return c;
  }

  private NBTTagList getNBTRecipes(EntityPlayer ep) {
  	String key = "recipes";
  	NBTTagCompound tag = this.getNBT(ep);
  	if (!tag.hasKey(key))
  		tag.setTag(key, new NBTTagList());
  	NBTTagList li = tag.getTagList(key, NBTTypes.COMPOUND.ID);
  	tag.setTag(key, li);
  	return li;
  }

  public boolean givePlayerRecipe(EntityPlayer ep, CastingRecipe cr) {
  	if (!this.playerHasRecipe(ep, cr)) {
  		NBTTagCompound tag = new NBTTagCompound();
  		cr.getOutput().writeToNBT(tag);
  		this.getNBTRecipes(ep).appendTag(tag);
  		if (ep instanceof EntityPlayerMP)
  			ReikaPlayerAPI.syncCustomData((EntityPlayerMP)ep);
  		this.notifyPlayerOfProgression(ep, cr);
  		return true;
  	}
  	return false;
  }

  public boolean playerHasRecipe(EntityPlayer ep, CastingRecipe cr) {
  	return this.getRecipesPerformed(ep).contains(cr);
  }
   */
  private NBTTagList getNBTFragments(EntityPlayer ep) {
    String key = "fragments";
    NBTTagCompound tag = this.getNBT(ep);
    if (!tag.hasKey(key)) tag.setTag(key, new NBTTagList());
    NBTTagList li = tag.getTagList(key, NBTTypes.STRING.ID);
    tag.setTag(key, li);
    return li;
  }
コード例 #15
0
ファイル: MekanismHooks.java プロジェクト: kenlefeb/Mekanism
  public void addPulverizerRecipe(ItemStack input, ItemStack output, int energy) {
    NBTTagCompound nbtTags = new NBTTagCompound();

    nbtTags.setInteger("energy", energy);
    nbtTags.setTag("input", input.writeToNBT(new NBTTagCompound()));
    nbtTags.setTag("primaryOutput", output.writeToNBT(new NBTTagCompound()));

    FMLInterModComms.sendMessage("mekanism", "PulverizerRecipe", nbtTags);
  }
コード例 #16
0
  public void encode() {
    ItemStack output = this.patternSlotOUT.getStack();

    final ItemStack[] in = this.getInputs();
    final ItemStack[] out = this.getOutputs();

    // if there is no input, this would be silly.
    if (in == null || out == null) {
      return;
    }

    // first check the output slots, should either be null, or a pattern
    if (output != null && !this.isPattern(output)) {
      return;
    } // if nothing is there we should snag a new pattern.
    else if (output == null) {
      output = this.patternSlotIN.getStack();
      if (output == null || !this.isPattern(output)) {
        return; // no blanks.
      }

      // remove one, and clear the input slot.
      output.stackSize--;
      if (output.stackSize == 0) {
        this.patternSlotIN.putStack(null);
      }

      // add a new encoded pattern.
      for (final ItemStack encodedPatternStack :
          AEApi.instance().definitions().items().encodedPattern().maybeStack(1).asSet()) {
        output = encodedPatternStack;
        this.patternSlotOUT.putStack(output);
      }
    }

    // encode the slot.
    final NBTTagCompound encodedValue = new NBTTagCompound();

    final NBTTagList tagIn = new NBTTagList();
    final NBTTagList tagOut = new NBTTagList();

    for (final ItemStack i : in) {
      tagIn.appendTag(this.createItemTag(i));
    }

    for (final ItemStack i : out) {
      tagOut.appendTag(this.createItemTag(i));
    }

    encodedValue.setTag("in", tagIn);
    encodedValue.setTag("out", tagOut);
    encodedValue.setBoolean("crafting", this.isCraftingMode());
    encodedValue.setBoolean("substitute", this.isSubstitute());

    output.setTagCompound(encodedValue);
  }
コード例 #17
0
  @Override
  public void writeToNBT(NBTTagCompound data) {
    super.writeToNBT(data);

    NBTTagList itemList = new NBTTagList();
    NBTTagList sideItemList = new NBTTagList();
    NBTTagCompound configData;

    data.setBoolean("shareRS", isRSShared);

    for (int i = 0; i < 3; i++) {

      if (inventory.getStackInSlot(i) != null) {
        NBTTagCompound itemCompound = new NBTTagCompound();
        itemCompound.setInteger("slot", i);
        inventory.getStackInSlot(i).writeToNBT(itemCompound);
        itemList.appendTag(itemCompound);
      }

      if (tanks[i].getFluid() != null) {
        data.setInteger("tankCap" + i, tanks[i].getCapacity());
        data.setTag("Fluid" + i, tanks[i].getFluid().writeToNBT(new NBTTagCompound()));
      }

      data.setBoolean("rsControl" + i, rsControl[i]);
      data.setBoolean("rsLatch" + i, rsLatch[i]);
    }

    data.setTag("items", itemList);

    for (int i = 0; i < 6; i++) {
      data.setInteger("side" + i, sides[i]);
      configData = new NBTTagCompound();
      configs[i].writeToNBT(configData);
      data.setCompoundTag("config" + i, configData);
      data.setBoolean("rs" + i, sideRS[i]);
      data.setBoolean("lock" + i, sideLocked[i]);
      data.setInteger("facID" + i, facID[i]);
      data.setInteger("facMeta" + i, facMeta[i]);

      if (sideInventory.getStackInSlot(i) != null) {
        NBTTagCompound itemCompound = new NBTTagCompound();
        itemCompound.setInteger("slot", i);
        sideInventory.getStackInSlot(i).writeToNBT(itemCompound);
        sideItemList.appendTag(itemCompound);
      }
    }

    data.setTag("sideItems", sideItemList);

    if (capacitor != null) {
      data.setInteger("realPower", capacitor.getEnergyStored());
      capacitor.writeToNBT(data);
      data.setInteger("powerCap2", capacitor.getMaxEnergyStored());
    }
  }
コード例 #18
0
  @Override
  public void writeToNBT(NBTTagCompound nbtTags) {
    super.writeToNBT(nbtTags);

    nbtTags.setBoolean("isActive", isActive);
    nbtTags.setInteger("controlType", controlType.ordinal());
    nbtTags.setInteger("operatingTicks", operatingTicks);
    nbtTags.setTag("injectTank", injectTank.write(new NBTTagCompound()));
    nbtTags.setTag("gasTank", outputTank.write(new NBTTagCompound()));
  }
コード例 #19
0
  public Entity func_98265_a(Entity p_98265_1_) {
    if (this.getRandomMinecart() != null) {
      NBTTagCompound var2 = new NBTTagCompound();
      p_98265_1_.writeToNBTOptional(var2);
      Iterator var3 = this.getRandomMinecart().field_98222_b.func_150296_c().iterator();

      while (var3.hasNext()) {
        String var4 = (String) var3.next();
        NBTBase var5 = this.getRandomMinecart().field_98222_b.getTag(var4);
        var2.setTag(var4, var5.copy());
      }

      p_98265_1_.readFromNBT(var2);

      if (p_98265_1_.worldObj != null) {
        p_98265_1_.worldObj.spawnEntityInWorld(p_98265_1_);
      }

      NBTTagCompound var11;

      for (Entity var10 = p_98265_1_; var2.func_150297_b("Riding", 10); var2 = var11) {
        var11 = var2.getCompoundTag("Riding");
        Entity var12 = EntityList.createEntityByName(var11.getString("id"), p_98265_1_.worldObj);

        if (var12 != null) {
          NBTTagCompound var6 = new NBTTagCompound();
          var12.writeToNBTOptional(var6);
          Iterator var7 = var11.func_150296_c().iterator();

          while (var7.hasNext()) {
            String var8 = (String) var7.next();
            NBTBase var9 = var11.getTag(var8);
            var6.setTag(var8, var9.copy());
          }

          var12.readFromNBT(var6);
          var12.setLocationAndAngles(
              var10.posX, var10.posY, var10.posZ, var10.rotationYaw, var10.rotationPitch);

          if (p_98265_1_.worldObj != null) {
            p_98265_1_.worldObj.spawnEntityInWorld(var12);
          }

          var10.mountEntity(var12);
        }

        var10 = var12;
      }
    } else if (p_98265_1_ instanceof EntityLivingBase && p_98265_1_.worldObj != null) {
      ((EntityLiving) p_98265_1_).onSpawnWithEgg((IEntityLivingData) null);
      this.getSpawnerWorld().spawnEntityInWorld(p_98265_1_);
    }

    return p_98265_1_;
  }
コード例 #20
0
 public NBTTagCompound toNbt() {
   NBTTagCompound tag = new NBTTagCompound();
   NBTTagList elements = new NBTTagList();
   for (Map.Entry<Key, Integer> e : _elements.entrySet()) {
     NBTTagCompound element = new NBTTagCompound();
     element.setTag("key", e.getKey().toNbt());
     element.setInteger("count", e.getValue());
     elements.appendTag(element);
   }
   tag.setTag("elements", elements);
   tag.setInteger("size", _size);
   return tag;
 }
コード例 #21
0
    public static void addGrinderRecipe(ItemStack input, ItemStack output, int turns) {
      NBTTagCompound msg = new NBTTagCompound();
      NBTTagCompound in = new NBTTagCompound();
      NBTTagCompound out = new NBTTagCompound();

      input.writeToNBT(in);
      output.writeToNBT(out);

      msg.setTag("in", in);
      msg.setTag("out", out);
      msg.setInteger("turns", turns);

      sendInterModMessage("appliedenergistics2", "add-grindable", msg);
    }
コード例 #22
0
  private void handleFireworks(WorldServer world) {
    if (random.nextFloat() < 0.05) {
      // Calculate a bounding box for all players in the world.
      double minPosX = 1000000000.0f;
      double minPosZ = 1000000000.0f;
      double maxPosX = -1000000000.0f;
      double maxPosZ = -1000000000.0f;
      for (Object playerEntity : world.playerEntities) {
        EntityPlayer player = (EntityPlayer) playerEntity;
        if (player.posX > maxPosX) {
          maxPosX = player.posX;
        }
        if (player.posX < minPosX) {
          minPosX = player.posX;
        }
        if (player.posZ > maxPosZ) {
          maxPosZ = player.posZ;
        }
        if (player.posZ < minPosZ) {
          minPosZ = player.posZ;
        }
      }
      double posX = random.nextFloat() * (maxPosX - minPosX + 60.0f) + minPosX - 30.0f;
      double posZ = random.nextFloat() * (maxPosZ - minPosZ + 60.0f) + minPosZ - 30.0f;

      ItemStack fireworkStack = new ItemStack(Items.fireworks);
      NBTTagCompound tag = new NBTTagCompound();

      NBTTagCompound fireworks = new NBTTagCompound();
      fireworks.setByte("Flight", (byte) 2);

      NBTTagList explosions = new NBTTagList();
      explosions.appendTag(makeExplosion(tag));
      fireworks.setTag("Explosions", explosions);

      tag.setTag("Fireworks", fireworks);

      fireworkStack.setTagCompound(tag);

      int y = world.getTopSolidOrLiquidBlock((int) posX, (int) posZ);
      if (y == -1) {
        y = 64;
      } else {
        y += 3;
      }
      EntityFireworkRocket entityfireworkrocket =
          new EntityFireworkRocket(world, posX, y, posZ, fireworkStack);
      world.spawnEntityInWorld(entityfireworkrocket);
    }
  }
コード例 #23
0
  @Override
  public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) {
    super.writeCustomNBT(nbt, descPacket);
    nbt.setInteger("facing", facing);
    energyStorage.writeToNBT(nbt);

    NBTTagCompound tankTag = tank.writeToNBT(new NBTTagCompound());
    nbt.setTag("tank", tankTag);

    nbt.setTag("inventory", Utils.writeInventory(inventory));

    nbt.setTag("predictedOutput", Utils.writeInventory(predictedOutput));

    nbt.setIntArray("process", process);
  }
コード例 #24
0
 @Override
 public void writeToNBT(NBTTagCompound tag) {
   super.writeToNBT(tag);
   tag.setString("owningPlayer", owningPlayer);
   tag.setTag(
       "bookInventory", InventoryTools.writeInventoryToNBT(bookInventory, new NBTTagCompound()));
   tag.setTag(
       "resourceInventory",
       InventoryTools.writeInventoryToNBT(resourceInventory, new NBTTagCompound()));
   tag.setBoolean("useAdjacentInventory", useAdjacentInventory);
   tag.setDouble("storedEnergy", storedEnergy);
   tag.setInteger("orientation", orientation.ordinal());
   tag.setInteger("inventoryDirection", inventoryDirection.ordinal());
   tag.setInteger("inventorySide", inventorySide.ordinal());
 }
コード例 #25
0
ファイル: TileEntity.java プロジェクト: tjkenmate/MCOverhaul
  private NBTTagCompound writeInternal(NBTTagCompound compound) {
    String s = (String) classToNameMap.get(this.getClass());

    if (s == null) {
      throw new RuntimeException(this.getClass() + " is missing a mapping! This is a bug!");
    } else {
      compound.setString("id", s);
      compound.setInteger("x", this.pos.getX());
      compound.setInteger("y", this.pos.getY());
      compound.setInteger("z", this.pos.getZ());
      if (this.customTileData != null) compound.setTag("ForgeData", this.customTileData);
      if (this.capabilities != null) compound.setTag("ForgeCaps", this.capabilities.serializeNBT());
      return compound;
    }
  }
コード例 #26
0
 @Override
 public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) {
   super.writeCustomNBT(nbt, descPacket);
   nbt.setInteger("facing", facing);
   NBTTagCompound tankTag = tank0.writeToNBT(new NBTTagCompound());
   nbt.setTag("tank0", tankTag);
   tankTag = tank1.writeToNBT(new NBTTagCompound());
   nbt.setTag("tank1", tankTag);
   tankTag = tank2.writeToNBT(new NBTTagCompound());
   nbt.setTag("tank2", tankTag);
   energyStorage.writeToNBT(nbt);
   if (!descPacket) {
     nbt.setTag("inventory", Utils.writeInventory(inventory));
   }
 }
コード例 #27
0
 @Override
 public void updatePacket(NBTTagCompound nbt) {
   super.updatePacket(nbt);
   for (int i = 0; i < connections.length; i++) {
     if (connections[i] != null) nbt.setTag("co" + i, connections[i].saveConnection());
   }
 }
コード例 #28
0
 @Override
 public void saveTileExtra(NBTTagCompound nbt) {
   super.saveTileExtra(nbt);
   for (int i = 0; i < connections.length; i++) {
     if (connections[i] != null) nbt.setTag("co" + i, connections[i].saveConnection());
   }
 }
コード例 #29
0
  // インベントリの保存
  public void save() {
    NBTTagList nbttaglist = new NBTTagList();

    for (int i = 0; i < this.containerItems.length; i++) {
      if (this.containerItems[i] != null) {
        NBTTagCompound nbttagcompound1 = new NBTTagCompound();
        nbttagcompound1.setByte("EquipmentSlot", (byte) i);
        this.containerItems[i].writeToNBT(nbttagcompound1);
        nbttaglist.appendTag(nbttagcompound1);
      }
    }

    // ItemStackのNBTに中身を保存
    NBTTagCompound nbttagcompound = this.baseChest.getEntityData();

    if (nbttagcompound == null) {
      nbttagcompound = new NBTTagCompound();
    }

    nbttagcompound.setTag("EquipmentItems", nbttaglist);

    // EntityLivingのequipmentと同期
    for (int slot = 0; slot < this.containerItems.length; slot++) {
      this.baseChest.setCurrentItemOrArmor(slot, this.containerItems[slot]);
    }
  }
コード例 #30
0
 public ItemStack getItemStackWithData(World world, int x, int y, int z) {
   ItemStack stack = new ItemStack(world.getBlock(x, y, z), 1, 0);
   TileEntity tentity = world.getTileEntity(x, y, z);
   if (tentity instanceof TileVendorBlock) {
     TileVendorBlock te = (TileVendorBlock) tentity;
     NBTTagList itemList = new NBTTagList();
     NBTTagCompound tagCompound = new NBTTagCompound();
     for (int i = 0; i < te.getSizeInventory(); i++) {
       ItemStack invStack = te.getStackInSlot(i);
       if (invStack != null) {
         NBTTagCompound tag = new NBTTagCompound();
         tag.setByte("Slot", (byte) i);
         invStack.writeToNBT(tag);
         itemList.appendTag(tag);
       }
     }
     tagCompound.setTag("Inventory", itemList);
     tagCompound.setInteger("CoinSum", te.coinSum);
     tagCompound.setInteger("UserCoinSum", te.userCoinSum);
     tagCompound.setInteger("ItemPrice", te.itemPrice);
     tagCompound.setString("BlockOwner", te.blockOwner);
     tagCompound.setBoolean("Infinite", te.infiniteMode);
     stack.setTagCompound(tagCompound);
     return stack;
   } else return stack;
 }