Skip to content

Commit

Permalink
Undeprecated mazes
Browse files Browse the repository at this point in the history
  • Loading branch information
LudoCrypt committed May 13, 2022
1 parent bb18326 commit 77f73f8
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ loader_version=0.13.3
fabric_version=0.47.10+1.18.2
satin_version=1.7.2

mod_version = 5.1.3
mod_version = 5.1.4
maven_group = net.ludocrypt
archives_base_name = limlib
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package net.ludocrypt.limlib.api.world.maze.deprecated;
package net.ludocrypt.limlib.api.world.maze;

import java.util.List;
import java.util.Random;
import java.util.Stack;

import com.google.common.collect.Lists;

@Deprecated
public class DepthFirstMaze extends MazeComponent {

public Stack<Vec2i> stack = new Stack<Vec2i>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.ludocrypt.limlib.api.world.maze.deprecated;
package net.ludocrypt.limlib.api.world.maze;

@Deprecated
public abstract class MazeComponent {

public final int width;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package net.ludocrypt.limlib.api.world.maze.deprecated;
package net.ludocrypt.limlib.api.world.maze;

import java.util.HashMap;
import java.util.Random;
import java.util.function.Function;

import com.mojang.serialization.Codec;

import net.ludocrypt.limlib.api.world.maze.deprecated.MazeComponent.CellState;
import net.ludocrypt.limlib.api.world.maze.MazeComponent.CellState;
import net.ludocrypt.limlib.impl.LimlibRegistries;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.ChunkRegion;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.gen.chunk.ChunkGenerator;

@Deprecated
public abstract class MazeGenerator {

public static final Codec<MazeGenerator> CODEC = LimlibRegistries.LIMINAL_MAZE_GENERATOR.getCodec().dispatchStable(MazeGenerator::getCodec, Function.identity());
Expand All @@ -33,7 +33,7 @@ public MazeGenerator(int width, int height, int thickness, boolean redundancy, l
this.seedModifier = seedModifier;
}

public void generateMaze(BlockPos pos, Chunk chunk, ChunkRegion region) {
public <T extends ChunkGenerator> void generateMaze(BlockPos pos, Chunk chunk, ChunkRegion region, T chunkGenerator) {
if (thickness < 1)
throw new UnsupportedOperationException("Thickness can not be less than 1");

Expand All @@ -47,7 +47,7 @@ public void generateMaze(BlockPos pos, Chunk chunk, ChunkRegion region) {
if (this.mazes.containsKey(mazePos)) {
maze = this.mazes.get(mazePos);
} else {
maze = this.newMaze(region, chunk, redundancy ? width + 4 : width, redundancy ? height + 4 : height, new Random(blockSeed(mazePos.getX(), mazePos.getZ(), seedModifier)));
maze = this.newMaze(region, chunk, redundancy ? width + 4 : width, redundancy ? height + 4 : height, new Random(blockSeed(mazePos.getX(), mazePos.getZ(), seedModifier)), chunkGenerator);
this.mazes.put(mazePos, maze);
}

Expand All @@ -63,15 +63,15 @@ public void generateMaze(BlockPos pos, Chunk chunk, ChunkRegion region) {

CellState originCell = maze.cellState(redundancy ? mazeX + 2 : mazeX, redundancy ? mazeY + 2 : mazeX);

this.decorateCell(inPos, originPos, chunk, region, originCell, isOpenCell, isWallCell, isTopCell, isSideCell, thickness);
this.decorateCell(inPos, originPos, chunk, region, chunkGenerator, originCell, isOpenCell, isWallCell, isTopCell, isSideCell, thickness);
}
}
}
}

public abstract MazeComponent newMaze(ChunkRegion region, Chunk chunk, int width, int height, Random random);
public abstract <T extends ChunkGenerator> MazeComponent newMaze(ChunkRegion region, Chunk chunk, int width, int height, Random random, T chunkGenerator);

public abstract void decorateCell(BlockPos pos, BlockPos origin, Chunk chunk, ChunkRegion region, CellState state, boolean isOpen, boolean isWall, boolean isTopCell, boolean isSideCell, int thickness);
public abstract <T extends ChunkGenerator> void decorateCell(BlockPos pos, BlockPos origin, Chunk chunk, ChunkRegion region, T chunkGenerator, CellState state, boolean isOpen, boolean isWall, boolean isTopCell, boolean isSideCell, int thickness);

public abstract Codec<? extends MazeGenerator> getCodec();

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/ludocrypt/limlib/impl/LimlibRegistries.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import net.ludocrypt.limlib.api.render.LiminalBaseEffects;
import net.ludocrypt.limlib.api.render.LiminalShaderApplier;
import net.ludocrypt.limlib.api.render.LiminalSkyRenderer;
import net.ludocrypt.limlib.api.world.maze.deprecated.MazeGenerator;
import net.ludocrypt.limlib.api.world.maze.MazeGenerator;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.SimpleRegistry;

@SuppressWarnings({ "unchecked", "deprecation" })
@SuppressWarnings("unchecked")
public class LimlibRegistries {

public static final SimpleRegistry<LiminalWorld> LIMINAL_WORLD = FabricRegistryBuilder.createSimple(LiminalWorld.class, new Identifier("limlib", "limlib_world")).attribute(RegistryAttribute.SYNCED).buildAndRegister();
Expand Down

0 comments on commit 77f73f8

Please sign in to comment.