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…
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).
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.
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”.
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.
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?
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!
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?