Jump to content

Recommended Posts

Posted

I have a block that looks exactly like a hopper except for the textures. How do I make my hopper show the correct textures? I managed to make it show the _top and _outside textures using reflection (my textures are just like the ones from the original hopper, but with different colour), but from what I could understand, _inside texture is referenced only inside a method of the RenderBlocks class called renderBlockHopperMetadata, exactly at this line:

 

Icon icon1 = BlockHopper.getHopperIcon("hopper_inside");

 

And that's my problem. That line is invoking a static method. For obvious reasons I can't override a static method (even though I think java should allow that since it's the only language I know where you can access a static member using an instance, like:

 

SomeClass instance = new SomeClass();
instance.SomeStaticMethod(); //this line is one of the top 10 reasons of why java sucks IMO.)

 

and here's the BlockHopper static method:

 

@SideOnly(Side.CLIENT)
public static Icon getHopperIcon(String par0Str)
{
        return par0Str.equals("hopper_outside") ? Block.hopperBlock.hopperIcon :
               (par0Str.equals("hopper_inside") ? Block.hopperBlock.hopperInsideIcon : null);
}

 

What can I do? Basically, all I need to do is change the color of the hopper, nothing more, like tinge it a little. Is there a way to do that? Thanks

Posted

I am thinking that you could try using a GL11.glSomethingOrOtherThatDealsWithOverlayRGBA(Red, Green, Blue, Alpha); somewhere to change the color of only your Hopper... Since I am guessing your hopper extends the other one, couldn't you also just override the method? Or is it in another class?

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Posted

the method that renders the hopper is in another class called net.minecraft.client.renderer.RenderBlocks. And that same class has a method (named renderBlockHopperMetadata) which is called for rendering the hopper. That method in renderBlockHopperMetadata "asks" the hopper for it's icons, but the method it invokes is static (so I can't override it), and it invokes it like this:

 

Icon icon1 = BlockHopper.getHopperIcon("hopper_inside");

 

getHopperIcon does the following:

 

@SideOnly(Side.CLIENT)
public static Icon getHopperIcon(String par0Str)
{
        return par0Str.equals("hopper_outside") ? Block.hopperBlock.hopperIcon :
               (par0Str.equals("hopper_inside") ? Block.hopperBlock.hopperInsideIcon : null);
}

 

so my derived class is left out... And I know nothing of the other thing you said oO GL11 what  :o???

 

 

Posted
For obvious reasons I can't override a static method (even though I think java should allow that since it's the only language I know where you can access a static member using an instance, like:

no and there's actually a good for that but its kinda long to explain (or i suck at explaining things)

 

cant you just override the icons with the one you want and copy the cope to render the hopper in a ISBRH ?

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

The icons are overriden with the ones I want on my class (which are the same, but slightly tinged golden), but as you can see in the code I posted, renderBlockHopperMetadata calls a static method of BlockHopper, which uses the static instance of BlockHopper owned by the Block class (Block.blockHopper). If I ovewrite the textures of BlockHopper, my Hopper will work, but the vanilla Hopper will look just like mine.

 

I don't know what is a ISBRH. Could you explain that?

Posted

no and there's actually a good for that but its kinda long to explain (or i suck at explaining things)

 

You mean there is a good reason why I can't override static methods? (If that's it, I know there is one. It does't even make sense from a OOP point of view, and it would also break the virtual machine since static methods are invoked differently with a different OPcode).

 

But if you mean there is a good reason why I can do this in java, please let me know:

Integer aNumber;
aNumber.parseInt("1000");

 

Calling a static method on an instance is confusing. People would assume aNumber has the value 1000 now, but it doesn't, The static method doesn't even know aNumber exists.

Posted

I'm working on it, hydroflame, but I have a doubt: I only need to override renderWorldBlock? Not overriding the other methods of the interface won't cause any problems under specific circumstances?

yeah

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

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.