Jump to content

Bind Server Capabilities & Custom GuiScreen to modify it


Durzann

Recommended Posts

Hi there, I'm happy to join the MCForge community today :)

 

I'm actually looking for creating a mod which allow players to create custom description for their character (Roleplay server), It's a complicated object, which handle several layers of description (not a simple string)

So I have my Capability classes, and i'm using a basic serializer to save it as a json string.

 

On the other side, I sucessffuly created a custom GuiScreen, with many inputs to edit the description and create new layers (But I didn't create any server/client interaction to open it.... Did I miss something ?)

 

 

But now, i'm struggling to get the next step with the server/client architecture :

 

_ What did I need to store the Capabilities on the server side (one per player), and send it to the Client to let him make some modifications (via my GuiScreen) ?

 

I Want to allow any players to right-click on another player, get his description, and make some modification on it, so what's the next things that I have to looking for ?

 

I can find detailed infos by myself, I just want to have a clear view of what I will need to make that works (And If you guys, can teach me a bit of how Client/server works, it will be great for me :)) )

 

 

 

Edited by Durzann
Link to comment
Share on other sites

The way to do this would be to attach the capability on the client as well (same procedure applies).

Then you need to decide whether the data is needed on the client only while the GUI is open or also outside of it.

 

Only during the GUI:

Send the data to the client as part of opening the GUI (NetworkHooks#openGui allows you to write extra data to the PacketBuffer).

 

Also outside the GUI:

  • You need to include Entity#getEntityId in the packets so that the client knows which player you are talking about. World#getEntityByID is the counterpart.
  • You need to send the data as follows:
    • In PlayerLoggedInEvent, PlayerRespawnEvent and PlayerChangedDimensionEvent: Send the data of PlayerEvent#getPlayer to only that player.
    • In PlayerEvent.StartTracking send the data of StartTracking#getTarget (if it is a player) to PlayerEvent#getPlayer.
    • Whenever the data changes send it to the player itself and all players tracking it: see PacketDistributor.TRACKING_ENTITY_AND_SELF.

 

As for client-to-server communication: Send information about what the player does to the server and validate it properly, do not send "commands". I.e. "Player clicked button x" not "change field 123 to value 'hello'". Treat the client as a lying bastard at all times and verify things.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now


  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I am trying to get a Private Vault Hunters 3rd edition up and running. The server launched fine before I pasted the Vault+Hunters+3rd+Edition-Update-10.0.1_Server-Files Contents into the file I made for the server info. Then after I pasted it I get the log information in the spoiler. I don't understand what I'm looking at. I'm using Forge 1.18.2, I also downloaded the most recent version of JDK.
    • Hey, my friends put together a custom modpack to use and asked me to set up a server to run it. Problem is, they didn't think to log which mods where client side only and which worked server side. Naturally, I only found this out when I actually attempted to run said server. There's quite a long list of them and, frankly, I have no idea which are causing the problem. I just run servers and install modpacks, not curate them. If anyone could help me identify the problem and what's causing the error, it would be greatly appreciated.   To make things a bit easier, I'm running the server in a docker container on a Ubuntu 20.04 server installation. Also, I'm using Java 17 and Forge ver 1.19.2 release 43.2.8 as that is the same version as the modpack, so everything should be working. Again, any help would be really appreciated. latest log: https://pastebin.com/f95NC0X7 All mods installed: https://pastebin.com/xy8d55kJ
    • I'm trying to install Forge for 1.12.2. The installer runs properly and says it installed forged succesfully, but when I go into the launcher there is no Forge profile and forge isn't in the version list when cresting a custom profile. In the versions folder in .minecraft the forge 1.12.2 folder is there, but it only has the .json file, it seems that the installer is not actually getting the .jar file. I tried with both the recommended and latest installers. I also tried downloading the universal .jar directly and pasting it into the versions folder but that didn't work either.   Installer log: JVM info: Oracle Corporation - 1.8.0_371 - 25.371-b11 java.net.preferIPv4Stack=true Found java version 1.8.0_371 Extracting json Considering minecraft client jar Downloading libraries Found 0 additional library directories Considering library net.minecraftforge:forge:1.12.2-14.23.5.2859   File exists: Checksum validated. Considering library org.ow2.asm:asm-debug-all:5.2   File exists: Checksum validated. Considering library net.minecraft:launchwrapper:1.12   File exists: Checksum validated. Considering library org.jline:jline:3.5.1   File exists: Checksum validated. Considering library com.typesafe.akka:akka-actor_2.11:2.3.3   File exists: Checksum validated. Considering library com.typesafe:config:1.2.1   File exists: Checksum validated. Considering library org.scala-lang:scala-actors-migration_2.11:1.1.0   File exists: Checksum validated. Considering library org.scala-lang:scala-compiler:2.11.1   File exists: Checksum validated. Considering library org.scala-lang.plugins:scala-continuations-library_2.11:1.0.2_mc   File exists: Checksum validated. Considering library org.scala-lang.plugins:scala-continuations-plugin_2.11.1:1.0.2_mc   File exists: Checksum validated. Considering library org.scala-lang:scala-library:2.11.1   File exists: Checksum validated. Considering library org.scala-lang:scala-parser-combinators_2.11:1.0.1   File exists: Checksum validated. Considering library org.scala-lang:scala-reflect:2.11.1   File exists: Checksum validated. Considering library org.scala-lang:scala-swing_2.11:1.0.1   File exists: Checksum validated. Considering library org.scala-lang:scala-xml_2.11:1.0.2   File exists: Checksum validated. Considering library lzma:lzma:0.0.1   File exists: Checksum validated. Considering library java3d:vecmath:1.5.2   File exists: Checksum validated. Considering library net.sf.trove4j:trove4j:3.0.3   File exists: Checksum validated. Considering library org.apache.maven:maven-artifact:3.5.3   File exists: Checksum validated. Considering library net.sf.jopt-simple:jopt-simple:5.0.3   File exists: Checksum validated. Considering library org.apache.logging.log4j:log4j-api:2.15.0   File exists: Checksum validated. Considering library org.apache.logging.log4j:log4j-core:2.15.0   File exists: Checksum validated. Considering library org.apache.logging.log4j:log4j-slf4j18-impl:2.15.0   File exists: Checksum validated. Building Processors Injecting profile Finished!
    • So I want to give the player the strength effect when they use a totem, but I can't get it to work. I've tested and if you have an effect when you use a totem, it is removed when you get revived (presumably because you "die.") After testing with System.out.print(), I've concluded the entity is given strength then has it immediately removed. This occurs even if I set the event priority to lowest. Does anyone have any ideas on getting around this? Thanks!
    • i cant make a mod server  2023-06-04 19:33:54,349 main WARN Advanced terminal features are not available in this environment [19:33:54] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher running: args [--launchTarget, forgeserver, --fml.forgeVersion, 43.2.13, --fml.mcVersion, 1.19.2, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20220805.130853, nogui] [19:33:54] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher 10.0.8+10.0.8+main.0ef7e830 starting: java version 20.0.1 by Oracle Corporation; OS Windows 10 arch amd64 version 10.0 [19:33:55] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.5 Source=union:/C:/Users/Sinrox/Desktop/Apps/SERVER/libraries/org/spongepowered/mixin/0.8.5/mixin-0.8.5.jar%2363!/ Service=ModLauncher Env=SERVER [19:33:56] [main/WARN] [ne.mi.fm.lo.mo.ModFileParser/LOADING]: Mod file C:\Users\Sinrox\Desktop\Apps\SERVER\libraries\net\minecraftforge\fmlcore\1.19.2-43.2.13\fmlcore-1.19.2-43.2.13.jar is missing mods.toml file [19:33:56] [main/WARN] [ne.mi.fm.lo.mo.ModFileParser/LOADING]: Mod file C:\Users\Sinrox\Desktop\Apps\SERVER\libraries\net\minecraftforge\javafmllanguage\1.19.2-43.2.13\javafmllanguage-1.19.2-43.2.13.jar is missing mods.toml file [19:33:56] [main/WARN] [ne.mi.fm.lo.mo.ModFileParser/LOADING]: Mod file C:\Users\Sinrox\Desktop\Apps\SERVER\libraries\net\minecraftforge\lowcodelanguage\1.19.2-43.2.13\lowcodelanguage-1.19.2-43.2.13.jar is missing mods.toml file [19:33:56] [main/WARN] [ne.mi.fm.lo.mo.ModFileParser/LOADING]: Mod file C:\Users\Sinrox\Desktop\Apps\SERVER\libraries\net\minecraftforge\mclanguage\1.19.2-43.2.13\mclanguage-1.19.2-43.2.13.jar is missing mods.toml file [19:33:56] [main/INFO] [ne.mi.fm.lo.mo.JarInJarDependencyLocator/]: Found 3 dependencies adding them to mods collection [19:34:00] [main/INFO] [mixin/]: Compatibility level set to JAVA_17 [19:34:00] [main/ERROR] [mixin/]: Mixin config mixins.oculus.compat.sodium.json does not specify "minVersion" property [19:34:00] [main/INFO] [mixin/]: Successfully loaded Mixin Connector [de.maxhenkel.camera.MixinConnector] [19:34:00] [main/INFO] [cp.mo.mo.LaunchServiceHandler/MODLAUNCHER]: Launching target 'forgeserver' with arguments [nogui] [19:34:00] [main/INFO] [Rubidium/]: Loaded configuration file for Rubidium: 30 options available, 0 override(s) found [19:34:01] [main/WARN] [mixin/]: Reference map 'smallships-forge-refmap.json' for smallships.mixins.json could not be read. If this is a development environment you can ignore this message [Tough As Nails Transformer]: Transforming m_36399_ (F)V in net/minecraft/world/entity/player/Player [Tough As Nails Transformer]: Successfully patched causeFoodExhaustion [19:34:01] [main/WARN] [mixin/]: Error loading class: vectorwing/farmersdelight/common/block/TomatoVineBlock (java.lang.ClassNotFoundException: vectorwing.farmersdelight.common.block.TomatoVineBlock) [19:34:01] [main/WARN] [mixin/]: @Mixin target vectorwing.farmersdelight.common.block.TomatoVineBlock was not found supplementaries.mixins.json:CompatFarmersDelightMixin [19:34:02] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/util/Map$Entry (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/util/Map$Entry (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/util/Map$Entry (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/util/Map$Entry (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:02] [main/WARN] [mixin/]: Error loading class: java/util/Map$Entry (java.lang.IllegalArgumentException: Unsupported class file major version 64) [19:34:03] [main/WARN] [mixin/]: Error loading class: java/lang/NullPointerException (java.lang.IllegalArgumentException: Unsupported class file major version 64) Exception in thread "main" java.lang.RuntimeException: org.spongepowered.asm.mixin.transformer.throwables.MixinTransformerError: An unexpected critical error was encountered         at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:32)         at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53)         at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71)         at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.Launcher.run(Launcher.java:106)         at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.Launcher.main(Launcher.java:77)         at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26)         at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23)         at cpw.mods.bootstraplauncher@1.1.2/cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:141) Caused by: org.spongepowered.asm.mixin.transformer.throwables.MixinTransformerError: An unexpected critical error was encountered         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:392)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClass(MixinTransformer.java:250)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.service.modlauncher.MixinTransformationHandler.processClass(MixinTransformationHandler.java:131)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.launch.MixinLaunchPluginLegacy.processClass(MixinLaunchPluginLegacy.java:131)         at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.serviceapi.ILaunchPluginService.processClassWithFlags(ILaunchPluginService.java:156)         at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.LaunchPluginHandler.offerClassNodeToPlugins(LaunchPluginHandler.java:88)         at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.ClassTransformer.transform(ClassTransformer.java:120)         at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.TransformingClassLoader.maybeTransformClassBytes(TransformingClassLoader.java:50)         at cpw.mods.securejarhandler/cpw.mods.cl.ModuleClassLoader.readerToClass(ModuleClassLoader.java:113)         at cpw.mods.securejarhandler/cpw.mods.cl.ModuleClassLoader.lambda$findClass$15(ModuleClassLoader.java:219)         at cpw.mods.securejarhandler/cpw.mods.cl.ModuleClassLoader.loadFromModule(ModuleClassLoader.java:229)         at cpw.mods.securejarhandler/cpw.mods.cl.ModuleClassLoader.findClass(ModuleClassLoader.java:219)         at cpw.mods.securejarhandler/cpw.mods.cl.ModuleClassLoader.loadClass(ModuleClassLoader.java:135)         at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)         at java.base/java.lang.Class.getDeclaredMethods0(Native Method)         at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3502)         at java.base/java.lang.Class.getMethodsRecursive(Class.java:3643)         at java.base/java.lang.Class.getMethod0(Class.java:3629)         at java.base/java.lang.Class.getMethod(Class.java:2319)         at MC-BOOTSTRAP/fmlloader@1.19.2-43.2.13/net.minecraftforge.fml.loading.targets.CommonServerLaunchHandler.lambda$launchService$0(CommonServerLaunchHandler.java:29)         at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:30)         ... 7 more Caused by: org.spongepowered.asm.mixin.throwables.ClassMetadataNotFoundException: java.lang.NullPointerException         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.transformMethod(MixinPreProcessorStandard.java:754)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.transform(MixinPreProcessorStandard.java:739)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.attach(MixinPreProcessorStandard.java:310)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.createContextFor(MixinPreProcessorStandard.java:280)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinInfo.createContextFor(MixinInfo.java:1288)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.apply(MixinApplicatorStandard.java:292)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.TargetClassContext.apply(TargetClassContext.java:383)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.TargetClassContext.applyMixins(TargetClassContext.java:365)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:363)         ... 27 more
  • Topics

×
×
  • Create New...

Important Information

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