Posted July 27, 20169 yr 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); } }
July 28, 20169 yr 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.