WIP: highground
This commit is contained in:
@ -8,6 +8,7 @@ import eu.mhsl.minenet.minigames.instance.game.stateless.types.backrooms.Backroo
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.bedwars.BedwarsFactory;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.acidRain.AcidRainFactory;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.deathcube.DeathcubeFactory;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.highGround.HighGroundFactory;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.jumpDive.JumpDiveFactory;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.minerun.MinerunFactory;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.spleef.SpleefFactory;
|
||||
@ -34,7 +35,8 @@ public enum GameList {
|
||||
ELYTRARACE(new ElytraRaceFactory(), GameType.PVP),
|
||||
SPLEEF(new SpleefFactory(), GameType.PVP),
|
||||
JUMPDIVE(new JumpDiveFactory(), GameType.JUMPNRUN),
|
||||
SUMO(new SumoFactory(), GameType.PVP);
|
||||
SUMO(new SumoFactory(), GameType.PVP),
|
||||
HIGHGROUND(new HighGroundFactory(), GameType.PROTOTYPE);
|
||||
|
||||
private final GameFactory factory;
|
||||
private final GameType type;
|
||||
|
@ -0,0 +1,93 @@
|
||||
package eu.mhsl.minenet.minigames.instance.game.stateless.types.highGround;
|
||||
|
||||
import eu.mhsl.minenet.minigames.instance.Dimension;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.StatelessGame;
|
||||
import eu.mhsl.minenet.minigames.score.PointsWinScore;
|
||||
import eu.mhsl.minenet.minigames.world.BlockPallet;
|
||||
import io.github.togar2.pvp.events.EntityKnockbackEvent;
|
||||
import io.github.togar2.pvp.events.FinalAttackEvent;
|
||||
import io.github.togar2.pvp.events.PrepareAttackEvent;
|
||||
import io.github.togar2.pvp.feature.CombatFeatures;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.player.PlayerMoveEvent;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class HighGround extends StatelessGame {
|
||||
|
||||
int radius = 5;
|
||||
public HighGround() {
|
||||
super(Dimension.THE_END.key, "highground", new PointsWinScore());
|
||||
|
||||
this.eventNode().addChild(
|
||||
CombatFeatures.empty()
|
||||
.add(CombatFeatures.VANILLA_ATTACK)
|
||||
.add(CombatFeatures.VANILLA_DAMAGE)
|
||||
.add(CombatFeatures.VANILLA_KNOCKBACK)
|
||||
.build()
|
||||
.createNode()
|
||||
);
|
||||
|
||||
this.eventNode().addListener(
|
||||
FinalAttackEvent.class,
|
||||
finalAttackEvent -> finalAttackEvent.setBaseDamage(0)
|
||||
);
|
||||
|
||||
this.eventNode().addListener(PrepareAttackEvent.class, prepareAttackEvent -> {
|
||||
if(this.isBeforeBeginning){
|
||||
prepareAttackEvent.setCancelled(true);
|
||||
}
|
||||
});
|
||||
|
||||
this.eventNode().addListener(
|
||||
EntityKnockbackEvent.class,
|
||||
entityKnockbackEvent -> entityKnockbackEvent.setStrength(1.1f)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLoad(@NotNull CompletableFuture<Void> callback) {
|
||||
for (int y = 0; y >= -3; y--) {
|
||||
int radius = (Math.abs(y) * 5) + 5;
|
||||
for (int x = -radius; x <= radius; x++) {
|
||||
for (int z = -radius; z <= radius; z++) {
|
||||
double distance = new Pos(x, 0, z).distance(0, 0, 0);
|
||||
if (distance <= radius) {
|
||||
this.setBlock(x, y, z, y == 0 ? Block.DIAMOND_BLOCK : Block.GRASS_BLOCK);
|
||||
Pos featurePosition = new Pos(x, y + 1, z);
|
||||
|
||||
if(y >= 0 || this.getBlock(featurePosition).isSolid()) continue;
|
||||
if (this.rnd.nextDouble() < 0.1){
|
||||
this.setBlock(featurePosition, Block.SHORT_GRASS);
|
||||
}
|
||||
if (this.rnd.nextDouble() < 0.01){
|
||||
this.setBlock(featurePosition, BlockPallet.FLOWER.rnd());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPlayerMove(@NotNull PlayerMoveEvent playerMoveEvent) {
|
||||
Player player = playerMoveEvent.getPlayer();
|
||||
if(playerMoveEvent.getNewPosition().y() < -10){
|
||||
player.teleport(this.getSpawn());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pos getSpawn() {
|
||||
double theta = this.rnd.nextDouble() * 2 * Math.PI;
|
||||
|
||||
double spawnRadius = this.radius + 5;
|
||||
double x = spawnRadius * Math.cos(theta);
|
||||
double z = spawnRadius * Math.sin(theta);
|
||||
|
||||
return new Pos(x, 0, z).withLookAt(new Pos(0, 0, 0));
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package eu.mhsl.minenet.minigames.instance.game.stateless.types.highGround;
|
||||
|
||||
import eu.mhsl.minenet.minigames.instance.game.Game;
|
||||
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.instance.room.Room;
|
||||
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class HighGroundFactory implements GameFactory {
|
||||
@Override
|
||||
public TranslatedComponent name() {
|
||||
return TranslatedComponent.byId("game_Highground#name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Game manufacture(Room parent, Map<String, Option<?>> configuration) throws Exception {
|
||||
return new HighGround().setParent(parent);
|
||||
}
|
||||
}
|
@ -46,7 +46,8 @@ public class Sumo extends StatelessGame {
|
||||
.add(CombatFeatures.VANILLA_ATTACK)
|
||||
.add(CombatFeatures.VANILLA_DAMAGE)
|
||||
.add(CombatFeatures.VANILLA_KNOCKBACK)
|
||||
.build().createNode()
|
||||
.build()
|
||||
.createNode()
|
||||
);
|
||||
|
||||
this.eventNode().addListener(PrepareAttackEvent.class, prepareAttackEvent -> {
|
||||
|
@ -13,7 +13,10 @@ import java.util.Map;
|
||||
|
||||
public class SumoFactory implements GameFactory {
|
||||
@Override
|
||||
public TranslatedComponent name() {return TranslatedComponent.byId("game_Sumo#name");}
|
||||
public TranslatedComponent name() {
|
||||
return TranslatedComponent.byId("game_Sumo#name");
|
||||
}
|
||||
|
||||
public TranslatedComponent description() {
|
||||
return TranslatedComponent.byId("game_Sumo#description");
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public enum BlockPallet {
|
||||
STONE(new Block[] {Block.CHISELED_STONE_BRICKS, Block.STONE_BRICKS, Block.POLISHED_ANDESITE, Block.POLISHED_BLACKSTONE, Block.POLISHED_DIORITE}),
|
||||
WINTER(new Block[] {Block.SNOW_BLOCK, Block.ICE, Block.PACKED_ICE, Block.BLUE_CONCRETE, Block.SEA_LANTERN}),
|
||||
STREET(new Block[] {Block.BLACK_CONCRETE_POWDER, Block.GRAY_CONCRETE_POWDER, Block.GRAVEL, Block.BLACK_CONCRETE, Block.GRAY_CONCRETE}),
|
||||
|
||||
FLOWER(new Block[] {Block.ORANGE_TULIP, Block.PINK_TULIP, Block.RED_TULIP, Block.WHITE_TULIP}),
|
||||
PRESSURE_PLATES(new Block[] {Block.ACACIA_PRESSURE_PLATE, Block.BIRCH_PRESSURE_PLATE, Block.CRIMSON_PRESSURE_PLATE, Block.JUNGLE_PRESSURE_PLATE, Block.OAK_PRESSURE_PLATE, Block.DARK_OAK_PRESSURE_PLATE, Block.HEAVY_WEIGHTED_PRESSURE_PLATE, Block.HEAVY_WEIGHTED_PRESSURE_PLATE, Block.POLISHED_BLACKSTONE_PRESSURE_PLATE, Block.SPRUCE_PRESSURE_PLATE, Block.STONE_PRESSURE_PLATE, Block.WARPED_PRESSURE_PLATE});
|
||||
|
||||
final List<Block> list;
|
||||
|
Reference in New Issue
Block a user