@SuppressWarnings("unchecked") public void merge(NBTTagCompound nbt, NBTTagCompound other) { Iterator<String> iterator = other.func_150296_c().iterator(); while (iterator.hasNext()) { String s = iterator.next(); NBTBase nbtbase = other.getTag(s); if (nbtbase.getId() == 10) { if (nbt.hasKey(s, 10)) { NBTTagCompound nbttagcompound1 = nbt.getCompoundTag(s); merge(nbttagcompound1, (NBTTagCompound) nbtbase); } else nbt.setTag(s, nbtbase.copy()); } else nbt.setTag(s, nbtbase.copy()); } }
public EntityFireworkRocket(World worldIn, double x, double y, double z, ItemStack givenItem) { super(worldIn); this.fireworkAge = 0; this.setSize(0.25F, 0.25F); this.setPosition(x, y, z); int i = 1; if (givenItem != null && givenItem.hasTagCompound()) { this.dataWatcher.updateObject(8, givenItem); NBTTagCompound nbttagcompound = givenItem.getTagCompound(); NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("Fireworks"); if (nbttagcompound1 != null) { i += nbttagcompound1.getByte("Flight"); } } this.motionX = this.rand.nextGaussian() * 0.001D; this.motionZ = this.rand.nextGaussian() * 0.001D; this.motionY = 0.05D; this.lifetime = 10 * i + this.rand.nextInt(6) + this.rand.nextInt(7); }
public NBTTagCompound writeStructureComponentsToNBT(int chunkX, int chunkZ) { if (MapGenStructureIO.getStructureStartName(this) == null) // This is just a more friendly error instead of the 'Null String' below { throw new RuntimeException("StructureStart \"" + this.getClass().getName() + "\" missing ID Mapping, Modder see MapGenStructureIO"); } NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setString("id", MapGenStructureIO.getStructureStartName(this)); nbttagcompound.setInteger("ChunkX", chunkX); nbttagcompound.setInteger("ChunkZ", chunkZ); nbttagcompound.setTag("BB", this.boundingBox.toNBTTagIntArray()); NBTTagList nbttaglist = new NBTTagList(); for (StructureComponent structurecomponent : this.components) { nbttaglist.appendTag(structurecomponent.createStructureBaseNBT()); } nbttagcompound.setTag("Children", nbttaglist); this.writeToNBT(nbttagcompound); return nbttagcompound; }
public void load(NBTTagCompound nbt) { byte[] regs = nbt.getByteArray("regs"); addr1 = regs[0]; addr2 = regs[1]; sectorSize = regs[2]; numSectors1 = regs[3]; numSectors2 = regs[4]; sector1 = regs[5]; sector2 = regs[6]; if(nbt.hasKey("mappedDrive")) mappedDrive = nbt.getString("mappedDrive"); else mappedDrive = null; if(nbt.hasKey("sectorReadPos")) sectorReadPos = nbt.getInteger("sectorReadPos"); else sectorReadPos = -1; if(nbt.hasKey("sectorWritePos")) sectorWritePos = nbt.getInteger("sectorWritePos"); else sectorWritePos = -1; if(nbt.hasKey("sectorBuffer")) sectorBuffer = nbt.getByteArray("sectorBuffer"); else sectorBuffer = null; }
/** * Load inventory data from NBT tag * @param inventory Target inventory * @param tag tag to load * @param seed Loading seed */ private static void load(IInventory inventory, NBTTagCompound tag, long seed) { if (tag == null || !Configurator.NATIVE_LOOT) { return; } Random random = new Random(seed); NBTTagList items = tag.getTagList("Items", Constants.NBT.TAG_COMPOUND); for (int i = 0; i < items.tagCount() && i < inventory.getSizeInventory(); ++i) { NBTTagCompound stackTag = items.getCompoundTagAt(i); String itemName = stackTag.getString("id").replaceAll(".*:", ""); itemName = itemName.isEmpty() ? String.valueOf(stackTag.getShort("id")) : itemName; Pattern iPattern = Pattern.compile(Pattern.quote(itemName), Pattern.CASE_INSENSITIVE); UItem item = Utils.select(UItems.items.select(iPattern), random.nextLong()); byte count = items.getCompoundTagAt(i).getByte("Count"); int damage = items.getCompoundTagAt(i).getShort("Damage"); int slot = stackTag.hasKey("Slot", Constants.NBT.TAG_BYTE) ? stackTag.getByte("Slot") : i; slot = (slot < 0 || slot >= inventory.getSizeInventory()) ? i : slot; if (item != null && count > 0 && UItems.getPossibleMeta(item).contains(damage)) { inventory.setInventorySlotContents(slot, new UItemStack(item, count, damage).getItemStack()); } } }
@Override public void handleData(NBTTagCompound data) { PacketType type = PacketType.registry.get(data.getShort("requestID")); NBTTagCompound dataTag = VoidNetwork.handlers.get(data.getShort("requestID")).handleRequest(data.getString("requester")); if (dataTag == null) { return; } if (MC.getSide() == Side.SERVER) { EntityPlayerMP to = Players.getPlayerByUsername(data.getString("requester")); VoidNetwork.sendDataToClient(type, dataTag, to); } else { VoidNetwork.sendDataToServer(type, dataTag); } }
protected NBTTagList objectivesToNbt() { NBTTagList nbttaglist = new NBTTagList(); for (ScoreObjective scoreobjective : this.theScoreboard.getScoreObjectives()) { if (scoreobjective.getCriteria() != null) { NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setString("Name", scoreobjective.getName()); nbttagcompound.setString("CriteriaName", scoreobjective.getCriteria().getName()); nbttagcompound.setString("DisplayName", scoreobjective.getDisplayName()); nbttagcompound.setString("RenderType", scoreobjective.getRenderType().getRenderType()); nbttaglist.appendTag(nbttagcompound); } } return nbttaglist; }
private ItemStack storeTEInStack(ItemStack stack, TileEntity te) { NBTTagCompound nbttagcompound = te.writeToNBT(new NBTTagCompound()); if (stack.getItem() == Items.SKULL && nbttagcompound.hasKey("Owner")) { NBTTagCompound nbttagcompound2 = nbttagcompound.getCompoundTag("Owner"); NBTTagCompound nbttagcompound3 = new NBTTagCompound(); nbttagcompound3.setTag("SkullOwner", nbttagcompound2); stack.setTagCompound(nbttagcompound3); return stack; } else { stack.setTagInfo("BlockEntityTag", nbttagcompound); NBTTagCompound nbttagcompound1 = new NBTTagCompound(); NBTTagList nbttaglist = new NBTTagList(); nbttaglist.appendTag(new NBTTagString("(+NBT)")); nbttagcompound1.setTag("Lore", nbttaglist); stack.setTagInfo("display", nbttagcompound1); return stack; } }
public String describeContents(ItemStack bundleOrPattern, int depth) { NBTTagCompound nbt = bundleOrPattern.getTagCompound(); if (nbt == null || !nbt.hasKey("Items")) { return "Combines multiple items for automation. See Bundler/Unbundler"; } ArrayList<String> itemStrings = new ArrayList<String>(); String prefix = ""; for (int i = 0; i < depth; ++i) prefix += " "; for (ItemStack stack : getItemsFromBundle(bundleOrPattern)) { Item item = stack.getItem(); itemStrings.add(prefix + stack.stackSize+" "+item.getItemStackDisplayName(stack)); if (item == RezolveMod.BUNDLE_ITEM) { itemStrings.add(describeContents(stack, depth + 1)); } } return String.join("\n", itemStrings); }
private WeightedRandomMinecart(NBTTagCompound tagCompound, String type, int weight) { super(weight); if (type.equals("Minecart")) { if (tagCompound != null) { type = EntityMinecart.EnumMinecartType.byNetworkID(tagCompound.getInteger("Type")).getName(); } else { type = "MinecartRideable"; } } this.nbtData = tagCompound; this.entityType = type; }
/** * Saves the given MapDataBase to disk. */ private void saveData(WorldSavedData p_75747_1_) { if (this.saveHandler != null) { try { File file1 = this.saveHandler.getMapFileFromName(p_75747_1_.mapName); if (file1 != null) { NBTTagCompound nbttagcompound = new NBTTagCompound(); p_75747_1_.writeToNBT(nbttagcompound); NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setTag("data", nbttagcompound); FileOutputStream fileoutputstream = new FileOutputStream(file1); CompressedStreamTools.writeCompressed(nbttagcompound1, fileoutputstream); fileoutputstream.close(); } } catch (Exception exception) { exception.printStackTrace(); } } }
/** * (abstract) Protected helper method to read subclass entity data from NBT. */ public void readEntityFromNBT(NBTTagCompound tagCompund) { super.readEntityFromNBT(tagCompund); if (tagCompund.hasKey("Potion", 10)) { this.potionDamage = ItemStack.loadItemStackFromNBT(tagCompund.getCompoundTag("Potion")); } else { this.setPotionDamage(tagCompund.getInteger("potionValue")); } if (this.potionDamage == null) { this.setDead(); } }
public static SoundType getHighestSoundType(ItemStack stack){ double max = 0; SoundType type = null; NBTTagCompound itemTag = ItemUtil.getOrCreateTag(stack); if (itemTag.hasKey(SOUNDS_TAG)) { NBTTagCompound container = stack.getTagCompound().getCompoundTag(SOUNDS_TAG); for (SoundType t : SoundType.getSoundTypes()){ if (container.hasKey(t.getTag())){ if (container.getDouble(t.getTag()) > max){ max = container.getDouble(t.getTag()); type = t; } } } } return type; }
/** * (abstract) Protected helper method to write subclass entity data to NBT. */ public void writeEntityToNBT(NBTTagCompound compound) { super.writeEntityToNBT(compound); IBlockState iblockstate = this.getHeldBlockState(); if (iblockstate != null) { compound.setShort("carried", (short)Block.getIdFromBlock(iblockstate.getBlock())); compound.setShort("carriedData", (short)iblockstate.getBlock().getMetaFromState(iblockstate)); } }
protected HoverEvent getHoverEvent() { NBTTagCompound nbttagcompound = new NBTTagCompound(); String s = EntityList.getEntityString(this); nbttagcompound.setString("id", this.getUniqueID().toString()); if (s != null) { nbttagcompound.setString("type", s); } nbttagcompound.setString("name", this.getName()); return new HoverEvent(HoverEvent.Action.SHOW_ENTITY, new ChatComponentText(nbttagcompound.toString())); }
@Override public boolean writeToNBTAtomically(NBTTagCompound compound) { if (m_realPlayer == null) { return super.writeToNBTAtomically(compound); } else { return m_realPlayer.writeToNBTAtomically(compound); } }
/** * Allows for a specialized description packet to be created. This is often used to sync tile entity data from the * server to the client easily. For example this is used by signs to synchronise the text to be displayed. */ public Packet getDescriptionPacket() { NBTTagCompound nbttagcompound = new NBTTagCompound(); this.writeToNBT(nbttagcompound); return new S35PacketUpdateTileEntity(this.pos, 3, nbttagcompound); }
/** * write data to NBTTagCompound from this MapDataBase, similar to Entities and TileEntities */ public void writeToNBT(NBTTagCompound nbt) { nbt.setByte("dimension", this.dimension); nbt.setInteger("xCenter", this.xCenter); nbt.setInteger("zCenter", this.zCenter); nbt.setByte("scale", this.scale); nbt.setShort("width", (short)128); nbt.setShort("height", (short)128); nbt.setByteArray("colors", this.colors); }
/** * allows items to add custom lines of information to the mouseover description */ @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) { if (stack.hasTagCompound()) { NBTTagCompound nbttagcompound = stack.getTagCompound().getCompoundTag("Fireworks"); if (nbttagcompound != null) { if (nbttagcompound.hasKey("Flight", 99)) { tooltip.add(I18n.translateToLocal("item.fireworks.flight") + " " + nbttagcompound.getByte("Flight")); } NBTTagList nbttaglist = nbttagcompound.getTagList("Explosions", 10); if (nbttaglist != null && !nbttaglist.hasNoTags()) { for (int i = 0; i < nbttaglist.tagCount(); ++i) { NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); List<String> list = Lists.<String>newArrayList(); ItemFireworkCharge.addExplosionInfo(nbttagcompound1, list); if (!list.isEmpty()) { for (int j = 1; j < ((List)list).size(); ++j) { list.set(j, " " + (String)list.get(j)); } tooltip.addAll(list); } } } } } }
/** * (abstract) Protected helper method to read subclass entity data from NBT. */ public void readEntityFromNBT(NBTTagCompound compound) { super.readEntityFromNBT(compound); this.setRabbitType(compound.getInteger("RabbitType")); this.carrotTicks = compound.getInteger("MoreCarrotTicks"); }
@Override public void readFromNBT(NBTTagCompound tag) { super.readFromNBT(tag); if (tag.hasKey("instability", 6)) { this.instability = tag.getDouble("instability"); } if (tag.hasKey("size", 6)) { this.size = tag.getDouble("size"); } }
/** * Write a custom potion effect to a potion item's NBT data. */ public NBTTagCompound writeCustomPotionEffectToNBT(NBTTagCompound nbt) { nbt.setByte("Id", (byte)this.getPotionID()); nbt.setByte("Amplifier", (byte)this.getAmplifier()); nbt.setInteger("Duration", this.getDuration()); nbt.setBoolean("Ambient", this.getIsAmbient()); nbt.setBoolean("ShowParticles", this.getIsShowParticles()); return nbt; }
public void readFromNBT(NBTTagCompound tag) { if (!meeCreep.getWorld().isRemote) { ServerActionManager manager = ServerActionManager.getManager(); int actionId = meeCreep.getActionId(); if (actionId != 0) { ActionOptions options = manager.getOptions(actionId); if (options != null && options.getTask() != null) { getHelper(options).readFromNBT(tag); } } } }
/** * Creates a new NBTTagCompound for the world, with the given NBTTag as the "Player" */ public NBTTagCompound cloneNBTCompound(@Nullable NBTTagCompound nbt) { if (nbt == null) { nbt = this.playerTag; } NBTTagCompound nbttagcompound = new NBTTagCompound(); this.updateTagCompound(nbttagcompound, nbt); return nbttagcompound; }
@Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); if (compound.hasKey("R")) r = compound.getInteger("R"); if (compound.hasKey("G")) g = compound.getInteger("G"); if (compound.hasKey("B")) b = compound.getInteger("B"); }
@Override public void writeToPacket(NBTTagCompound tag) { super.writeToPacket(tag); tag.setInteger("floors", floors.length); for (ElevatorButton floor : floors) { NBTTagCompound buttonTag = new NBTTagCompound(); floor.writeToNBT(buttonTag); tag.setTag("floor" + floor.floorNumber, buttonTag); } }
/** * (abstract) Protected helper method to read subclass entity data from NBT. */ protected void readEntityFromNBT(NBTTagCompound tagCompund) { super.readEntityFromNBT(tagCompund); this.commandBlockLogic.readDataFromNBT(tagCompund); this.getDataWatcher().updateObject(23, this.getCommandBlockLogic().getCommand()); this.getDataWatcher().updateObject(24, IChatComponent.Serializer.componentToJson(this.getCommandBlockLogic().getLastOutput())); }
/** * Return the defined game rules as NBT. */ public NBTTagCompound writeToNBT() { NBTTagCompound nbttagcompound = new NBTTagCompound(); for (String s : this.theGameRules.keySet()) { GameRules.Value gamerules$value = (GameRules.Value)this.theGameRules.get(s); nbttagcompound.setString(s, gamerules$value.getString()); } return nbttagcompound; }
/** * (abstract) Protected helper method to read subclass entity data from NBT. */ public void readEntityFromNBT(NBTTagCompound tagCompund) { this.xTile = tagCompund.getShort("xTile"); this.yTile = tagCompund.getShort("yTile"); this.zTile = tagCompund.getShort("zTile"); if (tagCompund.hasKey("inTile", 8)) { this.inTile = Block.getBlockFromName(tagCompund.getString("inTile")); } else { this.inTile = Block.getBlockById(tagCompund.getByte("inTile") & 255); } this.throwableShake = tagCompund.getByte("shake") & 255; this.inGround = tagCompund.getByte("inGround") == 1; this.thrower = null; this.throwerName = tagCompund.getString("ownerName"); if (this.throwerName != null && this.throwerName.length() == 0) { this.throwerName = null; } this.thrower = this.getThrower(); }
@Override public void onCollideWithPlayer(EntityPlayer player) { if (!this.worldObj.isRemote) { NBTTagCompound nbt = new NBTTagCompound(); this.writeToNBT(nbt); boolean inground = nbt.hasKey("inGround") && nbt.getByte("inGround") == 1; if(inground) { boolean flag = this.canBePickedUp == 1 || (this.canBePickedUp == 2 && player.capabilities.isCreativeMode); EntityItem ei = new EntityItem(this.worldObj, this.posX, this.posY, this.posZ, new ItemStack(this.pickupItem, 1, 0)); if (this.canBePickedUp == 1) { EntityItemPickupEvent event = new EntityItemPickupEvent(player, ei); if (MinecraftForge.EVENT_BUS.post(event)) return; } ItemStack itemstack = ei.getEntityItem(); if (itemstack.stackSize <= 0) flag = true; else if (this.canBePickedUp == 1 && !player.inventory.addItemStackToInventory(itemstack)) flag = false; if (flag) { this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); player.onItemPickup(this, 1); this.setDead(); } } } }
/** * Allows for a specialized description packet to be created. This is often used to sync tile entity data from the * server to the client easily. For example this is used by signs to synchronise the text to be displayed. */ public Packet getDescriptionPacket() { NBTTagCompound nbttagcompound = new NBTTagCompound(); this.writeToNBT(nbttagcompound); nbttagcompound.removeTag("Item"); nbttagcompound.setInteger("Item", Item.getIdFromItem(this.flowerPotItem)); return new S35PacketUpdateTileEntity(this.pos, 5, nbttagcompound); }
/** * Saves the given World Info with the given NBTTagCompound as the Player. */ public void saveWorldInfoWithPlayer(WorldInfo worldInformation, NBTTagCompound tagCompound) { NBTTagCompound nbttagcompound = worldInformation.cloneNBTCompound(tagCompound); NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setTag("Data", nbttagcompound); try { File file1 = new File(this.worldDirectory, "level.dat_new"); File file2 = new File(this.worldDirectory, "level.dat_old"); File file3 = new File(this.worldDirectory, "level.dat"); CompressedStreamTools.writeCompressed(nbttagcompound1, new FileOutputStream(file1)); if (file2.exists()) { file2.delete(); } file3.renameTo(file2); if (file3.exists()) { file3.delete(); } file1.renameTo(file3); if (file1.exists()) { file1.delete(); } } catch (Exception exception) { exception.printStackTrace(); } }
@Override public void readFromNBT(NBTTagCompound nbtTagCompound) { super.readFromNBT(nbtTagCompound); burnTime = nbtTagCompound.getInteger("burnTime"); maxBurnTime = nbtTagCompound.getInteger("maxBurn"); redstoneMode = nbtTagCompound.getInteger("redstoneMode"); inventory = new AirCompressorHandler(); inventory.deserializeNBT(nbtTagCompound.getCompoundTag("Items")); }
public NBTTagCompound fixTagCompound(NBTTagCompound compound) { if ("Sign".equals(compound.getString("id"))) { this.updateLine(compound, "Text1"); this.updateLine(compound, "Text2"); this.updateLine(compound, "Text3"); this.updateLine(compound, "Text4"); } return compound; }
@Override public void makeFireworks(double x, double y, double z, double motionX, double motionY, double motionZ, NBTTagCompound compund) { if (m_proxyWorld != null && Util.isPrefixInCallStack(m_modPrefix)) { m_proxyWorld.makeFireworks(x, y, z, motionX, motionY, motionZ, compund); } else if (m_realWorld != null) { m_realWorld.makeFireworks(x, y, z, motionX, motionY, motionZ, compund); } else { super.makeFireworks(x, y, z, motionX, motionY, motionZ, compund); } }
/** * (abstract) Protected helper method to write subclass entity data to NBT. */ protected void writeEntityToNBT(NBTTagCompound tagCompound) { super.writeEntityToNBT(tagCompound); tagCompound.setDouble("PushX", this.pushX); tagCompound.setDouble("PushZ", this.pushZ); tagCompound.setShort("Fuel", (short)this.fuel); }
public static void func_181020_a(NBTTagCompound p_181020_0_, int p_181020_1_, NBTTagList p_181020_2_) { p_181020_0_.setInteger("Base", p_181020_1_); if (p_181020_2_ != null) { p_181020_0_.setTag("Patterns", p_181020_2_); } }
protected void readStructureFromNBT(NBTTagCompound tagCompound) { NBTTagList nbttaglist = tagCompound.getTagList("Entrances", 11); for (int i = 0; i < nbttaglist.tagCount(); ++i) { this.roomsLinkedToTheRoom.add(new StructureBoundingBox(nbttaglist.getIntArrayAt(i))); } }