Jump to content

Getting type of Block (ore)


Skkkitzo

Recommended Posts

Forgive me if this is a duplicate answer, I haven't been able to find anything relating to this.

 

How can I test if a block at position x,y,z is a type of ore? Something like this

MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
World world = server.getWorld(0);
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();

if (block.type == Type.ORE) {
	// do smthing
}

 

I cannot just manually check for every ore type, because depending on how many other mods are installed, there could be a lot of different ores.

I'm not really sure how to proceed from here, as I can't find anything regarding the type of a block.

 

Thanks in advance

Link to comment
Share on other sites

4 minutes ago, Skkkitzo said:

I cannot just manually check for every ore type, because depending on how many other mods are installed, there could be a lot of different ores.

You do realize you have to create your own optional dependency for every mod you want to add support for?

 

Minecraft you can just check if the block is an instance of OreBlock. However, every other mod you would need to check individually as there is likely no centralization.

Link to comment
Share on other sites

53 minutes ago, ChampionAsh5357 said:

You do realize you have to create your own optional dependency for every mod you want to add support for?

 

Minecraft you can just check if the block is an instance of OreBlock. However, every other mod you would need to check individually as there is likely no centralization.

 

When you say, "just check if the block is an instance of OreBlock", do you mean something like this?

if (event.getState().getBlock() instanceof BlockOre) {
	System.out.println("Yes");
}

 

Link to comment
Share on other sites

2 minutes ago, ChampionAsh5357 said:

That should work fine

And regarding other mod support, I'll do some research on how to implement general mod supportivity, but specifically regarding checking if the block that I mine is an instance of their mod, would it be similar to 

block_mined instanceof BlockOre

or is it something entirely different? I would assume because other mod's ores would still be extensions of the BlockOre class that this code would work. 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • Create New...

Important Information

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