コード例 #1
0
  @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);
    }
  }
コード例 #2
0
  @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");
  }
コード例 #3
0
  public void setData(TileEntity te, boolean force, NBTTagCompound NBT) {
    if (dispatch) {
      if (DragonOptions.LOGSYNCCME.getState()) {
        DragonAPICore.log("The sync packet for " + te + " would have just CME'd, as the");
        DragonAPICore.log(
            "Server-Thread data-writing code has overlapped with the Network-Thread byte[] dispatch.");
        DragonAPICore.log("Seeing this message frequently could indicate a serious issue.\n");
      }
      return;
    }

    field_148863_a = te.xCoord;
    field_148861_b = te.yCoord;
    field_148862_c = te.zCoord;

    changes.clear();
    Collection c = NBT.func_150296_c();
    Iterator<String> it = c.iterator();
    while (it.hasNext()) {
      String name = it.next();
      if (name == null) {
        DragonAPICore.logError(
            "An NBT tag with a null key is being sent to the sync packet from " + te);
      } else {
        NBTBase tag = NBT.getTag(name);
        this.addData(name, tag, force);
      }
    }
  }
コード例 #4
0
  private void func_143027_a(World world) {
    if (this.itemData == null) {
      this.itemData = world.loadItemData(MapGenStructureData.class, this.getStructureName());

      if (this.itemData == null) {
        this.itemData = new MapGenStructureData(this.getStructureName());
        world.setItemData(this.getStructureName(), this.itemData);
      } else {
        NBTTagCompound var2 = this.itemData.getTag();

        for (String var4 : var2.getKeySet()) {
          NBTBase var5 = var2.getTag(var4);

          if (var5.getType() == 10) {
            NBTTagCompound var6 = (NBTTagCompound) var5;

            if (var6.hasKey("ChunkX") && var6.hasKey("ChunkZ")) {
              int x = var6.getInteger("ChunkX");
              int z = var6.getInteger("ChunkZ");
              StructureStart var9 = MapGenStructureIO.func_143035_a(var6);

              if (var9 != null) {
                this.structureMap.put(ChunkPos.toLong(x, z), var9);
              }
            }
          }
        }
      }
    }
  }
コード例 #5
0
  @Override
  protected void readCustomNBT(NBTTagCompound root) {
    if (root.hasKey("accessMode")) {
      accessMode = AccessMode.values()[root.getShort("accessMode")];
    } else {
      // keep behavior the same for blocks placed prior to this update
      accessMode = AccessMode.PUBLIC;
    }
    placedBy = PlayerUtil.getPlayerUIDUnstable(root.getString("placedBy"));
    for (int i = 0; i < password.length; i++) {
      if (root.hasKey("password" + i)) {
        NBTTagCompound stackRoot = (NBTTagCompound) root.getTag("password" + i);
        password[i] = ItemStack.loadItemStackFromNBT(stackRoot);
      } else {
        password[i] = null;
      }
    }
    authorisedUsers.clear();
    String userStr = root.getString("authorisedUsers");
    if (userStr != null && userStr.length() > 0) {
      String[] users = userStr.split(",");
      for (String user : users) {
        if (user != null) {
          user = user.trim();
          if (user.length() > 0) {
            authorisedUsers.add(PlayerUtil.getPlayerUIDUnstable(user));
          }
        }
      }
    }
    if (root.hasKey("itemLabel")) {
      NBTTagCompound stackRoot = (NBTTagCompound) root.getTag("itemLabel");
      itemLabel = ItemStack.loadItemStackFromNBT(stackRoot);
    } else {
      itemLabel = null;
    }

    String sourceBlockStr = root.getString(KEY_SOURCE_BLOCK_ID);
    sourceBlock = Block.getBlockFromName(sourceBlockStr);
    sourceBlockMetadata = root.getInteger(KEY_SOURCE_BLOCK_META);

    label = root.getString("label");
    if (label == null || label.trim().length() == 0) {
      label = null;
    }
  }
コード例 #6
0
ファイル: ReikaNBTHelper.java プロジェクト: TehporP/DragonAPI
 public static void combineNBT(NBTTagCompound tag1, NBTTagCompound tag2) {
   if (tag2 == null || tag2.hasNoTags()) return;
   for (Object o : tag2.func_150296_c()) {
     String s = (String) o;
     NBTBase key = tag2.getTag(s);
     tag1.setTag(s, key.copy());
   }
 }
コード例 #7
0
 public static DataCompound create(final NBTTagCompound nbt) {
   final DataCompound compound = new DataCompound();
   for (final Object key : nbt.func_150296_c())
     try {
       compound.set((String) key, create(nbt.getTag((String) key)));
     } catch (final Exception e) {
     }
   return compound;
 }
コード例 #8
0
 private void populateFromStream(NBTTagCompound received) {
   Collection c = received.func_150296_c();
   Iterator<String> it = c.iterator();
   while (it.hasNext()) {
     String name = it.next();
     NBTBase tag = received.getTag(name);
     data.put(name, tag);
   }
 }
コード例 #9
0
 @Override
 public void readCommonNBT(NBTTagCompound nbt) {
   super.readCommonNBT(nbt);
   if (nbt.hasKey("isRedstonePowerd")) isRedstonePowered = nbt.getBoolean("isRedstonePowerd");
   if (nbt.hasKey("burning")) burning = nbt.getInteger("burning");
   if (nbt.hasKey("burningItem")) {
     NBTTagCompound tag = (NBTTagCompound) nbt.getTag("burningItem");
     burningItem = ItemStack.loadItemStackFromNBT(tag);
   }
 }
コード例 #10
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_;
  }
コード例 #11
0
ファイル: DimensionInformation.java プロジェクト: ntf/RFTools
 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];
   }
 }
コード例 #12
0
 @Override
 public void readFromNBT(NBTTagCompound nbt) {
   super.readFromNBT(nbt);
   if (nbt.hasKey("Items")) {
     NBTTagList l = (NBTTagList) nbt.getTag("Items");
     for (int i = 0; i < l.tagCount(); i++) {
       NBTTagCompound item = l.getCompoundTagAt(i);
       slots[item.getInteger("Slot")] = ItemStack.loadItemStackFromNBT(item);
     }
   }
 }
コード例 #13
0
 // Load whatever data you saved
 @Override
 public void loadNBTData(NBTTagCompound compound) {
   // Here we fetch the unique tag compound we set for this class of Extended Properties
   NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PROP_NAME);
   // Get our data from the custom tag compound
   this.player
       .getDataWatcher()
       .updateObject(KINDNESS_WATCHER, properties.getInteger("CurrentKindness"));
   this.maxKindness = properties.getInteger("maxKindness");
   // Just so you know it's working, add this line:
   // System.out.println("[TUT PROPS] Mana from NBT: " + this.currentMana + "/" +
   // this.maxKindness);
 }
コード例 #14
0
 @Override
 public void readFromNBT(NBTTagCompound nbtTagCompound) {
   super.readFromNBT(nbtTagCompound);
   this.inventory = new ItemStack[getSizeInventory()];
   this.isComplete = false;
   NBTTagCompound blueprintNBT = (NBTTagCompound) nbtTagCompound.getTag("blueprint");
   if (blueprintNBT != null) {
     ItemStack blueprintStack = ItemStack.loadItemStackFromNBT(blueprintNBT);
     MinechemBlueprint blueprint = MinechemItems.blueprint.getBlueprint(blueprintStack);
     setBlueprint(blueprint);
     this.inventory[0] = blueprintStack;
   }
 }
コード例 #15
0
  @Override
  public void readFromNBT(NBTTagCompound nbt) {
    super.readFromNBT(nbt);

    wft = nbt.getInteger("wft");
    // passed = nbt.getBoolean("passed");
    gameUsable = nbt.getBoolean("gameUsable");

    ownership = nbt.getInteger("ownership");
    XOwnership = nbt.getInteger("xownership");
    if (nbt.hasKey("in")) {
      stackIn = ItemStack.loadItemStackFromNBT((NBTTagCompound) nbt.getTag("in"));
    } else stackIn = null;
  }
コード例 #16
0
ファイル: Melter.java プロジェクト: Robbi-Blechdose/BaconMod
  public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
    super.readFromNBT(par1NBTTagCompound);
    NBTBase nbttaglist = par1NBTTagCompound.getTag("Items");
    this.inv = new ItemStack[this.getSizeInventory()];
    for (int i = 0; i < ((NBTTagList) nbttaglist).tagCount(); ++i) {
      NBTTagCompound nbttagcompound1 = (NBTTagCompound) ((Object) nbttaglist).tagAt(i);
      byte b0 = nbttagcompound1.getByte("Slot");

      if (b0 >= 0 && b0 < this.inv.length) {
        this.inv[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
      }
    }

    lava = lava.readFromNBT(par1NBTTagCompound);
    heat = par1NBTTagCompound.getInteger("Heat");
    progress = par1NBTTagCompound.getInteger("Pro");
  }
コード例 #17
0
  public void readFromNBT(NBTTagCompound nbt) {
    this.doSpinning = true; // nbt.getBoolean("doSpinning");
    this.angularVelocityRadians = nbt.getFloat("omegaRad");
    this.skyAngularVelocity = nbt.getFloat("omegaSky");
    this.angularVelocityTarget = nbt.getFloat("omegaTarget");
    this.angularVelocityAccel = nbt.getFloat("omegaAcc");

    NBTTagCompound oneBlock = (NBTTagCompound) nbt.getTag("oneBlock");
    if (oneBlock != null) {
      this.oneSSBlock = BlockVec3.readFromNBT(oneBlock);
    } else {
      this.oneSSBlock = null;
    }

    // A lot of the data can be refreshed by checkSS
    this.checkSS(this.oneSSBlock, false);

    // Send packets to clients in this dimension
    List<Object> objList = new ArrayList<Object>();
    objList.add(Float.valueOf(this.angularVelocityRadians));
    objList.add(Boolean.valueOf(this.thrustersFiring));
    GalacticraftCore.packetPipeline.sendToDimension(
        new PacketSimple(EnumSimplePacket.C_UPDATE_STATION_SPIN, objList),
        this.spaceStationDimensionID);

    objList = new ArrayList<Object>();
    objList.add(Double.valueOf(this.spinCentreX));
    objList.add(Double.valueOf(this.spinCentreZ));
    GalacticraftCore.packetPipeline.sendToDimension(
        new PacketSimple(EnumSimplePacket.C_UPDATE_STATION_DATA, objList),
        this.spaceStationDimensionID);

    objList = new ArrayList<Object>();
    objList.add(Integer.valueOf(this.ssBoundsMinX));
    objList.add(Integer.valueOf(this.ssBoundsMaxX));
    objList.add(Integer.valueOf(this.ssBoundsMinY));
    objList.add(Integer.valueOf(this.ssBoundsMaxY));
    objList.add(Integer.valueOf(this.ssBoundsMinZ));
    objList.add(Integer.valueOf(this.ssBoundsMaxZ));
    GalacticraftCore.packetPipeline.sendToDimension(
        new PacketSimple(EnumSimplePacket.C_UPDATE_STATION_BOX, objList),
        this.spaceStationDimensionID);
  }
コード例 #18
0
  @Override
  public void readFromNBT(NBTTagCompound nbtRoot) {
    readSettingsFromNBT(nbtRoot);

    if (nbtRoot.hasKey("snapshot")) {
      snapshot = new ArrayList<ItemStack>();
      NBTTagList itemList = (NBTTagList) nbtRoot.getTag("snapshot");
      for (int i = 0; i < itemList.tagCount(); i++) {
        NBTTagCompound itemTag = itemList.getCompoundTagAt(i);
        ItemStack itemStack = ItemStack.loadItemStackFromNBT(itemTag);
        if (itemStack != null) {
          snapshot.add(itemStack);
        }
      }

    } else {
      snapshot = null;
    }
  }
コード例 #19
0
  @Override
  public void readFromNBT(NBTTagCompound tagCompound) {
    super.readFromNBT(tagCompound);

    NBTTagList tagList = (NBTTagList) tagCompound.getTag("Items");
    this.inventory = new ItemStack[this.getSizeInventory()];

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

      if (slot >= 0 && slot < this.inventory.length) {
        this.inventory[slot] = ItemStack.loadItemStackFromNBT(nbt);
      }
    }

    this.freezing = tagCompound.getBoolean("Freezing");
    this.progress = tagCompound.getInteger("Progress");
    this.fuelTime = tagCompound.getInteger("FuelTime");
    this.timeRemaining = tagCompound.getInteger("Remaining");
  }
コード例 #20
0
ファイル: ReikaNBTHelper.java プロジェクト: TehporP/DragonAPI
  public static ArrayList<String> parseNBTAsLines(NBTTagCompound nbt) {
    ArrayList<String> li = new ArrayList();
    Iterator<NBTBase> it = nbt.func_150296_c().iterator();
    for (Object o : nbt.func_150296_c()) {
      String key = (String) o;
      NBTBase b = nbt.getTag(key); /*
			if (b instanceof NBTTagByteArray) {
				li.add(b.getName()+": "+Arrays.toString(((NBTTagByteArray)b).byteArray));
			}
			else if (b instanceof NBTTagIntArray) {
				li.add(b.getName()+": "+Arrays.toString(((NBTTagIntArray)b).intArray));
			}
			else if (b instanceof NBTTagCompound) {
				li.add(EnumChatFormatting.GOLD+b.getName()+": "+b.toString());
			}
			else {
				li.add(b.getName()+": "+b.toString());
			}*/
      li.add(key + ": " + b.toString());
    }
    return li;
  }
コード例 #21
0
ファイル: TileConduitBundle.java プロジェクト: haXs/EnderIO
  @Override
  public void readCustomNBT(NBTTagCompound nbtRoot) {
    short nbtVersion = nbtRoot.getShort("nbtVersion");

    conduits.clear();
    cachedCollidables.clear();
    NBTTagList conduitTags = (NBTTagList) nbtRoot.getTag("conduits");
    if (conduitTags != null) {
      for (int i = 0; i < conduitTags.tagCount(); i++) {
        NBTTagCompound conduitTag = conduitTags.getCompoundTagAt(i);
        IConduit conduit = ConduitUtil.readConduitFromNBT(conduitTag, nbtVersion);
        if (conduit != null) {
          conduit.setBundle(this);
          conduits.add(conduit);
        }
      }
    }
    String fs = nbtRoot.getString("facadeId");
    if (fs == null || "null".equals(fs)) {
      facadeId = null;
      facadeType = FacadeType.BASIC;
    } else {
      facadeId = Block.getBlockFromName(fs);
      if (nbtRoot.hasKey("facadeType")) { // backwards compat, never true in freshly placed bundles
        facadeType = FacadeType.valueOf(nbtRoot.getString("facadeType"));
      }
    }
    facadeMeta = nbtRoot.getInteger("facadeMeta");

    if (worldObj != null && worldObj.isRemote) {
      clientUpdated = true;
    }

    if (MicroblocksUtil.supportMicroblocks()) {
      readMicroblocksFromNBT(nbtRoot);
    }
  }
コード例 #22
0
  // Returns error code and reason string
  private int deployShip(
      String fileName, int offsetX, int offsetY, int offsetZ, StringBuilder reason) {
    // Load schematic
    NBTTagCompound schematic = readNBTFromFile(WarpDriveConfig.G_SCHEMALOCATION + "/" + fileName);
    if (schematic == null) {
      reason.append("Schematic not found or unknow error reading it.");
      return -1;
    }

    // Compute geometry
    short width = schematic.getShort("Width");
    short height = schematic.getShort("Height");
    short length = schematic.getShort("Length");

    targetX = xCoord + offsetX;
    targetY = yCoord + offsetY;
    targetZ = zCoord + offsetZ;
    blocksToDeployCount = width * height * length;

    // Validate context
    {
      // Check distance
      double dX = xCoord - targetX;
      double dY = yCoord - targetY;
      double dZ = zCoord - targetZ;
      double distance = MathHelper.sqrt_double(dX * dX + dY * dY + dZ * dZ);

      if (distance > WarpDriveConfig.SS_MAX_DEPLOY_RADIUS_BLOCKS) {
        reason.append("Cannot deploy ship so far away from scanner.");
        return 5;
      }

      // Consume energy
      if (!consumeEnergy(getDeploymentEnergyCost(blocksToDeployCount), false)) {
        reason.append(
            "Insufficient energy (" + getDeploymentEnergyCost(blocksToDeployCount) + " required)");
        return 1;
      }

      // Check specified area for occupation by blocks
      // If specified area occupied, break deploying with error message
      int occupiedBlockCount = 0;
      for (int x = 0; x < width; x++) {
        for (int y = 0; y < height; y++) {
          for (int z = 0; z < length; z++) {
            if (!worldObj.isAirBlock(targetX + x, targetY + y, targetZ + z)) occupiedBlockCount++;
          }
        }
      }
      if (occupiedBlockCount > 0) {
        reason.append(
            "Deploying area occupied with " + occupiedBlockCount + " blocks. Can't deploy ship.");
        return 2;
      }
    }

    // Set deployment variables
    blocksToDeploy = new JumpBlock[blocksToDeployCount];
    isDeploying = true;
    currentDeployIndex = 0;

    // Read blocks and TileEntities from NBT to internal storage array
    NBTTagList localBlocks = (NBTTagList) schematic.getTag("Blocks");
    byte localMetadata[] = schematic.getByteArray("Data");

    // Load Tile Entities
    NBTTagCompound[] tileEntities = new NBTTagCompound[blocksToDeployCount];
    NBTTagList tileEntitiesList =
        schematic.getTagList(
            "TileEntities", new NBTTagByteArray(new byte[0]).getId()); // TODO: 0 is not correct

    for (int i = 0; i < tileEntitiesList.tagCount(); i++) {
      NBTTagCompound teTag = tileEntitiesList.getCompoundTagAt(i);
      int teX = teTag.getInteger("x");
      int teY = teTag.getInteger("y");
      int teZ = teTag.getInteger("z");

      tileEntities[teX + (teY * length + teZ) * width] = teTag;
    }

    // Create list of blocks to deploy
    for (int x = 0; x < width; x++) {
      for (int y = 0; y < height; y++) {
        for (int z = 0; z < length; z++) {
          int index = x + (y * length + z) * width;
          JumpBlock jb = new JumpBlock();

          jb.x = x;
          jb.y = y;
          jb.z = z;
          jb.block = Block.getBlockFromName(localBlocks.getStringTagAt(index));
          jb.blockMeta = (localMetadata[index]) & 0xFF;
          jb.blockNBT = tileEntities[index];

          if (jb.block != null) {

            if (WarpDriveConfig.LOGGING_BUILDING) {
              if (tileEntities[index] == null) {
                WarpDrive.logger.info(
                    "[ShipScanner] Adding block to deploy: "
                        + jb.block.getUnlocalizedName()
                        + " (no tile entity)");
              } else {
                WarpDrive.logger.info(
                    "[ShipScanner] Adding block to deploy: "
                        + jb.block.getUnlocalizedName()
                        + " with tile entity "
                        + tileEntities[index].getString("id"));
              }
            }

            blocksToDeploy[index] = jb;
          } else {
            jb = null;

            blocksToDeploy[index] = jb;
          }
        }
      }
    }

    setActive(true);
    reason.append("Ship deploying...");
    return 3;
  }
コード例 #23
0
 @Override
 public void loadNBTData(NBTTagCompound compound) {
   NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PROP_NAME);
 }
コード例 #24
0
ファイル: MapData.java プロジェクト: sidben/CartoCraft
  /** 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));
      }
    }
  }
コード例 #25
0
 @Override
 public void loadNBTData(NBTTagCompound compound) {
   NBTTagCompound properties = (NBTTagCompound) compound.getTag(tagName);
   this.unblocked = CalculatorRecipes.instance().readFromNBT(properties, "unblocked");
 }
コード例 #26
0
ファイル: MapData.java プロジェクト: KidMinecraft/LavaBukkit
  /** reads in data from the NBTTagCompound into this MapDataBase */
  public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
    NBTBase dimension = par1NBTTagCompound.getTag("dimension");

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

    // CraftBukkit start
    // LavaBukkit TODO: is it necessary to track UUID, since LB should ensure a stable
    // dimension/world mapping?
    {
      long least = par1NBTTagCompound.getLong("UUIDLeast");
      long most = par1NBTTagCompound.getLong("UUIDMost");

      if (least != 0L && most != 0L) {
        this.uniqueId = new UUID(most, least);

        CraftWorld world = (CraftWorld) server.getWorld(this.uniqueId);
        // Check if the stored world details are correct.
        if (world == null) {
          /* All Maps which do not have their valid world loaded are set to a dimension which hopefully won't be reached.
          This is to prevent them being corrupted with the wrong map data. */
          this.dimension = Integer.MAX_VALUE; // LavaBukkit - 127 -> Integer.MAX_VALUE
        } else {
          this.dimension = (byte) world.getHandle().provider.dimensionId;
        }
      }
    }
    // CraftBukkit end

    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 var2 = par1NBTTagCompound.getShort("width");
    short var3 = par1NBTTagCompound.getShort("height");

    if (var2 == 128 && var3 == 128) {
      this.colors = par1NBTTagCompound.getByteArray("colors");
    } else {
      byte[] var4 = par1NBTTagCompound.getByteArray("colors");
      this.colors = new byte[16384];
      int var5 = (128 - var2) / 2;
      int var6 = (128 - var3) / 2;

      for (int var7 = 0; var7 < var3; ++var7) {
        int var8 = var7 + var6;

        if (var8 >= 0 || var8 < 128) {
          for (int var9 = 0; var9 < var2; ++var9) {
            int var10 = var9 + var5;

            if (var10 >= 0 || var10 < 128) {
              this.colors[var10 + var8 * 128] = var4[var9 + var7 * var2];
            }
          }
        }
      }
    }
  }