Skip to content

Commit

Permalink
Port to latest plasmid
Browse files Browse the repository at this point in the history
  • Loading branch information
thecatcore committed Aug 11, 2020
1 parent 9cf4ac4 commit 2cd197f
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 35 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dependencies {
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

// Plasmid
modImplementation "xyz.nucleoid:plasmid:0.1.0+build.42"
modImplementation "xyz.nucleoid:plasmid:0.1.0+build.44"

modRuntime ("com.github.jellysquid3:sodium-fabric:b9c2ad3c38b16275cf2f1a81dcfb2fee1563905b")
modRuntime ("com.github.jellysquid3:phosphor-fabric:0749029a498e8f6574643285bae7aecb2eda76b8")
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ minecraft_version=1.16.1
yarn_mappings=1.16.1+build.21
loader_version=0.9.0+build.204
# Mod Properties
mod_version=1.1.2
mod_version=1.1.3
maven_group=fr.catcore
archives_base_name=deacoudre
# Dependencies
Expand Down
12 changes: 5 additions & 7 deletions src/main/java/fr/catcore/deacoudre/DeACoudre.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ public class DeACoudre implements ModInitializer {
public static final String ID = "deacoudre";
public static final Logger LOGGER = LogManager.getLogger(ID);

public static final GameType<DeACoudreConfig> TYPE = GameType.register(
new Identifier(ID, "deacoudre"),
DeACoudreWaiting::open,
DeACoudreConfig.CODEC
);

@Override
public void onInitialize() {
// MapProvider.REGISTRY.register(new Identifier(ID, "deacoudre"), DeACoudreMapGenerator.CODEC);
GameType.register(
new Identifier(ID, "deacoudre"),
DeACoudreWaiting::open,
DeACoudreConfig.CODEC
);
}
}
7 changes: 2 additions & 5 deletions src/main/java/fr/catcore/deacoudre/game/DeACoudreActive.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import net.minecraft.world.GameMode;

import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;

public class DeACoudreActive {
Expand Down Expand Up @@ -154,8 +153,7 @@ private boolean onPlayerDeath(ServerPlayerEntity player, DamageSource source) {
}

private void spawnParticipant(ServerPlayerEntity player) {
this.spawnLogic.resetPlayer(player, GameMode.ADVENTURE);
this.spawnLogic.spawnPlayer(player);
this.spawnLogic.spawnPlayer(player, GameMode.ADVENTURE);
}

private void eliminatePlayer(ServerPlayerEntity player) {
Expand Down Expand Up @@ -186,8 +184,7 @@ private void broadcastSound(SoundEvent sound) {
}

private void spawnSpectator(ServerPlayerEntity player) {
this.spawnLogic.resetPlayer(player, GameMode.SPECTATOR);
this.spawnLogic.spawnPlayer(player);
this.spawnLogic.spawnPlayer(player, GameMode.SPECTATOR);
}

private void tick() {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/fr/catcore/deacoudre/game/DeACoudreConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import fr.catcore.deacoudre.game.map.DeACoudreMapConfig;
import xyz.nucleoid.plasmid.game.config.GameConfig;
import xyz.nucleoid.plasmid.game.config.PlayerConfig;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;

public class DeACoudreConfig implements GameConfig {
public class DeACoudreConfig {

public static final Codec<DeACoudreConfig> CODEC = RecordCodecBuilder.create(instance -> {
return instance.group(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@ public DeACoudreSpawnLogic(GameWorld gameWorld, DeACoudreMap map) {
this.map = map;
}

public void resetPlayer(ServerPlayerEntity player, GameMode gameMode) {
player.inventory.clear();
player.getEnderChestInventory().clear();
player.clearStatusEffects();
player.setHealth(20.0F);
player.getHungerManager().setFoodLevel(20);
player.fallDistance = 0.0F;
public void spawnPlayer(ServerPlayerEntity player, GameMode gameMode) {
player.setGameMode(gameMode);

player.addStatusEffect(new StatusEffectInstance(
Expand All @@ -34,9 +28,7 @@ public void resetPlayer(ServerPlayerEntity player, GameMode gameMode) {
true,
false
));
}

public void spawnPlayer(ServerPlayerEntity player) {
ServerWorld world = this.gameWorld.getWorld();

BlockPos pos = new BlockPos(0,3,0);
Expand Down
22 changes: 12 additions & 10 deletions src/main/java/fr/catcore/deacoudre/game/DeACoudreWaiting.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

import fr.catcore.deacoudre.game.map.DeACoudreMap;
import fr.catcore.deacoudre.game.map.DeACoudreMapGenerator;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.math.Vec3d;
import xyz.nucleoid.plasmid.game.GameWorld;
import xyz.nucleoid.plasmid.game.GameWorldState;
import xyz.nucleoid.plasmid.game.StartResult;
import xyz.nucleoid.plasmid.game.config.PlayerConfig;
import xyz.nucleoid.plasmid.game.event.OfferPlayerListener;
Expand All @@ -16,6 +17,7 @@
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.world.GameMode;
import xyz.nucleoid.plasmid.game.world.bubble.BubbleWorldConfig;

import java.util.concurrent.CompletableFuture;

Expand All @@ -33,11 +35,16 @@ private DeACoudreWaiting(GameWorld gameWorld, DeACoudreMap map, DeACoudreConfig
this.spawnLogic = new DeACoudreSpawnLogic(gameWorld, map);
}

public static CompletableFuture<Void> open(GameWorldState worldState, DeACoudreConfig config) {
public static CompletableFuture<Void> open(MinecraftServer minecraftServer, DeACoudreConfig config) {
DeACoudreMapGenerator generator = new DeACoudreMapGenerator(config.mapConfig);

return generator.create().thenAccept(map -> {
GameWorld gameWorld = worldState.openWorld(map.asGenerator());
BubbleWorldConfig worldConfig = new BubbleWorldConfig()
.setGenerator(map.asGenerator())
.setDefaultGameMode(GameMode.SPECTATOR)
.setSpawnPos(new Vec3d(0,3,0));

GameWorld gameWorld = GameWorld.open(minecraftServer, worldConfig);

DeACoudreWaiting waiting = new DeACoudreWaiting(gameWorld, map, config);

Expand Down Expand Up @@ -79,16 +86,11 @@ private StartResult requestStart() {
}

private void addPlayer(ServerPlayerEntity player) {
this.spawnPlayer(player);
this.spawnLogic.spawnPlayer(player, GameMode.ADVENTURE);
}

private boolean onPlayerDeath(ServerPlayerEntity player, DamageSource source) {
this.spawnPlayer(player);
this.spawnLogic.spawnPlayer(player, GameMode.ADVENTURE);
return true;
}

private void spawnPlayer(ServerPlayerEntity player) {
this.spawnLogic.resetPlayer(player, GameMode.ADVENTURE);
this.spawnLogic.spawnPlayer(player);
}
}

0 comments on commit 2cd197f

Please sign in to comment.