Jump to content

CompressedStreamTools.writeCompressed not in craftbukkit?


Recommended Posts

I have a problem and all the links in google point to Forge solutions. Please dont rake me over the coals but I am building against spigot.


Getting a little more advanced in my java now and sick of spamming all my data into yaml, would like to begin using binary files. As I understand it, the best format for what I want is NBT.


I found the following tutorial which provides what I want.



Only eclipse highlighted NBTTagCompound in red meaning not found.


Found this explaining the reason I couldn't find it is because its in craftbukkit, not spigot


He say's

You need to add craftbukkit.jar as a dependency rather than bukkit.jar. craftbukkit has all the mc-dev stuff in it :)


So, I have added craftbukkit to my build path but now CompressedStreamTools is not found.

CompressedStreamTools.writeCompressed(nbttagcompound, fileoutputstream);


So I figured at this point after spending an hour on this, before I find more problems and spend another hour, I should come to Forge and ask the simple question, How do I make this work?

Link to comment
Share on other sites

Could this code have changed? I did some fiddling and ended up with this:



import java.io.File;
import java.io.FileOutputStream;

import net.minecraft.server.v1_9_R2.NBTTagCompound;
import net.minecraft.server.v1_9_R2.NBTCompressedStreamTools;

public class FileHandler {

    private void writeNBTToFile() {
        try {
            File file = new File(ModLoader.getMinecraftInstance().getMinecraftDir() + "/saves/" + ModLoader.getMinecraftInstance().theWorld.saveHandler.getSaveDirectoryName() + "", "any_name_you_want.dat");
            if(!file.exists()) {
            FileOutputStream fileoutputstream = new FileOutputStream(file);
            NBTTagCompound nbttagcompound = new net.minecraft.server.v1_9_R2.NBTTagCompound();
            nbttagcompound.setBoolean("my_value_a", this.my_value_a);
            nbttagcompound.setInt("my_value_b", this.my_value_B);

            NBTCompressedStreamTools.a(nbttagcompound, fileoutputstream);
        } catch(Exception exception) { 



Edit: Fixed some errors and put the code in code tags to make it more readable. Which did not seem to work as there are no indents

Link to comment
Share on other sites

This appears to be broken when building against spigot/craftbukkit 1.9.4. with:


import net.minecraft.server.v1_9_R2.NBTCompressedStreamTools;

import net.minecraft.server.v1_9_R2.NBTTagCompound;



However the previous version works for me under spigot/craftbukkit 1.9.2 with:

import net.minecraft.server.v1_9_R1.NBTCompressedStreamTools;

import net.minecraft.server.v1_9_R1.NBTTagCompound;


Maybe I did something wrong but this is how it appears to me.


Edit: Yep, I did something wrong. I was using an older server for testing purposes and in haste forgot to edit my start file when I upgraded the server to 1.9.4. for the testing. I can confirm now that, yes the code has changed since that original tutorial I posted and yes it does work the new way, in 1.9.4.

Link to comment
Share on other sites

Actually, just the other day, Akkarin on the Spigot IRC provided me with this link.




The example code for using it seems more bloated and messy to me. It has a lot of extra imports:


import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;


Im still trying to decide its value.


We did look at developing mods with forge but many of the users in our community say they don't have systems that are powerful enough to run it. A while ago we provide a Crash Landing server for them to try, however many of them either timed out before they could establish a connection to the server, or couldn't get the forge client to run at all.


I am still considering developing a Forge modded server but I still don't know much about it, for instance, if a server is not heavily modded, can it still be loaded with a normal client? How large is the community? Also, when you look at something like life in the woods, im not sure anyone that downloads Forge would be interested in playing what I have to offer. Im a sole programmer and have never even looked at re-texturing. Don't get me wrong, im sure I have something to offer, however probably not anything significant enough by myself compared to what teams of developers can produce.

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.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.