Jump to content

[1.8] [SOLVED] crash loading #decorate method in Biome


Glistre

Recommended Posts

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);
            }
        }

 

 

Link to comment
Share on other sites

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!

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.