Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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)

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

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.