So I have a mod and I was taught how to make it by Youth Digital. Alright, I want to make a server but they wont tell me how to make a proxy for a server and stuff. I researched and I found out how to make a proxy and now I would like to know what stuff to add to it. Here is a pastebin of my main class http://pastebin.com/yEYYwEh6
Ok I changed it but I would like to know what stuff I need to add to put into the proxy, as im pretty sure i added all the entities. Or if I added some unnecessary stuff. Here is everything I added to the proxy.
public void RegisterRandomStuff() {
LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_1", "en_US", "You Have Been Playing For a While");
LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_1.desc", "en_US", "Achieve Mega Stone");
LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_2", "en_US", "Nio Goodness");
LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_2.desc", "en_US", "Aquire a Nio Block");
LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_3", "en_US", "Bacon, YEAH!");
LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_3.desc", "en_US", "Get Bacon From 1 Cooked Porkchop and 2 Raw Porkchops");
LanguageRegistry.instance().addStringLocalization("itemGroup.MyCreativeTab_1", "en_US", "InfiniCraft");
RenderingRegistry.registerEntityRenderingHandler(MyEntityAbe.class, new MyRenderAbe(new MyModelAbe(), 0.3F));
RenderingRegistry.registerEntityRenderingHandler(MyEntityOgre.class, new MyRenderOgre(new MyModelOgre(), 0.3F));
RenderingRegistry.registerEntityRenderingHandler(EntityBeardedDragon.class, new RenderBeardedDragon(new ModelBeardedDragon(), 0.3F));
Proxies are a helper for stuff that should only run on client side, server side or both. Take this example in my CommonProxy:
public class CommonProxy {
public void preInit(FMLPreInitializationEvent event) {
}
public void init(FMLInitializationEvent event) {
}
public void postInit(FMLPostInitializationEvent event) {
MinecraftForge.EVENT_BUS.register(new EntityEvents());
MinecraftForge.EVENT_BUS.register(new WorldEvents());
FMLCommonHandler.instance().bus().register(new WorldTickEvents());
}
public void openJournal(EntityPlayer player) {
}
public EntityPlayer getPlayerFromMessageContext(MessageContext ctx) {
switch(ctx.side) {
case CLIENT:
assert false : "Message for CLIENT received on dedicated server";
break;
case SERVER:
EntityPlayer entityPlayerMP = ctx.getServerHandler().playerEntity;
return entityPlayerMP;
default:
assert false : "Invalid side in TestMsgHandler: " + ctx.side;
}
return null;
}
}
Being in the common proxy, this is stuff that I want to run on the server but not the client. openJournal here is blank, but in my client proxy it is overridden and actually opens a GUI. getPlayerFromMessageContext is a helper for Packets, it is also overridden in client proxy:
public class ClientProxy extends CommonProxy {
@Override
public void preInit(FMLPreInitializationEvent event) {
super.preInit(event);
// register custom renderers
ModRenderers.registerAll();
}
@Override
public void init(FMLInitializationEvent event) {
super.init(event);
}
@Override
public void postInit(FMLPostInitializationEvent event) {
super.postInit(event);
MinecraftForge.EVENT_BUS.register(new GuiCompass(Minecraft.getMinecraft()));
}
@Override
public void openJournal(EntityPlayer player) {
// client-only hook command for when user presses right-click on their Journal (called from the Journal item class)
// remember - getMinecraft() only exists in the client!
Minecraft.getMinecraft().displayGuiScreen(new GuiLog(player));
}
@Override
public EntityPlayer getPlayerFromMessageContext(MessageContext ctx) {
switch(ctx.side) {
case CLIENT:
EntityPlayer entityClientPlayerMP = Minecraft.getMinecraft().thePlayer;
return entityClientPlayerMP;
case SERVER:
EntityPlayer entityPlayerMP = ctx.getServerHandler().playerEntity;
return entityPlayerMP;
default:
assert false : "Invalid side in TestMsgHandler: " + ctx.side;
}
return null;
}
}
As for block/recipe/item registration, they should stay in your main class - because both the client and server needs them. I think, that's the way I understand it anyway (even though CommonProxy name suggests otherwise, but the ClientProxy overrides all the CommonProxy methods with it's own stuff).
You don't need to add anything, nor do you even need CommonProxy and ClientProxy classes; they merely assist in running code that should only be run on one side or the other, but if you call "super.someMethod" in your ClientProxy it will also run the code in the CommonProxy.someMethod method, but on the client side.
Otherwise, you need to check the side yourself before you do things like register render classes.
Basically, you register renderers, Gui overlays, KeyBindings, and other client-side only things in the ClientProxy, and everything else you stick in your main mod class or wherever else suits your fancy, but wherever you put the rest of your code should be running on the server (doesn't matter if it also runs client side or not, generally).
What are you doing using the LanguageRegistry still, btw? That has long since been deprecated in favor of using an actual language file, e.g. en_US.lang.
I took classes from Youth Digital and thats how they set it up. I just looked at and did what he said. I had to add stuff to the proxy.
I did what this guy said. it worked for him and I did the same thing
Thanks! Any help is appreciated!
you need a common proxy too..
Art by me: MrPancakeWolfie@DeviantArt
Art by me: MrPancakeWolfie@DeviantArt
public void RegisterRandomStuff() {
LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_1", "en_US", "You Have Been Playing For a While");
LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_1.desc", "en_US", "Achieve Mega Stone");
LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_2", "en_US", "Nio Goodness");
LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_2.desc", "en_US", "Aquire a Nio Block");
LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_3", "en_US", "Bacon, YEAH!");
LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_3.desc", "en_US", "Get Bacon From 1 Cooked Porkchop and 2 Raw Porkchops");
LanguageRegistry.instance().addStringLocalization("itemGroup.MyCreativeTab_1", "en_US", "InfiniCraft");
RenderingRegistry.registerEntityRenderingHandler(MyEntityAbe.class, new MyRenderAbe(new MyModelAbe(), 0.3F));
RenderingRegistry.registerEntityRenderingHandler(MyEntityOgre.class, new MyRenderOgre(new MyModelOgre(), 0.3F));
RenderingRegistry.registerEntityRenderingHandler(EntityBeardedDragon.class, new RenderBeardedDragon(new ModelBeardedDragon(), 0.3F));
Being in the common proxy, this is stuff that I want to run on the server but not the client. openJournal here is blank, but in my client proxy it is overridden and actually opens a GUI. getPlayerFromMessageContext is a helper for Packets, it is also overridden in client proxy:
As for block/recipe/item registration, they should stay in your main class - because both the client and server needs them. I think, that's the way I understand it anyway (even though CommonProxy name suggests otherwise, but the ClientProxy overrides all the CommonProxy methods with it's own stuff).
Otherwise, you need to check the side yourself before you do things like register render classes.
Basically, you register renderers, Gui overlays, KeyBindings, and other client-side only things in the ClientProxy, and everything else you stick in your main mod class or wherever else suits your fancy, but wherever you put the rest of your code should be running on the server (doesn't matter if it also runs client side or not, generally).
What are you doing using the LanguageRegistry still, btw? That has long since been deprecated in favor of using an actual language file, e.g. en_US.lang.
I did what this guy said. it worked for him and I did the same thing