Jump to content

Recommended Posts

Posted

Hey guys!

 

I have a question on how to switch models.

There is an item in my mod, called the psychedelic shroom.

Now, I want to make dogs look like cats if that shroom was eaten.

After a while, the effects reset and dogs look like cats again.

However, I just want them to render like a cat, their entity stays the same.

 

Where can I switch the models (in clientside, since others who didn't eat the shroom look everything normally)?

How do I access the render classes?

 

Thanks for some ideas!

Posted

First I will ask - can you update 1.9+? You should.

 

If not, I will try to answer because code differs and idk if you have access to specific events/methods in 1.8.

  Quote

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

Posted

Do you have "RenderLivingEvent" in 1.8?

 

The PROPER approach is to use said event.

1. Check if you are hallucinating and if entity rendered is Dog.

2. Cancel event and render cat instead.

3. To render cat you will need ... and here are some problems.

* Each Render class is designed to work specifically with given entity and render specific model.

* If inside RenderCat (idk name) there are any casts of entity to cat entity and cat-specific fields are used, you can't really use it.

So:

* If there aren't - you can try getting instance of RenderCat from RenderingRegistry - look for getter methods or access map directly.]

* If said render class uses some cat-specific stuff - you will need to recreate it.

In that case:

* Extend RenderDog or RenderLiving and copy most of code from render cat. to achieve same rendering.

 

Now: In renders there are cases where Render class needs to store some entity render data in entity fields - let's say some render uses "currentLegMovement" saved in entity to rotate leg of entity. In this case this is probably not needed, but if you would need to store such additional data you can use IEEP to do so and write Render class to use those fields.

 

Since dog and cat are pretty much same, I don't think it will be hard (where for some entities it is hard).

  Quote

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

Posted

wfobEla.jpg

 

Read what I said again - where the hell did you get all those methods...

The ONLY thing you need is said event and what I described.

 

Other problem at hand is this:

  On 7/27/2016 at 9:59 AM, Ernio said:

1. Check if you are hallucinating and if entity rendered is Dog.

 

Hallucinating has to be stored somehow - for that you can make your food apply custom potion effect on player or change some boolean that could be stored inside IExtendedEntityProperties - all that can be found on google, if you have any problems, ask.

  Quote

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

Posted

Nice xD

 

public class BLEventHandler {

 private final Render renderCat = new RenderOcelot(Minecraft.getMinecraft().getRenderManager(), new ModelOcelot(), 0.5F);

@SubscribeEvent
public void onRenderLiving(RenderLivingEvent event) {	

	System.out.println("does this work");
	//if(event.entityLiving.isPotionActive(BLFeatures.fungiPotion)) {
		if(event.renderer instanceof RenderWolf) {
			System.out.println("Is this correct?");
			 event.setCanceled(true);
			 renderCat.doRender(event.entity, 0F, 0F, 0F, 0F, 0F);
		}
	//}
}
  
}

 

I have this but it doesnt trigger the event idk why.

 

ClientProxy:

    @Override
    public void preInit(FMLPreInitializationEvent e) {
        super.preInit(e);
        
        BLEventHandler event = new BLEventHandler();
        MinecraftForge.EVENT_BUS.register(event);
        FMLCommonHandler.instance().bus().register(event);
        
        BlockRenderRegister.preInit();
        ItemRenderRegister.preInit();      
    }

 

Main

@EventHandler
public void init(FMLInitializationEvent event) {
    this.proxy.init(event);
    
	MinecraftForge.EVENT_BUS.register(new BLEventHandler());
}

 

 

Posted

1st of all - centralize your code. Move event registration to one place.

 

You do this:

MinecraftForge.EVENT_BUS.register(new BLEventHandler());

and this:

BLEventHandler event = new BLEventHandler();
MinecraftForge.EVENT_BUS.register(event);
FMLCommonHandler.instance().bus().register(event);

Which means you make 2 instances / 2 registers.

 

Recommended design:

 

Make 4 classes:

CommonFMLEvents

CommonForgeEvents

ClientFMLEvents

ClientForgeEvents

 

... place all common events in common class and register it from main mod (pre init) or common proxy.

Place all client only events (which in this case is RenderLivingEvent) in client class and register it from client proxy.

FML and Forge events can be recognized by package they are in (which in later versions of forge is merged).

 

Now onto actual problems:

1. This should work:

private final Render renderCat = new RenderOcelot(Minecraft.getMinecraft().getRenderManager(), new ModelOcelot(), 0.5F);

... but I'd pull Render instance from RenderingRegistry.

 

2.

if(event.entityLiving.isPotionActive(BLFeatures.fungiPotion))

This will check if entity to-be-rendered has potion. When you want is to check is Minecraft.getMinecraft().thePlayer has potion effect (how to make custom potion effect deserves another thread if you can't find it already).

 

3. Don't ever use global event - use Pre or Post (sub-events of rendering events, look inside event class). Cancel Pre and render in Pre. In this case you don't have to touch Post.

 

4. Everything after seems fine. You cancel normal render and do ocelot.

 

SO WHY IT DOESN'T WORK?!

 

Funny thing - if my 1st part of post (about cleaning up event classes) will not fix it (because you might have some big mistakes that I can't see) - which I don't think it will, you my friend are fucked.

 

During 1.8 code has been heavily refactored after 1.7.10->1.8 rendering updates. There is high possibility that RenderLivingEvent IS NOT CALLED at all (disabled) - because there was such time. You can be sure by checking callbacks on Pre and Post sub-event. If it has none - you NEED to update (there are ways to make it work but PLEASE consider updating to 1.8.9+ to do this properly).

  Quote

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

Posted

So instead checking the renderer, I checked the entity (event.entity instanceof EntityWolf),

and I changed it to .Pre.

 

It obviously spammed the line into the console log, but Minecraft crashed.

 

Here is the log:

 

 

  Reveal hidden contents

 

Posted
private final Render renderCat = new RenderOcelot(Minecraft.getMinecraft().getRenderManager(), new ModelOcelot(), 0.5F);

@SubscribeEvent
public void onRenderLiving(RenderLivingEvent.Pre event) {	

	if(Minecraft.getMinecraft().thePlayer.isPotionActive(BLFeatures.fungiPotion)) {
		if(event.entity instanceof EntityWolf) {
			//System.out.println("Is this correct?");
			 event.setCanceled(true);
			 renderCat.doRender(event.entity, 0F, 0F, 0F, 0F, 0F);
		}
	}
}

Posted

Am gonna be pretty straight with you - you don't seem like the best coder there is (don't take it personally), so unless you update most of us can't really help you without seeing 1.8 files.

 

Current state of Render classes (1.9+) is so much better and what you do there works on my 1.10. There is probably something messy in 1.8 about it.

 

All in all - UPDATE (please?) :P

  Quote

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

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.