The Meaning of Life, the Universe, and Everything.
Join Date:
3/6/2014
Posts:
44
Minecraft:
SodaSpartan
Xbox:
Soda Sp4rtan
Member Details
I just made an armor set and want to add a mechanic that makes it to where, when i am wearing the full set ONLY i get the ability to fly.
I dont want to use a potion affect, and im okay with using some sort of custom enchantment but i was hoping there was a way to do this without either of them.
I believe that this is what your want. This code takes away the players ability to fly when they take off the armor, but I'm not sure if it takes it away when they die. I haven't tested it yet, but if you have any issues just ask
The Meaning of Life, the Universe, and Everything.
Join Date:
3/6/2014
Posts:
44
Minecraft:
SodaSpartan
Xbox:
Soda Sp4rtan
Member Details
sorry, thats what i meant i just changed it to EtherealDynamics.itemCustom_Boots and ect for all the other pieces and i have no red lines. im gonna go test it and let you know if it works. wish me luck
nope it crashes the second i put on the armor and now i cant load that world anymore because it crashes everytime now, could it be that the onArmorTick is too much checking to see if the armor is on?
The Meaning of Life, the Universe, and Everything.
Join Date:
3/6/2014
Posts:
44
Minecraft:
SodaSpartan
Xbox:
Soda Sp4rtan
Member Details
its telling me to remove the @Override are there perhaps different params for onArmorTickUpdate because if there are they are not showing up and it says the current params are wrong
Edit: i tried getting rid of the @Override and it allowed me to load the game but the armor was just normal armor
I found one that sort of works but on removing an armor piece the flying doesn't stop and you continue to be immune to fall damage untill restarting the game
Although i am starting to think i should go about this a different way... like maybe a ring or something that goes in a special inventory slot that is powered by something and can run out, but that gets into a whole other world of modding
*facepalm*, so the crash I was getting was an array our of bounds error. So basically when you set the itemstack variables at the top of the onArmorTick event change it to the following.
ItemStack bootStack = player.getCurrentArmor(0);
ItemStack legsStack = player.getCurrentArmor(1);
ItemStack chestStack = player.getCurrentArmor(2);
ItemStack helmStack = player.getCurrentArmor(3);
If you need any more help I set it up to work on github. Here is the link
I just made an armor set and want to add a mechanic that makes it to where, when i am wearing the full set ONLY i get the ability to fly.
I dont want to use a potion affect, and im okay with using some sort of custom enchantment but i was hoping there was a way to do this without either of them.
I believe that this is what your want. This code takes away the players ability to fly when they take off the armor, but I'm not sure if it takes it away when they die. I haven't tested it yet, but if you have any issues just ask
http://pastebin.com/r3bJ6j5f
Note: I just noticed on the pastebin that I forgot to add the () at the end of the second stack.getItem()
My name is MisterBlock11
Github
I'm assuming this goes under the constructor in the armor class file?
Not under the constructor just in the item armor's class
My name is MisterBlock11
Github
if (bootStack != null && legsStack != null && chestStack != null && helmetStack != null) {
if (bootStack.getItem() == YourMod.boots && legsStack.getItem == YourMod.legs && chestStack.getItem() == YourMod.chest && helmetStack.getItem() == YourMod.helmet) {
also Where it says YourMod.boots && legsStack.getItem (my mod name is EtherealDynamics and the modid is ed)
would i change YourMod.boots to ed.boots or EtherealDynamics.boots
then in legsStack.getItem should i change get item to the getItemBoots or just leave it
No, use the name of the class that the item variable is defined in
So yeah, EtherealDynamic.(whatever the item is called)
And change the legsStack.getItem to legsStack.getItem()
My name is MisterBlock11
Github
sorry, thats what i meant i just changed it to EtherealDynamics.itemCustom_Boots and ect for all the other pieces and i have no red lines. im gonna go test it and let you know if it works. wish me luck
nope it crashes the second i put on the armor and now i cant load that world anymore because it crashes everytime now, could it be that the onArmorTick is too much checking to see if the armor is on?
whoops i added that as an edit by accident lol
and i did fix the missing () btw
Sorry, I don't know if it'll fix it, but use onArmorTickUpdate instead of onArmorTick
My name is MisterBlock11
Github
its telling me to remove the @Override are there perhaps different params for onArmorTickUpdate because if there are they are not showing up and it says the current params are wrong
Edit: i tried getting rid of the @Override and it allowed me to load the game but the armor was just normal armor
Okay, onArmorTick is the right one not on ArmorTickUpdate
Can you give me the exact code your using, and the crash report?
My name is MisterBlock11
Github
its still not working and i cant think of a reason why. The code looks like it should work
I'll get back to you, I'm going to test it myself
My name is MisterBlock11
Github
ok, thank you
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack itemstack) {
// Checks if you are wearing the entire body of armor, remove sections of statement below to get your result.
if(player.getCurrentArmor(3) != null && player.getCurrentArmor(2) != null && player.getCurrentArmor(1) != null && player.getCurrentArmor(0) != null){
ItemStack helmet = player.getCurrentArmor(3);
ItemStack chestplate = player.getCurrentArmor(2);
ItemStack leggings = player.getCurrentArmor(1);
ItemStack boots = player.getCurrentArmor(0);
if(helmet.getItem() == yourmodsmainclass.thehelmetyouwant && chestplate.getItem() == yourmodsmainclass.thechestplateyouwant && leggings.getItem() == yourmodsmainclass.theleggingsyouwant && boots.getItem() == yourmodsmainclass.thebootsyouwant) {
player.capabilities.allowFlying = true;
player.fallDistance = 0.0f;
}
else {
player.capabilities.allowFlying = false;
player.capabilities.isFlying = false;
}
}
}
I found one that sort of works but on removing an armor piece the flying doesn't stop and you continue to be immune to fall damage untill restarting the game
Although i am starting to think i should go about this a different way... like maybe a ring or something that goes in a special inventory slot that is powered by something and can run out, but that gets into a whole other world of modding
*facepalm*, so the crash I was getting was an array our of bounds error. So basically when you set the itemstack variables at the top of the onArmorTick event change it to the following.
ItemStack bootStack = player.getCurrentArmor(0);
ItemStack legsStack = player.getCurrentArmor(1);
ItemStack chestStack = player.getCurrentArmor(2);
ItemStack helmStack = player.getCurrentArmor(3);
If you need any more help I set it up to work on github. Here is the link
My name is MisterBlock11
Github
if you take off the armor though you continue to fly until you restart the game
Is that just until you touch the ground again?Add player.capabilities.isFlying=false; in the else statement as well
And move the else statement to the first if statement not the second
I also edited my github so that the code fixes that issue.
My name is MisterBlock11
Github
like this ?
if (bootStack != null && legsStack != null && chestStack != null && helmetStack != null) {}
else {
player.capabilities.allowFlying = false;
player.capabilities.isFlying = false;
}
Yes
My name is MisterBlock11
Github