Too much off-topic. Discuss everything on the mod's page.
Melonslise is quite right, we should continue this discussion on Wizardry's thread, and then others will see it as well. On topic: Do you have the shortened reach thing working?
Edit: I have quoted you in the Wizardry thread here.
The Meaning of Life, the Universe, and Everything.
Location:
Colorado
Join Date:
3/27/2016
Posts:
208
Location:
Colorado
Minecraft:
ProfessorOro
Discord:
gargatheoro
PMC:
GargatheOro
Member Details
Melonslice, please. You have come to make unproductive comments on two or three of my threads so far. Thank you for the notice on the wrong thread chat.
Electroblob, I have unfortunatly not. I am pretty much useless on figuring things out from a concept. I have only made it this far from youtube and exact tutorials. I have not and still have yet to get shortened reach working, knockback, ranged weapon range, and weapon attack speed working.
1. Make an IShortenedReach interface, exactly the same as the IExtendedReach one, and have your item class implement it.
2. In your CommonHandler class, create a new method (call it what you like) with the @SubscribeEvent annotation and one parameter of type LivingAttackEvent. This will be called each time a living entity is attacked. The method should look something like this:
@SubscribeEvent
public void onLivingAttackEvent(LivingAttackEvent event){
// Checks if the attack is from a living creature and not, for example, lightning or a cactus.
if(event.source.getEntity() instanceof EntityLivingBase){
EntityLivingBase attacker = (EntityLivingBase)event.source.getEntity();
// Tests if the attacker is holding an item and if so, whether that item has a shortened reach.
if(attacker.getHeldItem() != null && attacker.getHeldItem().getItem() instanceof IShortenedReach){
// Gets the reach of the item.
double reach = ((IShortenedReach)attacker.getHeldItem().getItem()).getReach();
// Tests whether the distance between the attacker and the target is greater than the reach.
if(attacker.getDistanceToEntity(event.entity) > reach){
// Cancels the event, preventing the attack.
event.setCanceled(true);
// Not strictly necessary if this is the only code in this method, but if not then this ensures no other
// code in this method is executed.
return;
}
}
}
}
That should work, but I haven't tested it. Hopefully you can also tell what that code is doing.
As far as learning modding is concerned, here are some useful links:
The Meaning of Life, the Universe, and Everything.
Location:
Colorado
Join Date:
3/27/2016
Posts:
208
Location:
Colorado
Minecraft:
ProfessorOro
Discord:
gargatheoro
PMC:
GargatheOro
Member Details
Shortened Reach for melee works! Thank you for that and the learning resources. I thought it would be more complex but it sure works. I have to be in someones face to attack with dagger now. As for weapon reach where do I pull the velocity from? I think I am ready to try and tackle this on my own but I just need the location. I have been learning more basic Java and learned lots. That tells me I started doing something advanced without knowing the basics. I will in the future keep that in mind that I must learn from the beginning.
Something however I do want to learn that I need assistance for: Melting metal. I am adding metals and alloys, but that includes melted metal. There are two things for this: I want to make the furnace right clickable with a bucket to harvest the melted metal safely, but only if it is hot enough for liquid (IE I want certain items that HAVE to be obtained via this method). Secondly, the metal that is searing hot but still solid, I want it to go to the inventory but it will set you on fire and deal lava damage if you don't have item Tongs in your hand. Are one, if not both, of these possible? If so, please guide me.
Great to hear it's working, and yes, it really is that simple! There may well be a more complicated way of doing it but that's the way that made sense to me.
As for weapon reach where do I pull the velocity from?
If you mean knockback velocity, I explained that in my very first post on this thread, so have a look at that again. If not, I'm not sure I understand what you meant, so please could you explain?
I would suggest making a separate thread for the melting metal stuff, but I would do it like this:
The furnace will need a tile entity anyway, so assuming it's a custom furnace, store a heat variable in the tile entity and have the bucket check it when clicking on the furnace.
Having items set you on fire if you aren't holding a certain item is easy enough, just override the ingot's onUpdate method and inside, check the player is holding the tongs and if not set them on fire. What's more difficult is storing the heat value in your ingot. Because (I assume) they are stackable, you would have to use metadata to store the heat level and reduce it over time. You can then check that in the onUpdate method as well. You could even change the texture based on the metadata.
net.minecraft.item.Item is one of those classes that's definitely worth knowing inside out.
Ok, the ranged weapon velocity is as simple as setting the velocity of the projectile when it leaves the weapon. Look through the weapon's class and find a call to the method world.spawnEntityInWorld(...). Just before that is the place to set the velocity. You could probably just multiply its existing x/y/z velocities by a constant to get the behaviour you're looking for.
For the melting metals, as I understand it, you want the item itself to exist only within the furnace or a bucket, so it can't be removed from the furnace without a bucket and in addition you need tongs to stop the bucket burning you? The burning effect will work the same way as I explained before no matter what item it happens to be. Now, a bucket of [whatever] is an item in its own right the same way a bucket of milk is a separate item, so you'll need to make that as well. You may also want to look into Forge's universal bucket, which will allow any bucket from any other mod to hold your item/liquid, but I don't know much about that system.
spawnEntityInWorld actually places the arrow in the world, but I think the version in World is blank. Look at WorldServer.spawnEntityInWorld and you'll see what it really does.
It should say something like spawnEntityInWorld(arrow), it may not be called arrow but I'll use that here for the sake of example. Before that, put the line:
The Meaning of Life, the Universe, and Everything.
Location:
Colorado
Join Date:
3/27/2016
Posts:
208
Location:
Colorado
Minecraft:
ProfessorOro
Discord:
gargatheoro
PMC:
GargatheOro
Member Details
I haven't gotten feedback in a while because I was coding the other weapons and getting them up to speed. I then moved to a bunch of marble blocks. Now, one more thing: How do I add attack delay?
The Meaning of Life, the Universe, and Everything.
Location:
Colorado
Join Date:
3/27/2016
Posts:
208
Location:
Colorado
Minecraft:
ProfessorOro
Discord:
gargatheoro
PMC:
GargatheOro
Member Details
Yes. I want to add that and be able to configure times for some of my heavier weapons. People didn't swing hammers 10 times a second back in the day lol.
EDIT: I will download the 1.9 forge SDK to analyze but help would still be appreciated.
Melonslise is quite right, we should continue this discussion on Wizardry's thread, and then others will see it as well. On topic: Do you have the shortened reach thing working?
Edit: I have quoted you in the Wizardry thread here.
I'd recommend taking a look at mods that already do what you want in 1.7.10.
Battlegear and Balkon's weapons.
Melonslice, please. You have come to make unproductive comments on two or three of my threads so far. Thank you for the notice on the wrong thread chat.
Electroblob, I have unfortunatly not. I am pretty much useless on figuring things out from a concept. I have only made it this far from youtube and exact tutorials. I have not and still have yet to get shortened reach working, knockback, ranged weapon range, and weapon attack speed working.
An SF Towny server! Join our Discord: Click here
How do I do all that to make shortened reach?
Also, how do I learn how to mod properly? I am embarrassed to be spoon fed code and feel bad for asking others to write me code.
An SF Towny server! Join our Discord: Click here
Ok, so one step at a time:
1. Make an IShortenedReach interface, exactly the same as the IExtendedReach one, and have your item class implement it.
2. In your CommonHandler class, create a new method (call it what you like) with the @SubscribeEvent annotation and one parameter of type LivingAttackEvent. This will be called each time a living entity is attacked. The method should look something like this:
That should work, but I haven't tested it. Hopefully you can also tell what that code is doing.
As far as learning modding is concerned, here are some useful links:
Minecraft forge documentation - explains how to use forge's API
The Java tutorials - written by Oracle themselves, explains a lot of Java stuff with examples
Mapping and modding tutorials - an entire section of Minecraft forum dedicated to modding tutorials, try searching it for what you want to do
Minecraft Wiki page on Mod development - has loads of links to other places
Jabelar's modding tutorials - very useful and well-written tutorials
BedrockMiner's tutorials - also useful, though a bit outdated
Shortened Reach for melee works! Thank you for that and the learning resources. I thought it would be more complex but it sure works. I have to be in someones face to attack with dagger now. As for weapon reach where do I pull the velocity from? I think I am ready to try and tackle this on my own but I just need the location. I have been learning more basic Java and learned lots. That tells me I started doing something advanced without knowing the basics. I will in the future keep that in mind that I must learn from the beginning.
Something however I do want to learn that I need assistance for: Melting metal. I am adding metals and alloys, but that includes melted metal. There are two things for this: I want to make the furnace right clickable with a bucket to harvest the melted metal safely, but only if it is hot enough for liquid (IE I want certain items that HAVE to be obtained via this method). Secondly, the metal that is searing hot but still solid, I want it to go to the inventory but it will set you on fire and deal lava damage if you don't have item Tongs in your hand. Are one, if not both, of these possible? If so, please guide me.
Thank you for all your help and support.
An SF Towny server! Join our Discord: Click here
Great to hear it's working, and yes, it really is that simple! There may well be a more complicated way of doing it but that's the way that made sense to me.
If you mean knockback velocity, I explained that in my very first post on this thread, so have a look at that again. If not, I'm not sure I understand what you meant, so please could you explain?
I would suggest making a separate thread for the melting metal stuff, but I would do it like this:
The furnace will need a tile entity anyway, so assuming it's a custom furnace, store a heat variable in the tile entity and have the bucket check it when clicking on the furnace.
Having items set you on fire if you aren't holding a certain item is easy enough, just override the ingot's onUpdate method and inside, check the player is holding the tongs and if not set them on fire. What's more difficult is storing the heat value in your ingot. Because (I assume) they are stackable, you would have to use metadata to store the heat level and reduce it over time. You can then check that in the onUpdate method as well. You could even change the texture based on the metadata.
net.minecraft.item.Item is one of those classes that's definitely worth knowing inside out.
I mean ranged weapon velocity for changing ranged weapon range.
The melting metals are separate items altogether so I just wanna make them only obtainable with buckets from furnaces and not pickup able.
An SF Towny server! Join our Discord: Click here
@Electroblob_
An SF Towny server! Join our Discord: Click here
Ok, the ranged weapon velocity is as simple as setting the velocity of the projectile when it leaves the weapon. Look through the weapon's class and find a call to the method world.spawnEntityInWorld(...). Just before that is the place to set the velocity. You could probably just multiply its existing x/y/z velocities by a constant to get the behaviour you're looking for.
For the melting metals, as I understand it, you want the item itself to exist only within the furnace or a bucket, so it can't be removed from the furnace without a bucket and in addition you need tongs to stop the bucket burning you? The burning effect will work the same way as I explained before no matter what item it happens to be. Now, a bucket of [whatever] is an item in its own right the same way a bucket of milk is a separate item, so you'll need to make that as well. You may also want to look into Forge's universal bucket, which will allow any bucket from any other mod to hold your item/liquid, but I don't know much about that system.
Apologies if I haven't understood you correctly.
All I can find is stuff about consuming arrows and a spawnEntityInWorld thing that seems to not serve a purpose.
An SF Towny server! Join our Discord: Click here
spawnEntityInWorld actually places the arrow in the world, but I think the version in World is blank. Look at WorldServer.spawnEntityInWorld and you'll see what it really does.
It should say something like spawnEntityInWorld(arrow), it may not be called arrow but I'll use that here for the sake of example. Before that, put the line:
That will double its velocity. Multiply each of those motion values by a constant to change the velocity to what you want.
like arrow.addVelocity(arrow.x3?
An SF Towny server! Join our Discord: Click here
Something like:
would do. Bear in mind that you're adding velocity, so adding twice the arrow's velocity means it will be 3 times the arrow's original velocity.
Thank you so much. I will get this working if I can. Can I use division to lessen velocity?
An SF Towny server! Join our Discord: Click here
To reduce the velocity you would multiply by a negative number, so
would halve the arrow's velocity.
Thank you so much. If you happen to know how to add slabs, I made a new thread if you want to help.
An SF Towny server! Join our Discord: Click here
I haven't gotten feedback in a while because I was coding the other weapons and getting them up to speed. I then moved to a bunch of marble blocks. Now, one more thing: How do I add attack delay?
An SF Towny server! Join our Discord: Click here
When you say attack delay, what exactly do you mean? Do you mean like the attack cooldown in 1.9+?
Yes. I want to add that and be able to configure times for some of my heavier weapons. People didn't swing hammers 10 times a second back in the day lol.
EDIT: I will download the 1.9 forge SDK to analyze but help would still be appreciated.
An SF Towny server! Join our Discord: Click here