From 4cfb22ebd995ddfd0152a78a596dfbf20d4c3268 Mon Sep 17 00:00:00 2001 From: NewJumper Date: Fri, 22 Dec 2023 18:42:46 -0600 Subject: [PATCH] glowing grass can now be waterlogged --- .../103d9f3f36b01595f1aa5172191e60eff02e6924 | 4 +-- .../blooming_sculk_vegetation.json | 5 +++- .../blocks/vegetation/GlowingGrassBlock.java | 27 +++++++++++++++++-- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/generated/resources/.cache/103d9f3f36b01595f1aa5172191e60eff02e6924 b/src/generated/resources/.cache/103d9f3f36b01595f1aa5172191e60eff02e6924 index 443e55d83..72b59cfa1 100644 --- a/src/generated/resources/.cache/103d9f3f36b01595f1aa5172191e60eff02e6924 +++ b/src/generated/resources/.cache/103d9f3f36b01595f1aa5172191e60eff02e6924 @@ -1,4 +1,4 @@ -// 1.20.1 2023-12-20T00:25:41.7400779 Registries +// 1.20.1 2023-12-22T18:42:21.2231355 Registries 65c8c67a4ec7ef0ce6846fb2f4d921cc6ceb02e2 data/deeperdarker/damage_type/bite.json 0b65c61bd1e5086d0f3685566cc6cecf6e324516 data/deeperdarker/damage_type/ring.json 67f8cd0621b1c3614da8c1910f6b7bcb61660293 data/deeperdarker/dimension_type/otherside.json @@ -8,7 +8,7 @@ bd2c433caf3a3f7dfff3668a68dbdf56fa994df5 data/deeperdarker/worldgen/biome/echoin 06d29b9291ed3a63be90750a8c6f182e0c168b7b data/deeperdarker/worldgen/biome/overcast_columns.json 5df9b477f5858b1cf8e0d3d0db7bff27a7a07d97 data/deeperdarker/worldgen/configured_feature/blooming_pool.json e7bebee214c738b7a13868c0fd4e804954087c04 data/deeperdarker/worldgen/configured_feature/blooming_sculk_patch.json -befb8dd1022d3e0e0bea6f211800fe3c8b63bb2e data/deeperdarker/worldgen/configured_feature/blooming_sculk_vegetation.json +97ed3584ea072e20778c14293a3c7723cd17e590 data/deeperdarker/worldgen/configured_feature/blooming_sculk_vegetation.json 5097028f5c8ae5e294126d6df771e3126d4fbd07 data/deeperdarker/worldgen/configured_feature/gloomslate_column.json ba29dfa84f2bebe688044c6e89b6c1d38dbaf0c6 data/deeperdarker/worldgen/configured_feature/gloomslate_generation.json 5d330f021ad1e22b038b08bfd79b49f5da654254 data/deeperdarker/worldgen/configured_feature/gloomy_sculk_patch.json diff --git a/src/generated/resources/data/deeperdarker/worldgen/configured_feature/blooming_sculk_vegetation.json b/src/generated/resources/data/deeperdarker/worldgen/configured_feature/blooming_sculk_vegetation.json index 8f1071acd..0afcd25dd 100644 --- a/src/generated/resources/data/deeperdarker/worldgen/configured_feature/blooming_sculk_vegetation.json +++ b/src/generated/resources/data/deeperdarker/worldgen/configured_feature/blooming_sculk_vegetation.json @@ -15,7 +15,10 @@ }, { "data": { - "Name": "deeperdarker:glowing_grass" + "Name": "deeperdarker:glowing_grass", + "Properties": { + "waterlogged": "false" + } }, "weight": 1 } diff --git a/src/main/java/com/kyanite/deeperdarker/content/blocks/vegetation/GlowingGrassBlock.java b/src/main/java/com/kyanite/deeperdarker/content/blocks/vegetation/GlowingGrassBlock.java index 0708fa3d0..ddf04765f 100644 --- a/src/main/java/com/kyanite/deeperdarker/content/blocks/vegetation/GlowingGrassBlock.java +++ b/src/main/java/com/kyanite/deeperdarker/content/blocks/vegetation/GlowingGrassBlock.java @@ -2,31 +2,54 @@ import com.kyanite.deeperdarker.content.DDBlocks; import net.minecraft.core.BlockPos; +import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.BushBlock; 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; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; @SuppressWarnings({"deprecation", "NullableProblems"}) public class GlowingGrassBlock extends BushBlock { + public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; private static final VoxelShape SHAPE = Block.box(2, 0, 2, 14, 12, 14); public GlowingGrassBlock(Properties pProperties) { super(pProperties); + this.registerDefaultState(this.stateDefinition.any().setValue(WATERLOGGED, Boolean.FALSE)); } @Override public boolean canSurvive(BlockState pState, LevelReader pLevel, BlockPos pPos) { BlockState state = pLevel.getBlockState(pPos.below()); - return state.is(DDBlocks.BLOOMING_SCULK_STONE.get()); + return state.is(DDBlocks.SCULK_STONE.get()) || state.is(DDBlocks.BLOOMING_SCULK_STONE.get()); } @Override protected boolean mayPlaceOn(BlockState pState, BlockGetter pLevel, BlockPos pPos) { - return pState.is(DDBlocks.BLOOMING_SCULK_STONE.get()); + return pState.is(DDBlocks.SCULK_STONE.get()) || pState.is(DDBlocks.BLOOMING_SCULK_STONE.get()); + } + + @Override + protected void createBlockStateDefinition(StateDefinition.Builder pBuilder) { + pBuilder.add(WATERLOGGED); + } + + @Override + public BlockState getStateForPlacement(BlockPlaceContext pContext) { + return this.defaultBlockState().setValue(WATERLOGGED, pContext.getLevel().getFluidState(pContext.getClickedPos()).getType() == Fluids.WATER); + } + + @Override + public FluidState getFluidState(BlockState pState) { + return pState.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(pState); } @Override