Jump to content

[1.8] Override EntityFishHook


badner

Recommended Posts

Hi,

 

how can I override, or extend EntityFishHook.class and use the new Class instead of the old? If im extending the EntityFishHook.class how can I register it? Should it looks like this:

 

EntityRegistry.registerModEntity(NewEntityFishHook.class, ... I dont know ...);

 

Thank you :)

Link to comment
Share on other sites

I am trying to "extend" the vanilla entity, which means that all methods and so on are the same, and do the same. But some methods are able to do additional things e.g. showing information on gui, if a fish "is coming".

 

I dont want add/remove fish, junk and treasure.

Link to comment
Share on other sites

I want this: So you are trying to replace the vanilla entity?  And thats the answer of your question. -Yes

I tried this: Or make your own that is similar?

 

But whats the difference between replacing the vanilla entity and make an own that is similar?

 

 

Link to comment
Share on other sites

Registering the entity doesn't magically make the ItemFishingRod class spawn it when used.

 

And that bit you don't know?  It's either strings or ints, which are largely irrelevant.  Meaning you can put fuckanything in and it'll work.  But it still doesn't magically make the Fishing rod use the new lure.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Why not use the EntityJoinWorldEvent? Just cancel it and spawn your own fishing hook.

- Make sure to check if the entity is the vanilla fishing hook by checking if the class of the entity (

entity#getClass()

) is equal to the EntityFishingHook class (

EntityFishingHook#class

)

- cancel the event to prevent spawning the original

- apply every value from the vanilla entity to yours (motion, position, etc.)

- spawn your custom entity

 

But why do you need to replace the hook entirely? Does the FishingHooks.java not suffice? What do you want to do with it?

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

But why do you need to replace the hook entirely? Does the FishingHooks.java not suffice? What do you want to do with it?

 

He answered that already:

 

But some methods are able to do additional things e.g. showing information on gui, if a fish "is coming".

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

But why do you need to replace the hook entirely? Does the FishingHooks.java not suffice? What do you want to do with it?

 

He answered that already:

 

But some methods are able to do additional things e.g. showing information on gui, if a fish "is coming".

 

Oh, didn't see that one. So yeah, the EntityJoinWorldEvent should be used to replace it then.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

Why not use the EntityJoinWorldEvent? Just cancel it and spawn your own fishing hook.

- Make sure to check if the entity is the vanilla fishing hook by checking if the class of the entity (entity#getClass()) is equal to the EntityFishingHook class (EntityFishingHook#class)

- cancel the event to prevent spawning the original

- apply every value from the vanilla entity to yours (motion, position, etc.)

- spawn your custom entity

 

According to your post, I added this method to the Eventhandler class:

 

@SubscribeEvent
public void fishJoinEvent(EntityJoinWorldEvent event){
if(event.getClass().equals(EntityFishHook.class)){
	System.out.println("here it is!");
}
}

 

Unfortunately nothing happend...

 

What are the next steps? How can I spawn my own entity?

 

I also tried to use this:

 

RenderingRegistry.registerEntityRenderingHandler(EntityFishHook.class, new RenderFish(Need a Rendermanager));

 

In this case I should able to create a custom RenderFish. Can I get the information which I need in RenderFish?

 

 

Link to comment
Share on other sites

In the main class of my mod:

 

(head of the class)

MyEventHandler handler = new MyEventHandler();

 

and then in:

 

@EventHandler
public void preinit(FMLPreInitializationEvent preevent){

MinecraftForge.EVENT_BUS.register(handler);
//some code here
}

 

The Eventhandler is working, because my other SubscribeEvents like RenderGameOverlayEvent or ClientChatReceivedEvent are working.

Link to comment
Share on other sites

Ups... -->  event.entity.getClass()  :)

 

[23:44:13] [server thread/INFO] [sTDOUT]: [MyEventHandler:fishJoinEvent:22]: its a fishing hook

[23:44:13] [Client thread/INFO] [sTDOUT]: [MyEventHandler:fishJoinEvent:22]: its a fishing hook

 

My Code must only work on clientside, how can i reach this?

 

What are the next steps to:

- cancel the event to prevent spawning the original

- apply every value from the vanilla entity to yours (motion, position, etc.)

- spawn your custom entity

 

Link to comment
Share on other sites

Since this is client-only I assume you want to display something (as you told few posts before). What exacly do you want to do with what data that should be in your customHook?

 

EntityFishHook is an Entity, that means you can use IExtendedEntityProperties to store additional info. To render ANY kind of stuff that would be inside either EntityFishHook or IEEP you can use RenderWorldLastEvent to find hook in world and even render labels with info above it. You can also use RenderGameOverlayEvent to add custom info on your game screen when fishEntity field in player is not null.

 

Possibilities = endless.

Also - yes, this can be done for client-only, as long as you won't be keeping any data that should be shared with server.

 

Now what exacly is that you want?

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

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.