Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Eya, I need some help to add capabilities to the player.

I want just to add simple NBT to the player, like booleans and int, no more, but I've been searching for information since 1 or 2 weeks ago and every guide or github do the capabilities different, i've seen like 6 differents forms or more to do the capabilities but i dont understand it, some people make only 1 class, others makes like 8...

So, I hope if anybody can give me a little example and can explain it a bit to me, thanks!

  • Author
2 hours ago, Luis_ST said:

you can take a look at the doc or at this example

A lot of this code is not working, are you sure that is for 1.16.5?

Edited by Zanckor

  • Author
5 minutes ago, Luis_ST said:

it's for 1.18 but the doc exists for 1.16, also show your code and define 'not working'

well, a lot of code errors, but if its for 1.18 that explains all xD

where is your CapabilityProvider, also i would recommend you to ignore the CapabilityStorage since it's unused

  • Author

K, tnks, so, i need to add the provider and delete storage?

 

Btw, what do the storage??

  • Author

okay, i done everything but still dont works

 

when i try to open the game to test the capabilities it crash... there's my code and crash-log:

 

code:

https://github.com/Zanckor/mmorpg

 

crash-log:


 

Quote

 

Description: Ticking player

java.lang.ClassFormatError: Illegal field modifiers in class com/mod/capabilities/Capabilities: 0x1009
    at java.lang.ClassLoader.defineClass1(Native Method) ~[?:1.8.0_231] {}
    at java.lang.ClassLoader.defineClass(ClassLoader.java:756) ~[?:1.8.0_231] {}
    at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:138) ~[modlauncher-8.0.9.jar:?] {re:classloading}
    at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:98) ~[modlauncher-8.0.9.jar:?] {re:classloading}
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[?:1.8.0_231] {}
    at com.mod.handlers.ModEventHandler.onPlayerTick(ModEventHandler.java:33) ~[main/:?] {re:classloading}
    at net.minecraftforge.eventbus.ASMEventHandler_4_ModEventHandler_onPlayerTick_PlayerTickEvent.invoke(.dynamic) ~[?:?] {}
    at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:85) ~[eventbus-4.0.0.jar:?] {}
    at net.minecraftforge.eventbus.EventBus.post(EventBus.java:302) ~[eventbus-4.0.0.jar:?] {}
    at net.minecraftforge.eventbus.EventBus.post(EventBus.java:283) ~[eventbus-4.0.0.jar:?] {}
    at net.minecraftforge.fml.hooks.BasicEventHooks.onPlayerPreTick(BasicEventHooks.java:85) ~[forge:?] {re:classloading}
    at net.minecraft.entity.player.PlayerEntity.tick(PlayerEntity.java:196) ~[forge:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.entity.player.ServerPlayerEntity.doTick(ServerPlayerEntity.java:404) ~[forge:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.network.play.ServerPlayNetHandler.tick(ServerPlayNetHandler.java:207) ~[forge:?] {re:classloading}
    at net.minecraft.network.NetworkManager.tick(NetworkManager.java:226) ~[forge:?] {re:classloading}
    at net.minecraft.network.NetworkSystem.tick(NetworkSystem.java:134) ~[forge:?] {re:classloading}
    at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:865) ~[forge:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:787) ~[forge:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.server.integrated.IntegratedServer.tickServer(IntegratedServer.java:78) ~[forge:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:642) ~[forge:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:232) ~[forge:?] {re:classloading,pl:accesstransformer:B}
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_231] {}


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Server thread
Stacktrace:
    at java.lang.ClassLoader.defineClass1(Native Method) ~[?:1.8.0_231] {}
    at java.lang.ClassLoader.defineClass(ClassLoader.java:756) ~[?:1.8.0_231] {}
    at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:138) ~[modlauncher-8.0.9.jar:?] {re:classloading}
    at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:98) ~[modlauncher-8.0.9.jar:?] {re:classloading}
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[?:1.8.0_231] {}
    at com.mod.handlers.ModEventHandler.onPlayerTick(ModEventHandler.java:33) ~[main/:?] {re:classloading}
    at net.minecraftforge.eventbus.ASMEventHandler_4_ModEventHandler_onPlayerTick_PlayerTickEvent.invoke(.dynamic) ~[?:?] {}
    at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:85) ~[eventbus-4.0.0.jar:?] {}
    at net.minecraftforge.eventbus.EventBus.post(EventBus.java:302) ~[eventbus-4.0.0.jar:?] {}
    at net.minecraftforge.eventbus.EventBus.post(EventBus.java:283) ~[eventbus-4.0.0.jar:?] {}
    at net.minecraftforge.fml.hooks.BasicEventHooks.onPlayerPreTick(BasicEventHooks.java:85) ~[forge:?] {re:classloading}
    at net.minecraft.entity.player.PlayerEntity.tick(PlayerEntity.java:196) ~[forge:?] {re:classloading,pl:accesstransformer:B}
-- Player being ticked --
Details:
    Entity Type: minecraft:player (net.minecraft.entity.player.ServerPlayerEntity)
    Entity ID: 152
    Entity Name: Dev
    Entity's Exact location: -170.74, 66.00, -81.88
    Entity's Block location: World: (-171,66,-82), Chunk: (at 5,4,14 in -11,-6; contains blocks -176,0,-96 to -161,255,-81), Region: (-1,-1; contains chunks -32,-32 to -1,-1, blocks -512,0,-512 to -1,255,-1)
    Entity's Momentum: 0.00, -0.08, 0.00
    Entity's Passengers: []
    Entity's Vehicle: ~~ERROR~~ NullPointerException: null
Stacktrace:
    at net.minecraft.entity.player.ServerPlayerEntity.doTick(ServerPlayerEntity.java:404) ~[forge:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.network.play.ServerPlayNetHandler.tick(ServerPlayNetHandler.java:207) ~[forge:?] {re:classloading}
    at net.minecraft.network.NetworkManager.tick(NetworkManager.java:226) ~[forge:?] {re:classloading}
    at net.minecraft.network.NetworkSystem.tick(NetworkSystem.java:134) ~[forge:?] {re:classloading}
    at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:865) ~[forge:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:787) ~[forge:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.server.integrated.IntegratedServer.tickServer(IntegratedServer.java:78) ~[forge:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:642) ~[forge:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:232) ~[forge:?] {re:classloading,pl:accesstransformer:B}
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_231] {}

 

 

  • Author
1 hour ago, diesieben07 said:

Make sure you are using Java 8 for both compiling and running the game.

where can i check it?

 

  • Author
4 minutes ago, diesieben07 said:

What IDE are you using and how are you starting the game?

I'm using Eclipse, and to start it i just go to the icon "Start" and select the option runClient

 

  • Author

Maybe is my gradle? Cause it shows me this error:

 

"Could not run phased build action using a connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-6.8.1-all.zip'.

  • Author

Okay, i'm idiot, i put the capabilities.class like interface xD, so, how can i get the capabilitie now? like, make a player.getMana()

 

And, btw, i read that i need to send the information from the server to the client when i change my capabilities, how can i make it?

Player#getCapability

Quote

And, btw, i read that i need to send the information from the server to the client when i change my capabilities, how can i make it?

you need a custom Network Packet (Message) and a SimpleChannel, you can read the doc

Edited by Luis_ST

  • Author

Mhh, when i try to access to them it crash me.

 

My github:

https://github.com/Zanckor/mmorpg

 

Crash:

 

Time: 20/02/22 18:16 Description: Ticking memory connection java.lang.NullPointerException: Ticking memory connection at com.mod.capabilities.MyCapabilityProvider.<init>(MyCapabilityProvider.java:11) ~[main/:?] {re:classloading} at com.mod.capabilities.Capabilities.attachCapabilities(Capabilities.java:31) ~[main/:?] {re:classloading,pl:capability_inject_definalize:A} at net.minecraftforge.eventbus.ASMEventHandler_3_Capabilities_attachCapabilities_AttachCapabilitiesEvent.invoke(.dynamic) ~[?:?] {} at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:85) ~[eventbus-4.0.0.jar:?] {} at net.minecraftforge.eventbus.EventBus.post(EventBus.java:302) ~[eventbus-4.0.0.jar:?] {} at net.minecraftforge.eventbus.EventBus.post(EventBus.java:283) ~[eventbus-4.0.0.jar:?] {} at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:579) ~[forge:?] {re:classloading} at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:573) ~[forge:?] {re:classloading} at net.minecraftforge.common.capabilities.CapabilityProvider.gatherCapabilities(CapabilityProvider.java:48) ~[forge:?] {re:classloading} at net.minecraftforge.common.capabilities.CapabilityProvider.gatherCapabilities(CapabilityProvider.java:44) ~[forge:?] {re:classloading} at net.minecraft.entity.Entity.<init>(Entity.java:221) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.entity.LivingEntity.<init>(LivingEntity.java:205) ~[forge:?] {re:classloading} at net.minecraft.entity.player.PlayerEntity.<init>(PlayerEntity.java:159) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.entity.player.ServerPlayerEntity.<init>(ServerPlayerEntity.java:179) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.management.PlayerList.getPlayerForLogin(PlayerList.java:406) ~[forge:?] {re:classloading} at net.minecraft.network.login.ServerLoginNetHandler.handleAcceptedLogin(ServerLoginNetHandler.java:118) ~[forge:?] {re:classloading} at net.minecraft.network.login.ServerLoginNetHandler.tick(ServerLoginNetHandler.java:65) ~[forge:?] {re:classloading} at net.minecraft.network.NetworkManager.tick(NetworkManager.java:222) ~[forge:?] {re:classloading} at net.minecraft.network.NetworkSystem.tick(NetworkSystem.java:134) ~[forge:?] {re:classloading} at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:865) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:787) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.integrated.IntegratedServer.tickServer(IntegratedServer.java:78) ~[forge:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:642) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:232) ~[forge:?] {re:classloading,pl:accesstransformer:B} at java.lang.Thread.run(Thread.java:748) [?:1.8.0_231] {}

Edited by Zanckor

  • Author

There's any way to send the capaiblities from PlayerTickEvent and save them into Server side without packets?

Edited by Zanckor

no, you need a custom Packet if you want to send data from server to client

15 hours ago, Zanckor said:

send the capaiblities from PlayerTickEvent

this is a terrible idea, do not send data each tick, send the data only if it changed

Edited by Luis_ST

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.