ProtocolLib

3M Downloads

ResourceKey reflection

Peng1104 opened this issue ยท 3 comments

commented

Is your feature request related to a problem? Please describe.
I am trying to create the Respawn packet for the 1.16_R1 / 1.16_R2 but there is a huge change in this version, the DimensionManager is on the 1.16_R1 a ResourceKey the same for the new filed in the packet the ResourceKey for the world. Spigot Post

Describe the solution you'd like
I need a class that is equivalent to the ResourceKey of the minecraft server something like the MinecraftKey class, a way that I can create or modify it (I am lost with it)

Respawn Packet on the 1.16_R1

commented

ResourceKey<World> => new StructureModifier #906

ResourceKey<DimensionManager => updated ProtocolLib code - same API: #893

commented

@games647 Ok i got for the capture of a ResourceKey for a given World, but how can I manipulate / create it using reflections?

For the world for example: I want the world that the packet is handling, I would need something like:

ResourceKey worldKey = packet.getSpecificModifier(resourceKeyClass).readSafely(1); // The protocolLib ResourceKey
MinecraftKey key = worldKey.getKey(); //The needed part
World world = Bukkit.getWorld(key.getKey());

commented

You don't need reflection to modify it. There is a fixed modifier for it:

* Retrieve a read/write structure for World ResourceKeys in 1.16+
* @return The Structure Modifier
*/
public StructureModifier<World> getWorldKeys() {

EDIT: This was added in the mentioned tickets.