-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
623 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/de/dafuqs/starrysky/dimension/decorators/GlowLichenDecorator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package de.dafuqs.starrysky.dimension.decorators; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import de.dafuqs.starrysky.dimension.SpheroidDecorator; | ||
import de.dafuqs.starrysky.spheroid.spheroids.Spheroid; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.Blocks; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Direction; | ||
import net.minecraft.world.StructureWorldAccess; | ||
import net.minecraft.world.gen.feature.GlowLichenFeature; | ||
import net.minecraft.world.gen.feature.GlowLichenFeatureConfig; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Random; | ||
|
||
public class GlowLichenDecorator extends SpheroidDecorator { | ||
|
||
// TODO: TEST | ||
private final List<BlockState> placeableOn = ImmutableList.of(Blocks.STONE.getDefaultState(), Blocks.ANDESITE.getDefaultState(), Blocks.DIORITE.getDefaultState(), Blocks.GRANITE.getDefaultState(), Blocks.DRIPSTONE_BLOCK.getDefaultState(), Blocks.CALCITE.getDefaultState(), Blocks.TUFF.getDefaultState(), Blocks.DEEPSLATE.getDefaultState()); | ||
private final GlowLichenFeatureConfig glowLichenFeatureConfig = new GlowLichenFeatureConfig(5, true, true, true, 0.5F, placeableOn); | ||
private final float chance; | ||
|
||
public GlowLichenDecorator(float chance) { | ||
this.chance = chance; | ||
} | ||
|
||
@Override | ||
public void decorateSpheroid(StructureWorldAccess world, Spheroid spheroid, ArrayList<BlockPos> decorationBlockPositions, Random random) { | ||
for(BlockPos bp : decorationBlockPositions) { | ||
if(random.nextFloat() < chance) { | ||
GlowLichenFeature.generate(world, bp, world.getBlockState(bp), glowLichenFeatureConfig, random, Arrays.asList(Direction.values())); | ||
} | ||
} | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
src/main/java/de/dafuqs/starrysky/dimension/decorators/PointedDripstoneDecorator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package de.dafuqs.starrysky.dimension.decorators; | ||
|
||
import de.dafuqs.starrysky.dimension.SpheroidDecorator; | ||
import de.dafuqs.starrysky.spheroid.spheroids.Spheroid; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.Blocks; | ||
import net.minecraft.tag.BlockTags; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Direction; | ||
import net.minecraft.world.StructureWorldAccess; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Random; | ||
|
||
public class PointedDripstoneDecorator extends SpheroidDecorator { | ||
|
||
private final float chance; | ||
private final PointedDripstoneDecoratorMode mode; | ||
|
||
public enum PointedDripstoneDecoratorMode { | ||
UP, | ||
DOWN, | ||
CAVE | ||
} | ||
|
||
public PointedDripstoneDecorator(float chance, PointedDripstoneDecoratorMode mode) { | ||
this.chance = chance; | ||
this.mode = mode; | ||
} | ||
|
||
@Override | ||
public void decorateSpheroid(StructureWorldAccess world, Spheroid spheroid, ArrayList<BlockPos> decorationBlockPositions, Random random) { | ||
for(BlockPos bp : decorationBlockPositions) { | ||
if(random.nextFloat() < chance) { | ||
int height = random.nextInt(5); | ||
switch (this.mode) { | ||
case UP -> { | ||
placeDripstoneBlocks(world, bp, height, Direction.UP); | ||
} | ||
case DOWN -> { | ||
placeDripstoneBlocks(world, bp, height, Direction.DOWN); | ||
} | ||
case CAVE -> { | ||
if(random.nextBoolean()) { | ||
placeDripstoneBlocks(world, bp, height, Direction.UP); | ||
} else { | ||
BlockPos.Mutable mutable = bp.mutableCopy(); | ||
for(int i = 0; i < spheroid.getRadius(); ++i) { | ||
if (!world.isAir(bp)) { | ||
placeDripstoneBlocks(world, bp, height, Direction.UP); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
} | ||
} | ||
} | ||
|
||
private void placeDripstoneBlocks(StructureWorldAccess world, BlockPos pos, int height, Direction direction) { | ||
BlockPos.Mutable mutable = pos.mutableCopy(); | ||
for(int i = 0; i < height; ++i) { | ||
if (!generateDripstoneBlock(world, mutable)) { | ||
return; | ||
} | ||
mutable.move(direction); | ||
} | ||
} | ||
|
||
protected static boolean generateDripstoneBlock(StructureWorldAccess world, BlockPos pos) { | ||
BlockState blockState = world.getBlockState(pos); | ||
if (blockState.isIn(BlockTags.DRIPSTONE_REPLACEABLE_BLOCKS)) { | ||
world.setBlockState(pos, Blocks.DRIPSTONE_BLOCK.getDefaultState(), 2); | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.