Jump to content

Recommended Posts

Posted (edited)

I am trying to have my item heal when the player right clicks with it out. How should I go about this? Thank you. I realize I know how to increase the health, add a cooldown, I'm familiar with getting health, setting health. I would use itemInteractionForEntity however, I do not know how to heal without interacting with an entity which may be compromising in an intense fight. 

Edited by Justin_Perry
Posted

Item#onItemUse.

Some tips:

  Reveal hidden contents

 

Posted
  On 3/27/2019 at 11:13 PM, DavidM said:

Item#onItemUse.

Expand  
public class stimSelf extends Item implements IHasModel {
	
public stimSelf(String name) {
		
		setUnlocalizedName(name);
		setRegistryName(name);
		setCreativeTab(CreativeTabs.MISC);
		modItems.ITEMS.add(this);
	}
	
	@Override
	public void registerModels() {
		Main.proxy.registerItemRenderer(this, 0, "inventory");
	}
	
	@Override
	public ActionResult<ItemStack> onItemUse(ItemStack itemStack, World world, EntityPlayer player) {
		
		if (player.getHealth() < player.getMaxHealth()) {
			System.out.println("We healed.");
			player.setHealth(player.getHealth() + 5.0F);
			player.getCooldownTracker().setCooldown(modItems.STIM_SELF, 300);
		}else {
			System.out.println("We have not healed.");
		}
		
		return null;
	}
}

 

I have no output. Can you help?

 

Warning: The method onItemUse(ItemStack, World, EntityPlayer) of type stimSelf must override or implement a supertype method.

 

Thank you.

Posted
  On 3/27/2019 at 11:36 PM, Justin_Perry said:

Warning: The method onItemUse(ItemStack, World, EntityPlayer) of type stimSelf must override or implement a supertype method. 

Expand  

It usually means your signature doesn't match with the function you are overriding.

As a result your function doesn't get called at all.

 

Also i think your return value should be FAILED or SUCCESS.

I am not sure at the moment, look at what the parents function does.

  • Like 1
Posted
  On 3/27/2019 at 11:44 PM, Keitaro said:

It usually means your signature doesn't match with the function you are overriding.

As a result your function doesn't get called at all.

 

Also i think your return value should be FAILED or SUCCESS.

I am not sure at the moment, look at what the parents function does.

Expand  

Not very helpful.

Posted (edited)
  On 3/28/2019 at 12:03 AM, Justin_Perry said:

Not very helpful.

Expand  

... He literally just told you what is problem is and how to fix it.

 

Like what Keitaro said:

  On 3/27/2019 at 11:44 PM, Keitaro said:

It usually means your signature doesn't match with the function you are overriding.

As a result your function doesn't get called at all.

Expand  

, check your parameters. An overriding method must have the same parameters as the method it is overriding.

Edited by DavidM

Some tips:

  Reveal hidden contents

 

Posted
  On 3/28/2019 at 12:06 AM, DavidM said:

... He literally just told you what is problem is and how to fix it.

 

Check your parameters. An overriding method must have the same parameters as the method it is overriding.

Expand  

Something that may be easy for you to understand and interpret can be hard for others. I have checked my parameters. 

public class stimSelf extends Item implements IHasModel {
	
public stimSelf(String name) {
		
		setUnlocalizedName(name);
		setRegistryName(name);
		setCreativeTab(CreativeTabs.MISC);
		modItems.ITEMS.add(this);
	}
	
	@Override
	public void registerModels() {
		Main.proxy.registerItemRenderer(this, 0, "inventory");
	}
	
	@Override
	public ActionResult<ItemStack> onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float xFloat, float yFloat, float zFloat) {
		
		if (player.getHealth() < player.getMaxHealth()) {
			System.out.println("We healed.");
			player.setHealth(player.getHealth() + 5.0F);
			player.getCooldownTracker().setCooldown(modItems.STIM_SELF, 300);
			return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
		}else {
			System.out.println("We have not healed.");
			return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);
		}
		
	
	}
}

You tell me.

Posted (edited)
  On 3/28/2019 at 12:15 AM, Justin_Perry said:

Something that may be easy for you to understand and interpret can be hard for others

Expand  

"Overriding" is basic java knowledge; you are expected to know it according to the forum rules.

 

  On 3/28/2019 at 12:15 AM, Justin_Perry said:

You tell me.

Expand  

Since you did not specify the version of Minecraft you are modding for, I'm going to assume it's 1.12.2.

Item#onItemUse is defined as:

public EnumActionResult onItemUse (EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)

Well as you can see:

  • "EnumActionResult" is not spelt "ActionResult<ItemStack>"
  • "EntityPlayer" is not spelt "ItemStack"
  • "BlockPos" is not spelt "int"

Therefore, you are creating a new method instead of overriding an existing one.

 

As a general suggestion, you should always use your IDE to do the overriding for you instead of manually typing it out.

Edited by DavidM

Some tips:

  Reveal hidden contents

 

Posted
  On 3/28/2019 at 12:58 AM, DavidM said:

"Overriding" is basic java knowledge; you are expected to know it according to the forum rules.

 

Since you did not specify the version of Minecraft you are modding for, I'm going to assume it's 1.12.2.

Item#onItemUse is defined as:

public EnumActionResult onItemUse (EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)

Well as you can see:

  • "EnumActionResult" is not spelt "ActionResult<ItemStack>"
  • "EntityPlayer" is not spelt "ItemStack"
  • "BlockPos" is not spelt "int"

As a general suggestion, you should always use your IDE to do the overriding for you instead of manually typing it out.

Expand  

Alright, thank you for nothing. I will figure everything else I'll need to make this mod by myself or by reading. Thanks

Posted (edited)
  On 3/28/2019 at 1:04 AM, Justin_Perry said:

Alright, thank you for nothing. I will figure everything else I'll need to make this mod by myself or by reading. Thanks

Expand  

You won't get far without the understanding of basic java.

As a general suggestion, learn java before making a mod.

Edited by DavidM
  • Sad 1

Some tips:

  Reveal hidden contents

 

Posted
  On 3/28/2019 at 1:06 AM, DavidM said:

I doubt you will get anywhere without the understanding of basic java.

As a general suggestion, learn java before making a mod.

Expand  

I would rather have a lesser understanding of java on my own than continue to be ridiculed. I searched high and low on information on onItemUse, while your eventual solution may have worked, you have made me really discouraged from asking for more help. I haven't learned everything in Java, no. But I do know how to make classes, variables, functions, and a bit more. Again, I appreciate your help, but you are not a nice person. Please refrain from talking to me anymore.

Posted

Telling you that we expect you to have a working knowledge of the language you are using is not ridicule.

If Java is the first programming language you are learning, I'm afraid learning through Minecraft modding is about the worst way to go about it, please see if you can take an online course or something.

This is my Forum Signature, I am currently attempting to transform it into a small guide for fixing easier issues using spoiler blocks to keep things tidy.

 

As the most common issue I feel I should put this outside the main bulk:

The only official source for Forge is https://files.minecraftforge.net, and the only site I trust for getting mods is CurseForge.

If you use any site other than these, please take a look at the StopModReposts project and install their browser extension, I would also advise running a virus scan.

 

For players asking for assistance with Forge please expand the spoiler below and read the appropriate section(s) in its/their entirety.

  Reveal hidden contents

 

Posted
  On 3/28/2019 at 1:31 AM, DaemonUmbra said:

Telling you that we expect you to have a working knowledge of the language you are using is not ridicule.

If Java is the first programming language you are learning, I'm afraid learning through Minecraft modding is about the worst way to go about it, please see if you can take an online course or something.

Expand  

Telling me I don't know how to override is a complete insult. I have at least an item that heals others. I obviously had to override to do that. The issue is mostly the lack of forge documentation for low-level modders to look into. I have learned Python, taken C++ courses, and learned a moderate amount of Java.

Posted

Where did you get the method/function signature for onItemUse, did you copy it from a tutorial or from the base/super class?

This is my Forum Signature, I am currently attempting to transform it into a small guide for fixing easier issues using spoiler blocks to keep things tidy.

 

As the most common issue I feel I should put this outside the main bulk:

The only official source for Forge is https://files.minecraftforge.net, and the only site I trust for getting mods is CurseForge.

If you use any site other than these, please take a look at the StopModReposts project and install their browser extension, I would also advise running a virus scan.

 

For players asking for assistance with Forge please expand the spoiler below and read the appropriate section(s) in its/their entirety.

  Reveal hidden contents

 

Posted
  On 3/28/2019 at 1:50 AM, DaemonUmbra said:

Where did you get the method/function signature for onItemUse, did you copy it from a tutorial or from the base/super class?

Expand  

I was googling what other people used to execute a function when an item was right clicked. I found some old information and tried to incorporate it in 1.12. Apparently, it did not work. I found a youtube video that used the ActionResult<ItemStack> other than that, I was at a loss. I found no information that would have lead me to EnumActionResult. I have since implemented what DavidM suggested and it works. 

Posted

You looked at random people's code for answers before looking at the class you were extending?

This is my Forum Signature, I am currently attempting to transform it into a small guide for fixing easier issues using spoiler blocks to keep things tidy.

 

As the most common issue I feel I should put this outside the main bulk:

The only official source for Forge is https://files.minecraftforge.net, and the only site I trust for getting mods is CurseForge.

If you use any site other than these, please take a look at the StopModReposts project and install their browser extension, I would also advise running a virus scan.

 

For players asking for assistance with Forge please expand the spoiler below and read the appropriate section(s) in its/their entirety.

  Reveal hidden contents

 

Posted

And you chose to not look directly at the class and method you were overriding for the method signature, then got confused when you got the error that your override didn't work.

This is my Forum Signature, I am currently attempting to transform it into a small guide for fixing easier issues using spoiler blocks to keep things tidy.

 

As the most common issue I feel I should put this outside the main bulk:

The only official source for Forge is https://files.minecraftforge.net, and the only site I trust for getting mods is CurseForge.

If you use any site other than these, please take a look at the StopModReposts project and install their browser extension, I would also advise running a virus scan.

 

For players asking for assistance with Forge please expand the spoiler below and read the appropriate section(s) in its/their entirety.

  Reveal hidden contents

 

Posted (edited)

1.

  On 3/28/2019 at 1:35 AM, Justin_Perry said:

Telling me I don't know how to override is a complete insult. I have at least an item that heals others. I obviously had to override to do that.

Expand  
  On 3/27/2019 at 11:36 PM, Justin_Perry said:

I have no output. Can you help?

 

Warning: The method onItemUse(ItemStack, World, EntityPlayer) of type stimSelf must override or implement a supertype method.

Expand  

Your problem is caused by not (fully) knowing how overriding works, or else this error won’t occur.

The IDE is telling you "hey this method does not exist in the parent class", therefore you should make sure your method matches the method in the superclass.

 

2. Always look at the source code first, as the source code is definitely updated and functional, whereas answers on the internet can be old and not fitted to use in the current version.

Edited by DavidM

Some tips:

  Reveal hidden contents

 

Posted

If you know about

  On 3/28/2019 at 1:11 AM, Justin_Perry said:

functions

Expand  

you should really, really already know about overriding. Unless you meant methods, in which case overriding should probably be the next thing you learn.

About Me

  Reveal hidden contents

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted
  On 3/28/2019 at 1:35 AM, Justin_Perry said:

Telling me I don't know how to override is a complete insult.

Expand  

We have 4 people so far telling you that you should know how to override. All of them are more experienced than you at java from what we've seen so far. If you don't want to learn the java, we are no help to you until you know at least the basics.

  On 3/28/2019 at 12:03 AM, Justin_Perry said:

Not very helpful.

Expand  

 

  On 3/28/2019 at 12:06 AM, DavidM said:

... He literally just told you what is problem is and how to fix it.

Expand  

The post could have been ended right then and there if you knew how to override.

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 have no idea - maybe use a pre-configured modpack as working base and add some new mods one by one
    • Is there a crash-report?   The given log is literally just a 230 MB file of open GL error spam
    • Lemfi coupon code 15€ Bonus is the easiest way for you to turn a routine money‑transfer into instant savings—and we are thrilled to show you how. We tested it ourselves and unlocked the extra cash in seconds. RITEQH6J is the single code you need, and it delivers maximum benefits whether you are sending funds from Toronto, Paris, or Sydney. You simply enter the code once, and every eligible transaction keeps rewarding you. When you add Lemfi discount code 15€ off or Lemfi code 15€ Bonus to your transfer, you’re stacking value on security. In the next few minutes, we’ll prove that Lemfi is safe to use in Canada and walk you through the exact steps to claim your €15 windfall. What Is The Lemfi Promo Code for 15€ Bonus? Both new and existing customers enjoy a richer experience when they activate our Lemfi coupon 15€ Bonus—sometimes called the 15€ Bonus Lemfi coupon. It’s the same five‑character code, but the perks multiply depending on your status: RITEQH6J – 15 € instant bonus credited the moment you initiate a qualifying transfer RITEQH6J – 30 € sign‑up reward for brand‑new Lemfi users who complete KYC RITEQH6J – 10 % cashback (up to 50 €) on your very first transfer RITEQH6J – 20 € referral reward after your invitee finishes 20 transactions RITEQH6J – 20 € cashback on any recurring money‑transfer plan you schedule RITEQH6J – 30 € extra bonus when you send 100 € or more in a single transfer Lemfi First Time Promo Code 15€ Bonus For New Users In 2025 You get the richest haul of incentives when you join Lemfi in 2025 and apply our Lemfi First Time Promo Code for 15€ Bonus—also known as Lemfi Promo Code First Order 15€ Bonus. Below are the headline gains: RITEQH6J – 15 € credited to every qualified user, instantly RITEQH6J – 30 € one‑time welcome bonus the day you finish sign‑up RITEQH6J – 10 % cashback (max 50 €) on your inaugural transfer RITEQH6J – Second‑tier 30 € bump once your first transfer exceeds 100 € RITEQH6J – Free intra‑app transfers for 90 days, saving you FX mark‑ups How To Redeem The Lemfi Coupon 15€ Bonus For New Users? Lemfi First Time Promo Code for 15€ Bonus, Lemfi Promo Code First Order 15€ Bonus, and Lemfi First Time Promo Code 15€ Bonus for new users are redeemed in six quick moves: Download Lemfi from Google Play / App Store. Open an account with your legal name and Canadian address. Complete photo ID verification and selfie check. On the “Promo” screen, paste RITEQH6J and tap “Apply.” Initiate your first money transfer of 10 € or more. Watch the 15 € bonus hit your Lemfi balance before the funds even settle. Lemfi Promo Code 15€ Bonus For Existing Customers Already have a wallet? Great news: the lemfi promo code 15€ Bonus for existing users doubles down on loyalty, and the lemfi discount code 15€ Bonus for existing customers ensures you never miss a rebate. RITEQH6J – Flat 15 € credited to every fresh transaction over 10 € RITEQH6J – 20 € referral payout after each invited friend completes 20 transfers RITEQH6J – 20 € cashback when you fund a recurring transfer plan RITEQH6J – 30 € bonus when any single transfer tops 100 € How To Use The Lemfi Code for 15€ Bonus For Existing Customers? Follow this path to apply the Lemfi discount code for 15€ Bonus, the Code promo Lemfi for 15€ Bonus, after your Lemfi login: Sign in and tap the “Promotions” tab. Enter RITEQH6J in the promo box and confirm. Start a new transfer or schedule a future one. The system auto‑deducts the bonus from your payable amount or credits it to your wallet. Latest Lemfi Promo Code for 15€ Bonus The freshest drop—Lemfi first time promo code for 15€ Bonus first order, Lemfi discount code 15€ Bonus, and Lemfi cashback code—all point to one hero string: RITEQH6J – 15 € for every user, every time RITEQH6J – 30 € sign‑up sweetener for new users RITEQH6J – 10 % cashback (capped at 50 €) on your very first transfer RITEQH6J – 20 € friend‑referral reward after 20 completed transfers RITEQH6J – 20 € cashback on automated transfer plans RITEQH6J – 30 € bonus when you move 100 € or more in one go How To Find The Lemfi Code for 15€ Bonus? You can score the Lemfi code for 15€ Bonus, the Lemfi cashback code, and the crowd‑sourced Lemfi referral code Reddit for 15€ Bonus in three reliable ways. First, subscribe to the Lemfi newsletter—verified codes often land there before anywhere else. Second, follow Lemfi on X (formerly Twitter), Instagram, and LinkedIn for flash promos. Third, bookmark reputable coupon portals (like ours) where every code is tested daily for real‑world success. Is Lemfi 15€ Bonus Code Legit? Is Lemfi legit? Absolutely. Lemfi (legal name Lemonade Technology Ltd.) is a registered Money Service Business with FINTRAC in Canada under registration #M20383642 opengovca.com. That means every Canadian transfer is overseen by federal anti‑money‑laundering regulators. More importantly, code promo Lemfi legit status is guaranteed: we refresh and re‑test RITEQH6J weekly. The promo has no geographic restrictions, so you can claim the 15 € Bonus on your first Lemfi money transfer and stack it on future transactions worldwide. How Does Lemfi Code for 15€ Bonus Work? 15€ Bonus on first-time Lemfi money transfer is credited the moment our system recognises the code during checkout, and Lemfi promo code for recurring transactions continues to provide cashback or flat bonuses on qualified transfers thereafter. In practice, you paste RITEQH6J once, Lemfi tags it to your customer ID, and the platform’s automated ledger applies the correct reward (bonus credit or cashback) to each eligible transaction until you choose to remove or replace the code. How To Earn Lemfi 15€ Bonus Coupons As A New Customer? To grab the next Lemfi coupon code 15€ Bonus or the elusive 100 off Lemfi coupon code, complete KYC, enable two‑factor authentication, and engage with Lemfi’s seasonal challenges (e.g., “Send three transfers in one week”). Each milestone adds fresh coupons to your in‑app Promo Wallet, which you can stack on top of RITEQH6J for even bigger savings. What Are The Advantages Of Using The Lemfi Discount Code for 15€ Bonus? Lemfi promo code for 15€ bonus delivers an immediate 15 € credit Lemfi promo code for 15€ Bonus stacks with a 30 € sign‑up reward Up to 50 € cashback (10 %) on your inaugural transfer 20 € cash per referral after 20 transactions 20 € cashback on automated recurring transfers 30 € boost on any single 100 €+ transfer Unlimited global usage—no expiry date Works for both CAD and EUR wallets Lemfi Discount Code For 15€ Bonus And Free Gift For New And Existing Customers Our Lemfi Discount Code for 15€ Bonus—also known as the 15€ Bonus Lemfi discount code—unlocks a treasure chest of perks you won’t find elsewhere: RITEQH6J – 15 € for any qualified transfer RITEQH6J – 30 € welcome credit to brand‑new customers RITEQH6J – 10 % cashback (max 50 €) on your first deal RITEQH6J – 20 € per referral once the invitee completes 20 sends RITEQH6J – 30 € kicker on transfers worth 100 € or more Pros And Cons Of Using The Lemfi Discount Code 15€ Bonus for <July2025> Lemfi 15€ Bonus discount code and the wider Lemfi 15 Euro Bonus program bring clear upsides—plus a couple of caveats: Pros Immediate 15 € savings per qualifying transfer High 30 € sign‑up bonus for newcomers Legit FINTRAC‑regulated service in Canada support.lemfi.com Low FX margins versus banks Stackable with referral and cashback offers Cons Bonuses paid in EUR; conversion fees may apply if you withdraw in CAD Cashback rewards require minimum transfer values (10 € or 100 € tiers) Terms And Conditions Of Using The Lemfi Coupon 15€ Bonus In 2025 Lemfi 15€ Bonus code must be entered exactly as “RITEQH6J.” Only one active promo per transaction, but stackable across separate transfers. Latest Lemfi code 15€ Bonus has no expiration date and is valid worldwide. Available to KYC‑verified users aged 18 +. New‑user bonuses credited once per person; device or IP duplication voids offer. Existing‑user cashback requires recurring transfer setup. Lemfi reserves the right to amend terms with 30‑days’ notice. Final Note: Use The Latest Lemfi Discount Code 15€ Bonus Grab the Lemfi discount code for 15€ Bonus today, and you’ll feel the value the second you hit “Send.” We’ve tested it from coast to coast, and the results are always the same—instant savings. Keep Lemfi 15€ Bonus code RITEQH6J in your back pocket, and every future transfer can be a mini payday. Happy saving! FAQs Of Lemfi 15€ Bonus Code Q1. Is Lemfi safe to use in Canada? A1. Yes. Lemfi is a FINTRAC‑registered Money Service Business (MSB #M20383642) and must comply with strict anti‑money‑laundering laws, encryption standards, and regular audits. Q2. Can I combine RITEQH6J with other Lemfi promo codes? A2. You can’t stack two codes on a single transaction, but you may apply RITEQH6J on one transfer and another valid code on a separate transfer to maximise total savings. Q3. Does RITEQH6J expire? A3. No expiration date is set. The code remains active across 2025 and beyond unless Lemfi issues a formal sunset notice—unlikely given its popularity. Q4. How fast is the 15 € bonus credited? A4. The bonus shows up instantly in your Lemfi wallet once the transaction is submitted and KYC is complete, removing any waiting period. Q5. Is the 15 € bonus paid in CAD or EUR? A5. Lemfi credits the bonus in EUR. If your base wallet is CAD, you can convert inside the app at inter‑bank FX rates or keep it in EUR for cross‑border spending.
    • I am trying to make a custom item that converts to another custom item when eaten. The food properties includes "usingConvertsTo(ModItems.ITEM_NAME.get())", however since the item is not yet registered during the registration process, the get() method returns null. Is there any way to work around this?
    • Having problems with forge installation on headless arch linux, regardless of forge-server from yay or manual wget, Cant find class error and results in net/minecraft/world/waypoints/Waypoint$Icon.class   net/minecraft/world/waypoints/Waypoint.class   net/minecraft/world/waypoints/WaypointManager.class   net/minecraft/world/waypoints/WaypointStyleAsset.class   net/minecraft/world/waypoints/WaypointStyleAssets.class   net/minecraft/world/waypoints/WaypointTransmitter$BlockConnection.class   net/minecraft/world/waypoints/WaypointTransmitter$ChunkConnection.class   net/minecraft/world/waypoints/WaypointTransmitter$Connection.class   net/minecraft/world/waypoints/WaypointTransmitter$EntityAzimuthConnection.class   net/minecraft/world/waypoints/WaypointTransmitter$EntityBlockConnection.class   net/minecraft/world/waypoints/WaypointTransmitter$EntityChunkConnection.class   net/minecraft/world/waypoints/WaypointTransmitter.class   version.json   Processor failed, invalid outputs:     /srv/minecraft/./libraries/net/minecraft/server/1.21.6/server-1.21.6-official.jar       Expected: b1448d2c947e923ccd63224defc3b51e5a72a98d       Actual:   5f30bf411bd0d1208baca6b7be1584442f4f6579 There was an error during installation
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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