Jump to content

[1.10.2] [SOLVED]Potion effect when full set is worn. Where do I put it?


nedas60

Recommended Posts

I have a class for each individual armor item. Code looks like:

package Nedas60.TestMod.items;

import net.minecraft.item.ItemArmor;
import Nedas60.TestMod.Reference;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;

public class Infused_Leggings extends ItemArmor {

public Infused_Leggings(ArmorMaterial material) {
	super(material, 2, EntityEquipmentSlot.LEGS);
	setUnlocalizedName(Reference.TestItems.INFUSED_LEGGINGS.getUnlocalizedName());
	setRegistryName(Reference.TestItems.INFUSED_LEGGINGS.getRegistryName());
}
}

Ofcourse each one has it's own names. The problem is that I don't know where to put the test for armor set. Should I create a new class?

Link to comment
Share on other sites

Put the test?

Sorry if it unclear. It said "test for armor set"

 

 

Override onUpdate, check if you (i.e.

this

) are the helmet (or any other piece, but just one piece needs to check obviously). Then check if the player is wearing the full set, if so apply the potion.

Do I put that for each class or just one of my choice?

 

Link to comment
Share on other sites

Do I put that for each class or just one of my choice?

Which classes are you talking about? You only posted one so far.

He made multiple classes for each Armor piece and posted one as an example.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Do I put that for each class or just one of my choice?

Which classes are you talking about? You only posted one so far.

All of the armor ones. The difference between them is just the name and the super value. There is Infused_Helmet, Infused_Leggings, Infused_Boots, Infused_Chestplate.

Link to comment
Share on other sites

Yes, there is no need to make a class for all those. In fact it is pretty stupid to do that.

I am kinda new to forge. Who knows how it works. Please don't judge  ;D

 

I also tried following BedrockMiner's tutorial and I seem to be getting an error. Code:

package Nedas60.TestMod.items;

import Nedas60.TestMod.Reference;
import Nedas60.TestMod.init.ModItems;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;

public class Infused_Leggings extends ItemArmor {

public Infused_Leggings(ArmorMaterial material) {
	super(material, 2, EntityEquipmentSlot.LEGS);
	setUnlocalizedName(Reference.TestItems.INFUSED_LEGGINGS.getUnlocalizedName());
	setRegistryName(Reference.TestItems.INFUSED_LEGGINGS.getRegistryName());
}
        @Override
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {

	private void effectPlayer(EntityPlayer player1, Potion potionIn, int amplifier) {
	    //Always effect for 8 seconds, then refresh
	    if (player1.getActivePotionEffect(potionIn) == null || player1.getActivePotionEffect(potionIn).getDuration() <= 1)
	        player1.addPotionEffect(new PotionEffect(Potion.getActivePotionEffect(potionIn)), 159, amplifier, true, true));
	}

	if (player1.inventory.armorItemInSlot(3) != null && player1.inventory.armorItemInSlot(3).getItem() == ModItems.InfusedHelmet
	    && player1.inventory.armorItemInSlot(2) != null && player1.inventory.armorItemInSlot(2).getItem() == ModItems.InfusedBoots
	    && player1.inventory.armorItemInSlot(1) != null && player1.inventory.armorItemInSlot(1).getItem() == ModItems.InfusedLeggings
	    && player1.inventory.armorItemInSlot(0) != null && player1.inventory.armorItemInSlot(0).getItem() == ModItems.InfusedChestplate) {
			this.effectPlayer(player, MobEffects.SPEED, 3);
	}
}
}

But there are a lot of errors. Can someone explain how can I get it to work normally? Errors:

Multiple markers at this line

- void is an invalid type for the variable

effectPlayer

- Syntax error on token ",", ; expected

- Syntax error on token "(", ; expected

- Syntax error on token ")", ; expected

- Syntax error on token ",", ; expected

That's not all:

        Multiple markers at this line

- The method addPotionEffect(PotionEffect) in the type EntityLivingBase is not applicable for the arguments (PotionEffect, int, int, boolean,

boolean)

- The method getActivePotionEffect(Potion) is undefined for the type Potion

- Syntax error on token ")", delete this token

Also:

        The method effectPlayer(EntityPlayer, Potion, int) is undefined for the type Infused_Leggings

 

 

Link to comment
Share on other sites

Please learn some basic Java and come back once you have done that. No where in BedrockMiner's tutorial does it put a method inside of a method, that is a good tutorial.

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Link to comment
Share on other sites

Also onArmorTick might not work unless you set the potion effects time to a small number, as Diesieben said might wanna use onUpdate.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Also onArmorTick might not work unless you set the potion effects time to a small number, as Diesieben said might wanna use onUpdate.

 

What?  Those are the same thing, one is just specific to armor. Just set the potion effect length to whatever you want after checking that the player doesn't already have that potion effect.

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Link to comment
Share on other sites

Also onArmorTick might not work unless you set the potion effects time to a small number, as Diesieben said might wanna use onUpdate.

 

What?  Those are the same thing, one is just specific to armor. Just set the potion effect length to whatever you want after checking that the player doesn't already have that potion effect.

You are right, I was just remembering back to 1.5 when I was just getting into this and couldn't get it to get rid of the potion effect when one piece of the armor is taken off....

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Please learn some basic Java and come back once you have done that. No where in BedrockMiner's tutorial does it put a method inside of a method, that is a good tutorial.

I have learned java. What I have NOT learned is minecraft's functions and stuff like that. What can I do? Sure sometimes people don't see mistakes. I didn't notice that he made it differently. That's why I am here.

Link to comment
Share on other sites

This right here is super clever:

		setUnlocalizedName(Reference.TestItems.INFUSED_LEGGINGS.getUnlocalizedName());
	setRegistryName(Reference.TestItems.INFUSED_LEGGINGS.getRegistryName());

 

(Hint: no it's not, does not do what you want it do to,* and in fact is just going to crash the game)

 

Lets see here, you are setting the unlocalized name to....this item's unlocalized name. 

A = A; //A currently equals null

good jorb this code does precisely nothing.

Except oh wait, you didn't use

this

but rather the public static reference of your main class.  Whiiiich because the constructor--where this code is located--hasn't completed yet that reference is fucking null, so good jorb again you got an NPE.

And then you do it all over again for the registry name. Bravo.

 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I suppose it could be an enum.  It has the look of being an Item object, though.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Oh, sure. It is definitely that.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Ok, so tell me what's wrong here:

 

//new function
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { //open paren

	//new function
	private void effectPlayer(EntityPlayer player1, Potion potionIn, int amplifier) { //open paren

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Oh wait sorry forgot to update the title. This is now fixed. Previously in the comment I said didn't notice that the effectPlayer or whatever it is was in a method. Also bedrock's design was a bit broken. I had to fix it up a bit. Now it is fixed

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.