One of my NBT items persist upon death but my other two dont.
Think it might be the data watcher values
How do you know they are not persisting? If one is persisting but not the others, check that you are handling them the same.
Data persistence has nothing to do with datawatcher - please read the post I linked earlier, then post the relevant code using pastebin or spoiler tags.
Hey coolAlias, I don't know if this has already been asked, or answered or what ever, but as I'm studying your NBT guide, I'm on section 3.1 presently, When i tried to do the initial test to start the onitemuse event mana reduction, my console kicked out a whole bunch of errors, here I'm using 1.8 and everything has seemed to work just fine up until this point
it's probably something simple, but I've been banging my head on this mod for about 2 weeks now, so my mind is a bit strapped.
Thanks for help, you're awesome, and very informative
You're getting a NullPointerException in your extended properties which sounds like there is no value to load from the NBT
Mind pasting your extended properties class?
Not sure what I did, but the null is gone, so that error is out of the way. But now I'm sitting at the point where, everything I coded, doesn't seem like it's getting registered. yes I did MinecraftForge.EVENT_BUS.register(new EventHandling()); inside the init method but I feel like I'm missing something.
and sometimes, it seems like, it starts to register the item and the event attached to it, but when I right click it, it overticks and spits out "can't keep up message"
and sometimes, it seems like, it starts to register the item and the event attached to it, but when I right click it, it overticks and spits out "can't keep up message"
That has to be the funkiest Item code I have ever seen, though I don't see anything that would necessarily prevent it from working.
If all you are getting is the 'can't keep up' message, then you're probably fine - that message is usually not related to your mod, but just the general slowness of Minecraft.
That has to be the funkiest Item code I have ever seen, though I don't see anything that would necessarily prevent it from working.
If all you are getting is the 'can't keep up' message, then you're probably fine - that message is usually not related to your mod, but just the general slowness of Minecraft.
Interesting, well, I suppose my code could be called worse things, I try to keep everything as neat and organized as possible. Just wish I could figure out why I'm not getting anything in the console when I right click my item
Interesting, well, I suppose my code could be called worse things, I try to keep everything as neat and organized as possible. Just wish I could figure out why I'm not getting anything in the console when I right click my item
Sure, nothing wrong with that - you just have a different idea of 'organized' compared to most other modders. For example, I prefer to have all of my item declarations, instantiations, and registrations together in one 'library'-type class. Yours could be considered to have better encapsulation, but personally I don't think that the item class should know anything about the objects that belong to that class (though I am guilty of breaking that, too).
Anyway, not a big deal
Are you testing your item on a server? If so, the server console is different from the client console, and your System.outs will be printing to the server console. Like I said, I don't see anything awry in your code - it looks like it should work.
An easy way to get immediate feedback is to send the player a chat message instead of printing to the console - this way you see it directly in game when you right click, and it doesn't matter if your code is on the server or client environment.
It's in single player only, I was thinking about the chat message myself, a way to sort of bypass the system lines, that or having something happen in game like arrows being shot, just some way to let me know that it's counting down.
And I also use the "library-type" class as well, but I didn't want to alter anything in that code, when i started your tutorials, so i just set the mana item as it's own thing, away form everything but the core mechanics that should make it work.
Just an after thought, would I need to subscribe the onItemRightClicked event in my event handler, because it just seems like it's not catching the right click at all
what I mean by this is, the block doesn't respond to being right clicked in survval like most items do, but it behaves in creative mode, like it should without the system lines
onItemRightClick is not an Event, it is a class method of Item.
If your item is not working at all, I suggest you use one of your working items and test out your mana system using its onItemRightClick method, or rewrite your current item to follow a more typical format. Note that the example there is for 1.8, but there is also a 1.7.10 branch if that's what you're using.
onItemRightClick is not an Event, it is a class method of Item.
If your item is not working at all, I suggest you use one of your working items and test out your mana system using its onItemRightClick method, or rewrite your current item to follow a more typical format. Note that the example there is for 1.8, but there is also a 1.7.10 branch if that's what you're using.
Ah right, All the other items I have are just ingots and ores at the moment, but I'm only working in 1.8 environment this was supposed to be my attempt at using the right click to do things, so I'll work it out in the end, thank you for all the help, you've been amazing. I'm gonna to rebuild all my item code as best as I can and try to follow better procedures. Always learning!
I was having trouble getting the IExtendedEntityProperties to work together with the SimpleNetworkWrapper for synchronizing the client and server sides of each player instance. I had one variable that appears in a HUD, so I needed to synchronize them.
I was seeing an NullPointer exception, which I figured was the problem, but it turns out is a normal by product of how you say to configure this in the tutorial. I'm wondering if there is anyway to eliminate this.
Here is what I traced it down to:
When you start the game, the client and server player objects are created in separate threads (when running from Eclipse), in a client/server environment, these would be on separate PCs. So because of this, the client player instance was being create several seconds after the server. In the meantime, the server side was sending a network packet to the client, which didn't exist. It got the exception. When it fails, it tries to send it again, and the 2nd time it succeeds.
I guess since it catches the exception, it is pretty harmless, but sure threw me for a loop when I had a separate bug that was causing a crash. I usually look at the very first stack trace when this happens, and in this case it was the 2nd stack trace that had the real problem.
I was having trouble getting the IExtendedEntityProperties to work together with the SimpleNetworkWrapper for synchronizing the client and server sides of each player instance. I had one variable that appears in a HUD, so I needed to synchronize them.
I was seeing an NullPointer exception, which I figured was the problem, but it turns out is a normal by product of how you say to configure this in the tutorial. I'm wondering if there is anyway to eliminate this.
Here is what I traced it down to:
When you start the game, the client and server player objects are created in separate threads (when running from Eclipse), in a client/server environment, these would be on separate PCs. So because of this, the client player instance was being create several seconds after the server. In the meantime, the server side was sending a network packet to the client, which didn't exist. It got the exception. When it fails, it tries to send it again, and the 2nd time it succeeds.
I guess since it catches the exception, it is pretty harmless, but sure threw me for a loop when I had a separate bug that was causing a crash. I usually look at the very first stack trace when this happens, and in this case it was the 2nd stack trace that had the real problem.
It sounds like you are coding for 1.8, in which case you need to wait for the main thread before processing your packet or the client will not exist yet (when you first join the world) or you will find other idiosyncrasies in other cases.
If you are coding in 1.7.10 or earlier and getting this error, something else is wrong.
It sounds like you are coding for 1.8, in which case you need to wait for the main thread before processing your packet or the client will not exist yet (when you first join the world) or you will find other idiosyncrasies in other cases.
If you are coding in 1.7.10 or earlier and getting this error, something else is wrong.
Yes, I am coding for 1.7.10. The only thing a little bit different that I have, is that i supply the username, because I have something that requires that (can't recall at the moment what it is though)
I don't see how the client and server parts would ever start simultaneously, are you saying that in 1.7.10 they do? I understand that they added threading to 1.8, I haven't even tried to figure out how to do anything in 1.8 other than write a little bit of structure generation code for another mod I help out with.
I'm not at my computer, I can check how I have Eclipse configured later tonight, but I haven't changed my project setup in months, not sure what could be wrong with it.
It sounds like you are coding for 1.8, in which case you need to wait for the main thread before processing your packet or the client will not exist yet (when you first join the world) or you will find other idiosyncrasies in other cases.
If you are coding in 1.7.10 or earlier and getting this error, something else is wrong.
Oh, and to clarify, I have messages that print to the console when the EntityConstructing event and the EntityJoinWorldEvent occur, like so:
if (event.entity.worldObj.isRemote) // On client
LogHelper.info("DragonPlayerEventHandler: Registered a new DragonPlayer on client.");
else
LogHelper.info("DragonPlayerEventHandler: Registered a new DragonPlayer on server.");
This is how I know the client is creating the player several seconds (or longer) after the server creates the player.
Don't send packets from EntityConstructing - that is WAY too early - do it from PlayerLoggedInEvent or EntityJoinWorldEvent, as those happen nearly simultaneously on both the server and the client; even if there is lag, the client side entity is guaranteed to be ready by the time it receives a packet.
Don't send packets from EntityConstructing - that is WAY too early - do it from PlayerLoggedInEvent or EntityJoinWorldEvent, as those happen nearly simultaneously on both the server and the client; even if there is lag, the client side entity is guaranteed to be ready by the time it receives a packet.
Right, I am not sending packets from EntityConstructing. My packets are sent in EntityJoinWorldEvent. I have a function that gets called there and it calls a syncClient function, which then sends the packet to the client.
Anyway, it does seem pretty harmless that the client is still not ready. I thought I would post here, mainly so if anyone else sees this, they might know that it is possible for there to be a delay before the client is ready, and to see an error.
For myself, I tried like 3 times to get this working, each time thinking I had a serious error, until I debugged in all the way through the code, and saw the error was deep in the packet handliing. I then added in the prints, and then I could see the cause. I was a bit surprised this could be the cause, but I'm pretty sure it is.
Right, I am not sending packets from EntityConstructing. My packets are sent in EntityJoinWorldEvent. I have a function that gets called there and it calls a syncClient function, which then sends the packet to the client.
Anyway, it does seem pretty harmless that the client is still not ready. I thought I would post here, mainly so if anyone else sees this, they might know that it is possible for there to be a delay before the client is ready, and to see an error.
For myself, I tried like 3 times to get this working, each time thinking I had a serious error, until I debugged in all the way through the code, and saw the error was deep in the packet handliing. I then added in the prints, and then I could see the cause. I was a bit surprised this could be the cause, but I'm pretty sure it is.
I wouldn't be so sure - I send packets all the time from EntityJoinWorldEvent without any problems. That doesn't necessarily rule out that your problem is where you think it is, but it could easily be a problem somewhere else in your code.
I'm trying to make an overlay bar with your tutorial but the bar just won't appear.
I have two print-outs in the onRenderExperienceBar method to try to see if it does anything, one at the beginning and one at the end.
The first one prints but the second one does not? All I changed from your code is "mana" to "sanity" and made my GUI a bit bigger than the example one you had, which is definitely there because there's no resourcelocation error in the console.
@SideOnly(Side.CLIENT)
public class SanityBar extends Gui
{
private Minecraft mc;
private static final ResourceLocation texturepath = new ResourceLocation(Main.modid + ":" + "textures/gui/sanity_bar.png");
public SanityBar(Minecraft mc)
{
super();
this.mc = mc;
}
@SubscribeEvent(priority = EventPriority.NORMAL)
public void onRenderExperienceBar(RenderGameOverlayEvent event)
{
System.out.println("Rendering sanity");
if (event.isCancelable() || event.type != ElementType.EXPERIENCE)
{
return;
}
I'm trying to make an overlay bar with your tutorial but the bar just won't appear.
Did you register your IEEP class? If not, it will return null and your render code will not get called.
Is your 'max sanity' synchronized to the client (either via DataWatcher or packet)? If not, it will always be zero, and your render code will not get called.
Also, you can be more specific in the event you use: RenderGameOverlayEvent is called twice, once for Pre and once for Post - you should use RenderGameOverlayEvent.Post and then you don't need to check if the event is cancelable.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumHow do you know they are not persisting? If one is persisting but not the others, check that you are handling them the same.
Data persistence has nothing to do with datawatcher - please read the post I linked earlier, then post the relevant code using pastebin or spoiler tags.
Hey coolAlias, I don't know if this has already been asked, or answered or what ever, but as I'm studying your NBT guide, I'm on section 3.1 presently, When i tried to do the initial test to start the onitemuse event mana reduction, my console kicked out a whole bunch of errors, here I'm using 1.8 and everything has seemed to work just fine up until this point
it's probably something simple, but I've been banging my head on this mod for about 2 weeks now, so my mind is a bit strapped.
Thanks for help, you're awesome, and very informative
Not sure what I did, but the null is gone, so that error is out of the way. But now I'm sitting at the point where, everything I coded, doesn't seem like it's getting registered. yes I did MinecraftForge.EVENT_BUS.register(new EventHandling()); inside the init method but I feel like I'm missing something.
and sometimes, it seems like, it starts to register the item and the event attached to it, but when I right click it, it overticks and spits out "can't keep up message"
as per request my extendedplayer class
http://pastebin.com/nnMCFxF8
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumShow your item and event handler code.
http://pastebin.com/KV8HQAev This is the Item's code
http://pastebin.com/mnLJw17F this is my event handler
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumThat has to be the funkiest Item code I have ever seen, though I don't see anything that would necessarily prevent it from working.
If all you are getting is the 'can't keep up' message, then you're probably fine - that message is usually not related to your mod, but just the general slowness of Minecraft.
Interesting, well, I suppose my code could be called worse things, I try to keep everything as neat and organized as possible. Just wish I could figure out why I'm not getting anything in the console when I right click my item
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumSure, nothing wrong with that - you just have a different idea of 'organized' compared to most other modders. For example, I prefer to have all of my item declarations, instantiations, and registrations together in one 'library'-type class. Yours could be considered to have better encapsulation, but personally I don't think that the item class should know anything about the objects that belong to that class (though I am guilty of breaking that, too).
Anyway, not a big deal
Are you testing your item on a server? If so, the server console is different from the client console, and your System.outs will be printing to the server console. Like I said, I don't see anything awry in your code - it looks like it should work.
An easy way to get immediate feedback is to send the player a chat message instead of printing to the console - this way you see it directly in game when you right click, and it doesn't matter if your code is on the server or client environment.
It's in single player only, I was thinking about the chat message myself, a way to sort of bypass the system lines, that or having something happen in game like arrows being shot, just some way to let me know that it's counting down.
And I also use the "library-type" class as well, but I didn't want to alter anything in that code, when i started your tutorials, so i just set the mana item as it's own thing, away form everything but the core mechanics that should make it work.
Just an after thought, would I need to subscribe the onItemRightClicked event in my event handler, because it just seems like it's not catching the right click at all
what I mean by this is, the block doesn't respond to being right clicked in survval like most items do, but it behaves in creative mode, like it should without the system lines
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumonItemRightClick is not an Event, it is a class method of Item.
If your item is not working at all, I suggest you use one of your working items and test out your mana system using its onItemRightClick method, or rewrite your current item to follow a more typical format. Note that the example there is for 1.8, but there is also a 1.7.10 branch if that's what you're using.
Ah right, All the other items I have are just ingots and ores at the moment, but I'm only working in 1.8 environment this was supposed to be my attempt at using the right click to do things, so I'll work it out in the end, thank you for all the help, you've been amazing. I'm gonna to rebuild all my item code as best as I can and try to follow better procedures. Always learning!
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumI was having trouble getting the IExtendedEntityProperties to work together with the SimpleNetworkWrapper for synchronizing the client and server sides of each player instance. I had one variable that appears in a HUD, so I needed to synchronize them.
I was seeing an NullPointer exception, which I figured was the problem, but it turns out is a normal by product of how you say to configure this in the tutorial. I'm wondering if there is anyway to eliminate this.
Here is what I traced it down to:
When you start the game, the client and server player objects are created in separate threads (when running from Eclipse), in a client/server environment, these would be on separate PCs. So because of this, the client player instance was being create several seconds after the server. In the meantime, the server side was sending a network packet to the client, which didn't exist. It got the exception. When it fails, it tries to send it again, and the 2nd time it succeeds.
I guess since it catches the exception, it is pretty harmless, but sure threw me for a loop when I had a separate bug that was causing a crash. I usually look at the very first stack trace when this happens, and in this case it was the 2nd stack trace that had the real problem.
[url=2482915-wip-arkcraft-survival-evolved-dinos-taming]
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumIt sounds like you are coding for 1.8, in which case you need to wait for the main thread before processing your packet or the client will not exist yet (when you first join the world) or you will find other idiosyncrasies in other cases.
If you are coding in 1.7.10 or earlier and getting this error, something else is wrong.
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumYes, I am coding for 1.7.10. The only thing a little bit different that I have, is that i supply the username, because I have something that requires that (can't recall at the moment what it is though)
I don't see how the client and server parts would ever start simultaneously, are you saying that in 1.7.10 they do? I understand that they added threading to 1.8, I haven't even tried to figure out how to do anything in 1.8 other than write a little bit of structure generation code for another mod I help out with.
I'm not at my computer, I can check how I have Eclipse configured later tonight, but I haven't changed my project setup in months, not sure what could be wrong with it.
[url=2482915-wip-arkcraft-survival-evolved-dinos-taming]
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumOh, and to clarify, I have messages that print to the console when the EntityConstructing event and the EntityJoinWorldEvent occur, like so:
if (event.entity.worldObj.isRemote) // On client
LogHelper.info("DragonPlayerEventHandler: Registered a new DragonPlayer on client.");
else
LogHelper.info("DragonPlayerEventHandler: Registered a new DragonPlayer on server.");
This is how I know the client is creating the player several seconds (or longer) after the server creates the player.
[url=2482915-wip-arkcraft-survival-evolved-dinos-taming]
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumDon't send packets from EntityConstructing - that is WAY too early - do it from PlayerLoggedInEvent or EntityJoinWorldEvent, as those happen nearly simultaneously on both the server and the client; even if there is lag, the client side entity is guaranteed to be ready by the time it receives a packet.
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumRight, I am not sending packets from EntityConstructing. My packets are sent in EntityJoinWorldEvent. I have a function that gets called there and it calls a syncClient function, which then sends the packet to the client.
Anyway, it does seem pretty harmless that the client is still not ready. I thought I would post here, mainly so if anyone else sees this, they might know that it is possible for there to be a delay before the client is ready, and to see an error.
For myself, I tried like 3 times to get this working, each time thinking I had a serious error, until I debugged in all the way through the code, and saw the error was deep in the packet handliing. I then added in the prints, and then I could see the cause. I was a bit surprised this could be the cause, but I'm pretty sure it is.
[url=2482915-wip-arkcraft-survival-evolved-dinos-taming]
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumI wouldn't be so sure - I send packets all the time from EntityJoinWorldEvent without any problems. That doesn't necessarily rule out that your problem is where you think it is, but it could easily be a problem somewhere else in your code.
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumI'm trying to make an overlay bar with your tutorial but the bar just won't appear.
I have two print-outs in the onRenderExperienceBar method to try to see if it does anything, one at the beginning and one at the end.
The first one prints but the second one does not? All I changed from your code is "mana" to "sanity" and made my GUI a bit bigger than the example one you had, which is definitely there because there's no resourcelocation error in the console.
@SideOnly(Side.CLIENT)
public class SanityBar extends Gui
{
private Minecraft mc;
private static final ResourceLocation texturepath = new ResourceLocation(Main.modid + ":" + "textures/gui/sanity_bar.png");
public SanityBar(Minecraft mc)
{
super();
this.mc = mc;
}
@SubscribeEvent(priority = EventPriority.NORMAL)
public void onRenderExperienceBar(RenderGameOverlayEvent event)
{
System.out.println("Rendering sanity");
if (event.isCancelable() || event.type != ElementType.EXPERIENCE)
{
return;
}
ExtendedPlayer props = ExtendedPlayer.get(this.mc.thePlayer);
if (props == null || props.getMaxSanity() == 0)
{
return;
}
int xPos = 2;
int yPos = 2;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_LIGHTING);
this.mc.getTextureManager().bindTexture(texturepath);
this.drawTexturedModalRect(xPos, yPos, 0, 0, 60, 8);
int sanitybarwidth = (int)(((float) props.getCurrentSanity() / props.getMaxSanity()) * 58);
System.out.println("[GUI SANITY] Current sanity bar width: " + sanitybarwidth);
this.drawTexturedModalRect(xPos + 1, yPos + 1, 4, 4, sanitybarwidth, 2);
}
}
Am I doing something wrong? It's for 1.7.10.
PubliCraft & Fandomcraft
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumDid you register your IEEP class? If not, it will return null and your render code will not get called.
Is your 'max sanity' synchronized to the client (either via DataWatcher or packet)? If not, it will always be zero, and your render code will not get called.
Also, you can be more specific in the event you use: RenderGameOverlayEvent is called twice, once for Pre and once for Post - you should use RenderGameOverlayEvent.Post and then you don't need to check if the event is cancelable.