作为一个联机Mod
代理类是重要的
在Forge里一个Mod最完美的状态就是不区分客户端mod和服务端mod
服务端Mod可以粗略理解为没有渲染,GUI和纹理的客户端Mod
所以我们只要想办法让Mod在服务端不加载纹理什么的就好了
这时我们就要通过代理类来实现~
首先,右键snowmiku.RPG包来创建一个名为RPGCommonProxy的类
然后添加
/*** 执行第1阶段的加载行为。*/public void preInit() {}
/*** 执行第2阶段的加载行为。*/public void init() {}
/*** 执行第3阶段的加载行为。*/public void postInit() {}
这时你的class应该是这个样子的:

然后再右键snowmiku.RPG包来新建一个名为RPGClientProxy的类

并让其继承(extends)RPGCommonProxy类
<知识点:继承(extends)的用法是“在class名后加extends再加父类名”,举个栗子!上面那一步的操作应该是在“public class RPGClientProxy”后加上“extends RPGCommonProxy”;继承的类称为子类,被继承的类称为父类,子类拥有父类的所有方法(函数),也可以通过????????重写????????(Override)来重新定义方法>
然后在类中添加:
public void preInit() {super.preInit();}
public void init() {super.init();}
public void postInit() {super.postInit();}
这时你的RPGClientProxy类应该是这样的:

然后,我们需要回到mod_RPG类中打上注解(2014.7.3更正):
@SidedProxy(clientSide = "snowmiku.RPG.RPGClientProxy",serverSide = "snowmiku.RPG.RPGCommonProxy")
并添加静态字段:
public static RPGCommonProxy proxy;
然后你的Eclipse会报错,我们把鼠标移到波浪线处来导入相关类(以后请自行导入):

这时你的Mod主类应该是这样的:

注意以后窝说的在mod主类中添加xxx都是指在上图红色方框处添加!
OK,你已经成功的为mod添加了代理类~
2021.12 数据,可能有更多内容
作为一个联机Mod代理类是重要的在Forge里一个Mod最完美的状态就是不区分客户端mod和服务端mod服务端Mod可以粗略理解为没有渲染,GUI和纹理的客户端Mod所以我们只要想办法让Mod在服务端不加载纹理什么的就好了这时我们就要通过代理类来实现~首先,右键snowmiku.RPG包来创建一个名为RPGCommonProxy的类然后添加
/** * 执行第1阶段的加载行为。 */ public void preInit() {}
/** * 执行第2阶段的加载行为。 */ public void init() {}
/** * 执行第3阶段的加载行为。 */ public void postInit() {}
这时你的class应该是这个样子的:

然后再右键snowmiku.RPG包来新建一个名为RPGClientProxy的类

并让其继承(extends)RPGCommonProxy类<知识点:继承(extends)的用法是“在class名后加extends再加父类名”,举个栗子!上面那一步的操作应该是在“public class RPGClientProxy”后加上“extends RPGCommonProxy”;继承的类称为子类,被继承的类称为父类,子类拥有父类的所有方法(函数),也可以通过????????重写????????(Override)来重新定义方法>
然后在类中添加: public void preInit() { super.preInit(); }
public void init() { super.init(); }
public void postInit() { super.postInit(); }
这时你的RPGClientProxy类应该是这样的:

然后,我们需要回到mod_RPG类中打上注解(2014.7.3更正):@SidedProxy( clientSide = "snowmiku.RPG.RPGClientProxy", serverSide = "snowmiku.RPG.RPGCommonProxy" )并添加静态字段:public static RPGCommonProxy proxy;
然后你的Eclipse会报错,我们把鼠标移到波浪线处来导入相关类(以后请自行导入):

这时你的Mod主类应该是这样的:

注意以后窝说的在mod主类中添加xxx都是指在上图红色方框处添加!
OK,你已经成功的为mod添加了代理类~
图挂了
我这里没有挂啊= =?
音の贤者 发表于 2014-7-19 09:36
我这里没有挂啊= =?
好吧挂了....
不明觉厉...
音の贤者 发表于 2014-7-19 09:36
我这里没有挂啊= =?
← ←上传图片可用左上方工具内图床