I love the superheroes unlimited mod with all its heroes, villains, etc, and I figured I could do it too, but I just need to know how to make it so that if the player has the armor set on, they can use specific powers and can get items when a key is pressed (if you use the superheroes unlimited mod, you know what I'm talking about).
Use event handlers to check if the player is wearing a full set of armor and then test for pressed keys. be sure to send a packet to the server that the key was pressed, processing this on the clientside won't work.
Use event handlers to check if the player is wearing a full set of armor and then test for pressed keys. be sure to send a packet to the server that the key was pressed, processing this on the clientside won'*t work.
Sorry if this is too much to ask, but if you could show an example, that would be awesome, or at least how to check if the armor set is on.
Sorry if this is too much to ask, but if you could show an example, that would be awesome, or at least how to check if the armor set is on.
For the event Handler look for tutorials, there are enough out there.
For your armor check if EntityPlayer#getCurrentArmor(Int ArmorSlot) isn't null and then ckeck if it's your armor. Do this for all 4 armor slots (0 - 3).
There's plenty of source code available for a ton of different mods. Think of a mod you know that incorporates this, and search for its source code. Should take you a matter of minutes and will come very helpful down the road.
There's plenty of source code available for a ton of different mods. Think of a mod you know that incorporates this, and search for its source code. Should take you a matter of minutes and will come very helpful down the road.
Like this? I thought there would only be 4 of them...
Like this? I thought there would only be 4 of them...
Not exactly... that looks more like a chunk of rendering logic. Here is a link to a similar post, targeting 1.7.10. If you have modding experience already it should be enough to get you started.
Also, look at Jabelar's Event Handling tutorial.
Rollback Post to RevisionRollBack
Click this banner for a list of illegal mod distributors -- only download from legal sites!
@SubscribeEvent
public void onPlayerTickEvent(PlayerTickEvent event)
{
Random rand = new Random();
if (event.player instanceof EntityPlayer)
{
EntityPlayer player = event.player;
if (player.getCurrentArmor(3) !=null && player.getCurrentArmor(2) != null && player.getCurrentArmor(1) != null && player.getCurrentArmor(0) != null)
{
if (player.getCurrentArmor(3).getItem() instanceof ArmorCivilWarAntman && player.getCurrentArmor(2).getItem() instanceof ArmorCivilWarAntman && player.getCurrentArmor(1).getItem() instanceof ArmorCivilWarAntman && player.getCurrentArmor(0).getItem() instanceof ArmorCivilWarAntman)
{
//some code
}
}
}
}
The first if statement of armor checks whether the slot is empty or not. The second if statement of armor checks if the items in the slots are a specific set of armor pieces, in this case, civilwarantman armor pieces.
@SubscribeEvent
public void onPlayerTickEvent(PlayerTickEvent event)
{
Random rand = new Random();
if (event.player instanceof EntityPlayer)
{
EntityPlayer player = event.player;
if (player.getCurrentArmor(3) !=null && player.getCurrentArmor(2) != null && player.getCurrentArmor(1) != null && player.getCurrentArmor(0) != null)
{
if (player.getCurrentArmor(3).getItem() instanceof ArmorCivilWarAntman && player.getCurrentArmor(2).getItem() instanceof ArmorCivilWarAntman && player.getCurrentArmor(1).getItem() instanceof ArmorCivilWarAntman && player.getCurrentArmor(0).getItem() instanceof ArmorCivilWarAntman)
{
//some code
}
}
}
}
The first if statement of armor checks whether the slot is empty or not. The second if statement of armor checks if the items in the slots are a specific set of armor pieces, in this case, civilwarantman armor pieces.
What do you mean? The code covers all 4 armor slots (0-3), and all armor pieces mentioned are of type ArmorCivilWarAntman (helmet, chestpiece, leggings and boots).
By replacing my 'System.out.println' with player.addPotionEffect(PotionEffect effect)
Look at the constructor for PotionEffect (or Google it) if you are still confused.
Rollback Post to RevisionRollBack
Click this banner for a list of illegal mod distributors -- only download from legal sites!
I love the superheroes unlimited mod with all its heroes, villains, etc, and I figured I could do it too, but I just need to know how to make it so that if the player has the armor set on, they can use specific powers and can get items when a key is pressed (if you use the superheroes unlimited mod, you know what I'm talking about).
Use event handlers to check if the player is wearing a full set of armor and then test for pressed keys. be sure to send a packet to the server that the key was pressed, processing this on the clientside won't work.
Sorry if this is too much to ask, but if you could show an example, that would be awesome, or at least how to check if the armor set is on.
For the event Handler look for tutorials, there are enough out there.
For your armor check if EntityPlayer#getCurrentArmor(Int ArmorSlot) isn't null and then ckeck if it's your armor. Do this for all 4 armor slots (0 - 3).
There's plenty of source code available for a ton of different mods. Think of a mod you know that incorporates this, and search for its source code. Should take you a matter of minutes and will come very helpful down the road.
Like this? I thought there would only be 4 of them...
Also, sorry if I'm asking too much.
Not exactly... that looks more like a chunk of rendering logic. Here is a link to a similar post, targeting 1.7.10. If you have modding experience already it should be enough to get you started.
Also, look at Jabelar's Event Handling tutorial.
Just create an Eventhandler with LivingUpdateEvent:
Youtube | Website | Twitter
This is what I needed, thanks! I see that I have to list all 4 armor slots, if I'm correct.
Best to use this
The first if statement of armor checks whether the slot is empty or not. The second if statement of armor checks if the items in the slots are a specific set of armor pieces, in this case, civilwarantman armor pieces.
Why no legs, chest plate, etc?
What do you mean? The code covers all 4 armor slots (0-3), and all armor pieces mentioned are of type ArmorCivilWarAntman (helmet, chestpiece, leggings and boots).
Ohh, never mind then, I figured it out. Thank's for all you help!
i get errors on .getCurrentArmor saying The method getCurrentArmor(int) is undefined for the type EntityPlayer
If you're using 1.10, call EntityPlayer#getItemStackFromSlot(EntityEquipmentSlot slotIn)
Values for slotIn are:
EntityEquipmentSlot.MAINHAND
EntityEquipmentSlot.OFFHAND
EntityEquipmentSlot.FEET
EntityEquipmentSlot.LEGS
EntityEquipmentSlot.CHEST
EntityEquipmentSlot.HEAD
If this method is not available, please say which version of Minecraft and Forge you are using.
i am using 1.10
can U please give me some example code for this
It's not very difficult...
for example, to check if the player is wearing iron boots:
and then how do I give it a Potion effect
By replacing my 'System.out.println' with player.addPotionEffect(PotionEffect effect)
Look at the constructor for PotionEffect (or Google it) if you are still confused.