ok so I'm still having issues with my problem in the link below is my mess around mod please I looked in the IBlockventState again I'm new to modding and I want to learn as much as I can so if you could help explaine to me how its not workingI would be greatfull also did I use the wrong bus kuz I feel like I did.
few things:
1. like how you need the annotations @EventHandler for forge to run your initialization methods, you also need @SubscribeEvent in order for your methods to get called.
2. you need to name your methods the appropriate method as the API states. e.g. if you want it to be called when a block is destroyed you need to call it
public void onBlockDestroyedEvent(HarvestDropsEvent event) {
//code here
}
few things:
1. like how you need the annotations @EventHandler for forge to run your initialization methods, you also need @SubscribeEvent in order for your methods to get called.
2. you need to name your methods the appropriate method as the API states. e.g. if you want it to be called when a block is destroyed you need to call it
public void onBlockDestroyedEvent(HarvestDropsEvent event) {
//code here
}
1. Yes, that's correct.
2. No, the name doesn't matter at all - the only thing that matters is #1, and that your method is public, void, and contains only one single Event as a parameter. And that you register an instance of the class on the correct event bus.
Yes, I have already covered using PlayerEvent.Clone, I just haven't updated the main tutorial yet because I don't want to fight the forum editor.
You will probably want to clone your properties when switching dimensions, too, otherwise the player will lose all of their data when the come back from the End.
Yes, I have already covered using PlayerEvent.Clone, I just haven't updated the main tutorial yet because I don't want to fight the forum editor.
You will probably want to clone your properties when switching dimensions, too, otherwise the player will lose all of their data when the come back from the End.
Yes, I've seen that you do lose all the data when coming back from the End. So is there an event for that? From the code above, it is the (event.wasDeath == false), right?
Yes, I've seen that you do lose all the data when coming back from the End. So is there an event for that? From the code above, it is the (event.wasDeath == false), right?
More appropriately: if (!event.wasDeath), but yes, basically, although 99% of the time you probably won't care whether the player actually died or came back from the End, as either way you will lose all of the player's extra data if you don't handle the clone event, and it is generally handled identically for both.
I used your code on github to render the manabar, which works so far. The problem is it creates a black bar in the chat and where the shadows of item names normally are.
Im using 1.8 - forge 1.8-11.14.3.1543, any help is appreciated.
That happens because Minecraft probably still needs blend or alpha enabled or disabled for its rendering, but we've changed the GL state and don't know what it was prior to our changes.
It's much better to use push and pop attributes, rather than trying to manually undo each change you make. Then you don't have to worry about interfering with other things that need rendering.
Also, in 1.8, you should be using the GlStateManager rather than direct calls to GL11, but I didn't in the tutorial for simplicity of updating from 1.7.10.
Try using the following:
GlStateManager.pushAttrib();
GlStateManager.disableLighting();
GlStateManager.enableAlpha();
GlStateManager.enableBlend();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
// render your stuff here
// This will reset the GL state back to what it was before you changed stuff
GlStateManager.popAttrib();
"More appropriately: if (!event.wasDeath), but yes, basically, although 99% of the time you probably won't care whether the player actually died or came back from the End, as either way you will lose all of the player's extra data if you don't handle the clone event, and it is generally handled identically for both."
That happens because Minecraft probably still needs blend or alpha enabled or disabled for its rendering, but we've changed the GL state and don't know what it was prior to our changes.
It's much better to use push and pop attributes, rather than trying to manually undo each change you make. Then you don't have to worry about interfering with other things that need rendering.
Also, in 1.8, you should be using the GlStateManager rather than direct calls to GL11, but I didn't in the tutorial for simplicity of updating from 1.7.10.
If you want to use any value from your IEEP class in a GUI or other client-side only class, you need to send a packet from the server (which has that information) to the client (which doesn't) when the player joins the world and whenever that field updates.
Thanks for that, an example how it would look? I'm really stucking at that point.
There are examples of sending packets in the tutorial, but the network code is outdated. You should use SimpleNetworkWrapper instead of the PacketPipeline.
It's basically the same; if you're using my PacketDispatcher wrapper, you would just call sendTo(EntityPlayerMP, IMessage). Make sure you are on the server first, and cast the regular player to EntityPlayerMP.
You're sending data the wrong way. Only ever send data from the server to the client. If you have a GUI or something that needs to impact the IEEP data, send a packet from there saying "Player clicked this button" and then the server can decide what to do with that information, e.g. set the player's class, and then send the IEEP data back to the client so the client has the information it needs.
The way you're doing it now, I could write a client-side mod that sends any NBT data I want and your code would just read it in and let me have anything. Mage class? Okay, I'll send NBT saying I have ALL the spells and max mana, poof done. That's why you should only allow things to be set on the server, and if it involves any client input (e.g. button press from GUI), be sure to validate that the action is valid (e.g. does the player already have a class? then sorry, can't select again).
You fix it by NOT setting the property directly from the GUI - send a packet to the server with the id of the button pressed and let the server handle it, like I already explained.
Guys, I successfully made an extended property for player. now i need it to grow everytime player kills an entity but with different amounts. I'm approaching it by checking the killed entity in LivingDeathEvent and doing adding decreasing there, but I seem to have too much else if's and i think it's not efficient. Any ideas for other approaches? Here's example of code:
Use a lookup table, e.g. a HashMap<Class<? extends Entity>, KillingList> and populate it sometime during your mod initialization. Then you can simply do:
Hey there, coolAlias. Great guide. I followed your Extended Properties guide to the letter, and it worked like a charm in the 1.7.10 version of my mod Archmagus. However, things seem to have broken done as I struggle to update my mod to 1.8.9, and it has to do with the Extended Properties.
Even though the maximum mana of players seems to persist through death and dimensional travel as intended, it seems the client doesn't receive the actual maximum mana update message when they (re)spawn. It takes manually sending a message to inform the client, such as eating a Crystalline Apple which in my mod increases a player's maximum mana.
Do you have any idea what might be going wrong?
Perhaps related to that question is another question: you speak in your guide of the methods 'syncExtendedProperties' and 'syncProperties', but nowhere in your guide are their implementations given. Could you reveal what their actual implementations are?
few things:
1. like how you need the annotations @EventHandler for forge to run your initialization methods, you also need @SubscribeEvent in order for your methods to get called.
2. you need to name your methods the appropriate method as the API states. e.g. if you want it to be called when a block is destroyed you need to call it
1. Yes, that's correct.
2. No, the name doesn't matter at all - the only thing that matters is #1, and that your method is public, void, and contains only one single Event as a parameter. And that you register an instance of the class on the correct event bus.
sorry, shouldn't have used the word 'need'. it 'should'
Sweet tutorial it helped me out
There is a much simpler way to persist the data on death though:
@SubscribeEvent
public void onClonePlayer(PlayerEvent.Clone event)
{
if(event.wasDeath)//false means switched dimensions
{
if(PERSIST_DEATH)
{
InventoryPersistProperty odata = InventoryPersistProperty.get(event.original);
InventoryPersistProperty.get(event.entityPlayer).setPotionNBT(odata.getPotionNBT());
}
}
}
I am 'PrinceOfAmber' on github if you want to see the rest
My Released Mods
Twitter
Yes, I have already covered using PlayerEvent.Clone, I just haven't updated the main tutorial yet because I don't want to fight the forum editor.
You will probably want to clone your properties when switching dimensions, too, otherwise the player will lose all of their data when the come back from the End.
Yes, I've seen that you do lose all the data when coming back from the End. So is there an event for that? From the code above, it is the (event.wasDeath == false), right?
[url=2482915-wip-arkcraft-survival-evolved-dinos-taming]
More appropriately: if (!event.wasDeath), but yes, basically, although 99% of the time you probably won't care whether the player actually died or came back from the End, as either way you will lose all of the player's extra data if you don't handle the clone event, and it is generally handled identically for both.
Hey
I used your code on github to render the manabar, which works so far. The problem is it creates a black bar in the chat and where the shadows of item names normally are.
Im using 1.8 - forge 1.8-11.14.3.1543, any help is appreciated.
Edit:
Seems like this line at the end causes all the mess
//GL11.glDisable(GL11.GL_BLEND);
It's much better to use push and pop attributes, rather than trying to manually undo each change you make. Then you don't have to worry about interfering with other things that need rendering.
Also, in 1.8, you should be using the GlStateManager rather than direct calls to GL11, but I didn't in the tutorial for simplicity of updating from 1.7.10.
Try using the following:
"More appropriately: if (!event.wasDeath), but yes, basically, although 99% of the time you probably won't care whether the player actually died or came back from the End, as either way you will lose all of the player's extra data if you don't handle the clone event, and it is generally handled identically for both."
Wow thanks for the tip coolAlias !
My Released Mods
Twitter
Will try it at home. Ty
If you want to use any value from your IEEP class in a GUI or other client-side only class, you need to send a packet from the server (which has that information) to the client (which doesn't) when the player joins the world and whenever that field updates.
There are examples of sending packets in the tutorial, but the network code is outdated. You should use SimpleNetworkWrapper instead of the PacketPipeline.
It's basically the same; if you're using my PacketDispatcher wrapper, you would just call sendTo(EntityPlayerMP, IMessage). Make sure you are on the server first, and cast the regular player to EntityPlayerMP.
You're sending data the wrong way. Only ever send data from the server to the client. If you have a GUI or something that needs to impact the IEEP data, send a packet from there saying "Player clicked this button" and then the server can decide what to do with that information, e.g. set the player's class, and then send the IEEP data back to the client so the client has the information it needs.
The way you're doing it now, I could write a client-side mod that sends any NBT data I want and your code would just read it in and let me have anything. Mage class? Okay, I'll send NBT saying I have ALL the spells and max mana, poof done. That's why you should only allow things to be set on the server, and if it involves any client input (e.g. button press from GUI), be sure to validate that the action is valid (e.g. does the player already have a class? then sorry, can't select again).
You fix it by NOT setting the property directly from the GUI - send a packet to the server with the id of the button pressed and let the server handle it, like I already explained.
Love all the tutorials, thanks!
Guys, I successfully made an extended property for player. now i need it to grow everytime player kills an entity but with different amounts. I'm approaching it by checking the killed entity in LivingDeathEvent and doing adding decreasing there, but I seem to have too much else if's and i think it's not efficient. Any ideas for other approaches? Here's example of code:
Hey there, coolAlias. Great guide. I followed your Extended Properties guide to the letter, and it worked like a charm in the 1.7.10 version of my mod Archmagus. However, things seem to have broken done as I struggle to update my mod to 1.8.9, and it has to do with the Extended Properties.
Even though the maximum mana of players seems to persist through death and dimensional travel as intended, it seems the client doesn't receive the actual maximum mana update message when they (re)spawn. It takes manually sending a message to inform the client, such as eating a Crystalline Apple which in my mod increases a player's maximum mana.
Do you have any idea what might be going wrong?
Perhaps related to that question is another question: you speak in your guide of the methods 'syncExtendedProperties' and 'syncProperties', but nowhere in your guide are their implementations given. Could you reveal what their actual implementations are?
Thank you in advance.
My mods: Archmagus, BetterBoneMeal, BetterVanilla, Brewing-API, NaturalArmors, and PluckableChickens!