Jump to content

teh_black_d00m

Members
  • Posts

    9
  • Joined

  • Last visited

Everything posted by teh_black_d00m

  1. I did that because I thought that's what you're supposed to do to send a packet (put the code into a class that implements IMessage and IMessageHandler) but maybe I'm still not quite understanding packets correctly. So for the example of restoring the player's fatigue I need to use that MessageRestoreFatigue class to send a packet right? I'm not sure of the correctly terminology here but I think I'm supposed to be sending data between the client and server so they are synced. Should I be using the toBytes and fromBytes methods to just send the data instead of doing what I did in the example (moving all the code into MessageRestoreFatigue)?
  2. I mean to say that I moved that code I posted earlier so that its here now And then I did this I know it worked because it kept printing "Fatigue is being restored". So am I correct in assuming that I need to send a packet in the above example (because I am changing the amount of fatigue the player has)? And if I send the packets correctly in the cases you mentioned my HUD will display the correct data right?
  3. Okay I watched this tutorial and i think I i mostly understand how to send packets but I'm still not really sure when I'm supposed to send one. I also dont know why when I try to display my custom NBT data using a Gui its not synced. Here is a class that draws some bars displaying the player's health and fatigue(capability I made) Here is code that restores the player's fatigue I put that code in a packet and I know that its working like its supposed to (restoring the fatigue) but for some reason the fatigue bar is not being draw correctly to show that its working. It actually was working before when I wasn't using a packet. Any idea why this is happening?
  4. Those are all static final variables that are set in the StatConstants class. They are just used as indexes for the arrays holding the actual data
  5. Probably not because I don't know how to do that haha. For each field in the default implementation of IStats I've done this public class FatigueStorage implements IStorage<IStats> { @Override public NBTBase writeNBT(Capability<IStats> capability, IStats instance, EnumFacing side) { final NBTTagCompound tag = new NBTTagCompound(); tag.setFloat("fatigue", instance.getFatigue()); return tag; } @Override public void readNBT(Capability<IStats> capability, IStats instance, EnumFacing side, NBTBase nbt) { final NBTTagCompound tag = (NBTTagCompound) nbt; instance.setFatigue(tag.getFloat("fatigue")); } } Is that not enough? Does the data still need to be synced even if the mod is only multiplayer? EDIT: I mean the EXACT OPPOSITE. its singleplayer only
  6. I have used a Capability to store a lot of data on to the player and usually Im able to access the data just fine and get the correct values by using the capability's interface (called IStats) . here is an example of using the Capability to get the necessary values that works fine But when I try to do this Minecraft.getMinecraft().displayGuiScreen(new CharacterSheetGUI(Minecraft.getMinecraft().player)); once the GUI is displayed its giving me incorrect numbers. Here is the GUI code if it helps For example this line fontRenderer.drawString("Long Blade " + playerSkills.getStat(StatConstants.LONG_BLADE), centerX+40, centerY+90, 0x000000); will display Long Blade 0 (which is the value it is initialized to in the default implementation of IStats) instead of the actual value that's supposed to be there. How can I make make sure I am getting the correct data from the player? The mod is only meant to be single player if that changes anything
  7. I'm making a Capability that requires I store data in a float array and it looks like NBT Tag compound only has a method for integer arrays. Is there some way around this or do I need to use an integer array instead?
  8. I thought I could use ItemSword.GetAttackDamage() to get the weapon's attack damage but that just gives the base value. How can I get the value with all damage modifiers applied?
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.