Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7943385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:15:34+00:00 2026-06-04T00:15:34+00:00

Possible Duplicate: extending from two classes I’m currently trying to make a simple Mod

  • 0

Possible Duplicate:
extending from two classes

I’m currently trying to make a simple Mod for Minecraft and I basically need this code:

(I don’t want to edit many classes because I want my mod to be compatible with many other mods.)

public class EntityModPlayer extends EntityPlayer, EntityCreature
{
    super(par1World);
    fishHook = new EntityFishHook(this /* has to be EntityPlayer */);
    tasks.addTask(0, new EntityAISwimming(this /* has to be EntityCreature */));
}

But you can’t extend more than one class…

The new EntityFishHook* wants a EntityPlayer and not a EntityModPlayer as param but the new EntityAISwimming method wants me to use an instance of EntityCreature as param. So I need to “extend” EntityPlayer AND EntityCreature and can’t just copy EntityPlayer and paste it as EntityModPlayer.

I already played around with Interfaces but I think this is something different so I can’t use this like “extends”.

Sorry @ everybody who doesn’t know Minecraft or can’t understand my english… (I’m german.)

Any ideas where I don’t have to change many / important classes like EntityTasks (because this would make my mod incompatible with other mods if they are editing the same class)?

*The method new EntityFishHook (EntityPlayer) does not really exist in Minecraft. I just used this as an example to explain it better. I hope you understood what I tried to explain, I’m sure it’s not easy :/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T00:15:36+00:00Added an answer on June 4, 2026 at 12:15 am

    The correct idiom for Java ( and other single inheritance languages ) is to have two interfaces. EntityPlayer and EntityCreature then you combine them into a single class that Implements each of the interfaces.

    Another approach is to use the Composite Pattern to create a single class that has all the methods from each Class and have that class delegate each of the methods to instances of each of the internal classes owned by the single class that combines the interfaces. This works if the client code doesn’t expect either of the interfaces at a language level or with a duck typing language like Python.

    You can combine both approaches two interfaces with the Composite Pattern and have the Composite object delegate to individual implementations of each Interface, this would enable easy dependency injection; making your code more flexible using something like Google Guice.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: XPath: How to match attributes that contain a certain string I'm trying
Possible Duplicate: thread with multiple parameters How does one thread a sub with two
Possible Duplicate: Extracting dollar amounts from existing sql data? I have a column in
Possible Duplicate: Turning on camera flash LED in Android? I need to turn on
Possible Duplicate: Java: “implements Runnable” vs. “extends Thread” I have two questions about multithreaded
Possible Duplicate: Make copy of array Java I'm a beginner at Java and I
Possible Duplicate: How do I make a list with checkboxes in Java Swing? I
Possible Duplicate: How would I identify if a website originates from a mobile browser?
Possible Duplicate: git - removing a file from source control (but not from the
Possible Duplicate: Find out the instance id from within an ec2 machine I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.