Jump to content

[1.7.10] getting meta block from the registry


winnetrie

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I tried to play a mod for forge 1.20.2 and the mod didn't work, fix this please.
    • EntityRenders requires an EntityRenderProvider. This is what I have: @Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) public static class ClientModEvents { @SubscribeEvent public static void clientSetup(FMLClientSetupEvent event) { EntityRenderers.register(HOSE.get(), new HoseEntityRenderFactory()); } private static class HoseEntityRenderFactory implements EntityRendererProvider<HoseEntity> { @Override public EntityRenderer<HoseEntity> create(Context context) { return new HoseEntityRenderer<>(context); } } } Replace HoseEntity with your own entity. If you're doing multiple try doing generics (though untested).
    • First off, I know should probably be able to debug this on my own, but this is my first mod, and I couldn't figure it out for multiple days now. What I'm trying to do, is to modify the default minecart by replacing it with a slightly different version, but I'm stuck 1 step before that, that being "cloning" the minecart as a separate Entity/Item. Here you can see a GitHub gist of all relevant files: https://gist.github.com/Kipama/cd39127e8891715a3006fa990ca7ff14 If there are files missing or access isn't working as intended, please let me know! In the Gist you can find the following files: -CustomMinecartEntity.java:        This file extends AbstractMinecart and is a clone of the vanilla minecart entity. I know I should override the minecart entity directly, but as this should work rn, I didn't change it yet. -CustomMinecartRenderer.java:  Basically vanilla MinecartRenderer with a Custom slapped on it, extends MinecraftRenderer. -ModEntities.java:                         This is where the new Entity gets added to the deferred register ENTITY_TYPES. -ModernMinecarts.java:               The main mod file. Relevant part is at the bottom, where I try to use onClientSetup to register the new Entity using EntityRenderers.register(). That last part is where my problem begins. When I try to register the new entity using EntityRenderers.register(ModEntities.CUSTOM_MINECART_ENTITY.get(), CustomMinecartRenderer::new); I get a syntax Error saying the provided and required types don't match. These are the required and provided types: ModEntities.CUSTOM_MINECART_ENTITY.get(): Required: EntityType<? extends T> Provided:EntityType<CustomMinecartEntity> CustomMinecartRenderer::new: Required: EntityRendererProvider<T> Provided:<method reference   So far I looked at 2 different Git repositories implementing custom entities, but haven't been able to figure out what I'm doing wrong. Any answers, suggestions and ridicules appreciated.
    • Yes, it is. I found out how to do it. (for Forge 1.20.1) Add this to main class constructor: // ... MinecraftForge.EVENT_BUS.<PlayerInteractEvent.EntityInteract>addListener(e -> { Player playerWhoUsed = e.getEntity(); ItemStack usedItemStack = e.getItemStack(); Entity entityThatWasClicked = e.getTarget(); if (usedItemStack.getItem() instanceof YourItem item) { // your code... e.setCancelled(true); // you can remove this if you want to continue interaction } } // ...
    • Hi there, I'm hoping to create a block that renders a fake skybox, blocking anything behind it. There are a couple of mods that already do this, but they are very outdated. One example: https://github.com/Elix-x/Skyblocks/ https://www.curseforge.com/minecraft/mc-mods/skyblocks I'm not familiar enough with rendering to be able to port it. Is there anyone who can point me in the right direction? Any help would be appreciated.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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