Jump to content

[1.7.10] creating bookshelfs


winnetrie

Recommended Posts

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?

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I tried to play a mod for forge 1.20.2 and the mod didn't work, fix this please.
    • EntityRenders requires an EntityRenderProvider. This is what I have: @Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) public static class ClientModEvents { @SubscribeEvent public static void clientSetup(FMLClientSetupEvent event) { EntityRenderers.register(HOSE.get(), new HoseEntityRenderFactory()); } private static class HoseEntityRenderFactory implements EntityRendererProvider<HoseEntity> { @Override public EntityRenderer<HoseEntity> create(Context context) { return new HoseEntityRenderer<>(context); } } } Replace HoseEntity with your own entity. If you're doing multiple try doing generics (though untested).
    • First off, I know should probably be able to debug this on my own, but this is my first mod, and I couldn't figure it out for multiple days now. What I'm trying to do, is to modify the default minecart by replacing it with a slightly different version, but I'm stuck 1 step before that, that being "cloning" the minecart as a separate Entity/Item. Here you can see a GitHub gist of all relevant files: https://gist.github.com/Kipama/cd39127e8891715a3006fa990ca7ff14 If there are files missing or access isn't working as intended, please let me know! In the Gist you can find the following files: -CustomMinecartEntity.java:        This file extends AbstractMinecart and is a clone of the vanilla minecart entity. I know I should override the minecart entity directly, but as this should work rn, I didn't change it yet. -CustomMinecartRenderer.java:  Basically vanilla MinecartRenderer with a Custom slapped on it, extends MinecraftRenderer. -ModEntities.java:                         This is where the new Entity gets added to the deferred register ENTITY_TYPES. -ModernMinecarts.java:               The main mod file. Relevant part is at the bottom, where I try to use onClientSetup to register the new Entity using EntityRenderers.register(). That last part is where my problem begins. When I try to register the new entity using EntityRenderers.register(ModEntities.CUSTOM_MINECART_ENTITY.get(), CustomMinecartRenderer::new); I get a syntax Error saying the provided and required types don't match. These are the required and provided types: ModEntities.CUSTOM_MINECART_ENTITY.get(): Required: EntityType<? extends T> Provided:EntityType<CustomMinecartEntity> CustomMinecartRenderer::new: Required: EntityRendererProvider<T> Provided:<method reference   So far I looked at 2 different Git repositories implementing custom entities, but haven't been able to figure out what I'm doing wrong. Any answers, suggestions and ridicules appreciated.
    • Yes, it is. I found out how to do it. (for Forge 1.20.1) Add this to main class constructor: // ... MinecraftForge.EVENT_BUS.<PlayerInteractEvent.EntityInteract>addListener(e -> { Player playerWhoUsed = e.getEntity(); ItemStack usedItemStack = e.getItemStack(); Entity entityThatWasClicked = e.getTarget(); if (usedItemStack.getItem() instanceof YourItem item) { // your code... e.setCancelled(true); // you can remove this if you want to continue interaction } } // ...
    • Hi there, I'm hoping to create a block that renders a fake skybox, blocking anything behind it. There are a couple of mods that already do this, but they are very outdated. One example: https://github.com/Elix-x/Skyblocks/ https://www.curseforge.com/minecraft/mc-mods/skyblocks I'm not familiar enough with rendering to be able to port it. Is there anyone who can point me in the right direction? Any help would be appreciated.
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.