And all of those examples are terrible. Because all three of those things are main mod class tasks.
Check out this and this instead. Or even better, this.
Yes. That's how proxies work.
From what I see in the examples I've found, proxies are basically used for preInitialization, Inizialization, and postInizialization tasks.
Here I've got an Item class, with method onItemRightClick() that should perform different things based on the game mode (multiplayer vs. singleplayer).
How would I take advantage of the sided proxies to refactor the following class? Should I have two classes, one for the client, the other for the dedicated server, and register the first class on the client, and the second on the dedicated server?
I'm confused and basically stuck.
public class ScriptItem extends Item {
// [...]
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
// [...]
String separator = getSeparator();
if (world.isRemote) {
// client side
if (!Minecraft.getMinecraft().isSingleplayer()) {
// client talks to dedicated server (multiplayer game)
String scriptName = nbtTagCompound.getString("scriptName");
ClientCommandHandler.instance.executeCommand(player,
"/lpython " + "pythontool" + separator + scriptName);
}
} else {
// server side
if (!FMLCommonHandler.instance().getMinecraftServerInstance().isDedicatedServer()) {
// server is integrated (singleplayer game)
String scriptName = nbtTagCompound.getString("scriptName");
world.getMinecraftServer().getCommandManager().executeCommand(player,
"/python " + "pythontool" + separator + scriptName);
}
}
}
When I try to launch forge, there are roughly 20 seconds when it might work and then the Minecraft launcher shows up saying that there was an unexpected issue and the game crashed. I can't seem to get a crash report and I don't know what to do!