diff --git a/build-data/divinemc.at b/build-data/divinemc.at index 3115868..377f9c3 100644 --- a/build-data/divinemc.at +++ b/build-data/divinemc.at @@ -17,6 +17,7 @@ public net.minecraft.world.entity.ai.sensing.Sensor timeToTick public net.minecraft.world.entity.animal.armadillo.Armadillo scuteTime public net.minecraft.world.entity.animal.frog.Tadpole getTicksLeftUntilAdult()I public net.minecraft.world.entity.decoration.ArmorStand noTickEquipmentDirty +public net.minecraft.world.level.Level isClientSide public net.minecraft.world.level.chunk.LevelChunk$RebindableTickingBlockEntityWrapper public net.minecraft.world.level.chunk.LevelChunk$RebindableTickingBlockEntityWrapper rebind(Lnet/minecraft/world/level/block/entity/TickingBlockEntity;)V public net.minecraft.world.level.chunk.LevelChunk$RebindableTickingBlockEntityWrapper ticker diff --git a/divinemc-server/minecraft-patches/features/0003-Completely-remove-Mojang-profiler.patch b/divinemc-server/minecraft-patches/features/0003-Completely-remove-Mojang-profiler.patch index 9ab94c6..593f311 100644 --- a/divinemc-server/minecraft-patches/features/0003-Completely-remove-Mojang-profiler.patch +++ b/divinemc-server/minecraft-patches/features/0003-Completely-remove-Mojang-profiler.patch @@ -203,10 +203,10 @@ index 18071dcc69cc28471dddb7de94e803ec1e5fc2e4..aa25f5ebaf7d1b22825b962b02dcae02 } } diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 5d761c36739981897fe165148e528ef6b0e80b8d..ac0122e9a54c4f6e41638c79a75542fe2db3c9a4 100644 +index 5d761c36739981897fe165148e528ef6b0e80b8d..18c3599ceb7a1c9dc769af0ad4c3eff9e37e2a76 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -117,20 +117,8 @@ import net.minecraft.util.TimeUtil; +@@ -117,20 +117,9 @@ import net.minecraft.util.TimeUtil; import net.minecraft.util.debug.ServerDebugSubscribers; import net.minecraft.util.debugchart.SampleLogger; import net.minecraft.util.debugchart.TpsDebugDimensions; @@ -216,7 +216,7 @@ index 5d761c36739981897fe165148e528ef6b0e80b8d..ac0122e9a54c4f6e41638c79a75542fe -import net.minecraft.util.profiling.ProfilerFiller; -import net.minecraft.util.profiling.ResultField; -import net.minecraft.util.profiling.SingleTickProfiler; --import net.minecraft.util.profiling.jfr.Environment; + import net.minecraft.util.profiling.jfr.Environment; import net.minecraft.util.profiling.jfr.JvmProfiler; import net.minecraft.util.profiling.jfr.callback.ProfiledDuration; -import net.minecraft.util.profiling.metrics.profiling.ActiveMetricsRecorder; @@ -227,7 +227,7 @@ index 5d761c36739981897fe165148e528ef6b0e80b8d..ac0122e9a54c4f6e41638c79a75542fe import net.minecraft.util.thread.ReentrantBlockableEventLoop; import net.minecraft.world.Difficulty; import net.minecraft.world.RandomSequences; -@@ -203,13 +191,6 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop tickables = Lists.newArrayList(); @@ -241,7 +241,17 @@ index 5d761c36739981897fe165148e528ef6b0e80b8d..ac0122e9a54c4f6e41638c79a75542fe private ServerConnectionListener connection; // Paper - per world load listener - moved LevelLoadListener to ServerLevel @Nullable -@@ -1164,10 +1145,6 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0 && this.tickCount % autosavePeriod == 0; try { this.isSaving = true; -@@ -1660,10 +1605,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop serverPlayer1.connection.suspendFlushing()); this.server.getScheduler().mainThreadHeartbeat(); // CraftBukkit // Paper start - optimise Folia entity scheduler -@@ -1771,9 +1710,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0; // Purpur - Ridables @@ -467,7 +477,7 @@ index 5d761c36739981897fe165148e528ef6b0e80b8d..ac0122e9a54c4f6e41638c79a75542fe try { serverLevel.tick(hasTimeLeft); } catch (Throwable var7) { -@@ -1829,37 +1761,25 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop biomeRegistry, ++ PalettedContainerFactory containerFactory, + ChunkPos chunkPos, + int minSectionY, + long lastUpdateTime, @@ -298,7 +298,7 @@ index 84840f50d1bcebc7b0bdb1d2f79b53fd6fc98abb..38cdc0f8ce03cfd99658177f609ba3a6 + CompoundTag structureData, + @Nullable net.minecraft.nbt.Tag persistentDataContainer // CraftBukkit - persistentDataContainer + ) { -+ this(biomeRegistry, ++ this(containerFactory, + chunkPos, + minSectionY, + lastUpdateTime, diff --git a/divinemc-server/minecraft-patches/features/0022-ModernFix-compact_bit_storage.patch b/divinemc-server/minecraft-patches/features/0022-ModernFix-compact_bit_storage.patch index d1b8ab3..49f7932 100644 --- a/divinemc-server/minecraft-patches/features/0022-ModernFix-compact_bit_storage.patch +++ b/divinemc-server/minecraft-patches/features/0022-ModernFix-compact_bit_storage.patch @@ -10,7 +10,7 @@ As part of: ModernFix (https://github.com/embeddedt/ModernFix) Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) diff --git a/net/minecraft/world/level/chunk/PalettedContainer.java b/net/minecraft/world/level/chunk/PalettedContainer.java -index f1cae4cab36546d5798d2b59ac59774d1c9838c0..731da3f35013d9916577a7f475d6a796dd201742 100644 +index f1cae4cab36546d5798d2b59ac59774d1c9838c0..3baf84b3f636a3ea04945cb4c0f17acd7109bedb 100644 --- a/net/minecraft/world/level/chunk/PalettedContainer.java +++ b/net/minecraft/world/level/chunk/PalettedContainer.java @@ -283,6 +283,28 @@ public class PalettedContainer implements PaletteResize, PalettedContainer @@ -35,7 +35,7 @@ index f1cae4cab36546d5798d2b59ac59774d1c9838c0..731da3f35013d9916577a7f475d6a796 + return; + } + this.data = this.createOrReuseData(null, 0); -+ this.data.palette.idFor(value); ++ this.data.palette.idFor(value, this); + } + } + // DivineMC end - ModernFix: compact_bit_storage diff --git a/divinemc-server/minecraft-patches/features/0035-Implement-NoChatReports.patch b/divinemc-server/minecraft-patches/features/0035-Implement-NoChatReports.patch index 4cc81b9..3f8a0b2 100644 --- a/divinemc-server/minecraft-patches/features/0035-Implement-NoChatReports.patch +++ b/divinemc-server/minecraft-patches/features/0035-Implement-NoChatReports.patch @@ -99,7 +99,7 @@ index b5afc05924ae899e020c303c8b86398e1d4ab8a0..2a6fdec4faae3512060cbb21a2043129 + // DivineMC end - Implement NoChatReports } diff --git a/net/minecraft/network/protocol/game/ServerboundChatSessionUpdatePacket.java b/net/minecraft/network/protocol/game/ServerboundChatSessionUpdatePacket.java -index 1df628ac0b414511aaed6e09d78f884c4170f730..1543f730843c1736c4db9a6ebe30be9cc9fbe36a 100644 +index 1df628ac0b414511aaed6e09d78f884c4170f730..aba42c2ea4f2dde395edbded3bc96e58d213908f 100644 --- a/net/minecraft/network/protocol/game/ServerboundChatSessionUpdatePacket.java +++ b/net/minecraft/network/protocol/game/ServerboundChatSessionUpdatePacket.java @@ -26,6 +26,19 @@ public record ServerboundChatSessionUpdatePacket(RemoteChatSession.Data chatSess @@ -110,7 +110,7 @@ index 1df628ac0b414511aaed6e09d78f884c4170f730..1543f730843c1736c4db9a6ebe30be9c + if (org.bxteam.divinemc.config.DivineConfig.NetworkCategory.noChatReportsEnabled) { + var impl = (net.minecraft.server.network.ServerGamePacketListenerImpl) handler; + -+ if (!impl.getPlayer().getServer().isSingleplayerOwner(impl.getPlayer().getGameProfile())) { ++ if (!impl.getPlayer().level().getServer().isSingleplayerOwner(impl.getPlayer().nameAndId())) { + if (org.bxteam.divinemc.config.DivineConfig.NetworkCategory.noChatReportsDemandOnClient) { + impl.disconnect(net.minecraft.network.chat.Component.literal(org.bxteam.divinemc.config.DivineConfig.NetworkCategory.noChatReportsDisconnectDemandOnClientMessage)); + } diff --git a/divinemc-server/minecraft-patches/features/0036-Lag-compensation.patch b/divinemc-server/minecraft-patches/features/0036-Lag-compensation.patch index be18914..f60d22f 100644 --- a/divinemc-server/minecraft-patches/features/0036-Lag-compensation.patch +++ b/divinemc-server/minecraft-patches/features/0036-Lag-compensation.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Lag compensation diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index ac0122e9a54c4f6e41638c79a75542fe2db3c9a4..558445fbaeddf33506dea7080b3a76e6aa87f21f 100644 +index 18c3599ceb7a1c9dc769af0ad4c3eff9e37e2a76..89aa020832fb9894e057b0f2b1226eb48c8accd1 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -286,6 +286,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop level = new java.util.concurrent.atomic.AtomicReference<>(); + + private int lagCompensation(int original, GameRules.Key rule) { -+ ServerLevel level = getOrCacheLevel(); ++ net.minecraft.server.level.ServerLevel level = getOrCacheLevel(); + if (!org.bxteam.divinemc.config.DivineConfig.MiscCategory.lagCompensationEnabled || !org.bxteam.divinemc.config.DivineConfig.MiscCategory.randomTickSpeedAcceleration) return original; + if (!(rule == GameRules.RULE_RANDOMTICKING)) return original; + return (int) (original * org.bxteam.divinemc.util.tps.TPSCalculator.MAX_TPS / (float) level.tpsCalculator.getMostAccurateTPS()); + } + -+ private ServerLevel getOrCacheLevel() { ++ private net.minecraft.server.level.ServerLevel getOrCacheLevel() { + if (level.get() == null) { -+ for (final ServerLevel level : MinecraftServer.getServer().getAllLevels()) { ++ for (final net.minecraft.server.level.ServerLevel level : MinecraftServer.getServer().getAllLevels()) { + if (level.getGameRules() == this) { + this.level.set(level); + break; diff --git a/divinemc-server/minecraft-patches/features/0037-Virtual-Threads.patch b/divinemc-server/minecraft-patches/features/0037-Virtual-Threads.patch index 96d309a..6d5dbcd 100644 --- a/divinemc-server/minecraft-patches/features/0037-Virtual-Threads.patch +++ b/divinemc-server/minecraft-patches/features/0037-Virtual-Threads.patch @@ -18,10 +18,10 @@ index 9a7a40c1dcea57ba674d8431077d2477104a456f..8e41097f978800039e6e057c5bbcfcf0 new java.util.concurrent.LinkedBlockingQueue<>(), new com.google.common.util.concurrent.ThreadFactoryBuilder() diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 558445fbaeddf33506dea7080b3a76e6aa87f21f..93a0bd04a325a0fbac2eb01f2db9f57801f2f8a9 100644 +index 89aa020832fb9894e057b0f2b1226eb48c8accd1..4ba10f90711ac8b6813f86bcff9635716fdc6028 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -2717,8 +2717,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop STREAM_CODEC = StreamCodec.of((buffer, value) -> value.writeToStream(buffer), Path::createFromStream); + public final List nodes; + @Nullable @@ -28,6 +28,17 @@ public final class Path { this.reached = reached; } diff --git a/divinemc-server/minecraft-patches/features/0046-Pufferfish-Optimize-mob-spawning.patch b/divinemc-server/minecraft-patches/features/0046-Pufferfish-Optimize-mob-spawning.patch index 2e25f27..26a8002 100644 --- a/divinemc-server/minecraft-patches/features/0046-Pufferfish-Optimize-mob-spawning.patch +++ b/divinemc-server/minecraft-patches/features/0046-Pufferfish-Optimize-mob-spawning.patch @@ -9,10 +9,10 @@ Original project: https://github.com/pufferfish-gg/Pufferfish This patch reduces the main-thread impact of mob spawning by moving spawning work to other threads diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index a876c7c47788218a86cef53330b2c07f7008b0b0..b65e35cd5bf7f3af8826cb9e9e2696921a951a62 100644 +index 4ba10f90711ac8b6813f86bcff9635716fdc6028..95e39a728b7505a273a6e9c927308ee8931ea756 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -287,6 +287,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop states = new java.util.ArrayList<>(level.capturedBlockStates.values()); level.capturedBlockStates.clear(); diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index d311370b1ab05d63e0926e762fe5a938b25a42cb..495fbb4285f7da79e35118cae9212cb29b057d97 100644 +index 95e39a728b7505a273a6e9c927308ee8931ea756..9e09e9823f53e60c819d43012905fa21d044e283 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -288,6 +288,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop serverPlayer1.connection.suspendFlushing()); this.server.getScheduler().mainThreadHeartbeat(); // CraftBukkit -@@ -1744,28 +1769,43 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop, ServerLevel> oldLevels = this.levels; Map, ServerLevel> newLevels = Maps.newLinkedHashMap(oldLevels); newLevels.remove(level.dimension()); @@ -958,7 +958,7 @@ index 358d69bdca0aa46d1952d3ef9bf9b65dc39a3338..d04167eccda1fe29abe7fc28cab0c837 serverLevel.capturedBlockStates.clear(); org.bukkit.event.world.StructureGrowEvent structureEvent = null; diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index b94b946986258fed3c6d68d9972a657e176d08a4..250978ef6e09c8744065d143af38b99914bd25ec 100644 +index c8f5462bfd4d0fd24dfb20116ad5eb3489484042..49c4d40e802f8adaba52d929ba013d3953704989 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java @@ -166,6 +166,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl diff --git a/divinemc-server/minecraft-patches/features/0053-MSPT-Tracking-for-each-world.patch b/divinemc-server/minecraft-patches/features/0053-MSPT-Tracking-for-each-world.patch index 018d121..f9a97d5 100644 --- a/divinemc-server/minecraft-patches/features/0053-MSPT-Tracking-for-each-world.patch +++ b/divinemc-server/minecraft-patches/features/0053-MSPT-Tracking-for-each-world.patch @@ -5,10 +5,10 @@ Subject: [PATCH] MSPT Tracking for each world diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 495fbb4285f7da79e35118cae9212cb29b057d97..88296555274b67dc504c4765bc9bf049545ca19a 100644 +index 9e09e9823f53e60c819d43012905fa21d044e283..e3fb85c466aca52bd4431aabbc13a4de58c2f474 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -1714,7 +1714,15 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop new CubeNode(toAst(f.input())); case HALF_NEGATIVE -> new NegMulNode(toAst(f.input()), 0.5); case QUARTER_NEGATIVE -> new NegMulNode(toAst(f.input()), 0.25); + case INVERT -> new DivNode(new ConstantNode(1.0), toAst(f.input())); case SQUEEZE -> new SqueezeNode(toAst(f.input())); }; case DensityFunctions.RangeChoice f -> new RangeChoiceNode(toAst(f.input()), f.minInclusive(), f.maxExclusive(), toAst(f.whenInRange()), toAst(f.whenOutOfRange())); diff --git a/divinemc-server/src/main/java/com/ishland/c2me/opts/dfc/common/ast/binary/DivNode.java b/divinemc-server/src/main/java/com/ishland/c2me/opts/dfc/common/ast/binary/DivNode.java new file mode 100644 index 0000000..3576ed0 --- /dev/null +++ b/divinemc-server/src/main/java/com/ishland/c2me/opts/dfc/common/ast/binary/DivNode.java @@ -0,0 +1,53 @@ +package com.ishland.c2me.opts.dfc.common.ast.binary; + +import com.ishland.c2me.opts.dfc.common.ast.AstNode; +import com.ishland.c2me.opts.dfc.common.ast.EvalType; +import com.ishland.c2me.opts.dfc.common.gen.BytecodeGen; +import org.objectweb.asm.Type; +import org.objectweb.asm.commons.InstructionAdapter; + +public class DivNode extends AbstractBinaryNode { + public DivNode(AstNode left, AstNode right) { + super(left, right); + } + + @Override + protected AstNode newInstance(AstNode left, AstNode right) { + return new DivNode(left, right); + } + + @Override + public double evalSingle(int x, int y, int z, EvalType type) { + return this.left.evalSingle(x, y, z, type) / this.right.evalSingle(x, y, z, type); + } + + @Override + public void evalMulti(double[] res, int[] x, int[] y, int[] z, EvalType type) { + double[] res1 = new double[res.length]; + this.left.evalMulti(res, x, y, z, type); + this.right.evalMulti(res1, x, y, z, type); + for (int i = 0; i < res1.length; i++) { + res[i] /= res1[i]; + } + } + + @Override + public void doBytecodeGenSingle(BytecodeGen.Context context, InstructionAdapter m, BytecodeGen.Context.LocalVarConsumer localVarConsumer) { + super.doBytecodeGenSingle(context, m, localVarConsumer); + m.div(Type.DOUBLE_TYPE); + m.areturn(Type.DOUBLE_TYPE); + } + + @Override + protected void bytecodeGenMultiBody(InstructionAdapter m, int idx, int res1) { + m.load(1, InstructionAdapter.OBJECT_TYPE); + m.load(idx, Type.INT_TYPE); + m.dup2(); + m.aload(Type.DOUBLE_TYPE); + m.load(res1, InstructionAdapter.OBJECT_TYPE); + m.load(idx, Type.INT_TYPE); + m.aload(Type.DOUBLE_TYPE); + m.div(Type.DOUBLE_TYPE); + m.astore(Type.DOUBLE_TYPE); + } +} diff --git a/divinemc-server/src/main/java/org/bxteam/divinemc/command/subcommands/MSPTCommand.java b/divinemc-server/src/main/java/org/bxteam/divinemc/command/subcommands/MSPTCommand.java index 2ec4aaa..66b772c 100644 --- a/divinemc-server/src/main/java/org/bxteam/divinemc/command/subcommands/MSPTCommand.java +++ b/divinemc-server/src/main/java/org/bxteam/divinemc/command/subcommands/MSPTCommand.java @@ -1,5 +1,6 @@ package org.bxteam.divinemc.command.subcommands; +import ca.spottedleaf.moonrise.common.time.TickData; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.minecraft.server.MinecraftServer; @@ -59,7 +60,7 @@ public final class MSPTCommand extends DivineSubCommandPermission { } private void displayCompactStats(CommandSender sender, MinecraftServer server) { - List serverTimes = eval(server.tickTimes5s.getTimes()); + List serverTimes = evalFromTickData(server.tickTimes5s, server.tickRateManager().nanosecondsPerTick()); sender.sendMessage(Component.text("Server: ", GOLD) .append(joinComponents(serverTimes, SLASH))); @@ -68,7 +69,7 @@ public final class MSPTCommand extends DivineSubCommandPermission { for (int i = 0; i < worlds.size(); i++) { ServerLevel level = worlds.get(i); - List worldTimes = eval(level.tickTimes5s.getTimes()); + List worldTimes = evalFromTickData(level.getServer().tickTimes5s, server.tickRateManager().nanosecondsPerTick()); sender.sendMessage(Component.text(level.getWorld().getName() + ": ", GOLD) .append(joinComponents(worldTimes, SLASH))); if (i < worlds.size() - 1) { @@ -81,9 +82,10 @@ public final class MSPTCommand extends DivineSubCommandPermission { sender.sendMessage(Component.text("Server tick times ", GOLD) .append(Component.text("(avg/min/max)", YELLOW))); - sendTickLine(sender, " 5s: ", eval(server.tickTimes5s.getTimes()), GOLD, SLASH); - sendTickLine(sender, " 10s: ", eval(server.tickTimes10s.getTimes()), GOLD, SLASH); - sendTickLine(sender, " 60s: ", eval(server.tickTimes60s.getTimes()), GOLD, SLASH); + long tickInterval = server.tickRateManager().nanosecondsPerTick(); + sendTickLine(sender, " 5s: ", evalFromTickData(server.tickTimes5s, tickInterval), GOLD, SLASH); + sendTickLine(sender, " 10s: ", evalFromTickData(server.tickTimes10s, tickInterval), GOLD, SLASH); + sendTickLine(sender, " 60s: ", evalFromTickData(server.tickTimes1m, tickInterval), GOLD, SLASH); } private void displayWorldMSPT(CommandSender sender, MinecraftServer server) { @@ -133,6 +135,26 @@ public final class MSPTCommand extends DivineSubCommandPermission { return Arrays.asList(getColoredValue(avg), getColoredValue(min), getColoredValue(max)); } + private static List evalFromTickData(ca.spottedleaf.moonrise.common.time.TickData tickData, long tickInterval) { + TickData.TickReportData report = tickData.generateTickReport(null, System.nanoTime(), tickInterval); + + if (report == null) { + return Arrays.asList( + Component.text("N/A", GRAY), + Component.text("N/A", GRAY), + Component.text("N/A", GRAY) + ); + } + + TickData.SegmentData segmentAll = report.timePerTickData().segmentAll(); + + double avg = segmentAll.average() * 1.0E-6; + double min = segmentAll.least() * 1.0E-6; + double max = segmentAll.greatest() * 1.0E-6; + + return Arrays.asList(getColoredValue(avg), getColoredValue(min), getColoredValue(max)); + } + private static Component getColoredValue(double value) { NamedTextColor color = value >= 50 ? RED : value >= 40 ? YELLOW diff --git a/divinemc-server/src/main/java/org/bxteam/divinemc/config/DivineConfig.java b/divinemc-server/src/main/java/org/bxteam/divinemc/config/DivineConfig.java index ba79347..cdf7099 100644 --- a/divinemc-server/src/main/java/org/bxteam/divinemc/config/DivineConfig.java +++ b/divinemc-server/src/main/java/org/bxteam/divinemc/config/DivineConfig.java @@ -11,7 +11,6 @@ import org.bxteam.divinemc.config.annotations.Experimental; import org.bxteam.divinemc.async.pathfinding.PathfindTaskRejectPolicy; import org.bxteam.divinemc.region.EnumRegionFileExtension; import org.bxteam.divinemc.region.type.LinearRegionFile; -import org.bxteam.divinemc.async.AsyncJoinHandler; import org.jetbrains.annotations.Nullable; import org.simpleyaml.configuration.comments.CommentType; import org.simpleyaml.configuration.file.YamlFile; diff --git a/divinemc-server/src/main/java/org/leavesmc/leaves/protocol/AppleSkinProtocol.java b/divinemc-server/src/main/java/org/leavesmc/leaves/protocol/AppleSkinProtocol.java index dd2bf73..ac7126f 100644 --- a/divinemc-server/src/main/java/org/leavesmc/leaves/protocol/AppleSkinProtocol.java +++ b/divinemc-server/src/main/java/org/leavesmc/leaves/protocol/AppleSkinProtocol.java @@ -54,7 +54,7 @@ public class AppleSkinProtocol implements LeavesProtocol { @ProtocolHandler.MinecraftRegister(onlyNamespace = true) public static void onPlayerSubscribed(@NotNull Context context, ResourceLocation id) { - subscribedChannels.computeIfAbsent(context.profile().getId(), k -> new HashSet<>()).add(id.getPath()); + subscribedChannels.computeIfAbsent(context.profile().id(), k -> new HashSet<>()).add(id.getPath()); } @ProtocolHandler.Ticker diff --git a/divinemc-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/CampfireProvider.java b/divinemc-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/CampfireProvider.java index 2deb377..99188a4 100644 --- a/divinemc-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/CampfireProvider.java +++ b/divinemc-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/CampfireProvider.java @@ -36,9 +36,8 @@ public enum CampfireProvider implements IServerExtensionProvider { } stack = stack.copy(); - CustomData customData = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY) - .update(NbtOps.INSTANCE, COOKING_TIME_CODEC, campfire.cookingTime[i] - campfire.cookingProgress[i]) - .getOrThrow(); + int time = campfire.cookingTime[i] - campfire.cookingProgress[i]; + CustomData customData = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY).update(tag -> tag.putInt("jade:cooking", time)); stack.set(DataComponents.CUSTOM_DATA, customData); list.add(stack); diff --git a/divinemc-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/ChiseledBookshelfProvider.java b/divinemc-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/ChiseledBookshelfProvider.java index 12fdbc3..d2bcd59 100644 --- a/divinemc-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/ChiseledBookshelfProvider.java +++ b/divinemc-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/ChiseledBookshelfProvider.java @@ -13,6 +13,8 @@ import org.leavesmc.leaves.protocol.jade.accessor.BlockAccessor; import org.leavesmc.leaves.protocol.jade.provider.ItemStorageProvider; import org.leavesmc.leaves.protocol.jade.provider.StreamServerDataProvider; +import static net.minecraft.world.level.block.CampfireBlock.FACING; + public enum ChiseledBookshelfProvider implements StreamServerDataProvider { INSTANCE; @@ -20,7 +22,7 @@ public enum ChiseledBookshelfProvider implements StreamServerDataProvider { +public enum AnimalOwnerProvider implements StreamServerDataProvider { INSTANCE; private static final ResourceLocation MC_ANIMAL_OWNER = JadeProtocol.mc_id("animal_owner"); @@ -32,17 +37,37 @@ public enum AnimalOwnerProvider implements StreamServerDataProvider streamCodec() { - return ByteBufCodecs.STRING_UTF8.cast(); + public @NotNull StreamCodec streamCodec() { + return ComponentSerialization.STREAM_CODEC; } @Override public ResourceLocation getUid() { return MC_ANIMAL_OWNER; } -} \ No newline at end of file +} diff --git a/divinemc-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/CommonUtil.java b/divinemc-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/CommonUtil.java index 4e48a26..30deeb8 100644 --- a/divinemc-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/CommonUtil.java +++ b/divinemc-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/CommonUtil.java @@ -1,20 +1,15 @@ package org.leavesmc.leaves.protocol.jade.util; -import com.mojang.authlib.GameProfile; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.boss.EnderDragonPart; import net.minecraft.world.entity.boss.enderdragon.EnderDragon; -import net.minecraft.world.level.block.entity.SkullBlockEntity; -import org.jetbrains.annotations.Nullable; import org.leavesmc.leaves.LeavesLogger; import org.leavesmc.leaves.protocol.jade.accessor.Accessor; import org.leavesmc.leaves.protocol.jade.provider.IServerExtensionProvider; import java.util.List; import java.util.Map; -import java.util.Optional; -import java.util.UUID; public class CommonUtil { @@ -42,16 +37,6 @@ public class CommonUtil { } - @Nullable - public static String getLastKnownUsername(@Nullable UUID uuid) { - if (uuid == null) { - return null; - } - Optional optional = SkullBlockEntity.fetchGameProfile(String.valueOf(uuid)).getNow(Optional.empty()); - return optional.map(GameProfile::getName).orElse(null); - } - - public static Map.Entry>> getServerExtensionData( Accessor accessor, WrappedHierarchyLookup> lookup) { diff --git a/divinemc-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java b/divinemc-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java index c9fcf90..ddd6be8 100644 --- a/divinemc-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java +++ b/divinemc-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java @@ -55,7 +55,7 @@ public class CommunicationManager implements LeavesProtocol { final VersionHandshakeServer hi = new VersionHandshakeServer(newPlayer); playerMap.put(newPlayer, player); final GameProfile profile = player.getGameProfile(); - SyncmaticaProtocol.getPlayerIdentifierProvider().updateName(profile.getId(), profile.getName()); + SyncmaticaProtocol.getPlayerIdentifierProvider().updateName(profile.id(), profile.name()); startExchangeUnchecked(hi); } @@ -149,7 +149,7 @@ public class CommunicationManager implements LeavesProtocol { final UUID placementId = packetBuf.readUUID(); final ServerPlacement placement = SyncmaticaProtocol.getSyncmaticManager().getPlacement(placementId); if (placement != null) { - if (!getGameProfile(source).getId().equals(placement.getOwner().uuid)) { + if (!getGameProfile(source).id().equals(placement.getOwner().uuid)) { return; } diff --git a/divinemc-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PlayerIdentifierProvider.java b/divinemc-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PlayerIdentifierProvider.java index 4a6248f..a4f983a 100644 --- a/divinemc-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PlayerIdentifierProvider.java +++ b/divinemc-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PlayerIdentifierProvider.java @@ -22,7 +22,7 @@ public class PlayerIdentifierProvider { } public PlayerIdentifier createOrGet(final @NotNull GameProfile gameProfile) { - return createOrGet(gameProfile.getId(), gameProfile.getName()); + return createOrGet(gameProfile.id(), gameProfile.name()); } public PlayerIdentifier createOrGet(final UUID uuid, final String playerName) {