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

I need to execute some code when the player switches his armor. But the LivingEquipmentChangeEvent is only server side and i need to do my stuff client side. So is there a way to run my stuff client side when the LivingEquipmentChangeEvent is fired?

  • Author

I tried sending a packet and it is recieved on the client.

public class MessageHandlerBD implements IMessageHandler<MessageBD, IMessage> {

	@Override
	public IMessage onMessage(MessageBD messageBD, MessageContext ctx) {
		System.out.println("PACKET");
		return null;
	}

}

But instead of just writing PACKET in the client log, I want to do something with my Capability on the client side. But when i try it the game always is crashing

	@Override
	public IMessage onMessage(MessageBD messageBD, MessageContext ctx) {
		ctx.getServerHandler().player.getCapability(DiveSpeedProvider.DIVESPEED, null).updateDiveSpeed(ctx.getServerHandler().player);
		return null;
	}

 

  • Author

I also thought that the getServerHandler isn't working on client side. But how can I access the Player object on the client side?

  • Author
14 minutes ago, diesieben07 said:

The client player is always Minecraft#player.

Ok. I feel like that was pretty obvious. Thanks for the help.

 

15 minutes ago, diesieben07 said:

Note that you will need to encapsulate this access to client-only classes through @SidedProxy.

But I don't know what you mean with that.

  • Author

Ok, I now registered the Packet in my ClientProxy

public class ClientProxy implements CommonProxy {
	
	@Override
	public void init() {
		BetterDiving.INSTANCE.registerMessage(MessageHandlerBD.class, MessageBD.class, 0, Side.CLIENT);
	}
}

But once i switch armor on a server nothing happens and on the server i get this message: Undefined discriminator for message type MessageBD in channel better_diving

  • Author

Now I created a MessageHandlerBDDummy class and I'm calling this in my ServerProxy

BetterDiving.INSTANCE.registerMessage(MessageHandlerBDDummy.class, MessageBD.class, 0, Side.SERVER);

The MessageHandlyerBDDummy class isn't doing something when receiving a packet. And everything seems to work know. Thank you for the help. If there is a better way of solving my issue you can say it.

20 hours ago, Meldexun said:

CommonProxy

A common proxy doesn’t make sense, proxies are for separating side specific code i.e. code that will crash when executed on the wrong side. A proxy by definition cannot be common. Common code goes anywhere except for in a proxy

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

  • Author
1 hour ago, diesieben07 said:

The packet must be registered on both sides, no reason to do that through your proxy.

Only the packet action must be encapsulated.

Ok. That makes sense. I will try to do that.

 

13 minutes ago, Cadiboo said:

A common proxy doesn’t make sense, proxies are for separating side specific code i.e. code that will crash when executed on the wrong side. A proxy by definition cannot be common. Common code goes anywhere except for in a proxy

It's just the name of the interface. I have just followed a tutorial for modding beginning and there it was named common proxy. I'm not doing something in this interface.

3 minutes ago, Meldexun said:

It's just the name of the interface. I have just followed a tutorial for modding beginning and there it was named common proxy. I'm not doing something in this interface.

Great! IProxy is the conventional name for it though

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

  • Author
1 hour ago, diesieben07 said:

The packet must be registered on both sides, no reason to do that through your proxy.

Only the packet action must be encapsulated.

I now check in my MessageHandler if the message is recieved client side and it seems to work.

	@Override
	public IMessage onMessage(MessageCapabilitySync messageCapabilitySync, MessageContext ctx) {
		if (ctx.side.isClient()) {
			//do some stuff
		}
		return null;
	}

I tried that before but then it was crashing all the time. Thats why I used the proxy to register my message.

 

17 minutes ago, Cadiboo said:

Great! IProxy is the conventional name for it though

I also noticed that most people name it IProxy. Maybe I will change it too.

  • Author
8 minutes ago, diesieben07 said:

The condition is pointless, you know which side you sent the packet do.

The "do some stuff" part must be in your client proxy though, like I initially mentioned.

So I just create a method in my Client proxy which is than called by the MessageHandler.

	@Override
	public IMessage onMessage(MessageCapabilitySync messageCapabilitySync, MessageContext ctx) {
		ClientProxy.message1(messageCapabilitySync, ctx);
		return null;
	}

 

Directly calling something on ClientProxy defeats its purpose IIRC, You need to call the method from your proxy instance

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

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.