Added Backrooms gamemode
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package eu.mhsl.minenet.minigames.instance.game;
|
||||
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.config.GameFactory;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.backrooms.BackroomsFactory;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.bedwars.BedwarsFactory;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.deathcube.DeathcubeFactory;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.minerun.MinerunFactory;
|
||||
@ -14,7 +15,8 @@ public enum GameList {
|
||||
MINERUN(new MinerunFactory(), GameType.PVE),
|
||||
TRAFFICLIGHTRACE(new TrafficLightRaceFactory(), GameType.OTHER),
|
||||
TOWERDEFENSE(new TowerdefenseFactory(), GameType.PVE),
|
||||
BEDWARS(new BedwarsFactory(), GameType.PVP);
|
||||
BEDWARS(new BedwarsFactory(), GameType.PVP),
|
||||
BACKROOMS(new BackroomsFactory(), GameType.PVE);
|
||||
|
||||
private final GameFactory factory;
|
||||
private final GameType type;
|
||||
|
@ -0,0 +1,14 @@
|
||||
package eu.mhsl.minenet.minigames.instance.game.stateless.types.backrooms;
|
||||
|
||||
import eu.mhsl.minenet.minigames.instance.Dimension;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.StatelessGame;
|
||||
|
||||
public class Backrooms extends StatelessGame {
|
||||
public Backrooms() {
|
||||
super(Dimension.NETHER.DIMENSION, "Backrooms");
|
||||
BackroomsGenerator generator = new BackroomsGenerator();
|
||||
setGenerator(unit -> generator.generateRoom(unit, 50));
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package eu.mhsl.minenet.minigames.instance.game.stateless.types.backrooms;
|
||||
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.StatelessGame;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.config.GameFactory;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.config.Option;
|
||||
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class BackroomsFactory implements GameFactory {
|
||||
@Override
|
||||
public TranslatedComponent name() {
|
||||
return TranslatedComponent.byId("gameBackrooms");
|
||||
}
|
||||
|
||||
@Override
|
||||
public StatelessGame manufacture(Map<String, Option<?>> configuration) throws Exception {
|
||||
return new Backrooms();
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package eu.mhsl.minenet.minigames.instance.game.stateless.types.backrooms;
|
||||
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.instance.generator.GenerationUnit;
|
||||
import net.minestom.server.instance.generator.UnitModifier;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class BackroomsGenerator {
|
||||
public void generateRoom(GenerationUnit unit, int y) {
|
||||
var modifier = unit.modifier();
|
||||
var start = unit.absoluteStart();
|
||||
var yPos = start.blockY() + y;
|
||||
|
||||
for (int x = 0; x < unit.size().blockX(); x++) {
|
||||
for (int z = 0; z < unit.size().blockZ(); z++) {
|
||||
var xPos = start.blockX() + x;
|
||||
var zPos = start.blockZ() + z;
|
||||
|
||||
modifier.setBlock(xPos, yPos - 1, zPos, Block.BEDROCK);
|
||||
modifier.setBlock(xPos, yPos + 5, zPos, Block.BEDROCK);
|
||||
|
||||
modifier.setBlock(xPos, yPos, zPos, Block.LIGHT_GRAY_WOOL);
|
||||
modifier.setBlock(xPos, yPos + 4, zPos, Block.SMOOTH_STONE_SLAB);
|
||||
|
||||
// idk man... dont ask about this
|
||||
if (
|
||||
(x - 2) % 4 == 0 && (
|
||||
((z - 2) % 8 == 0) ||
|
||||
((z - 2) % 8 == 1) ||
|
||||
((z - 2) % 8 == 3) ||
|
||||
((z - 2) % 8 == 4)
|
||||
)
|
||||
) {
|
||||
modifier.setBlock(xPos, yPos + 4, zPos, Block.SEA_LANTERN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
generateWalls(modifier, start.blockX() + 0, yPos + 1, start.blockZ() + 0);
|
||||
generateWalls(modifier, start.blockX() + 8, yPos + 1, start.blockZ() + 0);
|
||||
generateWalls(modifier, start.blockX() + 0, yPos + 1, start.blockZ() + 8);
|
||||
generateWalls(modifier, start.blockX() + 8, yPos + 1, start.blockZ() + 8);
|
||||
}
|
||||
|
||||
private void generateWalls(UnitModifier modifier, int xPos, int yPos, int zPos) {
|
||||
generatePillar(modifier, xPos, yPos, zPos, Block.CHISELED_SANDSTONE);
|
||||
|
||||
var random = ThreadLocalRandom.current();
|
||||
|
||||
var wall1 = random.nextInt(4) != 0;
|
||||
var wall2 = random.nextInt(4) != 0;
|
||||
var door1 = random.nextInt(2) != 0;
|
||||
var door2 = random.nextInt(2) != 0;
|
||||
|
||||
var door1pos = random.nextInt(2, 6);
|
||||
var door2pos = random.nextInt(2, 6);
|
||||
|
||||
if (wall1) {
|
||||
for (int x = xPos; x < xPos + 8; x++) {
|
||||
generatePillar(modifier, x, yPos, zPos, Block.SMOOTH_SANDSTONE);
|
||||
}
|
||||
}
|
||||
|
||||
if (wall2) {
|
||||
for (int z = zPos; z < zPos + 8; z++) {
|
||||
generatePillar(modifier, xPos, yPos, z, Block.SMOOTH_SANDSTONE);
|
||||
}
|
||||
}
|
||||
|
||||
if (door1 && wall1) {
|
||||
generatePillar(modifier, xPos + door1pos, yPos, zPos, Block.AIR);
|
||||
generatePillar(modifier, xPos + door1pos + 1, yPos, zPos, Block.AIR);
|
||||
}
|
||||
|
||||
if (door2 && wall2) {
|
||||
generatePillar(modifier, xPos, yPos, zPos + door2pos, Block.AIR);
|
||||
generatePillar(modifier, xPos, yPos, zPos + door2pos + 1, Block.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
private void generatePillar(UnitModifier modifier, int xPos, int yPos, int zPos, Block material) {
|
||||
for (int y = yPos; y < yPos + 3; y++) {
|
||||
modifier.setBlock(xPos, y, zPos, material);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user