Extending a method on an interface

This is probably basic java, but I'm new to the language, so please forgive me

I would like to extend the SetCustomName method of LivingEntity so that, in addition to it's normal steps, it will also throw a custom event/exception.

My attempts to do this result in errors regarding abstract, and can't have body.

In addition, I can't tell if this is a class or an interface, which means I'm not sure if I should use extends or implements.

Finally, I'm looking to add this functionality, rather then create a new object.

Can you please tell me if this is possible / steer me in the correct direction? Thank you very much for the help.


LivingEntity is an interface, CraftLivingEntity is a class. You can only extend a class, you implement an interface. The interface itself has no "normal steps".

If you can control whether CraftLivingEntity or a different class is instantiated, extend CLE as follows

public class MyCraftLivingEntity extends CraftLivingEntity {

    @Override // just a marker annotation to help catch inheritance issues
    public void setCustomName(String name) {


         // do whatever else

and instantiate your class instead.

Looked at your file you gave from GitHub..

LivingEntity is an interface and so you would have to implement it into another class because it's methods aren't allowed to be defined.

Just follow Emerson's overridden method, as it's correct. Put your custom code under the call to super.setCustomName(name);.

Need Your Help

java constructor handling lack of arguments


i have this code here for a person details and the person should be intialized always whatever the number of possible arguments given ,like for example only height and age or salary and age

Where do I set cookies when my web application receives an HttpRequest?

c# post cookies httpwebrequest set

Where in my C# code do I need to put the code for setting cookies? Firefox shows three cookies when I'm logged in to the system.