Skip to content

Commit

Permalink
Update to 1.21.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Dec 8, 2024
1 parent b0ebdd4 commit a83aa9a
Show file tree
Hide file tree
Showing 19 changed files with 95 additions and 88 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 17
java-version: 21

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew build

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: artifacts
path: build/libs
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 17
java-version: 21

- name: Grant execute permission for gradlew
run: chmod +x gradlew
Expand All @@ -32,7 +32,7 @@ jobs:
run: ./gradlew build

- name: Upload GitHub release
uses: AButler/upload-release-assets@v2.0
uses: AButler/upload-release-assets@v3.0
with:
files: 'build/libs/*.jar;!build/libs/*-sources.jar;!build/libs/*-dev.jar'
repo-token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies {
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

// Plasmid
modImplementation "xyz.nucleoid:plasmid:0.5.102-SNAPSHOT+1.20.4"
modImplementation "xyz.nucleoid:plasmid:0.6.2+1.21.4"

// modRuntime ("com.github.jellysquid3:sodium-fabric:b9c2ad3c38b16275cf2f1a81dcfb2fee1563905b")
// modRuntime ("com.github.jellysquid3:phosphor-fabric:0749029a498e8f6574643285bae7aecb2eda76b8")
Expand All @@ -50,7 +50,7 @@ tasks.withType(JavaCompile).configureEach {
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"
it.options.release = 17
it.options.release = 21
}

java {
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
loader_version=0.15.11
minecraft_version=1.21.4
yarn_mappings=1.21.4+build.1
loader_version=0.16.9
# Mod Properties
mod_version=1.4.1
mod_version=1.4.2
maven_group=fr.catcore
archives_base_name=deacoudre
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.97.1+1.20.4
fabric_version=0.110.2+1.21.4
4 changes: 2 additions & 2 deletions src/main/java/fr/catcore/deacoudre/DeACoudre.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import fr.catcore.deacoudre.game.DeACoudreConfig;
import fr.catcore.deacoudre.game.DeACoudreWaiting;
import net.fabricmc.api.ModInitializer;
import xyz.nucleoid.plasmid.game.GameType;
import xyz.nucleoid.plasmid.api.game.GameType;
import net.minecraft.util.Identifier;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand All @@ -16,7 +16,7 @@ public class DeACoudre implements ModInitializer {
@Override
public void onInitialize() {
GameType.register(
new Identifier(ID, "deacoudre"),
Identifier.of(ID, "deacoudre"),
DeACoudreConfig.CODEC,
DeACoudreWaiting::open
);
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/fr/catcore/deacoudre/game/DeACoudreConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@

import com.mojang.datafixers.util.Either;
import com.mojang.serialization.Codec;
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import fr.catcore.deacoudre.game.map.DeACoudreMapConfig;
import net.minecraft.util.Identifier;
import xyz.nucleoid.plasmid.game.common.config.PlayerConfig;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import xyz.nucleoid.plasmid.api.game.common.config.WaitingLobbyConfig;

public record DeACoudreConfig(
Either<DeACoudreMapConfig, Identifier> map,
PlayerConfig playerConfig, int life, boolean concurrent) {
WaitingLobbyConfig playerConfig, int life, boolean concurrent) {

public static final Codec<DeACoudreConfig> CODEC = RecordCodecBuilder.create(instance -> {
public static final MapCodec<DeACoudreConfig> CODEC = RecordCodecBuilder.mapCodec(instance -> {
return instance.group(
Codec.either(DeACoudreMapConfig.CODEC, Identifier.CODEC).fieldOf("map").forGetter(config -> config.map),
PlayerConfig.CODEC.fieldOf("players").forGetter(config -> config.playerConfig),
WaitingLobbyConfig.CODEC.fieldOf("players").forGetter(config -> config.playerConfig),
Codec.INT.optionalFieldOf("life", 3).forGetter(config -> config.life),
Codec.BOOL.optionalFieldOf("concurrent", false).forGetter(config -> config.concurrent)
).apply(instance, DeACoudreConfig::new);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/fr/catcore/deacoudre/game/DeACoudrePool.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.random.Random;
import xyz.nucleoid.map_templates.BlockBounds;
import xyz.nucleoid.plasmid.game.GameSpace;
import xyz.nucleoid.plasmid.api.game.GameSpace;

import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.GameMode;
import xyz.nucleoid.plasmid.game.GameSpace;
import xyz.nucleoid.plasmid.api.game.GameSpace;

import java.util.Set;

public record DeACoudreSpawnLogic(GameSpace gameSpace, ServerWorld world,
DeACoudreMap map) {
Expand All @@ -24,6 +26,6 @@ public void spawnPlayer(ServerPlayerEntity player, GameMode gameMode) {
));

BlockPos pos = this.map.getSpawn();
player.teleport(this.world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 0.0F, 0.0F);
player.teleport(this.world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, Set.of(), 0.0F, 0.0F, false);
}
}
32 changes: 17 additions & 15 deletions src/main/java/fr/catcore/deacoudre/game/DeACoudreWaiting.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
import xyz.nucleoid.fantasy.RuntimeWorldConfig;
import xyz.nucleoid.map_templates.MapTemplate;
import xyz.nucleoid.map_templates.MapTemplateSerializer;
import xyz.nucleoid.plasmid.game.*;
import xyz.nucleoid.plasmid.game.common.GameWaitingLobby;
import xyz.nucleoid.plasmid.game.event.GameActivityEvents;
import xyz.nucleoid.plasmid.game.event.GamePlayerEvents;
import xyz.nucleoid.plasmid.game.player.PlayerOffer;
import xyz.nucleoid.plasmid.game.player.PlayerOfferResult;
import xyz.nucleoid.plasmid.game.rule.GameRuleType;
import xyz.nucleoid.plasmid.api.game.*;
import xyz.nucleoid.plasmid.api.game.common.GameWaitingLobby;
import xyz.nucleoid.plasmid.api.game.event.GameActivityEvents;
import xyz.nucleoid.plasmid.api.game.event.GamePlayerEvents;
import xyz.nucleoid.plasmid.api.game.player.JoinAcceptor;
import xyz.nucleoid.plasmid.api.game.player.JoinAcceptorResult;
import xyz.nucleoid.plasmid.api.game.player.JoinOffer;
import xyz.nucleoid.plasmid.api.game.rule.GameRuleType;
import xyz.nucleoid.stimuli.event.EventResult;
import xyz.nucleoid.stimuli.event.player.PlayerDeathEvent;

import java.io.IOException;
Expand Down Expand Up @@ -79,7 +81,8 @@ public static GameOpenProcedure open(GameOpenContext<DeACoudreConfig> context) {

game.listen(GameActivityEvents.REQUEST_START, waiting::requestStart);

game.listen(GamePlayerEvents.OFFER, waiting::offerPlayer);
game.listen(GamePlayerEvents.OFFER, JoinOffer::accept);
game.listen(GamePlayerEvents.ACCEPT, waiting::acceptPlayer);
game.listen(PlayerDeathEvent.EVENT, waiting::onPlayerDeath);
});
}
Expand All @@ -93,21 +96,20 @@ private GameResult requestStart() {
return GameResult.ok();
}

private PlayerOfferResult offerPlayer(PlayerOffer offer) {
private JoinAcceptorResult acceptPlayer(JoinAcceptor offer) {
var spawn = this.map.getSpawn();
if (spawn == null) {
return offer.reject(Text.literal("No spawn defined on map!"));
return offer.pass();
}

return offer.accept(this.world, Vec3d.ofCenter(spawn))
.and(() -> {
var player = offer.player();
return offer.teleport(this.world, Vec3d.ofCenter(spawn))
.thenRunForEach((player) -> {
this.spawnLogic.spawnPlayer(player, GameMode.ADVENTURE);
});
}

private ActionResult onPlayerDeath(ServerPlayerEntity player, DamageSource source) {
private EventResult onPlayerDeath(ServerPlayerEntity player, DamageSource source) {
this.spawnLogic.spawnPlayer(player, GameMode.ADVENTURE);
return ActionResult.FAIL;
return EventResult.DENY;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.GameMode;
import org.jetbrains.annotations.Nullable;
import xyz.nucleoid.plasmid.game.GameCloseReason;
import xyz.nucleoid.plasmid.game.GameSpace;
import xyz.nucleoid.plasmid.game.common.GlobalWidgets;
import xyz.nucleoid.plasmid.game.common.widget.SidebarWidget;
import xyz.nucleoid.plasmid.game.event.*;
import xyz.nucleoid.plasmid.game.player.PlayerOffer;
import xyz.nucleoid.plasmid.game.player.PlayerOfferResult;
import xyz.nucleoid.plasmid.game.player.PlayerSet;
import xyz.nucleoid.plasmid.game.rule.GameRuleType;
import xyz.nucleoid.plasmid.api.game.GameCloseReason;
import xyz.nucleoid.plasmid.api.game.GameSpace;
import xyz.nucleoid.plasmid.api.game.common.GlobalWidgets;
import xyz.nucleoid.plasmid.api.game.common.widget.SidebarWidget;
import xyz.nucleoid.plasmid.api.game.event.*;
import xyz.nucleoid.plasmid.api.game.player.*;
import xyz.nucleoid.plasmid.api.game.rule.GameRuleType;
import xyz.nucleoid.stimuli.event.EventResult;
import xyz.nucleoid.stimuli.event.player.PlayerDamageEvent;
import xyz.nucleoid.stimuli.event.player.PlayerDeathEvent;

Expand Down Expand Up @@ -65,7 +64,7 @@ public static void open(GameSpace gameSpace, ServerWorld world, DeACoudreMap map
gameSpace.setActivity(game -> {
GlobalWidgets widgets = GlobalWidgets.addTo(game);

Set<ServerPlayerEntity> jumpers = Sets.newHashSet(gameSpace.getPlayers());
Set<ServerPlayerEntity> jumpers = Sets.newHashSet(gameSpace.getPlayers().participants());
DeACoudreConcurrent active = new DeACoudreConcurrent(gameSpace, world, map, jumpers, widgets);

game.deny(GameRuleType.CRAFTING);
Expand All @@ -78,7 +77,8 @@ public static void open(GameSpace gameSpace, ServerWorld world, DeACoudreMap map
game.listen(GameActivityEvents.ENABLE, active::onOpen);
game.listen(GameActivityEvents.TICK, active::tick);

game.listen(GamePlayerEvents.OFFER, active::offerPlayer);
game.listen(GamePlayerEvents.ACCEPT, active::offerPlayer);
game.listen(GamePlayerEvents.OFFER, JoinOffer::acceptSpectators);

game.listen(GamePlayerEvents.LEAVE, active::removePlayer);

Expand All @@ -92,28 +92,31 @@ private void onOpen() {
this.spawnJumper(player);
}

for (ServerPlayerEntity player : this.gameSpace.getPlayers().spectators()) {
this.spawnSpectator(player);
}

this.updateSidebar();
}

private PlayerOfferResult offerPlayer(PlayerOffer offer) {
return offer.accept(this.world, Vec3d.ofCenter(this.gameMap.getSpawn()))
.and(() -> {
var player = offer.player();
if (!this.jumpers.contains(player)) {
private JoinAcceptorResult offerPlayer(JoinAcceptor offer) {
return offer.teleport(this.world, Vec3d.ofCenter(this.gameMap.getSpawn()))
.thenRunForEach((player, intent) -> {
if (!this.jumpers.contains(player) || intent == JoinIntent.SPECTATE) {
this.spawnSpectator(player);
}
});
}

private ActionResult onPlayerDamage(ServerPlayerEntity player, DamageSource source, float amount) {
if (player == null) return ActionResult.FAIL;
private EventResult onPlayerDamage(ServerPlayerEntity player, DamageSource source, float amount) {
if (player == null) return EventResult.DENY;

if (source.isOf(DamageTypes.OUT_OF_WORLD) || source.isOf(DamageTypes.FALL)) {
this.onPlayerFailJump(player);
return ActionResult.FAIL;
return EventResult.DENY;
}

return ActionResult.FAIL;
return EventResult.DENY;
}

private void onPlayerFailJump(ServerPlayerEntity player) {
Expand Down Expand Up @@ -143,9 +146,9 @@ private void onPlayerLandInWater(ServerPlayerEntity player) {
}
}

private ActionResult onPlayerDeath(ServerPlayerEntity player, DamageSource source) {
private EventResult onPlayerDeath(ServerPlayerEntity player, DamageSource source) {
this.spawnJumper(player);
return ActionResult.FAIL;
return EventResult.DENY;
}

private void removePlayer(ServerPlayerEntity player) {
Expand Down Expand Up @@ -182,7 +185,7 @@ private void spawnSpectator(ServerPlayerEntity player) {
private void spawnJumper(ServerPlayerEntity jumper) {
Vec3d platformSpawn = this.gameMap.getJumpingPlatform().center();

jumper.teleport(this.world, platformSpawn.x, platformSpawn.y, platformSpawn.z, 180F, 0F);
jumper.teleport(this.world, platformSpawn.x, platformSpawn.y, platformSpawn.z, Set.of(), 180F, 0F, false);
jumper.fallDistance = 0.0F;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import xyz.nucleoid.map_templates.BlockBounds;
import xyz.nucleoid.map_templates.MapTemplate;
import xyz.nucleoid.map_templates.MapTemplateMetadata;
import xyz.nucleoid.plasmid.game.world.generator.TemplateChunkGenerator;
import xyz.nucleoid.plasmid.api.game.world.generator.TemplateChunkGenerator;

public class DeACoudreMap {
private final MapTemplate template;
Expand Down
Loading

0 comments on commit a83aa9a

Please sign in to comment.