Jump to content

Recommended Posts

Posted

I have succesfully added alot of simple blocks and item to my mod.

Things like: bricked blocks, stairs, slabs, walls, fences, buttons, tools, items, recipes and also made an addon for BOP.

I had alot of help here on this forum, but once again i need help again.

I now want to make bookshelfs in all 6 wood types and also in the woodtypes of BOP (later)

 

i found the bookshelf class and changed it to this:

public class CustomBookShelves extends BlockBookshelf {
    private final Block planks;
    private final int meta;
    @SideOnly(value=Side.CLIENT)
    private IIcon overlay;
    @SideOnly(value=Side.CLIENT)
    public CustomBookShelves(Block block, int meta)
    {
        this.planks=block;
        this.meta=meta;
        this.setHardness(1.5F);
        this.setBlockName("bookshelf_"+planks.getUnlocalizedName());
        this.setCreativeTab(TemBlocks.extrafences);
    }

    /**
     * Gets the block's texture. Args: side, meta
     */
public float getEnchantPowerBonus(World world, int x, int y, int z) {
        return 1.0f;
    }

@Override
    @SideOnly(Side.CLIENT)
    public IIcon getIcon(int side, int meta)
    {
	IIcon plankIcon = this.planks.getIcon(side, this.meta);
        return side != 1 && side != 0 ? (renderOverlay ? this.overlay : plankIcon) : plankIcon;
        //return side != 1 && side != 0 ? super.getIcon(side, meta) : Blocks.planks.getBlockTextureFromSide(side);
    }
@Override
@SideOnly(value=Side.CLIENT)
    public void registerBlockIcons(IIconRegister reg) {
        this.overlay = reg.registerIcon("tem:bookshelf");
    }

    
@Override
    public int quantityDropped(Random rand)
    {
        return 3;
    }

@Override
    public Item getItemDropped(int par1, Random par2, int par3)
    {
        return Items.book;
    }

}

So ingame my custom bookshelf has the right woodtype texture but there aren't bookshelfs drawn on it.

While the bookshelf does do his task as a bookshelf (enchantmentlevel get increased), i don't see the effect (those weird signs flying from the bookshelf into the enchantment table)

So how do i do it right?

Posted

add this at top

 

@SideOnly(Side.CLIENT)
    private IIcon field_150035_a;
    @SideOnly(Side.CLIENT)
    private IIcon field_150034_b;
    @SideOnly(Side.CLIENT)
    private IIcon field_150034_c;

 

and this some where

 


@SideOnly(Side.CLIENT)
    public IIcon getIcon(int side, int met)
    {
        return side == 1 ? this.field_150035_a : (side == 0 ? field_150034_c : (side != 2 && side != 4 ? this.blockIcon : this.field_150034_b));
    }

    @SideOnly(Side.CLIENT)
    public void registerBlockIcons(IIconRegister p_149651_1_)
    {
        this.blockIcon = p_149651_1_.registerIcon("side");
        this.field_150035_a = p_149651_1_.registerIcon("top");
        this.field_150034_b = p_149651_1_.registerIcon("side");
        this.field_150034_c = p_149651_1_.registerIcon("bottom");
     	 	   
    }

 

then replace "side" with you side texture "top" with your top texture and "bottom" with your bottom texture

 

then it will render properly like a bookshelf

 

Posted

Combining textures is a pain in the ass doing it runtime.  Possible, but a huge pain.

 

https://github.com/Draco18s/HarderStuff/blob/master/src/main/java/com/draco18s/hardlib/client/TextureAtlasDynamic.java

 

This class comes with no warranty and if something goes wrong I will not help you figure out what because the errors will not occur in this class.  I had to solve several myself when writing it and it involved a lot of backtracking through the stacktrace and examining obfuscated code to figure out what value hadn't been correctly set in order for Vanilla to properly handle the custom sprite loader.

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.

Posted

When setting IIcons, you should be able to refer to vanilla textures for the sides you want to look like vanilla (e.g. the books).

 

As for the animated particles flowing to an enchanting table, you are probably hosed. Those are generated by the table itself. If the table's client-side particle generator doesn't recognize extensions of BlockBookshelf (using instanceof for its comparison), then you might not have an easy fix.

 

One workaround would be for your bookshelf to generate particles aimed at any nearby enchanting table. Look at how the enchanting table generates its particles, and then see about mirroring the effect.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

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.