Posted January 18, 201510 yr For the last few weeks I have been on and off tyring to code a generic solution that allows me to register groups of blocks of any kind to overcomes the 16 metastates per-block limit. My first attempt was an enumeration that holds all the states, and my code would just register as many blocks as needed to hold all states. But Java Enum cannot be extended so this would be a massive copy&paste for each class of block. My second attempt to overcome the enum limits was to simulate extensible enums via abstract classes. But here I ran into the next limit - you can't extend from, or define abstract static methods. Before I redo it all again, has perhaps already someone solved this limitation in a generic way? Or is there perhaps a software pattern I could use here? What I more or less want to get to is to be able to define a list of blocktypes and the code manages the registering of blocks and setting the metadata for each type, but with the simplicity of java enums, where I could do a call like EnumFlower.Peonia.getBlockState() or EnumFlower.getStateFromMeta(block, meta)
January 20, 201510 yr I added a group of colored stone blocks in my block class public static BlockIndexed[] colorstone=new BlockIndexed[numstones]; int the init method for(int s=0;s<numstones;s++){ colorstone[s]=new BlockIndexed(Material.rock); String ns=""+(s+1); String tname="colorstone"+ns; String name=tname+"_"; colorstone[s].setBlockName(name); colorstone[s].setBlockTextureName(tname); colorstone[s].setCreativeTab(LoonBlocksTabs.colorblock_tab); colorstone[s].setHardness(2.5F); colorstone[s].setResistance(15.F); colorstone[s].setStepSound(Block.soundTypePiston); GameRegistry.registerBlock(colorstone[s], ColorItem.class, name); using this method I also added slabs, wall, and steps for each stone hope this gives you a good idea
January 20, 201510 yr Mmm, code tags... 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.
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.