diff --git a/.circleci/config.yml b/.circleci/config.yml index 2e9a628b9..ce9dc615a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,7 +7,7 @@ jobs: build: docker: # specify the version you desire here - - image: eclipse-temurin:21-jdk-noble + - image: eclipse-temurin:25-jdk-noble resource_class: large working_directory: ~/repo diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 7bc74e8cb..d8d9fc4c6 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -6,9 +6,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2 - name: cache - uses: actions/cache@v4 + uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # 5.0.5 with: path: | ~/.gradle/caches @@ -18,16 +18,16 @@ jobs: restore-keys: | caches- - name: JDK - uses: actions/setup-java@v4 + uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # 5.2.0 with: distribution: "temurin" - java-version: "21" + java-version: "25" - name: Gradle - uses: gradle/actions/wrapper-validation@v4 + uses: gradle/actions/wrapper-validation@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0 - name: Build run: ./gradlew --no-daemon build - name: Upload-Artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: jar path: build/libs/Galaxy.jar @@ -45,20 +45,16 @@ jobs: shell: bash run: echo IMAGE_TAG=$([ "$GITHUB_REF" = "refs/heads/master" ] && echo "latest" || ([ "$GITHUB_EVENT_NAME" = 'pull_request' ] && echo pr-${{github.event.pull_request.number}} || echo ${GITHUB_REF##*/})) >> $GITHUB_ENV - name: Checkout - uses: actions/checkout@v4 - - name: Checkout submodules - shell: bash - run: | - auth_header="$(git config --local --get http.https://github.com/.extraheader)" - git submodule sync --recursive - git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1 - - uses: actions/download-artifact@v4 + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2 + with: + submodules: recursive + - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # 8.0.1 with: name: jar path: docker/mods/Galaxy.jar - name: login if: env.USERNAME != '' && env.PASSWORD != '' - uses: docker/login-action@v3 + uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # 4.1.0 with: registry: harbor.k8s.oktw.one username: ${{ secrets.OKTW_HARBOR_USERNAME }} diff --git a/build.gradle.kts b/build.gradle.kts index a4246320f..f04759634 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,22 +3,22 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinVersion import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { - // "maven-publish" kotlin("jvm") version "2.3.0" - id("net.fabricmc.fabric-loom-remap") version "1.14-SNAPSHOT" + id("net.fabricmc.fabric-loom") version "1.16.1" } val version = "0.0.1" val group = "one.oktw" -val minecraftVersion = "1.21.11" -val fabricLoaderVersion = "0.18.3" -val fabricAPIVersion = "0.140.0+1.21.11" -val galaxyLibVersion = "2235da5" +val minecraftVersion = "26.1.2" +val fabricLoaderVersion = "0.19.2" +val fabricAPIVersion = "0.146.1+26.1.2" +val galaxyLibVersion = "9546e40" repositories { mavenCentral() maven(url = "https://jitpack.io") + maven(url = "https://maven.fabricmc.net/") } base { @@ -26,15 +26,15 @@ base { } java { - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 + sourceCompatibility = JavaVersion.VERSION_25 + targetCompatibility = JavaVersion.VERSION_25 } tasks.withType().configureEach { compilerOptions { apiVersion = KotlinVersion.KOTLIN_2_0 languageVersion = KotlinVersion.KOTLIN_2_0 - jvmTarget = JvmTarget.JVM_21 + jvmTarget = JvmTarget.JVM_25 } } @@ -52,11 +52,10 @@ fabricApi { dependencies { // Core minecraft("com.mojang:minecraft:${minecraftVersion}") - mappings(loom.officialMojangMappings()) - modImplementation("net.fabricmc:fabric-loader:${fabricLoaderVersion}") + implementation("net.fabricmc:fabric-loader:${fabricLoaderVersion}") // fabric api - modImplementation("net.fabricmc.fabric-api:fabric-api:${fabricAPIVersion}") { + implementation("net.fabricmc.fabric-api:fabric-api:${fabricAPIVersion}") { val gametest = fabricApi.module("fabric-gametest-api-v1", fabricAPIVersion) // Unused and cause client Registry remapping failed. exclude(gametest.group, gametest.name) } diff --git a/docker b/docker index 21322f8ff..b1533cb2e 160000 --- a/docker +++ b/docker @@ -1 +1 @@ -Subproject commit 21322f8ff0b0acf2d3e149ce2243f3cd003b1c4d +Subproject commit b1533cb2e1319a492a1db53658587f5285d7a442 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index f8e1ee312..d997cfc60 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 23449a2b5..c61a118f7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index adff685a0..739907dfd 100755 --- a/gradlew +++ b/gradlew @@ -57,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/2d6327017519d23b96af35865dc997fcb544fb40/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/. diff --git a/src/main/java/one/oktw/galaxy/mixin/event/MixinPlayerChat_EmoteCommands.java b/src/main/java/one/oktw/galaxy/mixin/event/MixinPlayerChat_EmoteCommands.java index 16f2ffdd0..5637652f6 100644 --- a/src/main/java/one/oktw/galaxy/mixin/event/MixinPlayerChat_EmoteCommands.java +++ b/src/main/java/one/oktw/galaxy/mixin/event/MixinPlayerChat_EmoteCommands.java @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -33,7 +33,7 @@ @Mixin(EmoteCommands.class) public class MixinPlayerChat_EmoteCommands { - @Redirect(method = "method_43645", at = @At( + @Redirect(method = "lambda$register$1", at = @At( value = "INVOKE", target = "Lnet/minecraft/server/players/PlayerList;broadcastChatMessage(Lnet/minecraft/network/chat/PlayerChatMessage;Lnet/minecraft/commands/CommandSourceStack;Lnet/minecraft/network/chat/ChatType$Bound;)V", ordinal = 0 diff --git a/src/main/java/one/oktw/galaxy/mixin/event/MixinPlayerChat_SayCommand.java b/src/main/java/one/oktw/galaxy/mixin/event/MixinPlayerChat_SayCommand.java index 8afe2f7fe..0d7ea3010 100644 --- a/src/main/java/one/oktw/galaxy/mixin/event/MixinPlayerChat_SayCommand.java +++ b/src/main/java/one/oktw/galaxy/mixin/event/MixinPlayerChat_SayCommand.java @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -35,7 +35,7 @@ @Mixin(SayCommand.class) public class MixinPlayerChat_SayCommand { @Inject( - method = "method_43657", + method = "lambda$register$1", at = @At( value = "INVOKE", target = "Lnet/minecraft/server/players/PlayerList;broadcastChatMessage(Lnet/minecraft/network/chat/PlayerChatMessage;Lnet/minecraft/commands/CommandSourceStack;Lnet/minecraft/network/chat/ChatType$Bound;)V", diff --git a/src/main/java/one/oktw/galaxy/mixin/tweak/MixinAsyncChunk_IOWorker.java b/src/main/java/one/oktw/galaxy/mixin/tweak/MixinAsyncChunk_IOWorker.java index b2787da69..6e3392c44 100644 --- a/src/main/java/one/oktw/galaxy/mixin/tweak/MixinAsyncChunk_IOWorker.java +++ b/src/main/java/one/oktw/galaxy/mixin/tweak/MixinAsyncChunk_IOWorker.java @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -75,7 +75,7 @@ public abstract class MixinAsyncChunk_IOWorker { @Inject(method = "", at = @At("RETURN")) private void parallelExecutor(RegionStorageInfo storageKey, Path directory, boolean dsync, CallbackInfo ci) { - pendingWrites = new ConcurrentSkipListMap<>(Comparator.comparingLong(ChunkPos::toLong)); + pendingWrites = new ConcurrentSkipListMap<>(Comparator.comparingLong(ChunkPos::pack)); consecutiveExecutor = new KotlinCoroutineTaskExecutor(3 /* FOREGROUND,BACKGROUND,SHUTDOWN */, "IOWorker-" + storageKey.type()); } @@ -87,7 +87,7 @@ private void parallelExecutor(RegionStorageInfo storageKey, Path directory, bool private void storePendingChunk() { if (!this.pendingWrites.isEmpty() && !writeLock.getAndSet(true)) { HashMap>> map = new HashMap<>(); - pendingWrites.forEach((pos, result) -> map.computeIfAbsent(ChunkPos.asLong(pos.getRegionX(), pos.getRegionZ()), k -> new ArrayList<>()).add(new Tuple<>(pos, result))); + pendingWrites.forEach((pos, result) -> map.computeIfAbsent(ChunkPos.pack(pos.getRegionX(), pos.getRegionZ()), k -> new ArrayList<>()).add(new Tuple<>(pos, result))); map.values().forEach(list -> consecutiveExecutor.schedule(new StrictQueue.RunnableWithPriority(Priority.FOREGROUND.ordinal(), () -> list.forEach(pair -> runStore(pair.getA(), pair.getB())))) ); diff --git a/src/main/java/one/oktw/galaxy/mixin/tweak/MixinAsyncChunk_ServerGamePacketListener.java b/src/main/java/one/oktw/galaxy/mixin/tweak/MixinAsyncChunk_ServerGamePacketListener.java index 7855e93f4..cefc696a1 100644 --- a/src/main/java/one/oktw/galaxy/mixin/tweak/MixinAsyncChunk_ServerGamePacketListener.java +++ b/src/main/java/one/oktw/galaxy/mixin/tweak/MixinAsyncChunk_ServerGamePacketListener.java @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -54,7 +54,7 @@ private void noBlockingMove(ServerboundMovePlayerPacket packet, CallbackInfo ci) int x = SectionPos.posToSectionCoord(clampHorizontal(packet.getX(this.player.getX()))); int z = SectionPos.posToSectionCoord(clampHorizontal(packet.getZ(this.player.getZ()))); - if (!player.level().getChunkSource().isPositionTicking(ChunkPos.asLong(x, z))) { + if (!player.level().getChunkSource().isPositionTicking(ChunkPos.pack(x, z))) { player.setDeltaMovement(Vec3.ZERO); teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot()); ci.cancel(); diff --git a/src/main/java/one/oktw/galaxy/mixin/tweak/MixinDisableHardLink_FileFixerUpper.java b/src/main/java/one/oktw/galaxy/mixin/tweak/MixinDisableHardLink_FileFixerUpper.java new file mode 100644 index 000000000..2d21db616 --- /dev/null +++ b/src/main/java/one/oktw/galaxy/mixin/tweak/MixinDisableHardLink_FileFixerUpper.java @@ -0,0 +1,37 @@ +/* + * OKTW Galaxy Project + * Copyright (C) 2018-2026 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package one.oktw.galaxy.mixin.tweak; + +import net.minecraft.util.filefix.FileFixerUpper; +import net.minecraft.util.filefix.FileSystemCapabilities; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.nio.file.Path; + +@Mixin(FileFixerUpper.class) +public class MixinDisableHardLink_FileFixerUpper { + @Inject(method = "detectFileSystemCapabilities", at = @At("RETURN"), cancellable = true) + private static void disableHardLink(Path dir, CallbackInfoReturnable cir) { + FileSystemCapabilities current = cir.getReturnValue(); + cir.setReturnValue(new FileSystemCapabilities(current.atomicMove(), false)); + } +} diff --git a/src/main/java/one/oktw/galaxy/mixin/tweak/MixinMapExistingChunk_MapItem.java b/src/main/java/one/oktw/galaxy/mixin/tweak/MixinMapExistingChunk_MapItem.java index f84fe26d4..7319a03df 100644 --- a/src/main/java/one/oktw/galaxy/mixin/tweak/MixinMapExistingChunk_MapItem.java +++ b/src/main/java/one/oktw/galaxy/mixin/tweak/MixinMapExistingChunk_MapItem.java @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -36,8 +36,8 @@ public abstract class MixinMapExistingChunk_MapItem { private LevelChunk getExistingChunk(Level world, int x, int z) { ServerLevel serverWorld = (ServerLevel) world; ChunkPos chunkPos = new ChunkPos(x, z); - if (serverWorld.getChunkSource().isPositionTicking(chunkPos.toLong())) { // TODO check this - LevelChunk chunk = world.getChunkSource().getChunkNow(chunkPos.x, chunkPos.z); + if (serverWorld.getChunkSource().isPositionTicking(chunkPos.pack())) { // TODO check this + LevelChunk chunk = world.getChunkSource().getChunkNow(x, z); if (chunk != null) return chunk; } return new EmptyLevelChunk(world, new ChunkPos(x, z), world.registryAccess().lookupOrThrow(Registries.BIOME).getOrThrow(Biomes.PLAINS)); diff --git a/src/main/java/one/oktw/galaxy/mixin/tweak/MixinThrownCountdown_Entity.java b/src/main/java/one/oktw/galaxy/mixin/tweak/MixinThrownCountdown_Entity.java index ea5f41398..d7b9915e6 100644 --- a/src/main/java/one/oktw/galaxy/mixin/tweak/MixinThrownCountdown_Entity.java +++ b/src/main/java/one/oktw/galaxy/mixin/tweak/MixinThrownCountdown_Entity.java @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -27,7 +27,7 @@ import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(Entity.class) public abstract class MixinThrownCountdown_Entity implements IThrownCountdown_Entity { @@ -37,9 +37,9 @@ public abstract class MixinThrownCountdown_Entity implements IThrownCountdown_En @Shadow public abstract void discard(); - @Inject(method = "updateInWaterStateAndDoWaterCurrentPushing", - at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;doWaterSplashEffect()V")) - private void countIntoWater(CallbackInfo ci) { + @Inject(method = "updateFluidInteraction", + at = @At(value = "RETURN")) + private void countIntoWater(CallbackInfoReturnable ci) { //noinspection ConstantConditions if (((Object) this) instanceof Arrow || ((Object) this) instanceof SpectralArrow) { if (intoWater > 10) { diff --git a/src/main/java/org/spongepowered/common/mixin/realtime/world/ServerClockManagerMixin_RealTime.java b/src/main/java/org/spongepowered/common/mixin/realtime/world/ServerClockManagerMixin_RealTime.java new file mode 100644 index 000000000..dac19b491 --- /dev/null +++ b/src/main/java/org/spongepowered/common/mixin/realtime/world/ServerClockManagerMixin_RealTime.java @@ -0,0 +1,67 @@ +/* + * OKTW Galaxy Project + * Copyright (C) 2018-2026 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package org.spongepowered.common.mixin.realtime.world; + +import net.minecraft.core.Holder; +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.clock.ServerClockManager; +import net.minecraft.world.clock.WorldClock; +import net.minecraft.world.level.gamerules.GameRules; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.common.bridge.RealTimeTrackingBridge; + +import java.util.Map; + +@Mixin(ServerClockManager.class) +public abstract class ServerClockManagerMixin_RealTime implements RealTimeTrackingBridge { + @Shadow + private MinecraftServer server; + + @Final + @Shadow + private Map, ServerClockManager.ClockInstance> clocks; + + @Inject(method = "tick", at=@At("HEAD")) + private void realTimeImpl$fixTimeOfDayForRealTime(CallbackInfo ci){ + //noinspection deprecation + if (this.server.getGlobalGameRules().get(GameRules.ADVANCE_TIME)) { + // Subtract the one the original tick method is going to add + long diff = this.realTimeBridge$getRealTimeTicks() - 1; + // Don't set if we're not changing it as other mods might be listening for changes + if (diff > 0) { + for (int i = 0; i < diff; i++) { + this.clocks.values().forEach(ServerClockManager.ClockInstance::tick); + } + } + } + } + + @Override + public long realTimeBridge$getRealTimeTicks() { + if (this.server != null) { + return ((RealTimeTrackingBridge) this.server).realTimeBridge$getRealTimeTicks(); + } + return 1; + } +} diff --git a/src/main/java/org/spongepowered/common/mixin/realtime/world/ServerLevelMixin_RealTime.java b/src/main/java/org/spongepowered/common/mixin/realtime/world/ServerLevelMixin_RealTime.java index c4edb8169..37541cd20 100644 --- a/src/main/java/org/spongepowered/common/mixin/realtime/world/ServerLevelMixin_RealTime.java +++ b/src/main/java/org/spongepowered/common/mixin/realtime/world/ServerLevelMixin_RealTime.java @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -49,24 +49,14 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.Level; import net.minecraft.world.level.dimension.DimensionType; -import net.minecraft.world.level.gamerules.GameRules; -import net.minecraft.world.level.storage.ServerLevelData; import net.minecraft.world.level.storage.WritableLevelData; import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.common.bridge.RealTimeTrackingBridge; @Mixin(ServerLevel.class) public abstract class ServerLevelMixin_RealTime extends Level implements RealTimeTrackingBridge { - @Shadow - @Final - private ServerLevelData serverLevelData; - protected ServerLevelMixin_RealTime(WritableLevelData properties, ResourceKey registryRef, RegistryAccess registryManager, Holder dimensionEntry, boolean isClient, boolean debugWorld, long seed, int maxChainedNeighborUpdates) { super(properties, registryRef, registryManager, dimensionEntry, isClient, debugWorld, seed, maxChainedNeighborUpdates); } @@ -75,21 +65,6 @@ protected ServerLevelMixin_RealTime(WritableLevelData properties, ResourceKey 0) { - this.setDayTime(this.levelData.getDayTime() + diff); - } - } - } - @Override public long realTimeBridge$getRealTimeTicks() { if (this.getServer() != null) { diff --git a/src/main/kotlin/one/oktw/galaxy/Main.kt b/src/main/kotlin/one/oktw/galaxy/Main.kt index dd0d56e7e..6f0957301 100644 --- a/src/main/kotlin/one/oktw/galaxy/Main.kt +++ b/src/main/kotlin/one/oktw/galaxy/Main.kt @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -84,14 +84,14 @@ class Main : DedicatedServerModInitializer, CoroutineScope { // Register Custom Payload // Register Proxy Packet (C2S: Send, S2C: Receive) - PayloadTypeRegistry.playC2S().register(ProxyAPIPayload.ID, ProxyAPIPayload.CODEC) - PayloadTypeRegistry.playS2C().register(ProxyAPIPayload.ID, ProxyAPIPayload.CODEC) + PayloadTypeRegistry.serverboundPlay().register(ProxyAPIPayload.ID, ProxyAPIPayload.CODEC) + PayloadTypeRegistry.clientboundPlay().register(ProxyAPIPayload.ID, ProxyAPIPayload.CODEC) // Register Event ServerPlayNetworking.registerGlobalReceiver(ProxyAPIPayload.ID) { payload, context -> eventManager.emit(ProxyResponseEvent(context.player(), payload.packet)) } // Register Proxy Chat Packet - PayloadTypeRegistry.playS2C().register(ProxyChatPayload.ID, ProxyChatPayload.CODEC) + PayloadTypeRegistry.clientboundPlay().register(ProxyChatPayload.ID, ProxyChatPayload.CODEC) //Events eventManager.register(Exchange()) diff --git a/src/main/kotlin/one/oktw/galaxy/block/CustomBlock.kt b/src/main/kotlin/one/oktw/galaxy/block/CustomBlock.kt index 33409c541..c62a5c256 100644 --- a/src/main/kotlin/one/oktw/galaxy/block/CustomBlock.kt +++ b/src/main/kotlin/one/oktw/galaxy/block/CustomBlock.kt @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -47,12 +47,12 @@ open class CustomBlock(final override val identifier: Identifier, val baseBlock: val CONTROL_PANEL = registry.register(CustomBlock("control_panel", baseBlock = COMPARATOR)) val PLANET_TERMINAL = registry.register(CustomBlock("planet_terminal", baseBlock = BEACON)) val HT_CRAFTING_TABLE = registry.register(HTCraftingTable()) - val ELEVATOR = registry.register(ModelCustomBlock("elevator", CustomBlockItem.ELEVATOR.createItemStack())) - val ANGEL_BLOCK = registry.register(ModelCustomBlock("angel_block", CustomBlockItem.ANGEL_BLOCK.createItemStack())) - val TRASHCAN = registry.register(TrashcanBlock("trashcan", CustomBlockItem.TRASHCAN.createItemStack())) - val TELEPORTER_CORE_BASIC = registry.register(ModelCustomBlock("teleporter_core_basic", CustomBlockItem.TELEPORTER_CORE_BASIC.createItemStack())) - val TELEPORTER_CORE_ADVANCE = registry.register(ModelCustomBlock("teleporter_core_advance", CustomBlockItem.TELEPORTER_CORE_ADVANCE.createItemStack())) - val TELEPORTER_FRAME = registry.register(ModelCustomBlock("teleporter_frame", CustomBlockItem.TELEPORTER_FRAME.createItemStack())) + val ELEVATOR = registry.register(ModelCustomBlock("elevator", CustomBlockItem.ELEVATOR)) + val ANGEL_BLOCK = registry.register(ModelCustomBlock("angel_block", CustomBlockItem.ANGEL_BLOCK)) + val TRASHCAN = registry.register(TrashcanBlock("trashcan", CustomBlockItem.TRASHCAN)) + val TELEPORTER_CORE_BASIC = registry.register(ModelCustomBlock("teleporter_core_basic", CustomBlockItem.TELEPORTER_CORE_BASIC)) + val TELEPORTER_CORE_ADVANCE = registry.register(ModelCustomBlock("teleporter_core_advance", CustomBlockItem.TELEPORTER_CORE_ADVANCE)) + val TELEPORTER_FRAME = registry.register(ModelCustomBlock("teleporter_frame", CustomBlockItem.TELEPORTER_FRAME)) val TEST_GUI = registry.register(TestGuiBlock()) val HARVEST = registry.register(HarvestBlock()) } diff --git a/src/main/kotlin/one/oktw/galaxy/block/HTCraftingTable.kt b/src/main/kotlin/one/oktw/galaxy/block/HTCraftingTable.kt index a2baa5fd8..89bdf5dcb 100644 --- a/src/main/kotlin/one/oktw/galaxy/block/HTCraftingTable.kt +++ b/src/main/kotlin/one/oktw/galaxy/block/HTCraftingTable.kt @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -23,7 +23,7 @@ import one.oktw.galaxy.block.entity.CustomBlockEntity import one.oktw.galaxy.block.entity.HTCraftingTableBlockEntity import one.oktw.galaxy.item.CustomBlockItem -class HTCraftingTable : ModelCustomBlock("ht_crafting_table", CustomBlockItem.HT_CRAFTING_TABLE.createItemStack()) { +class HTCraftingTable : ModelCustomBlock("ht_crafting_table", CustomBlockItem.HT_CRAFTING_TABLE) { override fun createBlockEntity(pos: BlockPos): CustomBlockEntity { return HTCraftingTableBlockEntity(blockEntityType, pos, modelItem) } diff --git a/src/main/kotlin/one/oktw/galaxy/block/HarvestBlock.kt b/src/main/kotlin/one/oktw/galaxy/block/HarvestBlock.kt index df0104f1b..6b1a1c808 100644 --- a/src/main/kotlin/one/oktw/galaxy/block/HarvestBlock.kt +++ b/src/main/kotlin/one/oktw/galaxy/block/HarvestBlock.kt @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -23,7 +23,7 @@ import one.oktw.galaxy.block.entity.CustomBlockEntity import one.oktw.galaxy.block.entity.HarvestBlockEntity import one.oktw.galaxy.item.CustomBlockItem -class HarvestBlock : ModelCustomBlock("harvest", CustomBlockItem.HARVEST.createItemStack()) { +class HarvestBlock : ModelCustomBlock("harvest", CustomBlockItem.HARVEST) { override fun createBlockEntity(pos: BlockPos): CustomBlockEntity { return HarvestBlockEntity(blockEntityType, pos, modelItem) } diff --git a/src/main/kotlin/one/oktw/galaxy/block/ModelCustomBlock.kt b/src/main/kotlin/one/oktw/galaxy/block/ModelCustomBlock.kt index 38f65f6c5..b5ec8f434 100644 --- a/src/main/kotlin/one/oktw/galaxy/block/ModelCustomBlock.kt +++ b/src/main/kotlin/one/oktw/galaxy/block/ModelCustomBlock.kt @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -20,17 +20,15 @@ package one.oktw.galaxy.block import net.minecraft.core.BlockPos import net.minecraft.resources.Identifier -import net.minecraft.world.item.ItemStack import net.minecraft.world.level.block.Blocks.BARRIER import one.oktw.galaxy.block.entity.CustomBlockEntity import one.oktw.galaxy.block.entity.ModelCustomBlockEntity import one.oktw.galaxy.item.CustomBlockItem -import one.oktw.galaxy.item.CustomItemHelper -open class ModelCustomBlock(identifier: Identifier, protected open val modelItem: ItemStack) : CustomBlock(identifier, BARRIER) { - constructor(id: String, modelItem: ItemStack) : this(Identifier.fromNamespaceAndPath("galaxy", "block/$id"), modelItem) +open class ModelCustomBlock(identifier: Identifier, protected open val modelItem: CustomBlockItem) : CustomBlock(identifier, BARRIER) { + constructor(id: String, modelItem: CustomBlockItem) : this(Identifier.fromNamespaceAndPath("galaxy", "block/$id"), modelItem) - override fun toItem() = modelItem.let { CustomItemHelper.getItem(it) as? CustomBlockItem } + override fun toItem() = modelItem override fun createBlockEntity(pos: BlockPos): CustomBlockEntity { return ModelCustomBlockEntity(blockEntityType, pos, modelItem) diff --git a/src/main/kotlin/one/oktw/galaxy/block/TestGuiBlock.kt b/src/main/kotlin/one/oktw/galaxy/block/TestGuiBlock.kt index 51161cb6d..978b5f3fc 100644 --- a/src/main/kotlin/one/oktw/galaxy/block/TestGuiBlock.kt +++ b/src/main/kotlin/one/oktw/galaxy/block/TestGuiBlock.kt @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -23,7 +23,7 @@ import one.oktw.galaxy.block.entity.CustomBlockEntity import one.oktw.galaxy.block.entity.TestGuiBlockEntity import one.oktw.galaxy.item.CustomBlockItem -class TestGuiBlock : ModelCustomBlock("test_gui", CustomBlockItem.TEST_GUI.createItemStack()) { +class TestGuiBlock : ModelCustomBlock("test_gui", CustomBlockItem.TEST_GUI) { override fun createBlockEntity(pos: BlockPos): CustomBlockEntity { return TestGuiBlockEntity(blockEntityType, pos, modelItem) } diff --git a/src/main/kotlin/one/oktw/galaxy/block/TrashcanBlock.kt b/src/main/kotlin/one/oktw/galaxy/block/TrashcanBlock.kt index f2cdc8cfb..39542167a 100644 --- a/src/main/kotlin/one/oktw/galaxy/block/TrashcanBlock.kt +++ b/src/main/kotlin/one/oktw/galaxy/block/TrashcanBlock.kt @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -20,11 +20,11 @@ package one.oktw.galaxy.block import net.minecraft.core.BlockPos import net.minecraft.resources.Identifier -import net.minecraft.world.item.ItemStack import one.oktw.galaxy.block.entity.CustomBlockEntity import one.oktw.galaxy.block.entity.TrashcanBlockEntity +import one.oktw.galaxy.item.CustomBlockItem -class TrashcanBlock(id: String, modelItem: ItemStack) : ModelCustomBlock(Identifier.fromNamespaceAndPath("galaxy", "block/$id"), modelItem) { +class TrashcanBlock(id: String, modelItem: CustomBlockItem) : ModelCustomBlock(Identifier.fromNamespaceAndPath("galaxy", "block/$id"), modelItem) { override fun createBlockEntity(pos: BlockPos): CustomBlockEntity { return TrashcanBlockEntity(blockEntityType, pos, modelItem) } diff --git a/src/main/kotlin/one/oktw/galaxy/block/entity/CustomBlockEntity.kt b/src/main/kotlin/one/oktw/galaxy/block/entity/CustomBlockEntity.kt index 414dc9198..d3ba267e3 100644 --- a/src/main/kotlin/one/oktw/galaxy/block/entity/CustomBlockEntity.kt +++ b/src/main/kotlin/one/oktw/galaxy/block/entity/CustomBlockEntity.kt @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -19,6 +19,7 @@ package one.oktw.galaxy.block.entity import net.minecraft.core.BlockPos +import net.minecraft.core.registries.BuiltInRegistries import net.minecraft.world.level.block.Blocks import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.entity.BlockEntityType @@ -27,7 +28,7 @@ import net.minecraft.world.level.storage.ValueOutput // BlockEntity need extend open class CustomBlockEntity(type: BlockEntityType<*>, pos: BlockPos) : BlockEntity(type, pos, Blocks.BARRIER.defaultBlockState()) { - fun getId() = BlockEntityType.getKey(type)!! + fun getId() = BuiltInRegistries.BLOCK_ENTITY_TYPE.getKey(type)!! override fun loadAdditional(view: ValueInput) { super.loadAdditional(view) diff --git a/src/main/kotlin/one/oktw/galaxy/block/entity/HTCraftingTableBlockEntity.kt b/src/main/kotlin/one/oktw/galaxy/block/entity/HTCraftingTableBlockEntity.kt index b773d6493..8819934b1 100644 --- a/src/main/kotlin/one/oktw/galaxy/block/entity/HTCraftingTableBlockEntity.kt +++ b/src/main/kotlin/one/oktw/galaxy/block/entity/HTCraftingTableBlockEntity.kt @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -28,7 +28,7 @@ import net.minecraft.world.InteractionHand import net.minecraft.world.InteractionResult import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Player -import net.minecraft.world.inventory.ClickType +import net.minecraft.world.inventory.ContainerInput import net.minecraft.world.inventory.MenuType import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack @@ -37,6 +37,7 @@ import net.minecraft.world.phys.BlockHitResult import one.oktw.galaxy.block.listener.CustomBlockClickListener import one.oktw.galaxy.gui.GUI import one.oktw.galaxy.gui.GUISBackStackManager +import one.oktw.galaxy.item.CustomBlockItem import one.oktw.galaxy.item.CustomItemBrowser import one.oktw.galaxy.item.Gui import one.oktw.galaxy.item.Misc @@ -45,7 +46,7 @@ import one.oktw.galaxy.item.gui.GuiIcon import one.oktw.galaxy.item.gui.GuiModelBuilder import one.oktw.galaxy.item.recipe.CustomItemRecipe -class HTCraftingTableBlockEntity(type: BlockEntityType<*>, pos: BlockPos, modelItem: ItemStack) : ModelCustomBlockEntity(type, pos, modelItem), +class HTCraftingTableBlockEntity(type: BlockEntityType<*>, pos: BlockPos, modelItem: CustomBlockItem) : ModelCustomBlockEntity(type, pos, modelItem), CustomBlockClickListener, CoroutineScope by CoroutineScope(Dispatchers.Default + SupervisorJob()) { private val previousPageButton = Gui( GuiModelBuilder().withButton(GuiButton.BUTTON).withIcon(GuiIcon.ARROWHEAD_UP).build(), @@ -97,20 +98,20 @@ class HTCraftingTableBlockEntity(type: BlockEntityType<*>, pos: BlockPos, modelI // Category Paging addBinding(0, 0) { cancel = true - if (action == ClickType.PICKUP) itemBrowser.previousCategory() + if (action == ContainerInput.PICKUP) itemBrowser.previousCategory() } addBinding(0, 1) { cancel = true // Cancel creative clone item } addBinding(0, 2) { cancel = true - if (action == ClickType.PICKUP) itemBrowser.nextCategory() + if (action == ContainerInput.PICKUP) itemBrowser.nextCategory() } // Handle Items addBinding(2..7, 0..2) { cancel = true - if (action != ClickType.PICKUP) return@addBinding Unit + if (action != ContainerInput.PICKUP) return@addBinding Unit // Slot is 6 x 3 val index = this.y * 6 + (this.x - 2) val item = itemBrowser.getItemByIndex(index) ?: return@addBinding Unit @@ -121,11 +122,11 @@ class HTCraftingTableBlockEntity(type: BlockEntityType<*>, pos: BlockPos, modelI // Handle Pages addBinding(8, 0) { cancel = true - if (action == ClickType.PICKUP) itemBrowser.previousPage() + if (action == ContainerInput.PICKUP) itemBrowser.previousPage() } addBinding(8, 2) { cancel = true - if (action == ClickType.PICKUP) itemBrowser.nextPage() + if (action == ContainerInput.PICKUP) itemBrowser.nextPage() } } } @@ -160,7 +161,7 @@ class HTCraftingTableBlockEntity(type: BlockEntityType<*>, pos: BlockPos, modelI } addBinding(7, 1) { // Allow creative clone true item - if (action == ClickType.CLONE && player.isCreative) { + if (action == ContainerInput.CLONE && player.isCreative) { cancel = true val screen = player.containerMenu if (screen.carried.isEmpty) screen.carried = recipe.outputItem.createItemStack().apply { count = maxStackSize } diff --git a/src/main/kotlin/one/oktw/galaxy/block/entity/HarvestBlockEntity.kt b/src/main/kotlin/one/oktw/galaxy/block/entity/HarvestBlockEntity.kt index 529a8f710..6e86c13c9 100644 --- a/src/main/kotlin/one/oktw/galaxy/block/entity/HarvestBlockEntity.kt +++ b/src/main/kotlin/one/oktw/galaxy/block/entity/HarvestBlockEntity.kt @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -44,11 +44,12 @@ import one.oktw.galaxy.block.listener.CustomBlockClickListener import one.oktw.galaxy.block.listener.CustomBlockTickListener import one.oktw.galaxy.gui.GUI import one.oktw.galaxy.gui.GUISBackStackManager +import one.oktw.galaxy.item.CustomBlockItem import one.oktw.galaxy.item.Misc import one.oktw.galaxy.item.Upgrade import one.oktw.galaxy.util.HarvestUtil -class HarvestBlockEntity(type: BlockEntityType<*>, pos: BlockPos, modelItem: ItemStack) : +class HarvestBlockEntity(type: BlockEntityType<*>, pos: BlockPos, modelItem: CustomBlockItem) : ModelCustomBlockEntity(type, pos, modelItem, facing = Direction.NORTH), CustomBlockClickListener, WorldlyContainer, CustomBlockTickListener { companion object { private val TOOL_SLOT = 0..0 @@ -151,6 +152,7 @@ class HarvestBlockEntity(type: BlockEntityType<*>, pos: BlockPos, modelItem: Ite components.getOrDefault(DataComponents.CONTAINER, ItemContainerContents.EMPTY).copyInto(inventory) } + @Deprecated("Deprecated in Java") override fun removeComponentsFromTag(view: ValueOutput) { super.removeComponentsFromTag(view) view.discard("Items") diff --git a/src/main/kotlin/one/oktw/galaxy/block/entity/ModelCustomBlockEntity.kt b/src/main/kotlin/one/oktw/galaxy/block/entity/ModelCustomBlockEntity.kt index f24031bc2..aeaca102b 100644 --- a/src/main/kotlin/one/oktw/galaxy/block/entity/ModelCustomBlockEntity.kt +++ b/src/main/kotlin/one/oktw/galaxy/block/entity/ModelCustomBlockEntity.kt @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -25,16 +25,16 @@ import net.minecraft.nbt.CompoundTag import net.minecraft.server.level.ServerLevel import net.minecraft.world.entity.Display import net.minecraft.world.entity.EntityType -import net.minecraft.world.item.ItemStack import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.storage.TagValueOutput import net.minecraft.world.level.storage.ValueInput import net.minecraft.world.level.storage.ValueOutput import one.oktw.galaxy.block.listener.CustomBlockTickListener +import one.oktw.galaxy.item.CustomBlockItem import java.util.* import kotlin.jvm.optionals.getOrNull -open class ModelCustomBlockEntity(type: BlockEntityType<*>, pos: BlockPos, private val modelItem: ItemStack, facing: Direction? = null) : +open class ModelCustomBlockEntity(type: BlockEntityType<*>, pos: BlockPos, private val modelItem: CustomBlockItem, facing: Direction? = null) : CustomBlockEntity(type, pos), CustomBlockTickListener { @@ -53,7 +53,7 @@ open class ModelCustomBlockEntity(type: BlockEntityType<*>, pos: BlockPos, priva override fun tick() { if (entityUUID == null || --checkCooldown <= 0 && (level as ServerLevel).getEntity(entityUUID!!) == null) { // Kill leak entities - (level as ServerLevel).getEntities(EntityType.ITEM_DISPLAY) { it.blockPosition() == worldPosition && it.tags.contains("BLOCK") }.forEach { + (level as ServerLevel).getEntities(EntityType.ITEM_DISPLAY) { it.blockPosition() == worldPosition && it.entityTags().contains("BLOCK") }.forEach { it.kill(level as ServerLevel) } @@ -65,12 +65,12 @@ open class ModelCustomBlockEntity(type: BlockEntityType<*>, pos: BlockPos, priva override fun loadAdditional(view: ValueInput) { super.loadAdditional(view) - view.childOrEmpty("galaxy_data")?.getIntArray("model_entity")?.getOrNull()?.let { entityUUID = UUIDUtil.uuidFromIntArray(it) } + view.childOrEmpty("galaxy_data").getIntArray("model_entity").getOrNull()?.let { entityUUID = UUIDUtil.uuidFromIntArray(it) } } override fun readCopyableData(view: ValueInput) { super.readCopyableData(view) - view.childOrEmpty("galaxy_data")?.getString("facing")?.getOrNull()?.let { facing = Direction.byName(it) } + view.childOrEmpty("galaxy_data").getString("facing").getOrNull()?.let { facing = Direction.byName(it) } } override fun saveAdditional(view: ValueOutput) { @@ -80,6 +80,7 @@ open class ModelCustomBlockEntity(type: BlockEntityType<*>, pos: BlockPos, priva facing?.let { data.putString("facing", it.name) } } + @Deprecated("Deprecated in Java") override fun removeComponentsFromTag(view: ValueOutput) { val nbt = (view as TagValueOutput).buildResult().get("galaxy_data") as? CompoundTag ?: return nbt.remove("model_entity") @@ -94,7 +95,7 @@ open class ModelCustomBlockEntity(type: BlockEntityType<*>, pos: BlockPos, priva private fun spawnEntity() { val entity = Display.ItemDisplay(EntityType.ITEM_DISPLAY, level!!) - entity.itemStack = modelItem + entity.itemStack = modelItem.createItemStack() entity.snapTo(worldPosition.x + 0.5, worldPosition.y + 0.5, worldPosition.z + 0.5, facing?.toYRot() ?: 0.0F, 0.0F) entity.addTag("BLOCK") entity.addTag(getId().toString()) diff --git a/src/main/kotlin/one/oktw/galaxy/block/entity/TestGuiBlockEntity.kt b/src/main/kotlin/one/oktw/galaxy/block/entity/TestGuiBlockEntity.kt index 4fe4e10de..5ac6538eb 100644 --- a/src/main/kotlin/one/oktw/galaxy/block/entity/TestGuiBlockEntity.kt +++ b/src/main/kotlin/one/oktw/galaxy/block/entity/TestGuiBlockEntity.kt @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -31,7 +31,7 @@ import net.minecraft.world.ContainerHelper import net.minecraft.world.InteractionHand import net.minecraft.world.InteractionResult import net.minecraft.world.entity.player.Player -import net.minecraft.world.inventory.ClickType +import net.minecraft.world.inventory.ContainerInput import net.minecraft.world.inventory.MenuType import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack @@ -43,13 +43,14 @@ import net.minecraft.world.phys.BlockHitResult import one.oktw.galaxy.block.listener.CustomBlockClickListener import one.oktw.galaxy.gui.GUI import one.oktw.galaxy.gui.GUISBackStackManager +import one.oktw.galaxy.item.CustomBlockItem import one.oktw.galaxy.item.Gui import one.oktw.galaxy.item.Misc import one.oktw.galaxy.item.gui.GuiButton import one.oktw.galaxy.item.gui.GuiIcon import one.oktw.galaxy.item.gui.GuiModelBuilder -class TestGuiBlockEntity(type: BlockEntityType<*>, pos: BlockPos, modelItem: ItemStack) : ModelCustomBlockEntity(type, pos, modelItem), +class TestGuiBlockEntity(type: BlockEntityType<*>, pos: BlockPos, modelItem: CustomBlockItem) : ModelCustomBlockEntity(type, pos, modelItem), CustomBlockClickListener, Container { private val checkMarkButton = Gui( GuiModelBuilder().withButton(GuiButton.BUTTON).withIcon(GuiIcon.CHECK_MARK).build() @@ -84,11 +85,11 @@ class TestGuiBlockEntity(type: BlockEntityType<*>, pos: BlockPos, modelItem: Ite } addBinding(4, 2) { cancel = true - if (action == ClickType.PICKUP) GUISBackStackManager.openGUI(player, gui2) + if (action == ContainerInput.PICKUP) GUISBackStackManager.openGUI(player, gui2) } addBinding(2, 2) { cancel = true - if (action == ClickType.PICKUP) GUISBackStackManager.openGUI(player, gui3) + if (action == ContainerInput.PICKUP) GUISBackStackManager.openGUI(player, gui3) } } @@ -106,7 +107,7 @@ class TestGuiBlockEntity(type: BlockEntityType<*>, pos: BlockPos, modelItem: Ite } addBinding(4, 3) { cancel = true - if (action == ClickType.PICKUP) GUISBackStackManager.closeAll(player) + if (action == ContainerInput.PICKUP) GUISBackStackManager.closeAll(player) } } private val gui3 = GUI.Builder(MenuType.ANVIL) @@ -121,7 +122,7 @@ class TestGuiBlockEntity(type: BlockEntityType<*>, pos: BlockPos, modelItem: Ite } addBinding(2) { cancel = true - if (action == ClickType.PICKUP) player.sendSystemMessage(Component.literal(inputText)) + if (action == ContainerInput.PICKUP) player.sendSystemMessage(Component.literal(inputText)) } } @@ -145,6 +146,7 @@ class TestGuiBlockEntity(type: BlockEntityType<*>, pos: BlockPos, modelItem: Ite components.getOrDefault(DataComponents.CONTAINER, ItemContainerContents.EMPTY).copyInto(inventory) } + @Deprecated("Deprecated in Java") override fun removeComponentsFromTag(view: ValueOutput) { super.removeComponentsFromTag(view) view.discard("Items") diff --git a/src/main/kotlin/one/oktw/galaxy/block/entity/TrashcanBlockEntity.kt b/src/main/kotlin/one/oktw/galaxy/block/entity/TrashcanBlockEntity.kt index 3082673ec..f51ad9d37 100644 --- a/src/main/kotlin/one/oktw/galaxy/block/entity/TrashcanBlockEntity.kt +++ b/src/main/kotlin/one/oktw/galaxy/block/entity/TrashcanBlockEntity.kt @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -35,9 +35,10 @@ import net.minecraft.world.phys.BlockHitResult import one.oktw.galaxy.block.listener.CustomBlockClickListener import one.oktw.galaxy.gui.GUI import one.oktw.galaxy.gui.GUISBackStackManager +import one.oktw.galaxy.item.CustomBlockItem import one.oktw.galaxy.item.Misc -class TrashcanBlockEntity(type: BlockEntityType<*>, pos: BlockPos, modelItem: ItemStack) : Container, ModelCustomBlockEntity(type, pos, modelItem), +class TrashcanBlockEntity(type: BlockEntityType<*>, pos: BlockPos, modelItem: CustomBlockItem) : Container, ModelCustomBlockEntity(type, pos, modelItem), CustomBlockClickListener { override fun clearContent() {} diff --git a/src/main/kotlin/one/oktw/galaxy/block/event/AngelBlock.kt b/src/main/kotlin/one/oktw/galaxy/block/event/AngelBlock.kt index a26e9d692..4c5d11231 100644 --- a/src/main/kotlin/one/oktw/galaxy/block/event/AngelBlock.kt +++ b/src/main/kotlin/one/oktw/galaxy/block/event/AngelBlock.kt @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -37,10 +37,10 @@ class AngelBlock { private val usedLock = HashSet() init { - ServerTickEvents.END_WORLD_TICK.register(ServerTickEvents.EndWorldTick { + ServerTickEvents.END_LEVEL_TICK.register { justBroke.clear() usedLock.clear() - }) + } } @EventListener(sync = true) diff --git a/src/main/kotlin/one/oktw/galaxy/block/event/BlockEvents.kt b/src/main/kotlin/one/oktw/galaxy/block/event/BlockEvents.kt index 925d8d602..5699d06ea 100644 --- a/src/main/kotlin/one/oktw/galaxy/block/event/BlockEvents.kt +++ b/src/main/kotlin/one/oktw/galaxy/block/event/BlockEvents.kt @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -39,11 +39,9 @@ class BlockEvents { private val usedLock = WeakHashMap() init { - ServerTickEvents.END_WORLD_TICK.register( - ServerTickEvents.EndWorldTick { - usedLock.entries.removeIf { (_, v) -> v + 3 < it.server.tickCount } // Packet task max delay 3 tick - } - ) + ServerTickEvents.END_LEVEL_TICK.register { serverWorld -> + usedLock.entries.removeIf { (_, v) -> v + 3 < serverWorld.server.tickCount } // Packet task max delay 3 tick + } } @EventListener(true) diff --git a/src/main/kotlin/one/oktw/galaxy/chat/Exchange.kt b/src/main/kotlin/one/oktw/galaxy/chat/Exchange.kt index 5c693502b..0837d766f 100644 --- a/src/main/kotlin/one/oktw/galaxy/chat/Exchange.kt +++ b/src/main/kotlin/one/oktw/galaxy/chat/Exchange.kt @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -20,7 +20,7 @@ package one.oktw.galaxy.chat import com.google.gson.GsonBuilder import com.mojang.serialization.JsonOps -import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking.createS2CPacket +import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking.createClientboundPacket import net.minecraft.core.RegistryAccess import net.minecraft.network.chat.ComponentSerialization import one.oktw.galaxy.Main @@ -41,7 +41,7 @@ class Exchange { event.cancel = true event.player.connection.send( - createS2CPacket( + createClientboundPacket( ProxyChatPayload( MessageSend( sender = event.player.uuid, diff --git a/src/main/kotlin/one/oktw/galaxy/command/commands/Home.kt b/src/main/kotlin/one/oktw/galaxy/command/commands/Home.kt index d40b3eaec..35d2a99be 100644 --- a/src/main/kotlin/one/oktw/galaxy/command/commands/Home.kt +++ b/src/main/kotlin/one/oktw/galaxy/command/commands/Home.kt @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -36,6 +36,7 @@ import one.oktw.galaxy.Main.Companion.main import one.oktw.galaxy.command.Command import java.util.* import java.util.concurrent.TimeUnit +import kotlin.time.Duration.Companion.milliseconds class Home : Command { private val lock = HashSet() @@ -59,30 +60,30 @@ class Home : Command { // Check Stage val spawnPointPosition = player.respawnConfig?.respawnData?.pos() if (spawnPointPosition == null) { - player.displayClientMessage(Component.translatable("block.minecraft.spawn.not_valid").withStyle { it.withColor(ChatFormatting.RED) }, false) + player.sendSystemMessage(Component.translatable("block.minecraft.spawn.not_valid").withStyle { it.withColor(ChatFormatting.RED) }, false) lock -= player.uuid return com.mojang.brigadier.Command.SINGLE_SUCCESS } val teleportTarget = player.findRespawnPositionAndUseSpawnBlock(player.wonGame, TeleportTransition.DO_NOTHING) if (teleportTarget.missingRespawnBlock()) { - player.displayClientMessage(Component.translatable("block.minecraft.spawn.not_valid").withStyle { it.withColor(ChatFormatting.RED) }, false) + player.sendSystemMessage(Component.translatable("block.minecraft.spawn.not_valid").withStyle { it.withColor(ChatFormatting.RED) }, false) lock -= player.uuid } else { main?.launch { for (i in 0..4) { - player.displayClientMessage( + player.sendSystemMessage( Component.translatable("Respond.commandCountdown", 5 - i).withStyle { it.withColor(ChatFormatting.GREEN) }, true ) - delay(TimeUnit.SECONDS.toMillis(1)) + delay(TimeUnit.SECONDS.toMillis(1).milliseconds) } - player.displayClientMessage(Component.translatable("Respond.TeleportStart").withStyle { it.withColor(ChatFormatting.GREEN) }, true) + player.sendSystemMessage(Component.translatable("Respond.TeleportStart").withStyle { it.withColor(ChatFormatting.GREEN) }, true) // Check Again (Actual Teleport Stage) val realTeleportTarget = player.findRespawnPositionAndUseSpawnBlock(player.wonGame, TeleportTransition.DO_NOTHING) if (realTeleportTarget.missingRespawnBlock()) { - player.displayClientMessage(Component.translatable("block.minecraft.spawn.not_valid").withStyle { it.withColor(ChatFormatting.RED) }, false) + player.sendSystemMessage(Component.translatable("block.minecraft.spawn.not_valid").withStyle { it.withColor(ChatFormatting.RED) }, false) lock -= player.uuid return@launch } diff --git a/src/main/kotlin/one/oktw/galaxy/command/commands/Join.kt b/src/main/kotlin/one/oktw/galaxy/command/commands/Join.kt index 87af4fa42..ff6c7bb16 100644 --- a/src/main/kotlin/one/oktw/galaxy/command/commands/Join.kt +++ b/src/main/kotlin/one/oktw/galaxy/command/commands/Join.kt @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -39,6 +39,7 @@ import one.oktw.galaxy.proxy.api.packet.SearchPlayer import java.time.Duration import java.util.concurrent.CompletableFuture import java.util.concurrent.ConcurrentHashMap +import kotlin.time.Duration.Companion.milliseconds class Join : Command, CoroutineScope by CoroutineScope(Dispatchers.Default + SupervisorJob()) { private val lock = ConcurrentHashMap() @@ -102,17 +103,17 @@ class Join : Command, CoroutineScope by CoroutineScope(Dispatchers.Default + Sup if (data.uuid != targetPlayer.id) return when (data.stage) { - Queue -> sourcePlayer.displayClientMessage(Component.literal("正在等待星系載入"), false) - Creating -> sourcePlayer.displayClientMessage(Component.literal("星系載入中..."), false) - Starting -> sourcePlayer.displayClientMessage(Component.literal("星系正在啟動請稍後..."), false) + Queue -> sourcePlayer.sendSystemMessage(Component.literal("正在等待星系載入"), false) + Creating -> sourcePlayer.sendSystemMessage(Component.literal("星系載入中..."), false) + Starting -> sourcePlayer.sendSystemMessage(Component.literal("星系正在啟動請稍後..."), false) Started -> { - sourcePlayer.displayClientMessage(Component.literal("星系已載入!"), false) + sourcePlayer.sendSystemMessage(Component.literal("星系已載入!"), false) lock[sourcePlayer]?.unlock() lock.remove(sourcePlayer) } Failed -> { - sourcePlayer.displayClientMessage(Component.literal("星系載入失敗,請聯絡開發團隊!"), false) + sourcePlayer.sendSystemMessage(Component.literal("星系載入失敗,請聯絡開發團隊!"), false) lock[sourcePlayer]?.unlock() lock.remove(sourcePlayer) } @@ -120,7 +121,7 @@ class Join : Command, CoroutineScope by CoroutineScope(Dispatchers.Default + Sup } main!!.eventManager.register(ProxyResponseEvent::class, listener) - delay(Duration.ofMinutes(5).toMillis()) // TODO change to kotlin Duration + delay(Duration.ofMinutes(5).toMillis().milliseconds) main!!.eventManager.unregister(ProxyResponseEvent::class, listener) lock[sourcePlayer]?.unlock() lock.remove(sourcePlayer) diff --git a/src/main/kotlin/one/oktw/galaxy/command/commands/Spawn.kt b/src/main/kotlin/one/oktw/galaxy/command/commands/Spawn.kt index 63cc413e8..1e7e84f6a 100644 --- a/src/main/kotlin/one/oktw/galaxy/command/commands/Spawn.kt +++ b/src/main/kotlin/one/oktw/galaxy/command/commands/Spawn.kt @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -32,6 +32,7 @@ import one.oktw.galaxy.Main.Companion.main import one.oktw.galaxy.command.Command import java.util.* import java.util.concurrent.TimeUnit +import kotlin.time.Duration.Companion.milliseconds class Spawn : Command { private val lock = HashSet() @@ -56,11 +57,11 @@ class Spawn : Command { main?.launch { for (i in 0..4) { - originPlayer.displayClientMessage( + originPlayer.sendSystemMessage( Component.translatable("Respond.commandCountdown", 5 - i).withStyle { it.withColor(ChatFormatting.GREEN) }, true ) - delay(TimeUnit.SECONDS.toMillis(1)) + delay(TimeUnit.SECONDS.toMillis(1).milliseconds) } val player = originPlayer.level().server.playerList.getPlayer(originPlayer.uuid) @@ -68,13 +69,13 @@ class Spawn : Command { lock -= originPlayer.uuid return@launch } - player.displayClientMessage(Component.translatable("Respond.TeleportStart").withStyle { it.withColor(ChatFormatting.GREEN) }, true) + player.sendSystemMessage(Component.translatable("Respond.TeleportStart").withStyle { it.withColor(ChatFormatting.GREEN) }, true) val world = player.level() val type = world.dimension() if (type == Level.NETHER) { - player.displayClientMessage(Component.translatable("Respond.TeleportNothing").withStyle { it.withColor(ChatFormatting.RED) }, true) + player.sendSystemMessage(Component.translatable("Respond.TeleportNothing").withStyle { it.withColor(ChatFormatting.RED) }, true) lock -= player.uuid return@launch } diff --git a/src/main/kotlin/one/oktw/galaxy/command/commands/admin/Creative.kt b/src/main/kotlin/one/oktw/galaxy/command/commands/admin/Creative.kt index fbc92ca22..49fb16ca6 100644 --- a/src/main/kotlin/one/oktw/galaxy/command/commands/admin/Creative.kt +++ b/src/main/kotlin/one/oktw/galaxy/command/commands/admin/Creative.kt @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -27,7 +27,7 @@ import net.minecraft.network.chat.Component import net.minecraft.resources.Identifier import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Player -import net.minecraft.world.inventory.ClickType +import net.minecraft.world.inventory.ContainerInput import net.minecraft.world.inventory.MenuType import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack @@ -41,14 +41,18 @@ import one.oktw.galaxy.item.gui.GuiIcon import one.oktw.galaxy.item.gui.GuiModelBuilder class Creative { - private val previousPageButton = Gui( - GuiModelBuilder().withButton(GuiButton.BUTTON).withIcon(GuiIcon.ARROWHEAD_UP).build(), - Component.translatable("UI.Button.PreviousPage") - ).createItemStack() - private val nextPageButton = Gui( - GuiModelBuilder().withButton(GuiButton.BUTTON).withIcon(GuiIcon.ARROWHEAD_DOWN).build(), - Component.translatable("UI.Button.NextPage") - ).createItemStack() + private val previousPageButton by lazy { + Gui( + GuiModelBuilder().withButton(GuiButton.BUTTON).withIcon(GuiIcon.ARROWHEAD_UP).build(), + Component.translatable("UI.Button.PreviousPage") + ).createItemStack() + } + private val nextPageButton by lazy { + Gui( + GuiModelBuilder().withButton(GuiButton.BUTTON).withIcon(GuiIcon.ARROWHEAD_DOWN).build(), + Component.translatable("UI.Button.NextPage") + ).createItemStack() + } private fun getListGui(): GUI { val itemBrowser = CustomItemBrowser() @@ -106,24 +110,24 @@ class Creative { // Category Paging addBinding(0, 0) { cancel = true - if (action == ClickType.PICKUP) itemBrowser.previousCategory() + if (action == ContainerInput.PICKUP) itemBrowser.previousCategory() } addBinding(0, 1) { cancel = true // Cancel creative clone item } addBinding(0, 2) { cancel = true - if (action == ClickType.PICKUP) itemBrowser.nextCategory() + if (action == ContainerInput.PICKUP) itemBrowser.nextCategory() } // Handle Pages addBinding(8, 0) { cancel = true - if (action == ClickType.PICKUP) itemBrowser.previousPage() + if (action == ContainerInput.PICKUP) itemBrowser.previousPage() } addBinding(8, 2) { cancel = true - if (action == ClickType.PICKUP) itemBrowser.nextPage() + if (action == ContainerInput.PICKUP) itemBrowser.nextPage() } } } diff --git a/src/main/kotlin/one/oktw/galaxy/gui/GUI.kt b/src/main/kotlin/one/oktw/galaxy/gui/GUI.kt index 47700f0db..939c7a192 100644 --- a/src/main/kotlin/one/oktw/galaxy/gui/GUI.kt +++ b/src/main/kotlin/one/oktw/galaxy/gui/GUI.kt @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -33,7 +33,7 @@ import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.* -import net.minecraft.world.inventory.ClickType.* +import net.minecraft.world.inventory.ContainerInput.* import net.minecraft.world.inventory.MenuType.* import net.minecraft.world.item.ItemStack import net.minecraft.world.level.block.entity.BlockEntity @@ -239,7 +239,7 @@ class GUI private constructor( // Unused } - override fun clicked(slot: Int, button: Int, action: ClickType, player: Player) { + override fun clicked(slot: Int, button: Int, action: ContainerInput, player: Player) { // Trigger binding if (slot in 0 until inventory.containerSize) { inventoryUtils.indexToXY(slot).let { (x, y) -> diff --git a/src/main/kotlin/one/oktw/galaxy/gui/GUIClickEvent.kt b/src/main/kotlin/one/oktw/galaxy/gui/GUIClickEvent.kt index 97d6577af..af1e683f5 100644 --- a/src/main/kotlin/one/oktw/galaxy/gui/GUIClickEvent.kt +++ b/src/main/kotlin/one/oktw/galaxy/gui/GUIClickEvent.kt @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -19,7 +19,7 @@ package one.oktw.galaxy.gui import net.minecraft.server.level.ServerPlayer -import net.minecraft.world.inventory.ClickType +import net.minecraft.world.inventory.ContainerInput import net.minecraft.world.item.ItemStack -data class GUIClickEvent(val player: ServerPlayer, val x: Int, val y: Int, val action: ClickType, val item: ItemStack, var cancel: Boolean = false) +data class GUIClickEvent(val player: ServerPlayer, val x: Int, val y: Int, val action: ContainerInput, val item: ItemStack, var cancel: Boolean = false) diff --git a/src/main/kotlin/one/oktw/galaxy/item/CustomBlockItem.kt b/src/main/kotlin/one/oktw/galaxy/item/CustomBlockItem.kt index e855ee2ed..35c5363b8 100644 --- a/src/main/kotlin/one/oktw/galaxy/item/CustomBlockItem.kt +++ b/src/main/kotlin/one/oktw/galaxy/item/CustomBlockItem.kt @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -26,15 +26,15 @@ import one.oktw.galaxy.block.CustomBlock class CustomBlockItem private constructor(private val id: String, private val name: String?) : CustomItem(Identifier.fromNamespaceAndPath("galaxy", "block/$id"), COMMAND_BLOCK) { companion object { - val HT_CRAFTING_TABLE = registry.register(CustomBlockItem("ht_crafting_table", "block.HT_CRAFTING_TABLE")) - val ELEVATOR = registry.register(CustomBlockItem("elevator", "block.ELEVATOR")) - val ANGEL_BLOCK = registry.register(CustomBlockItem("angel_block", "block.ANGEL_BLOCK")) - val TRASHCAN = registry.register(CustomBlockItem("trashcan", "block.TRASHCAN")) - val TELEPORTER_CORE_BASIC = registry.register(CustomBlockItem("teleporter_core_basic", "block.TELEPORTER")) - val TELEPORTER_CORE_ADVANCE = registry.register(CustomBlockItem("teleporter_core_advance", "block.TELEPORTER_ADVANCED")) - val TELEPORTER_FRAME = registry.register(CustomBlockItem("teleporter_frame", "block.TELEPORTER_FRAME")) - val TEST_GUI = registry.register(CustomBlockItem("test_gui", "block.TEST_GUI")) - val HARVEST = registry.register(CustomBlockItem("harvest", "block.HARVEST")) + val HT_CRAFTING_TABLE = registry.register(CustomBlockItem("ht_crafting_table", "block.HT_CRAFTING_TABLE")) as CustomBlockItem + val ELEVATOR = registry.register(CustomBlockItem("elevator", "block.ELEVATOR")) as CustomBlockItem + val ANGEL_BLOCK = registry.register(CustomBlockItem("angel_block", "block.ANGEL_BLOCK")) as CustomBlockItem + val TRASHCAN = registry.register(CustomBlockItem("trashcan", "block.TRASHCAN")) as CustomBlockItem + val TELEPORTER_CORE_BASIC = registry.register(CustomBlockItem("teleporter_core_basic", "block.TELEPORTER")) as CustomBlockItem + val TELEPORTER_CORE_ADVANCE = registry.register(CustomBlockItem("teleporter_core_advance", "block.TELEPORTER_ADVANCED")) as CustomBlockItem + val TELEPORTER_FRAME = registry.register(CustomBlockItem("teleporter_frame", "block.TELEPORTER_FRAME")) as CustomBlockItem + val TEST_GUI = registry.register(CustomBlockItem("test_gui", "block.TEST_GUI")) as CustomBlockItem + val HARVEST = registry.register(CustomBlockItem("harvest", "block.HARVEST")) as CustomBlockItem } fun getBlock(): CustomBlock { diff --git a/src/main/kotlin/one/oktw/galaxy/item/recipe/CustomItemRecipe.kt b/src/main/kotlin/one/oktw/galaxy/item/recipe/CustomItemRecipe.kt index 4e29c3c0f..4152c31a6 100644 --- a/src/main/kotlin/one/oktw/galaxy/item/recipe/CustomItemRecipe.kt +++ b/src/main/kotlin/one/oktw/galaxy/item/recipe/CustomItemRecipe.kt @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -148,7 +148,7 @@ abstract class CustomItemRecipe { // TODO Translate val lore = listOf( Component.literal("Accept:").withStyle { it.withColor(ChatFormatting.AQUA).withBold(true).withItalic(false) }, - *items.map { item -> item.name.copy().withStyle { it.withColor(ChatFormatting.WHITE).withItalic(false) } }.toTypedArray() + *items.map { item -> item.getName(item.defaultInstance).copy().withStyle { it.withColor(ChatFormatting.WHITE).withItalic(false) } }.toTypedArray() ) items.map { it.defaultInstance.copyWithCount(count).apply { set(LORE, ItemLore(lore)) } } diff --git a/src/main/kotlin/one/oktw/galaxy/player/Harvest.kt b/src/main/kotlin/one/oktw/galaxy/player/Harvest.kt index 314521bdd..67882616a 100644 --- a/src/main/kotlin/one/oktw/galaxy/player/Harvest.kt +++ b/src/main/kotlin/one/oktw/galaxy/player/Harvest.kt @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2025 + * Copyright (C) 2018-2026 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -32,7 +32,7 @@ class Harvest { private val justHarvested = HashSet() init { - ServerTickEvents.END_WORLD_TICK.register(ServerTickEvents.EndWorldTick { justHarvested.clear() }) + ServerTickEvents.END_LEVEL_TICK.register { justHarvested.clear() } } @EventListener(true) diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 52f62a0b2..944e1b8e3 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -29,9 +29,9 @@ "accessor.mixin.json" ], "depends": { - "minecraft": "1.21.x", - "fabricloader": ">=0.15.11", - "fabric": ">=0.83.0" + "minecraft": "26.x", + "fabricloader": ">=0.19.1", + "fabric-api": ">=0.145.4" }, "suggests": {} } diff --git a/src/main/resources/galaxy.accesswidener b/src/main/resources/galaxy.accesswidener index 18b3b61a2..f2b17a997 100644 --- a/src/main/resources/galaxy.accesswidener +++ b/src/main/resources/galaxy.accesswidener @@ -1,4 +1,4 @@ -accessWidener v1 named +accessWidener v2 official # CloneCommand accessible class net/minecraft/server/commands/CloneCommands$Mode @@ -8,3 +8,6 @@ accessible class net/minecraft/server/commands/CloneCommands$CloneBlockInf accessible class net/minecraft/world/level/chunk/storage/IOWorker$Priority accessible field net/minecraft/world/level/chunk/storage/IOWorker$PendingStore data Lnet/minecraft/nbt/CompoundTag; accessible method net/minecraft/world/level/chunk/storage/IOWorker$PendingStore copyData ()Lnet/minecraft/nbt/CompoundTag; + +# Realtime ServerClockManagerMixin +accessible class net/minecraft/world/clock/ServerClockManager$ClockInstance diff --git a/src/main/resources/sponge.realtime.mixin.json b/src/main/resources/sponge.realtime.mixin.json index ce37e14b4..774f7f1de 100644 --- a/src/main/resources/sponge.realtime.mixin.json +++ b/src/main/resources/sponge.realtime.mixin.json @@ -21,6 +21,7 @@ "server.network.ServerGamePacketListenerMixin_RealTime", "server.network.ServerPlayerGameModeMixin_RealTime", "world.ServerLevelMixin_RealTime", + "world.ServerClockManagerMixin_RealTime", "world.dimension.PortalProcessorMixin_RealTime" ], "server": [ diff --git a/src/main/resources/tweak.mixin.json b/src/main/resources/tweak.mixin.json index 520e48c8b..e96c49e79 100644 --- a/src/main/resources/tweak.mixin.json +++ b/src/main/resources/tweak.mixin.json @@ -10,6 +10,7 @@ "MixinCustomBlockEntity_BarrierBlock", "MixinCustomBlockEntity_ClientboundLevelChunkPacketData", "MixinCustomBlockEntity_StructureTemplate", + "MixinDisableHardLink_FileFixerUpper", "MixinFixBeacon_BeaconBlockEntity", "MixinGlobalDataPack_ServerPacksSource", "MixinGUI_ServerGamePacketListener",