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 void readFromNBT( final NBTTagCompound data ) this.finalOutput = AEItemStack.fromNBT( (NBTTagCompound) data.getTag( "finalOutput" ) ); for( final IAEItemStack ais : this.readList( (NBTTagList) data.getTag( "inventory" ) ) ) this.waitingFor = this.readList( (NBTTagList) data.getTag( "waitingFor" ) ); for( final IAEItemStack is : this.waitingFor )
@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)); } } }
@Override public void deserializeNBT( NBTTagCompound nbt ) { if( nbt.hasKey( NBT_SPATIAL_DATA_KEY ) ) { final NBTTagList list = (NBTTagList) nbt.getTag( NBT_SPATIAL_DATA_KEY ); this.spatialData.clear(); for( int i = 0; i < list.tagCount(); ++i ) { final NBTTagCompound entry = list.getCompoundTagAt( i ); final StorageCellData data = new StorageCellData(); final int id = entry.getInteger( NBT_SPATIAL_ID_KEY ); data.deserializeNBT( entry ); this.spatialData.put( id, data ); } } }
@Override public void process( final IMCMessage m ) { final NBTTagCompound msg = m.getNBTValue(); final NBTTagCompound item = (NBTTagCompound) msg.getTag( "item" ); final ItemStack ammo = new ItemStack( item ); final double weight = msg.getDouble( "weight" ); if( ammo.isEmpty() ) { throw new IllegalStateException( "invalid item in message " + m ); } AEApi.instance().registries().matterCannon().registerAmmo( ammo, weight ); } }
@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 @Nullable NBTTagCompound getTag(@Nullable NBTTagCompound tag, @Nullable NBTTagCompound _default) { if (tag != null && tag.hasKey(key)) { return (NBTTagCompound) tag.getTag(key); } setTag(tag, _default); return _default; }
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; }
public static void readFromNBT(IEnergyStorage storage, String key, NBTTagCompound nbt) { if (nbt.hasKey(key)) { CapabilityEnergy.ENERGY.readNBT(storage, null, nbt.getTag(key)); } }
public void readFromNBT(NBTTagCompound nbttagcompound) { if (nbttagcompound.getTag("bufferRF") instanceof NBTTagFloat) { // support for old float internalBufferRF = nbttagcompound.getFloat("bufferRF"); } else { internalBufferRF = nbttagcompound.getDouble("bufferRF"); } if (nbttagcompound.getTag("bufferEU") instanceof NBTTagFloat) { // support for old float internalBufferRF = nbttagcompound.getFloat("bufferEU"); } else { internalBufferRF = nbttagcompound.getDouble("bufferEU"); } }
@Override public void readEntityFromNBT(@Nonnull NBTTagCompound root) { super.readEntityFromNBT(root); loadedCats.clear(); if (root.hasKey("cats")) { NBTTagList catsList = (NBTTagList) root.getTag("cats"); for (int i = 0; i < catsList.tagCount(); i++) { loadedCats.add(catsList.getCompoundTagAt(i)); } } }
@Override public void fromBytes(ByteBuf buf) { NBTTagCompound root = NetworkUtil.readNBTTagCompound(buf); NBTTagList tagList = (NBTTagList) root.getTag("chanList"); for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound tag = tagList.getCompoundTagAt(i); Channel chan = Channel.readFromNBT(tag); if (chan != null) { channels.add(chan); } } }
@Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); int size = nbt.getInteger("taskSize"); for (int i = 0; i < size; i++) { NBTTagCompound tag = (NBTTagCompound) nbt.getTag("Task_" + i); TrackingTask task = new TrackingTask(); task.readFromNBT(tag); tasks.add(task); } }
@Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); if (compound.hasKey("items")) { itemStackHandler.deserializeNBT((NBTTagCompound) compound.getTag("items")); } }
@SuppressWarnings("null") public NBTTagCompound getTag(@Nonnull ItemStack stack, NBTTagCompound _default) { if (stack.hasTagCompound() && stack.getTagCompound().hasKey(key)) { return (NBTTagCompound) stack.getTagCompound().getTag(key); } setTag(stack, _default); return _default; }
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 public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); if (nbt.getTag("internalStorage") instanceof NBTTagFloat) { // support for old float internalStorage = nbt.getFloat("internalStorage"); } else { internalStorage = nbt.getDouble("internalStorage"); } maxMode = nbt.getInteger("maxMode"); }
static void readChannels(NBTTagCompound nbtRoot, ChannelList channels, @Nonnull String key) { channels.clear(); ; if (!nbtRoot.hasKey(key)) { return; } NBTTagList tags = (NBTTagList) nbtRoot.getTag(key); for (int i = 0; i < tags.tagCount(); i++) { channels.add(Channel.readFromNBT(tags.getCompoundTagAt(i))); } }
private TransformerData(NBTTagCompound nbt) { position = nbt.getLong(POS_KEY); range = nbt.getInteger(RANGE_KEY); climateState = ClimateStateHelper.INSTANCE.create(nbt.getCompoundTag(STATE_DATA_KEY)); circular = nbt.getBoolean(CIRCULAR_KEY); chunks = NBTUtilForestry.getLongArray(nbt.getTag(CHUNKS_KEY)); }