diff --git a/patches/server/0026-Fix-MC-31819.patch b/patches/server/0026-Fix-MC-31819.patch new file mode 100644 index 0000000..0f2432c --- /dev/null +++ b/patches/server/0026-Fix-MC-31819.patch @@ -0,0 +1,25 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com> +Date: Sat, 8 Apr 2023 01:13:16 +0300 +Subject: [PATCH] Fix MC-31819 + +The food saturation value is depleted on peaceful, even though the displayed hunger bar never goes down. +Hunger (or any related value, including saturation) should not go down on peaceful. +Original bug on Mojira: https://bugs.mojang.com/browse/MC-31819 + +diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java +index 71c22dfc5d6b86b812a6b2be1cd7fe2338471734..61a69dff027875afae4d54c52a098de05e64d19a 100644 +--- a/src/main/java/net/minecraft/world/entity/player/Player.java ++++ b/src/main/java/net/minecraft/world/entity/player/Player.java +@@ -1951,6 +1951,11 @@ public abstract class Player extends LivingEntity { + } + + public void causeFoodExhaustion(float f, EntityExhaustionEvent.ExhaustionReason reason) { ++ // DivineMC start - Fix MC-31819 ++ if (this.level.getDifficulty() == Difficulty.PEACEFUL) { ++ return; ++ } ++ // DivineMC end + // CraftBukkit end + if (!this.abilities.invulnerable) { + if (!this.level.isClientSide) { diff --git a/patches/server/0027-lithium-collections.goals.patch b/patches/server/0027-lithium-collections.goals.patch new file mode 100644 index 0000000..17e984f --- /dev/null +++ b/patches/server/0027-lithium-collections.goals.patch @@ -0,0 +1,27 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com> +Date: Sat, 8 Apr 2023 01:22:35 +0300 +Subject: [PATCH] lithium: collections.goals + + +diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java +index 02978315bc2b828cc603ce7478408f3f82c249c2..d8ee71cb3afc0f63669d26c4160f7cd7ed2fd453 100644 +--- a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java ++++ b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java +@@ -13,6 +13,7 @@ import java.util.function.Supplier; + import java.util.stream.Stream; + import net.minecraft.util.profiling.ProfilerFiller; + import org.slf4j.Logger; ++import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet; + + public class GoalSelector { + private static final Logger LOGGER = LogUtils.getLogger(); +@@ -28,7 +29,7 @@ public class GoalSelector { + } + }; + private final Map lockedFlags = new EnumMap<>(Goal.Flag.class); +- private final Set availableGoals = Sets.newLinkedHashSet(); ++ private final Set availableGoals = new ObjectLinkedOpenHashSet<>(); // DivineMC - lithium: collections.goals + private final Supplier profiler; + private final EnumSet disabledFlags = EnumSet.noneOf(Goal.Flag.class); // Paper unused, but dummy to prevent plugins from crashing as hard. Theyll need to support paper in a special case if this is super important, but really doesn't seem like it would be. + private final com.destroystokyo.paper.util.set.OptimizedSmallEnumSet goalTypes = new com.destroystokyo.paper.util.set.OptimizedSmallEnumSet<>(Goal.Flag.class); // Paper - remove streams from pathfindergoalselector diff --git a/patches/server/0028-lithium-collections.gamerules.patch b/patches/server/0028-lithium-collections.gamerules.patch new file mode 100644 index 0000000..f56eced --- /dev/null +++ b/patches/server/0028-lithium-collections.gamerules.patch @@ -0,0 +1,27 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com> +Date: Sat, 8 Apr 2023 01:28:01 +0300 +Subject: [PATCH] lithium: collections.gamerules + + +diff --git a/src/main/java/net/minecraft/world/level/GameRules.java b/src/main/java/net/minecraft/world/level/GameRules.java +index 29d1f78dbc8410f9292f409b17705acde55979df..6310b0e2daedddd5b1e9d983d43baa4653e22344 100644 +--- a/src/main/java/net/minecraft/world/level/GameRules.java ++++ b/src/main/java/net/minecraft/world/level/GameRules.java +@@ -27,6 +27,7 @@ import net.minecraft.network.protocol.game.ClientboundGameEventPacket; + import net.minecraft.server.MinecraftServer; + import net.minecraft.server.level.ServerPlayer; + import org.slf4j.Logger; ++import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; + + public class GameRules { + +@@ -127,7 +128,7 @@ public class GameRules { + } + + private GameRules(Map, GameRules.Value> rules) { +- this.rules = rules; ++ this.rules = new Object2ObjectOpenHashMap<>(rules); // DivineMC - lithium: collections.gamerules + + // Pufferfish start + int arraySize = rules.keySet().stream().mapToInt(key -> key.gameRuleIndex).max().orElse(-1) + 1; diff --git a/patches/server/0029-lithium-collections.attributes.patch b/patches/server/0029-lithium-collections.attributes.patch new file mode 100644 index 0000000..16c0a6d --- /dev/null +++ b/patches/server/0029-lithium-collections.attributes.patch @@ -0,0 +1,37 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com> +Date: Sat, 8 Apr 2023 01:40:11 +0300 +Subject: [PATCH] lithium: collections.attributes + + +diff --git a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java +index 210a0bee1227e4671909dd553ab22027cfc868fb..083621765f9936df869ec1f90133198cf882e7fa 100644 +--- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java ++++ b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java +@@ -1,8 +1,6 @@ + package net.minecraft.world.entity.ai.attributes; + +-import com.google.common.collect.Maps; + import com.google.common.collect.Multimap; +-import com.google.common.collect.Sets; + import com.mojang.logging.LogUtils; + import java.util.Collection; + import java.util.Map; +@@ -17,11 +15,15 @@ import net.minecraft.nbt.CompoundTag; + import net.minecraft.nbt.ListTag; + import net.minecraft.resources.ResourceLocation; + import org.slf4j.Logger; ++import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap; ++import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet; + + public class AttributeMap { + private static final Logger LOGGER = LogUtils.getLogger(); +- private final Map attributes = Maps.newHashMap(); +- private final Set dirtyAttributes = Sets.newHashSet(); ++ // DivineMC start - lithium: collections.attributes ++ private final Map attributes = new Reference2ReferenceOpenHashMap<>(0); ++ private final Set dirtyAttributes = new ReferenceOpenHashSet<>(0); ++ // DivineMC end + private final AttributeSupplier supplier; + private final java.util.function.Function createInstance; // Pufferfish + private final net.minecraft.world.entity.LivingEntity entity; // Purpur diff --git a/patches/server/0030-lithium-cached_hashcode.patch b/patches/server/0030-lithium-cached_hashcode.patch new file mode 100644 index 0000000..f01fa85 --- /dev/null +++ b/patches/server/0030-lithium-cached_hashcode.patch @@ -0,0 +1,42 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com> +Date: Sat, 8 Apr 2023 01:40:11 +0300 +Subject: [PATCH] lithium: cached_hashcode + + +diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java +index 773162c3456945605fb664114508622f7d2fcec8..cc4a2bafc319fb54e8d1168cba85746c5dfafbc2 100644 +--- a/src/main/java/net/minecraft/world/level/block/Block.java ++++ b/src/main/java/net/minecraft/world/level/block/Block.java +@@ -663,11 +663,18 @@ public class Block extends BlockBehaviour implements ItemLike { + private final BlockState first; + private final BlockState second; + private final Direction direction; ++ private final int hash; // DivineMC - lithium: cached_hashcode + + public BlockStatePairKey(BlockState self, BlockState other, Direction facing) { + this.first = self; + this.second = other; + this.direction = facing; ++ // DivineMC start - lithium: cached_hashcode ++ int hash = this.first.hashCode(); ++ hash = 31 * hash + this.second.hashCode(); ++ hash = 31 * hash + this.direction.hashCode(); ++ this.hash = hash; ++ // DivineMC end + } + + public boolean equals(Object object) { +@@ -683,11 +690,7 @@ public class Block extends BlockBehaviour implements ItemLike { + } + + public int hashCode() { +- int i = this.first.hashCode(); +- +- i = 31 * i + this.second.hashCode(); +- i = 31 * i + this.direction.hashCode(); +- return i; ++ return this.hash; // DivineMC - lithium: cached_hashcode + } + } + }