NMS Import?

Hey, does anyone know the Maven import I need to use to be able to access NMS?

Thanks!

What do you need NMS for? The Sponge API aims to make the use of NMS unnecessary, so it’s possible that whatever you want to do can be done with the API already. Furthermore, to use NMS, you’d need to import and setup the MCP mappings, used by both SpongeForge and SpongeVanilla, and doing that requires a couple more steps than a maven import (steps which I do not know how to accomplish :cry: )…

Well, there’s some things that I used in Spigot that Sponge doesn’t have, to my knowledge. For instance, hiding players without having those annoying potion effect particles everywhere. In Spigot, you’d simply
Player#hidePlayer(targetPlayer);
and it did the packet-magic for you. It was brilliant. Also I need to do per-client spawning of entities for ‘instanced’ areas. Mappings huh? That doesn’t sound fun xD I figured it was just an import because that’s all I had to do with Spigot. I’m still kinda getting the hang of Sponge.

There is a Data API key Keys.VANISH I believe

Yeah, I heard about that. Unfortunately, you can’t specify who the vanished player is vanished from. It’s either everyone, or no one :confused:

You could request for a feature like that… The sponge team is open to ideas…

Hmmm, where would I submit ideas? I have a few in mind. haha.

2 Likes

As suggested the first thing to do would be consider getting your desired functionality into SpongeAPI, though if you do need to access internal classes then it’s quite simple.
I suggest you create a forge environment and include spongeforge as a dependency.
You can find ForgeGradle docs here: https://forgegradle.readthedocs.io/en/latest/

and a template build.gradle in forge

To add spongeforge as a dependency, put

compile 'org.spongepowered:spongeforge:{spongeforge_version}:dev'

in your dependencies. Example version: “1.11.2-2201-6.0.0-BETA-2040”

then run the gradle task setupDecompWorkspace to create the forgegradle workspace (or setupDevWorkspace if you don’t need to decompile MC sources)

2 Likes

This kind of per-player data stuff is already being planned:

1 Like

But that doesn’t work on vanilla. I forget the vanilla way, but you might want to mention it.

Spigot is a modified jar of Minecraft. This means that method names and such are by and large deobfuscated already. Conversely, Sponge uses an unmodified Minecraft server jar, and mixes into it to make it implement the Sponge API at runtime. Thus, the classes and methods and variables are still obfuscated. You need a gradle plugin to properly map your deobfuscated calls to obfuscated calls.

So by saying that @simon816’s way doesn’t work with Vanilla, using his way I’d have to make a Forge mod to do NMS stuff and use a plugin messaging channel to communicate between the plugin and mod?

I didn’t know that about Spigot. That makes a lot of sense actually. Do you know what the name of the plugin is that I’d need? Even with the plugin though, I still wouldn’t have access to NMS without using Simon’s suggestion, right?

There is a way to do it in vanilla, I have just forgotten it.

Pretty sure the ForgeGradle plugin has a configuration for that… I don’t remember how to set it up though…

Edit:
ha-ha, that moment when you realize you had the exact same problem:

The only question is: did I delete the project that has the proper configurations or not…

I would suggest that you take a bit of time to read Implementation-dependent Plugins — Sponge 7.2.0 documentation. It describes most of the things you need to know when you really have to use NMS in your plugin, including setting up a Vanilla MCP workspace.

2 Likes