Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.7.10] Problems with FluidTank NBT read/write


grand_mind1
 Share

Recommended Posts

I ran into some trouble when using the NBT read/write methods of FluidTank. The writeToNBT() method creates a string tag with the key "Empty" if the fluid being saved is null. However, this tag is never removed if the same compound is written to with fluid present. This means that the first time the tank saves while empty, it will never be able to be read from properly again, because the readFromNBT() method simply sets the fluid to null if the "Empty" tag is present. I understand that I can solve this problem by creating a new tag every time I write and save all of my other data to it as well, however this problem seems like an oversight.

Link to comment
Share on other sites

I don't think that's true.

public FluidTank readFromNBT(NBTTagCompound nbt)
    {
        if (!nbt.hasKey("Empty"))
        {
            FluidStack fluid = FluidStack.loadFluidStackFromNBT(nbt);
            setFluid(fluid);
        }
        else
        {
            setFluid(null);
        }
        return this;
    }

    public NBTTagCompound writeToNBT(NBTTagCompound nbt)
    {
        if (fluid != null)
        {
            fluid.writeToNBT(nbt);
        }
        else
        {
            nbt.setString("Empty", "");
        }
        return nbt;
    }

Link to comment
Share on other sites

I think you're misunderstanding. That code is entirely relevant, it's the two methods this post is about in the first place. You're claiming that they function in a way they do not.

Yes, the fluidstack the tank creates will be null, because the "empty" tag is present. You are correct in saying that the data saved to the compound in writeToNBT() will not be null, however that is irrelevant as it will never be read.

Link to comment
Share on other sites

It will never be read because the "Empty" tag is present. It doesn't matter what other data is there, if the "Empty" tag is present, the fluid is set to null.

The "Empty" tag is created in writeToNBT() of FluidTank if there is no fluid. Meaning that if I ever save the tank while it is empty, it will never be read from properly again. This is because the "Empty" tag is not removed if I write with fluid present.

Link to comment
Share on other sites

You really don't understand. I am using one NBTTagCompound. Let's say I write some tank data to it while the tank has some water in it. This works fine and can be read later. Now, I remove the water and save. Because the fluid was null, the "empty" tag was added to the compound. If I add water again and write, it will still be read as empty because the tag was not removed on write.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • I did and it still crashes, same crash too.
    • I'll just send the crash report, I personally have no idea what I'm looking at. Someone help [20Oct2021 09:32:39.664] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--gameDir, ., --launchTarget, fmlserver, --fml.forgeVersion, 36.2.0, --fml.mcpVersion, 20210115.111550, --fml.mcVersion, 1.16.5, --fml.forgeGroup, net.minecraftforge] [20Oct2021 09:32:39.668] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 8.0.9+86+master.3cf110c starting: java version 1.8.0_302 by Oracle Corporation [20Oct2021 09:32:39.921] [main/INFO] [net.minecraftforge.fml.loading.FixSSL/CORE]: Added Lets Encrypt root certificates as additional trust [20Oct2021 09:32:39.969] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.2 Source=file:/home/container/libraries/org/spongepowered/mixin/0.8.2/mixin-0.8.2.jar Service=ModLauncher Env=SERVER [20Oct2021 09:32:41.561] [main/INFO] [mixin/]: Successfully loaded Mixin Connector [com.performant.coremod.mixin.Connector] [20Oct2021 09:32:41.565] [main/INFO] [cpw.mods.modlauncher.LaunchServiceHandler/MODLAUNCHER]: Launching target 'fmlserver' with arguments [--gameDir, .] [20Oct2021 09:32:41.619] [main/INFO] [com.performant.coremod.Performant/]: Performant configs loaded [20Oct2021 09:32:42.113] [main/INFO] [com.performant.coremod.Performant/]: Not enabling mixin forcom.performant.coremod.mixin.forge.BasicEventHooksMixin as config disables it. [20Oct2021 09:32:42.138] [main/INFO] [com.performant.coremod.Performant/]: Not enabling mixin forcom.performant.coremod.mixin.entity.LivingEntityUpdateEventMixin as config disables it. [20Oct2021 09:32:42.210] [main/WARN] [mixin/]: @Mixin target net/minecraft/world/server/ChunkManager$EntityTracker is public in performant.mixins.json:world.chunk.ChunkManagerEntityTrackMixin and should be specified in value [20Oct2021 09:32:47.988] [main/ERROR] [mixin/]: Critical injection failure: LVT in net/minecraft/world/gen/FlatGenerationSettings::func_236942_c_()Lnet/minecraft/world/biome/Biome; has incompatible changes at opcode 106 in callback net/minecraft/world/gen/FlatGenerationSettings::addCrashDetails. Expected: [Lnet/minecraft/world/biome/Biome;, Lnet/minecraft/world/biome/BiomeGenerationSettings;, Lnet/minecraft/world/biome/BiomeGenerationSettings$Builder;, Ljava/util/Iterator;, Ljava/util/Map$Entry;]    Found: [Lnet/minecraft/world/biome/Biome;, Lnet/minecraft/world/biome/BiomeGenerationSettings;, Lnet/minecraft/world/biome/BiomeGenerationSettings$Builder;, Ljava/util/Map;, Ljava/util/Iterator;] [20Oct2021 09:32:47.990] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException [20Oct2021 09:32:47.990] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:39) [20Oct2021 09:32:47.990] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [20Oct2021 09:32:47.990] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [20Oct2021 09:32:47.990] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [20Oct2021 09:32:47.990] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [20Oct2021 09:32:47.990] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at net.minecraftforge.server.ServerMain$Runner.runLauncher(ServerMain.java:63) [20Oct2021 09:32:47.990] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at net.minecraftforge.server.ServerMain$Runner.access$100(ServerMain.java:60) [20Oct2021 09:32:47.991] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at net.minecraftforge.server.ServerMain.main(ServerMain.java:57) [20Oct2021 09:32:47.991] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]: Caused by: java.lang.reflect.InvocationTargetException [20Oct2021 09:32:47.991] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [20Oct2021 09:32:47.991] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [20Oct2021 09:32:47.991] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [20Oct2021 09:32:47.991] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at java.lang.reflect.Method.invoke(Method.java:498) [20Oct2021 09:32:47.992] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at net.minecraftforge.fml.loading.FMLServerLaunchProvider.lambda$launchService$0(FMLServerLaunchProvider.java:51) [20Oct2021 09:32:47.992] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [20Oct2021 09:32:47.992] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     ... 7 more [20Oct2021 09:32:47.992] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]: Caused by: org.spongepowered.asm.mixin.transformer.throwables.MixinTransformerError: An unexpected critical error was encountered [20Oct2021 09:32:47.992] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:363) [20Oct2021 09:32:47.992] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClass(MixinTransformer.java:223) [20Oct2021 09:32:47.992] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at org.spongepowered.asm.mixin.transformer.MixinTransformationHandler.processClass(MixinTransformationHandler.java:121) [20Oct2021 09:32:47.993] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at org.spongepowered.asm.launch.MixinLaunchPlugin.processClass(MixinLaunchPlugin.java:131) [20Oct2021 09:32:47.993] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at cpw.mods.modlauncher.serviceapi.ILaunchPluginService.processClassWithFlags(ILaunchPluginService.java:154) [20Oct2021 09:32:47.993] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at cpw.mods.modlauncher.LaunchPluginHandler.offerClassNodeToPlugins(LaunchPluginHandler.java:85) [20Oct2021 09:32:47.993] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at cpw.mods.modlauncher.ClassTransformer.transform(ClassTransformer.java:120) [20Oct2021 09:32:47.993] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at cpw.mods.modlauncher.TransformingClassLoader$DelegatedClassLoader.findClass(TransformingClassLoader.java:265) [20Oct2021 09:32:47.993] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:136) [20Oct2021 09:32:47.993] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:98) [20Oct2021 09:32:47.993] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at java.lang.ClassLoader.loadClass(ClassLoader.java:351) [20Oct2021 09:32:47.993] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at net.minecraft.world.gen.FlatChunkGenerator.<clinit>(SourceFile:21) [20Oct2021 09:32:47.994] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at net.minecraft.world.gen.ChunkGenerator.<clinit>(SourceFile:54) [20Oct2021 09:32:47.994] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at net.minecraft.util.registry.Registry.func_243579_h(Registry.java:294) [20Oct2021 09:32:47.994] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at net.minecraft.util.registry.Registry.lambda$static$51(Registry.java:466) [20Oct2021 09:32:47.994] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) [20Oct2021 09:32:47.994] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at net.minecraft.util.registry.Registry.<clinit>(Registry.java:465) [20Oct2021 09:32:47.994] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at net.minecraft.util.registry.Bootstrap.func_151354_b(Bootstrap.java:38) [20Oct2021 09:32:47.994] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at net.minecraft.server.Main.main(Main.java:92) [20Oct2021 09:32:47.994] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     ... 13 more [20Oct2021 09:32:47.995] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:668]: Caused by: org.spongepowered.asm.mixin.injection.throwables.InjectionError: LVT in net/minecraft/world/gen/FlatGenerationSettings::func_236942_c_()Lnet/minecraft/world/biome/Biome; has incompatible changes at opcode 106 in callback net/minecraft/world/gen/FlatGenerationSettings::addCrashDetails. Expected: [Lnet/minecraft/world/biome/Biome;, Lnet/minecraft/world/biome/BiomeGenerationSettings;, Lnet/minecraft/world/biome/BiomeGenerationSettings$Builder;, Ljava/util/Iterator;, Ljava/util/Map$Entry;]    Found: [Lnet/minecraft/world/biome/Biome;, Lnet/minecraft/world/biome/BiomeGenerationSettings;, Lnet/minecraft/world/biome/BiomeGenerationSettings$Builder;, Ljava/util/Map;, Ljava/util/Iterator;] [20Oct2021 09:32:47.995] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:668]:     at org.spongepowered.asm.mixin.injection.callback.CallbackInjector.inject(CallbackInjector.java:487) [20Oct2021 09:32:47.995] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:668]:     at org.spongepowered.asm.mixin.injection.callback.CallbackInjector.inject(CallbackInjector.java:437) [20Oct2021 09:32:47.995] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:668]:     at org.spongepowered.asm.mixin.injection.code.Injector.inject(Injector.java:264) [20Oct2021 09:32:47.995] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:668]:     at org.spongepowered.asm.mixin.injection.struct.InjectionInfo.inject(InjectionInfo.java:385) [20Oct2021 09:32:47.995] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:668]:     at org.spongepowered.asm.mixin.transformer.MixinTargetContext.applyInjections(MixinTargetContext.java:1284) [20Oct2021 09:32:47.995] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:668]:     at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.applyInjections(MixinApplicatorStandard.java:1042) [20Oct2021 09:32:47.995] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:668]:     at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.applyMixin(MixinApplicatorStandard.java:395) [20Oct2021 09:32:47.996] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:668]:     at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.apply(MixinApplicatorStandard.java:320) [20Oct2021 09:32:47.996] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:668]:     at org.spongepowered.asm.mixin.transformer.TargetClassContext.applyMixins(TargetClassContext.java:345) [20Oct2021 09:32:47.996] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:668]:     at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:569) [20Oct2021 09:32:47.996] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:668]:     at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:351) [20Oct2021 09:32:47.996] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:668]:     ... 31 more  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.