diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e9483be..42ce5a8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,7 +21,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 @@ -29,7 +29,7 @@ jobs: - name: Build with Gradle run: ./gradlew build - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: artifacts path: build/libs diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 66bcb69..7259f2c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,7 +24,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 @@ -33,7 +33,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 }} diff --git a/build.gradle b/build.gradle index c80df79..a018744 100644 --- a/build.gradle +++ b/build.gradle @@ -1,9 +1,9 @@ plugins { - id 'fabric-loom' version '1.1.+' + id 'fabric-loom' version '1.9.+' id 'maven-publish' } -sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17 +sourceCompatibility = targetCompatibility = JavaVersion.VERSION_21 archivesBaseName = project.archives_base_name version = project.mod_version @@ -34,7 +34,7 @@ processResources { tasks.withType(JavaCompile).configureEach { it.options.encoding = "UTF-8" - it.options.release = 17 + it.options.release = 21 } java { diff --git a/gradle.properties b/gradle.properties index d7ce798..36d8c6d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,13 +2,13 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties -minecraft_version=1.20.1 -yarn_mappings=1.20.1+build.9 -loader_version=0.14.21 +minecraft_version=1.21.3 +yarn_mappings=1.21.3+build.2 +loader_version=0.16.9 # Dependencies -fabric_version=0.85.0+1.20.1 -plasmid_version=0.5+1.20.1-SNAPSHOT +fabric_version=0.110.0+1.21.3 +plasmid_version=0.6.2-SNAPSHOT+1.21.3 # Mod Properties mod_version=1.0.0 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180..a4b76b9 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e750102..e2847c8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1b6c787..f5feea6 100644 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +82,12 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,22 +134,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,11 +201,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ @@ -205,6 +217,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index 107acd3..9b42019 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,89 +1,94 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/src/main/java/xyz/nucleoid/mineout/Mineout.java b/src/main/java/xyz/nucleoid/mineout/Mineout.java index 3bc8940..b315d5a 100644 --- a/src/main/java/xyz/nucleoid/mineout/Mineout.java +++ b/src/main/java/xyz/nucleoid/mineout/Mineout.java @@ -6,7 +6,7 @@ import org.apache.logging.log4j.Logger; import xyz.nucleoid.mineout.game.MineoutConfig; import xyz.nucleoid.mineout.game.MineoutWaiting; -import xyz.nucleoid.plasmid.game.GameType; +import xyz.nucleoid.plasmid.api.game.GameType; public final class Mineout implements ModInitializer { public static final String ID = "mineout"; @@ -15,9 +15,13 @@ public final class Mineout implements ModInitializer { @Override public void onInitialize() { GameType.register( - new Identifier(Mineout.ID, "mineout"), + Mineout.identifier("mineout"), MineoutConfig.CODEC, MineoutWaiting::open ); } + + public static Identifier identifier(String path) { + return Identifier.of(Mineout.ID, path); + } } diff --git a/src/main/java/xyz/nucleoid/mineout/game/MineoutActive.java b/src/main/java/xyz/nucleoid/mineout/game/MineoutActive.java index 48fe03b..d663510 100644 --- a/src/main/java/xyz/nucleoid/mineout/game/MineoutActive.java +++ b/src/main/java/xyz/nucleoid/mineout/game/MineoutActive.java @@ -20,7 +20,6 @@ import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; import net.minecraft.text.Text; -import net.minecraft.util.ActionResult; import net.minecraft.util.Formatting; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; @@ -29,28 +28,31 @@ import xyz.nucleoid.mineout.Mineout; import xyz.nucleoid.mineout.game.map.MineoutCheckpoint; import xyz.nucleoid.mineout.game.map.MineoutMap; -import xyz.nucleoid.plasmid.game.GameCloseReason; -import xyz.nucleoid.plasmid.game.GameOpenException; -import xyz.nucleoid.plasmid.game.GameSpace; -import xyz.nucleoid.plasmid.game.common.GlobalWidgets; -import xyz.nucleoid.plasmid.game.common.team.GameTeam; -import xyz.nucleoid.plasmid.game.common.team.GameTeamConfig; -import xyz.nucleoid.plasmid.game.common.team.GameTeamKey; -import xyz.nucleoid.plasmid.game.common.team.TeamManager; -import xyz.nucleoid.plasmid.game.common.widget.BossBarWidget; -import xyz.nucleoid.plasmid.game.common.widget.SidebarWidget; -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.player.PlayerSet; -import xyz.nucleoid.plasmid.game.rule.GameRuleType; +import xyz.nucleoid.plasmid.api.game.GameCloseReason; +import xyz.nucleoid.plasmid.api.game.GameOpenException; +import xyz.nucleoid.plasmid.api.game.GameSpace; +import xyz.nucleoid.plasmid.api.game.common.GlobalWidgets; +import xyz.nucleoid.plasmid.api.game.common.team.GameTeam; +import xyz.nucleoid.plasmid.api.game.common.team.GameTeamConfig; +import xyz.nucleoid.plasmid.api.game.common.team.GameTeamKey; +import xyz.nucleoid.plasmid.api.game.common.team.TeamManager; +import xyz.nucleoid.plasmid.api.game.common.widget.BossBarWidget; +import xyz.nucleoid.plasmid.api.game.common.widget.SidebarWidget; +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.player.PlayerSet; +import xyz.nucleoid.plasmid.api.game.rule.GameRuleType; +import xyz.nucleoid.stimuli.event.EventResult; import xyz.nucleoid.stimuli.event.block.BlockPlaceEvent; import xyz.nucleoid.stimuli.event.player.PlayerDamageEvent; import xyz.nucleoid.stimuli.event.player.PlayerDeathEvent; import java.util.ArrayList; import java.util.List; +import java.util.Set; import java.util.UUID; public final class MineoutActive { @@ -117,7 +119,8 @@ public static void open(ServerWorld world, GameSpace gameSpace, MineoutMap map, activity.listen(GameActivityEvents.ENABLE, active::onOpen); - activity.listen(GamePlayerEvents.OFFER, active::offerPlayer); + activity.listen(GamePlayerEvents.ACCEPT, active::onAcceptPlayers); + activity.listen(GamePlayerEvents.OFFER, JoinOffer::accept); activity.listen(GamePlayerEvents.ADD, active::addPlayer); activity.listen(GamePlayerEvents.REMOVE, active::removePlayer); @@ -147,7 +150,7 @@ private void onOpen() { throw new GameOpenException(Text.literal("No start checkpoint!")); } - for (ServerPlayerEntity player : this.gameSpace.getPlayers()) { + for (ServerPlayerEntity player : this.gameSpace.getPlayers().participants()) { this.playerStates.put(player.getUuid(), 0); player.changeGameMode(GameMode.ADVENTURE); @@ -155,13 +158,16 @@ private void onOpen() { startCheckpoint.sendTaskTo(player); } + for (ServerPlayerEntity player : this.gameSpace.getPlayers().spectators()) { + this.spawnSpectator(player); + } + this.updateSidebar(); } - private PlayerOfferResult offerPlayer(PlayerOffer offer) { - var player = offer.player(); - return offer.accept(this.world, Vec3d.ofBottomCenter(this.map.getSpawn())) - .and(() -> this.spawnPlayer(player)); + private JoinAcceptorResult onAcceptPlayers(JoinAcceptor acceptor) { + return acceptor.teleport(this.world, Vec3d.ofBottomCenter(this.map.getSpawn())) + .thenRunForEach(this::spawnPlayer); } private void addPlayer(ServerPlayerEntity player) { @@ -173,14 +179,14 @@ private void removePlayer(ServerPlayerEntity player) { this.playerStates.removeInt(player.getUuid()); } - private ActionResult onPlaceBlock(ServerPlayerEntity player, ServerWorld world, BlockPos pos, BlockState state, ItemUsageContext context) { + private EventResult onPlaceBlock(ServerPlayerEntity player, ServerWorld world, BlockPos pos, BlockState state, ItemUsageContext context) { if (this.playerStates.containsKey(player.getUuid())) { if (this.map.canBuildAt(pos)) { this.blockDecay.enqueue(pos); - return ActionResult.SUCCESS; + return EventResult.ALLOW; } } - return ActionResult.FAIL; + return EventResult.DENY; } private void tick() { @@ -292,7 +298,7 @@ private void onPlayerComplete(long time, ServerPlayerEntity player) { for (ServerPlayerEntity otherPlayer : players) { if (!otherPlayer.getUuid().equals(player.getUuid())) { - otherPlayer.playSound(SoundEvents.ENTITY_VILLAGER_YES, SoundCategory.PLAYERS, 1.0F, 1.0F); + otherPlayer.playSoundToPlayer(SoundEvents.ENTITY_VILLAGER_YES, SoundCategory.PLAYERS, 1.0F, 1.0F); otherPlayer.sendMessage( Text.empty().append(player.getDisplayName()) .append(" finished with a time of ") @@ -355,45 +361,45 @@ private void broadcastFinish() { } } - private ActionResult onPlayerDamage(ServerPlayerEntity player, DamageSource source, float amount) { + private EventResult onPlayerDamage(ServerPlayerEntity player, DamageSource source, float amount) { if (player.isSpectator()) { - return ActionResult.FAIL; + return EventResult.DENY; } if (source.getSource() instanceof ServerPlayerEntity) { int checkpointIndex = this.playerStates.getOrDefault(player.getUuid(), -1); MineoutCheckpoint checkpoint = this.map.getCheckpoint(checkpointIndex); if (checkpoint != null && checkpoint.isPvpEnabled()) { - return ActionResult.PASS; + return EventResult.PASS; } } if (source.isOf(DamageTypes.FLY_INTO_WALL)) { - return ActionResult.PASS; + return EventResult.PASS; } if (this.shouldRespawnFromDamage(source)) { this.spawnPlayer(player); } - return ActionResult.FAIL; + return EventResult.DENY; } private boolean shouldRespawnFromDamage(DamageSource source) { return source.isOf(DamageTypes.LAVA) || source.isOf(DamageTypes.OUT_OF_WORLD); } - private ActionResult onPlayerDeath(ServerPlayerEntity player, DamageSource source) { + private EventResult onPlayerDeath(ServerPlayerEntity player, DamageSource source) { if (!player.isSpectator()) { this.spawnPlayer(player); } - return ActionResult.FAIL; + return EventResult.DENY; } private void spawnPlayer(ServerPlayerEntity player) { player.setHealth(20.0F); player.setFireTicks(0); - player.stopFallFlying(); + player.stopGliding(); int checkpointIndex = this.playerStates.getOrDefault(player.getUuid(), -1); var checkpoint = this.map.getCheckpoint(checkpointIndex); @@ -412,7 +418,7 @@ private void spawnSpectator(ServerPlayerEntity player) { var spawn = this.map.getSpawn(); float rotation = this.map.getRotation(); - player.teleport(this.world, spawn.getX() + 0.5, spawn.getY(), spawn.getZ() + 0.5, rotation, 0.0F); + player.teleport(this.world, spawn.getX() + 0.5, spawn.getY(), spawn.getZ() + 0.5, Set.of(), rotation, 0.0F, true); } private void updateSidebar() { diff --git a/src/main/java/xyz/nucleoid/mineout/game/MineoutConfig.java b/src/main/java/xyz/nucleoid/mineout/game/MineoutConfig.java index db8ad62..0f92898 100644 --- a/src/main/java/xyz/nucleoid/mineout/game/MineoutConfig.java +++ b/src/main/java/xyz/nucleoid/mineout/game/MineoutConfig.java @@ -1,20 +1,21 @@ package xyz.nucleoid.mineout.game; import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import xyz.nucleoid.mineout.game.map.MineoutMapConfig; -import xyz.nucleoid.plasmid.game.common.config.PlayerConfig; +import xyz.nucleoid.plasmid.api.game.common.config.WaitingLobbyConfig; public record MineoutConfig( MineoutMapConfig map, - PlayerConfig players, + WaitingLobbyConfig players, int decaySeconds, int timeLimitSeconds ) { - public static final Codec CODEC = RecordCodecBuilder.create(instance -> { + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> { return instance.group( MineoutMapConfig.CODEC.fieldOf("map").forGetter(MineoutConfig::map), - PlayerConfig.CODEC.fieldOf("players").forGetter(MineoutConfig::players), + WaitingLobbyConfig.CODEC.fieldOf("players").forGetter(MineoutConfig::players), Codec.INT.optionalFieldOf("decay_seconds", 4).forGetter(MineoutConfig::decaySeconds), Codec.INT.optionalFieldOf("time_limit_seconds", 150).forGetter(MineoutConfig::timeLimitSeconds) ).apply(instance, MineoutConfig::new); diff --git a/src/main/java/xyz/nucleoid/mineout/game/MineoutWaiting.java b/src/main/java/xyz/nucleoid/mineout/game/MineoutWaiting.java index 70b16cc..26cd85f 100644 --- a/src/main/java/xyz/nucleoid/mineout/game/MineoutWaiting.java +++ b/src/main/java/xyz/nucleoid/mineout/game/MineoutWaiting.java @@ -4,24 +4,27 @@ import net.minecraft.entity.effect.StatusEffects; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.ActionResult; import net.minecraft.util.math.Vec3d; import net.minecraft.world.GameMode; import xyz.nucleoid.fantasy.RuntimeWorldConfig; import xyz.nucleoid.mineout.game.map.MineoutMap; import xyz.nucleoid.mineout.game.map.MineoutMapGenerator; -import xyz.nucleoid.plasmid.game.GameOpenContext; -import xyz.nucleoid.plasmid.game.GameOpenProcedure; -import xyz.nucleoid.plasmid.game.GameResult; -import xyz.nucleoid.plasmid.game.GameSpace; -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.api.game.GameOpenContext; +import xyz.nucleoid.plasmid.api.game.GameOpenProcedure; +import xyz.nucleoid.plasmid.api.game.GameResult; +import xyz.nucleoid.plasmid.api.game.GameSpace; +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.stimuli.event.EventResult; import xyz.nucleoid.stimuli.event.player.PlayerDamageEvent; import xyz.nucleoid.stimuli.event.player.PlayerDeathEvent; +import java.util.Set; + public final class MineoutWaiting { private final ServerWorld world; private final GameSpace gameSpace; @@ -51,9 +54,10 @@ public static GameOpenProcedure open(GameOpenContext context) { activity.listen(GameActivityEvents.REQUEST_START, waiting::requestStart); activity.listen(GameActivityEvents.TICK, waiting::tick); - activity.listen(GamePlayerEvents.OFFER, waiting::offerPlayer); - activity.listen(PlayerDamageEvent.EVENT, (player, source, amount) -> ActionResult.FAIL); - activity.listen(PlayerDeathEvent.EVENT, (player, source) -> ActionResult.FAIL); + activity.listen(GamePlayerEvents.ACCEPT, waiting::onAcceptPlayers); + activity.listen(GamePlayerEvents.OFFER, JoinOffer::accept); + activity.listen(PlayerDamageEvent.EVENT, (player, source, amount) -> EventResult.DENY); + activity.listen(PlayerDeathEvent.EVENT, (player, source) -> EventResult.DENY); }); } @@ -66,21 +70,19 @@ private void tick() { for (ServerPlayerEntity player : this.gameSpace.getPlayers()) { if (!this.map.getBounds().contains(player.getBlockPos())) { Vec3d spawn = Vec3d.ofBottomCenter(this.map.getSpawn()); - player.teleport(this.world, spawn.getX(), spawn.getY(), spawn.getZ(), this.map.getRotation(), 0); + player.teleport(this.world, spawn.getX(), spawn.getY(), spawn.getZ(), Set.of(), this.map.getRotation(), 0, true); } } } - private PlayerOfferResult offerPlayer(PlayerOffer offer) { - var player = offer.player(); - return offer.accept(this.world, Vec3d.ofBottomCenter(this.map.getSpawn())) - .and(() -> { + private JoinAcceptorResult onAcceptPlayers(JoinAcceptor acceptor) { + return acceptor.teleport(this.world, Vec3d.ofBottomCenter(this.map.getSpawn()), this.map.getRotation(), 0) + .thenRunForEach(player -> { player.changeGameMode(GameMode.ADVENTURE); - player.setYaw(this.map.getRotation()); player.addStatusEffect(new StatusEffectInstance( StatusEffects.NIGHT_VISION, - Integer.MAX_VALUE, + StatusEffectInstance.INFINITE, 1, true, false diff --git a/src/main/java/xyz/nucleoid/mineout/game/map/CheckpointConfig.java b/src/main/java/xyz/nucleoid/mineout/game/map/CheckpointConfig.java index b829a8b..8113df7 100644 --- a/src/main/java/xyz/nucleoid/mineout/game/map/CheckpointConfig.java +++ b/src/main/java/xyz/nucleoid/mineout/game/map/CheckpointConfig.java @@ -9,7 +9,7 @@ import net.minecraft.text.Text; import xyz.nucleoid.map_templates.BlockBounds; import xyz.nucleoid.map_templates.MapTemplateMetadata; -import xyz.nucleoid.plasmid.game.GameOpenException; +import xyz.nucleoid.plasmid.api.game.GameOpenException; import java.util.List; import java.util.Map; diff --git a/src/main/java/xyz/nucleoid/mineout/game/map/MineoutCheckpoint.java b/src/main/java/xyz/nucleoid/mineout/game/map/MineoutCheckpoint.java index 565e6e3..a268cea 100644 --- a/src/main/java/xyz/nucleoid/mineout/game/map/MineoutCheckpoint.java +++ b/src/main/java/xyz/nucleoid/mineout/game/map/MineoutCheckpoint.java @@ -10,6 +10,7 @@ import java.util.List; import java.util.Map; +import java.util.Set; public final class MineoutCheckpoint { private final BlockBounds bounds; @@ -43,7 +44,7 @@ public boolean contains(ServerPlayerEntity player) { } public void spawnPlayer(ServerPlayerEntity player, float rotation) { - player.teleport(player.getServerWorld(), this.spawn.getX() + 0.5, this.spawn.getY(), this.spawn.getZ() + 0.5, rotation, 0.0F); + player.teleport(player.getServerWorld(), this.spawn.getX() + 0.5, this.spawn.getY(), this.spawn.getZ() + 0.5, Set.of(), rotation, 0.0F, true); player.networkHandler.syncWithPlayerPosition(); this.applyTo(player); diff --git a/src/main/java/xyz/nucleoid/mineout/game/map/MineoutMap.java b/src/main/java/xyz/nucleoid/mineout/game/map/MineoutMap.java index 800c5f7..a712923 100644 --- a/src/main/java/xyz/nucleoid/mineout/game/map/MineoutMap.java +++ b/src/main/java/xyz/nucleoid/mineout/game/map/MineoutMap.java @@ -6,7 +6,7 @@ import org.jetbrains.annotations.Nullable; import xyz.nucleoid.map_templates.BlockBounds; import xyz.nucleoid.map_templates.MapTemplate; -import xyz.nucleoid.plasmid.game.world.generator.TemplateChunkGenerator; +import xyz.nucleoid.plasmid.api.game.world.generator.TemplateChunkGenerator; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/xyz/nucleoid/mineout/game/map/MineoutMapGenerator.java b/src/main/java/xyz/nucleoid/mineout/game/map/MineoutMapGenerator.java index f0e7057..2ff8a37 100644 --- a/src/main/java/xyz/nucleoid/mineout/game/map/MineoutMapGenerator.java +++ b/src/main/java/xyz/nucleoid/mineout/game/map/MineoutMapGenerator.java @@ -5,7 +5,7 @@ import xyz.nucleoid.map_templates.MapTemplate; import xyz.nucleoid.map_templates.MapTemplateMetadata; import xyz.nucleoid.map_templates.MapTemplateSerializer; -import xyz.nucleoid.plasmid.game.GameOpenException; +import xyz.nucleoid.plasmid.api.game.GameOpenException; import java.io.IOException; diff --git a/src/main/resources/data/mineout/map_templates/mineout.nbt b/src/main/resources/data/mineout/map_template/mineout.nbt similarity index 100% rename from src/main/resources/data/mineout/map_templates/mineout.nbt rename to src/main/resources/data/mineout/map_template/mineout.nbt diff --git a/src/main/resources/data/mineout/games/standard.json b/src/main/resources/data/mineout/plasmid/game/standard.json similarity index 71% rename from src/main/resources/data/mineout/games/standard.json rename to src/main/resources/data/mineout/plasmid/game/standard.json index 8815740..562da65 100644 --- a/src/main/resources/data/mineout/games/standard.json +++ b/src/main/resources/data/mineout/plasmid/game/standard.json @@ -17,12 +17,14 @@ "give": [ { "id": "minecraft:red_wool", - "Count": 64, - "tag": { - "CanPlaceOn": [ - "minecraft:red_terracotta", - "minecraft:red_wool" - ] + "count": 64, + "components": { + "minecraft:can_place_on": { + "blocks": [ + "minecraft:red_terracotta", + "minecraft:red_wool" + ] + } } } ], @@ -34,11 +36,11 @@ "give": [ { "id": "minecraft:firework_rocket", - "Count": 64 + "count": 64 } ], "equip": { - "chest": {"id": "minecraft:elytra", "Count": 1} + "chest": {"id": "minecraft:elytra"} }, "task": "Fly your elytra through the blocks!" }, @@ -47,13 +49,12 @@ "give": [ { "id": "minecraft:trident", - "tag": { - "Enchantments": [ - {"id": "minecraft:riptide", "lvl": 1} - ], - "Unbreakable": true - }, - "Count": 1 + "components": { + "minecraft:enchantments": { + "minecraft:riptide": 1 + }, + "minecraft:unbreakable": {} + } } ], "task": "Use riptide on the trident to jump through the hoops! (Tip: riptide only works in water!)" diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index a1b3a6d..40e0838 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -13,8 +13,8 @@ "depends": { "fabricloader": ">=0.11", "fabric": "*", - "minecraft": ">=1.19.3", - "plasmid": "0.5.x", - "java": ">=16" + "minecraft": ">=1.21.3", + "plasmid": "0.6.x", + "java": ">=21" } }