diff --git a/build.gradle.kts b/build.gradle.kts
index 869545a73..09ebb2f63 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -4,15 +4,15 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
// "maven-publish"
- kotlin("jvm") version "2.0.10"
- id("fabric-loom") version "1.7-SNAPSHOT"
+ kotlin("jvm") version "2.0.21"
+ id("fabric-loom") version "1.8-SNAPSHOT"
}
val version = "0.0.1"
val group = "one.oktw"
-val fabricVersion = "0.102.1+1.21.1"
-val galaxyLibVersion = "7376fcdf"
+val fabricVersion = "0.108.0+1.21.3"
+val galaxyLibVersion = "c328418"
repositories {
mavenCentral()
@@ -42,9 +42,9 @@ loom {
dependencies {
// Core
- minecraft(group = "com.mojang", name = "minecraft", version = "1.21.1")
- mappings(group = "net.fabricmc", name = "yarn", version = "1.21.1+build.3", classifier = "v2")
- modImplementation(group = "net.fabricmc", name = "fabric-loader", version = "0.15.11")
+ minecraft(group = "com.mojang", name = "minecraft", version = "1.21.3")
+ mappings(group = "net.fabricmc", name = "yarn", version = "1.21.3+build.2", classifier = "v2")
+ modImplementation(group = "net.fabricmc", name = "fabric-loader", version = "0.16.9")
// fabric api
modImplementation(group = "net.fabricmc.fabric-api", name = "fabric-api", version = fabricVersion) {
diff --git a/docker b/docker
index 61954b2cd..f92d0ae1b 160000
--- a/docker
+++ b/docker
@@ -1 +1 @@
-Subproject commit 61954b2cd9a65a0c8c9d3dbcf15132cdb498075e
+Subproject commit f92d0ae1b774fb8b9445f018ca6ea8b4e65beb3a
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 2c3521197..a4b76b953 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 09523c0e5..df97d72b8 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-8.9-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
diff --git a/src/main/java/one/oktw/galaxy/mixin/accessor/SerializingRegionBasedStorageAccessor.java b/src/main/java/one/oktw/galaxy/mixin/accessor/SerializingRegionBasedStorageAccessor.java
deleted file mode 100644
index 2e7193223..000000000
--- a/src/main/java/one/oktw/galaxy/mixin/accessor/SerializingRegionBasedStorageAccessor.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * OKTW Galaxy Project
- * Copyright (C) 2018-2024
- *
- * 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.accessor;
-
-import net.minecraft.nbt.NbtCompound;
-import net.minecraft.nbt.NbtElement;
-import net.minecraft.registry.RegistryOps;
-import net.minecraft.util.math.ChunkPos;
-import net.minecraft.world.poi.PointOfInterestSet;
-import net.minecraft.world.storage.SerializingRegionBasedStorage;
-import org.jetbrains.annotations.Nullable;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.gen.Invoker;
-
-import java.util.Optional;
-import java.util.concurrent.CompletableFuture;
-
-@Mixin(SerializingRegionBasedStorage.class)
-public interface SerializingRegionBasedStorageAccessor {
- @Invoker
- @Nullable
- Optional callGetIfLoaded(long pos);
-
- @Invoker
- CompletableFuture> callLoadNbt(ChunkPos pos);
-
- @Invoker
- void callUpdate(ChunkPos pos, RegistryOps ops, @Nullable NbtCompound nbt);
-}
diff --git a/src/main/java/one/oktw/galaxy/mixin/interfaces/CustomRecipeManager.java b/src/main/java/one/oktw/galaxy/mixin/interfaces/CustomRecipeManager.java
deleted file mode 100644
index 77963f3c4..000000000
--- a/src/main/java/one/oktw/galaxy/mixin/interfaces/CustomRecipeManager.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * OKTW Galaxy Project
- * Copyright (C) 2018-2023
- *
- * 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.interfaces;
-
-import net.minecraft.recipe.Recipe;
-import net.minecraft.recipe.RecipeEntry;
-import net.minecraft.recipe.RecipeType;
-import net.minecraft.util.Identifier;
-
-import java.util.HashMap;
-
-public interface CustomRecipeManager {
- HashMap, HashMap>> customRecipes = new HashMap<>();
-
- static void addRecipe(RecipeType> type, Identifier id, Recipe> recipe) {
- customRecipes.computeIfAbsent(type, k -> new HashMap<>()).put(id, new RecipeEntry>(id, recipe));
- }
-}
diff --git a/src/main/java/one/oktw/galaxy/mixin/recipe/MixinCustomRecipe_CraftingResultSlot.java b/src/main/java/one/oktw/galaxy/mixin/recipe/MixinCustomRecipe_CraftingResultSlot.java
deleted file mode 100644
index 910a23ea2..000000000
--- a/src/main/java/one/oktw/galaxy/mixin/recipe/MixinCustomRecipe_CraftingResultSlot.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * OKTW Galaxy Project
- * Copyright (C) 2018-2021
- *
- * 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.recipe;
-
-import net.minecraft.entity.player.PlayerEntity;
-import net.minecraft.item.ItemStack;
-import net.minecraft.network.packet.s2c.play.InventoryS2CPacket;
-import net.minecraft.screen.ScreenHandler;
-import net.minecraft.screen.slot.CraftingResultSlot;
-import net.minecraft.server.network.ServerPlayerEntity;
-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.CallbackInfo;
-
-@Mixin(CraftingResultSlot.class)
-public class MixinCustomRecipe_CraftingResultSlot {
- @Inject(method = "onTakeItem", at = @At("RETURN"))
- private void consumeInput(PlayerEntity player, ItemStack stack, CallbackInfo ci) {
- ScreenHandler handler = player.currentScreenHandler;
- ((ServerPlayerEntity) player).networkHandler.sendPacket(
- new InventoryS2CPacket(handler.syncId, handler.nextRevision(), handler.getStacks(), handler.getCursorStack().copy())
- );
- }
-}
diff --git a/src/main/java/one/oktw/galaxy/mixin/recipe/MixinCustomRecipe_RecipeManager.java b/src/main/java/one/oktw/galaxy/mixin/recipe/MixinCustomRecipe_RecipeManager.java
deleted file mode 100644
index 90647e878..000000000
--- a/src/main/java/one/oktw/galaxy/mixin/recipe/MixinCustomRecipe_RecipeManager.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * OKTW Galaxy Project
- * Copyright (C) 2018-2024
- *
- * 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.recipe;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableMultimap;
-import com.google.gson.JsonElement;
-import net.minecraft.recipe.RecipeEntry;
-import net.minecraft.recipe.RecipeManager;
-import net.minecraft.recipe.RecipeType;
-import net.minecraft.registry.RegistryOps;
-import net.minecraft.resource.ResourceManager;
-import net.minecraft.util.Identifier;
-import net.minecraft.util.profiler.Profiler;
-import one.oktw.galaxy.mixin.interfaces.CustomRecipeManager;
-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.CallbackInfo;
-import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
-
-import java.util.Map;
-
-@Mixin(RecipeManager.class)
-public class MixinCustomRecipe_RecipeManager implements CustomRecipeManager {
- @Inject(method = "apply(Ljava/util/Map;Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/util/profiler/Profiler;)V", at = @At(value = "INVOKE", target = "Ljava/util/Map;entrySet()Ljava/util/Set;", ordinal = 0), locals = LocalCapture.CAPTURE_FAILSOFT)
- private void recipeLoad(Map map, ResourceManager resourceManager, Profiler profiler, CallbackInfo ci, ImmutableMultimap.Builder, RecipeEntry>> builder, ImmutableMap.Builder> builder2, RegistryOps registryOps) {
- customRecipes.forEach((type, recipeEntryHashMap) -> builder.putAll(type, recipeEntryHashMap.values()));
- customRecipes.forEach((type, recipeEntryHashMap) -> builder2.putAll(recipeEntryHashMap));
- }
-}
diff --git a/src/main/java/one/oktw/galaxy/mixin/tweak/MixinAsyncChunk_ChunkPosDistanceLevelPropagator.java b/src/main/java/one/oktw/galaxy/mixin/tweak/MixinAsyncChunk_ChunkPosDistanceLevelPropagator.java
deleted file mode 100644
index 08f353fa7..000000000
--- a/src/main/java/one/oktw/galaxy/mixin/tweak/MixinAsyncChunk_ChunkPosDistanceLevelPropagator.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * OKTW Galaxy Project
- * Copyright (C) 2018-2023
- *
- * 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.math.ChunkPos;
-import net.minecraft.world.ChunkPosDistanceLevelPropagator;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Redirect;
-
-@Mixin(ChunkPosDistanceLevelPropagator.class)
-public abstract class MixinAsyncChunk_ChunkPosDistanceLevelPropagator {
- @Redirect(method = "propagateLevel", at = @At(value = "NEW", target = "(J)Lnet/minecraft/util/math/ChunkPos;"))
- private ChunkPos skipCreateChunkPos(long pos) {
- return ChunkPos.ORIGIN;
- }
-
- @Redirect(method = "propagateLevel", at = @At(value = "FIELD", target = "Lnet/minecraft/util/math/ChunkPos;x:I"))
- private int getX(ChunkPos instance, long pos, int level, boolean decrease) {
- return (int) pos;
- }
-
- @Redirect(method = "propagateLevel", at = @At(value = "FIELD", target = "Lnet/minecraft/util/math/ChunkPos;z:I"))
- private int getZ(ChunkPos instance, long pos, int level, boolean decrease) {
- return (int) (pos >> 32);
- }
-
- @Redirect(method = "recalculateLevel", at = @At(value = "NEW", target = "(J)Lnet/minecraft/util/math/ChunkPos;"))
- private ChunkPos skipCreateChunkPos2(long pos) {
- return ChunkPos.ORIGIN;
- }
-
- @Redirect(method = "recalculateLevel", at = @At(value = "FIELD", target = "Lnet/minecraft/util/math/ChunkPos;x:I"))
- private int getX2(ChunkPos instance, long pos, long excludedId, int maxLevel) {
- return (int) pos;
- }
-
- @Redirect(method = "recalculateLevel", at = @At(value = "FIELD", target = "Lnet/minecraft/util/math/ChunkPos;z:I"))
- private int getZ2(ChunkPos instance, long pos, long excludedId, int maxLevel) {
- return (int) (pos >> 32);
- }
-}
diff --git a/src/main/java/one/oktw/galaxy/mixin/tweak/MixinAsyncChunk_RegionBasedStorage.java b/src/main/java/one/oktw/galaxy/mixin/tweak/MixinAsyncChunk_RegionBasedStorage.java
deleted file mode 100644
index 9ffb467d9..000000000
--- a/src/main/java/one/oktw/galaxy/mixin/tweak/MixinAsyncChunk_RegionBasedStorage.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * OKTW Galaxy Project
- * Copyright (C) 2018-2021
- *
- * 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.math.ChunkPos;
-import net.minecraft.world.storage.RegionBasedStorage;
-import net.minecraft.world.storage.RegionFile;
-import one.oktw.galaxy.mixin.interfaces.RegionFileInputStream;
-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.Redirect;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
-
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.util.concurrent.locks.ReentrantLock;
-
-@Mixin(RegionBasedStorage.class)
-public abstract class MixinAsyncChunk_RegionBasedStorage {
- private final ReentrantLock lock = new ReentrantLock();
-
- @Inject(method = "getRegionFile", at = @At("HEAD"))
- private void readLock(ChunkPos pos, CallbackInfoReturnable cir) {
- lock.lock();
- }
-
- @Inject(method = "getRegionFile", at = @At("RETURN"))
- private void readUnlock(ChunkPos pos, CallbackInfoReturnable cir) {
- lock.unlock();
- }
-
- @Inject(method = "close", at = @At("HEAD"))
- private void closeLock(CallbackInfo ci) {
- lock.lock();
- }
-
- @Inject(method = "close", at = @At("RETURN"))
- private void closeUnlock(CallbackInfo ci) {
- lock.unlock();
- }
-
- @Inject(method = "sync", at = @At("HEAD"))
- private void syncLock(CallbackInfo ci) {
- lock.lock();
- }
-
- @Inject(method = "sync", at = @At("RETURN"))
- private void syncUnlock(CallbackInfo ci) {
- lock.unlock();
- }
-
- @Redirect(method = "getTagAt", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/storage/RegionFile;getChunkInputStream(Lnet/minecraft/util/math/ChunkPos;)Ljava/io/DataInputStream;"))
- private DataInputStream overwriteGetIntputStream(RegionFile regionFile, ChunkPos pos) throws IOException {
- return ((RegionFileInputStream) regionFile).getChunkInputStreamNoSync(pos);
- }
-}
diff --git a/src/main/java/one/oktw/galaxy/mixin/tweak/MixinAsyncChunk_RegionFile.java b/src/main/java/one/oktw/galaxy/mixin/tweak/MixinAsyncChunk_RegionFile.java
deleted file mode 100644
index f35f5fd50..000000000
--- a/src/main/java/one/oktw/galaxy/mixin/tweak/MixinAsyncChunk_RegionFile.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * OKTW Galaxy Project
- * Copyright (C) 2018-2023
- *
- * 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.math.ChunkPos;
-import net.minecraft.world.storage.RegionFile;
-import one.oktw.galaxy.mixin.interfaces.RegionFileInputStream;
-import org.jetbrains.annotations.Nullable;
-import org.slf4j.Logger;
-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.asm.mixin.injection.callback.CallbackInfoReturnable;
-
-import java.io.ByteArrayInputStream;
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.ByteBuffer;
-import java.nio.channels.FileChannel;
-import java.util.concurrent.locks.ReentrantLock;
-
-@Mixin(RegionFile.class)
-public abstract class MixinAsyncChunk_RegionFile implements RegionFileInputStream {
- private final ReentrantLock lock = new ReentrantLock();
-
- @Shadow
- @Final
- private static Logger LOGGER;
-
- @Shadow
- @Final
- private FileChannel channel;
-
- @Shadow
- protected abstract int getSectorData(ChunkPos pos);
-
- @Shadow
- private static int getOffset(int sectorData) {
- return 0;
- }
-
- @Shadow
- private static int getSize(int sectorData) {
- return 0;
- }
-
- @Shadow
- private static boolean hasChunkStreamVersionId(byte b) {
- return false;
- }
-
- @Shadow
- private static byte getChunkStreamVersionId(byte b) {
- return 0;
- }
-
- @Shadow
- private static ByteArrayInputStream getInputStream(ByteBuffer buffer, int length) {
- return null;
- }
-
- @Shadow
- @Nullable
- protected abstract DataInputStream getInputStream(ChunkPos chunkPos, byte b) throws IOException;
-
- @Shadow
- @Nullable
- protected abstract DataInputStream decompress(ChunkPos chunkPos, byte b, InputStream inputStream) throws IOException;
-
- @Inject(method = "delete", at = @At("HEAD"))
- private void deleteLock(ChunkPos chunkPos, CallbackInfo ci) {
- lock.lock();
- }
-
- @Inject(method = "delete", at = @At("RETURN"))
- private void deleteUnlock(ChunkPos chunkPos, CallbackInfo ci) {
- lock.unlock();
- }
-
- @Inject(method = "writeChunk", at = @At("HEAD"))
- private void writeChunkLock(ChunkPos pos, ByteBuffer byteBuffer, CallbackInfo ci) {
- lock.lock();
- }
-
- @Inject(method = "writeChunk", at = @At("RETURN"))
- private void writeChunkUnlock(ChunkPos pos, ByteBuffer byteBuffer, CallbackInfo ci) {
- lock.unlock();
- }
-
- @Inject(method = "getSectorData", at = @At("HEAD"))
- private void getSectorDataLock(ChunkPos pos, CallbackInfoReturnable cir) {
- lock.lock();
- }
-
- @Inject(method = "getSectorData", at = @At("RETURN"))
- private void getSectorDataUnlock(ChunkPos pos, CallbackInfoReturnable cir) {
- lock.unlock();
- }
-
- // Remove synchronized.
- @Override
- public DataInputStream getChunkInputStreamNoSync(ChunkPos pos) throws IOException {
- int i = getSectorData(pos);
- if (i == 0) return null;
- int start = getOffset(i);
- int count = getSize(i);
- int length = count * 4096;
- ByteBuffer byteBuffer = ByteBuffer.allocate(length);
- channel.read(byteBuffer, start * 4096L);
- byteBuffer.flip();
- if (byteBuffer.remaining() < 5) {
- LOGGER.error("Chunk {} header is truncated: expected {} but read {}", pos, length, byteBuffer.remaining());
- return null;
- }
- int m = byteBuffer.getInt();
- byte b = byteBuffer.get();
- if (m == 0) {
- LOGGER.warn("Chunk {} is allocated, but stream is missing", pos);
- return null;
- }
- int n = m - 1;
- if (hasChunkStreamVersionId(b)) {
- if (n != 0) LOGGER.warn("Chunk has both internal and external streams");
- return getInputStream(pos, getChunkStreamVersionId(b));
- }
- if (n > byteBuffer.remaining()) {
- LOGGER.error("Chunk {} stream is truncated: expected {} but read {}", pos, n, byteBuffer.remaining());
- return null;
- }
- if (n < 0) {
- LOGGER.error("Declared size {} of chunk {} is negative", m, pos);
- return null;
- }
- return decompress(pos, b, getInputStream(byteBuffer, n));
- }
-}
diff --git a/src/main/java/one/oktw/galaxy/mixin/tweak/MixinAsyncChunk_ServerChunkLoadingManager.java b/src/main/java/one/oktw/galaxy/mixin/tweak/MixinAsyncChunk_ServerChunkLoadingManager.java
deleted file mode 100644
index c721c719f..000000000
--- a/src/main/java/one/oktw/galaxy/mixin/tweak/MixinAsyncChunk_ServerChunkLoadingManager.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * OKTW Galaxy Project
- * Copyright (C) 2018-2024
- *
- * 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 com.mojang.datafixers.DataFixer;
-import net.minecraft.nbt.NbtCompound;
-import net.minecraft.nbt.NbtElement;
-import net.minecraft.nbt.NbtOps;
-import net.minecraft.registry.RegistryOps;
-import net.minecraft.server.world.ServerChunkLoadingManager;
-import net.minecraft.server.world.ServerWorld;
-import net.minecraft.util.math.ChunkPos;
-import net.minecraft.util.thread.ThreadExecutor;
-import net.minecraft.world.ChunkSerializer;
-import net.minecraft.world.chunk.Chunk;
-import net.minecraft.world.chunk.ChunkType;
-import net.minecraft.world.chunk.ProtoChunk;
-import net.minecraft.world.poi.PointOfInterestSet;
-import net.minecraft.world.poi.PointOfInterestStorage;
-import net.minecraft.world.storage.StorageKey;
-import net.minecraft.world.storage.VersionedChunkStorage;
-import one.oktw.galaxy.mixin.accessor.SerializingRegionBasedStorageAccessor;
-import org.slf4j.Logger;
-import org.spongepowered.asm.mixin.Final;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.Overwrite;
-import org.spongepowered.asm.mixin.Shadow;
-
-import java.nio.file.Path;
-import java.util.HashMap;
-import java.util.Optional;
-import java.util.concurrent.CompletableFuture;
-
-@Mixin(ServerChunkLoadingManager.class)
-public abstract class MixinAsyncChunk_ServerChunkLoadingManager extends VersionedChunkStorage {
- private final HashMap> poiFutures = new HashMap<>();
-
- @Shadow
- @Final
- private static Logger LOGGER;
- @Shadow
- @Final
- ServerWorld world;
- @Shadow
- @Final
- private PointOfInterestStorage pointOfInterestStorage;
- @Shadow
- @Final
- private ThreadExecutor mainThreadExecutor;
-
- public MixinAsyncChunk_ServerChunkLoadingManager(StorageKey storageKey, Path directory, DataFixer dataFixer, boolean dsync) {
- super(storageKey, directory, dataFixer, dsync);
- }
-
- @Shadow
- private static boolean containsStatus(NbtCompound nbt) {
- return false;
- }
-
- @Shadow
- protected abstract CompletableFuture> getUpdatedChunkNbt(ChunkPos chunkPos);
-
- @Shadow
- protected abstract Chunk getProtoChunk(ChunkPos chunkPos);
-
- @Shadow
- protected abstract byte mark(ChunkPos pos, ChunkType type);
-
- @Shadow
- protected abstract Chunk recoverFromException(Throwable throwable, ChunkPos chunkPos);
-
- /**
- * @author James58899
- * @reason Async POI loading
- */
- @Overwrite
- private CompletableFuture loadChunk(ChunkPos pos) {
- CompletableFuture> chunkNbtFuture = this.getUpdatedChunkNbt(pos).thenApply(nbt -> nbt.filter(nbt2 -> {
- boolean bl = containsStatus(nbt2);
- if (!bl) {
- LOGGER.error("Chunk file at {} is missing level data, skipping", pos);
- }
- return bl;
- }));
- SerializingRegionBasedStorageAccessor poiStorage = ((SerializingRegionBasedStorageAccessor) pointOfInterestStorage);
- Optional poiData = poiStorage.callGetIfLoaded(pos.toLong());
- var poiFuture = CompletableFuture.completedFuture(null);
- //noinspection OptionalAssignedToNull
- if (poiData == null || poiData.isEmpty()) {
- if (poiFutures.containsKey(pos)) {
- poiFuture = poiFutures.get(pos);
- } else {
- poiFuture = ((SerializingRegionBasedStorageAccessor) pointOfInterestStorage).callLoadNbt(pos).thenAcceptAsync(nbt -> {
- RegistryOps registryOps = RegistryOps.of(NbtOps.INSTANCE, world.getRegistryManager());
- poiStorage.callUpdate(pos, registryOps, nbt.orElse(null));
- }, this.mainThreadExecutor);
- poiFutures.put(pos, poiFuture);
- }
- }
- return CompletableFuture.allOf(chunkNbtFuture, poiFuture).thenApplyAsync(unused -> {
- poiFutures.remove(pos);
- var nbt = chunkNbtFuture.join();
- this.world.getProfiler().visit("chunkLoad");
- if (nbt.isPresent()) {
- ProtoChunk chunk = ChunkSerializer.deserialize(this.world, this.pointOfInterestStorage, this.getStorageKey(), pos, nbt.get());
- this.mark(pos, ((Chunk) chunk).getStatus().getChunkType());
- return chunk;
- }
- return this.getProtoChunk(pos);
- }, this.mainThreadExecutor).exceptionallyAsync(throwable -> this.recoverFromException(throwable, pos), this.mainThreadExecutor);
- }
-}
diff --git a/src/main/java/one/oktw/galaxy/mixin/tweak/MixinAsyncChunk_ServerChunkManager.java b/src/main/java/one/oktw/galaxy/mixin/tweak/MixinAsyncChunk_ServerChunkManager.java
deleted file mode 100644
index c24677d4c..000000000
--- a/src/main/java/one/oktw/galaxy/mixin/tweak/MixinAsyncChunk_ServerChunkManager.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * OKTW Galaxy Project
- * Copyright (C) 2018-2024
- *
- * 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.server.world.*;
-import net.minecraft.util.math.ChunkPos;
-import net.minecraft.world.chunk.ChunkStatus;
-import net.minecraft.world.chunk.WorldChunk;
-import one.oktw.galaxy.mixin.accessor.ServerChunkLoadingManagerAccessor;
-import org.jetbrains.annotations.Nullable;
-import org.spongepowered.asm.mixin.Final;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.Overwrite;
-import org.spongepowered.asm.mixin.Shadow;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Redirect;
-
-import java.util.stream.Collectors;
-import java.util.stream.StreamSupport;
-
-@Mixin(ServerChunkManager.class)
-public abstract class MixinAsyncChunk_ServerChunkManager {
- @Shadow
- @Final
- ServerWorld world;
-
- @Shadow
- @Nullable
- protected abstract ChunkHolder getChunkHolder(long pos);
-
- @Shadow
- protected abstract boolean isMissingForLevel(@Nullable ChunkHolder holder, int maxLevel);
-
- /**
- * @author James58899
- * @reason Use static ChunkPos.toLong
- */
- @Overwrite
- public boolean isChunkLoaded(int x, int z) {
- return !this.isMissingForLevel(this.getChunkHolder(ChunkPos.toLong(x, z)), ChunkLevels.getLevelFromStatus(ChunkStatus.FULL));
- }
-
- @Redirect(method = "tickChunks", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/world/ServerChunkLoadingManager;entryIterator()Ljava/lang/Iterable;"))
- private Iterable earlyCheckChunkShouldTick(ServerChunkLoadingManager instance) {
- ServerChunkLoadingManagerAccessor accessor = (ServerChunkLoadingManagerAccessor) instance;
- var stream = StreamSupport.stream(accessor.callEntryIterator().spliterator(), false);
- return stream.filter(chunkHolder -> {
- WorldChunk chunk = chunkHolder.getWorldChunk();
- if (chunk == null) return false;
- ChunkPos pos = chunk.getPos();
- return world.shouldTick(pos) && accessor.callShouldTick(pos);
- }).collect(Collectors.toList());
- }
-
- @Redirect(method = "tickChunks", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/world/ServerWorld;shouldTick(Lnet/minecraft/util/math/ChunkPos;)Z"))
- private boolean skipDupTickCheck(ServerWorld instance, ChunkPos pos) {
- return true;
- }
-
- @Redirect(method = "tickChunks", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/world/ServerChunkLoadingManager;shouldTick(Lnet/minecraft/util/math/ChunkPos;)Z"))
- private boolean skipDupTickCheck(ServerChunkLoadingManager instance, ChunkPos pos) {
- return true;
- }
-}
diff --git a/src/main/java/one/oktw/galaxy/mixin/tweak/MixinAsyncChunk_ServerPlayNetworkHandler.java b/src/main/java/one/oktw/galaxy/mixin/tweak/MixinAsyncChunk_ServerPlayNetworkHandler.java
index 5798022f6..c06255fea 100644
--- a/src/main/java/one/oktw/galaxy/mixin/tweak/MixinAsyncChunk_ServerPlayNetworkHandler.java
+++ b/src/main/java/one/oktw/galaxy/mixin/tweak/MixinAsyncChunk_ServerPlayNetworkHandler.java
@@ -18,6 +18,7 @@
package one.oktw.galaxy.mixin.tweak;
+import net.minecraft.entity.player.PlayerPosition;
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
import net.minecraft.network.packet.s2c.play.PositionFlag;
import net.minecraft.server.network.ServerPlayNetworkHandler;
@@ -60,8 +61,8 @@ private void noBlockingMove(PlayerMoveC2SPacket packet, CallbackInfo ci) {
}
}
- @Inject(method = "requestTeleport(DDDFFLjava/util/Set;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;updatePositionAndAngles(DDDFF)V", shift = At.Shift.AFTER))
- private void onTeleport(double x, double y, double z, float yaw, float pitch, Set set, CallbackInfo ci) {
+ @Inject(method = "requestTeleport(Lnet/minecraft/entity/player/PlayerPosition;Ljava/util/Set;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;setPosition(Lnet/minecraft/entity/player/PlayerPosition;Ljava/util/Set;)V", shift = At.Shift.AFTER))
+ private void onTeleport(PlayerPosition pos, Set flags, CallbackInfo ci) {
ServerWorld world = player.getServerWorld();
if (!world.getPlayers().contains(player)) return;
world.getChunkManager().updatePosition(this.player);
diff --git a/src/main/java/one/oktw/galaxy/mixin/tweak/MixinAsyncChunk_StorageIoWorker.java b/src/main/java/one/oktw/galaxy/mixin/tweak/MixinAsyncChunk_StorageIoWorker.java
deleted file mode 100644
index bc02ce311..000000000
--- a/src/main/java/one/oktw/galaxy/mixin/tweak/MixinAsyncChunk_StorageIoWorker.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * OKTW Galaxy Project
- * Copyright (C) 2018-2024
- *
- * 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.nbt.NbtCompound;
-import net.minecraft.util.Pair;
-import net.minecraft.util.math.ChunkPos;
-import net.minecraft.util.thread.TaskExecutor;
-import net.minecraft.util.thread.TaskQueue;
-import net.minecraft.world.storage.StorageIoWorker;
-import net.minecraft.world.storage.StorageIoWorker.Priority;
-import net.minecraft.world.storage.StorageKey;
-import one.oktw.galaxy.util.KotlinCoroutineTaskExecutor;
-import org.jetbrains.annotations.Nullable;
-import org.spongepowered.asm.mixin.*;
-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;
-
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-@Mixin(StorageIoWorker.class)
-public abstract class MixinAsyncChunk_StorageIoWorker {
- private final AtomicBoolean writeLock = new AtomicBoolean(false);
-
- @Mutable
- @Shadow
- @Final
- private TaskExecutor executor;
-
- @Mutable
- @Shadow
- @Final
- private Map results;
-
- @Shadow
- protected abstract void write(ChunkPos pos, StorageIoWorker.Result result);
-
- @Inject(method = "", at = @At("RETURN"))
- private void parallelExecutor(StorageKey storageKey, Path directory, boolean dsync, CallbackInfo ci) {
- results = new ConcurrentHashMap<>();
- executor = new KotlinCoroutineTaskExecutor<>(new TaskQueue.Prioritized(4 /* FOREGROUND,BACKGROUND,WRITE_DONE,SHUTDOWN */), "IOWorker-" + storageKey.type());
- }
-
- /**
- * @author James58899
- * @reason no low priority write & bulk write
- */
- @Overwrite
- private void writeResult() {
- if (!this.results.isEmpty() && !writeLock.getAndSet(true)) {
- HashMap>> map = new HashMap<>();
- results.forEach((pos, result) -> map.computeIfAbsent(ChunkPos.toLong(pos.getRegionX(), pos.getRegionZ()), k -> new ArrayList<>()).add(new Pair<>(pos, result)));
- map.values().forEach(list ->
- executor.send(new TaskQueue.PrioritizedTask(Priority.FOREGROUND.ordinal(), () -> list.forEach(pair -> write(pair.getLeft(), pair.getRight()))))
- );
- this.executor.send(new TaskQueue.PrioritizedTask(Priority.BACKGROUND.ordinal(), () -> {
- writeLock.set(false);
- writeResult();
- }));
- }
- }
-
- /**
- * @author James58899
- * @reason no low priority write
- */
- @Overwrite
- private void writeRemainingResults() {
- writeResult();
- }
-
- /**
- * @author James58899
- * @reason no delay set result
- */
- @Overwrite
- public CompletableFuture setResult(ChunkPos pos, @Nullable NbtCompound nbt) {
- StorageIoWorker.Result result = this.results.computeIfAbsent(pos, pos2 -> new StorageIoWorker.Result(nbt));
- result.nbt = nbt;
- return result.future;
- }
-
- @Inject(method = "readChunkData", at = @At("HEAD"), cancellable = true)
- private void fastRead(ChunkPos pos, CallbackInfoReturnable>> cir) {
- StorageIoWorker.Result result = this.results.get(pos);
- if (result != null) {
- cir.setReturnValue(CompletableFuture.completedFuture(Optional.ofNullable(result.nbt)));
- }
- }
-
- @Inject(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/storage/RegionBasedStorage;write(Lnet/minecraft/util/math/ChunkPos;Lnet/minecraft/nbt/NbtCompound;)V", shift = At.Shift.BEFORE), cancellable = true)
- private void removeResults(ChunkPos pos, StorageIoWorker.Result result, CallbackInfo ci) {
- if (!this.results.remove(pos, result)) { // Only write once
- ci.cancel();
- }
- }
-}
diff --git a/src/main/java/one/oktw/galaxy/mixin/tweak/MixinMapExistingChunk_FilledMapItem.java b/src/main/java/one/oktw/galaxy/mixin/tweak/MixinMapExistingChunk_FilledMapItem.java
index 7b330aebf..6896c7f58 100644
--- a/src/main/java/one/oktw/galaxy/mixin/tweak/MixinMapExistingChunk_FilledMapItem.java
+++ b/src/main/java/one/oktw/galaxy/mixin/tweak/MixinMapExistingChunk_FilledMapItem.java
@@ -40,6 +40,6 @@ private WorldChunk getExistingChunk(World world, int x, int z) {
WorldChunk chunk = (WorldChunk) world.getChunkAsView(chunkPos.x, chunkPos.z);
if (chunk != null) return chunk;
}
- return new EmptyChunk(world, new ChunkPos(x, z), world.getRegistryManager().get(RegistryKeys.BIOME).entryOf(BiomeKeys.PLAINS));
+ return new EmptyChunk(world, new ChunkPos(x, z), world.getRegistryManager().getOrThrow(RegistryKeys.BIOME).getOrThrow(BiomeKeys.PLAINS));
}
}
diff --git a/src/main/java/org/spongepowered/common/mixin/realtime/blockentity/AbstractFurnaceBlockEntityMixin_RealTime.java b/src/main/java/org/spongepowered/common/mixin/realtime/blockentity/AbstractFurnaceBlockEntityMixin_RealTime.java
index 829f3a664..51465c5bb 100644
--- a/src/main/java/org/spongepowered/common/mixin/realtime/blockentity/AbstractFurnaceBlockEntityMixin_RealTime.java
+++ b/src/main/java/org/spongepowered/common/mixin/realtime/blockentity/AbstractFurnaceBlockEntityMixin_RealTime.java
@@ -98,7 +98,7 @@ public abstract class AbstractFurnaceBlockEntityMixin_RealTime {
),
to = @At(
value = "INVOKE",
- target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"
+ target = "Lnet/minecraft/server/world/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"
)
)
)
diff --git a/src/main/java/org/spongepowered/common/mixin/realtime/entity/EntityMixin_RealTime.java b/src/main/java/org/spongepowered/common/mixin/realtime/entity/EntityMixin_RealTime.java
index de770eca3..d5b236968 100644
--- a/src/main/java/org/spongepowered/common/mixin/realtime/entity/EntityMixin_RealTime.java
+++ b/src/main/java/org/spongepowered/common/mixin/realtime/entity/EntityMixin_RealTime.java
@@ -74,9 +74,8 @@ public abstract class EntityMixin_RealTime {
target = "Lnet/minecraft/entity/Entity;stopRiding()V"
),
to = @At(
- value = "FIELD",
- target = "Lnet/minecraft/entity/Entity;horizontalSpeed:F",
- opcode = Opcodes.GETFIELD
+ value = "INVOKE",
+ target = "Lnet/minecraft/entity/Entity;tickPortalTeleportation()V"
)
)
)
diff --git a/src/main/java/org/spongepowered/common/mixin/realtime/server/network/ServerPlayNetworkHandlerMixin_RealTime.java b/src/main/java/org/spongepowered/common/mixin/realtime/server/network/ServerPlayNetworkHandlerMixin_RealTime.java
index dc11f35cf..e4efb66db 100644
--- a/src/main/java/org/spongepowered/common/mixin/realtime/server/network/ServerPlayNetworkHandlerMixin_RealTime.java
+++ b/src/main/java/org/spongepowered/common/mixin/realtime/server/network/ServerPlayNetworkHandlerMixin_RealTime.java
@@ -48,7 +48,7 @@
import net.minecraft.server.network.ServerCommonNetworkHandler;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
-import org.objectweb.asm.Opcodes;
+import net.minecraft.util.Cooldown;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@@ -59,10 +59,6 @@
public abstract class ServerPlayNetworkHandlerMixin_RealTime extends ServerCommonNetworkHandler {
@Shadow
public ServerPlayerEntity player;
- @Shadow
- private int messageCooldown;
- @Shadow
- private int creativeItemDropThreshold;
public ServerPlayNetworkHandlerMixin_RealTime(MinecraftServer server, ClientConnection connection, ConnectedClientData clientData) {
super(server, connection, clientData);
@@ -71,27 +67,14 @@ public ServerPlayNetworkHandlerMixin_RealTime(MinecraftServer server, ClientConn
@Redirect(
method = "tick",
at = @At(
- value = "FIELD",
- target = "Lnet/minecraft/server/network/ServerPlayNetworkHandler;messageCooldown:I",
- opcode = Opcodes.PUTFIELD,
- ordinal = 0
- )
- )
- private void realTimeImpl$adjustForRealTimeChatSpamCheck(final ServerPlayNetworkHandler self, final int modifier) {
- final int ticks = (int) ((RealTimeTrackingBridge) this.server).realTimeBridge$getRealTimeTicks();
- this.messageCooldown = Math.max(0, this.messageCooldown - ticks);
- }
-
- @Redirect(
- method = "tick",
- at = @At(
- value = "FIELD",
- target = "Lnet/minecraft/server/network/ServerPlayNetworkHandler;creativeItemDropThreshold:I",
- opcode = Opcodes.PUTFIELD, ordinal = 0
+ value = "INVOKE",
+ target = "Lnet/minecraft/util/Cooldown;tick()V"
)
)
- private void realTimeImpl$adjustForRealTimeDropSpamCheck(final ServerPlayNetworkHandler self, final int modifier) {
+ private void realTimeImpl$adjustForRealTimeCooldownTick(Cooldown instance) {
final int ticks = (int) ((RealTimeTrackingBridge) this.server).realTimeBridge$getRealTimeTicks();
- this.creativeItemDropThreshold = Math.max(0, this.creativeItemDropThreshold - ticks);
+ for (int i = 0; i < ticks; i++) {
+ instance.tick();
+ }
}
}
diff --git a/src/main/java/org/spongepowered/common/mixin/realtime/world/WorldMixin_RealTime.java b/src/main/java/org/spongepowered/common/mixin/realtime/world/WorldMixin_RealTime.java
index 1c7f88511..ec434653b 100644
--- a/src/main/java/org/spongepowered/common/mixin/realtime/world/WorldMixin_RealTime.java
+++ b/src/main/java/org/spongepowered/common/mixin/realtime/world/WorldMixin_RealTime.java
@@ -47,12 +47,13 @@
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.world.ServerWorld;
-import net.minecraft.util.profiler.Profiler;
import net.minecraft.world.GameRules;
import net.minecraft.world.MutableWorldProperties;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
+import net.minecraft.world.level.ServerWorldProperties;
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;
@@ -60,12 +61,14 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.common.bridge.RealTimeTrackingBridge;
-import java.util.function.Supplier;
-
@Mixin(ServerWorld.class)
public abstract class WorldMixin_RealTime extends World implements RealTimeTrackingBridge {
- protected WorldMixin_RealTime(MutableWorldProperties properties, RegistryKey registryRef, DynamicRegistryManager registryManager, RegistryEntry dimensionEntry, Supplier profiler, boolean isClient, boolean debugWorld, long biomeAccess, int maxChainedNeighborUpdates) {
- super(properties, registryRef, registryManager, dimensionEntry, profiler, isClient, debugWorld, biomeAccess, maxChainedNeighborUpdates);
+ @Shadow
+ @Final
+ private ServerWorldProperties worldProperties;
+
+ protected WorldMixin_RealTime(MutableWorldProperties properties, RegistryKey registryRef, DynamicRegistryManager registryManager, RegistryEntry dimensionEntry, boolean isClient, boolean debugWorld, long seed, int maxChainedNeighborUpdates) {
+ super(properties, registryRef, registryManager, dimensionEntry, isClient, debugWorld, seed, maxChainedNeighborUpdates);
}
@Shadow
@@ -77,7 +80,7 @@ protected WorldMixin_RealTime(MutableWorldProperties properties, RegistryKey = Registry.register(
Registries.BLOCK_ENTITY_TYPE,
identifier,
- Builder.create({ pos, _ -> createBlockEntity(pos) }, BARRIER).build(null)
+ FabricBlockEntityTypeBuilder.create({ pos, _ -> createBlockEntity(pos) }, BARRIER).build(null)
)
companion object {
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 994bf7954..af88ae46a 100644
--- a/src/main/kotlin/one/oktw/galaxy/block/entity/ModelCustomBlockEntity.kt
+++ b/src/main/kotlin/one/oktw/galaxy/block/entity/ModelCustomBlockEntity.kt
@@ -19,9 +19,9 @@
package one.oktw.galaxy.block.entity
import net.minecraft.block.entity.BlockEntityType
-import net.minecraft.entity.Entity
import net.minecraft.entity.EntityType
import net.minecraft.entity.EquipmentSlot
+import net.minecraft.entity.SpawnReason
import net.minecraft.entity.decoration.ArmorStandEntity
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NbtCompound
@@ -61,7 +61,9 @@ open class ModelCustomBlockEntity(type: BlockEntityType<*>, pos: BlockPos, priva
override fun tick() {
if (entityUUID == null || (world as ServerWorld).getEntity(entityUUID) == null) {
// Kill leak entities
- (world as ServerWorld).getEntitiesByType(EntityType.ARMOR_STAND) { it.blockPos == pos && it.commandTags.contains("BLOCK") }.forEach(Entity::kill)
+ (world as ServerWorld).getEntitiesByType(EntityType.ARMOR_STAND) { it.blockPos == pos && it.commandTags.contains("BLOCK") }.forEach {
+ it.kill(world as ServerWorld)
+ }
spawnEntity()
}
@@ -78,7 +80,7 @@ open class ModelCustomBlockEntity(type: BlockEntityType<*>, pos: BlockPos, priva
super.writeNbt(nbt, registryLookup)
val data = NbtCompound()
entityUUID?.let { data.putUuid("ModelEntity", it) }
- facing?.let { data.putString("Facing", it.getName()) }
+ facing?.let { data.putString("Facing", it.name) }
if (!data.isEmpty) {
nbt.put("GalaxyData", data)
}
@@ -86,11 +88,11 @@ open class ModelCustomBlockEntity(type: BlockEntityType<*>, pos: BlockPos, priva
override fun markRemoved() {
super.markRemoved()
- (world as ServerWorld).getEntity(entityUUID)?.kill()
+ (world as ServerWorld).getEntity(entityUUID)?.kill(world as ServerWorld)
}
private fun spawnEntity() {
- val entity: ArmorStandEntity = EntityType.getEntityFromNbt(armorStandNbt, world).get() as ArmorStandEntity
+ val entity: ArmorStandEntity = EntityType.getEntityFromNbt(armorStandNbt, world, SpawnReason.COMMAND).get() as ArmorStandEntity
entity.refreshPositionAndAngles(pos.x + 0.5, pos.y + 0.5, pos.z + 0.5, facing?.asRotation() ?: 0.0F, 0.0F)
entity.equipStack(EquipmentSlot.HEAD, modelItem)
entity.addCommandTag("BLOCK")
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 915ed4498..4bb0087cf 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-2023
+ * Copyright (C) 2018-2024
*
* 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
@@ -22,6 +22,7 @@ import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents
import net.minecraft.advancement.criterion.Criteria
import net.minecraft.item.ItemPlacementContext
import net.minecraft.server.network.ServerPlayerEntity
+import net.minecraft.util.ActionResult
import net.minecraft.util.Hand
import one.oktw.galaxy.block.CustomBlockHelper
import one.oktw.galaxy.block.entity.ModelCustomBlockEntity
@@ -62,7 +63,7 @@ class BlockEvents {
val result = blockEntity.onClick(player, packet.hand, hitResult)
if (result.isAccepted) {
Criteria.ITEM_USED_ON_BLOCK.trigger(player, hitResult.blockPos, player.getStackInHand(packet.hand))
- event.swing = result.shouldSwingHand()
+ event.swing = (result as? ActionResult.Success)?.swingSource() == ActionResult.SwingSource.SERVER
usedLock[player] = player.server.ticks
}
}
diff --git a/src/main/kotlin/one/oktw/galaxy/block/event/Elevator.kt b/src/main/kotlin/one/oktw/galaxy/block/event/Elevator.kt
index 77dd19dc2..ad5c73a1c 100644
--- a/src/main/kotlin/one/oktw/galaxy/block/event/Elevator.kt
+++ b/src/main/kotlin/one/oktw/galaxy/block/event/Elevator.kt
@@ -1,6 +1,6 @@
/*
* OKTW Galaxy Project
- * Copyright (C) 2018-2023
+ * Copyright (C) 2018-2024
*
* 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 @@ class Elevator {
}
private fun isSafe(world: ServerWorld, blockPos: BlockPos): Boolean {
- return !world.getBlockState(blockPos).isOpaqueFullCube(world, blockPos)
+ return !world.getBlockState(blockPos).isOpaqueFullCube
}
private fun doTeleport(player: ServerPlayerEntity, pos: BlockPos) {
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 9b2289e15..124922ed7 100644
--- a/src/main/kotlin/one/oktw/galaxy/command/commands/Home.kt
+++ b/src/main/kotlin/one/oktw/galaxy/command/commands/Home.kt
@@ -21,6 +21,7 @@ package one.oktw.galaxy.command.commands
import com.mojang.brigadier.CommandDispatcher
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
+import net.minecraft.block.Blocks
import net.minecraft.block.RespawnAnchorBlock
import net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket
import net.minecraft.server.command.CommandManager
@@ -54,6 +55,7 @@ class Home : Command {
lock += player.uuid
+ // Check Stage
val spawnPointPosition = player.spawnPointPosition
if (spawnPointPosition == null) {
player.sendMessage(Text.translatable("block.minecraft.spawn.not_valid").styled { it.withColor(Formatting.RED) }, false)
@@ -61,68 +63,55 @@ class Home : Command {
return com.mojang.brigadier.Command.SINGLE_SUCCESS
}
- val world = source.server.getWorld(player.spawnPointDimension)
-
val teleportTarget = player.getRespawnTarget(player.notInAnyWorld, TeleportTarget.NO_OP)
if (teleportTarget.missingRespawnBlock()) {
player.sendMessage(Text.translatable("block.minecraft.spawn.not_valid").styled { it.withColor(Formatting.RED) }, false)
lock -= player.uuid
} else {
main?.launch {
- // Add back charge in countdown stage
- if (world != null) {
- val blockState = world.getBlockState(spawnPointPosition)
- if (blockState.block is RespawnAnchorBlock) {
- world.setBlockState(
- spawnPointPosition, blockState.with(RespawnAnchorBlock.CHARGES, blockState[RespawnAnchorBlock.CHARGES] + 1)
- )
- world.updateNeighbors(spawnPointPosition, blockState.block)
- }
- }
-
for (i in 0..4) {
player.sendMessage(Text.translatable("Respond.commandCountdown", 5 - i).styled { it.withColor(Formatting.GREEN) }, true)
delay(TimeUnit.SECONDS.toMillis(1))
}
player.sendMessage(Text.translatable("Respond.TeleportStart").styled { it.withColor(Formatting.GREEN) }, true)
- // Check Again
- val teleportTargetDoubleCheck = player.getRespawnTarget(player.notInAnyWorld, TeleportTarget.NO_OP)
-
- if (teleportTargetDoubleCheck.missingRespawnBlock()) {
+ // Check Again (Actual Teleport Stage)
+ val realTeleportTarget = player.getRespawnTarget(player.notInAnyWorld, TeleportTarget.NO_OP)
+ if (realTeleportTarget.missingRespawnBlock()) {
player.sendMessage(Text.translatable("block.minecraft.spawn.not_valid").styled { it.withColor(Formatting.RED) }, false)
lock -= player.uuid
return@launch
}
- val world2 = if (world != null && !teleportTargetDoubleCheck.missingRespawnBlock()) world else source.server.overworld
- val position = teleportTarget.pos()
- player.teleport(
- world2,
- position.x,
- position.y,
- position.z,
- player.yaw,
- player.pitch
- )
+ player.teleportTo(realTeleportTarget)
- val blockState = world2.getBlockState(spawnPointPosition)
- if (!player.notInAnyWorld && blockState.block is RespawnAnchorBlock) {
- player.networkHandler.sendPacket(
- PlaySoundS2CPacket(
+ val realSpawnPointPosition = player.spawnPointPosition
+ val realWorld = source.server.getWorld(player.spawnPointDimension)
+ if (realWorld != null && realSpawnPointPosition != null) {
+ val blockState = realWorld.getBlockState(realSpawnPointPosition)
+ if (!player.notInAnyWorld && blockState.isOf(Blocks.RESPAWN_ANCHOR)) {
+ // Consume Respawn Anchor Charge
+ realWorld.setBlockState(
+ realSpawnPointPosition, blockState.with(RespawnAnchorBlock.CHARGES, blockState[RespawnAnchorBlock.CHARGES] - 1)
+ )
+ realWorld.updateNeighbors(realSpawnPointPosition, blockState.block)
+
+ player.networkHandler.sendPacket(
+ PlaySoundS2CPacket(
SoundEvents.BLOCK_RESPAWN_ANCHOR_DEPLETE,
SoundCategory.BLOCKS,
- spawnPointPosition.x.toDouble(),
- spawnPointPosition.y.toDouble(),
- spawnPointPosition.z.toDouble(),
+ realSpawnPointPosition.x.toDouble(),
+ realSpawnPointPosition.y.toDouble(),
+ realSpawnPointPosition.z.toDouble(),
1.0f,
1.0f,
- world2.getRandom().nextLong()
+ realWorld.getRandom().nextLong()
)
- )
- }
+ )
+ }
- lock -= player.uuid
+ lock -= player.uuid
+ }
}
}
return com.mojang.brigadier.Command.SINGLE_SUCCESS
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 1bf4d61af..d06b3f52f 100644
--- a/src/main/kotlin/one/oktw/galaxy/command/commands/Spawn.kt
+++ b/src/main/kotlin/one/oktw/galaxy/command/commands/Spawn.kt
@@ -94,7 +94,7 @@ class Spawn : Command {
player.refreshPositionAndAngles(spawnPosition, 0.0f, 0.0f)
}
- while (!world.isSpaceEmpty(player) && player.y < world.topY) {
+ while (!world.isSpaceEmpty(player) && player.y < world.topYInclusive) {
player.updatePosition(player.x, player.y + 1, player.z)
}
player.networkHandler.requestTeleport(player.x, player.y, player.z, player.yaw, player.pitch)
diff --git a/src/main/kotlin/one/oktw/galaxy/item/CustomItem.kt b/src/main/kotlin/one/oktw/galaxy/item/CustomItem.kt
index a93f346b4..ff29d558e 100644
--- a/src/main/kotlin/one/oktw/galaxy/item/CustomItem.kt
+++ b/src/main/kotlin/one/oktw/galaxy/item/CustomItem.kt
@@ -31,7 +31,12 @@ import net.minecraft.util.Identifier
import one.oktw.galaxy.util.CustomRegistry
import one.oktw.galaxy.util.Registrable
-abstract class CustomItem(override val identifier: Identifier, private val baseItem: Item, private val modelData: Int) : Registrable {
+abstract class CustomItem(
+ override val identifier: Identifier,
+ private val baseItem: Item,
+ private val modelData: Int,
+ private val maxStackSize: Int = 64
+) : Registrable {
companion object {
val registry = CustomRegistry()
@@ -69,6 +74,7 @@ abstract class CustomItem(override val identifier: Identifier, private val baseI
set(DataComponentTypes.UNBREAKABLE, UnbreakableComponent(false))
set(DataComponentTypes.ATTRIBUTE_MODIFIERS, AttributeModifiersComponent(emptyList(), false))
set(DataComponentTypes.ITEM_NAME, this@CustomItem.getName())
+ set(DataComponentTypes.MAX_STACK_SIZE, maxStackSize)
// Galaxy Data
val galaxyNbt = CustomItemHelper.getNbt(this)
diff --git a/src/main/kotlin/one/oktw/galaxy/item/Tool.kt b/src/main/kotlin/one/oktw/galaxy/item/Tool.kt
index 78b7de083..4d2efee23 100644
--- a/src/main/kotlin/one/oktw/galaxy/item/Tool.kt
+++ b/src/main/kotlin/one/oktw/galaxy/item/Tool.kt
@@ -19,15 +19,13 @@
package one.oktw.galaxy.item
import net.minecraft.item.Items.COMMAND_BLOCK
-import net.minecraft.nbt.NbtCompound
import net.minecraft.text.Text
import net.minecraft.text.Text.translatable
import net.minecraft.util.Formatting
import net.minecraft.util.Identifier
-import net.minecraft.util.math.MathHelper
class Tool private constructor(id: String, modelData: Int, private val name: String) :
- CustomItem(Identifier.of("galaxy", "item/tool/$id"), COMMAND_BLOCK, modelData) {
+ CustomItem(Identifier.of("galaxy", "item/tool/$id"), COMMAND_BLOCK, modelData, 1) {
override val cacheable = false
companion object {
@@ -36,9 +34,4 @@ class Tool private constructor(id: String, modelData: Int, private val name: Str
}
override fun getName(): Text = translatable(name).styled { it.withColor(Formatting.WHITE).withItalic(false) }
-
- override fun writeCustomNbt(nbt: NbtCompound) {
- super.writeCustomNbt(nbt)
- nbt.put("ToolData", NbtCompound().apply { putUuid("id", MathHelper.randomUuid()) })
- }
}
diff --git a/src/main/kotlin/one/oktw/galaxy/item/Weapon.kt b/src/main/kotlin/one/oktw/galaxy/item/Weapon.kt
index bba401013..2f7b1ce4d 100644
--- a/src/main/kotlin/one/oktw/galaxy/item/Weapon.kt
+++ b/src/main/kotlin/one/oktw/galaxy/item/Weapon.kt
@@ -19,15 +19,13 @@
package one.oktw.galaxy.item
import net.minecraft.item.Items.COMMAND_BLOCK
-import net.minecraft.nbt.NbtCompound
import net.minecraft.text.Text
import net.minecraft.text.Text.translatable
import net.minecraft.util.Formatting
import net.minecraft.util.Identifier
-import net.minecraft.util.math.MathHelper
class Weapon private constructor(id: String, modelData: Int, private val name: String) :
- CustomItem(Identifier.of("galaxy", "item/weapon/$id"), COMMAND_BLOCK, modelData) {
+ CustomItem(Identifier.of("galaxy", "item/weapon/$id"), COMMAND_BLOCK, modelData, 1) {
override val cacheable = false
companion object {
@@ -58,9 +56,4 @@ class Weapon private constructor(id: String, modelData: Int, private val name: S
}
override fun getName(): Text = translatable(name).styled { it.withColor(Formatting.WHITE).withItalic(false) }
-
- override fun writeCustomNbt(nbt: NbtCompound) {
- super.writeCustomNbt(nbt)
- nbt.put("WeaponData", NbtCompound().apply { putUuid("id", MathHelper.randomUuid()) })
- }
}
diff --git a/src/main/kotlin/one/oktw/galaxy/item/event/Wrench.kt b/src/main/kotlin/one/oktw/galaxy/item/event/Wrench.kt
index f09f6dce2..df111f766 100644
--- a/src/main/kotlin/one/oktw/galaxy/item/event/Wrench.kt
+++ b/src/main/kotlin/one/oktw/galaxy/item/event/Wrench.kt
@@ -213,7 +213,7 @@ class Wrench {
}
world.setBlockState(blockPos, newState)
- world.updateNeighbor(newState, blockPos, newState.block, blockPos, true)
+ world.updateNeighbor(newState, blockPos, newState.block, null, true)
// Workaround disable state update for bell
Block.postProcessState(newState, world, blockPos).let { if (!it.isAir && it.block != BELL) world.setBlockState(blockPos, it, 2) }
diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/RecipeRegistry.kt b/src/main/kotlin/one/oktw/galaxy/recipe/RecipeRegistry.kt
deleted file mode 100644
index 43cab5c1b..000000000
--- a/src/main/kotlin/one/oktw/galaxy/recipe/RecipeRegistry.kt
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * OKTW Galaxy Project
- * Copyright (C) 2018-2024
- *
- * 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.recipe
-
-import net.minecraft.recipe.RecipeType
-import net.minecraft.util.Identifier
-import one.oktw.galaxy.mixin.interfaces.CustomRecipeManager
-import one.oktw.galaxy.recipe.blocks.Elevator
-import one.oktw.galaxy.recipe.blocks.HTCraftingTable
-import one.oktw.galaxy.recipe.blocks.Harvest
-import one.oktw.galaxy.recipe.blocks.Trashcan
-import one.oktw.galaxy.recipe.materials.CeramicPlate
-import one.oktw.galaxy.recipe.tools.Crowbar
-import one.oktw.galaxy.recipe.tools.Wrench
-
-object RecipeRegistry {
- fun register() {
- // Recipe
- CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier.of("galaxy", "item/wrench"), Wrench())
- CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier.of("galaxy", "item/crowbar"), Crowbar())
- CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier.of("galaxy", "block/elevator"), Elevator())
- CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier.of("galaxy", "block/htct"), HTCraftingTable())
- CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier.of("galaxy", "block/harvest"), Harvest())
- CustomRecipeManager.addRecipe(RecipeType.SMELTING, Identifier.of("galaxy", "material/ceramic_plate"), CeramicPlate())
- CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier.of("galaxy", "block/trashcan"), Trashcan())
- }
-}
diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/blocks/Elevator.kt b/src/main/kotlin/one/oktw/galaxy/recipe/blocks/Elevator.kt
deleted file mode 100644
index 4bd05b828..000000000
--- a/src/main/kotlin/one/oktw/galaxy/recipe/blocks/Elevator.kt
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * OKTW Galaxy Project
- * Copyright (C) 2018-2023
- *
- * 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.recipe.blocks
-
-import net.minecraft.item.Items
-import net.minecraft.recipe.Ingredient
-import net.minecraft.recipe.ShapelessRecipe
-import net.minecraft.recipe.book.CraftingRecipeCategory
-import net.minecraft.util.collection.DefaultedList
-import one.oktw.galaxy.item.CustomBlockItem
-
-class Elevator : ShapelessRecipe(
- "",
- CraftingRecipeCategory.EQUIPMENT,
- CustomBlockItem.ELEVATOR.createItemStack(),
- DefaultedList.copyOf(Ingredient.EMPTY, Ingredient.ofItems(Items.ENDER_PEARL), Ingredient.ofItems(Items.IRON_BLOCK))
-)
diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/blocks/HTCraftingTable.kt b/src/main/kotlin/one/oktw/galaxy/recipe/blocks/HTCraftingTable.kt
deleted file mode 100644
index cfb645ed6..000000000
--- a/src/main/kotlin/one/oktw/galaxy/recipe/blocks/HTCraftingTable.kt
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * OKTW Galaxy Project
- * Copyright (C) 2018-2023
- *
- * 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.recipe.blocks
-
-import net.minecraft.item.Items
-import net.minecraft.recipe.Ingredient
-import net.minecraft.recipe.RawShapedRecipe
-import net.minecraft.recipe.ShapedRecipe
-import net.minecraft.recipe.book.CraftingRecipeCategory
-import one.oktw.galaxy.item.CustomBlockItem
-
-class HTCraftingTable : ShapedRecipe(
- "",
- CraftingRecipeCategory.BUILDING,
- RawShapedRecipe.create(
- mapOf(
- Character.valueOf('r') to Ingredient.ofItems(Items.REDSTONE),
- Character.valueOf('d') to Ingredient.ofItems(Items.DIAMOND),
- Character.valueOf('l') to Ingredient.ofItems(Items.LAPIS_LAZULI),
- Character.valueOf('i') to Ingredient.ofItems(Items.IRON_INGOT),
- Character.valueOf('c') to Ingredient.ofItems(Items.CRAFTING_TABLE),
- Character.valueOf('o') to Ingredient.ofItems(Items.OBSIDIAN),
- ),
- "rdl",
- "ici",
- "lor"
- ),
- CustomBlockItem.HT_CRAFTING_TABLE.createItemStack()
-)
diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/blocks/Harvest.kt b/src/main/kotlin/one/oktw/galaxy/recipe/blocks/Harvest.kt
deleted file mode 100644
index d1d1aec3a..000000000
--- a/src/main/kotlin/one/oktw/galaxy/recipe/blocks/Harvest.kt
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * OKTW Galaxy Project
- * Copyright (C) 2018-2023
- *
- * 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.recipe.blocks
-
-import net.minecraft.item.Items
-import net.minecraft.recipe.Ingredient.ofItems
-import net.minecraft.recipe.RawShapedRecipe
-import net.minecraft.recipe.ShapedRecipe
-import net.minecraft.recipe.book.CraftingRecipeCategory
-import one.oktw.galaxy.item.CustomBlockItem
-
-class Harvest : ShapedRecipe(
- "",
- CraftingRecipeCategory.BUILDING,
- RawShapedRecipe.create(
- mapOf(
- Character.valueOf('c') to ofItems(Items.COPPER_INGOT),
- Character.valueOf('o') to ofItems(Items.OBSERVER),
- Character.valueOf('d') to ofItems(Items.DISPENSER),
- ),
- "ccc",
- "cdo",
- "ccc"
- ),
- CustomBlockItem.HARVEST.createItemStack()
-)
diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/blocks/Trashcan.kt b/src/main/kotlin/one/oktw/galaxy/recipe/blocks/Trashcan.kt
deleted file mode 100644
index 2204f2215..000000000
--- a/src/main/kotlin/one/oktw/galaxy/recipe/blocks/Trashcan.kt
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * OKTW Galaxy Project
- * Copyright (C) 2018-2023
- *
- * 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.recipe.blocks
-
-import net.minecraft.item.Items
-import net.minecraft.recipe.Ingredient.ofItems
-import net.minecraft.recipe.RawShapedRecipe
-import net.minecraft.recipe.ShapedRecipe
-import net.minecraft.recipe.book.CraftingRecipeCategory
-import one.oktw.galaxy.item.CustomBlockItem
-
-class Trashcan : ShapedRecipe(
- "",
- CraftingRecipeCategory.BUILDING,
- RawShapedRecipe.create(
- mapOf(
- Character.valueOf('g') to ofItems(Items.GLASS),
- Character.valueOf('c') to ofItems(Items.CACTUS),
- Character.valueOf('t') to ofItems(Items.TERRACOTTA),
- Character.valueOf('s') to ofItems(Items.SAND, Items.RED_SAND)
- ),
- "ggg",
- "gcg",
- "tst"
- ),
- CustomBlockItem.TRASHCAN.createItemStack()
-)
diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/materials/CeramicPlate.kt b/src/main/kotlin/one/oktw/galaxy/recipe/materials/CeramicPlate.kt
deleted file mode 100644
index 9587a4104..000000000
--- a/src/main/kotlin/one/oktw/galaxy/recipe/materials/CeramicPlate.kt
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * OKTW Galaxy Project
- * Copyright (C) 2018-2024
- *
- * 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.recipe.materials
-
-import net.minecraft.recipe.Ingredient
-import net.minecraft.recipe.SmeltingRecipe
-import net.minecraft.recipe.book.CookingRecipeCategory
-import net.minecraft.recipe.input.SingleStackRecipeInput
-import net.minecraft.world.World
-import one.oktw.galaxy.item.CustomItemHelper
-import one.oktw.galaxy.item.Material
-
-class CeramicPlate : SmeltingRecipe(
- "",
- CookingRecipeCategory.MISC,
- Ingredient.ofStacks(Material.RAW_BASE_PLATE.createItemStack()),
- Material.BASE_PLATE.createItemStack(),
- 0.1F,
- 200
-) {
- override fun matches(singleStackRecipeInput: SingleStackRecipeInput, world: World): Boolean {
- val input = singleStackRecipeInput.getStackInSlot(0) ?: return false
- return CustomItemHelper.getItem(input) == Material.RAW_BASE_PLATE
- }
-}
diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/tools/Crowbar.kt b/src/main/kotlin/one/oktw/galaxy/recipe/tools/Crowbar.kt
deleted file mode 100644
index e668a2cdf..000000000
--- a/src/main/kotlin/one/oktw/galaxy/recipe/tools/Crowbar.kt
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * OKTW Galaxy Project
- * Copyright (C) 2018-2024
- *
- * 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.recipe.tools
-
-import net.minecraft.item.Items
-import net.minecraft.recipe.RawShapedRecipe
-import net.minecraft.recipe.ShapedRecipe
-import net.minecraft.recipe.book.CraftingRecipeCategory
-import net.minecraft.recipe.input.CraftingRecipeInput
-import net.minecraft.registry.RegistryWrapper
-import one.oktw.galaxy.item.Tool
-
-class Crowbar : ShapedRecipe(
- "",
- CraftingRecipeCategory.EQUIPMENT,
- RawShapedRecipe.create(
- mapOf(Character.valueOf('i') to net.minecraft.recipe.Ingredient.ofItems(Items.IRON_INGOT)),
- "ii",
- " i",
- " i"
- ),
- Tool.CROWBAR.createItemStack()
-) {
- override fun craft(craftingRecipeInput: CraftingRecipeInput, wrapperLookup: RegistryWrapper.WrapperLookup) = Tool.CROWBAR.createItemStack()
-}
diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/tools/Wrench.kt b/src/main/kotlin/one/oktw/galaxy/recipe/tools/Wrench.kt
deleted file mode 100644
index 748f0a6c9..000000000
--- a/src/main/kotlin/one/oktw/galaxy/recipe/tools/Wrench.kt
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * OKTW Galaxy Project
- * Copyright (C) 2018-2024
- *
- * 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.recipe.tools
-
-import net.minecraft.item.Items
-import net.minecraft.recipe.Ingredient
-import net.minecraft.recipe.RawShapedRecipe
-import net.minecraft.recipe.ShapedRecipe
-import net.minecraft.recipe.book.CraftingRecipeCategory
-import net.minecraft.recipe.input.CraftingRecipeInput
-import net.minecraft.registry.RegistryWrapper
-import one.oktw.galaxy.item.Tool
-
-class Wrench : ShapedRecipe(
- "",
- CraftingRecipeCategory.EQUIPMENT,
- RawShapedRecipe.create(
- mapOf(Character.valueOf('i') to Ingredient.ofItems(Items.IRON_INGOT), Character.valueOf('s') to Ingredient.ofItems(Items.STICK)),
- "i i",
- " s ",
- " i "
- ),
- Tool.WRENCH.createItemStack()
-) {
- override fun craft(craftingRecipeInput: CraftingRecipeInput, wrapperLookup: RegistryWrapper.WrapperLookup) = Tool.WRENCH.createItemStack()
-}
diff --git a/src/main/kotlin/one/oktw/galaxy/util/KotlinCoroutineTaskExecutor.kt b/src/main/kotlin/one/oktw/galaxy/util/KotlinCoroutineTaskExecutor.kt
deleted file mode 100644
index 60709f1ec..000000000
--- a/src/main/kotlin/one/oktw/galaxy/util/KotlinCoroutineTaskExecutor.kt
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * OKTW Galaxy Project
- * Copyright (C) 2018-2023
- *
- * 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.util
-
-import kotlinx.coroutines.*
-import net.minecraft.util.Util
-import net.minecraft.util.thread.TaskExecutor
-import net.minecraft.util.thread.TaskQueue
-import net.minecraft.util.thread.TaskQueue.PrioritizedTask
-import java.util.concurrent.Executors
-import java.util.concurrent.atomic.AtomicInteger
-
-class KotlinCoroutineTaskExecutor(private val queue: TaskQueue, name: String) : TaskExecutor(queue, null, name), CoroutineScope {
- companion object {
- private var index = 0
- private val dispatcher = Executors.newFixedThreadPool(16) { r -> Thread(r, "IO-Kotlin-${index++}").apply { isDaemon = true } }.asCoroutineDispatcher()
- }
-
- private val job = SupervisorJob()
- private val executePriority = AtomicInteger(0)
- private val executingTask = AtomicInteger(0)
-
- override val coroutineContext = dispatcher + job
-
- override fun send(message: T) {
- queue.add(message)
- launch { runTasks() }
- }
-
- private fun runTasks() {
- while (!queue.isEmpty) {
- val task = queue.poll() ?: continue
-
- // Check task priority
- if (task is PrioritizedTask && executingTask.get() > 0 && task.priority > executePriority.get()) {
- // executing task priority higher than next task, wait all task done
- @Suppress("UNCHECKED_CAST")
- queue.add(task as T)
- break
- }
-
- // Run task
- if (task is PrioritizedTask) executePriority.set(task.priority)
- executingTask.incrementAndGet()
- launch {
- Util.debugRunnable(name, task).run()
- if (executingTask.decrementAndGet() <= 0) runTasks() // Trigger next write batch
- }
- }
- }
-
- override fun close() {
- super.close()
- runBlocking { job.cancelAndJoin() }
- }
-}
diff --git a/src/main/resources/accessor.mixin.json b/src/main/resources/accessor.mixin.json
index be509346a..8fd549e4f 100644
--- a/src/main/resources/accessor.mixin.json
+++ b/src/main/resources/accessor.mixin.json
@@ -5,7 +5,6 @@
"mixins": [
"BeaconLevelAccessor",
"PlayerAbilitiesAccessor",
- "SerializingRegionBasedStorageAccessor",
"ServerChunkLoadingManagerAccessor"
],
"client": [],
diff --git a/src/main/resources/data/galaxy/recipe/blocks/elevator.json b/src/main/resources/data/galaxy/recipe/blocks/elevator.json
new file mode 100644
index 000000000..31dfe3713
--- /dev/null
+++ b/src/main/resources/data/galaxy/recipe/blocks/elevator.json
@@ -0,0 +1,28 @@
+{
+ "type": "minecraft:crafting_shapeless",
+ "category": "building",
+ "ingredients": [
+ "minecraft:ender_pearl",
+ "minecraft:iron_block"
+ ],
+ "result": {
+ "id": "minecraft:command_block",
+ "count": 1,
+ "components": {
+ "unbreakable": {
+ "show_in_tooltip": false
+ },
+ "attribute_modifiers": {
+ "modifiers": [],
+ "show_in_tooltip": false
+ },
+ "item_name": "{\"translate\": \"block.ELEVATOR\", \"color\": \"white\", \"italic\": false}",
+ "custom_model_data": 1010200,
+ "custom_data": {
+ "GalaxyData": {
+ "CustomItemIdentifier": "galaxy:item/block/elevator"
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/resources/data/galaxy/recipe/blocks/harvest.json b/src/main/resources/data/galaxy/recipe/blocks/harvest.json
new file mode 100644
index 000000000..870b45510
--- /dev/null
+++ b/src/main/resources/data/galaxy/recipe/blocks/harvest.json
@@ -0,0 +1,34 @@
+{
+ "type": "minecraft:crafting_shaped",
+ "category": "building",
+ "pattern": [
+ "CCC",
+ "CDO",
+ "CCC"
+ ],
+ "key": {
+ "C": "minecraft:copper_ingot",
+ "D": "minecraft:dispenser",
+ "O": "minecraft:observer"
+ },
+ "result": {
+ "id": "minecraft:command_block",
+ "count": 1,
+ "components": {
+ "unbreakable": {
+ "show_in_tooltip": false
+ },
+ "attribute_modifiers": {
+ "modifiers": [],
+ "show_in_tooltip": false
+ },
+ "item_name": "{\"translate\": \"block.HARVEST\", \"color\": \"white\", \"italic\": false}",
+ "custom_model_data": 1010700,
+ "custom_data": {
+ "GalaxyData": {
+ "CustomItemIdentifier": "galaxy:item/block/harvest"
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/resources/data/galaxy/recipe/blocks/ht_crafting_table.json b/src/main/resources/data/galaxy/recipe/blocks/ht_crafting_table.json
new file mode 100644
index 000000000..3c6a1852c
--- /dev/null
+++ b/src/main/resources/data/galaxy/recipe/blocks/ht_crafting_table.json
@@ -0,0 +1,37 @@
+{
+ "type": "minecraft:crafting_shaped",
+ "category": "building",
+ "pattern": [
+ "RDL",
+ "ICI",
+ "LOR"
+ ],
+ "key": {
+ "R": "minecraft:redstone",
+ "D": "minecraft:diamond",
+ "L": "minecraft:lapis_lazuli",
+ "I": "minecraft:iron_ingot",
+ "C": "minecraft:crafting_table",
+ "O": "minecraft:obsidian"
+ },
+ "result": {
+ "id": "minecraft:command_block",
+ "count": 1,
+ "components": {
+ "unbreakable": {
+ "show_in_tooltip": false
+ },
+ "attribute_modifiers": {
+ "modifiers": [],
+ "show_in_tooltip": false
+ },
+ "item_name": "{\"translate\": \"block.HT_CRAFTING_TABLE\", \"color\": \"white\", \"italic\": false}",
+ "custom_model_data": 1010100,
+ "custom_data": {
+ "GalaxyData": {
+ "CustomItemIdentifier": "galaxy:item/block/ht_crafting_table"
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/resources/data/galaxy/recipe/blocks/trashcan.json b/src/main/resources/data/galaxy/recipe/blocks/trashcan.json
new file mode 100644
index 000000000..ef831df27
--- /dev/null
+++ b/src/main/resources/data/galaxy/recipe/blocks/trashcan.json
@@ -0,0 +1,35 @@
+{
+ "type": "minecraft:crafting_shaped",
+ "category": "building",
+ "pattern": [
+ "GGG",
+ "GCG",
+ "TST"
+ ],
+ "key": {
+ "G": "minecraft:glass",
+ "C": "minecraft:cactus",
+ "T": "minecraft:terracotta",
+ "S": "#minecraft:sand"
+ },
+ "result": {
+ "id": "minecraft:command_block",
+ "count": 1,
+ "components": {
+ "unbreakable": {
+ "show_in_tooltip": false
+ },
+ "attribute_modifiers": {
+ "modifiers": [],
+ "show_in_tooltip": false
+ },
+ "item_name": "{\"translate\": \"block.TRASHCAN\", \"color\": \"white\", \"italic\": false}",
+ "custom_model_data": 1010700,
+ "custom_data": {
+ "GalaxyData": {
+ "CustomItemIdentifier": "galaxy:item/block/trashcan"
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/resources/data/galaxy/recipe/tools/crowbar.json b/src/main/resources/data/galaxy/recipe/tools/crowbar.json
new file mode 100644
index 000000000..148d94f5b
--- /dev/null
+++ b/src/main/resources/data/galaxy/recipe/tools/crowbar.json
@@ -0,0 +1,33 @@
+{
+ "type": "minecraft:crafting_shaped",
+ "category": "equipment",
+ "pattern": [
+ "II",
+ " I",
+ " I"
+ ],
+ "key": {
+ "I": "minecraft:iron_ingot"
+ },
+ "result": {
+ "id": "minecraft:command_block",
+ "count": 1,
+ "components": {
+ "max_stack_size": 1,
+ "unbreakable": {
+ "show_in_tooltip": false
+ },
+ "attribute_modifiers": {
+ "modifiers": [],
+ "show_in_tooltip": false
+ },
+ "item_name": "{\"translate\": \"item.Tool.CROWBAR\", \"color\": \"white\", \"italic\": false}",
+ "custom_model_data": 2010200,
+ "custom_data": {
+ "GalaxyData": {
+ "CustomItemIdentifier": "galaxy:item/tool/crowbar"
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/resources/data/galaxy/recipe/tools/wrench.json b/src/main/resources/data/galaxy/recipe/tools/wrench.json
new file mode 100644
index 000000000..f170c1def
--- /dev/null
+++ b/src/main/resources/data/galaxy/recipe/tools/wrench.json
@@ -0,0 +1,34 @@
+{
+ "type": "minecraft:crafting_shaped",
+ "category": "building",
+ "pattern": [
+ "I I",
+ " S ",
+ " I "
+ ],
+ "key": {
+ "I": "minecraft:iron_ingot",
+ "S": "minecraft:stick"
+ },
+ "result": {
+ "id": "minecraft:command_block",
+ "count": 1,
+ "components": {
+ "max_stack_size": 1,
+ "unbreakable": {
+ "show_in_tooltip": false
+ },
+ "attribute_modifiers": {
+ "modifiers": [],
+ "show_in_tooltip": false
+ },
+ "item_name": "{\"translate\": \"item.Tool.WRENCH\", \"color\": \"white\", \"italic\": false}",
+ "custom_model_data": 2010100,
+ "custom_data": {
+ "GalaxyData": {
+ "CustomItemIdentifier": "galaxy:item/tool/wrench"
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json
index 9784dda85..a312a86c9 100644
--- a/src/main/resources/fabric.mod.json
+++ b/src/main/resources/fabric.mod.json
@@ -23,8 +23,7 @@
"galaxy.mixin.json",
"tweak.mixin.json",
"sponge.realtime.mixin.json",
- "accessor.mixin.json",
- "recipe.mixin.json"
+ "accessor.mixin.json"
],
"depends": {
"minecraft": "1.21.x",
diff --git a/src/main/resources/recipe.mixin.json b/src/main/resources/recipe.mixin.json
deleted file mode 100644
index b73244802..000000000
--- a/src/main/resources/recipe.mixin.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "required": true,
- "package": "one.oktw.galaxy.mixin.recipe",
- "compatibilityLevel": "JAVA_21",
- "mixins": [
- "MixinCustomRecipe_CraftingResultSlot",
- "MixinCustomRecipe_RecipeManager"
- ],
- "client": [],
- "injectors": {
- "defaultRequire": 1
- }
-}
diff --git a/src/main/resources/tweak.mixin.json b/src/main/resources/tweak.mixin.json
index dc861f89d..eacb02969 100644
--- a/src/main/resources/tweak.mixin.json
+++ b/src/main/resources/tweak.mixin.json
@@ -3,13 +3,7 @@
"package": "one.oktw.galaxy.mixin.tweak",
"compatibilityLevel": "JAVA_21",
"mixins": [
- "MixinAsyncChunk_ChunkPosDistanceLevelPropagator",
- "MixinAsyncChunk_RegionBasedStorage",
- "MixinAsyncChunk_RegionFile",
- "MixinAsyncChunk_ServerChunkLoadingManager",
- "MixinAsyncChunk_ServerChunkManager",
"MixinAsyncChunk_ServerPlayNetworkHandler",
- "MixinAsyncChunk_StorageIoWorker",
"MixinCustomBlockEntity_BarrierBlock",
"MixinCustomBlockEntity_ChunkData",
"MixinCustomBlockEntity_Structure",