Jump to content

[1.12.2] Not sure on Predicate<IBlockState> initialization


SeptemberBlue

Recommended Posts

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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)?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.