Jump to content

Recommended Posts

Posted

Hi, I have a problem with the code, it crashes with error method does not override or implement a method from a supertype
I am using 3D model in my Minecraft mod and want to make a feature that will show 16x16 2D texture in inventory and generally in all GUI, and when item in hand it will show 3D model. Using forge 1.18.2 40.1.0 to create the mod.  Here is my code:

package net.mcreator.irondrill.item;

import net.minecraft.world.level.Level;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.Tier;
import net.minecraft.world.item.PickaxeItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Item;
import net.minecraft.world.entity.Entity;

import net.mcreator.irondrill.procedures.MagnitProcedure;
import net.mcreator.irondrill.init.DrillsModTabs;

public class GravityDrillItem extends PickaxeItem {
	public GravityDrillItem() {
		super(new Tier() {
			public int getUses() {
				return 2500;
			}

			public float getSpeed() {
				return 70f;
			}

			public float getAttackDamageBonus() {
				return 6f;
			}

			public int getLevel() {
				return 4;
			}

			public int getEnchantmentValue() {
				return 2;
			}

			public Ingredient getRepairIngredient() {
				return Ingredient.EMPTY;
			}
		}, 1, -3.5f, new Item.Properties().tab(DrillsModTabs.TAB_DRILLMOD));
	}

	@Override
	public void inventoryTick(ItemStack itemstack, Level world, Entity entity, int slot, boolean selected) {
		super.inventoryTick(itemstack, world, entity, slot, selected);
		if (selected)
			MagnitProcedure.execute(world, entity.getX(), entity.getY(), entity.getZ(), entity);
	}

	@Override // a line that makes the code not work.
	public boolean shouldRenderGroup(ItemStack stack, String group) {
		return group.equals("normal") || group.equals("inventory");
	}

	@Override
	public int getUseDuration(ItemStack stack) {
		return 0;
	}
}

How can this be fixed?

(Translated)

  • 2 weeks later...
Posted

If mc doesn't like your code in an Overridden function, it decides not to run that code and shows you the issue with the "does not override or implement a method from its supertype" error. You will see that if you remove the Override annotation, then there will be no action icon in the margin cos mc is unwilling to run it. To fix it, you must recreate mc acceptable code.

Posted
16 minutes ago, DinoPawz said:

If mc doesn't like your code in an Overridden function, it decides not to run that code and shows you the issue with the "does not override or implement a method from its supertype" error. You will see that if you remove the Override annotation, then there will be no action icon in the margin cos mc is unwilling to run it. To fix it, you must recreate mc acceptable code.

That's because overridden methods need to have the same signature as their supertype, you can't just go specifying your own new parameters and returns otherwise it becomes a different method.

I'm the CEO of breaking things 

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.