Vswe's Summer Courses | You're not logged in. Sign up or log in | Server time: | Donate
One can now see other persons' badge hunts. Simply head over to their profiles to access them.

Go back to course page

Climbing the interface ladder

From basic graphical interfaces to very advanced ones

Multiple Blocks

  • 2013-10-06 17:08:34
    Hey Vswe,
    I would like to know how to create a block that has multiple textures. Eg, i craft a wood+greendye = green wood texture, wood+bluedye = blue wood textures.

    Thanks a ton, Justin
  • 2013-10-06 17:20:16
    Lets say the craftins is done in a machine
  • 2013-10-06 17:21:22
    and i have like 100 combinations
  • 2013-10-06 17:48:10
    U could say a block which shares the same class, but diff textures in summary
  • 2013-10-06 21:11:17
    That is described in the course "Forging a Minecraft mod". Have you taken a look at it?
  • 2013-10-07 02:27:35
    Yes, but not sure which one, could u link me to it ?
  • 2013-10-07 04:13:32
    Hey, btw, can i get help for this code too ? Mind telling me what it does ?

    public void updateEntity() {
    AxisAlignedBB Axis = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord+ 1, yCoord + 1, zCoord + 1);

    List <?> Entities = worldObj.getEntitiesWithinAABB(EntityLiving.class, Axis);
    List <?> Items = worldObj.getEntitiesWithinAABB(EntityItem.class, Axis);
  • 2013-10-07 07:45:01
    Create the texture for every possible combination.
    Then create an ItemBlock of your block.
    When the player crafts your block, you give them the ItemBlock with a specific damage value depending on the crafting ingredient.(course 6 teach you how to handle the data more efficiently but its possible to do it without taking that course)
    When the block is placed, you set the tileentity data according to the damage value of the item.
    Finally, override getBlockTexture(world, x, y, z, side) and return the icon from there.
    If you want to get the correct item back when you break the block, override breakBlock(World world, int x, int y, int z, int id, int meta).

    If all these sound very foreign to you, I recommend you watch at least lecture 3 and 4 of forging a minecraft mod again.

    As for that chunk of code, I don't know what it means so I can't help you with it.
  • 2013-10-07 11:21:53
    For example Binnie in Extra Trees mod use multiple layers of textures to create texture combinations on single block, then use colorMultipiler based on metadata for each layer to give them different colors.

    The blocks are non-ticking tile entities and it's all based on metadata values.

    That's at least what i got from looking at his code. There's of course a lot more going on, but the basic idea remains.
  • 2013-10-07 14:00:47
    Hey Koycyk, that was very nice of u, helped me alot, mind explaining it in detail regarding Binnie's code, i dont want to flood NEI with my blocks thats why i am trying to do this method ?
  • 2013-10-07 17:03:06
    Flooding NEI is completely up to you. NEI is using exactly the same items as the creative inventory. And you're the one deciding what the creative inventory will show.

    Regarding that code snippet, it doesn't really do anything on its own so it's tricky to know without a context. It gets a list of items and one of living things around the entity.
  • 2013-10-07 19:10:34
    For the most basic block you would have a single gray texture and use different values for colorMultipiler, depending on block metadata. It's pretty much how wool in vanilla is done.

    For something more advanced i'll try to look into it and get back in a couple days with some code.
  • 2013-10-19 20:25:57
    If you're still interested in those kind of blocks i have a few more tips i've managed to get working:

    So basically you have a couple options to make such a block. You'll have to keep most data in tile entity and write them to ItemStack NBT data when crafted/picked up. I still have problems with that part, trying to look for open source mods to help me with this. Vsve could help here.

    To get color of a block you should use colorMultipiler method where you read data from tile entity.

    To use multiple textures you can either store it in metadata, but it allow you to only have 16 patterns. If you store that in tile entity you'll have to create custom rendering code. Binnie also uses that to render multicolor blocks.

    Binnie have non-ticking TileEntities, but so far i only managed to get it working with updating on client side only. To make that you need to use canUpdate class depending on side and then add @SideOnly annotation to updateEntity method.

    Since rendering use data kept on client side i force update from server on player login by sending single request packet to server, that makes it send tile entity data to client side.
    To make it update only once i created 'updated' boolean flag that is false on clinet side when you log in so client knows to request update. Otherwise client will have empty tile entity data and try to use that to render block.

    I've been working on something (https://www.dropbox.com/s/cgzjgi5h928aux1/2013-10-19_22.02.51.png) that use that update code and it seem to work well. Still need some work beacuase i get weird interactions in multiplayer, but mostly works fine.
  • Log in or sign up to reply to this thread