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

java.lang.ClassCastException: com.glistre.glistremod.blocks.SilverOreBlock cannot be cast to com.google.common.base.Predicate

at com.glistre.glistremod.biome.GlistreBiome.decorate(GlistreBiome.java:

 

 

 

       import com.google.common.base.Predicate; // do I have the wrong import?

  //1.8 replaces SilverOre with SilverBlock
    public void decorate(World worldIn, Random random, BlockPos blockPos) // do I have to create a custom WorldGen?
    {
        super.decorate(worldIn, random, blockPos);

  for (l = 0; l < k; ++l)
        {
            i1 = chunkX + random.nextInt(16);
            j1 = random.nextInt(28) + 4;
            int k1 = chunkZ + random.nextInt(16);
//1.8 changed target from glistre_block_1 to silver_ore_1 //Predicate is google.common.base.Predicate
            
            if (worldIn.getBlockState(blockPos).getBlock().isReplaceableOreGen(worldIn, blockPos, (Predicate<IBlockState>) BlockRegistry.silver_ore_1))
            		
            		
            {
            	 //not sure if 1.8 needs the .getDefaultState() or not  should I change this?
            	//last argument to setBlockState is a bit flag that tells Minecraft whether or not to update the client side / notify neighboring blocks / other things, and you almost always want it set to either 2 (notify client) or 3 (notify client AND notify neighbors, IIRC).
                worldIn.setBlockState(blockPos, (IBlockState) BlockRegistry.silver_block_1.getDefaultState(), 2);
            }
        }

 

 

  • Author

You cannot simply cast a Block to Predicate. You need to actually pass in a Predicate. Minecraft has several implementations you can use here: BlockMatcher for simply checking for a Block instance and BlockStateMatcher for checking against an IBlockState's properties.

 

Works fine now . . I used BlockHelper #forBlock since it's still on 1.8  Thanks!

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.