Stalactite enhancements (WIP)
This commit is contained in:
parent
7e73d9a31c
commit
0739e0580b
19 changed files with 272 additions and 43 deletions
|
@ -4,6 +4,7 @@ import java.util.Random;
|
|||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
@ -33,14 +34,14 @@ public class StalactiteFeature extends DefaultFeature {
|
|||
}
|
||||
|
||||
Mutable mut = new Mutable().set(pos);
|
||||
int height = random.nextInt(8);
|
||||
int height = random.nextInt(8);
|
||||
int dir = ceiling ? -1 : 1;
|
||||
boolean stalagnate = false;
|
||||
|
||||
for (int i = 1; i <= height; i++) {
|
||||
mut.setY(pos.getY() + i * dir);
|
||||
BlockState state = world.getBlockState(mut);
|
||||
if (!state.isAir()) {
|
||||
if (!state.getMaterial().isReplaceable()) {
|
||||
stalagnate = state.isIn(EndTags.GEN_TERRAIN);
|
||||
height = i - 1;
|
||||
break;
|
||||
|
@ -51,7 +52,10 @@ public class StalactiteFeature extends DefaultFeature {
|
|||
for (int i = 0; i < height; i++) {
|
||||
mut.setY(pos.getY() + i * dir);
|
||||
int size = stalagnate ? MathHelper.abs(i - center) + 1 : height - i - 1;
|
||||
BlocksHelper.setWithoutUpdate(world, mut, block.getDefaultState().with(StalactiteBlock.SIZE, size));
|
||||
boolean waterlogged = !world.getFluidState(mut).isEmpty();
|
||||
BlockState base = block.getDefaultState().with(StalactiteBlock.SIZE, size).with(Properties.WATERLOGGED, waterlogged);
|
||||
BlockState state = stalagnate ? base.with(StalactiteBlock.IS_FLOOR, dir > 0 ? i < center : i > center) : base.with(StalactiteBlock.IS_FLOOR, dir > 0);
|
||||
BlocksHelper.setWithoutUpdate(world, mut, state);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue