示例#1
0
  public static boolean moveBlock(
      World world, Coord src, Coord tgt, boolean allowBlockReplacement) {
    if (!world.isRemote
        && !src.isAirBlock(world)
        && (tgt.isAirBlock(world) || allowBlockReplacement)) {
      int blockID = src.getBlockID(world);
      int metadata = src.getBlockMetadata(world);

      world.setBlock(tgt.x, tgt.y, tgt.z, blockID, metadata, BlockNotifyFlags.ALL);

      if (world.blockHasTileEntity(src.x, src.y, src.z)) {
        TileEntity te = world.getBlockTileEntity(src.x, src.y, src.z);
        if (te != null) {
          NBTTagCompound nbt = new NBTTagCompound();
          te.writeToNBT(nbt);

          nbt.setInteger("x", tgt.x);
          nbt.setInteger("y", tgt.y);
          nbt.setInteger("z", tgt.z);

          te = world.getBlockTileEntity(tgt.x, tgt.y, tgt.z);
          if (te != null) te.readFromNBT(nbt);
        }
      }

      world.setBlockToAir(src.x, src.y, src.z);
      return true;
    }
    return false;
  }
示例#2
0
  @Override
  public void readFromNBT(final NBTTagCompound tag) {
    super.readFromNBT(tag);

    this.age = tag.getLong("age");

    this.inventories.clear();

    final NBTTagCompound inventoriesTag = tag.getCompoundTag("inventories");

    for (final Object key : inventoriesTag.getKeySet()) {
      final String inventoryName = (String) key;
      final NBTTagList inventoryTag = inventoriesTag.getTagList(inventoryName, tag.getId());
      final Map<Integer, ItemStack> inventory = new HashMap<>();

      for (int i = 0; i < inventoryTag.tagCount(); i++) {
        final NBTTagCompound slotTag = inventoryTag.getCompoundTagAt(i);
        final ItemStack stack = ItemStack.loadItemStackFromNBT(slotTag);

        inventory.put((int) slotTag.getByte("slot"), stack);
      }

      this.inventories.put(inventoryName, inventory);
    }

    this.setOwner(NBTUtil.readGameProfileFromNBT(tag.getCompoundTag("owner")));
  }
  @Override
  public void readFromNBT(NBTTagCompound compound) {
    super.readFromNBT(compound);

    if (this instanceof IStructurePart && compound.hasKey(CoreReferences.NBT.STRUCTURE)) {
      int dim;
      if (getWorld() == null) dim = compound.getInteger(CoreReferences.NBT.StructureData.DIMENSION);
      else dim = getWorld().provider.getDimension();

      ((IStructurePart) this)
          .setStructure(
              StructureRegistry.getInstance()
                  .getStructure(
                      dim,
                      Coordinate3D.fromNBT(compound.getCompoundTag(CoreReferences.NBT.STRUCTURE))));
    }

    if (getState().requiresNBTStorage())
      this.getState().readFromNBTTagCompound(compound.getTag(CoreReferences.NBT.STATE));

    if (this instanceof IItemStorage)
      this.readInventoryFromCompound(compound.getTag(CoreReferences.NBT.INVENTORY));

    if (this instanceof IFluidContainingEntity)
      this.readFluidsFromCompound(compound.getTag(CoreReferences.NBT.FLUIDS));

    if (compound.hasKey(CoreReferences.NBT.NAME)) {
      this.name = compound.getString(CoreReferences.NBT.NAME);
    }
  }
  /** Reads a tile entity from NBT. */
  public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
    super.readFromNBT(par1NBTTagCompound);
    NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Items", Constants.NBT.TAG_COMPOUND);
    this.chestContents = new ItemStack[this.getSizeInventory()];

    if (par1NBTTagCompound.hasKey("chestID")) {
      this.id = par1NBTTagCompound.getInteger("chestID");
    }

    if (par1NBTTagCompound.hasKey("myAccessTick")) {
      this.accessTicks = par1NBTTagCompound.getInteger("myAccessTick");
    }

    if (par1NBTTagCompound.hasKey("CustomName")) {
      this.customName = par1NBTTagCompound.getString("CustomName");
    }

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

      if (j >= 0 && j < this.chestContents.length) {
        this.chestContents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
      }
    }
  }
  @Override
  public void readFromNBT(NBTTagCompound nbttagcompound) {
    super.readFromNBT(nbttagcompound);

    Utils.readStacksFromNBT(nbttagcompound, "items", items);

    energyStored = nbttagcompound.getFloat("energyStored");

    NBTTagList list = nbttagcompound.getTagList("planned");

    for (int i = 0; i < list.tagCount(); ++i) {
      NBTTagCompound cpt = (NBTTagCompound) list.tagAt(i);

      ItemStack stack = ItemStack.loadItemStackFromNBT(cpt);

      for (AssemblyRecipe r : AssemblyRecipe.assemblyRecipes) {
        if (r.output.itemID == stack.itemID && r.output.getItemDamage() == stack.getItemDamage()) {
          plannedOutput.add(r);
        }
      }
    }

    if (nbttagcompound.hasKey("recipe")) {
      ItemStack stack = ItemStack.loadItemStackFromNBT(nbttagcompound.getCompoundTag("recipe"));

      for (AssemblyRecipe r : plannedOutput) {
        if (r.output.itemID == stack.itemID && r.output.getItemDamage() == stack.getItemDamage()) {
          setCurrentRecipe(r);
          break;
        }
      }
    }
  }
 @Override
 public void readFromNBT(NBTTagCompound nbt) {
   super.readFromNBT(nbt);
   if (nbt.hasKey("innerEnergy")) {
     this.innerEnerygy = nbt.getInteger("innerEnergy");
   }
 }
  @Override
  public void readFromNBT(NBTTagCompound tagCompound) {
    super.readFromNBT(tagCompound);

    facing = ForgeDirection.getOrientation(tagCompound.getInteger("direction"));

    isValidMultiblock = tagCompound.getBoolean("isValidMultiblock");

    NBTTagList itemsTag = (NBTTagList) tagCompound.getTag("Items");
    furnaceItems = new ItemStack[getSizeInventory()];

    for (int i = 0; i < itemsTag.tagCount(); i++) {
      NBTTagCompound slotTag = (NBTTagCompound) itemsTag.getCompoundTagAt(i);
      byte slot = slotTag.getByte("Slot");

      if (slot >= 0 && slot < furnaceItems.length)
        furnaceItems[slot] = ItemStack.loadItemStackFromNBT(slotTag);
    }

    furnaceBurnTime = tagCompound.getShort("BurnTime");
    furnaceCookTime = tagCompound.getShort("CookTime");
    currentItemBurnTime = TileEntityFurnace.getItemBurnTime(furnaceItems[1]);
    cooking = tagCompound.getBoolean("active");
    type = tagCompound.getInteger("type");
    if (type == 1) partBlocks = stonebrick;
    hole = hole.readFromNBT(tagCompound, "hole");
  }
 @Override
 public void readFromNBT(NBTTagCompound tagCompound) {
   super.readFromNBT(tagCompound);
   tank.readFromNBT(tagCompound);
   inventory.readFromNBT(tagCompound);
   energySource.readFromNBT(tagCompound);
 }
  @Override
  public void readFromNBT(NBTTagCompound tag) {

    super.readFromNBT(tag);

    readCustomNBT(tag);
  }
 @Override
 public void readFromNBT(NBTTagCompound compound) {
   super.readFromNBT(compound);
   if (compound.hasKey("CustomName")) customTitle = compound.getString("CustomName");
   if (contents != null) NbtUtils.readItems(contents, compound.getTagList("Items"));
   if (compound.getBoolean("ComparatorAccessed")) compAccessedOnLoad = true;
 }
  @Override
  public void readFromNBT(NBTTagCompound nbt) {
    super.readFromNBT(nbt);
    storage.readFromNBT(nbt);

    laserSat.readFromNBT(nbt.getCompoundTag("laser"));

    /*NBTTagList tagList = nbt.getTagList("Inventory");
    for (int i = 0; i < tagList.tagCount(); i++) {
    	NBTTagCompound tag = (NBTTagCompound) tagList.tagAt(i);
    	byte slot = tag.getByte("Slot");
    	if (slot >= 0 && slot < invBuffer.length) {
    		invBuffer[slot] = ItemStack.loadItemStackFromNBT(tag);
    	}
    }*/
    if (nbt.hasKey("GlassPane")) {
      NBTTagCompound tag = nbt.getCompoundTag("GlassPane");
      glassPanel = ItemStack.loadItemStackFromNBT(tag);
    }

    laserX = nbt.getInteger("laserX");
    laserZ = nbt.getInteger("laserZ");
    mode = MODE.values()[nbt.getByte("mode")];

    if (mode == MODE.SPIRAL) {
      xCenter = nbt.getInteger("CenterX");
      yCenter = nbt.getInteger("CenterY");
      radius = nbt.getInteger("radius");
      numSteps = nbt.getInteger("numSteps");
      prevDir = ForgeDirection.values()[nbt.getInteger("prevDir")];
    }
  }
  // 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 tagCompound) {
    super.readFromNBT(tagCompound);

    // ItemStacks
    NBTTagList tagList = tagCompound.getTagList("Items", 10);
    ovenStacks = new ItemStack[getSizeInventory()];

    for (int i = 0; i < tagList.tagCount(); ++i) {
      NBTTagCompound itemTag = tagList.getCompoundTagAt(i);
      byte slot = itemTag.getByte("Slot");

      if (slot >= 0 && slot < ovenStacks.length) {
        ovenStacks[slot] = ItemStack.loadItemStackFromNBT(itemTag);
      }
    }

    // Burn Time & Cook Time
    ovenBurnTime = tagCompound.getShort("BurnTime");
    ovenCookTime = tagCompound.getShort("CookTime");
    currentItemBurnLength = getItemBurnTime(ovenStacks[1]);

    if (tagCompound.hasKey("CustomName")) {
      ovenName = tagCompound.getString("CustomName");
    }
  }
 @Override
 public void readFromNBT(NBTTagCompound compound) {
   super.readFromNBT(compound);
   this.script = new ScriptInstance(this, compound.getString("SpellScript"));
   this.energy = compound.getInteger("MagicEnergy");
   this.direction = NBTUtils.convertTagContentToFacing(compound);
 }
  @Override
  public void readFromNBT(NBTTagCompound tagCompound) {
    super.readFromNBT(tagCompound);

    facing = Util.byte2Direction(tagCompound.getByte("facing"));
    functionalSide = Util.byte2Direction(tagCompound.getByte("functionalSide"));
  }
 public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
   try {
     super.readFromNBT(par1NBTTagCompound);
   } catch (Exception ex) {
     ex.printStackTrace();
   }
 }
  @Override
  public void readFromNBT(NBTTagCompound tag) {
    super.readFromNBT(tag);

    facing = ForgeDirection.getOrientation(tag.getInteger("facing"));
    linkedDir = ForgeDirection.getOrientation(tag.getInteger("linked"));
  }
示例#18
0
 @Override
 public void readFromNBT(NBTTagCompound nbt) {
   super.readFromNBT(nbt);
   NBTTagCompound tankTag = nbt.getCompoundTag("tank");
   this.tank.readFromNBT(tankTag);
   this.prevAmount = nbt.getInteger("prev");
   this.colour = nbt.getInteger("colour");
 }
  @Override
  public void readFromNBT(NBTTagCompound tagCompound) {
    super.readFromNBT(tagCompound);

    coreX = tagCompound.getInteger("CoreX");
    coreY = tagCompound.getInteger("CoreY");
    coreZ = tagCompound.getInteger("CoreZ");
  }
 @Override
 public void readFromNBT(NBTTagCompound tag) {
   super.readFromNBT(tag);
   this.currentEnergyValue = tag.getInteger("energy");
   this.tier = tag.getByte("tier");
   this.frequency = tag.getInteger("frequency");
   this.isEnabled = tag.getBoolean("enabled");
 }
 @Override
 public void readFromNBT(NBTTagCompound tagCompound) {
   super.readFromNBT(tagCompound);
   String mes = tagCompound.getString("MES");
   newEntity(mes);
   this.side = tagCompound.getInteger("MES.s");
   getProxyEntity().readFromNBT(tagCompound);
 }
    @Override
    public void readFromNBT(NBTTagCompound NBT) {
      super.readFromNBT(NBT);

      complete = NBT.getBoolean("built");

      charge = NBT.getInteger("charge");
    }
    public void readFromNBT(NBTTagCompound compound) {
      super.readFromNBT(compound);

      if (compound.hasKey("RecordItem", 10)) {
        this.setRecord(ItemStack.loadItemStackFromNBT(compound.getCompoundTag("RecordItem")));
      } else if (compound.getInteger("Record") > 0) {
        this.setRecord(new ItemStack(Item.getItemById(compound.getInteger("Record"))));
      }
    }
  @Override
  public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
    super.readFromNBT(par1NBTTagCompound);

    this.interval = par1NBTTagCompound.getShort("Interval");
    this.round = par1NBTTagCompound.getShort("Round");
    this.click = par1NBTTagCompound.getShort("Click");
    this.chargeAmount = par1NBTTagCompound.getShort("ChargeAmount");
  }
示例#25
0
  /** Reads a tile entity from NBT. */
  public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
    super.readFromNBT(par1NBTTagCompound);
    this.skullType = par1NBTTagCompound.getByte("SkullType");
    this.skullRotation = par1NBTTagCompound.getByte("Rot");

    if (par1NBTTagCompound.hasKey("ExtraType")) {
      this.extraType = par1NBTTagCompound.getString("ExtraType");
    }
  }
示例#26
0
 public void readFromNBT(NBTTagCompound compound) {
   super.readFromNBT(compound);
   this.field_174932_a =
       Block.getBlockById(compound.getInteger("blockId"))
           .getStateFromMeta(compound.getInteger("blockData"));
   this.field_174931_f = EnumFacing.getFront(compound.getInteger("facing"));
   this.lastProgress = this.progress = compound.getFloat("progress");
   this.extending = compound.getBoolean("extending");
 }
示例#27
0
  @Override
  public void readFromNBT(NBTTagCompound nbtTagCompound) {
    super.readFromNBT(nbtTagCompound);

    if (nbtTagCompound.hasKey("CustomName")) {
      this.customName = nbtTagCompound.getString("CustomName");
    } else {
      this.customName = null;
    }
  }
示例#28
0
 @Override
 public void readFromNBT(NBTTagCompound par1) {
   super.readFromNBT(par1);
   if (par1.getByte("TeamId") != teamId) {
     this.teamId = par1.getByte("TeamId");
   }
   this.type = par1.getByte("Type");
   this.xTarget = par1.getDouble("TargetX");
   this.yTarget = par1.getDouble("TargetY");
   this.zTarget = par1.getDouble("TargetZ");
 }
示例#29
0
  @Override
  public void readFromNBT(NBTTagCompound nbtTags) {
    super.readFromNBT(nbtTags);

    facing = nbtTags.getInteger("facing");
    redstone = nbtTags.getBoolean("redstone");

    for (ITileComponent component : components) {
      component.read(nbtTags);
    }
  }
  public void readFromNBT(NBTTagCompound tag) {
    super.readFromNBT(tag);

    hasAir = tag.getBoolean("b0");
    hasFire = tag.getBoolean("b1");
    hasWater = tag.getBoolean("b2");
    hasEarth = tag.getBoolean("b3");
    hasOrdo = tag.getBoolean("b4");
    hasEntropy = tag.getBoolean("b5");
    placerName = tag.getString("placer");
  }