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.

[1.12.2] Not sure on Predicate<IBlockState> initialization

Featured Replies

Posted

So I was trying to create ores for the end, and I noticed that the constructor for the WorldGenMinable had a third argument which I'm assuming which blocks can be replaced. I'm referring to the "Predicate<IBlockState>". The problem is that I don't know how to use predicate.

 

Assuming my IBlockState is

Blocks.END_STONE.getDefaultState()

How would I turn this into a Predicate?

  • Author
5 hours ago, diesieben07 said:

...provide something that returns true when the block passed in is the one you want to replace.

That's the reason I made this topic, I've never even seen a predicate before, and I don't know what to pass it.

I saw this as an example of initializing a predicate:

Predicate<String> allCaps = new Predicate<String>();

The problem is that it's giving me an error that "Cannot instantiate the type Predicate<String>". So how am I supposed to initialize it correctly?

  • Author
4 hours ago, diesieben07 said:

Predicate is an interface. If you do not know what an interface is or how it works, you need to learn basic Java first.

https://docs.oracle.com/javase/tutorial/java/IandI/createinterface.html

Also relevant (but you should probably just read all of those tutorials if you don't know Java):

https://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html

 

Please stop acting like I've had 0 experience with Java, it doesn't help at all. I know enough Java to make a competent program with it.

 

So with that said, I have two questions:

1. I've only really seen the <> brackets used with ArrayList. What exactly did they do again?

2. Given that Predicate is an interface, are there any classes that implement it (specifically minecraft classes)?

  • Author
34 minutes ago, diesieben07 said:

Use your IDE. 

Ok, so I'm using eclipse. I've barely used it before, so I don't know much about it.

 

Also, why can't you just send a line of code that properly initializes the Predicate<IBlockState>? I'm guessing it'll be just one line, like most initializations, and it's getting kind of annoying when this topic could've been solved in one comment.

  • Author

Didn't notice the StonePredicate class before.

 

Made an EndStonePredicate class, passed that as an argument and now everything works fine.

 

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

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.