Posted January 19, 20187 yr I am trying to render some information on screen for the players and I need to get some data from the scoreboard. The following code works fine in Single player but not on a server. What do I need to do to make this work when playing on a server? ManaBar public class ManaBar extends GuiIngame { public ManaBar(Minecraft mcIn) { super(mcIn); } private static final ResourceLocation texturepath = new ResourceLocation("vmod","textures/gui/mana_bar.png"); private int mana; private int maxMana; @SubscribeEvent public void onTick(PlayerTickEvent event) { EntityPlayer player = event.player; World world = player.getEntityWorld(); if(!world.isRemote){ MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); Scoreboard sb = world.getScoreboard(); mana = sb.getOrCreateScore(player.getName(),sb.getObjective("mana")).getScorePoints(); maxMana = sb.getOrCreateScore(player.getName(),sb.getObjective("maxMana")).getScorePoints(); } } ClientProxy public class ClientProxy extends CommonProxy { @Override public void init() { ModItems.registerRenders(); ModBlocks.registerRenders(); MinecraftForge.EVENT_BUS.register(new ManaBar(Minecraft.getMinecraft())); } }
January 19, 20187 yr This would: 15 minutes ago, vin0m said: MinecraftForge.EVENT_BUS.register(new ManaBar(Minecraft.getMinecraft())); This code only runs client side (good, its in your client proxy) but this: 15 minutes ago, vin0m said: MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); Is server side only. Also, why are you not using Capabilities? Edited January 19, 20187 yr by Draco18s Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
January 20, 20187 yr Author On 1/18/2018 at 9:10 PM, Draco18s said: Also, why are you not using Capabilities? I got it working with Capabilities, thank you.
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.