added basic obstacle mechanic
This commit is contained in:
+2
-2
@@ -13,11 +13,11 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
public class PlayerRace extends StatelessGame {
|
public class PlayerRace extends StatelessGame {
|
||||||
public PlayerRace() {
|
public PlayerRace() {
|
||||||
super(Dimension.THE_END.key, "PlayerRace", new LastWinsScore());
|
super(Dimension.THE_END.key, "PlayerRace", new LastWinsScore());
|
||||||
|
this.setGenerator(new PlayerRaceChunkgenerator(64));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onLoad(@NotNull CompletableFuture<Void> callback) {
|
protected void onLoad(@NotNull CompletableFuture<Void> callback) {
|
||||||
AbsoluteBlockBatch batch = new AbsoluteBlockBatch();
|
|
||||||
this.setBlock(0, 100, 0, Block.AMETHYST_BLOCK);
|
this.setBlock(0, 100, 0, Block.AMETHYST_BLOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,4 +26,4 @@ public class PlayerRace extends StatelessGame {
|
|||||||
return new Pos(0.5, 101.5, 0.5);
|
return new Pos(0.5, 101.5, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+46
@@ -0,0 +1,46 @@
|
|||||||
|
package eu.mhsl.minenet.minigames.instance.game.stateless.types.playerRace;
|
||||||
|
|
||||||
|
import eu.mhsl.minenet.minigames.instance.game.stateless.types.playerRace.obstacles.Obstacle;
|
||||||
|
import eu.mhsl.minenet.minigames.world.BlockPallet;
|
||||||
|
import eu.mhsl.minenet.minigames.world.generator.featureEnriched.ValeGenerator;
|
||||||
|
import eu.mhsl.minenet.minigames.world.generator.terrain.BaseGenerator;
|
||||||
|
import net.minestom.server.coordinate.Point;
|
||||||
|
import net.minestom.server.instance.block.Block;
|
||||||
|
|
||||||
|
public class PlayerRaceChunkgenerator extends BaseGenerator {
|
||||||
|
public PlayerRaceChunkgenerator(int height) {
|
||||||
|
ValeGenerator vale = new ValeGenerator();
|
||||||
|
vale.setXShiftMultiplier(integer -> 0.5d);
|
||||||
|
vale.setHeightNoiseMultiplier(integer -> 2);
|
||||||
|
this.addMixIn(vale);
|
||||||
|
|
||||||
|
this.addMixIn(unit -> {
|
||||||
|
if (
|
||||||
|
unit.absoluteStart().chunkX() != 0 ||
|
||||||
|
unit.absoluteStart().chunkZ() < 0 ||
|
||||||
|
unit.absoluteStart().chunkZ() > 16
|
||||||
|
) return;
|
||||||
|
|
||||||
|
Point start = unit.absoluteStart();
|
||||||
|
|
||||||
|
for(int x = 0; x <= 15; x++) {
|
||||||
|
for(int z = 0; z <= 15; z++) {
|
||||||
|
Point blockPosition = start.add(x, height, z);
|
||||||
|
if(unit.absoluteStart().chunkZ() == 0) {
|
||||||
|
unit.modifier().setBlock(blockPosition, Block.AMETHYST_BLOCK);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(unit.absoluteStart().chunkZ() == 16) {
|
||||||
|
unit.modifier().setBlock(blockPosition, Block.DIAMOND_BLOCK);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(unit.absoluteStart().chunkZ() % 2 == 1) {
|
||||||
|
Obstacle.getRandomObstacle().generate(unit, blockPosition);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
unit.modifier().setBlock(blockPosition, BlockPallet.GROUND.rnd());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
package eu.mhsl.minenet.minigames.instance.game.stateless.types.playerRace.obstacles;
|
||||||
|
|
||||||
|
import de.articdive.jnoise.JNoise;
|
||||||
|
import eu.mhsl.minenet.minigames.util.GeneratorUtils;
|
||||||
|
import net.minestom.server.coordinate.Point;
|
||||||
|
import net.minestom.server.instance.block.Block;
|
||||||
|
import net.minestom.server.instance.generator.GenerationUnit;
|
||||||
|
|
||||||
|
class Mudpit extends Obstacle {
|
||||||
|
private final JNoise curves = JNoise.newBuilder()
|
||||||
|
.fastSimplex()
|
||||||
|
.setFrequency(0.1)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generate(GenerationUnit unit, Point start) {
|
||||||
|
GeneratorUtils.foreachXZ(unit, point -> {
|
||||||
|
int modifier = point.blockX()/16 * -3;
|
||||||
|
double heightAtBlock = this.curves.getNoise(point.blockX(), point.blockY(), point.blockZ()) * modifier;
|
||||||
|
unit.modifier().setBlock(point.withY(v -> heightAtBlock), Block.SOUL_SAND);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
package eu.mhsl.minenet.minigames.instance.game.stateless.types.playerRace.obstacles;
|
||||||
|
|
||||||
|
import net.minestom.server.coordinate.Point;
|
||||||
|
import net.minestom.server.instance.generator.GenerationUnit;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
|
public abstract class Obstacle {
|
||||||
|
@SuppressWarnings("StaticInitializerReferencesSubClass")
|
||||||
|
private static final List<Obstacle> obstacles = List.of(new Mudpit());
|
||||||
|
|
||||||
|
public abstract void generate(GenerationUnit unit, Point start);
|
||||||
|
|
||||||
|
public static Obstacle getRandomObstacle() {
|
||||||
|
return obstacles.get(ThreadLocalRandom.current().nextInt(obstacles.size()));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user