Skip to content

Commit

Permalink
Tweaked still Liquid Null and Null Plant textures, allowed Null Plant…
Browse files Browse the repository at this point in the history
…s to be bonemealed into Null Trees
  • Loading branch information
Forstride committed Jan 19, 2024
1 parent eddf4d1 commit c47b25d
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,5 @@ public void performBonemeal(ServerLevel p_221270_, RandomSource p_221271_, Block
holder.value().place(p_221270_, p_221270_.getChunkSource().getGenerator(), p_221271_, blockpos1);
}
}

}
}
46 changes: 45 additions & 1 deletion common/src/main/java/biomesoplenty/block/NullPlantBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,27 @@
package biomesoplenty.block;

import biomesoplenty.init.ModTags;
import biomesoplenty.worldgen.feature.BOPTreeFeatures;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.Registries;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.RandomSource;
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.BonemealableBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;

public class NullPlantBlock extends Block
public class NullPlantBlock extends Block implements BonemealableBlock
{
protected static final VoxelShape SHAPE = Block.box(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D);

Expand Down Expand Up @@ -49,4 +57,40 @@ public boolean canBeReplaced(BlockState p_53910_, BlockPlaceContext p_53911_)
{
return true;
}

@Override
public boolean isValidBonemealTarget(LevelReader levelReader, BlockPos blockPos, BlockState blockState)
{
return true;
}

@Override
public boolean isBonemealSuccess(Level level, RandomSource randomSource, BlockPos blockPos, BlockState blockState)
{
return (double)randomSource.nextFloat() < 0.1D;
}

@Override
public void performBonemeal(ServerLevel serverLevel, RandomSource randomSource, BlockPos blockPos, BlockState blockState)
{
this.growTree(serverLevel, randomSource, blockPos, blockState);
}

public boolean growTree(ServerLevel serverLevel, RandomSource randomSource, BlockPos blockPos, BlockState blockState)
{
serverLevel.removeBlock(blockPos, false);

Registry<ConfiguredFeature<?, ?>> configuredFeatureRegistry = serverLevel.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE);
ConfiguredFeature<?, ?> feature = configuredFeatureRegistry.get(BOPTreeFeatures.NULL_TREE);

if (feature.place(serverLevel, serverLevel.getChunkSource().getGenerator(), randomSource, blockPos))
{
return true;
}
else
{
serverLevel.setBlock(blockPos, blockState, 3);
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
public class MonolithFeature extends Feature<NoneFeatureConfiguration>
{
protected SimpleBlockPredicate placeOn = (world, pos) -> world.getBlockState(pos).getBlock() == BOPBlocks.UNMAPPED_END_STONE;
protected SimpleBlockPredicate replace = (world, pos) -> TreeFeature.isAirOrLeaves(world, pos) || world.getBlockState(pos).is(BlockTags.REPLACEABLE_BY_TREES) || world.getBlockState(pos).getBlock() instanceof BushBlock;
protected SimpleBlockPredicate replace = (world, pos) -> TreeFeature.isAirOrLeaves(world, pos) || world.getBlockState(pos).is(BlockTags.REPLACEABLE_BY_TREES) || world.getBlockState(pos).getBlock() instanceof BushBlock || world.getBlockState(pos).getBlock() == BOPBlocks.NULL_END_STONE;

public MonolithFeature(Codec<NoneFeatureConfiguration> deserializer)
{
Expand All @@ -48,7 +48,7 @@ public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featurePlaceC

int sizeX = 1 + rand.nextInt(3);
int sizeZ = 1 + rand.nextInt(3);
int height = 4 + rand.nextInt(8);
int height = 5 + rand.nextInt(7);

if (!this.checkSpace(world, startPos.above(), sizeX, sizeZ, height))
{
Expand All @@ -60,11 +60,21 @@ public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featurePlaceC

for (int x = 0; x <= sizeX; x++)
{
for (int y = -4; y <= height; y++)
for (int y = -6; y <= height; y++)
{
for (int z = 0; z <= sizeZ; z++)
{
this.setBlock(world, pos.offset(x,y,z), Blocks.OBSIDIAN.defaultBlockState());
if (y == height - 1)
{
if ((x == 0 || x == sizeX) && (z == 0 || z == sizeZ))
{
this.setBlock(world, pos.offset(x,y,z), Blocks.OBSIDIAN.defaultBlockState());
}
}
else
{
this.setBlock(world, pos.offset(x,y,z), Blocks.OBSIDIAN.defaultBlockState());
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"variants": {
"": [
{ "model": "biomesoplenty:block/null_plant" },
{ "model": "biomesoplenty:block/null_plant_alt" },
{ "model": "biomesoplenty:block/null_plant_alt_2" },
{ "model": "biomesoplenty:block/null_plant_alt_3" }
{ "model": "biomesoplenty:block/null_plant_alt" }
]
}
}

This file was deleted.

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"biomesoplenty:null_end_stone",
"biomesoplenty:null_block",
"biomesoplenty:null_plant",
"biomesoplenty:liquid_null",
"biomesoplenty:white_sand",
"biomesoplenty:white_sandstone"
]
Expand Down

0 comments on commit c47b25d

Please sign in to comment.