Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ListTag Double issue #88

Closed
Wolfyxon opened this issue Feb 25, 2023 · 1 comment
Closed

ListTag Double issue #88

Wolfyxon opened this issue Feb 25, 2023 · 1 comment

Comments

@Wolfyxon
Copy link

Wolfyxon commented Feb 25, 2023

I'm trying to get player's position from .dat file inside playerdata folder

    public double[] getPosition(CompoundTag tag){
        double result[] = new double[3];
        ListTag list = tag.getListTag("Pos");
        for(int i=0;i<list.size();i++){
            result[result.length-1] = Double.parseDouble(list.get(i).valueToString());
        }
        return result;
    }
        CompoundTag tag = nbt.parseFile(utils.baseDir+"/world/playerdata/<UUID>");
        double[] pos = nbt.getPosition(tag); // <--- this
        for(int i=0;i<pos.length;i++){
            plugin.getLogger().info(String.valueOf(pos[i]));
        }

This function returns {0,0,0} but when I check the file with NBTEditor the values are correct with the actual position

@Wolfyxon
Copy link
Author

Wolfyxon commented Mar 2, 2023

I fixed it by using .replace("I;",""); but I'm pretty sure it's a bug

@Wolfyxon Wolfyxon closed this as completed Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant