forked from The-Aether-Team/The-Aether
-
Notifications
You must be signed in to change notification settings - Fork 0
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
11 changed files
with
178 additions
and
88 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
42 changes: 41 additions & 1 deletion
42
src/generated/resources/data/aether/worldgen/biome/floating_forest.json
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
14 changes: 14 additions & 0 deletions
14
...n/java/com/gildedgames/aether/common/world/gen/configuration/SimpleDiskConfiguration.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,14 @@ | ||
package com.gildedgames.aether.common.world.gen.configuration; | ||
|
||
import com.mojang.serialization.Codec; | ||
import com.mojang.serialization.codecs.RecordCodecBuilder; | ||
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration; | ||
import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider; | ||
|
||
public record SimpleDiskConfiguration(float radius, BlockStateProvider block, int clearanceRadius) implements FeatureConfiguration { | ||
public static final Codec<SimpleDiskConfiguration> CODEC = RecordCodecBuilder.create(instance -> instance.group( | ||
Codec.floatRange(1, 12).fieldOf("radius").forGetter(SimpleDiskConfiguration::radius), | ||
BlockStateProvider.CODEC.fieldOf("block").forGetter(SimpleDiskConfiguration::block), | ||
Codec.intRange(1, 12).fieldOf("clearance_radius").forGetter(SimpleDiskConfiguration::clearanceRadius) | ||
).apply(instance, SimpleDiskConfiguration::new)); | ||
} |
48 changes: 0 additions & 48 deletions
48
src/main/java/com/gildedgames/aether/common/world/gen/feature/QuicksoilFeature.java
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
src/main/java/com/gildedgames/aether/common/world/gen/feature/SimpleDiskFeature.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,33 @@ | ||
package com.gildedgames.aether.common.world.gen.feature; | ||
|
||
import com.gildedgames.aether.common.registry.AetherBlocks; | ||
import com.gildedgames.aether.common.registry.AetherTags; | ||
import com.gildedgames.aether.common.world.gen.configuration.SimpleDiskConfiguration; | ||
import com.gildedgames.aether.core.util.BlockLogic; | ||
import com.gildedgames.aether.core.util.BlockPlacers; | ||
import com.mojang.serialization.Codec; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.level.WorldGenLevel; | ||
import net.minecraft.world.level.levelgen.feature.Feature; | ||
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; | ||
|
||
public class SimpleDiskFeature extends Feature<SimpleDiskConfiguration> { | ||
public SimpleDiskFeature(Codec<SimpleDiskConfiguration> codec) { | ||
super(codec); | ||
} | ||
|
||
@Override | ||
public boolean place(FeaturePlaceContext<SimpleDiskConfiguration> context) { | ||
BlockPos pos = context.origin(); | ||
WorldGenLevel reader = context.level(); | ||
|
||
boolean doesProtrude = BlockLogic.doesAirExistNearby(pos, context.config().clearanceRadius(), reader) && | ||
(reader.getBlockState(pos).is(AetherTags.Blocks.HOLYSTONE) || | ||
reader.getBlockState(pos).getBlock() == AetherBlocks.AETHER_DIRT.get()); | ||
|
||
if (doesProtrude) | ||
BlockPlacers.placeDisk(pos, context.config().radius(), reader, context.config().block(), context.random()); | ||
|
||
return doesProtrude; | ||
} | ||
} |
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
16 changes: 16 additions & 0 deletions
16
src/main/java/com/gildedgames/aether/core/util/BlockLogic.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,16 @@ | ||
package com.gildedgames.aether.core.util; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.level.WorldGenLevel; | ||
|
||
public final class BlockLogic { | ||
public static boolean doesAirExistNearby(BlockPos center, int radius, WorldGenLevel level) { | ||
return level.isEmptyBlock(center.north(radius)) | ||
|| level.isEmptyBlock(center.south(radius)) | ||
|| level.isEmptyBlock(center.west(radius)) | ||
|| level.isEmptyBlock(center.east(radius)); | ||
} | ||
|
||
private BlockLogic() { | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/com/gildedgames/aether/core/util/BlockPlacers.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,34 @@ | ||
package com.gildedgames.aether.core.util; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.level.WorldGenLevel; | ||
import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider; | ||
|
||
import java.util.Random; | ||
|
||
public final class BlockPlacers { | ||
public static void placeDisk(BlockPos center, float radius, WorldGenLevel level, BlockStateProvider blockProvider, Random random) { | ||
float radiusSq = radius * radius; | ||
|
||
placeProvidedBlock(level, blockProvider, center, random); | ||
|
||
for (int z = 1; z < radius; z++) { | ||
for (int x = 0; x < radius; x++) { | ||
if (x * x + z * z > radiusSq) continue; | ||
|
||
placeProvidedBlock(level, blockProvider, center.offset(x, 0, z), random); | ||
placeProvidedBlock(level, blockProvider, center.offset(-x, 0, -z), random); | ||
placeProvidedBlock(level, blockProvider, center.offset(-z, 0, x), random); | ||
placeProvidedBlock(level, blockProvider, center.offset(z, 0, -x), random); | ||
} | ||
} | ||
} | ||
|
||
@SuppressWarnings("UnusedReturnValue") // Retain the boolean feedback from setting block | ||
public static boolean placeProvidedBlock(WorldGenLevel level, BlockStateProvider provider, BlockPos pos, Random random) { | ||
return level.setBlock(pos, provider.getState(random, pos), 2); | ||
} | ||
|
||
private BlockPlacers() { | ||
} | ||
} |