Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Role of ClientProxy and CommonProxy classes?


Recommended Posts

Hello Forge people,


I have had a very hard time understanding the role of the Common Proxy and Client Proxy Code that are frequently recommended in Forge Modding tutorials.


The code I'm referring to goes in the Main mod file that looks like this:


@SidedProxy(clientSide = "mymod.proxies.ClientProxy", serverSide = "mymod.proxies.CommonProxy")

public static CommonProxy proxy;


These refer to pretty much empty java classes named "ClientProxy" and "CommonProxy"


I have gone blindly forward and included them in my mod, but they don't seem to be doing anything.

When I remove them, nothing happens... Everything still seems to work fine!


So my questions are:

1. If they can be removed with no consequences, what exactly are those classes doing?

2. Am I making a rookie mistake by removing them?


Thanks in advance!

Link to comment
Share on other sites

The SidedProxy system allows you to call client-only code from common classes. For example: Your Item class exists on both client and server. But any rendering code only exists on the client, so you can't call it from your Item (because that would crash on the server). So you make a method in your Proxy that does the rendering stuff on the client (ClientProxy) and does nothing on the server (CommonProxy). That way you only ever reference the CommonProxy.

Also: CommonProxy and ClientProxy are the worst names for these things. Nothing about the CommonProxy is "common". Also I would name the thing Environment.

Neither should ClientProxy extend CommonProxy.

The way I personally do it is make an interface "MyModEnvironment" which contains all the methods. Then make a ClientEnvironment and a ServerEnvironment. On the server side your proxy field will be filled with the ServerEnvironment, on the client it will be filled with the ClientEnvironment.

Hope that makes any sense :D

Link to comment
Share on other sites

Typically, the name 'Common' is used because the client and server are integrated.

So the normal setup is 'ClientProxy extends CommonProxy' with almost every function calling it's super. So the server part gets called as well as the client part.

Hence.. common. But yes, this is, if you use it correctly, a pretty elegant way of dealing with the fact that Minecraft is obfusicated, and stripped. Meaning that a lot of classes/fields/functions don't exist on one side or the other. As long as you wrap those functions in your proxy you should never have a ClassNotFoundException or NoMethodException.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Patreon: http://www.patreon.com/lexmanos
Paypal: http://paypal.me/LexManos

BitCoin: 1Q8rWvUNMM2T1ZfDaFeeYQyVXtYoeT6tTn

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

    • I'm new to modding and I want to do this. What class would I put that in?
    • That is a different crash report. Please post the debug.log file from the logs folder.
    • [22Jan.2022 18:41:22.485] [Server thread/ERROR] [net.minecraftforge.eventbus.EventBus/EVENTBUS]: Exception caught during firing event: 'net.minecraft.nbt.CompoundTag net.minecraft.world.level.block.entity.SignBlockEntity.save(net.minecraft.nbt.CompoundTag)'     Index: 4     Listeners:         0: HIGH         1: ASM: class dev.architectury.event.forge.EventHandlerImplCommon event(Lnet/minecraftforge/event/server/ServerStartingEvent;)V         2: NORMAL         3: ASM: cyclopscore onServerStarting(Lnet/minecraftforge/event/server/ServerStartingEvent;)V         4: ASM: chanceCubes.CCubesCore@5b77fda6 serverStart(Lnet/minecraftforge/event/server/ServerStartingEvent;)V         5: ASM: mods.waterstrainer.event.EventServerStarting@2dc1913f onServerStarting(Lnet/minecraftforge/event/server/ServerStartingEvent;)V         6: ASM: com.song.castle_in_the_sky.CastleInTheSky@1f8c253d onServerStarting(Lnet/minecraftforge/event/server/ServerStartingEvent;)V         7: ASM: se.mickelus.tetra.TetraMod@203a3089 serverStarting(Lnet/minecraftforge/event/server/ServerStartingEvent;)V         8: net.minecraftforge.eventbus.EventBus$$Lambda$4325/0x0000000800c57770@71737087         9: ASM: de.teamlapen.vampirism.VampirismMod@1213b1b onServerStart(Lnet/minecraftforge/event/server/ServerStartingEvent;)V         10: net.minecraftforge.eventbus.EventBus$$Lambda$4325/0x0000000800c57770@1a894d2d         11: net.minecraftforge.eventbus.EventBus$$Lambda$4325/0x0000000800c57770@3deb329 java.lang.NoSuchMethodError: 'net.minecraft.nbt.CompoundTag net.minecraft.world.level.block.entity.SignBlockEntity.save(net.minecraft.nbt.CompoundTag)'     at TRANSFORMER/chancecubes@1.18.1-     at TRANSFORMER/chancecubes@1.18.1-     at net.minecraftforge.eventbus.ASMEventHandler_101_CCubesCore_serverStart_ServerStartingEvent.invoke(.dynamic)     at MC-BOOTSTRAP/eventbus@5.0.3/net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:85)     at MC-BOOTSTRAP/eventbus@5.0.3/net.minecraftforge.eventbus.EventBus.post(EventBus.java:302)     at MC-BOOTSTRAP/eventbus@5.0.3/net.minecraftforge.eventbus.EventBus.post(EventBus.java:283)     at TRANSFORMER/forge@39.0.56/net.minecraftforge.server.ServerLifecycleHooks.handleServerStarting(ServerLifecycleHooks.java:102)     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)     at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     at java.base/java.lang.reflect.Method.invoke(Method.java:568)     at TRANSFORMER/net.optifine/net.optifine.reflect.Reflector.callBoolean(Reflector.java:702)     at TRANSFORMER/minecraft@1.18.1/net.minecraft.client.server.IntegratedServer.m_7038_(IntegratedServer.java:90)     at TRANSFORMER/minecraft@1.18.1/net.minecraft.server.MinecraftServer.m_130011_(MinecraftServer.java:644)     at TRANSFORMER/minecraft@1.18.1/net.minecraft.server.MinecraftServer.m_177918_(MinecraftServer.java:258)     at java.base/java.lang.Thread.run(Thread.java:833) [22Jan.2022 18:41:22.509] [Server thread/DEBUG] [mixin/]: Mixing MixinChunkSerializer from architectury.mixins.json into net.minecraft.world.level.chunk.storage.ChunkSerializer [22Jan.2022 18:41:28.076] [Server thread/DEBUG] [net.minecraftforge.fml.loading.FileUtils/CORE]: Found existing serverconfig directory : C:\Users\UTW\AppData\Roaming\.minecraft\saves\New World\serverconfig [22Jan.2022 18:41:28.076] [Server thread/DEBUG] [net.minecraftforge.fml.config.ConfigTracker/CONFIG]: Unloading configs type SERVER Sry if its not the right one, im pretty new at Forge
    • I have a modded server that worked before I changed the config for SereneSeasons (made the seasons longer and turned off offline season progression). Now it just gives said error message, even after reverting the changes.
  • Topics

  • Who's Online (See full list)

  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.