world_info() - Dimension ID
LadyCailinBot opened this issue ยท 18 comments
CMDHELPER-3094 - Reported by SirWill
hey,
it would be great if you can get the Dimension ID with world_info()
Comment by PseudoKnight
It's Groovy. You can do that with CHGroovy too. It presumably uses the method I mentioned above. I'd have to look at the particular script. The plugin itself doesn't fetch the dimension id.
Comment by SirWill
That's how it would work in VarScript:
// setDimension.groovy
def player = args[0]
def world = args[1]
player.offlineNbt {
Dimension = world.environment.id
}
run command: /> setDimension PlayerName WorldName
How would that work in CHGroovy?
Comment by PseudoKnight
Are you sure that is the dimension id and not the environment id? (which is NOT the dimension id) It's not exactly clear where it's getting that data from, but it looks like it's a Bukkit world, and I already tested that id above. The variable is stored as "dimension" in the server.
Comment by SirWill
Looks like you are right, environment id is not the unique dimension id. So if you have 2 normal worlds both are 0.
Comment by wizjany
Some time ago forge would create each world with a different dimension ID, but they've since moved to giving each world a String name. that might be what you're thinking of. there's also world UUIDs, but i believe those are currently only a bukkit feature.
Comment by SirWill
@wizjany hm, not sure what do you mean with string name.
Probably the best to read the level.dat of the world to get the dimension id. Just need to find out how to read NBT data with CH.
Comment by PseudoKnight
wizjany, it looks like CraftBukkit assigns incremental "dimension" ids too, if you look at CraftServer.createWorld().
Thing is, I just looked around to see if the server actually uses the dimension id when a player logs in (for the purpose of offline teleportation), and it only uses it as a fallback. (See: NMS.Entity, search for "bworld") It first checks the world UID. If that doesn't exist, it checks the world string name (probably for Forge support, since CB doesn't seem to save this to player profiles), and then if the world is still null, it uses the dimension id.
Comment by PseudoKnight
What do you mean by Dimension ID? I thought you meant environment (eg. NETHER), but that's already included. Is this a mod support request?
Comment by SirWill
If you open the level.dat of a world it includes "Dimension: ". For example nether = -1, end 1.
And to change the offline location of a player for example, I need to know the dimension id.
Comment by PseudoKnight
Yes, the environment gives you that information in Bukkit terms.
Comment by PseudoKnight
Well, Bukkit also has a method to get the int id of the environment but it's deprecated and unneeded.
Comment by SirWill
The environment is not useful for that and doesn't help if you have multiple normal worlds.
Comment by PseudoKnight
Can you provide an example of what you mean? It's not clear why you can't use -1 for NETHER.
Comment by SirWill
I want to create a command to change the location of a offline player, for that I use CommandHelper and PowerNBT.
For that you run the command /offlineteleport CH would then get the world spawn of the specific world and run multiple PowerNBT command but to change the world of the player it requires the Dimension ID as the player.dat does only use the dimension ID for the player location.
For the main world, nether and end I could just check for the input and return the correct ID as it is always the same but if I have a world called testworld for example it would have an id of 2 upwards (depending whats free). Environment is not unique so it would be the same like for the main world.
Short version:
- environment != unique
- environment.id == unique
Comment by PseudoKnight
I don't think this information is accessible by the Bukkit API. I haven't tested it, but nothing in the code suggests the environment id is what you're looking for. (edit: confirmed) As far as I can tell, the dimension id is stored in NMS.WorldServer with no retrieving method.
Comment by PseudoKnight
It's a public var so I could throw it in my CHNaughty extension, though. (if my assessment is correct)
Comment by PseudoKnight
Well, I have it ready to go in my extension, if that's the case.
Comment by SirWill
Hm, how does this plugin do it: http://dev.bukkit.org/bukkit-plugins/varscript/
With that you can get the dimension id.