Skip to content

Commit

Permalink
Added bonemeal functionality for various plants/blocks, prevented Ori…
Browse files Browse the repository at this point in the history
…gin Grass from being bonemealed, allowed glowworm silk to be placed on the bottom of any sturdy block.
  • Loading branch information
Forstride committed Jan 9, 2024
1 parent 382d896 commit dec16d9
Show file tree
Hide file tree
Showing 15 changed files with 201 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20.4 2023-12-13T03:23:45.3537111 Registries
// 1.20.4 2024-01-09T12:43:37.113881 Registries
a09ddf53150a7fcf8767a311dd5cf040fa2e9221 data/biomesoplenty/damage_type/bramble.json
2d0eab2cc85c4c6397fdc41dd0cedefbc4a7a150 data/biomesoplenty/damage_type/fumarole.json
1db19ce8d33b8c131955b60ed830200bbee6a912 data/biomesoplenty/worldgen/biome/aspen_glade.json
Expand Down Expand Up @@ -163,9 +163,11 @@ b7c8479b58bf928126528554a624b24b31e271c9 data/biomesoplenty/worldgen/configured_
e789a1d5ed583b58970046ae7aaa1aee3db5e138 data/biomesoplenty/worldgen/configured_feature/flower_wildflower.json
9aea32958474412cd6f448ded674460bc3cbf5d4 data/biomesoplenty/worldgen/configured_feature/giant_glowshroom_cave.json
e61a36facff8a5ebc08130e6bf1d0ad698ee0c2d data/biomesoplenty/worldgen/configured_feature/giant_tree.json
058d0fbddf7d5401d3ce43a8ff48495914d0d2a7 data/biomesoplenty/worldgen/configured_feature/glowing_grotto_ceiling_plants.json
8548fcda4d231ff1fd559b533a744d05679ddd7d data/biomesoplenty/worldgen/configured_feature/glowing_grotto_floor_plants.json
e965af2123aa8370d24048c005c943a83de6b679 data/biomesoplenty/worldgen/configured_feature/glowing_moss_patch.json
a58a9feee8ed675421187fc4bd393b2458c79481 data/biomesoplenty/worldgen/configured_feature/glowing_moss_patch_bonemeal.json
465dd2845e4f36d543c30bf84b4126159e41a0d3 data/biomesoplenty/worldgen/configured_feature/glowing_moss_patch_bonemeal_bottom.json
cf8d22a77f9689ec358e1588f9059addb2000cf9 data/biomesoplenty/worldgen/configured_feature/glowworm_silk.json
fdc974dfafbf4a7658e36a1c3ab88f7d08ce99e2 data/biomesoplenty/worldgen/configured_feature/goldenrod.json
6d3c2a7a45a0663fce2968d5151036de0e606e34 data/biomesoplenty/worldgen/configured_feature/hair.json
Expand Down Expand Up @@ -263,6 +265,7 @@ d87d90916abd6fe071bf29076ed7d22cce851486 data/biomesoplenty/worldgen/configured_
c7c6754b855b755d3c183e6f8e86e0ade2b878c5 data/biomesoplenty/worldgen/configured_feature/spring_lava_volcano.json
3a4c60fa1ee57b5b8ba28a25bc0c41a86293fa45 data/biomesoplenty/worldgen/configured_feature/spring_water_extra.json
490897b03b2cb822737519650a9abe093070f922 data/biomesoplenty/worldgen/configured_feature/sprouts_undergrowth.json
bd086bf28e079252554cf73adf234953bf70dba2 data/biomesoplenty/worldgen/configured_feature/sprout_bonemeal.json
37c885b65c9c00709ebb25c7b9d25e069e1577ee data/biomesoplenty/worldgen/configured_feature/spruce_bush.json
7a5228091146cfb88a6a39df41d15fd596e13412 data/biomesoplenty/worldgen/configured_feature/spruce_poplar_tree.json
74610c78a0d85f60a0dcc58529cc074e2a0f239a data/biomesoplenty/worldgen/configured_feature/spruce_twiglet_tree.json
Expand Down Expand Up @@ -558,6 +561,7 @@ d6bc04af30883b72799cb256c49a550e3d8afee9 data/biomesoplenty/worldgen/placed_feat
76dfc2afe7cbffb594337ffea5df43449c93f758 data/biomesoplenty/worldgen/placed_feature/spring_lava_volcano.json
99ae840a7d0aa5fc5a1941126cc4b85a937b5996 data/biomesoplenty/worldgen/placed_feature/spring_water_extra.json
ee7f4df006fd534f998daf475482bb1acca0cd3f data/biomesoplenty/worldgen/placed_feature/sprouts_undergrowth.json
dd76a040b540ec4ab0986d74fa3cbba02725402a data/biomesoplenty/worldgen/placed_feature/sprout_bonemeal.json
212bb036d2b8b398ce520a3670f6124efa9bd229 data/biomesoplenty/worldgen/placed_feature/spruce_bush.json
e0d549bf2e58a98f405659b64f9831d25f979f88 data/biomesoplenty/worldgen/placed_feature/spruce_poplar_tree.json
849711fce232370528ad51f0f4111fc8657dfd18 data/biomesoplenty/worldgen/placed_feature/spruce_twiglet_tree.json
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"type": "minecraft:simple_block",
"config": {
"to_place": {
"type": "minecraft:simple_state_provider",
"state": {
"Name": "biomesoplenty:glowworm_silk",
"Properties": {
"age": "0"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"type": "minecraft:vegetation_patch",
"config": {
"depth": 1,
"extra_bottom_block_chance": 0.0,
"extra_edge_column_chance": 0.75,
"ground_state": {
"type": "minecraft:simple_state_provider",
"state": {
"Name": "biomesoplenty:glowing_moss_block"
}
},
"replaceable": "#minecraft:moss_replaceable",
"surface": "ceiling",
"vegetation_chance": 0.4,
"vegetation_feature": {
"feature": "biomesoplenty:glowing_grotto_ceiling_plants",
"placement": []
},
"vertical_range": 5,
"xz_radius": {
"type": "minecraft:uniform",
"value": {
"max_inclusive": 2,
"min_inclusive": 1
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"type": "minecraft:simple_block",
"config": {
"to_place": {
"type": "minecraft:simple_state_provider",
"state": {
"Name": "biomesoplenty:sprout"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"feature": "biomesoplenty:sprout_bonemeal",
"placement": [
{
"type": "minecraft:block_predicate_filter",
"predicate": {
"type": "minecraft:matching_blocks",
"blocks": "minecraft:air"
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,40 @@
package biomesoplenty.common.block;

import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.RandomSource;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.BonemealableBlock;
import net.minecraft.world.level.block.DoublePlantBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.common.PlantType;

public class DoublePlantBlockBOP extends DoublePlantBlock
public class DoublePlantBlockBOP extends DoublePlantBlock implements BonemealableBlock
{
public DoublePlantBlockBOP(Block.Properties properties)
{
super(properties);
}

@Override
public boolean isValidBonemealTarget(LevelReader p_256234_, BlockPos p_57304_, BlockState p_57305_) {
return true;
}

@Override
public boolean isBonemealSuccess(Level p_222573_, RandomSource p_222574_, BlockPos p_222575_, BlockState p_222576_) {
return true;
}

@Override
public void performBonemeal(ServerLevel p_222568_, RandomSource p_222569_, BlockPos p_222570_, BlockState p_222571_) {
popResource(p_222568_, p_222570_, new ItemStack(this));
}

@Override
public PlantType getPlantType(BlockGetter world, BlockPos pos)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.tags.FluidTags;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.DoublePlantBlock;
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
Expand All @@ -29,7 +28,7 @@

import javax.annotation.Nullable;

public class DoubleWaterPlantBlock extends DoublePlantBlock implements SimpleWaterloggedBlock
public class DoubleWaterPlantBlock extends DoublePlantBlock implements SimpleWaterloggedBlock, BonemealableBlock
{
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;

Expand Down Expand Up @@ -78,6 +77,21 @@ public boolean canSurvive(BlockState state, LevelReader worldIn, BlockPos pos)
}
}

@Override
public boolean isValidBonemealTarget(LevelReader p_256234_, BlockPos p_57304_, BlockState p_57305_) {
return true;
}

@Override
public boolean isBonemealSuccess(Level p_222573_, RandomSource p_222574_, BlockPos p_222575_, BlockState p_222576_) {
return true;
}

@Override
public void performBonemeal(ServerLevel p_222568_, RandomSource p_222569_, BlockPos p_222570_, BlockState p_222571_) {
popResource(p_222568_, p_222570_, new ItemStack(this));
}

@Override
public PlantType getPlantType(BlockGetter world, BlockPos pos)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public GlowingMossBlock(BlockBehaviour.Properties p_153790_) {
@Override
public boolean isValidBonemealTarget(LevelReader p_153797_, BlockPos p_153798_, BlockState p_153799_)
{
return p_153797_.getBlockState(p_153798_.above()).isAir();
return p_153797_.getBlockState(p_153798_.above()).isAir() || p_153797_.getBlockState(p_153798_.below()).isAir();
}

@Override
Expand All @@ -41,5 +41,6 @@ public void performBonemeal(ServerLevel p_153792_, RandomSource p_153793_, Block
{
Registry<ConfiguredFeature<?, ?>> configuredFeatureRegistry = p_153792_.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE);
configuredFeatureRegistry.get(BOPCaveFeatures.GLOWING_MOSS_PATCH_BONEMEAL).place(p_153792_, p_153792_.getChunkSource().getGenerator(), p_153793_, p_153794_.above());
configuredFeatureRegistry.get(BOPCaveFeatures.GLOWING_MOSS_PATCH_BONEMEAL_BOTTOM).place(p_153792_, p_153792_.getChunkSource().getGenerator(), p_153793_, p_153794_.below());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import biomesoplenty.api.block.BOPBlocks;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.GrowingPlantHeadBlock;
Expand Down Expand Up @@ -35,7 +34,7 @@ public boolean canSurvive(BlockState p_196260_1_, LevelReader p_196260_2_, Block
}
else
{
return block == this.getHeadBlock() || block == this.getBodyBlock() || blockstate.getBlock() == BOPBlocks.GLOWING_MOSS_BLOCK.get() || (blockstate.is(BlockTags.DRIPSTONE_REPLACEABLE) && blockstate.isFaceSturdy(p_196260_2_, blockpos, Direction.DOWN));
return block == this.getHeadBlock() || block == this.getBodyBlock() || blockstate.isFaceSturdy(p_196260_2_, blockpos, Direction.DOWN);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import biomesoplenty.init.ModParticles;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelReader;
Expand Down Expand Up @@ -38,7 +37,7 @@ public boolean canSurvive(BlockState p_196260_1_, LevelReader p_196260_2_, Block
}
else
{
return block == this.getHeadBlock() || block == this.getBodyBlock() || blockstate.getBlock() == BOPBlocks.GLOWING_MOSS_BLOCK.get() || (blockstate.is(BlockTags.DRIPSTONE_REPLACEABLE) && blockstate.isFaceSturdy(p_196260_2_, blockpos, Direction.DOWN));
return block == this.getHeadBlock() || block == this.getBodyBlock() || blockstate.isFaceSturdy(p_196260_2_, blockpos, Direction.DOWN);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package biomesoplenty.common.block;

import net.minecraft.core.BlockPos;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.GrassBlock;
Expand Down Expand Up @@ -30,4 +32,10 @@ public BlockState getToolModifiedState(BlockState state, UseOnContext context, T

return null;
}

@Override
public boolean isValidBonemealTarget(LevelReader p_256229_, BlockPos p_256432_, BlockState p_255677_)
{
return false;
}
}
65 changes: 64 additions & 1 deletion src/main/java/biomesoplenty/common/block/OvergrownSandBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,29 @@
package biomesoplenty.common.block;

import biomesoplenty.api.block.BOPBlocks;
import biomesoplenty.common.worldgen.placement.BOPVegetationPlacements;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Holder;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.worldgen.placement.VegetationPlacements;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.ColorRGBA;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.BonemealableBlock;
import net.minecraft.world.level.block.ColoredFallingBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
import net.minecraft.world.level.lighting.LightEngine;
import net.minecraftforge.common.PlantType;

public class OvergrownSandBlock extends ColoredFallingBlock
import java.util.Optional;

public class OvergrownSandBlock extends ColoredFallingBlock implements BonemealableBlock
{
public OvergrownSandBlock(ColorRGBA dustColor, Properties properties)
{
Expand Down Expand Up @@ -56,4 +66,57 @@ public void randomTick(BlockState p_222508_, ServerLevel p_222509_, BlockPos p_2
p_222509_.setBlockAndUpdate(p_222510_, BOPBlocks.BLACK_SAND.get().defaultBlockState());
}
}

@Override
public boolean isValidBonemealTarget(LevelReader p_256229_, BlockPos p_256432_, BlockState p_255677_)
{
return p_256229_.getBlockState(p_256432_.above()).isAir();
}

@Override
public boolean isBonemealSuccess(Level p_221275_, RandomSource p_221276_, BlockPos p_221277_, BlockState p_221278_)
{
return true;
}

@Override
public void performBonemeal(ServerLevel p_221270_, RandomSource p_221271_, BlockPos p_221272_, BlockState p_221273_)
{
BlockPos blockpos = p_221272_.above();
BlockState blockstate = Blocks.SHORT_GRASS.defaultBlockState();
Optional<Holder.Reference<PlacedFeature>> optional = p_221270_.registryAccess().registryOrThrow(Registries.PLACED_FEATURE).getHolder(BOPVegetationPlacements.SPROUT_BONEMEAL);

label49:
for(int i = 0; i < 128; ++i)
{
BlockPos blockpos1 = blockpos;

for(int j = 0; j < i / 16; ++j)
{
blockpos1 = blockpos1.offset(p_221271_.nextInt(3) - 1, (p_221271_.nextInt(3) - 1) * p_221271_.nextInt(3) / 2, p_221271_.nextInt(3) - 1);
if (!p_221270_.getBlockState(blockpos1.below()).is(this) || p_221270_.getBlockState(blockpos1).isCollisionShapeFullBlock(p_221270_, blockpos1)) {
continue label49;
}
}

BlockState blockstate1 = p_221270_.getBlockState(blockpos1);
if (blockstate1.is(blockstate.getBlock()) && p_221271_.nextInt(10) == 0)
{
((BonemealableBlock)blockstate.getBlock()).performBonemeal(p_221270_, p_221271_, blockpos1, blockstate1);
}

if (blockstate1.isAir())
{
Holder<PlacedFeature> holder;
if (!optional.isPresent()) {
continue;
}

holder = optional.get();

holder.value().place(p_221270_, p_221270_.getChunkSource().getGenerator(), p_221271_, blockpos1);
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@
public class BOPCaveFeatures
{
public static final ResourceKey<ConfiguredFeature<?, ?>> GLOWING_GROTTO_FLOOR_PLANTS = createKey("glowing_grotto_floor_plants");
public static final ResourceKey<ConfiguredFeature<?, ?>> GLOWING_GROTTO_CEILING_PLANTS = createKey("glowing_grotto_ceiling_plants");
public static final ResourceKey<ConfiguredFeature<?, ?>> GLOWING_MOSS_PATCH = createKey("glowing_moss_patch");
public static final ResourceKey<ConfiguredFeature<?, ?>> GLOWING_MOSS_PATCH_BONEMEAL = createKey("glowing_moss_patch_bonemeal");
public static final ResourceKey<ConfiguredFeature<?, ?>> GLOWING_MOSS_PATCH_BONEMEAL_BOTTOM = createKey("glowing_moss_patch_bonemeal_bottom");
public static final ResourceKey<ConfiguredFeature<?, ?>> MUD_PLANTS = createKey("mud_plants");
public static final ResourceKey<ConfiguredFeature<?, ?>> MUD_PATCH = createKey("mud_patch");
public static final ResourceKey<ConfiguredFeature<?, ?>> GLOWWORM_SILK = createKey("glowworm_silk");
Expand All @@ -58,8 +60,13 @@ public static void bootstrap(BootstapContext<ConfiguredFeature<?, ?>> context)
register(context, BOPCaveFeatures.GLOWING_GROTTO_FLOOR_PLANTS, Feature.SIMPLE_BLOCK, new SimpleBlockConfiguration(new WeightedStateProvider(SimpleWeightedRandomList.<BlockState>builder().add(BOPBlocks.GLOWSHROOM.get().defaultBlockState(), 6).add(BOPBlocks.GLOWING_MOSS_CARPET.get().defaultBlockState(), 25))));
final Holder<ConfiguredFeature<?, ?>> GLOWING_GROTTO_FLOOR_PLANTS = configuredFeatureGetter.getOrThrow(BOPCaveFeatures.GLOWING_GROTTO_FLOOR_PLANTS);

register(context, BOPCaveFeatures.GLOWING_GROTTO_CEILING_PLANTS, Feature.SIMPLE_BLOCK, new SimpleBlockConfiguration(BlockStateProvider.simple(BOPBlocks.GLOWWORM_SILK.get())));
final Holder<ConfiguredFeature<?, ?>> GLOWING_GROTTO_CEILING_PLANTS = configuredFeatureGetter.getOrThrow(BOPCaveFeatures.GLOWING_GROTTO_CEILING_PLANTS);


register(context, BOPCaveFeatures.GLOWING_MOSS_PATCH, Feature.VEGETATION_PATCH, new VegetationPatchConfiguration(BlockTags.MOSS_REPLACEABLE, BlockStateProvider.simple(BOPBlocks.GLOWING_MOSS_BLOCK.get()), PlacementUtils.inlinePlaced(GLOWING_GROTTO_FLOOR_PLANTS), CaveSurface.FLOOR, ConstantInt.of(1), 0.0F, 5, 0.5F, UniformInt.of(4, 7), 0.3F));
register(context, BOPCaveFeatures.GLOWING_MOSS_PATCH_BONEMEAL, Feature.VEGETATION_PATCH, new VegetationPatchConfiguration(BlockTags.MOSS_REPLACEABLE, BlockStateProvider.simple(BOPBlocks.GLOWING_MOSS_BLOCK.get()), PlacementUtils.inlinePlaced(GLOWING_GROTTO_FLOOR_PLANTS), CaveSurface.FLOOR, ConstantInt.of(1), 0.0F, 5, 0.4F, UniformInt.of(1, 2), 0.75F));
register(context, BOPCaveFeatures.GLOWING_MOSS_PATCH_BONEMEAL_BOTTOM, Feature.VEGETATION_PATCH, new VegetationPatchConfiguration(BlockTags.MOSS_REPLACEABLE, BlockStateProvider.simple(BOPBlocks.GLOWING_MOSS_BLOCK.get()), PlacementUtils.inlinePlaced(GLOWING_GROTTO_CEILING_PLANTS), CaveSurface.CEILING, ConstantInt.of(1), 0.0F, 5, 0.4F, UniformInt.of(1, 2), 0.75F));

register(context, BOPCaveFeatures.MUD_PLANTS, Feature.SIMPLE_BLOCK, new SimpleBlockConfiguration(BlockStateProvider.simple(BOPBlocks.GLOWING_MOSS_CARPET.get())));
final Holder<ConfiguredFeature<?, ?>> MUD_PLANTS = configuredFeatureGetter.getOrThrow(BOPCaveFeatures.MUD_PLANTS);
Expand Down
Loading

0 comments on commit dec16d9

Please sign in to comment.