Skip to content

Commit

Permalink
Merge pull request #11 from encryptionstudio/added-megalophobia-to-le…
Browse files Browse the repository at this point in the history
…vel-0

Added megalophobia to level 0, rnamed LevelTwoBiomeSource to Level2BiomeSource and use newer depency versions
  • Loading branch information
encrystudio authored Apr 14, 2024
2 parents fb38390 + 616e8ad commit 59e055a
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 22 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ dependencies {
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation "io.github.ladysnake:satin:${satin_version}"
modImplementation 'software.bernie.geckolib:geckolib-fabric-1.18:3.0.51'
modImplementation "software.bernie.geckolib:geckolib-fabric-1.18:${geckolib_version}"


modApi "com.terraformersmc:modmenu:${project.modmenu_version}"

modImplementation "me.shedaniel.cloth:cloth-config-fabric:${project.config_version}"
modImplementation "me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}"
modImplementation "com.github.LudoCrypt:Liminal-Library:${project.limlib_version}"

modImplementation "dev.onyxstudios.cardinal-components-api:cardinal-components-base:4.1.4"
modImplementation "dev.onyxstudios.cardinal-components-api:cardinal-components-entity:4.1.4"
modImplementation "dev.onyxstudios.cardinal-components-api:cardinal-components-base:${project.cardinal_components_version}"
modImplementation "dev.onyxstudios.cardinal-components-api:cardinal-components-entity:${project.cardinal_components_version}"

include "com.github.LudoCrypt:Liminal-Library:${project.limlib_version}"
// Includes Cardinal Components API as a Jar-in-Jar dependency (optional)
Expand Down
20 changes: 11 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@ org.gradle.jvmargs=-Xmx4G
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.18.2
yarn_mappings=1.18.2+build.3
loader_version=0.14.6
config_version=6.2.57
yarn_mappings=1.18.2+build.4
loader_version=0.15.7
# Mod Depencies
cloth_config_version=6.5.116
modmenu_version=3.2.5
satin_version=1.7.2
limlib_version=5.2.1
cardinal_components_version=4.1.4
# Mod Properties
mod_version = 0.6.10
maven_group = net.synchlabs
cardinal_components_version=4.2.0
geckolib_version=3.0.80
# Mod Properties
mod_version = 0.6.10
maven_group = net.synchlabs

archives_base_name = the-backrooms
archives_base_name = the-backrooms

# Dependencies
fabric_version=0.57.0+1.18.2
fabric_version=0.77.0+1.18.2
4 changes: 2 additions & 2 deletions src/main/java/com/kpabr/backrooms/init/BackroomsLevels.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class BackroomsLevels {

public static final LiminalWorld LEVEL_0 = addLevel("level_0", LevelZeroChunkGenerator.class, Level0BiomeSource.class);
public static final LiminalWorld LEVEL_1 = addLevel("level_1", LevelOneChunkGenerator.class, Level1BiomeSource.class);
public static final LiminalWorld LEVEL_2 = addLevel("level_2", LevelTwoChunkGenerator.class, LevelTwoBiomeSource.class);
public static final LiminalWorld LEVEL_2 = addLevel("level_2", LevelTwoChunkGenerator.class, Level2BiomeSource.class);
public static final LiminalWorld LEVEL_3 = addLevel("level_3", LevelThreeChunkGenerator.class, Level3BiomeSource.class);


Expand All @@ -55,7 +55,7 @@ public class BackroomsLevels {
public static void init() {
Registry.register(Registry.BIOME_SOURCE, "level_0_biome_source", Level0BiomeSource.CODEC);
Registry.register(Registry.BIOME_SOURCE, "level_1_biome_source", Level1BiomeSource.CODEC);
Registry.register(Registry.BIOME_SOURCE, "level_2_biome_source", LevelTwoBiomeSource.CODEC);
Registry.register(Registry.BIOME_SOURCE, "level_2_biome_source", Level2BiomeSource.CODEC);
Registry.register(Registry.BIOME_SOURCE, "level_3_biome_source", Level3BiomeSource.CODEC);
get("level_0_chunk_generator", LevelZeroChunkGenerator.CODEC);
get("level_1_chunk_generator", LevelOneChunkGenerator.CODEC);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public Level0BiomeSource(Registry<Biome> biomeRegistry, long seed) {
super(biomeRegistry, seed, new BiomeListBuilder()
.addBiome(BackroomsLevels.CRIMSON_WALLS_BIOME, 0.3)
.addBiome(BackroomsLevels.DECREPIT_BIOME, 0.4)
.addBiome(BackroomsLevels.MEGALOPHOBIA_BIOME, 0.3)
.addBiome(BackroomsLevels.LEVEL_ZERO_NORMAL_BIOME, BiomeRegistryList.DEFAULT_CHANCE_VALUE)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@

import java.util.stream.Stream;

public class LevelTwoBiomeSource extends BiomeSource {
public static final Codec<LevelTwoBiomeSource> CODEC = RecordCodecBuilder.create((instance) ->
public class Level2BiomeSource extends BiomeSource {
public static final Codec<Level2BiomeSource> CODEC = RecordCodecBuilder.create((instance) ->
instance.group(
RegistryOps.createRegistryCodec(Registry.BIOME_KEY)
.forGetter((biomeSource) -> biomeSource.BIOME_REGISTRY),
Codec.LONG.fieldOf("seed")
.stable()
.forGetter((biomeSource) -> biomeSource.seed)
).apply(instance, instance.stable(LevelTwoBiomeSource::new)));
).apply(instance, instance.stable(Level2BiomeSource::new)));


private final long seed;
protected Registry<Biome> BIOME_REGISTRY;
private final RegistryEntry<Biome> PIPES_BIOME;

public LevelTwoBiomeSource(Registry<Biome> registry, long seed) {
public Level2BiomeSource(Registry<Biome> registry, long seed) {
super(Stream.of(
registry.getOrCreateEntry(BackroomsLevels.PIPES_BIOME)));
PIPES_BIOME = registry.getOrCreateEntry(BackroomsLevels.PIPES_BIOME);
Expand All @@ -40,11 +40,11 @@ public RegistryEntry<Biome> getBiome(int x, int y, int z, MultiNoiseUtil.MultiNo
}

public BiomeSource withSeed(long seed) {
return new LevelTwoBiomeSource(BIOME_REGISTRY, seed);
return new Level2BiomeSource(BIOME_REGISTRY, seed);
}

@Override
protected Codec<LevelTwoBiomeSource> getCodec() {
protected Codec<Level2BiomeSource> getCodec() {
return CODEC;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,137 @@ public CompletableFuture<Chunk> populateNoise(ChunkRegion region, ChunkStatus ta
// BackroomsBlocks.MOLDY_WOOLEN_CARPET -> random blocks(you can just replace them with carpet)

final ChunkPos chunkPos = chunk.getPos();
final BlockPos biomePos = chunkPos.getBlockPos(4, 4, 4);
//Save the starting x and z position of the chunk. Note: positive x means east, positive z means south.
final int startX = chunkPos.getStartX();
final int startZ = chunkPos.getStartZ();

if (isBiomeEquals(BackroomsLevels.MEGALOPHOBIA_BIOME, chunk, biomePos)) {
//Create 3 floors, top to bottom, because one Megalophobia floor equals 6 normal floors.
for (int y = 2; y >= 0; y--) {
//Create 16 smaller sections of the floor, layed out in a 4x4 pattern. Each section will consist of the carpeting, the ceiling, two walls (located on the eastern and southern side of the section) and a pillar, located in the southeasternmost space.
for (int x = 1; x >= 0; x--) {
for (int z = 1; z >= 0; z--) {
//Make a Random object controlling the generation of the section.
final Random random = new Random(region.getSeed() + MathHelper.hashCode(startX, startZ, x + 4 * z + 20 * y));
//Decide the arrangement of the walls of the section. The two numbers with an F directly after them denote the probability of an eastern wall and a southern wall generating, respectively.
final int wallType = (random.nextFloat() < 0.4F ? 1 : 0) + (random.nextFloat() < 0.4F ? 2 : 0);

//Check if the arrangement includes the eastern wall.
// and create eastern wall if true
if ((wallType & 1) == 1) {
for(int i = 0; i < 7; i++){
for(int j = 0; j < 10; j++) {
for(int k = 0; k < 2; k++){
region.setBlockState(
new BlockPos(startX + x * 8 + 6 + k, 2 + 12 * y + j, startZ + z * 8 + i),
BackroomsBlocks.PATTERNED_WALLPAPER.getDefaultState(),
Block.FORCE_STATE,
0);
}
}
}
}
// Check if the arrangement includes the southern wall
// and create southern wall if true
if ((wallType & 2) == 2) {
for(int i = 0; i < 7; i++){
for(int j = 0; j < 10; j++){
for(int k = 0; k < 2; k++){
region.setBlockState(
new BlockPos(startX + x * 8 + i, 2 + 12 * y + j, startZ + z * 8 + 6 + k),
BackroomsBlocks.PATTERNED_WALLPAPER.getDefaultState(),
Block.FORCE_STATE,
0);
}
}
}
}
// New variable controlling whether a pillar in generated.
// If there's a wall in the current section, always create a pillar.
boolean pillar = wallType != 0;

//If you're on the southeasternmost spot on the chunk, always make a pillar.
pillar = pillar || (x == 1 && z == 1);

// Check if you're not on the eastern edge of the chunk. If you aren't, proceed.
// Check one block east whether there's a wall there. If so, a pillar will always be generated.
if(x != 1) {
pillar = pillar ||
!region.getBlockState(new BlockPos(startX + x * 8 + 8, 2 + 12 * y, startZ + z * 8 + 7)).isAir();
}
// Check if you're not on the southern edge of the chunk. If you aren't, proceed.
if(z != 1) {
// Check one block south whether there's a wall there. If so, a pillar will always be generated.
pillar = pillar || !region.getBlockState(new BlockPos(startX + x * 8 + 7, 2 + 12 * y, startZ + z * 8 + 8)).isAir();
}
pillar = pillar || (random.nextFloat() < 0.2F); //Sometimes generate a pillar anyways, even if none of the previous conditions were met.
if (pillar) {
//Create the pillar.
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 2; j++) {
for (int k = 0; k < 2; k++) {
region.setBlockState(new BlockPos(startX + x * 8 + 6 + j, 2 + 12 * y + i, startZ + z * 8 + 6 + k), BackroomsBlocks.PATTERNED_WALLPAPER.getDefaultState(), Block.FORCE_STATE, 0);
}
}
}
}
// Generate the carpeting and the ceiling.
for(int i = 0; i < 8; i++) {
for(int j = 0; j < 8; j++){
region.setBlockState(new BlockPos(startX + x * 8 + i, 1 + 12 * y, startZ + z * 8 + j), BackroomsBlocks.WOOLEN_CARPET.getDefaultState(), Block.FORCE_STATE, 0);
region.setBlockState(new BlockPos(startX + x * 8 + i, 12 + 12 * y, startZ + z * 8 + j), BackroomsBlocks.CORK_TILE.getDefaultState(), Block.FORCE_STATE, 0);
}
}
//Place a ceiling light.
region.setBlockState(new BlockPos(startX + x * 8 + 2, 12 + 12 * y, startZ + z * 8 + 2), BackroomsBlocks.FLUORESCENT_LIGHT.getDefaultState(), Block.FORCE_STATE, 0);
region.setBlockState(new BlockPos(startX + x * 8 + 2, 12 + 12 * y, startZ + z * 8 + 3), BackroomsBlocks.FLUORESCENT_LIGHT.getDefaultState(), Block.FORCE_STATE, 0);
region.setBlockState(new BlockPos(startX + x * 8 + 3, 12 + 12 * y, startZ + z * 8 + 2), BackroomsBlocks.FLUORESCENT_LIGHT.getDefaultState(), Block.FORCE_STATE, 0);
region.setBlockState(new BlockPos(startX + x * 8 + 3, 12 + 12 * y, startZ + z * 8 + 3), BackroomsBlocks.FLUORESCENT_LIGHT.getDefaultState(), Block.FORCE_STATE, 0);
}
}
}

//Mold placement code; will be subject to heavy revisions, so ignore for now.
for (int y = getFloorCount(); y >= 0; y--) {
final Random fullFloorRandom = new Random(region.getSeed()
+ MathHelper.hashCode(chunk.getPos().getStartX(), chunk.getPos().getStartZ(), y));

for(int i = 0 ; i < 300; i++){
final int x = fullFloorRandom.nextInt(16);
final int z = fullFloorRandom.nextInt(16);
int x2 = x + fullFloorRandom.nextInt(3) - 1;
int z2 = fullFloorRandom.nextInt(3) - 1;
if(region.getBlockState(new BlockPos(startX + x, 1 + 12 * y, startZ + z))
== BackroomsBlocks.WOOLEN_CARPET.getDefaultState()){
if(x2 < 0) x2=0;
else if(x2 > 15) x2=15;
if(z2 < 0) z2=0;
else if(z2 > 15) z2=15;
if(fullFloorRandom.nextFloat() < 0.1F || region.getBlockState(new BlockPos(startX + x2, 1 + 12 * y, startZ + z2)) == BackroomsBlocks.CORK_TILE.getDefaultState()) {
region.setBlockState(
new BlockPos(startX + x, 1 + 12 * y, startZ + z),
BackroomsBlocks.MOLDY_WOOLEN_CARPET.getDefaultState(),
Block.FORCE_STATE,
0);
}
}
}
}
// Place bedrock bricks at the bottom.
for (int x = startX; x < startX + 16; x++) {
for (int z = startZ; z < startZ + 16; z++) {
region.setBlockState(new BlockPos(x, 0, z), ROOF_BLOCK, Block.FORCE_STATE, 0);
}
}
// Place bedrock bricks at the roof of chunk
for (int x = startX; x < startX + 16; x++) {
for (int z = startZ; z < startZ + 16; z++) {
region.setBlockState(new BlockPos(x, ROOF_BEGIN_Y, z), ROOF_BLOCK, Block.FORCE_STATE, 0);
}
}
return CompletableFuture.completedFuture(chunk);
} else {
//Create 5 floors, top to bottom.
for (int y = getFloorCount(); y >= 0; y--) {
//Create 16 smaller sections of the floor, layed out in a 4x4 pattern. Each section will consist of the carpeting, the ceiling, two walls (located on the eastern and southern side of the section) and a pillar, located in the southeasternmost space.
Expand Down Expand Up @@ -270,7 +397,7 @@ public CompletableFuture<Chunk> populateNoise(ChunkRegion region, ChunkStatus ta
region.setBlockState(new BlockPos(x, ROOF_BEGIN_Y, z), ROOF_BLOCK, Block.FORCE_STATE, 0);
}
}
return CompletableFuture.completedFuture(chunk);
return CompletableFuture.completedFuture(chunk);}
}

public static int getFloorCount() {
Expand Down

0 comments on commit 59e055a

Please sign in to comment.