Jump to content

Recommended Posts

Posted

Is there another way to get a block with metadata from the registry?

I created this method:

public static Block getBlock(String name) {
	Block block = (Block) Block.blockRegistry.getObject(name);
	if (block == null || block == Blocks.air)
		throw new NullPointerException("Could not find any blocks named " + name);
	return block;
}
public static Block loadBlock(String name, int meta) {
	ItemStack stack = new ItemStack((Block) Block.blockRegistry.getObject(name), 1, meta);

	return Block.getBlockFromItem(stack.getItem());
}

the getblock method works fine but doesn't return a metablock, so i created the method 'loadblock'

This 1 returns a block with metadata but it has forgotten all the properties of that block.

hardness, resistance, material, stepsound etc etc has to be set again.

Here is what i mean:

GameRegistry.registerBlock(ashstonewall = new CustomWalls(getBlock("BiomesOPlenty:ashStone"), 0).setBlockName("ashstonewall"), "ashstonewall");

GameRegistry.registerBlock(limestonewall = new CustomBOPWalls(loadBlock("BiomesOPlenty:rocks",0), 0, Material.rock,5.0F/5.0F, 3.0F).setStepSound(Block.soundTypePiston).setBlockName("limestonewall"), "limestonewall");

Is there any other function that returns an object with his metadata?

Posted

So what's the best way to get the blocks?

I just found out that this works too:

GameRegistry.registerBlock(rocks = new Customstairs(getBlock("BiomesOPlenty:rocks"), 0).setBlockName("rocks"),"rocks" ).setCreativeTab(TemBlocks.extrastairs);
     GameRegistry.registerBlock(rocks = new Customstairs(getBlock("BiomesOPlenty:rocks"), 1).setBlockName("rocks1"),"rocks1" ).setCreativeTab(TemBlocks.extrastairs);
     GameRegistry.registerBlock(rocks = new Customstairs(getBlock("BiomesOPlenty:rocks"), 2).setBlockName("rocks2"),"rocks2" ).setCreativeTab(TemBlocks.extrastairs);
     GameRegistry.registerBlock(rocks = new Customstairs(getBlock("BiomesOPlenty:rocks"), 3).setBlockName("rocks3"),"rocks3" ).setCreativeTab(TemBlocks.extrastairs);

but still no hardness and resistance etc etc.

Posted

No.. that doesn't work.

There is NO WAY to use those methods to create a 'metadata' version of the block.

What you're doing is not possible.

You much override the function's you're trying to modify in your block class.

Note, you should also not be making a new block for every metadata you have 16 use them.

 

Beyond that REALLY should update to at least 1.8.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted

I know it's not the right way, but it does work!

It is wrong, i know, that's why i am here to ask help.....

But people keep telling me to update to at least 1.8. For sake why?

I WANT to use 1.7.10 because i can use it with cauldron. Cauldron supports forge mods and bukkit plugins, wich i need to set up a server.

I know those plugins could be replaced by mods who does the same thing, but that's the problem. There aren't such mods as good as those plugins(if so plz tell me), and since i am far away able to create them myself, i will use 1.7.10.

Besides that i have troubles with 1.9 and i can't find good documentations. If i would know how it all works and eventually i will at some point, i would make documentations myself, because i like forge and i want to help others.

For you everything looks and sounds logically, because you are high skilled in this. Those who aren't that skilled (yet), they don't see "IT". No we don't ask you to give us chewed code, that's rediculous, but proper examples WITH good explanations like : what does it do?, why use that?, how does it work? that can help us, and we learn from it.

Right now i have no clue and no ideas left to try it out. Before i post here, i searched google for hours!

 

Now for that object rock , wich has 6 metadata (0-5), how do i make stairs (for example) of it in the right way?

I think i do need a new block for every metadata because the metadata for stairs is used for the stairs position

So for every metadata rock has i need a new stairs

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.