Skip to content

Commit

Permalink
BoneMealing Tall Alliums Makes Giant Alliums
Browse files Browse the repository at this point in the history
  • Loading branch information
JT122406 committed Jul 29, 2024
1 parent a562ea4 commit e310f92
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 8 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
- Add BWG Logs to Logs That Burn Tag
- Fix a bunch of incorrect rendertypes around Plant like blocks
- Remove Surface Lava Pools from Forest like biomes
- Fix ores not genning in Eroded Borealis
- Fix ores not genning in Eroded Borealis
- BoneMealing Tall Alliums Makes Giant Alliums
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.grower.AbstractTreeGrower;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.material.MapColor;
import net.minecraft.world.phys.shapes.VoxelShape;
Expand All @@ -22,10 +23,7 @@
import net.potionstudios.biomeswevegone.world.level.block.plants.bush.*;
import net.potionstudios.biomeswevegone.world.level.block.plants.cactus.BarrelCactusBlock;
import net.potionstudios.biomeswevegone.world.level.block.plants.cactus.CarvedBarrelCactusBlock;
import net.potionstudios.biomeswevegone.world.level.block.plants.flower.BWGBonemealableFlowerBlock;
import net.potionstudios.biomeswevegone.world.level.block.plants.flower.BWGFlowerBlock;
import net.potionstudios.biomeswevegone.world.level.block.plants.flower.BWGTallFlowerBlock;
import net.potionstudios.biomeswevegone.world.level.block.plants.flower.FlowerBlockFeature;
import net.potionstudios.biomeswevegone.world.level.block.plants.flower.*;
import net.potionstudios.biomeswevegone.world.level.block.plants.tree.branch.TreeBranchBlock;
import net.potionstudios.biomeswevegone.world.level.block.plants.tree.fruit.BWGFruitBlock;
import net.potionstudios.biomeswevegone.world.level.block.plants.tree.grower.BWGTreeGrowers;
Expand Down Expand Up @@ -116,15 +114,15 @@ public class BWGBlocks {
public static final Supplier<MushroomBlock> WOOD_BLEWIT = registerBlockItem("wood_blewit", () -> new BWGMushroomBlock(BlockBehaviour.Properties.of().noCollission().mapColor(MapColor.DIRT).sound(SoundType.STEM).strength(0.2F), BWGBlockTags.BWG_MUSHROOM_PLACEABLE, BWGOverworldVegetationConfiguredFeatures.WOOD_BLEWIT));

/** Alliums */
public static final Supplier<TallFlowerBlock> TALL_ALLIUM = registerTallFlower("tall_allium", MapColor.COLOR_PURPLE);
public static final Supplier<TallFlowerBlock> TALL_ALLIUM = registerTallFlower("tall_allium", MapColor.COLOR_PURPLE, BWGTreeGrowers.GIANT_ALLIUM);
public static final FlowerBlockFeature ALLIUM_FLOWER_BUSH = registerFlower("allium_flower_bush", MapColor.COLOR_PURPLE, Block.box(2.0, 0.0, 2.0, 14.0, 13.0, 14.0), TALL_ALLIUM);
public static final Supplier<Block> ALLIUM_PETAL_BLOCK = registerCubeAllBlockItem("allium_petal_block", () -> new Block(BlockBehaviour.Properties.copy(Blocks.HAY_BLOCK).mapColor(MapColor.COLOR_PURPLE).sound(SoundType.AZALEA)));
public static final FlowerBlockFeature PINK_ALLIUM = registerFlower("pink_allium", MapColor.COLOR_PINK, Block.box(5.0, 0.0, 5.0, 11.0, 14.0, 11.0));
public static final Supplier<TallFlowerBlock> TALL_PINK_ALLIUM = registerTallFlower("tall_pink_allium", MapColor.COLOR_PINK);
public static final Supplier<TallFlowerBlock> TALL_PINK_ALLIUM = registerTallFlower("tall_pink_allium", MapColor.COLOR_PINK, BWGTreeGrowers.GIANT_PINK_ALLIUM);
public static final FlowerBlockFeature PINK_ALLIUM_FLOWER_BUSH = registerFlower("pink_allium_flower_bush", MapColor.COLOR_PINK, Block.box(2.0, 0.0, 2.0, 14.0, 13.0, 14.0), TALL_PINK_ALLIUM);
public static final Supplier<Block> PINK_ALLIUM_PETAL_BLOCK = registerCubeAllBlockItem("pink_allium_petal_block", () -> new Block(BlockBehaviour.Properties.copy(Blocks.HAY_BLOCK).mapColor(MapColor.COLOR_PINK).sound(SoundType.AZALEA)));
public static final FlowerBlockFeature WHITE_ALLIUM = registerFlower("white_allium", MapColor.TERRACOTTA_WHITE, Block.box(5.0, 0.0, 5.0, 11.0, 14.0, 11.0));
public static final Supplier<TallFlowerBlock> TALL_WHITE_ALLIUM = registerTallFlower("tall_white_allium", MapColor.TERRACOTTA_WHITE);
public static final Supplier<TallFlowerBlock> TALL_WHITE_ALLIUM = registerTallFlower("tall_white_allium", MapColor.TERRACOTTA_WHITE, BWGTreeGrowers.GIANT_WHITE_ALLIUM);
public static final FlowerBlockFeature WHITE_ALLIUM_FLOWER_BUSH = registerFlower("white_allium_flower_bush", MapColor.TERRACOTTA_WHITE, Block.box(2.0, 0.0, 2.0, 14.0, 13.0, 14.0), TALL_WHITE_ALLIUM);
public static final Supplier<Block> WHITE_ALLIUM_PETAL_BLOCK = registerCubeAllBlockItem("white_allium_petal_block", () -> new Block(BlockBehaviour.Properties.copy(Blocks.HAY_BLOCK).mapColor(MapColor.TERRACOTTA_WHITE).sound(SoundType.AZALEA)));

Expand Down Expand Up @@ -394,6 +392,10 @@ private static Supplier<TallFlowerBlock> registerTallFlower(String key, MapColor
return registerBlockItem(key, () -> new BWGTallFlowerBlock(BlockBehaviour.Properties.copy(Blocks.SUNFLOWER).mapColor(mapColor)));
}

private static Supplier<TallFlowerBlock> registerTallFlower(String key, MapColor mapColor, Supplier<AbstractTreeGrower> treeGrower) {
return registerBlockItem(key, () -> new BWGTallFlowerBlockTreeGrower(BlockBehaviour.Properties.copy(Blocks.SUNFLOWER).mapColor(mapColor), treeGrower));
}

private static Supplier<TallFlowerBlock> registerTallGlowingFlower(String key, MapColor mapColor) {
return registerBlockItem(key, () -> new BWGTallFlowerBlock(BlockBehaviour.Properties.copy(Blocks.SUNFLOWER).mapColor(mapColor).lightLevel(state -> 10)));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package net.potionstudios.biomeswevegone.world.level.block.plants.flower;

import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.tags.TagKey;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.grower.AbstractTreeGrower;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf;
import org.jetbrains.annotations.NotNull;

import java.util.function.Supplier;

public class BWGTallFlowerBlockTreeGrower extends BWGTallFlowerBlock {

private final Supplier<AbstractTreeGrower> treeGrower;

public BWGTallFlowerBlockTreeGrower(Properties properties, TagKey<Block> validGround, Supplier<AbstractTreeGrower> treeGrower) {
super(properties, validGround);
this.treeGrower = treeGrower;
}

public BWGTallFlowerBlockTreeGrower(Properties properties, Supplier<AbstractTreeGrower> treeGrower) {
super(properties);
this.treeGrower = treeGrower;
}

@Override
public boolean isBonemealSuccess(@NotNull Level level, RandomSource random, @NotNull BlockPos pos, @NotNull BlockState state) {
return random.nextBoolean();
}

@Override
public void performBonemeal(@NotNull ServerLevel level, @NotNull RandomSource random, @NotNull BlockPos pos, @NotNull BlockState state) {
level.setBlockAndUpdate(state.getValue(HALF) == DoubleBlockHalf.LOWER ? pos : pos.below(), Blocks.AIR.defaultBlockState());
treeGrower.get().growTree(level, level.getChunkSource().getGenerator(), pos, state, random);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -395,4 +395,25 @@ public class BWGTreeGrowers {
.add(BWGOverworldTreeConfiguredFeatures.FIRECRACKER_SHRUB, 1)
.add(BWGOverworldTreeConfiguredFeatures.FIRECRACKER_SHRUB2, 1)
.build());

public static final Supplier<AbstractTreeGrower> GIANT_ALLIUM = () -> new BWGTreeGrower(
new SimpleWeightedRandomList.Builder<ResourceKey<ConfiguredFeature<?, ?>>>()
.add(BWGOverworldTreeConfiguredFeatures.GIANT_ALLIUM_1, 1)
.add(BWGOverworldTreeConfiguredFeatures.GIANT_ALLIUM_2, 1)
.add(BWGOverworldTreeConfiguredFeatures.GIANT_ALLIUM_3, 1)
.build());

public static final Supplier<AbstractTreeGrower> GIANT_PINK_ALLIUM = () -> new BWGTreeGrower(
new SimpleWeightedRandomList.Builder<ResourceKey<ConfiguredFeature<?, ?>>>()
.add(BWGOverworldTreeConfiguredFeatures.GIANT_PINK_ALLIUM_1, 1)
.add(BWGOverworldTreeConfiguredFeatures.GIANT_PINK_ALLIUM_2, 1)
.add(BWGOverworldTreeConfiguredFeatures.GIANT_PINK_ALLIUM_3, 1)
.build());

public static final Supplier<AbstractTreeGrower> GIANT_WHITE_ALLIUM = () -> new BWGTreeGrower(
new SimpleWeightedRandomList.Builder<ResourceKey<ConfiguredFeature<?, ?>>>()
.add(BWGOverworldTreeConfiguredFeatures.GIANT_WHITE_ALLIUM_1, 1)
.add(BWGOverworldTreeConfiguredFeatures.GIANT_WHITE_ALLIUM_2, 1)
.add(BWGOverworldTreeConfiguredFeatures.GIANT_WHITE_ALLIUM_3, 1)
.build());
}

0 comments on commit e310f92

Please sign in to comment.