I have started developing a mod, as the title would suggest. I know the basics, and have made items, blocks, crafting recipes, and a creative tab. But I can no longer find good sources to learn more about modding in 1.7, so I can't progress in modding. Now, I have a quite a few questions, but I'll start out with 2. First, I would like to make a potion effect that makes the players screen spaz out and shake violently. I have seen it done before, so I know it's possible. I just have no idea how to do this. This effect should occur when a certain item I made is in a player's inventory. The second question is if anyone knows a good source for modding in 1.7. I've tried MrCrayfish, Wuppy, Scratchforfun, and the written forge tutorials(which sometimes are hard to follow) so I wouldn't have to ask these noob questions and bother everyone. Thank you to those who help or try to help.
Rollback Post to RevisionRollBack
"Minecraftia, a world of peace yet danger, a world of light yet darkness, a world of good yet evil. Every good thing you see has it's evil counterpart, evenly matching the power of the two. I intend, however, to simplify things down to one part, which just happens to be evil."- The Infector
Once you learn the basics by following tutorials, you should know enough about modding to do most things (or find out most things) on your own. As for your specific questions:
1) The "potion effect", is not exactly specific to Minecraft but Java and lwjgl/OpenGL. You'll have to render an overlay, and I'm sure you can get an idea for this from vanilla overlay effects - whatever the one is that makes the screen wavy and such, I even can't remember. To make it happen for an item in the player's inventory, I'm not sure - you'll probably need a TickHandler. There are like, four different things you're actually asking here - if someone tells me which PotionEffect does the wavy screen one then I can point you to the code for that.
2) Wuppy's are decent, as are Jabelar's. Personally I followed Havvy's tutorial on Forge wiki, and then I knew enough to get into it and learn as I go via Google, and sometimes specific questions on the forums here. As I said, the tutorials are designed to teach you basics - if you're expecting there to be a tutorial for every specific thing you want to code in your mod, you'll be very disappointed.
The effect you mean is Nausea, and if by code you mean id, that would be 9. I was actually going to use nausea with the custom effect, so I guess I could also use it as a placeholder. I have done my best to learn the basics, and I will continue to. I'll look into Jabelar's and Haavy's. Thank you for your help.
Rollback Post to RevisionRollBack
"Minecraftia, a world of peace yet danger, a world of light yet darkness, a world of good yet evil. Every good thing you see has it's evil counterpart, evenly matching the power of the two. I intend, however, to simplify things down to one part, which just happens to be evil."- The Infector
I do not plan on including any tools in my mod, so I skipped over toolmaking tutorials. Would I have missed any important basic info in these tutorials?
Rollback Post to RevisionRollBack
"Minecraftia, a world of peace yet danger, a world of light yet darkness, a world of good yet evil. Every good thing you see has it's evil counterpart, evenly matching the power of the two. I intend, however, to simplify things down to one part, which just happens to be evil."- The Infector
Making tools covers any "usable" item, if you plan on never making items then that's fine to skip I guess.
Ok, the GUI rendering code for portal nausea and such are done in EntityRenderer.setupCameraTransform - but in all honesty it's too complicated for me to grasp. This is a base class though, I can't see any Forge hooks to help with registering your own transformation effects - so that means you'd have to manually manipulate the viewport with OpenGL. Which is very much outside my skill level, so I can't help sorry.
Havvy's tutorials are only simple, Wuppy and Jabelar cover much more.
Hey, you tried. I thank you just for that. I will try to contact the modder that made that similar shaking screen effect I mentioned before. I will find some tool tutorials to read and/or watch, and go from there. I'll post sometime soon after that. Thanks again for your help.
"Minecraftia, a world of peace yet danger, a world of light yet darkness, a world of good yet evil. Every good thing you see has it's evil counterpart, evenly matching the power of the two. I intend, however, to simplify things down to one part, which just happens to be evil."- The Infector
I have progressed further in modding, and come across another issue. The mod revolves around a hazardous material that grants debuffs when in the inventory or when it's block form is walked on. However, I am not sure how to detect when the item is in a player's inventory, or if they are wearing special boots that null the debuffs when walking on the block. I have attempted researching this problem, but nothing turned up that could help me. How would I code these into the mod?
Rollback Post to RevisionRollBack
"Minecraftia, a world of peace yet danger, a world of light yet darkness, a world of good yet evil. Every good thing you see has it's evil counterpart, evenly matching the power of the two. I intend, however, to simplify things down to one part, which just happens to be evil."- The Infector
I have progressed further in modding, and come across another issue. The mod revolves around a hazardous material that grants debuffs when in the inventory or when it's block form is walked on. However, I am not sure how to detect when the item is in a player's inventory, or if they are wearing special boots that null the debuffs when walking on the block. I have attempted researching this problem, but nothing turned up that could help me. How would I code these into the mod?
For the item: override onUpdate in your Item class and use that to apply the debuff. This method is only called when a player has the item in their inventory.
For the block: I'm not sure if there's any method called when an entity walks on top of a block, but you may be able to use a reduced bounding box and override onEntityCollidedWithBlock in your Block class like BlockSoulSand does. You'll need to check if the entity is an instance of EntityLivingBase, use entity.getEquipmentInSlot(1) to check if it's wearing your boots and then use EntityLivingBase#addPotionEffect to add your debuff.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
For items it's probably the same, an entity tick handler. An items' own tick handler only runs if it's in the hotbar, as far as I know.
Item#onUpdate is indirectly (through ItemStack#updateAnimation) called by InventoryPlayer#decrementAnimations, which iterates through the mainInventory array (this contains the player's whole inventory apart from their worn items, not just the hotbar) and calls ItemStack#updateAnimation on each ItemStack in the inventory.
The doc comment for InventoryPlayer#decrementAnimations says it's only called client-side, but it appears to be called from EntityPlayer#onLivingUpdate without checking World#isRemote (i.e. it seems to be called on both the client and the server).
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
",courier">Item#onUpdate is indirectly (through ",courier">ItemStack#updateAnimation) called by ",courier">InventoryPlayer#decrementAnimations, which iterates through the ",courier">mainInventory array (this contains the player's whole inventory apart from their worn items, not just the hotbar) and calls ",courier">ItemStack#updateAnimation on each ItemStack in the inventory.
The doc comment for ",courier">InventoryPlayer#decrementAnimations says it's only called client-side, but it appears to be called from ",courier">EntityPlayer#onLivingUpdate without checking ",courier">World#isRemote (i.e. it seems to be called on both the client and the server).
Let's hope that's intentional and not a bug Mojang will fix, I can imagine quite a few mods would break if they fixed it.
Rollback Post to RevisionRollBack
Author of the Clarity, Serenity, Sapphire & Halcyon shader packs for Minecraft: Java Edition.
I already have it so the block gives the debuffs when walked on, I just need to check if the entity is wearing certain boots. Going to try your suggestions.
Rollback Post to RevisionRollBack
"Minecraftia, a world of peace yet danger, a world of light yet darkness, a world of good yet evil. Every good thing you see has it's evil counterpart, evenly matching the power of the two. I intend, however, to simplify things down to one part, which just happens to be evil."- The Infector
Item#onArmorTick and Item#onUpdate both occur every tick - the first for armor when it is equipped, the second for any item so long as it is in the player's inventory. Both of these are very useful for adding things like potion effects, but depending on the nature of your debuff, it may be challenging to remove the debuff since once the item is no longer worn / in the inventory (when the debuff should be removed), you no longer have access to an item tick within which to remove it.
Solutions are to use SharedMonsterAttributes and Item#getAttributeModifiers(ItemStack), for things like modifying player speed, or use the item tick methods to add potion effects with short durations every few ticks (which then wear off shortly after the item is no longer updating).
If neither of those will work for you, you will have to implement a more complicated solution: store the player's 'item state', e.g. 'currently_held/worn_item', to remember the current item that the player has, then each tick check if that item is no longer there; you still have an instance of it in your class field with which to call one last method to remove whatever effects were there. You can see my implementation of such a system here (storing last worn item) and here (Item class).
Part of my problem is that I know what I need to code, but not how. I'm still fairly new to modding, so even though everything you guys have suggested I understand, I don't know how I would type things like getUpdate in. I know what I need to utilize to code this, but I don't know how to use them. For example, I know that to detect the item, I need to use @Override and getUpdate together. From then on, the only thing I know is the line used to add a potion effect. I'm not sure what is in the line between adding the effect and the getUpdate. I've done my best to learn as much as I can so I wouldn't have to ask silly questions like these, but unfortunately I still have some.
On another note, I coded the block to give debuffs when walked on. The coding is:
public void onEntityWalking(World world, int par2, int par3, int par4, Entity entity){
I don't know how to post in a code box, sorry. So, how would I change this so the block does not give the debuff when wearing the boots?
Rollback Post to RevisionRollBack
"Minecraftia, a world of peace yet danger, a world of light yet darkness, a world of good yet evil. Every good thing you see has it's evil counterpart, evenly matching the power of the two. I intend, however, to simplify things down to one part, which just happens to be evil."- The Infector
Part of my problem is that I know what I need to code, but not how. I'm still fairly new to modding...
That means you are not only new to modding, but new to Java. I suggest you first take a week or two to learn the very basics of Java - it will go a LONG way towards helping you figure out how to mod.
Thanks, I'll look into it. If I continue to have problems I can't solve on my own, I'll probably use this page again. Until then, I'm off to better understand Java. Thank you for the tip.
"Minecraftia, a world of peace yet danger, a world of light yet darkness, a world of good yet evil. Every good thing you see has it's evil counterpart, evenly matching the power of the two. I intend, however, to simplify things down to one part, which just happens to be evil."- The Infector
Part of my problem is that I know what I need to code, but not how. I'm still fairly new to modding, so even though everything you guys have suggested I understand, I don't know how I would type things like getUpdate in. I know what I need to utilize to code this, but I don't know how to use them. For example, I know that to detect the item, I need to use @Override and getUpdate together. From then on, the only thing I know is the line used to add a potion effect. I'm not sure what is in the line between adding the effect and the getUpdate. I've done my best to learn as much as I can so I wouldn't have to ask silly questions like these, but unfortunately I still have some.
On another note, I coded the block to give debuffs when walked on. The coding is:
public void onEntityWalking(World world, int par2, int par3, int par4, Entity entity){
I don't know how to post in a code box, sorry. So, how would I change this so the block does not give the debuff when wearing the boots?
Just me being me, but @Override just FYI isn't actually needed, it mainly serves as a marker for the IDE to know that that method should override a super implementation. So say you have two classes, one that has an example() method, and another that extends the first and also implements the example() method. Java's hierarchy model automatically knows that the second class' method overrides the first, therefore when you call the method using an instance of the second class the second implementation of the method is called instead of the first.
However, the IDE (Eclipse) doesn't know that this method should override the super method, and therefore doesn't tell you if there is a discrepancy between the two methods (super and override). Annotating the override method with @Override (ie placing @Override over the method header) tells the IDE that this method should be overriding a super method. So what the IDE does is it will then look at all super methods to find one that has a signature (description, basically) match with the override method, if it does, the IDE doesn't do anything, however if it cannot find a matching method, it prints an error notifying you.
Rollback Post to RevisionRollBack
Author of the Clarity, Serenity, Sapphire & Halcyon shader packs for Minecraft: Java Edition.
1) The "potion effect", is not exactly specific to Minecraft but Java and lwjgl/OpenGL. You'll have to render an overlay, and I'm sure you can get an idea for this from vanilla overlay effects - whatever the one is that makes the screen wavy and such, I even can't remember. To make it happen for an item in the player's inventory, I'm not sure - you'll probably need a TickHandler. There are like, four different things you're actually asking here - if someone tells me which PotionEffect does the wavy screen one then I can point you to the code for that.
2) Wuppy's are decent, as are Jabelar's. Personally I followed Havvy's tutorial on Forge wiki, and then I knew enough to get into it and learn as I go via Google, and sometimes specific questions on the forums here. As I said, the tutorials are designed to teach you basics - if you're expecting there to be a tutorial for every specific thing you want to code in your mod, you'll be very disappointed.
Ok, the GUI rendering code for portal nausea and such are done in EntityRenderer.setupCameraTransform - but in all honesty it's too complicated for me to grasp. This is a base class though, I can't see any Forge hooks to help with registering your own transformation effects - so that means you'd have to manually manipulate the viewport with OpenGL. Which is very much outside my skill level, so I can't help sorry.
Havvy's tutorials are only simple, Wuppy and Jabelar cover much more.
For the item: override onUpdate in your Item class and use that to apply the debuff. This method is only called when a player has the item in their inventory.
For the block: I'm not sure if there's any method called when an entity walks on top of a block, but you may be able to use a reduced bounding box and override onEntityCollidedWithBlock in your Block class like BlockSoulSand does. You'll need to check if the entity is an instance of EntityLivingBase, use entity.getEquipmentInSlot(1) to check if it's wearing your boots and then use EntityLivingBase#addPotionEffect to add your debuff.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
For items it's probably the same, an entity tick handler. An items' own tick handler only runs if it's in the hotbar, as far as I know.
Item#onUpdate is indirectly (through ItemStack#updateAnimation) called by InventoryPlayer#decrementAnimations, which iterates through the mainInventory array (this contains the player's whole inventory apart from their worn items, not just the hotbar) and calls ItemStack#updateAnimation on each ItemStack in the inventory.
The doc comment for InventoryPlayer#decrementAnimations says it's only called client-side, but it appears to be called from EntityPlayer#onLivingUpdate without checking World#isRemote (i.e. it seems to be called on both the client and the server).
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Let's hope that's intentional and not a bug Mojang will fix, I can imagine quite a few mods would break if they fixed it.
Author of the Clarity, Serenity, Sapphire & Halcyon shader packs for Minecraft: Java Edition.
My Github page.
The entire Minecraft shader development community now has its own Discord server! Feel free to join and chat with all the developers!
Solutions are to use SharedMonsterAttributes and Item#getAttributeModifiers(ItemStack), for things like modifying player speed, or use the item tick methods to add potion effects with short durations every few ticks (which then wear off shortly after the item is no longer updating).
If neither of those will work for you, you will have to implement a more complicated solution: store the player's 'item state', e.g. 'currently_held/worn_item', to remember the current item that the player has, then each tick check if that item is no longer there; you still have an instance of it in your class field with which to call one last method to remove whatever effects were there. You can see my implementation of such a system here (storing last worn item) and here (Item class).
public void onEntityWalking(World world, int par2, int par3, int par4, Entity entity){
if (entity instanceof EntityLivingBase) {
((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.confusion.getId(), 200, 2));
I don't know how to post in a code box, sorry. So, how would I change this so the block does not give the debuff when wearing the boots?
That means you are not only new to modding, but new to Java. I suggest you first take a week or two to learn the very basics of Java - it will go a LONG way towards helping you figure out how to mod.
Just me being me, but @Override just FYI isn't actually needed, it mainly serves as a marker for the IDE to know that that method should override a super implementation. So say you have two classes, one that has an example() method, and another that extends the first and also implements the example() method. Java's hierarchy model automatically knows that the second class' method overrides the first, therefore when you call the method using an instance of the second class the second implementation of the method is called instead of the first.
However, the IDE (Eclipse) doesn't know that this method should override the super method, and therefore doesn't tell you if there is a discrepancy between the two methods (super and override). Annotating the override method with @Override (ie placing @Override over the method header) tells the IDE that this method should be overriding a super method. So what the IDE does is it will then look at all super methods to find one that has a signature (description, basically) match with the override method, if it does, the IDE doesn't do anything, however if it cannot find a matching method, it prints an error notifying you.
Author of the Clarity, Serenity, Sapphire & Halcyon shader packs for Minecraft: Java Edition.
My Github page.
The entire Minecraft shader development community now has its own Discord server! Feel free to join and chat with all the developers!