diff --git a/src/generated/resources/.cache/103d9f3f36b01595f1aa5172191e60eff02e6924 b/src/generated/resources/.cache/103d9f3f36b01595f1aa5172191e60eff02e6924 index 1377df198..d7acf3a79 100644 --- a/src/generated/resources/.cache/103d9f3f36b01595f1aa5172191e60eff02e6924 +++ b/src/generated/resources/.cache/103d9f3f36b01595f1aa5172191e60eff02e6924 @@ -1,4 +1,4 @@ -// 1.21 2024-12-11T21:15:31.7389635 Registries +// 1.21 2024-12-12T16:46:10.7707931 Registries 65c8c67a4ec7ef0ce6846fb2f4d921cc6ceb02e2 data/deeperdarker/damage_type/bite.json 0b65c61bd1e5086d0f3685566cc6cecf6e324516 data/deeperdarker/damage_type/ring.json dede162345c14db637f3dd9a20ca9319e037ae9d data/deeperdarker/dimension/otherside.json @@ -67,7 +67,7 @@ ee40c6672e01f7903cbd018effd3b9fb238b9dc8 data/deeperdarker/worldgen/configured_f 333ebc366d7e8a080a71cde8f67a83af1f4daa8a data/deeperdarker/worldgen/configured_feature/water_edge_blooming.json c7afaaec2673ebacca18346132ad25008799155c data/deeperdarker/worldgen/noise_settings/otherside.json 34fb9a5e22128132e9fb0b0a7700008873e4ac41 data/deeperdarker/worldgen/placed_feature/blooming_moss.json -75cae3824f63a98efdd5f8ea944c96f99864bc8e data/deeperdarker/worldgen/placed_feature/blooming_plant.json +c4020bc5fd1df4162e76204771b268958eb9c21a data/deeperdarker/worldgen/placed_feature/blooming_plant.json 7a014f12c936a2ce55cd0df3b6e7d66934996c63 data/deeperdarker/worldgen/placed_feature/blooming_pool.json fe37fcf58645ddec579c794a106fbcff6e32c041 data/deeperdarker/worldgen/placed_feature/blooming_sculk_vegetation.json 7af28967be32198f89f2b307bdbd34274d1d555b data/deeperdarker/worldgen/placed_feature/blooming_water_edge.json diff --git a/src/generated/resources/data/deeperdarker/worldgen/placed_feature/blooming_plant.json b/src/generated/resources/data/deeperdarker/worldgen/placed_feature/blooming_plant.json index 553c5c281..8b7fde532 100644 --- a/src/generated/resources/data/deeperdarker/worldgen/placed_feature/blooming_plant.json +++ b/src/generated/resources/data/deeperdarker/worldgen/placed_feature/blooming_plant.json @@ -15,6 +15,7 @@ "state": { "Name": "deeperdarker:blooming_stem", "Properties": { + "age": "0", "down": "false", "east": "false", "north": "false", diff --git a/src/main/java/com/kyanite/deeperdarker/content/DDBlocks.java b/src/main/java/com/kyanite/deeperdarker/content/DDBlocks.java index ca779dcfe..afaf4c137 100644 --- a/src/main/java/com/kyanite/deeperdarker/content/DDBlocks.java +++ b/src/main/java/com/kyanite/deeperdarker/content/DDBlocks.java @@ -86,7 +86,7 @@ public BlockEntity newBlockEntity(BlockPos pPos, BlockState pState) { private static final BlockSetType BLOOM_SET = BlockSetType.register(new BlockSetType("bloom")); public static final WoodType BLOOM = WoodType.register(new WoodType("bloom", BLOOM_SET)); - public static final DeferredBlock BLOOMING_STEM = register("blooming_stem", () -> new BloomingStemBlock(BlockBehaviour.Properties.of().strength(1f).sound(SoundType.WOOD).mapColor(MapColor.COLOR_CYAN).ignitedByLava().noOcclusion())); + public static final DeferredBlock BLOOMING_STEM = register("blooming_stem", () -> new BloomingStemBlock(BlockBehaviour.Properties.of().strength(1f).randomTicks().sound(SoundType.WOOD).mapColor(MapColor.COLOR_CYAN).ignitedByLava().noOcclusion())); public static final DeferredBlock STRIPPED_BLOOMING_STEM = register("stripped_blooming_stem", () -> new BloomingStemBlock(BlockBehaviour.Properties.ofFullCopy(BLOOMING_STEM.get()).mapColor(MapColor.GLOW_LICHEN))); public static final DeferredBlock BLOOM_PLANKS = register("bloom_planks", () -> new FlammableBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.OAK_PLANKS).mapColor(MapColor.GLOW_LICHEN), 20, 5)); public static final DeferredBlock BLOOM_STAIRS = register("bloom_stairs", () -> new FlammableStairBlock(BLOOM_PLANKS.get().defaultBlockState(), BlockBehaviour.Properties.ofFullCopy(Blocks.OAK_STAIRS).mapColor(MapColor.GLOW_LICHEN), 20, 5)); diff --git a/src/main/java/com/kyanite/deeperdarker/content/blocks/BloomingStemBlock.java b/src/main/java/com/kyanite/deeperdarker/content/blocks/BloomingStemBlock.java index a9860f06e..f877a6824 100644 --- a/src/main/java/com/kyanite/deeperdarker/content/blocks/BloomingStemBlock.java +++ b/src/main/java/com/kyanite/deeperdarker/content/blocks/BloomingStemBlock.java @@ -17,6 +17,7 @@ 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.block.state.properties.IntegerProperty; import net.minecraft.world.phys.shapes.BooleanOp; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.Shapes; @@ -27,6 +28,7 @@ @SuppressWarnings("NullableProblems") public class BloomingStemBlock extends Block { + public static final IntegerProperty AGE = BlockStateProperties.AGE_25; public static final BooleanProperty UP = BlockStateProperties.UP; public static final BooleanProperty DOWN = BlockStateProperties.DOWN; public static final BooleanProperty NORTH = BlockStateProperties.NORTH; @@ -45,12 +47,12 @@ public class BloomingStemBlock extends Block { public BloomingStemBlock(Properties properties) { super(properties); - this.registerDefaultState(this.stateDefinition.any().setValue(UP, false).setValue(DOWN, false).setValue(NORTH, false).setValue(EAST, false).setValue(SOUTH, false).setValue(WEST, false)); + this.registerDefaultState(this.stateDefinition.any().setValue(AGE, 0).setValue(UP, false).setValue(DOWN, false).setValue(NORTH, false).setValue(EAST, false).setValue(SOUTH, false).setValue(WEST, false)); } @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { - builder.add(UP, DOWN, NORTH, EAST, SOUTH, WEST); + builder.add(AGE, UP, DOWN, NORTH, EAST, SOUTH, WEST); } @Override @@ -59,10 +61,10 @@ public BlockState getStateForPlacement(BlockPlaceContext context) { BlockGetter level = context.getLevel(); BlockState belowState = level.getBlockState(pos.below()); - Direction clickedDir = context.getClickedFace(); + Direction clickedFace = context.getClickedFace(); if(validBase(belowState)) return this.defaultBlockState().setValue(DOWN, true); - return this.defaultBlockState().setValue(PipeBlock.PROPERTY_BY_DIRECTION.get(clickedDir.getOpposite()), true); + return this.defaultBlockState().setValue(PipeBlock.PROPERTY_BY_DIRECTION.get(clickedFace.getOpposite()), true); } @Override @@ -109,6 +111,48 @@ public void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource if(!state.canSurvive(level, pos)) level.destroyBlock(pos, true); } + @Override + protected void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { + if(state.getValue(AGE) >= 25) return; + if(!level.isEmptyBlock(pos.above())) return; + if(this.defaultBlockState().is(DDBlocks.STRIPPED_BLOOMING_STEM.get())) return; + + int age = Math.min(25, state.getValue(AGE) + random.nextInt(1, 4)); + state = state.setValue(AGE, age); + BlockState newState = this.defaultBlockState().setValue(AGE, age); + level.setBlock(pos, state, 3); + + int connections = 0; + for(Direction direction : Direction.values()) { + if(state.getValue(PipeBlock.PROPERTY_BY_DIRECTION.get(direction))) connections++; + if(connections == 2) return; + } + + if(random.nextFloat() < 0.05f) return; + if(connections == 1) { + if(state.getValue(DOWN) && random.nextFloat() < 0.3f) { // turn + Direction d1 = Direction.Plane.HORIZONTAL.getRandomDirection(random); + + if(random.nextFloat() < 0.4f) { // branch + Direction d2 = Direction.getRandom(random); + if(random.nextFloat() < 0.5f) d2 = Direction.UP; + else while(d2 == Direction.DOWN || d2 == d1) d2 = Direction.getRandom(random); + + if(level.isEmptyBlock(pos.relative(d2))) { + level.setBlock(pos.relative(d2), newState.setValue(PipeBlock.PROPERTY_BY_DIRECTION.get(d2.getOpposite()), true), 3); + } + } + + if(level.isEmptyBlock(pos.relative(d1))) { + level.setBlock(pos.relative(d1), newState.setValue(PipeBlock.PROPERTY_BY_DIRECTION.get(d1.getOpposite()), true), 3); + return; + } + } + + level.setBlock(pos.above(), newState.setValue(DOWN, true), 3); + } + } + @Override public boolean canSurvive(BlockState state, LevelReader level, BlockPos pos) { if(validBase(level.getBlockState(pos.below()))) return true;