Skip to content

Commit

Permalink
Some work
Browse files Browse the repository at this point in the history
(⊙o⊙)哇
  • Loading branch information
Dreeam-qwq committed Dec 13, 2024
1 parent f6287a8 commit dcb406a
Show file tree
Hide file tree
Showing 16 changed files with 206 additions and 178 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ group = cn.dreeam.leaf
mcVersion = 1.21.3
version = 1.21.3-R0.1-SNAPSHOT

galeCommit = abd27587a83632c04b1018976b783425e980b1f2
galeCommit = 3ec901d62b70f97c091a7557d17d05272270f367

org.gradle.caching = true
org.gradle.parallel = true
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions patches/server/0010-Purpur-Server-Changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -3290,11 +3290,11 @@ index 18dad0825616c4167a0a7555689ee64910a87e09..6945992491027d43eca4f1ca697ad45c
&& this.lookTime > 0
&& entity.getBrain().getMemory(MemoryModuleType.INTERACTION_TARGET).isPresent();
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/TradeWithVillager.java b/src/main/java/net/minecraft/world/entity/ai/behavior/TradeWithVillager.java
index 73e20e1f7d2bb1cd3d08e6bdca50efac22c9d958..b96e596fb123f5b69d2b2f5b4a65537beaab33e6 100644
index 90ae43979e05839d676ab51feb489955ecbee50e..1acf55dd527ac06a46f7e29a720ec53565ddcb9d 100644
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/TradeWithVillager.java
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/TradeWithVillager.java
@@ -62,6 +62,12 @@ public class TradeWithVillager extends Behavior<Villager> {
throwHalfStack(entity, Villager.FOOD_POINTS_KEY_ARRAY, villager); // Gale - optimize villager data storage
throwHalfStack(entity, WHEAT_SINGLETON_ARRAY, villager); // Gale - optimize villager data storage
}

+ // Purpur start
Expand Down
58 changes: 58 additions & 0 deletions patches/server/0023-Carpet-Fixes-Use-optimized-RecipeManager.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: nostalgic853 <[email protected]>
Date: Tue, 25 Oct 2022 00:57:45 +0800
Subject: [PATCH] Carpet-Fixes: Use optimized RecipeManager

This patch is based on the following mixin:
"carpetfixes/mixins/optimizations/RecipeManager_fasterMixin.java"
By: fxmorin <[email protected]>

Original license: MIT
Original project: https://github.com/fxmorin/carpet-fixes

Optimized the RecipeManager getFirstMatch call to be up to 3x faster
This is a fully vanilla optimization. Improves: [Blast]Furnace/Campfire/Smoker/Stonecutter/Crafting/Sheep Color Choosing
This was mostly made for the auto crafting table, since the performance boost is much more visible while using that mod

diff --git a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
index f6dd363ececf967d282f5ba713013085da1ddf37..1e05a89a4e4e3a5d2fa9f7dc72fd89a9e0d93468 100644
--- a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
+++ b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
@@ -195,7 +195,7 @@ public class RecipeManager extends SimplePreparableReloadListener<RecipeMap> imp

public <I extends RecipeInput, T extends Recipe<I>> Optional<RecipeHolder<T>> getRecipeFor(RecipeType<T> type, I input, Level world) {
// CraftBukkit start
- List<RecipeHolder<T>> list = this.recipes.getRecipesFor(type, input, world).toList();
+ List<RecipeHolder<T>> list = this.recipes.getRecipesForList(type, input, world); // Leaf - Carpet-Fixes - Remove streams to be faster
return (list.isEmpty()) ? Optional.empty() : Optional.of(list.getLast()); // CraftBukkit - SPIGOT-4638: last recipe gets priority
// CraftBukkit end
}
diff --git a/src/main/java/net/minecraft/world/item/crafting/RecipeMap.java b/src/main/java/net/minecraft/world/item/crafting/RecipeMap.java
index c4067fbf827fed882772962a0e4b3ead0d642e62..c62ecec9bbc40f66b84d384bacf39d6d09e10a61 100644
--- a/src/main/java/net/minecraft/world/item/crafting/RecipeMap.java
+++ b/src/main/java/net/minecraft/world/item/crafting/RecipeMap.java
@@ -105,4 +105,24 @@ public class RecipeMap {
return recipeholder.value().matches(input, world);
});
}
+
+ // Leaf start - Carpet-Fixes - Remove streams to be faster
+ public <I extends RecipeInput, T extends Recipe<I>> java.util.List<RecipeHolder<T>> getRecipesForList(RecipeType<T> type, I input, Level world) {
+ java.util.List<RecipeHolder<T>> list;
+
+ if (input.isEmpty()) {
+ return java.util.List.of();
+ } else {
+ list = new java.util.ArrayList<>();
+ }
+
+ for (RecipeHolder<T> recipeholder : this.byType(type)) {
+ if (recipeholder.value().matches(input, world)) {
+ list.add(recipeholder);
+ }
+ }
+
+ return list;
+ }
+ // Leaf end - Carpet-Fixes - Remove streams to be faster
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ and change store way to sql maybe?
Original license: GPLv3
Original project: https://github.com/LeavesMC/Leaves

Commit: 0fcb32c478a8137e692664f332ad2eb0fdd7939b
Commit: aeeef2213c2295288b71c9162cbe008c4a3defd9

diff --git a/src/main/java/org/leavesmc/leaves/LeavesLogger.java b/src/main/java/org/leavesmc/leaves/LeavesLogger.java
new file mode 100644
index 0000000000000000000000000000000000000000..47347a3bdab2ff9818bf8198291d2dabec7da8c6
index 0000000000000000000000000000000000000000..bc45935c96553c9bd9d9b6ab3a64e28f52862198
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/LeavesLogger.java
@@ -0,0 +1,24 @@
Expand All @@ -34,10 +34,10 @@ index 0000000000000000000000000000000000000000..47347a3bdab2ff9818bf8198291d2dab
+ }
+
+ public void severe(String msg, Exception exception) {
+ this.severe(msg + ", " + exception.getCause() + ": " + exception.getMessage());
+ this.log(Level.SEVERE, msg, exception);
+ }
+
+ public void warning(String msg, Exception exception) {
+ this.warning(msg + ", " + exception.getCause() + ": " + exception.getMessage());
+ this.log(Level.WARNING, msg, exception);
+ }
+}
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ index 1967c43ee3a12e63365cc40ee6565307e2fd73cf..6e376d0db5321d8e9b6e0b54617ffd17

assert isValidPath(path);
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index ccd94b0a8822b17bd218aa95e302a28196849027..bc4f50c55741c2a664f456a3b7555644ad224d53 100644
index 2550e0e4e40eccb6e01cd0b8287358c105abaebf..f52eb8f076a007167647e49db2734cd43f88b0b6 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1815,6 +1815,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1876,6 +1876,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
GameTestTicker.SINGLETON.tick();
}

Expand All @@ -62,10 +62,10 @@ index ccd94b0a8822b17bd218aa95e302a28196849027..bc4f50c55741c2a664f456a3b7555644
((Runnable) this.tickables.get(i)).run();
}
diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
index 499572fe78f3b0918d2bbf6ead15a2acf6a07007..8a3736dbf6ee0b2c6fbb514b2841154d2ad9f0f5 100644
index 32ab2e0f7bae7d0a54cebdd46c95e574c41ad1e3..c79e9930b090057487b9c83b79935639d885e67b 100644
--- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
@@ -166,6 +166,11 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
@@ -172,6 +172,11 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack

@Override
public void handleCustomPayload(ServerboundCustomPayloadPacket packet) {
Expand All @@ -77,7 +77,7 @@ index 499572fe78f3b0918d2bbf6ead15a2acf6a07007..8a3736dbf6ee0b2c6fbb514b2841154d
// Paper start - Brand support
if (packet.payload() instanceof net.minecraft.network.protocol.common.custom.BrandPayload brandPayload) {
this.player.clientBrandName = brandPayload.brand();
@@ -183,6 +188,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
@@ -189,6 +194,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
String channels = payload.toString(com.google.common.base.Charsets.UTF_8);
for (String channel : channels.split("\0")) {
this.getCraftPlayer().addChannel(channel);
Expand All @@ -86,10 +86,10 @@ index 499572fe78f3b0918d2bbf6ead15a2acf6a07007..8a3736dbf6ee0b2c6fbb514b2841154d
} catch (Exception ex) {
ServerGamePacketListenerImpl.LOGGER.error("Couldn\'t register custom payload", ex);
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 26a92a77481c46969b68e454b906b3935ad02043..73d67b3bebcf3dff210e25dda0b3df206e129173 100644
index e1ceb6added5c5d473cf25162b77c7cf6bf9da49..f846281cf11357249aea45e1add3e05150bb5615 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -360,6 +360,8 @@ public abstract class PlayerList {
@@ -364,6 +364,8 @@ public abstract class PlayerList {

player.didPlayerJoinEvent = true; // Gale - EMC - do not process chat/commands before player has joined

Expand All @@ -98,7 +98,7 @@ index 26a92a77481c46969b68e454b906b3935ad02043..73d67b3bebcf3dff210e25dda0b3df20
final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage();

if (jm != null && !jm.equals(net.kyori.adventure.text.Component.empty())) { // Paper - Adventure
@@ -607,6 +609,7 @@ public abstract class PlayerList {
@@ -557,6 +559,7 @@ public abstract class PlayerList {
return this.remove(entityplayer, net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? entityplayer.getBukkitEntity().displayName() : io.papermc.paper.adventure.PaperAdventure.asAdventure(entityplayer.getDisplayName())));
}
public net.kyori.adventure.text.Component remove(ServerPlayer entityplayer, net.kyori.adventure.text.Component leaveMessage) {
Expand All @@ -107,18 +107,18 @@ index 26a92a77481c46969b68e454b906b3935ad02043..73d67b3bebcf3dff210e25dda0b3df20
org.purpurmc.purpur.task.BossBarTask.removeFromAll(entityplayer.getBukkitEntity()); // Purpur
ServerLevel worldserver = entityplayer.serverLevel();
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 8365daf4b9da71b68493a309f11b94de1e8d56cf..b3cf26055a85aefe0ef19a843733b6dfe93d2641 100644
index b4986e322cb05ad6f98bbf5eee2b571c67e4d9d3..073ad95dc56f3b8d35913058a8eddcd610997124 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -491,6 +491,7 @@ public final class CraftServer implements Server {
@@ -506,6 +506,7 @@ public final class CraftServer implements Server {
this.potionBrewer = new io.papermc.paper.potion.PaperPotionBrewer(console); // Paper - custom potion mixes
datapackManager = new io.papermc.paper.datapack.PaperDatapackManager(console.getPackRepository()); // Paper
this.spark = new io.papermc.paper.SparksFly(this); // Paper - spark
+ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.init(); // Leaves - protocol
}

public boolean getCommandBlockOverride(String command) {
@@ -1122,6 +1123,7 @@ public final class CraftServer implements Server {
@@ -1137,6 +1138,7 @@ public final class CraftServer implements Server {
org.purpurmc.purpur.PurpurConfig.registerCommands(); // Purpur
this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*");
this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions");
Expand Down Expand Up @@ -202,10 +202,10 @@ index 0000000000000000000000000000000000000000..986d2a6641ff8017dddf3e5f2655adfc
+}
diff --git a/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java b/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java
new file mode 100644
index 0000000000000000000000000000000000000000..b76eb38942171d22dcd767ea353f012e5920f1f5
index 0000000000000000000000000000000000000000..87b1502c1b980d33cae205ae35d336f7450e5e94
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java
@@ -0,0 +1,436 @@
@@ -0,0 +1,435 @@
+package org.leavesmc.leaves.protocol.core;
+
+import com.google.common.collect.ImmutableSet;
Expand Down Expand Up @@ -493,10 +493,9 @@ index 0000000000000000000000000000000000000000..b76eb38942171d22dcd767ea353f012e
+
+ Map<ProtocolHandler.MinecraftRegister, Method> map = MINECRAFT_REGISTER.get(protocol);
+ for (ProtocolHandler.MinecraftRegister register : map.keySet()) {
+ if (register.ignoreId() || register.channelId().equals(channel[1]) ||
+ ArrayUtils.contains(register.channelIds(), channel[1])) {
+ if (register.ignoreId() || ArrayUtils.contains(register.channelId(), channel[1])) {
+ try {
+ map.get(register).invoke(null, player);
+ map.get(register).invoke(null, player, channel[1]);
+ } catch (InvocationTargetException | IllegalAccessException exception) {
+ LOGGER.warning("Failed to handle minecraft register, " + exception.getCause() + ": " + exception.getMessage());
+ }
Expand Down Expand Up @@ -644,10 +643,10 @@ index 0000000000000000000000000000000000000000..b76eb38942171d22dcd767ea353f012e
+}
diff --git a/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolHandler.java b/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolHandler.java
new file mode 100644
index 0000000000000000000000000000000000000000..9d71f8e6af24301bedf60f5c87e0bb3c1697d5e3
index 0000000000000000000000000000000000000000..22f47824e0d0ae9050d3a7fd6f59e1d0a7cde561
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolHandler.java
@@ -0,0 +1,63 @@
@@ -0,0 +1,56 @@
+package org.leavesmc.leaves.protocol.core;
+
+import java.lang.annotation.ElementType;
Expand All @@ -660,13 +659,11 @@ index 0000000000000000000000000000000000000000..9d71f8e6af24301bedf60f5c87e0bb3c
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface Init {
+
+ }
+
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface PayloadReceiver {
+
+ Class<? extends LeavesCustomPayload<?>> payload();
+
+ String[] payloadId() default "";
Expand All @@ -685,28 +682,23 @@ index 0000000000000000000000000000000000000000..9d71f8e6af24301bedf60f5c87e0bb3c
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface PlayerJoin {
+
+ }
+
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface PlayerLeave {
+
+ }
+
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface ReloadServer {
+
+ }
+
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface MinecraftRegister {
+
+ String channelId() default "";
+
+ String[] channelIds() default {};
+ String[] channelId() default "";
+
+ boolean ignoreId() default false;
+ }
Expand Down
Loading

0 comments on commit dcb406a

Please sign in to comment.