TheThorneCorporation Posted June 17, 2020 Posted June 17, 2020 (edited) Hey guys, So I have a biome, and I want it to be of type forest. However, I also want the grass and leaves in the biome to be orange, which is not the default for forest biomes. is there any way I can override the natural grass color of a biome type? In addition, I have written this method for class DrillItem that will allow it to perform a function similar to stripping wood for ores, that also spawns an item at the player using the block: protected static final Map<Block, Block> ORE_DEPLETION_MAP = (new Builder<Block, Block>()) .put(Blocks.COAL_ORE, BlockList.DEPLETED_COAL_ORE.get()) .put(BlockList.DEPLETED_COAL_ORE.get(), BlockList.TWICE_DEPLETED_COAL_ORE.get()) .put(BlockList.TWICE_DEPLETED_COAL_ORE.get(), BlockList.THRICE_DEPLETED_COAL_ORE.get()) .put(BlockList.THRICE_DEPLETED_COAL_ORE.get(), Blocks.STONE) .put(Blocks.IRON_ORE, BlockList.DEPLETED_IRON_ORE.get()) .put(BlockList.DEPLETED_IRON_ORE.get(), BlockList.TWICE_DEPLETED_IRON_ORE.get()) .put(BlockList.TWICE_DEPLETED_IRON_ORE.get(), BlockList.THRICE_DEPLETED_IRON_ORE.get()) .put(BlockList.THRICE_DEPLETED_IRON_ORE.get(), Blocks.STONE) .put(Blocks.GOLD_ORE, BlockList.DEPLETED_GOLD_ORE.get()) .put(BlockList.DEPLETED_GOLD_ORE.get(), BlockList.TWICE_DEPLETED_GOLD_ORE.get()) .put(BlockList.TWICE_DEPLETED_GOLD_ORE.get(), BlockList.THRICE_DEPLETED_GOLD_ORE.get()) .put(BlockList.THRICE_DEPLETED_GOLD_ORE.get(), Blocks.STONE) .put(Blocks.LAPIS_ORE, BlockList.DEPLETED_LAPIS_ORE.get()) .put(BlockList.DEPLETED_LAPIS_ORE.get(), BlockList.TWICE_DEPLETED_LAPIS_ORE.get()) .put(BlockList.TWICE_DEPLETED_LAPIS_ORE.get(), BlockList.THRICE_DEPLETED_LAPIS_ORE.get()) .put(BlockList.THRICE_DEPLETED_LAPIS_ORE.get(), Blocks.STONE) .put(Blocks.REDSTONE_ORE, BlockList.DEPLETED_REDSTONE_ORE.get()) .put(BlockList.DEPLETED_REDSTONE_ORE.get(), BlockList.TWICE_DEPLETED_REDSTONE_ORE.get()) .put(BlockList.TWICE_DEPLETED_REDSTONE_ORE.get(), BlockList.THRICE_DEPLETED_REDSTONE_ORE.get()) .put(BlockList.THRICE_DEPLETED_REDSTONE_ORE.get(), Blocks.STONE) .put(Blocks.EMERALD_ORE, BlockList.DEPLETED_EMERALD_ORE.get()) .put(BlockList.DEPLETED_EMERALD_ORE.get(), BlockList.TWICE_DEPLETED_EMERALD_ORE.get()) .put(BlockList.TWICE_DEPLETED_EMERALD_ORE.get(), BlockList.THRICE_DEPLETED_EMERALD_ORE.get()) .put(BlockList.THRICE_DEPLETED_EMERALD_ORE.get(), Blocks.STONE) .put(Blocks.DIAMOND_ORE, BlockList.DEPLETED_DIAMOND_ORE.get()) .put(BlockList.DEPLETED_DIAMOND_ORE.get(), BlockList.TWICE_DEPLETED_DIAMOND_ORE.get()) .put(BlockList.TWICE_DEPLETED_DIAMOND_ORE.get(), BlockList.THRICE_DEPLETED_DIAMOND_ORE.get()) .put(BlockList.THRICE_DEPLETED_DIAMOND_ORE.get(), Blocks.STONE) .put(BlockList.MOD_GEM_ORE.get(), BlockList.DEPLETED_MOD_GEM_ORE.get()) .put(BlockList.DEPLETED_MOD_GEM_ORE.get(), Blocks.STONE) .build(); protected static final Random rng = new Random(); protected static final Map<Block, Supplier<ItemStack>> DEPLETION_DROPS_MAP = (new Builder<Block, Supplier<ItemStack>>()) .put(Blocks.COAL_ORE, () -> new ItemStack(Items.COAL, 1)) .put(BlockList.DEPLETED_COAL_ORE.get(), () -> new ItemStack(Items.COAL, 1)) .put(BlockList.TWICE_DEPLETED_COAL_ORE.get(), () -> new ItemStack(Items.COAL, 1)) .put(BlockList.THRICE_DEPLETED_COAL_ORE.get(), () -> new ItemStack(Items.COAL, 1)) .put(Blocks.IRON_ORE, () -> new ItemStack(ItemList.IRON_SLAG.get(), 1)) .put(BlockList.DEPLETED_IRON_ORE.get(), () -> new ItemStack(ItemList.IRON_SLAG.get(), 1)) .put(BlockList.TWICE_DEPLETED_IRON_ORE.get(), () -> new ItemStack(ItemList.IRON_SLAG.get(), 1)) .put(BlockList.THRICE_DEPLETED_IRON_ORE.get(), () -> new ItemStack(ItemList.IRON_SLAG.get(), 1)) .put(Blocks.GOLD_ORE, () -> new ItemStack(ItemList.GOLD_SLAG.get(), 1)) .put(BlockList.DEPLETED_GOLD_ORE.get(), () -> new ItemStack(ItemList.GOLD_SLAG.get(), 1)) .put(BlockList.TWICE_DEPLETED_GOLD_ORE.get(), () -> new ItemStack(ItemList.GOLD_SLAG.get(), 1)) .put(BlockList.THRICE_DEPLETED_GOLD_ORE.get(), () -> new ItemStack(ItemList.GOLD_SLAG.get(), 1)) .put(Blocks.LAPIS_ORE, () -> new ItemStack(Items.LAPIS_LAZULI, MathHelper.nextInt(rng, 4, 9))) .put(BlockList.DEPLETED_LAPIS_ORE.get(), () -> new ItemStack(Items.LAPIS_LAZULI, MathHelper.nextInt(rng, 4, 9))) .put(BlockList.TWICE_DEPLETED_LAPIS_ORE.get(), () -> new ItemStack(Items.LAPIS_LAZULI, MathHelper.nextInt(rng, 4, 9))) .put(BlockList.THRICE_DEPLETED_LAPIS_ORE.get(), () -> new ItemStack(Items.LAPIS_LAZULI, MathHelper.nextInt(rng, 4, 9))) .put(Blocks.EMERALD_ORE, () -> new ItemStack(Items.EMERALD, 1)) .put(BlockList.DEPLETED_EMERALD_ORE.get(), () -> new ItemStack(Items.EMERALD, 1)) .put(BlockList.TWICE_DEPLETED_EMERALD_ORE.get(), () -> new ItemStack(Items.EMERALD, 1)) .put(BlockList.THRICE_DEPLETED_EMERALD_ORE.get(), () -> new ItemStack(Items.EMERALD, 1)) .put(Blocks.DIAMOND_ORE, () -> new ItemStack(Items.DIAMOND, 1)) .put(BlockList.DEPLETED_DIAMOND_ORE.get(), () -> new ItemStack(Items.DIAMOND, 1)) .put(BlockList.TWICE_DEPLETED_DIAMOND_ORE.get(), () -> new ItemStack(Items.DIAMOND, 1)) .put(BlockList.THRICE_DEPLETED_DIAMOND_ORE.get(), () -> new ItemStack(Items.DIAMOND, 1)) .put(Blocks.REDSTONE_ORE, () -> new ItemStack(Items.REDSTONE, MathHelper.nextInt(rng, 4, 5))) .put(BlockList.DEPLETED_REDSTONE_ORE.get(), () -> new ItemStack(Items.REDSTONE, MathHelper.nextInt(rng, 4, 5))) .put(BlockList.TWICE_DEPLETED_REDSTONE_ORE.get(), () -> new ItemStack(Items.REDSTONE, MathHelper.nextInt(rng, 4, 5))) .put(BlockList.THRICE_DEPLETED_REDSTONE_ORE.get(), () -> new ItemStack(Items.REDSTONE, MathHelper.nextInt(rng, 4, 5))) .put(BlockList.MOD_GEM_ORE.get(), () -> new ItemStack(ItemList.MOD_GEM.get(), 1)) .put(BlockList.DEPLETED_MOD_GEM_ORE.get(), () -> new ItemStack(ItemList.MOD_GEM.get(), 1)) .build(); . . . public ActionResultType onItemUse(ItemUseContext context) { World world = context.getWorld(); BlockPos blockpos = context.getPos(); BlockState blockstate = world.getBlockState(blockpos); Block block = ORE_DEPLETION_MAP.get(blockstate.getBlock()); if (block != null && this.canHarvestBlock(blockstate)) { PlayerEntity playerentity = context.getPlayer(); world.playSound(playerentity, blockpos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, 1.0F); if (!world.isRemote) { world.setBlockState(blockpos, block.getDefaultState().with(RotatedPillarBlock.AXIS, blockstate.get(RotatedPillarBlock.AXIS)), 11); if (playerentity != null) { if(DEPLETION_DROPS_MAP.get(blockstate.getBlock()) != null) { Supplier<ItemStack> sup = DEPLETION_DROPS_MAP.get(blockstate.getBlock()); world.addEntity(new ItemEntity(world, playerentity.getPosition().getX(), playerentity.getPosition().getY(), playerentity.getPosition().getZ(), sup.get())); } context.getItem().damageItem(1, playerentity, (player) -> { player.sendBreakAnimation(context.getHand()); }); } } return ActionResultType.SUCCESS; } else { return ActionResultType.PASS; } } Unfortunately, when I tested the method in the world it did not work, The block was not changed to the value it is mapped to in ORE_DEPLETION_MAP, nor did an ItemStack spawn. What am I doing wrong? Edited June 17, 2020 by TheThorneCorporation Quote
Haydenman2 Posted June 17, 2020 Posted June 17, 2020 (edited) It looks to me like you can override Biome#getGrassColor, passing in an int color, keeping in mind that it is client-side only. EDIT: Override Biome#getFoliageColor as well. Edited June 17, 2020 by Haydenman2 Quote ...
Recommended Posts
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.