Jump to content

Creating a Custom Block Render (ISBRH)


WaffleMan0310

Recommended Posts

So I recently started to learn how to mod and was progressing doing that when I had this idea to create blocks that create their own textures, overlay different stuff based off of their metadata. This lead me to the "ISimpleBlockRenderHandler" I was doing some playing around with it and came about some problems...

 

For one I had this working, then I added a new class that takes some parameters and does the drawing for the tessellator. ("addBlockVerticies") and changed some other stuff that I can't remember, and now I get a priority queue crash upon entering the world. Is probably something stupid that I'm not seeing, here is the class: http://pastebin.com/psWcKV6r

 

Onto the real problem, when it was working I was having a problem with placing more than one of the custom rendered blocks and placing the block below or at ground level.

Whenever I placed the block at ground level  or below, I world in roughly the chunk around the block would go transparent and nothing but the one face of the block I had alpha pass code for was rendering. Additionally whenever I placed two of more of the blocks together the same effect would happen just alpha pass texture would pick a random block.

 

Again I am new to modding and am probably doing something stupid that you experienced people would smack me for. ;D So be gentle.

 

Onto some concept questions:

 

Binding textures to the tessellator, is there an easier way than I am currently doing it? (like fetching an icon texture, scaling it down and rendering it onto the block face) I am currently registering the item and overlay textures in the block class, then in the render handler I am overriding the renderer with the default coal block texture, and using getIcon from the block class to get the other stuff. I tried using getIcon from a item class but it wouldn't, it have this weird blue tinted texture with a small texture in the corner. For reference:

 

 

    @Override

    @SideOnly(Side.CLIENT)

    public void registerBlockIcons(IIconRegister iconRegister) {

        overlay = iconRegister.registerIcon(Textures.RESOURCE_PREFIX + Textures.OVERLAY_FILTER_LOCATION + Names.Blocks.BLOCK_OF_MAGICAL_FUEL + ".overlay");

 

        overlayItems = new IIcon[Names.Items.FUEL_TYPES.length];

        for (int itemOverlay = 0; itemOverlay < Names.Items.FUEL_TYPES.length; itemOverlay++) {

            overlayItems[itemOverlay] = iconRegister.registerIcon(Textures.RESOURCE_PREFIX + Textures.OVERLAY_ITEM_LOCATION + Names.Items.MAGICAL_FUEL + "." + Names.Items.FUEL_TYPES[itemOverlay]);

        }

    }

 

    @Override

    @SideOnly(Side.CLIENT)

    public IIcon getIcon(int side, int metaData) {

        /*

        Overlay Filter Meta-Range:

            11-21

        Overlay Item Meta-Range

            0-10

        */

        if (metaData <= 10) {

            //Define Item Overlays

            if (metaData == Metadata.ARCANE_FUEL) {

                return overlayItems[Metadata.ARCANE_FUEL];

            } else if (metaData == Metadata.TAINT_INFUSED_COAL) {

                return overlayItems[Metadata.TAINT_INFUSED_COAL];

            } else if (metaData == Metadata.COMBUSIBLE_DARK_MATTER) {

                return overlayItems[Metadata.COMBUSIBLE_DARK_MATTER];

            } else if (metaData == Metadata.COSMIC_INCENDIARY_CHUNK) {

                return overlayItems[Metadata.COSMIC_INCENDIARY_CHUNK];

            }

        } else if (metaData > 10 && metaData <= 21) {

            //Define Filter Overlays

            if (metaData == 11) {

                return overlay;

            }

        }

        return null;

    }

 

 

 

The next question, is there a method (maybe in GL11?) that would scale a texture, and translate it? I tried "GL11.glScaleF()" and I actaully shrunk the chunk that the block was in which I am assuming correlates to the original problem

 

Thanks for your time and tolerance for my noob questions. :P

 

EDIT: I fixed the issue, it turns out that using GL11.glPushMatrix()/glPopMatrix(), then just changing the tessellator vertex methods to go based off of the block location is better than using tessellator.getTranslated() then operating in terms of 1. My question still remains about scaling and moving a texture on a block face.

Link to comment
Share on other sites

If you get a crash, always post your crash reports.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

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.