Skip to content

Commit 364906a

Browse files
committed
Starry Skies integration
1 parent b56cdd7 commit 364906a

File tree

11 files changed

+155
-8
lines changed

11 files changed

+155
-8
lines changed

build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ repositories {
3030
name = 'ParchmentMC'
3131
url = 'https://maven.parchmentmc.org'
3232
}
33+
maven { url = "https://maven.kyrptonaught.dev" } // CustomPortalAPI as requirement for Starry Skies
3334
mavenCentral()
3435
}
3536

@@ -71,6 +72,7 @@ dependencies {
7172
modImplementation include("de.dafuqs:fractal:${project.fractal_version}")
7273

7374
// external and compat
75+
modImplementation include("de.dafuqs.starryskies:StarrySkies:${project.starry_skies_version}")
7476
modApi("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") { exclude(group: "net.fabricmc.fabric-api") }
7577
modApi("dev.architectury:architectury-fabric:${project.architectury_version}") { exclude(group: "net.fabricmc.fabric-api") }
7678
modApi("com.terraformersmc:modmenu:${project.modmenu_version}")

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ port_lib_modules=lazy_registration
6262
exclusionslib_version=R2vQMUlU
6363
# https://modrinth.com/mod/vanity
6464
vanityslots_version=9oyPiBlw
65+
starry_skies_version=3.2.0+1.21.1
6566

6667
# What recipe viewer to use ('emi', 'rei', or 'disabled')
6768
recipe_viewer=emi

src/main/java/de/dafuqs/spectrum/compat/SpectrumIntegrationPacks.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import de.dafuqs.spectrum.compat.malum.*;
1313
import de.dafuqs.spectrum.compat.modonomicon.*;
1414
import de.dafuqs.spectrum.compat.neepmeat.*;
15+
import de.dafuqs.spectrum.compat.starry_skies.*;
1516
import de.dafuqs.spectrum.compat.travelersbackpack.*;
1617
import net.fabricmc.api.*;
1718
import net.fabricmc.loader.api.*;
@@ -47,6 +48,7 @@ protected static void registerIntegrationPack(String modId, Supplier<ModIntegrat
4748
public static final String NEEPMEAT_ID = "neepmeat";
4849
public static final String MALUM_ID = "malum";
4950
public static final String EXCLUSIONS_LIB_ID = "exclusions_lib";
51+
public static final String STARRY_SKIES_ID = "starry_skies";
5052

5153
// Client Only
5254
public static final String EARS_ID = "ears";
@@ -71,6 +73,7 @@ public static void register() {
7173
registerIntegrationPack(NEEPMEAT_ID, () -> new NEEPMeatCompat());
7274
registerIntegrationPack(MALUM_ID, () -> new MalumCompat());
7375
registerIntegrationPack(CREATE_ID, () -> new CreateCompat());
76+
registerIntegrationPack(STARRY_SKIES_ID, () -> new StarrySkiesCompat());
7477
}
7578

7679
for (ModIntegrationPack container : INTEGRATION_PACKS.values()) {
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package de.dafuqs.spectrum.compat.starry_skies;
2+
3+
import de.dafuqs.spectrum.*;
4+
import de.dafuqs.spectrum.compat.*;
5+
import de.dafuqs.spectrum.compat.starry_skies.decorators.*;
6+
import de.dafuqs.starryskies.registries.*;
7+
import de.dafuqs.starryskies.worldgen.*;
8+
import net.minecraft.core.*;
9+
10+
public class StarrySkiesCompat extends SpectrumIntegrationPacks.ModIntegrationPack {
11+
12+
public static SphereDecorator<SphereDecoratorConfig.DefaultSphereDecoratorConfig> QUITOXIC_REEDS_POND_DECORATOR = registerDecorator("quitoxic_reeds_pond", new QuitoxicReedsPondDecorator(SphereDecoratorConfig.DefaultSphereDecoratorConfig.CODEC));
13+
14+
@Override
15+
public void register() {
16+
17+
}
18+
19+
@Override
20+
public void registerClient() {
21+
22+
}
23+
24+
private static <C extends SphereDecoratorConfig, F extends SphereDecorator<C>> F registerDecorator(String name, F feature) {
25+
return Registry.register(StarryRegistries.SPHERE_DECORATOR, SpectrumCommon.locate(name), feature);
26+
}
27+
28+
}
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
package de.dafuqs.spectrum.compat.starry_skies.decorators;
2+
3+
import com.mojang.serialization.*;
4+
import de.dafuqs.spectrum.blocks.*;
5+
import de.dafuqs.spectrum.blocks.conditional.*;
6+
import de.dafuqs.spectrum.registries.*;
7+
import de.dafuqs.starryskies.*;
8+
import de.dafuqs.starryskies.worldgen.*;
9+
import net.minecraft.core.*;
10+
import net.minecraft.util.*;
11+
import net.minecraft.world.level.*;
12+
import net.minecraft.world.level.block.*;
13+
import net.minecraft.world.level.block.state.*;
14+
15+
public class QuitoxicReedsPondDecorator extends SphereDecorator<SphereDecoratorConfig.DefaultSphereDecoratorConfig> {
16+
17+
private static final float QUITOXIC_REEDS_CHANCE = 0.25F;
18+
19+
public QuitoxicReedsPondDecorator(Codec<SphereDecoratorConfig.DefaultSphereDecoratorConfig> codec) {
20+
super(codec);
21+
}
22+
23+
@Override
24+
public boolean generate(SphereFeatureContext<SphereDecoratorConfig.DefaultSphereDecoratorConfig> context) {
25+
WorldGenLevel world = context.getWorld();
26+
PlacedSphere<?> sphere = context.getSphere();
27+
ChunkPos origin = context.getChunkPos();
28+
RandomSource random = context.getRandom();
29+
30+
if (!sphere.isCenterInChunk(origin)) {
31+
return false;
32+
}
33+
34+
// doesn't make sense on small spheres
35+
if (sphere.getRadius() > 9) {
36+
int pondRadius = (int) (sphere.getRadius() / 2.5);
37+
BlockPos spherePos = sphere.getPosition();
38+
BlockPos sphereTop = spherePos.above(sphere.getRadius() + 1);
39+
int waterLevelY = determineWaterY(world, sphereTop, pondRadius);
40+
41+
// if there is not enough room for at least a decent amount of water: don't generate
42+
if (waterLevelY - sphere.getPosition().getY() < pondRadius * 1.5) {
43+
return false;
44+
}
45+
46+
BlockState water = Blocks.WATER.defaultBlockState();
47+
BlockState air = Blocks.AIR.defaultBlockState();
48+
BlockState clay = Blocks.CLAY.defaultBlockState();
49+
50+
BlockState quitoxic = SpectrumBlocks.QUITOXIC_REEDS.defaultBlockState();
51+
BlockState quitoxicWater = quitoxic.setValue(QuitoxicReedsBlock.LOGGED, FluidLogging.State.WATER);
52+
53+
BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos();
54+
int pond15 = (int) Math.round(pondRadius * 1.5);
55+
for (int x = -pond15; x <= pond15; x++) {
56+
for (int z = -pond15; z <= pond15; z++) {
57+
mutable.set(spherePos.getX() + x, waterLevelY, spherePos.getZ() + z);
58+
59+
double distance = Support.getDistance(mutable, sphereTop);
60+
if (distance > pond15) {
61+
continue;
62+
}
63+
64+
if (distance < pond15 - 1 && random.nextFloat() < QUITOXIC_REEDS_CHANCE) {
65+
int quitoxicHeight = random.nextInt(QuitoxicReedsBlock.MAX_GROWTH_HEIGHT_WATER);
66+
int setBlockHeight = Math.max(waterLevelY + quitoxicHeight, sphereTop.getY());
67+
68+
mutable.set(spherePos.getX() + x, waterLevelY, spherePos.getZ() + z);
69+
world.setBlock(mutable, quitoxicWater, 3);
70+
71+
for (int y = waterLevelY + 1; y < setBlockHeight; y++) {
72+
mutable.set(spherePos.getX() + x, y, spherePos.getZ() + z);
73+
world.setBlock(mutable, quitoxic, 3);
74+
}
75+
} else {
76+
world.setBlock(mutable, water, 3);
77+
78+
for (int y = waterLevelY + 1; y < sphereTop.getY(); y++) {
79+
mutable.set(spherePos.getX() + x, y, spherePos.getZ() + z);
80+
world.setBlock(mutable, air, 3);
81+
}
82+
}
83+
84+
mutable.set(spherePos.getX() + x, waterLevelY - 1, spherePos.getZ() + z);
85+
world.setBlock(mutable, clay, 3);
86+
}
87+
}
88+
89+
}
90+
91+
return true;
92+
}
93+
94+
public int determineWaterY(WorldGenLevel world, BlockPos sphereTop, int pondRadius) {
95+
for (int x = -pondRadius - 1; x <= pondRadius; x++) {
96+
for (int y = -pondRadius; y < 1; y++) {
97+
for (int z = -pondRadius - 1; z <= pondRadius; z++) {
98+
BlockPos currentBlockPos = sphereTop.offset(x, y, z);
99+
if (world.getBlockState(currentBlockPos).isAir()) {
100+
return currentBlockPos.getY() - 1;
101+
}
102+
}
103+
}
104+
}
105+
return sphereTop.getY();
106+
}
107+
108+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "spectrum:quitoxic_reeds_pond",
3+
"config": {}
4+
}

src/main/resources/data/spectrum/starry_skies/configured_sphere/overworld/essential/resources.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616

1717
"size": {
1818
"type": "minecraft:uniform",
19-
"min_inclusive": 5,
20-
"max_exclusive": 20
19+
"min_inclusive": 10,
20+
"max_exclusive": 14
2121
},
2222

2323
"decorators": {
24-
"spectrum:clover": 0.8,
25-
"spectrum:four_leaf_clover": 0.8
24+
"spectrum:quitoxic_reeds_pond": 1.0,
25+
"spectrum:clover": 0.5,
26+
"spectrum:four_leaf_clover": 0.5
2627
},
2728
"spawns": [
2829
{

src/main/resources/data/spectrum/starry_skies/configured_sphere/overworld/ores/azurite_ore.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"decorators": {},
2727
"spawns": [],
2828
"generation": {
29-
"weight": 0.3,
29+
"weight": 0.5,
3030
"group": "starry_skies:overworld/ores"
3131
}
3232
}

src/main/resources/data/spectrum/starry_skies/configured_sphere/overworld/ores/deepslate_azurite_ore.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"decorators": {},
2727
"spawns": [],
2828
"generation": {
29-
"weight": 0.5,
29+
"weight": 0.8,
3030
"group": "starry_skies:overworld/ores"
3131
}
3232
}

src/main/resources/data/spectrum/starry_skies/configured_sphere/overworld/ores/deepslate_shimmerstone_ore.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"decorators": {},
2727
"spawns": [],
2828
"generation": {
29-
"weight": 0.5,
29+
"weight": 0.4,
3030
"group": "starry_skies:overworld/ores"
3131
}
3232
}

0 commit comments

Comments
 (0)