public static CompoundTag fromNative(NBTTagCompound other) { Set<String> tags = other.getKeySet(); Map<String, Tag> map = new HashMap<>(); for (String tagName : tags) { map.put(tagName, fromNative(other.getTag(tagName))); } return new CompoundTag(map); }
public PacketFluidSlot( final ByteBuf stream ) { this.list = new HashMap<>(); NBTTagCompound tag = ByteBufUtils.readTag( stream ); for( final String key : tag.getKeySet() ) { this.list.put( Integer.parseInt( key ), AEFluidStack.fromNBT( tag.getCompoundTag( key ) ) ); } }
@Override public void readFromNBT(@Nonnull NBTTagCompound nbttagcompound) { ((BlockPistonRelay) ModBlocks.pistonRelay).mappedPositions.clear(); Collection<String> tags = nbttagcompound.getKeySet(); for(String key : tags) { NBTBase tag = nbttagcompound.getTag(key); if(tag instanceof NBTTagString) { String value = ((NBTTagString) tag).getString(); ((BlockPistonRelay) ModBlocks.pistonRelay).mappedPositions.put(DimWithPos.fromString(key), DimWithPos.fromString(value)); } } }
for( final Object oKey : in.getKeySet() )
Set<String> keys = notesCmp.getKeySet(); GuiLexicon.notes.clear(); for(String key : keys)
public List<String> getValidKeys(String identifer) { List<String> list = new ArrayList<>(); for (String key : saveTag.getKeySet()) { if (key.endsWith(",type=" + identifer)) { list.add(key.replace(",type=" + identifer, "")); } } return list; }
@Override public void readFromNBT( final NBTTagCompound data ) { super.readFromNBT( data ); this.cm.readFromNBT( data ); if( data.hasKey( "paintedColor" ) ) { this.paintedColor = AEColor.values()[data.getByte( "paintedColor" )]; } this.securityKey = data.getLong( "securityKey" ); this.getConfigSlot().readFromNBT( data, "config" ); final NBTTagCompound storedItems = data.getCompoundTag( "storedItems" ); for( final Object key : storedItems.getKeySet() ) { final NBTBase obj = storedItems.getTag( (String) key ); if( obj instanceof NBTTagCompound ) { this.inventory.getStoredItems().add( AEItemStack.fromItemStack( new ItemStack( (NBTTagCompound) obj ) ) ); } } }
public static void ClearCompoundTag(NBTTagCompound tag) { if(tag == null) { return; } ArrayList<String> list = new ArrayList<>(tag.getKeySet()); for(String key : list) { tag.removeTag(key); } }
@Override public void write(JsonWriter out, NBTTagCompound nbt) throws IOException{ out.beginObject(); for(String key : nbt.getKeySet()){ NBTBase value = nbt.getTag(key); out.name(key); NBT_BASE.write(out, value); } out.endObject(); }
@Override public void readData(NBTTagCompound nbt, SyncType type) { super.readData(nbt, type); NBTTagCompound recipeList = (NBTTagCompound) nbt.getTag("recipeList"); recipes = new ArrayList<>(); recipes.addAll(recipeList.getKeySet()); }
private static Map<String, String> getStateProperties(NBTTagCompound propertiesTag) { Map<String, String> ret = new HashMap<>(); for (String key : propertiesTag.getKeySet()) { if (propertiesTag.hasKey(key, Constants.NBT.TAG_STRING)) { ret.put(key, propertiesTag.getString(key)); } } return ret; }
public static int getOccupiedSlotCount(ItemStack itemStack) { NBTTagCompound nbt = itemStack.getTagCompound(); if (nbt == null) { return 0; } NBTTagCompound slotNbt = nbt.getCompoundTag(KEY_SLOTS); return slotNbt.getKeySet().size(); }
private int getHashCode(NBTTagCompound tag, int result) { for (String key : tag.getKeySet()) { result = 31 * result + key.hashCode(); result = getHashCode(tag.getTag(key), result); } return result; }
@Override public ValueTypeString.ValueString get(int index) throws EvaluationException { if (index < tag.getSize()) { return ValueTypeString.ValueString.of(Iterables.get(tag.getKeySet(), index)); } return null; }
@Override public void deserializeNBT(NBTTagCompound nbt) { for (String key : nbt.getKeySet()) { DataField<?> field = availableFields.get(key); if (field != null) { NBTBase nbtType = nbt.getTag(key); data.put(field, field.getDataTypeProcess().deserialize(world, nbtType)); } } }
public static List<Pair<String, Float>> getCapDataRaw(@Nonnull ItemStack stack) { NBTTagCompound tag = stack.getSubCompound("eiocap"); if (tag == null) { return null; } List<Pair<String, Float>> result = new ArrayList<Pair<String, Float>>(); for (String key : tag.getKeySet()) { if (key != null && !"level".equals(key) && tag.hasKey(key, (new NBTTagFloat(0)).getId())) { result.add(Pair.of(key, tag.getFloat(key))); } } return result; }
private void readGraphicsOperations(NBTTagCompound tagCompound) { gfxOps.clear(); NBTTagCompound opTag = tagCompound.getCompoundTag("gfxop"); for (String key : opTag.getKeySet()) { gfxOps.put(key, GfxOp.readFromNBT(opTag.getCompoundTag(key))); } sortOps(); }
public static ResultNBT copyAndHashNBT(NBTTagCompound tag) { int hash = Constants.NBT.TAG_COMPOUND; NBTTagCompound copy = new NBTTagCompound(); for (String s : tag.getKeySet()) { Result result = copyAndHash(tag.getTag(s)); hash += s.hashCode() ^ result.hash; copy.setTag(s, result.base); } return new ResultNBT(copy, hash); }
@Override @Nonnull public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); if (!stack.isEmpty() && stack.getItemDamage() == 2 && player.isSneaking() && stack.hasTagCompound()) { //noinspection ConstantConditions Set<String> keySet = stack.getTagCompound().getKeySet(); keySet.clear(); } return super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ); }
@Override @ParametersAreNonnullByDefault public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) { ItemStack itemStackIn = playerIn.getHeldItem(hand); if (!itemStackIn.isEmpty() && itemStackIn.getItemDamage() == 2 && playerIn.isSneaking() && itemStackIn.hasTagCompound()) { //noinspection ConstantConditions Set<String> keySet = itemStackIn.getTagCompound().getKeySet(); keySet.clear(); } return super.onItemRightClick(worldIn, playerIn, hand); }