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

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

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.

  • Author
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");
}

 

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

It makes no sense if the block is an extension of OreBlock. That's coded for the sole purpose of programming all ores into a single class. Most mods just use a standard Block instance or have their own single class handler for ores.

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.

Guest
This topic is now closed to further replies.

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.