コード例 #1
0
 @Override
 public void readCustomNBT(NBTTagCompound cmp) {
   super.readCustomNBT(cmp);
   if (cmp.hasKey(TAG_UUID_LEAST) && cmp.hasKey(TAG_UUID_MOST)) {
     golemConnected = new UUID(cmp.getLong(TAG_UUID_MOST), cmp.getLong(TAG_UUID_LEAST));
     // verifyGolem();
   }
 }
コード例 #2
0
  @Override
  public void readEntityFromNBT(NBTTagCompound nbt) {
    super.readEntityFromNBT(nbt);

    friendPlayerUUID =
        new UUID(nbt.getLong("friendPlayerUUID-msb"), nbt.getLong("friendPlayerUUID-lsb"));
    isImprisoned = nbt.getBoolean("isImprisoned");
  }
コード例 #3
0
 @Override
 public void readFromNBT(NBTTagCompound tag) {
   NBTTagList list = tag.getTagList("PlayerData", 10);
   for (int i = 0; i < list.tagCount(); i++) {
     NBTTagCompound playerData = list.getCompoundTagAt(i);
     UUID uuid = new UUID(playerData.getLong("UUIDMost"), playerData.getLong("UUIDLeast"));
     PlayerData data = new PlayerData(playerData);
     savedData.put(uuid, data);
   }
 }
コード例 #4
0
 @Override
 public void readEntityFromNBT(NBTTagCompound nbt) {
   super.readEntityFromNBT(nbt);
   spiderType = EnumSpiderType.byId(nbt.getInteger("spiderType"));
   abilityCounter = nbt.getInteger("abilityCounter");
   abilityThreshold = nbt.getInteger("abilityThreshold");
   killsUntilLevelUp = nbt.getInteger("killsUntilLevelUp");
   owner = new UUID(nbt.getLong("ownerMSB"), nbt.getLong("ownerLSB"));
   final NBTTagList tagList = nbt.getTagList("inventory", 10);
   inventory.loadInventoryFromNBT(tagList);
 }
コード例 #5
0
  @Override
  public void deserializeNBT(NBTTagCompound nbt) {

    this.stored = nbt.getLong("TeslaPower");

    if (nbt.hasKey("TeslaCapacity")) this.capacity = nbt.getLong("TeslaCapacity");

    if (nbt.hasKey("TeslaInput")) this.inputRate = nbt.getLong("TeslaInput");

    if (nbt.hasKey("TeslaOutput")) this.outputRate = nbt.getLong("TeslaOutput");

    if (this.stored > this.capacity) this.stored = this.capacity;
  }
コード例 #6
0
ファイル: DataHandler.java プロジェクト: ace5852/Miney
 @Override
 public void loadNBTData(NBTTagCompound compound) {
   NBTTagCompound tag = compound.getCompoundTag("Miney");
   mineyHand = tag.getDouble("Hand");
   mineyBank = tag.getDouble("Bank");
   lastInterest = tag.getLong("LastInterest");
 }
コード例 #7
0
  @SuppressWarnings("unchecked")
  @Override
  public void readFromNBT(NBTTagCompound nbt) {
    super.readFromNBT(nbt);

    this.spawned = nbt.getBoolean("spawned");
    this.playerInRange = this.lastPlayerInRange = nbt.getBoolean("playerInRange");
    this.isBossDefeated = nbt.getBoolean("defeated");
    this.playerCheated = nbt.getBoolean("playerCheated");

    try {
      this.bossClass = (Class<E>) Class.forName(nbt.getString("bossClass"));
    } catch (Exception e) {
      e.printStackTrace();
    }

    this.roomCoords = new Vector3();
    this.roomCoords.x = nbt.getDouble("roomCoordsX");
    this.roomCoords.y = nbt.getDouble("roomCoordsY");
    this.roomCoords.z = nbt.getDouble("roomCoordsZ");
    this.roomSize = new Vector3();
    this.roomSize.x = nbt.getDouble("roomSizeX");
    this.roomSize.y = nbt.getDouble("roomSizeY");
    this.roomSize.z = nbt.getDouble("roomSizeZ");

    if (nbt.hasKey("lastKillTime")) {
      this.lastKillTime = nbt.getLong("lastKillTime");
    }
  }
コード例 #8
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")));
  }
コード例 #9
0
  @Override
  public void readTileFromNBT(NBTTagCompound nbt) {
    colRgb = nbt.getByteArray("col");
    cachedCoords = Pos.at(nbt.getLong("loc"));
    data.readFromNBT(nbt);

    if (colRgb.length == 0) shouldBeDestroyedSilently = true;
  }
コード例 #10
0
 public void readFromNBT(NBTTagCompound nbt) {
   birthday.readFromNBT(nbt);
   stamina = nbt.getDouble("Stamina");
   fatigue = nbt.getDouble("Fatigue");
   gold = nbt.getLong("Gold");
   staminaMax = nbt.getDouble("StaminaMax");
   fatigueMin = nbt.getDouble("FatigueMin");
 }
コード例 #11
0
  @Override
  protected void readSyncTag(NBTTagCompound NBT) {
    super.readSyncTag(NBT);

    tank.readFromNBT(NBT);

    energy = NBT.getLong("e");
    temperature = NBT.getInteger("temp");
  }
コード例 #12
0
  /* === BUILD === */
  private void onDebugBuild(NBTTagCompound nbt, EntityPlayer player, Pos pos) {
    if (pos == null) nbt.removeTag("pos");
    else if (!nbt.hasKey("pos")) nbt.setLong("pos", pos.toLong());
    else if (player.isSneaking()) {
      ItemStack is = player.inventory.mainInventory[7];
      Block block =
          is == null || !(is.getItem() instanceof ItemBlock)
              ? Blocks.air
              : ((ItemBlock) is.getItem()).field_150939_a;
      int meta = block == Blocks.air ? 0 : is.getItemDamage();

      Pos.forEachBlock(
          pos,
          Pos.at(nbt.getLong("pos")),
          blockPos -> blockPos.setBlock(player.worldObj, block, meta));
      nbt.removeTag("pos");
    } else {
      final List<Pair<Block, Integer>> blocks = new ArrayList<>();

      Arrays.stream(player.inventory.mainInventory)
          .skip(9)
          .filter(is -> is != null && is.getItem() instanceof ItemBlock)
          .forEach(
              is -> {
                Pair<Block, Integer> data =
                    Pair.of(((ItemBlock) is.getItem()).field_150939_a, is.getItemDamage());
                for (int amt = 0; amt < is.stackSize; amt++) blocks.add(data);
              });

      final int blockCount = blocks.size();
      if (blockCount == 0) return;

      Pos.forEachBlock(
          pos,
          Pos.at(nbt.getLong("pos")),
          blockPos -> {
            Pair<Block, Integer> selectedBlock =
                blocks.get(player.worldObj.rand.nextInt(blockCount));
            blockPos.setBlock(player.worldObj, selectedBlock.getLeft(), selectedBlock.getRight());
          });

      nbt.removeTag("pos");
    }
  }
コード例 #13
0
  @Override
  protected void readSyncTag(NBTTagCompound NBT) {
    super.readSyncTag(NBT);

    tank.readFromNBT(NBT);

    omega = NBT.getInteger("speed");
    torque = NBT.getInteger("trq");
    power = NBT.getLong("pwr");
  }
コード例 #14
0
  public void readExtraData(NBTTagCompound nbttagcompound) {
    hasPlayedBefore = true;
    if (nbttagcompound.hasKey("bukkit")) {
      NBTTagCompound data = nbttagcompound.getCompoundTag("bukkit");

      if (data.hasKey("firstPlayed")) {
        firstPlayed = data.getLong("firstPlayed");
        lastPlayed = data.getLong("lastPlayed");
      }

      if (data.hasKey("newExp")) {
        EntityPlayerMP handle = getHandle();
        handle.experienceValue = data.getInteger("newExp");
        handle.experienceTotal = data.getInteger("newTotalExp");
        handle.experienceLevel = data.getInteger("newLevel");
        // handle.exp = data.getInteger("expToDrop");
        // handle.exp = data.getBoolean("keepLevel");
      }
    }
  }
コード例 #15
0
ファイル: Counter.java プロジェクト: Pyeroh/CountCraft
  public void readFromNBT(NBTTagCompound data) {
    byte[] byteArray = data.getByteArray("count");
    ByteArrayInputStream bais = new ByteArrayInputStream(byteArray);
    try {
      ObjectInputStream ois = new ObjectInputStream(bais);
      count = (HashMap<String, Integer>) ois.readObject();
    } catch (IOException e) {
      e.printStackTrace();
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    }
    totalCounted = data.getLong("total");
    active = data.getBoolean(ACTIVE_TAG);
    ticksRun = data.getLong("ticksrun");

    // Clear invalid items from possible updates

    List<String> invalid = new ArrayList<String>();
    Set<Entry<String, Integer>> entrySet = count.entrySet();
    for (Entry<String, Integer> entry : entrySet) {

      String[] split = entry.getKey().split(":");
      String[] split2 = split[1].split("-");

      if (split[0].equals(IStack.itemID)) {
        Integer intId = Integer.parseInt(split2[0]);
        if (Item.itemsList[intId] == null) {
          invalid.add(entry.getKey());
        }
      } else if (split[0].equals(IStack.fluidID)) {
        Integer intId = Integer.parseInt(split2[0]);
        if (FluidRegistry.getFluid(intId) == null) invalid.add(entry.getKey());
      }
    }

    for (String key : invalid) count.remove(key);
  }
コード例 #16
0
  public long getLastPlayed() {
    Player player = getPlayer();
    if (player != null) return player.getLastPlayed();

    NBTTagCompound data = getCraftData();

    if (data != null) {
      if (data.hasKey("lastPlayed")) {
        return data.getLong("lastPlayed");
      } else {
        File file = getDataFile();
        return file.lastModified();
      }
    } else {
      return 0;
    }
  }
コード例 #17
0
  @Override
  public void readFromNBT(NBTTagCompound nbt) {
    super.readFromNBT(nbt);

    NBTTagList nbttaglist = nbt.getTagList("Items");
    inventory = new ItemStack[getSizeInventory()];
    for (int i = 0; i < nbttaglist.tagCount(); i++) {
      NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i);
      byte byte0 = nbttagcompound1.getByte("Slot");
      if (byte0 >= 0 && byte0 < inventory.length) {
        inventory[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
      }
    }
    burnStart = nbt.getLong("burnStart");
    logsForBurn = nbt.getInteger("logsForBurn");
    hasRack = nbt.getBoolean("hasRack");
  }
コード例 #18
0
  /** (abstract) Protected helper method to read subclass entity data from NBT. */
  @Override
  public void readEntityFromNBT(NBTTagCompound nbt) {
    super.readEntityFromNBT(nbt);
    sex = nbt.getInteger("Sex");
    size_mod = nbt.getFloat("Size Modifier");

    strength_mod = nbt.getFloat("Strength Modifier");
    aggression_mod = nbt.getFloat("Aggression Modifier");
    obedience_mod = nbt.getFloat("Obedience Modifier");
    colour_mod = nbt.getFloat("Colour Modifier");
    climate_mod = nbt.getFloat("Climate Adaptation Modifier");
    hard_mod = nbt.getFloat("Hardiness Modifier");

    hunger = nbt.getInteger("Hunger");
    mateSizeMod = nbt.getFloat("MateSize");
    this.dataWatcher.updateObject(15, nbt.getInteger("Age"));
    nextEgg = nbt.getLong("nextEgg");
  }
コード例 #19
0
  /** Reads the state of the emitter from an NBT tag */
  @Override
  public void readFromNBT(final NBTTagCompound data) {
    // Call super
    super.readFromNBT(data);

    // Read the filter
    this.filterAspect =
        Aspect.aspects.get(data.getString(AEPartEssentiaLevelEmitter.ASPECT_FILTER_NBT_KEY));

    // Read the redstone mode
    this.redstoneMode =
        RedstoneMode.values()[data.getInteger(AEPartEssentiaLevelEmitter.REDSTONE_MODE_NBT_KEY)];

    // Read the wanted amount
    this.wantedAmount = data.getLong(AEPartEssentiaLevelEmitter.WANTED_AMOUNT_NBT_KEY);

    // Read if we are emitting
    this.isEmitting = data.getBoolean(AEPartEssentiaLevelEmitter.IS_EMITTING_NBT_KEY);
  }
コード例 #20
0
  public static ChunkLoader.AnvilConverterData load(NBTTagCompound nbt) {
    int var1 = nbt.getInteger("xPos");
    int var2 = nbt.getInteger("zPos");
    ChunkLoader.AnvilConverterData var3 = new ChunkLoader.AnvilConverterData(var1, var2);
    var3.blocks = nbt.getByteArray("Blocks");
    var3.data = new NibbleArrayReader(nbt.getByteArray("Data"), 7);
    var3.skyLight = new NibbleArrayReader(nbt.getByteArray("SkyLight"), 7);
    var3.blockLight = new NibbleArrayReader(nbt.getByteArray("BlockLight"), 7);
    var3.heightmap = nbt.getByteArray("HeightMap");
    var3.terrainPopulated = nbt.getBoolean("TerrainPopulated");
    var3.entities = nbt.getTagList("Entities", 10);
    var3.tileEntities = nbt.getTagList("TileEntities", 10);
    var3.tileTicks = nbt.getTagList("TileTicks", 10);

    try {
      var3.lastUpdated = nbt.getLong("LastUpdate");
    } catch (ClassCastException var5) {
      var3.lastUpdated = (long) nbt.getInteger("LastUpdate");
    }

    return var3;
  }
コード例 #21
0
  /* === CLEAR === */
  private void onDebugClear(NBTTagCompound nbt, EntityPlayer player, Pos pos) {
    if (pos == null) nbt.removeTag("pos");
    else if (!nbt.hasKey("pos")) nbt.setLong("pos", pos.toLong());
    else {
      final List<Block> blocks =
          Arrays.stream(player.inventory.mainInventory)
              .filter(is -> is != null && is.getItem() instanceof ItemBlock)
              .map(is -> ((ItemBlock) is.getItem()).field_150939_a)
              .collect(Collectors.toList());

      Pos.forEachBlock(
          pos,
          Pos.at(nbt.getLong("pos")),
          blockPos -> {
            if (blocks.contains(blockPos.getBlock(player.worldObj)))
              blockPos.setAir(player.worldObj);
            else if (player.isSneaking() && blockPos.getMaterial(player.worldObj).isLiquid())
              blockPos.setAir(player.worldObj);
          });

      nbt.removeTag("pos");
    }
  }
コード例 #22
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];
            }
          }
        }
      }
    }
  }
コード例 #23
0
 public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
   super.readEntityFromNBT(par1NBTTagCompound);
   time = par1NBTTagCompound.getLong("time");
   invul = par1NBTTagCompound.getBoolean("inv");
   estado = par1NBTTagCompound.getInteger("estado");
 }
コード例 #24
0
ファイル: DimensionInformation.java プロジェクト: ntf/RFTools
  private void setupFromNBT(NBTTagCompound tagCompound) {
    terrainType = TerrainType.values()[tagCompound.getInteger("terrain")];
    featureTypes = toEnumSet(getIntArraySafe(tagCompound, "features"), FeatureType.values());
    structureTypes = toEnumSet(getIntArraySafe(tagCompound, "structures"), StructureType.values());
    effectTypes = toEnumSet(getIntArraySafe(tagCompound, "effects"), EffectType.values());

    biomes.clear();
    for (int a : getIntArraySafe(tagCompound, "biomes")) {
      BiomeGenBase biome = BiomeGenBase.getBiome(a);
      if (biome != null) {
        biomes.add(biome);
      } else {
        // Protect against deleted biomes (i.e. a mod with biomes gets removed and this dimension
        // still uses it).
        // We will pick a replacement biome here.
        biomes.add(BiomeGenBase.plains);
      }
    }
    if (tagCompound.hasKey("controller")) {
      controllerType = ControllerType.values()[tagCompound.getInteger("controller")];
    } else {
      // Support for old type.
      if (biomes.isEmpty()) {
        controllerType = ControllerType.CONTROLLER_DEFAULT;
      } else {
        controllerType = ControllerType.CONTROLLER_SINGLE;
      }
    }

    digitString = tagCompound.getString("digits");

    forcedDimensionSeed = tagCompound.getLong("forcedSeed");
    baseSeed = tagCompound.getLong("baseSeed");
    worldVersion = tagCompound.getInteger("worldVersion");

    baseBlockForTerrain = getBlockMeta(tagCompound, "baseBlock");
    tendrilBlock = getBlockMeta(tagCompound, "tendrilBlock");
    canyonBlock = getBlockMeta(tagCompound, "canyonBlock");
    fluidForTerrain =
        (Block) Block.blockRegistry.getObjectById(tagCompound.getInteger("fluidBlock"));

    hugeLiquidSphereFluids = readFluidsFromNBT(tagCompound, "hugeLiquidSphereFluids");
    hugeLiquidSphereBlocks = readBlockArrayFromNBT(tagCompound, "hugeLiquidSphereBlocks");

    // Support for the old format with only one liquid block.
    Block oldLiquidSphereFluid =
        (Block) Block.blockRegistry.getObjectById(tagCompound.getInteger("liquidSphereFluid"));
    liquidSphereFluids = readFluidsFromNBT(tagCompound, "liquidSphereFluids");
    if (liquidSphereFluids.length == 0) {
      liquidSphereFluids = new Block[] {oldLiquidSphereFluid};
    }

    // Support for the old format with only one sphere block.
    BlockMeta oldLiquidSphereBlock = getBlockMeta(tagCompound, "liquidSphereBlock");
    liquidSphereBlocks = readBlockArrayFromNBT(tagCompound, "liquidSphereBlocks");
    if (liquidSphereBlocks.length == 0) {
      liquidSphereBlocks = new BlockMeta[] {oldLiquidSphereBlock};
    }

    pyramidBlocks = readBlockArrayFromNBT(tagCompound, "pyramidBlocks");
    if (pyramidBlocks.length == 0) {
      pyramidBlocks = new BlockMeta[] {BlockMeta.STONE};
    }

    // Support for the old format with only one sphere block.
    BlockMeta oldSphereBlock = getBlockMeta(tagCompound, "sphereBlock");
    sphereBlocks = readBlockArrayFromNBT(tagCompound, "sphereBlocks");
    if (sphereBlocks.length == 0) {
      sphereBlocks = new BlockMeta[] {oldSphereBlock};
    }

    hugeSphereBlocks = readBlockArrayFromNBT(tagCompound, "hugeSphereBlocks");

    extraOregen = readBlockArrayFromNBT(tagCompound, "extraOregen");
    fluidsForLakes = readFluidsFromNBT(tagCompound, "lakeFluids");

    peaceful = tagCompound.getBoolean("peaceful");
    noanimals = tagCompound.getBoolean("noanimals");
    shelter = tagCompound.getBoolean("shelter");
    respawnHere = tagCompound.getBoolean("respawnHere");
    if (tagCompound.hasKey("celestialAngle")) {
      celestialAngle = tagCompound.getFloat("celestialAngle");
    } else {
      celestialAngle = null;
    }
    if (tagCompound.hasKey("timeSpeed")) {
      timeSpeed = tagCompound.getFloat("timeSpeed");
    } else {
      timeSpeed = null;
    }
    probeCounter = tagCompound.getInteger("probes");
    actualRfCost = tagCompound.getInteger("actualCost");

    skyDescriptor = new SkyDescriptor.Builder().fromNBT(tagCompound).build();
    calculateCelestialBodyDescriptors();

    patreon1 = tagCompound.getLong("patreon1");

    weatherDescriptor = new WeatherDescriptor.Builder().fromNBT(tagCompound).build();

    extraMobs.clear();
    NBTTagList list = tagCompound.getTagList("mobs", Constants.NBT.TAG_COMPOUND);
    for (int i = 0; i < list.tagCount(); i++) {
      NBTTagCompound tc = list.getCompoundTagAt(i);
      String className = tc.getString("class");
      int chance = tc.getInteger("chance");
      int minGroup = tc.getInteger("minGroup");
      int maxGroup = tc.getInteger("maxGroup");
      int maxLoaded = tc.getInteger("maxLoaded");
      Class<? extends EntityLiving> c = null;
      try {
        c = (Class<? extends EntityLiving>) Class.forName(className);
      } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
      }
      MobDescriptor mob = new MobDescriptor(null, c, chance, minGroup, maxGroup, maxLoaded);
      extraMobs.add(mob);
    }

    String ds = tagCompound.getString("dimensionTypes");
    dimensionTypes = StringUtils.split(ds, ",");
    if (dimensionTypes == null) {
      dimensionTypes = new String[0];
    }
  }