From 57baf056bc6f2ad32afe7ae6a6a982aae477bdec Mon Sep 17 00:00:00 2001 From: arathain Date: Mon, 2 Feb 2026 14:48:40 +0100 Subject: [PATCH 1/2] bramble upgrade --- .../world/block/plant/ThornyStemBlock.java | 6 +- .../content/feature/BrineBrambleFeature.java | 90 +++++++++++++++++-- .../placed_feature/brine_bramble.json | 4 +- 3 files changed, 89 insertions(+), 11 deletions(-) diff --git a/src/main/java/birsy/clinker/common/world/block/plant/ThornyStemBlock.java b/src/main/java/birsy/clinker/common/world/block/plant/ThornyStemBlock.java index c0795f6a..a0aafc83 100644 --- a/src/main/java/birsy/clinker/common/world/block/plant/ThornyStemBlock.java +++ b/src/main/java/birsy/clinker/common/world/block/plant/ThornyStemBlock.java @@ -12,6 +12,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.block.SupportType; +import net.minecraft.world.level.block.SweetBerryBushBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluids; import net.minecraft.world.phys.AABB; @@ -76,7 +77,10 @@ protected void entityInside(BlockState state, Level level, BlockPos pos, Entity } } if (inside) { - entity.hurt(level.damageSources().cactus(), 1); + if(entity.tickCount % 20 < 12 && entity.tickCount % 3 == 0 && (entity.xOld != entity.getX() || entity.zOld != entity.getZ())) { + entity.hurt(level.damageSources().cactus(), 1); + entity.invulnerableTime = 11; + } boolean onClimbable = entity instanceof LivingEntity livingEntity && livingEntity.onClimbable(); if (entity.getDeltaMovement().y < 0 || onClimbable) { entity.makeStuckInBlock(state, new Vec3(1, 0.8, 1)); diff --git a/src/main/java/birsy/clinker/common/world/level/gen/content/feature/BrineBrambleFeature.java b/src/main/java/birsy/clinker/common/world/level/gen/content/feature/BrineBrambleFeature.java index f39e4c01..eda18c46 100644 --- a/src/main/java/birsy/clinker/common/world/level/gen/content/feature/BrineBrambleFeature.java +++ b/src/main/java/birsy/clinker/common/world/level/gen/content/feature/BrineBrambleFeature.java @@ -6,11 +6,9 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.util.RandomSource; -import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.PipeBlock; -import net.minecraft.world.level.block.SupportType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; @@ -21,6 +19,8 @@ import org.jetbrains.annotations.Nullable; import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; public class BrineBrambleFeature extends Feature { public BrineBrambleFeature(Codec config) { @@ -38,18 +38,38 @@ public boolean place(FeaturePlaceContext context) { ArrayList ps = new ArrayList<>(); ArrayList escrow = new ArrayList<>(); int budget; + ps.add(origin.mutable()); for(Direction d : Direction.values()) { - escrow.clear(); - tgt = origin.mutable(); - budget = 12; if(d == Direction.DOWN) continue; + + escrow.clear(); + tgt = origin.mutable(); + budget = 37; + ps.add(tgt.relative(d)); escrow.add(tgt.relative(d)); - propagateBramble(ps, escrow, level, d, tgt, random, budget); + propagateBrambleDown(ps, level, tgt, random, budget); + //propagateBramble(ps, escrow, level, d, tgt, random, budget); + } + + escrow.addAll(ps); + + int top = 8; + + for(BlockPos p : escrow) { + if(random.nextFloat() > 1f - 0.3f/(1f+Math.sqrt(p.distSqr(origin)))) { + top -= 1; + budget = 15; + propagateBrambleDown(ps, level, p, random, budget); + + if(top <= 0) { + break; + } + } } placeBramble(ps, level, origin, random); @@ -75,8 +95,10 @@ private static int propagateBramble(ArrayList tgts, ArrayList (d == Direction.UP ? 0.8 : d == Direction.DOWN ? -0.1 : 0.25)) { + if(s.canBeReplaced() && (s2.isSolid() || s3.isSolid()) && rs.nextFloat() > (d == Direction.UP ? 0.9 : d == Direction.DOWN ? 0. : 0.35)) { tgts.add(tgt); tgtEscrow.add(tgt); @@ -101,13 +123,65 @@ private static int propagateBramble(ArrayList tgts, ArrayList dirs = Arrays.stream(Direction.values()).filter(Direction.Plane.HORIZONTAL).toList(); + + + + private static int propagateBrambleDown(ArrayList tgts, WorldGenLevel level, BlockPos bp, RandomSource rs, int budget) { + if(budget <= 0) { + return 0; + } + + BlockPos.MutableBlockPos tgt = bp.mutable(); + BlockPos.MutableBlockPos tgtB = bp.relative(Direction.DOWN).mutable(); + while(budget > 0) { + if(!level.getBlockState(tgtB).canBeReplaced()) { + int r = rs.nextInt(4); + boolean noEsc = true; + for(int ui = 0; ui < 4; ui++) { + int i = (ui + r) % 4; + Direction dir = dirs.get(i); + tgt.move(dir); + if(level.getBlockState(tgt).canBeReplaced()) { + tgts.add(tgt.immutable()); + tgtB.move(dir); + budget -= 1; + noEsc = false; + break; + } + } + if(noEsc) { + budget = 0; + } + } else { + if(rs.nextFloat() > 0.7) { + Direction d2 = Direction.fromYRot(budget % 2 * 180 + (((budget + 1)*0.5) % 2 * 90)); + if(level.getBlockState(tgt.relative(d2)).canBeReplaced()) { + tgt.move(d2); + tgts.add(tgt.immutable()); + tgtB.move(d2); + } + } + tgt.move(Direction.DOWN); + tgts.add(tgt.immutable()); + tgtB.move(Direction.DOWN); + budget -= 1; + } + + } + + return budget; + } + private static final Vec3 up = new Vec3(0., 1., 0.); private void placeBramble(ArrayList positions, WorldGenLevel l, BlockPos p, RandomSource r) { for(BlockPos pos : positions) { if(pos.getY() > p.getY() + 2) continue; - Block ds = (pos.getCenter().subtract(p.getBottomCenter()).dot(up) < .5 + r.nextFloat() * 2.) ? ClinkerBlocks.THORNY_STEM.get() : ClinkerBlocks.SALTY_STEM.get(); + Block ds = (-pos.getCenter().subtract(p.getBottomCenter()).dot(up) < .5 + r.nextFloat() * 2.) ? ClinkerBlocks.THORNY_STEM.get() : ClinkerBlocks.SALTY_STEM.get(); + if(!l.getBlockState(pos).canBeReplaced()) + continue; BlockState s = getStateForPlacement(l, pos, p, positions, ds.defaultBlockState()); if(s != null) diff --git a/src/main/resources/data/clinker/worldgen/placed_feature/brine_bramble.json b/src/main/resources/data/clinker/worldgen/placed_feature/brine_bramble.json index 3ca5707d..11a44b73 100644 --- a/src/main/resources/data/clinker/worldgen/placed_feature/brine_bramble.json +++ b/src/main/resources/data/clinker/worldgen/placed_feature/brine_bramble.json @@ -5,8 +5,8 @@ "type": "minecraft:count", "count": { "type": "minecraft:uniform", - "min_inclusive": 1, - "max_inclusive": 1 + "min_inclusive": 2, + "max_inclusive": 5 } }, { From c2fc02297efd49ee12a9d7f7350d3ac0e7115732 Mon Sep 17 00:00:00 2001 From: arathain Date: Mon, 2 Feb 2026 14:48:40 +0100 Subject: [PATCH 2/2] bramble upgrade --- .../world/block/plant/ThornyStemBlock.java | 6 +- .../content/feature/BrineBrambleFeature.java | 90 +++++++++++++++++-- .../placed_feature/brine_bramble.json | 4 +- 3 files changed, 89 insertions(+), 11 deletions(-) diff --git a/src/main/java/birsy/clinker/common/world/block/plant/ThornyStemBlock.java b/src/main/java/birsy/clinker/common/world/block/plant/ThornyStemBlock.java index c0795f6a..a0aafc83 100644 --- a/src/main/java/birsy/clinker/common/world/block/plant/ThornyStemBlock.java +++ b/src/main/java/birsy/clinker/common/world/block/plant/ThornyStemBlock.java @@ -12,6 +12,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.block.SupportType; +import net.minecraft.world.level.block.SweetBerryBushBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluids; import net.minecraft.world.phys.AABB; @@ -76,7 +77,10 @@ protected void entityInside(BlockState state, Level level, BlockPos pos, Entity } } if (inside) { - entity.hurt(level.damageSources().cactus(), 1); + if(entity.tickCount % 20 < 12 && entity.tickCount % 3 == 0 && (entity.xOld != entity.getX() || entity.zOld != entity.getZ())) { + entity.hurt(level.damageSources().cactus(), 1); + entity.invulnerableTime = 11; + } boolean onClimbable = entity instanceof LivingEntity livingEntity && livingEntity.onClimbable(); if (entity.getDeltaMovement().y < 0 || onClimbable) { entity.makeStuckInBlock(state, new Vec3(1, 0.8, 1)); diff --git a/src/main/java/birsy/clinker/common/world/level/gen/content/feature/BrineBrambleFeature.java b/src/main/java/birsy/clinker/common/world/level/gen/content/feature/BrineBrambleFeature.java index f39e4c01..eda18c46 100644 --- a/src/main/java/birsy/clinker/common/world/level/gen/content/feature/BrineBrambleFeature.java +++ b/src/main/java/birsy/clinker/common/world/level/gen/content/feature/BrineBrambleFeature.java @@ -6,11 +6,9 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.util.RandomSource; -import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.PipeBlock; -import net.minecraft.world.level.block.SupportType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; @@ -21,6 +19,8 @@ import org.jetbrains.annotations.Nullable; import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; public class BrineBrambleFeature extends Feature { public BrineBrambleFeature(Codec config) { @@ -38,18 +38,38 @@ public boolean place(FeaturePlaceContext context) { ArrayList ps = new ArrayList<>(); ArrayList escrow = new ArrayList<>(); int budget; + ps.add(origin.mutable()); for(Direction d : Direction.values()) { - escrow.clear(); - tgt = origin.mutable(); - budget = 12; if(d == Direction.DOWN) continue; + + escrow.clear(); + tgt = origin.mutable(); + budget = 37; + ps.add(tgt.relative(d)); escrow.add(tgt.relative(d)); - propagateBramble(ps, escrow, level, d, tgt, random, budget); + propagateBrambleDown(ps, level, tgt, random, budget); + //propagateBramble(ps, escrow, level, d, tgt, random, budget); + } + + escrow.addAll(ps); + + int top = 8; + + for(BlockPos p : escrow) { + if(random.nextFloat() > 1f - 0.3f/(1f+Math.sqrt(p.distSqr(origin)))) { + top -= 1; + budget = 15; + propagateBrambleDown(ps, level, p, random, budget); + + if(top <= 0) { + break; + } + } } placeBramble(ps, level, origin, random); @@ -75,8 +95,10 @@ private static int propagateBramble(ArrayList tgts, ArrayList (d == Direction.UP ? 0.8 : d == Direction.DOWN ? -0.1 : 0.25)) { + if(s.canBeReplaced() && (s2.isSolid() || s3.isSolid()) && rs.nextFloat() > (d == Direction.UP ? 0.9 : d == Direction.DOWN ? 0. : 0.35)) { tgts.add(tgt); tgtEscrow.add(tgt); @@ -101,13 +123,65 @@ private static int propagateBramble(ArrayList tgts, ArrayList dirs = Arrays.stream(Direction.values()).filter(Direction.Plane.HORIZONTAL).toList(); + + + + private static int propagateBrambleDown(ArrayList tgts, WorldGenLevel level, BlockPos bp, RandomSource rs, int budget) { + if(budget <= 0) { + return 0; + } + + BlockPos.MutableBlockPos tgt = bp.mutable(); + BlockPos.MutableBlockPos tgtB = bp.relative(Direction.DOWN).mutable(); + while(budget > 0) { + if(!level.getBlockState(tgtB).canBeReplaced()) { + int r = rs.nextInt(4); + boolean noEsc = true; + for(int ui = 0; ui < 4; ui++) { + int i = (ui + r) % 4; + Direction dir = dirs.get(i); + tgt.move(dir); + if(level.getBlockState(tgt).canBeReplaced()) { + tgts.add(tgt.immutable()); + tgtB.move(dir); + budget -= 1; + noEsc = false; + break; + } + } + if(noEsc) { + budget = 0; + } + } else { + if(rs.nextFloat() > 0.7) { + Direction d2 = Direction.fromYRot(budget % 2 * 180 + (((budget + 1)*0.5) % 2 * 90)); + if(level.getBlockState(tgt.relative(d2)).canBeReplaced()) { + tgt.move(d2); + tgts.add(tgt.immutable()); + tgtB.move(d2); + } + } + tgt.move(Direction.DOWN); + tgts.add(tgt.immutable()); + tgtB.move(Direction.DOWN); + budget -= 1; + } + + } + + return budget; + } + private static final Vec3 up = new Vec3(0., 1., 0.); private void placeBramble(ArrayList positions, WorldGenLevel l, BlockPos p, RandomSource r) { for(BlockPos pos : positions) { if(pos.getY() > p.getY() + 2) continue; - Block ds = (pos.getCenter().subtract(p.getBottomCenter()).dot(up) < .5 + r.nextFloat() * 2.) ? ClinkerBlocks.THORNY_STEM.get() : ClinkerBlocks.SALTY_STEM.get(); + Block ds = (-pos.getCenter().subtract(p.getBottomCenter()).dot(up) < .5 + r.nextFloat() * 2.) ? ClinkerBlocks.THORNY_STEM.get() : ClinkerBlocks.SALTY_STEM.get(); + if(!l.getBlockState(pos).canBeReplaced()) + continue; BlockState s = getStateForPlacement(l, pos, p, positions, ds.defaultBlockState()); if(s != null) diff --git a/src/main/resources/data/clinker/worldgen/placed_feature/brine_bramble.json b/src/main/resources/data/clinker/worldgen/placed_feature/brine_bramble.json index 3ca5707d..11a44b73 100644 --- a/src/main/resources/data/clinker/worldgen/placed_feature/brine_bramble.json +++ b/src/main/resources/data/clinker/worldgen/placed_feature/brine_bramble.json @@ -5,8 +5,8 @@ "type": "minecraft:count", "count": { "type": "minecraft:uniform", - "min_inclusive": 1, - "max_inclusive": 1 + "min_inclusive": 2, + "max_inclusive": 5 } }, {