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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I try to play with better combat, I install its dependency but it tells me that it needs version 1.0.2 and I already have it, what do I do? the dependency is player animator
    • I think my save file was potentially corrupted (based on what I have been reading online). The world has loaded and saved perfectly fine for weeks. Today I added about 6 new mods and updated 3 mod libraries, and then encountered the following error: "Errors in currently selected data packs prevented the world from loading. You can either try to load it with only the vanilla data pack ("safe mode"), or go back to the title screen and fix it manually." I have tried changing to a newer Forge version, reverting the updated mods back to original versions, removing the new mods, removing and readding all mods, removing my world file and loading the forge profile and adding it back, renaming the level.dat_old file as level.dat... Nothing has worked yet. Forge loads fine and I don't want to risk trying to reload the world in "safe mode" in case I end up losing mod-related content. Not sure how that works. I am having trouble reading the output log to determine what is causing the error. Any advice is better than none!! Thank you!     Info: Minecraft 1.20.1 Forge 47.1.3 Mod list (includes which mods are disabled, newly added before this error, and any changes I found after the error) : https://pastebin.com/nquXY1Hj Latest log: https://pastebin.com/U4fD0kAt
    • It all began with a chance encounter with a testimonial shared by Olivia, a fellow traveler on the winding road of cryptocurrency. Her words spoke of a miraculous recovery orchestrated by Wizard Web Recovery, a beacon of hope in the murky waters of online fraud. Intrigued by her story, I reached out to Wizard Web Recovery, hoping they could work their magic on my blocked crypto recovery. With bated breath, I shared my plight, providing evidence of my dilemma and praying for a solution. To my astonishment, a prompt response came, swift and reassuring. Wizard Web Recovery wasted no time in assessing my situation, guiding me through the process with patience and expertise. and then like a ray of sunshine breaking through the clouds, came the news I had longed for – a new private key had been generated, restoring my precious bitcoins. It was a moment of jubilation, a triumph over adversity that filled me with newfound hope. At that moment, I realized the true power of Wizard Web Recovery, not just as skilled technicians, but as guardians of trust in the digital realm. With their assistance, I reclaimed what was rightfully mine, turning despair into determination and paving the way for a brighter future. But their capabilities did not end there. Delving deeper into their expertise, I discovered that Wizard Web Recovery possessed a wealth of knowledge in reclaiming lost stolen cryptocurrency, and even exposing fraudulent investment schemes. So to all those who find themselves entangled in the web of online fraud, take heart. With the guidance of Wizard Web Recovery, there is a path to redemption.     Write Mail; ( Wizard webrecovery AT  vprogrammer. net ) 
    • It all began with a chance encounter with a testimonial shared by Olivia, a fellow traveler on the winding road of cryptocurrency. Her words spoke of a miraculous recovery orchestrated by Wizard Web Recovery, a beacon of hope in the murky waters of online fraud. Intrigued by her story, I reached out to Wizard Web Recovery, hoping they could work their magic on my blocked crypto recovery. With bated breath, I shared my plight, providing evidence of my dilemma and praying for a solution. To my astonishment, a prompt response came, swift and reassuring. Wizard Web Recovery wasted no time in assessing my situation, guiding me through the process with patience and expertise. and then like a ray of sunshine breaking through the clouds, came the news I had longed for – a new private key had been generated, restoring my precious bitcoins. It was a moment of jubilation, a triumph over adversity that filled me with newfound hope. At that moment, I realized the true power of Wizard Web Recovery, not just as skilled technicians, but as guardians of trust in the digital realm. With their assistance, I reclaimed what was rightfully mine, turning despair into determination and paving the way for a brighter future. But their capabilities did not end there. Delving deeper into their expertise, I discovered that Wizard Web Recovery possessed a wealth of knowledge in reclaiming lost stolen cryptocurrency, and even exposing fraudulent investment schemes. So to all those who find themselves entangled in the web of online fraud, take heart. With the guidance of Wizard Web Recovery, there is a path to redemption.    
    • How can I add drops when killing an entity? Now there are no drops. How can I add an @override to change the attack speed to 1.6 and show "when in main hand...attack damage,...attack speed"? also, how can I make the item enchantable? 
  • Topics

×
×
  • Create New...

Important Information

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