Skip to content

Commit

Permalink
Moved world gen to TerrainAPI (new required dependency).
Browse files Browse the repository at this point in the history
New world gen:
- At approx. Y<=64 underground, smaller signalum meteorites now spawn somewhat commonly.
  • Loading branch information
MartinSVK12 committed Jan 24, 2024
1 parent ca5a557 commit 6e42d53
Show file tree
Hide file tree
Showing 10 changed files with 179 additions and 70 deletions.
15 changes: 12 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ repositories {
}
metadataSources { artifact() }
}
ivy {
url = "https://github.com/UselessBullets"
patternLayout {
artifact "[organisation]/releases/download/r[revision]/[module]-[revision].jar"
m2compatible = true
}
metadataSources { artifact() }
}
}

dependencies {
Expand All @@ -119,16 +127,17 @@ dependencies {
// If you do not need Halplibe you can comment this line out or delete this line
modImplementation "bta-halplibe:halplibe:${project.halplibe_version}"

modImplementation "ModMenu:ModMenu:2.0.3"
modImplementation "ModMenu:ModMenu:${project.modmenu_version}"

implementation project(path: ":catalyst",configuration: "namedElements")
implementation project(path: ":catalyst:energy",configuration: "namedElements")
implementation project(path: ":catalyst:fluids",configuration: "namedElements")
implementation project(path: ":catalyst:multiblocks",configuration: "namedElements")
implementation project(path: ":catalyst:effects",configuration: "namedElements")

modImplementation "DragonFly:dragonfly:1.4.1-7.1"
modImplementation "BTWaila:btwaila:1.0.7-7.1"
modImplementation "DragonFly:dragonfly:${project.dragonfly_version}"
modImplementation "BTWaila:btwaila:${project.btwaila_version}"
modImplementation "TerrainAPI:terrainapi:${project.terrain_api_version}"

implementation "org.slf4j:slf4j-api:1.8.0-beta4"
implementation "org.apache.logging.log4j:log4j-slf4j18-impl:2.16.0"
Expand Down
6 changes: 5 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ bta_version=7.1-pre1a
# Loader
loader_version=0.14.19-babric.3-bta

# HalpLibe
# Mods
halplibe_version=3.3.3
modmenu_version=2.0.3
dragonfly_version=1.4.1-7.1
btwaila_version=1.0.7-7.1
terrain_api_version=1.4.2-7.1

# Mod
mod_version=0.3.0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package sunsetsatellite.signalindustries.api.impl.terrainapi;

import sunsetsatellite.signalindustries.SignalIndustries;
import useless.terrainapi.api.TerrainAPI;

public class TerrainAPISignalIndustriesPlugin implements TerrainAPI {
@Override
public String getModID() {
return SignalIndustries.MOD_ID;
}

@Override
public void onInitialize() {
new WorldGenSI().init();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package sunsetsatellite.signalindustries.api.impl.terrainapi;

import net.minecraft.core.block.Block;
import net.minecraft.core.world.chunk.ChunkCoordinates;
import sunsetsatellite.signalindustries.SignalIndustries;
import sunsetsatellite.signalindustries.worldgen.WorldFeatureGeode;
import sunsetsatellite.signalindustries.worldgen.WorldFeatureMeteor;
import sunsetsatellite.signalindustries.worldgen.WorldFeatureObelisk;
import useless.terrainapi.generation.overworld.OverworldFunctions;
import useless.terrainapi.initialization.BaseInitialization;
import useless.terrainapi.initialization.worldtypes.OverworldInitialization;

public class WorldGenSI extends BaseInitialization {
@Override
protected void initValues() {

}

@Override
protected void initStructure() {

}

@Override
protected void initOre() {

}

@Override
protected void initRandom() {
OverworldInitialization.randomFeatures.addFeatureSurface(new WorldFeatureMeteor(Block.oreIronBasalt.id,0,25),512);
OverworldInitialization.randomFeatures.addFeatureSurface(new WorldFeatureMeteor(SignalIndustries.signalumOre.id,0,15),1024);
OverworldInitialization.randomFeatures.addFeatureSurface(new WorldFeatureMeteor(SignalIndustries.dilithiumOre.id,0,3),2048);
OverworldInitialization.randomFeatures.addFeatureSurface(new WorldFeatureObelisk(),4096);
OverworldInitialization.randomFeatures.addFeature(
(x) -> new WorldFeatureGeode(SignalIndustries.signalumOre.id,0,10,3),
null,
OverworldFunctions::getStandardBiomesDensity,
new Object[]{1, null},
32,
0.10f,
0.25f
);
}

@Override
protected void initBiome() {

}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package sunsetsatellite.signalindustries.worldgen;


import net.minecraft.core.block.Block;
import net.minecraft.core.lang.I18n;
import net.minecraft.core.world.World;
import net.minecraft.core.world.generate.feature.WorldFeature;
import sunsetsatellite.signalindustries.SignalIndustries;
import sunsetsatellite.signalindustries.entities.ExplosionNoDrops;

import java.util.Random;

public class WorldFeatureGeode extends WorldFeature {

public int oreId;
public int oreMeta;
public int oreChance;
public int radius = 4;

public WorldFeatureGeode(int oreId, int oreMeta, int oreChance){
this.oreId = oreId;
this.oreMeta = oreMeta;
this.oreChance = oreChance;
}

public WorldFeatureGeode(int oreId, int oreMeta, int oreChance, int radius){
this.oreId = oreId;
this.oreMeta = oreMeta;
this.oreChance = oreChance;
this.radius = radius;
}
@Override
public boolean generate(World world, Random random, int i, int j, int k) {
SignalIndustries.LOGGER.info(String.format("%s Geode at X:%d Y:%d Z:%d", I18n.getInstance().translateNameKey(Block.blocksList[oreId].getLanguageKey(oreMeta)),i,j,k));
int oreBlocks = 0;

int radius1 = radius+1;

for(int x = -radius1+1; x <= radius1; ++x) {
for (int y = -radius1; y <= radius1; ++y) {
for (int z = -radius1; z <= radius1; ++z) {
if (isPointInsideSphere(x, y, z, radius1)) {
world.setBlockAndMetadataWithNotify(x+i, (y+j)-8, z+k, 0, 0);
}
}
}
}

for(int x = -radius; x <= radius; ++x) {
for(int y = -radius; y <= radius; ++y) {
for(int z = -radius; z <= radius; ++z) {
if (isPointInsideSphere(x, y, z, radius)) {
if (oreId != 0 && random.nextInt(100) < oreChance){
world.setBlockAndMetadataWithNotify(x+i, (y+j)-8, z+k, oreId, oreMeta);
oreBlocks++;
} else {
world.setBlockAndMetadataWithNotify(x+i, (y+j)-8, z+k, Block.basalt.id, 0);
}
}
}
}
}

//SignalIndustries.LOGGER.info("Meteor contains "+oreBlocks+" ore.");
return true;
}

public boolean isPointInsideSphere(int x, int y, int z, double radius) {
return x*x + y*y + z*z < radius*radius;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@


import net.minecraft.core.block.Block;
import net.minecraft.core.lang.I18n;
import net.minecraft.core.world.World;
import net.minecraft.core.world.chunk.ChunkCoordinates;
import net.minecraft.core.world.generate.feature.WorldFeature;
import sunsetsatellite.signalindustries.SignalIndustries;
import sunsetsatellite.signalindustries.entities.ExplosionNoDrops;

import java.util.Random;
Expand All @@ -13,26 +16,32 @@ public class WorldFeatureMeteor extends WorldFeature {
public int oreId;
public int oreMeta;
public int oreChance;
public int radius = 4;

public WorldFeatureMeteor(int oreId, int oreMeta, int oreChance){
this.oreId = oreId;
this.oreMeta = oreMeta;
this.oreChance = oreChance;
}

public WorldFeatureMeteor(int oreId, int oreMeta, int oreChance, int radius){
this.oreId = oreId;
this.oreMeta = oreMeta;
this.oreChance = oreChance;
this.radius = radius;
}
@Override
public boolean generate(World world, Random random, int i, int j, int k) {
SignalIndustries.LOGGER.info(String.format("%s Meteor fell at X:%d Y:%d Z:%d", I18n.getInstance().translateNameKey(Block.blocksList[oreId].getLanguageKey(oreMeta)),i,j,k));
ExplosionNoDrops ex = new ExplosionNoDrops(world,null,i,j,k,50f);
ex.doExplosionA();
ex.doExplosionB(false);
//world.setBlockWithNotify(i,j,k, Block.bedrock.id);

int radius = 4;
int blockRadius = 4;
int oreBlocks = 0;

for(int x = -blockRadius; x <= blockRadius; ++x) {
for(int y = -blockRadius; y <= blockRadius; ++y) {
for(int z = -blockRadius; z <= blockRadius; ++z) {
for(int x = -radius; x <= radius; ++x) {
for(int y = -radius; y <= radius; ++y) {
for(int z = -radius; z <= radius; ++z) {
if (isPointInsideSphere(x, y, z, radius)) {
if (oreId != 0 && random.nextInt(100) < oreChance){
world.setBlockAndMetadataWithNotify(x+i, (y+j)-8, z+k, oreId, oreMeta);
Expand All @@ -45,6 +54,7 @@ public boolean generate(World world, Random random, int i, int j, int k) {
}
}

SignalIndustries.meteorLocations.add(new ChunkCoordinates(i,j,k));
//SignalIndustries.LOGGER.info("Meteor contains "+oreBlocks+" ore.");
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@
import java.util.Random;

public class WorldFeatureObelisk extends WorldFeature {

public WorldFeatureObelisk() {
}

@Override
public boolean generate(World world, Random random, int i, int j, int k) {
SignalIndustries.LOGGER.info(String.format("Obelisk at X:%d Y:%d Z:%d",i,j,k));
int l = 8;
if (j >= 1 && j + l + 1 <= world.getHeightBlocks()) {
for (int x = -4; x <= 4; x++) {
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
],
"btwaila": [
"sunsetsatellite.signalindustries.api.impl.btwaila.BTWailaSIPlugin"
],
"terrain-api": [
"sunsetsatellite.signalindustries.api.impl.terrainapi.TerrainAPISignalIndustriesPlugin"
]
},
"mixins": [
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/signalindustries.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"AchievementMixin",
"BlockFluidMixin",
"BlockRailMixin",
"ChunkDecoratorOverworldMixin",
"EntityArrowMixin",
"EntityLivingMixin",
"EntityMinecartMixin",
Expand Down

0 comments on commit 6e42d53

Please sign in to comment.