CompassMode (Bukkit) to Sponge/Forge


I saw on planetminecraft a plugin called “CompassMode” which allows the server admin to set the compass behavior per player / zone / whatever.

What I really need is to be able to let the compass point to the bed, rather than to the respawn point.

In my opinion, this could even be an exercise in order to practice with Sponge/Forge/Minecraft plugin creation (I’m new to Minecraft, but not to Java).

May anyone please help me creating this mod? I don’t even know if it’d be better to create a new compass (maybe different materials?) or overriding the original one…

Thanks :slightly_smiling:

There’s always the TargetedLocationData in the API that allows you to modify where a Player's compass points do (since all it does is point to the understood respawn location according to what the server tells the client). So it’s entirely feasible to have it point to any bed location you wish, through the API.

Of course, however, if you want the compass to be different from a normal compass, then by all means, a Forge mod is the way to go (making a new item).

Hello gabizou, thanks for the reply :slight_smile:

So first of all, as I understand, this is a client/server mod, or just a client one? I can imagine the server has to have the new compass entry, at least.

Depends. If you want:

  • to modify the direction the vanilla compass is facing, then

  • you create a serverside plugin

  • client stays unmodified (vanilla)

  • to create a super-duper fancy custom compass, then

  • you need to modify the client, preferably with a Forge mod.

Ok, so to keep things cleaner (also from a server point of view), maybe I’d start with a Forge plugin for the client. Which is in any case something that will teach me more about Sponge too, being it based on top of Forge, right?

Now the next step seems to be “how to override the Compass behavior”.

Sponge as it stands is strictly a server API.

The reason it works is that the client blindly listens to what the server tells it for almost everything.

A forge mod is only required if the vanilla client can’t be tricked into doing what you want.

Such things are:

  • Custom Rendering
  • Custom Blocks and Items
  • Custom GUIs
  • Custom Entities
  • Anything needing a hotkey
  • Any custom resources

It looks like you just want to tell a compass to point elsewhere. It would likely be easier as a server plugin.
The problem with client mods is that they are either client side only, which makes it so that not everyone gets the functionality it provides, or that it becomes required by the server, which prevents the use of vanilla clients.

The sweet spot configuration is a server plugin/mod that does not REQUIRE a client counterpart, but CAN utilize one if it is available. This is, however, stupidly annoying because you have to deal with Netty.IO.

I would just make a server plugin and go with @gabizou’s answer.

Also some vocabulary that you might not be used to:

  • A mod is a special kind of java plugin that touches Minecraft/MC Forge internals.
  • A coremod is a special kind of mod that uses class transformers. (Bytecode manipulation)
  • A plugin is a java plugin written primarily against an API, and does not touch Minecraft/MC Forge internals.

Netty.IO? Is that same as Plugin Channels? I thought channels were designed exactly for this purpose, and therefore won’t be so ‘annoying’.

Try to get a Sponge plugin to talk to a Forge mod without the forge mod depending on sponge OR the sponge plugin depending on forge.

If you find a way that doesn’t use netty, be my guest.

1 Like

I’m thinking more like in terms ‘.litemod’ mod.

without the forge mod depending on sponge OR the sponge plugin depending on forge.

Umm… Plugin Channels are Minecraft feature, not Sponge or Forge. Just like chat, or scoreboards.

no they aren’t. I’m not sure where you got that idea.

Well, the Netty.IO channels are built into minecraft, but FML does not provide an abstracted raw channel.

It only gives you Netty for raw input.

Forge and Sponge both have abstracted packet systems, but there is no guarantee that they are compatible with each other, which means if you want packets, you need to write adapters on top of the raw channel implementations.

In the case of sponge, this is just raw channels, in Forge/FML, it’s an embedded Netty channel.

By the way that post is WAY old. That was before minecraft switched over to Netty. Custom payload packets are long gone. Trust me on that one, I’ve been poking at modding since MC release 1.1

Edit: They aren’t completely gone, but forge has netty channels built in now, so mods never have to touch custom payload packets, much less plugins.

Thank you @gravitybox for both the plugin/mod/coremod definitions and the suggestion, I really appreciate it!

Bytecode manipulation means you can create “proxies” or even totally new methods instead of the original ones, maybe optimizing etc? Is this the core of Sponge then? Cool to know!

So now ideally I should create a SpongeAPI plugin, and not a Forge one right? Or it’s ideally the same, being SpongeForge based on Forge? Quite confusing… is SpongeAPI a superset of Forge?

Is there a tutorial/guide/wiki on where to start working on SpongeAPI?

Thanks :slightly_smiling:

Hehe, gravitybox :stuck_out_tongue:

Creating a plugin for the SpongeAPI will mean it can be run both on SpongeForge and SpongeVanilla.

Sponge is an API of its own, with two current official implementation. SpongeForge is built as a Forge coremod, which means it can run simultaneously with other mods. As of Forge 1.8, vanilla clients can connect to Forge servers as long as the server doesn’t have any mods that require a client side counterpart. This implementation has currently come a longer way than SpongeVanilla, but in the end they will ideally work in the same way.

SpongeVanilla is the vanilla implementation of the Sponge API (thus the name). It is a standalone server which does not require Forge to run.

As for a guide to start developing, have a look at the Documentation, and alternately the Javadocs!

OK! I’ve started reading the documentation, thanks for the link :slightly_smiling:

Following the plugin templates page though, I think the Gradle’s templates are missing… any hint?

Thanks :slight_smile:

^ build.gradle pom.xml if this helps at least a bit :wink:

Uhm, I think I didn’t understand. I’m setting up the Gradle project, where should I find / put the pom.xml file? Is that the Maven repository thing? Shouldn’t I set it up with build.gradle instead?

Worship Gradle.


1 Like

Yeah indeed. But I need to know how to configure it :stuck_out_tongue: I’m used to work with it via AndroidStudio, but I’ve never had to really set it up…

Here is the build.gradle file for foxguard, if you need a jumpstart.

It’s customized to my needs, so don’t use it word for word.

This is my build.gradle file:

And this is my simple file (under src/java/name/giacomofurlan/minecraft/compassToRespawnPoint)

The error is: “Cannot resolve symbol ‘spongepowered’” (on line 3).

Any hint? I’ve refreshed the gradle file via the “Refresh all Gradle projects” button.