Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

When a class/object is a child of another (it extends from it), it also has its fields and methods (only public and protected fields can be accessed directly).

If you want to have a different implementation of any of the parent methods, you override them.

For example, if you have a base class which describes all GeometricShapes and in it you have a method getArea().

You can override this method in the class triangles and rectangles which extend from GeometricShapes and you can make them return the respective areas.

Edited by Cerandior

Hi

 

The reason you should use @Override (it's optional) is so that, when Forge or minecraft updates and the signature for a method changes, your compiler tells you that there is a problem. 

 

eg

 

public class ItemVariants extends Item
{
  // what animation to use when the player holds the "use" button
  @Override
  public UseAction getUseAction(ItemStack stack) {
    return UseAction.DRINK;
  }
}

 

When minecraft is updated, and getUseAction(ItemStack stack) changes to getUseActionAnimationType(ItemStack stack), or changes to getUseAction(ItemStack stack, Hand whichHandUsing), then your compiler will give you an error.

Otherwise your code will silently stop working because your item will now use the Item base method which is

   public UseAction getUseAction(ItemStack stack) {
      return stack.getItem().isFood() ? UseAction.EAT : UseAction.NONE;
   }

 

This happens a lot and from bitter experience I can tell you that @Override can save you hours of pain and frustration.

 

-TGG

 

 

1 hour ago, axilirate said:

Thanks.

Override is typical Java. If you don‘t know Java 8 then learn this before you begin. Java has a JavaDoc, in them you can see what methods or functions can make. Hope this will help you

New in Modding? == Still learning!

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.