Jump to content

API and listing all Blocks


Kimpton

Recommended Posts

Hey I downloaded the api so I could look through a web browser however there's no 'search' feature xD

 

What I'm trying todo is register all blocks with a prefix (in a sense making a bunch of new blocks that equals the quantity of Minecraft's current blocks. I thought maybe if I we're to swim around the api I could find it - shamefully not. (So in a sense I'm looking for an array with all the blocks - or at least trying to make one without writing the array out)

 

Could someone point to roughly where I could look? Thanks.

Link to comment
Share on other sites

    	String[] vanillaBlocks = {"Brick", "Stone", "Stone_Brick" //All vanilla blocks prefer if I didn't have to write them out};
    	
    	
    	for(int i = 0; i < vanillaBlocks.length; i++){    		
    		allLarge = new LargeColumnProperties(Material.rock).setBlockName("ModelColumn" + vanillaBlocks[i]).setHardness(20.0F).setResistance(1.0F);
    		GameRegistry.registerBlock(allLarge, "ModelColumn" + vanillaBlocks[i]);
    		GameRegistry.registerTileEntity(TileEntityBlock.class, "ModelColumn" + vanillaBlocks[i]);
    	}

Link to comment
Share on other sites

Iterator it = Block.blockRegistry.iterator();
        ArrayList<String> vanillaBlocks = new ArrayList<String>();
        while (it.hasNext())
        {
            Block b = (Block)it.next();
            vanillaBlocks.add(b.getLocalizedName());
        }
        System.out.println(vanillaBlocks.toString());

Link to comment
Share on other sites

Iterator it = Block.blockRegistry.iterator();
        ArrayList<String> vanillaBlocks = new ArrayList<String>();
        while (it.hasNext())
        {
            Block b = (Block)it.next();
            vanillaBlocks.add(b.getLocalizedName());
        }
    	
        String[] blocks = (String[])vanillaBlocks.toArray();
    	
    	for(int i = 0; i < blocks.length; i++){    		
    		allLarge = new LargeColumnProperties(Material.rock).setBlockName("ModelColumn" + blocks[i]).setHardness(20.0F).setResistance(1.0F);
    		GameRegistry.registerBlock(allLarge, "ModelColumn" + blocks[i]);
    		GameRegistry.registerTileEntity(TileEntityBlock.class, "ModelColumn" + blocks[i]);
    	}

 

That's not quite right is it? I would have thought I would need another loop to turn it into an array? BTW the for loop does not accept arraylist - so it does have to be an array. I suppose it doesn't like how the array list can be ''added to'' while an array if fixed?

Link to comment
Share on other sites

Iterator it = Block.blockRegistry.iterator();

 

Now regardless of our previous posts I have spotted a problem :o

 

that spits out a lot of duplicate blocks.. and some blocks aren't even blocks, they're items such as: "redstone dust" - I'm starting to think I'm going to have to write these out by hand - because excluding the ones I don't want will be just as hard.

 

Maybe I should have specified I was looking for; full shaped blocks that are placeable? :) this would be easier if the api docs had a search feature haha :)

Link to comment
Share on other sites

OOOO!! Okay I've found a location with the majority of the blocks I want; in the building blocks tab! :) Its easy enough to get rid of all ''slab'' and ''stair'' and ''wall'' blocks (I know how todo that) - okay I think I'm set :)

Link to comment
Share on other sites

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.