im making a leveling system where it needs two components
one which is a form of experience that can be affected by actions and events which i have right now thanks to your help just before but i need it to be so that once you reach x amount of experience it changed the level value from 1 to 2 etc and short of duplicating the system that youve provided and making one system affect the other i dont know how to do it :/
is there a limit to how many times you can implement this?
im making a leveling system where it needs two components
one which is a form of experience that can be affected by actions and events which i have right now thanks to your help just before but i need it to be so that once you reach x amount of experience it changed the level value from 1 to 2 etc and short of duplicating the system that youve provided and making one system affect the other i dont know how to do it :/
is there a limit to how many times you can implement this?
It's Java, you can do whatever you want with it There is no reason that you could only have class fields for mana - just add some more for your xp, level, and anything else you need, and follow the same steps for synchronization. You may find it is better to create separate packets, one for current xp, one for current mana, etc., so you don't have to sync all the data every single time just one of them updates, but that's up to you and how you design it.
ive managed to implement both the leveling system and the exp but i cant figure out how to make it so that if the exp value reaches a set amount it updates the level amount +1
ive tried a onplayerupdate event but it didnt work (or im just being a newbie and missing something)
how would you do it ? ;/
EDIT:
it was me being a newbie :/ forgot to register minecraft forge event bus //Facepalm
i used this method of doing it (will be improved was just to try and get it up and running)
CoolAlias to your comment "If you need it to work for ANY block, then like I already mentioned, you need to subscribe to the net.minecraftforge.event.world.BlockEvent.BreakEvent event. "
is that possible to be made block specific (only happens for vanilla block dirt) for example
CoolAlias to your comment "If you need it to work for ANY block, then like I already mentioned, you need to subscribe to the net.minecraftforge.event.world.BlockEvent.BreakEvent event. "
is that possible to be made block specific (only happens for vanilla block dirt) for example
Yes, it is. Please learn basic Java and you will understand how to do so.
your comment has somewhat offended me.... ive been modding a week of two very scarcely and ive already picked up, how to make,
mobs (tamable or not) have modified ai's to suit my mobs, make blocks with meta or without, able to rotate, make items, food, drinks with custom potion effects, crops, use of apis , make custom inventory in blocks items and mobs, tile entities, models event handlers, and use of events, modify some aspects of vanilla blocks, use of ticks, and guis thats some of it from you and your tutorials which i really appreciate.... the very purpose of me visiting tutorials, i do so to "learn" and understand how things work in java. i chose to visit minecraft tutorials rather than straight out java tutorials to grasp context in which the concepts are used in relation to minecraft modding. if you dont like explaining java to those who dont know it perhaps dont try to make tutorials, im not entirely an idiot when it comes to learning java. i dont appreciate the arrogance you seem to hold.
I don't mean to offend you, and I commend your efforts to learn Java through Minecraft, but sometimes you really do just need to stop and look at some real Java tutorials if you are not getting everything you need from MC code. I'm not trying to be arrogant about it, I'm just telling you the truth. A simple if statement is about as basic of Java as it can get, and if you haven't learned how to write one in all of those tutorials you followed, then I'd say you haven't "learned" much of anything other than how to copy and paste. Sorry to disappoint you, but the onus is on you to learn from the code already provided, not on others to hold your hand the entire time.
The New Boston (also has tutorials on tons of other cool stuff)
I still refer to the Oracle website whenever I come across a new Java class or need to look up anything that I am unsure of. It is a great resource, with documentation on every aspect of Java.
Also, stackoverflow.com is a website devoted to answering Java questions; google pretty much any Java question and that site will come up with an answer.
thank you, i do appreciate the help for what its worth
No problem, and good luck One other wonderful resource for learning is the Minecraft code itself; once you've got some of the basics, you can learn TONS of cool things by reading lots and lots of other people's code, including Mojang's and any open source mods you can get your hands on. Though keep in mind that not all open-source mods are well written
The Meaning of Life, the Universe, and Everything.
Join Date:
8/9/2013
Posts:
211
Minecraft:
HappyKiller1O1
Xbox:
HappyKiller101
Member Details
So, I have been following your tutorial on how to make a Mana Bar with IExtendedEntityProperties (I'm modding in 1.6.4 if you're wondering), and well I need to have my Mana regenerate overtime. I saw a post a few pages back stating how to do it but I have only been coding for about two months and I still am a novice at most of it. So, if you could maybe give me bit of what to do to have it regenerate Mana or maybe direct me to a tutorial on it that would be great :). (Sorry if this is an easy/novice question, like I said I only have been coding for about two months and I still am getting the hang of it XD)
So, I have been following your tutorial on how to make a Mana Bar with IExtendedEntityProperties (I'm modding in 1.6.4 if you're wondering), and well I need to have my Mana regenerate overtime. I saw a post a few pages back stating how to do it but I have only been coding for about two months and I still am a novice at most of it. So, if you could maybe give me bit of what to do to have it regenerate Mana or maybe direct me to a tutorial on it that would be great . (Sorry if this is an easy/novice question, like I said I only have been coding for about two months and I still am getting the hang of it XD)
I covered pretty much everything you need to know in that post. I understand being new to coding, it can seem daunting, but the information is all there. You simply need to think carefully about how, exactly, you want your mana to regenerate, and then break that up into logical steps that you can explain to the computer via code. The very nature of the entity update methods gives you a built-in timer, as it executes every ticks (20 ticks = 1 second) - all you need is a variable to keep track of it.
The Meaning of Life, the Universe, and Everything.
Join Date:
12/4/2013
Posts:
45
Minecraft:
bluecube2
Member Details
This is pretty much exactly what I was looking for, but Im very much a beginner so I've got some problems.
I'm trying to make the player (upon death event) regenerate all their health, and cancel the death. I can't seem to be able to reach any health variables through the ExtendedPlayer. This should only happen one time, unless the player dies and respawns.
Also, I was kind of hoping to have this configurable in the config file, which Im also lost with.
hmm.. I've got a really confusing problem here,
I can't seem to figure out how to solve this error:
java.lang.ClassCastException: net.minecraft.client.entity.EntityClientPlayerMP cannot be cast to net.minecraft.entity.player.EntityPlayerMP
at org.xuluf.mod.handlers.ExtendedPlayerDerp.loadProxyData(ExtendedPlayerDerp.java:159) ~[ExtendedPlayerDerp.class:?]
at org.xuluf.mod.handlers.EventHandler.onEntityJoinWorld(EventHandler.java:62) ~[EventHandler.class:?]
I know what it tries to do, but I'm not sure I know how to fix it?
the loadProxyData() method
public static final void loadProxyData(EntityPlayer player) {
ExtendedPlayerDerp playerData = ExtendedPlayerDerp.get(player);
NBTTagCompound savedData = CommonProxy.getEntityDatafs(getSaveKey(player));
if (savedData != null) { playerData.loadNBTData(savedData); }
DerpMod.packetPipeline.sendTo(new SyncPlayerDerpsPacket(player), (EntityPlayerMP) player);
}
@BlueCube2 ExtendedPlayer has nothing to do with normal vanilla health. Please post whatever code you tried - if you have an EntityPlayer whose health is at zero, you cannot heal them at that point, but you can use player.setHealth(value) and cancel the death event, and this will work. How you decide to allow this only once is up to you.
@Xuluf Hint: entities join worlds on both the client and the server; EntityClientPlayerMP is client, while EntityPlayerMP is server - you are trying to cast the client player to the server player.
@BlueCube2 ExtendedPlayer has nothing to do with normal vanilla health. Please post whatever code you tried - if you have an EntityPlayer whose health is at zero, you cannot heal them at that point, but you can use player.setHealth(value) and cancel the death event, and this will work. How you decide to allow this only once is up to you.
@Xuluf Hint: entities join worlds on both the client and the server; EntityClientPlayerMP is client, while EntityPlayerMP is server - you are trying to cast the client player to the server player.
I don't have code to post because everything works except for the healing. I tried setHealth and it was not recognized.
I don't have code to post because everything works except for the healing. I tried setHealth and it was not recognized.
That's why I need the code, as in the code that is not working. You probably just didn't cast the entity properly, as setHealth is not an Entity method, but an EntityLivingBase (and thus also EntityPlayer) method. Post your entire LivingDeath event code.
@Xuluf Hint: entities join worlds on both the client and the server; EntityClientPlayerMP is client, while EntityPlayerMP is server - you are trying to cast the client player to the server player.
I had that figured out already :P, but I'm not sure how I would edit it so that it works. It's just the syncing to the client that is wrong, the server is working fine :/ Ideas?
im making a leveling system where it needs two components
one which is a form of experience that can be affected by actions and events which i have right now thanks to your help just before but i need it to be so that once you reach x amount of experience it changed the level value from 1 to 2 etc and short of duplicating the system that youve provided and making one system affect the other i dont know how to do it :/
is there a limit to how many times you can implement this?
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumIt's Java, you can do whatever you want with it
ive tried a onplayerupdate event but it didnt work (or im just being a newbie and missing something)
how would you do it ? ;/
EDIT:
it was me being a newbie :/ forgot to register minecraft forge event bus //Facepalm
i used this method of doing it (will be improved was just to try and get it up and running)
@SubscribeEvent
public void onPlayerUpdate(LivingUpdateEvent event){
if(event.entityLiving instanceof EntityPlayer){
EntityPlayer player = (EntityPlayer) event.entityLiving;
if(ExperienceStorage.get(player).GetExperience() > 50)
{
LevelStorage.get(player).AddLevel(1);
ExperienceStorage.get(player).SetExperience(0);
}
}
is that possible to be made block specific (only happens for vanilla block dirt) for example
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumYes, it is. Please learn basic Java and you will understand how to do so.
mobs (tamable or not) have modified ai's to suit my mobs, make blocks with meta or without, able to rotate, make items, food, drinks with custom potion effects, crops, use of apis , make custom inventory in blocks items and mobs, tile entities, models event handlers, and use of events, modify some aspects of vanilla blocks, use of ticks, and guis thats some of it from you and your tutorials which i really appreciate.... the very purpose of me visiting tutorials, i do so to "learn" and understand how things work in java. i chose to visit minecraft tutorials rather than straight out java tutorials to grasp context in which the concepts are used in relation to minecraft modding. if you dont like explaining java to those who dont know it perhaps dont try to make tutorials, im not entirely an idiot when it comes to learning java. i dont appreciate the arrogance you seem to hold.
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumI don't mean to offend you, and I commend your efforts to learn Java through Minecraft, but sometimes you really do just need to stop and look at some real Java tutorials if you are not getting everything you need from MC code. I'm not trying to be arrogant about it, I'm just telling you the truth. A simple if statement is about as basic of Java as it can get, and if you haven't learned how to write one in all of those tutorials you followed, then I'd say you haven't "learned" much of anything other than how to copy and paste. Sorry to disappoint you, but the onus is on you to learn from the code already provided, not on others to hold your hand the entire time.
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumThere are two excellent Java learning sites, the first is text-based (which is what I used and prefer), the second is video-based:
Oracle's Java Tutorials (they're the ones that wrote Java)
The New Boston (also has tutorials on tons of other cool stuff)
I still refer to the Oracle website whenever I come across a new Java class or need to look up anything that I am unsure of. It is a great resource, with documentation on every aspect of Java.
Also, stackoverflow.com is a website devoted to answering Java questions; google pretty much any Java question and that site will come up with an answer.
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumNo problem, and good luck
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumI covered pretty much everything you need to know in that post. I understand being new to coding, it can seem daunting, but the information is all there. You simply need to think carefully about how, exactly, you want your mana to regenerate, and then break that up into logical steps that you can explain to the computer via code. The very nature of the entity update methods gives you a built-in timer, as it executes every ticks (20 ticks = 1 second) - all you need is a variable to keep track of it.
I'm trying to make the player (upon death event) regenerate all their health, and cancel the death. I can't seem to be able to reach any health variables through the ExtendedPlayer. This should only happen one time, unless the player dies and respawns.
Also, I was kind of hoping to have this configurable in the config file, which Im also lost with.
I can't seem to figure out how to solve this error:
I know what it tries to do, but I'm not sure I know how to fix it?
the loadProxyData() method
public static final void loadProxyData(EntityPlayer player) { ExtendedPlayerDerp playerData = ExtendedPlayerDerp.get(player); NBTTagCompound savedData = CommonProxy.getEntityDatafs(getSaveKey(player)); if (savedData != null) { playerData.loadNBTData(savedData); } DerpMod.packetPipeline.sendTo(new SyncPlayerDerpsPacket(player), (EntityPlayerMP) player); }onEntityJoinWorld event method.
@SubscribeEvent public void onEntityJoinWorld(EntityJoinWorldEvent event) { if(event.entity instanceof EntityPlayer){ ExtendedPlayerDerp.loadProxyData((EntityPlayer) event.entity); } }If you need any more code I can provide it.
Art by me: [email protected]
-
View User Profile
-
View Posts
-
Send Message
Curse Premium@Xuluf Hint: entities join worlds on both the client and the server; EntityClientPlayerMP is client, while EntityPlayerMP is server - you are trying to cast the client player to the server player.
I don't have code to post because everything works except for the healing. I tried setHealth and it was not recognized.
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumThat's why I need the code, as in the code that is not working. You probably just didn't cast the entity properly, as setHealth is not an Entity method, but an EntityLivingBase (and thus also EntityPlayer) method. Post your entire LivingDeath event code.
I had that figured out already :P, but I'm not sure how I would edit it so that it works. It's just the syncing to the client that is wrong, the server is working fine :/ Ideas?
Art by me: [email protected]