Jump to content

A GUI trust system on my mod for players with pets to use on a server


Recommended Posts

I would like to make a beastmaster mod. Adds a lot of tameable and mountable mobs and I need a gui that when opened shows all the players that joined the server and set how much you trust that player. Back in the day someone killed all of our pets. They are way stronger than the players gear but they didn't fight back because they were tamed, and i don't want to resort the code to the vanilla scenario "hit your friend accidentally once and all of his 60+ tamed wolves start chasing you and you don't wanna kill any of them because they're all cute and your friend will hate you". So I need a system for choosing your friends from your enemy for your pets to trust.

There are 4 trust levels for a player:

1. Enemy - Pets will kill him on sight to prevent them from hurting the player.

2. Stranger(Default) - Pets will be wary but if the player attacked them or their owner too much, set to enemy then DEFEND THE MASTER! RIP AND TEAR! BLOOD FOR THE BLOOD GOD!

3.  Friend - Cast on trusted people Pets will not attack if accidentally punched or stabbed for a few times but with a mathematical algorithm that weighs how many times he attacked and dealt damage in a time, set him to Enemy Mode for pets to retaliate (Ill make my own algorithm for this, if is it too resource heavy for a server visited by 30,000 players at least once, warn me not to preventing lag). If a pet can mount multiple players, only allow the the player to the other seats not the first passenger index (controller)!

4. Best Friend - Same as friend but the player can become the controller (Necessary when you need to get out of a sticky situation and that friend was the first to ride and you were too slow)


What I understand:

1. Make an enum for the trust level. Enemy, Stranger, Friend, Best Friend

2. Collect all the player UUIDs using the Collections class or ArrayList and set it's enum state

3. Send those UUID to client(GUI).

4. Synchronize the enum with MessagePackets from client(GUI) to server.


What I don't understand:

1. How to connect it with the world data. Do I have to extend/implement a class, or call an Event?

2. How do I store the data in the world?

3. Should I use Collections or ArrayList? What's the difference, should I use a different class instead?

4.  How do I make a stored data outside the world data called "Recent Players", "Enemy Players" , "Best Friend Players". If a player for example hates a lot of players in a server and goes to another server, he can easily navigate these tabs and simply set them all to enemy and friend status without manually scrolling for thousands of players.

5. When a Friend player mounts a multiple passenger mob, how do I set it to ride except the driver without a Nullpointer . Is simply +1 his passenger index enough?

6. How to open a Gui by pressing a button or clicking a button in the player's inventory.



Link to comment
Share on other sites

For each player, you can store his settings of all other players in the player’s capability. Capabilities can be persistent, and seems to be an appropriate option here.


2 hours ago, Kiljaeden053 said:

How do I make a stored data outside the world data called "Recent Players", "Enemy Players" , "Best Friend Players". If a player for example hates a lot of players in a server and goes to another server, he can easily navigate these tabs and simply set them all to enemy and friend status without manually scrolling for thousands of players.

Check out World Saved Data.


2 hours ago, Kiljaeden053 said:

How to open a Gui by pressing a button or clicking a button in the player's inventory.

Send a packet to the server (with a handler that opens the GUI from server side) when the key is pressed.

Some tips:


Modder Support:


1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.



Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.



The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:


1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Issue with the player skills mod. Looks like it needs the KubeJS mod installed?
    • ---- Minecraft Crash Report ---- // Don't do that. Time: 25.03.2023, 11:31 Description: Exception in server tick loop java.lang.NoClassDefFoundError: dev/latvian/mods/kubejs/KubeJSPlugin     at java.lang.ClassLoader.defineClass1(Native Method) ~[?:?] {}     at java.lang.ClassLoader.defineClass(ClassLoader.java:1012) ~[?:?] {}     at cpw.mods.cl.ModuleClassLoader.readerToClass(ModuleClassLoader.java:116) ~[securejarhandler-1.0.3.jar:?] {}     at cpw.mods.cl.ModuleClassLoader.lambda$findClass$16(ModuleClassLoader.java:216) ~[securejarhandler-1.0.3.jar:?] {}     at cpw.mods.cl.ModuleClassLoader.loadFromModule(ModuleClassLoader.java:226) ~[securejarhandler-1.0.3.jar:?] {}     at cpw.mods.cl.ModuleClassLoader.findClass(ModuleClassLoader.java:216) ~[securejarhandler-1.0.3.jar:?] {}     at cpw.mods.cl.ModuleClassLoader.loadClass(ModuleClassLoader.java:132) ~[securejarhandler-1.0.3.jar:?] {}     at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?] {}     at net.impleri.playerskills.PlayerSkillsEvents.beforeServerStart(PlayerSkillsEvents.java:70) ~[player-skills-1.18.2-1.0.0.jar%2394!/:?] {re:classloading}     at dev.architectury.event.forge.EventHandlerImplCommon.event(EventHandlerImplCommon.java:403) ~[architectury-4.11.89-forge.jar%2358!/:?] {re:classloading}     at net.minecraftforge.eventbus.ASMEventHandler_356_EventHandlerImplCommon_event_ServerAboutToStartEvent.invoke(.dynamic) ~[?:?] {}     at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:85) ~[eventbus-5.0.3.jar%232!/:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:302) ~[eventbus-5.0.3.jar%232!/:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:283) ~[eventbus-5.0.3.jar%232!/:?] {}     at net.minecraftforge.server.ServerLifecycleHooks.handleServerAboutToStart(ServerLifecycleHooks.java:86) ~[forge-1.18.2-40.2.0-universal.jar%23124!/:?] {re:classloading}     at net.minecraft.client.server.IntegratedServer.m_7038_(IntegratedServer.java:63) ~[client-1.18.2-20220404.173914-srg.jar%23119!/:?] {re:mixin,pl:runtimedistcleaner:A,re:classloading,pl:mixin:APP:mixins.essential.json:server.integrated.MixinIntegratedServer,pl:mixin:A,pl:runtimedistcleaner:A}     at net.minecraft.server.MinecraftServer.m_130011_(MinecraftServer.java:661) ~[client-1.18.2-20220404.173914-srg.jar%23119!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:balm.mixins.json:MinecraftServerMixin,pl:mixin:APP:mixins.essential.json:server.MinecraftServerMixin_PvPGameRule,pl:mixin:APP:mixins.essential.json:server.Mixin_PublishServerStatusResponse,pl:mixin:A}     at net.minecraft.server.MinecraftServer.m_177918_(MinecraftServer.java:261) ~[client-1.18.2-20220404.173914-srg.jar%23119!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:balm.mixins.json:MinecraftServerMixin,pl:mixin:APP:mixins.essential.json:server.MinecraftServerMixin_PvPGameRule,pl:mixin:APP:mixins.essential.json:server.Mixin_PublishServerStatusResponse,pl:mixin:A}     at java.lang.Thread.run(Thread.java:833) [?:?] {re:mixin} Caused by: java.lang.ClassNotFoundException: dev.latvian.mods.kubejs.KubeJSPlugin     at jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[?:?] {}     at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?] {}     at cpw.mods.cl.ModuleClassLoader.loadClass(ModuleClassLoader.java:134) ~[securejarhandler-1.0.3.jar:?] {}     at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?] {}     at cpw.mods.cl.ModuleClassLoader.loadClass(ModuleClassLoader.java:134) ~[securejarhandler-1.0.3.jar:?] {}     at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?] {}     ... 19 more  
    • You might be able to make it work by using the sound directly? i.e. something like: SoundInstance sound = new SimpleSoundInstance(...); Minecraft.getInstance().getSoundManager().play(sound); But I guess you would need to use an AccessTransformer to make the SimpleSoundInstance constructor that takes a ResourceLocation instead of a SoundEvent publicly accessible. https://forge.gemwire.uk/wiki/Access_Transformers
    • Use java 17. Mixin does not support java 20 (which only came out last week).
    • From what I understand (which might be incorrect, I am not an expert on this), it doesn't use the local client registry for those registries that have data sent from a multiplayer server. SoundEvents is one of those registries. So in multiplayer your SoundEvent effectively won't exist unless it is also registered on the server?   The logic can be found here (and its related methods): https://github.com/MinecraftForge/MinecraftForge/blob/bb49b9e6dc7525ae0fa935abf6eec18b36091bd6/src/main/java/net/minecraftforge/registries/GameData.java#L656
  • Topics

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.