@Override public NBTTagCompound writeToNBT( final NBTTagCompound data ) { super.writeToNBT( data ); final ByteBuf myDat = Unpooled.buffer(); this.writeBuffer( myDat ); if( myDat.hasArray() ) { data.setByteArray( "dots", myDat.array() ); } return data; }
/** * This builds a tag with the actual data that should be sent to the client for update syncs. * If the tile entity doesn't need update syncs, it returns null. */ private NBTTagCompound writeUpdateData() { final NBTTagCompound data = new NBTTagCompound(); final ByteBuf stream = Unpooled.buffer(); try { this.writeToStream( stream ); if( stream.readableBytes() == 0 ) { return null; } } catch( final Throwable t ) { AELog.debug( t ); } stream.capacity( stream.readableBytes() ); data.setByteArray( "X", stream.array() ); return data; }
public static NBTTagCompound toNBTTag(PacketBase packetBase, NBTTagCompound inputTag) { ByteBuf buf = Unpooled.buffer(); byte discriminator = (byte) INSTANCE.packets.indexOf(packetBase.getClass()); buf.writeByte(discriminator); packetBase.encodeInto(null, buf); inputTag.setByteArray("CoFH:data", buf.array()); return inputTag; }
public static void addPacketToNBT(ModernPacket packet, NBTTagCompound nbt) { ByteBuf dataBuffer = buffer(); PacketHandler.fillByteBuf(packet, dataBuffer); byte[] data = new byte[dataBuffer.readableBytes()]; dataBuffer.getBytes(0, data); dataBuffer.release(); nbt.setByteArray("LogisticsPipes:PacketData", data); }
@Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setByte(CoreProps.FACING, facing); nbt.setByteArray(CoreProps.SIDE_CACHE, sideCache); return nbt; }
@Override public void writeToNBT(NBTTagCompound nbttagcompound) { _filterInventory.writeToNBT(nbttagcompound, ""); nbttagcompound.setBoolean("defaultdestination", isDefaultRoute()); nbttagcompound.setByteArray("ignoreData", ignoreData.toByteArray()); nbttagcompound.setByteArray("ignoreNBT", ignoreNBT.toByteArray()); }
public static NBTTagCompound writeStreamableToNbt(IStreamable streamable, NBTTagCompound nbt) { PacketBufferForestry data = new PacketBufferForestry(Unpooled.buffer()); streamable.writeData(data); byte[] bytes = new byte[data.readableBytes()]; data.getBytes(0, bytes); nbt.setByteArray("dataBytes", bytes); return nbt; }
@Override public void sendInitData() { if (tileEntity instanceof TileWorksiteFarm) { TileWorksiteFarm twub = (TileWorksiteFarm) tileEntity; NBTTagCompound tag = new NBTTagCompound(); tag.setByteArray("checkedMap", twub.getTargetMap()); sendDataToGui(tag); } }
private NBTTagCompound serializeInitializationData(NBTTagCompound tag) { final PacketBuffer tmp = new PacketBuffer(Unpooled.buffer()); try { getSyncMap().writeInitializationData(tmp); } catch (IOException e) { throw new RuntimeException(e); } byte[] data = new byte[tmp.readableBytes()]; tmp.readBytes(data); tag.setByteArray(TAG_SYNC_INIT, data); return tag; }
public static NBTTagCompound setItemStackTagReconfig(NBTTagCompound tag, TileReconfigurable tile) { if (tile == null) { return null; } if (tag == null) { tag = new NBTTagCompound(); } tag.setByte(CoreProps.FACING, (byte) tile.getFacing()); tag.setByteArray(CoreProps.SIDE_CACHE, tile.sideCache); return tag; }
@Nonnull @Override public ItemStack getRecipeOutput() { ItemStack stack = new ItemStack(heraldricWeapon, 1); stack.setTagCompound(new NBTTagCompound()); stack.getTagCompound().setByteArray("hc2", SigilHelper.getDefault()); return stack; }
@Override public void setHeraldry(ItemStack stack, byte[] data) { if(!stack.hasTagCompound()){ stack.setTagCompound(new NBTTagCompound()); } stack.getTagCompound().setByteArray(heraldryTag, data); }
public static boolean setSideCache(ItemStack stack, byte[] sideCache) { if (sideCache.length < 6) { return false; } if (stack.getTagCompound() == null) { stack.setTagCompound(new NBTTagCompound()); } stack.getTagCompound().setByteArray(CoreProps.SIDE_CACHE, sideCache); return true; }
@Override public void writeToNBT(final NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setByteArray(TAG_MEMORY, memory.clone()); nbt.setByte(TAG_ADDRESS, address); EnumUtils.writeToNBT(state, TAG_STATE, nbt); }
@Override public NBTTagCompound getUpdateTag() { NBTTagCompound updateTag = super.getUpdateTag(); updateTag.setInteger("x", getPos().getX()); updateTag.setInteger("y", getPos().getY()); updateTag.setInteger("z", getPos().getZ()); ByteBuf backedBuffer = Unpooled.buffer(); writeInitialSyncData(new PacketBuffer(backedBuffer)); byte[] updateData = Arrays.copyOfRange(backedBuffer.array(), 0, backedBuffer.writerIndex()); updateTag.setByteArray("d", updateData); return updateTag; }
@Override public void writeToNBT(NBTTagCompound nbt, String str) { nbt.setByteArray(str + "log", copyLog()); nbt.setFloat(str + "samplingPeriod", samplingPeriod); nbt.setFloat(str + "maxValue", maxValue); nbt.setFloat(str + "minValue", minValue); nbt.setByte(str + "unitType", unitType); }
@Override public NBTTagCompound writeToNBT(NBTTagCompound tag) { super.writeToNBT(tag); tag.setByteArray("targetMap", targetMap); tag.setTag("plantableInventory", plantableInventory.serializeNBT()); tag.setTag("miscInventory", miscInventory.serializeNBT()); return tag; }
@Override public boolean store(Registry registry, Set<NBTAction> phase, NBTTagCompound nbt, Type type, String name, StatCollector object) throws IllegalArgumentException, IllegalAccessException, InstantiationException, NoHandlerFoundException { NBTTagCompound tag = new NBTTagCompound(); tag.setInteger("pos", object.getPos()); tag.setInteger("count", object.getCollectCount()); tag.setByteArray("data", object.getData()); nbt.setTag(name, tag); return true; }
public void onClose(boolean boundsAdjusted, boolean targetsAdjusted, byte[] checkedMap) { NBTTagCompound tag = new NBTTagCompound(); tag.setBoolean("guiClosed", true); if (boundsAdjusted) { tag.setLong("min", min.toLong()); tag.setLong("max", max.toLong()); } if (targetsAdjusted && tileEntity instanceof TileWorksiteFarm) { tag.setByteArray("checkedMap", checkedMap); } sendDataToServer(tag); }
@Override public byte[] getHeraldry(ItemStack stack) { if(!stack.hasTagCompound()){ stack.setTagCompound(new NBTTagCompound()); } if(!stack.getTagCompound().hasKey(heraldryTag)){ stack.getTagCompound().setByteArray(heraldryTag, SigilHelper.getDefault()); } return stack.getTagCompound().getByteArray(heraldryTag); }