mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
Update WIP and removed patches
This commit is contained in:
@@ -0,0 +1,208 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Tue, 29 Nov 2022 15:16:54 +0100
|
||||||
|
Subject: [PATCH] Dev import deobfuscation fixes
|
||||||
|
|
||||||
|
Removed since Paper 1.21.4, hardfork
|
||||||
|
|
||||||
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/commands/execution/tasks/BuildContexts.java b/src/main/java/net/minecraft/commands/execution/tasks/BuildContexts.java
|
||||||
|
index b0d26b0eadb2a43924629424a6c13198aace8f69..e8b8c453a7ff7af0a60ae915cfd85aba313139c9 100644
|
||||||
|
--- a/src/main/java/net/minecraft/commands/execution/tasks/BuildContexts.java
|
||||||
|
+++ b/src/main/java/net/minecraft/commands/execution/tasks/BuildContexts.java
|
||||||
|
@@ -52,7 +52,7 @@ public class BuildContexts<T extends ExecutionCommandSource<T>> {
|
||||||
|
}
|
||||||
|
|
||||||
|
RedirectModifier<T> redirectModifier = commandContext.getRedirectModifier();
|
||||||
|
- if (redirectModifier instanceof CustomModifierExecutor<T> customModifierExecutor) {
|
||||||
|
+ if (redirectModifier instanceof CustomModifierExecutor.ModifierAdapter<T> customModifierExecutor) { // Gale - dev import deobfuscation fixes
|
||||||
|
customModifierExecutor.apply(baseSource, list, contextChain, chainModifiers, ExecutionControl.create(context, frame));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
@@ -92,11 +92,11 @@ public class BuildContexts<T extends ExecutionCommandSource<T>> {
|
||||||
|
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
if (chainModifiers.isReturn()) {
|
||||||
|
- context.queueNext(new CommandQueueEntry<>(frame, FallthroughTask.instance()));
|
||||||
|
+ context.queueNext(new CommandQueueEntry<T>(frame, FallthroughTask.instance())); // Gale - dev import deobfuscation fixes
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
CommandContext<T> commandContext2 = contextChain.getTopContext();
|
||||||
|
- if (commandContext2.getCommand() instanceof CustomCommandExecutor<T> customCommandExecutor) {
|
||||||
|
+ if (commandContext2.getCommand() instanceof CustomCommandExecutor.CommandAdapter<T> customCommandExecutor) { // Gale - dev import deobfuscation fixes
|
||||||
|
ExecutionControl<T> executionControl = ExecutionControl.create(context, frame);
|
||||||
|
|
||||||
|
for (T executionCommandSource2 : list) {
|
||||||
|
diff --git a/src/main/java/net/minecraft/util/ExtraCodecs.java b/src/main/java/net/minecraft/util/ExtraCodecs.java
|
||||||
|
index eaa47e644926d6ec32e1c70523a0e713bc4c4906..4e7ed7fa08fabb4c253c75db41f7f24947aefff0 100644
|
||||||
|
--- a/src/main/java/net/minecraft/util/ExtraCodecs.java
|
||||||
|
+++ b/src/main/java/net/minecraft/util/ExtraCodecs.java
|
||||||
|
@@ -226,7 +226,7 @@ public class ExtraCodecs {
|
||||||
|
P object2 = listx.get(1);
|
||||||
|
return combineFunction.apply(object, object2);
|
||||||
|
}), pair -> ImmutableList.of(leftFunction.apply((I)pair), rightFunction.apply((I)pair)));
|
||||||
|
- Codec<I> codec3 = RecordCodecBuilder.<Pair>create(
|
||||||
|
+ Codec<I> codec3 = RecordCodecBuilder.<Pair<P, P>>create( // Gale - dev import deobfuscation fixes
|
||||||
|
instance -> instance.group(codec.fieldOf(leftFieldName).forGetter(Pair::getFirst), codec.fieldOf(rightFieldName).forGetter(Pair::getSecond))
|
||||||
|
.apply(instance, Pair::of)
|
||||||
|
)
|
||||||
|
@@ -243,14 +243,14 @@ public class ExtraCodecs {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
- public static <A> ResultFunction<A> orElsePartial(A object) {
|
||||||
|
+ public static <A> ResultFunction<A> orElsePartial(A objectA) { // Gale - dev import deobfuscation fixes
|
||||||
|
return new ResultFunction<A>() {
|
||||||
|
public <T> DataResult<Pair<A, T>> apply(DynamicOps<T> dynamicOps, T object, DataResult<Pair<A, T>> dataResult) {
|
||||||
|
MutableObject<String> mutableObject = new MutableObject<>();
|
||||||
|
Optional<Pair<A, T>> optional = dataResult.resultOrPartial(mutableObject::setValue);
|
||||||
|
return optional.isPresent()
|
||||||
|
? dataResult
|
||||||
|
- : DataResult.error(() -> "(" + mutableObject.getValue() + " -> using default)", Pair.of(object, object));
|
||||||
|
+ : DataResult.error(() -> "(" + mutableObject.getValue() + " -> using default)", Pair.of(objectA, object)); // Gale - dev import deobfuscation fixes
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> DataResult<T> coApply(DynamicOps<T> dynamicOps, A object, DataResult<T> dataResult) {
|
||||||
|
@@ -259,7 +259,7 @@ public class ExtraCodecs {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
- return "OrElsePartial[" + object + "]";
|
||||||
|
+ return "OrElsePartial[" + objectA + "]"; // Gale - dev import deobfuscation fixes
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/net/minecraft/util/datafix/fixes/ChunkProtoTickListFix.java b/src/main/java/net/minecraft/util/datafix/fixes/ChunkProtoTickListFix.java
|
||||||
|
index 2942534d265416a3693848d76538c04735bc14fa..3f48037d5d6a4965b895fde69825d3b2a74770e8 100644
|
||||||
|
--- a/src/main/java/net/minecraft/util/datafix/fixes/ChunkProtoTickListFix.java
|
||||||
|
+++ b/src/main/java/net/minecraft/util/datafix/fixes/ChunkProtoTickListFix.java
|
||||||
|
@@ -186,7 +186,7 @@ public class ChunkProtoTickListFix extends DataFix {
|
||||||
|
int k = packedLocalPos >>> 8 & 15;
|
||||||
|
String string = blockIdGetter.apply(sectionSupplier != null ? sectionSupplier.get().get(i, j, k) : null);
|
||||||
|
return levelDynamic.createMap(
|
||||||
|
- ImmutableMap.builder()
|
||||||
|
+ ImmutableMap.<Dynamic<?>, Dynamic<?>>builder() // Gale - dev import deobfuscation fixes
|
||||||
|
.put(levelDynamic.createString("i"), levelDynamic.createString(string))
|
||||||
|
.put(levelDynamic.createString("x"), levelDynamic.createInt(sectionX * 16 + i))
|
||||||
|
.put(levelDynamic.createString("y"), levelDynamic.createInt(sectionY * 16 + j))
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/levelgen/SurfaceRules.java b/src/main/java/net/minecraft/world/level/levelgen/SurfaceRules.java
|
||||||
|
index 7174613ef2cac0f27c72dcfa2f822199ffbc79e5..38428ba2c522108f4f9f7986bc3535d1232ac1f8 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/levelgen/SurfaceRules.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/levelgen/SurfaceRules.java
|
||||||
|
@@ -177,10 +177,10 @@ public class SurfaceRules {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
- public SurfaceRules.Condition apply(SurfaceRules.Context context) {
|
||||||
|
+ public SurfaceRules.Condition apply(SurfaceRules.Context givenContext) { // Gale - dev import deobfuscation fixes
|
||||||
|
class BiomeCondition extends SurfaceRules.LazyYCondition {
|
||||||
|
BiomeCondition() {
|
||||||
|
- super(context);
|
||||||
|
+ super(givenContext); // Gale - dev import deobfuscation fixes
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@@ -522,12 +522,14 @@ public class SurfaceRules {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
- public SurfaceRules.Condition apply(SurfaceRules.Context context) {
|
||||||
|
- final NormalNoise normalNoise = context.randomState.getOrCreateNoise(this.noise);
|
||||||
|
+ // Gale start - dev import deobfuscation fixes
|
||||||
|
+ public SurfaceRules.Condition apply(SurfaceRules.Context givenContext) {
|
||||||
|
+ final NormalNoise normalNoise = givenContext.randomState.getOrCreateNoise(this.noise);
|
||||||
|
+ // Gale end - dev import deobfuscation fixes
|
||||||
|
|
||||||
|
class NoiseThresholdCondition extends SurfaceRules.LazyXZCondition {
|
||||||
|
NoiseThresholdCondition() {
|
||||||
|
- super(context);
|
||||||
|
+ super(givenContext); // Gale - dev import deobfuscation fixes
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@@ -663,12 +665,12 @@ public class SurfaceRules {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
- public SurfaceRules.Condition apply(SurfaceRules.Context context) {
|
||||||
|
+ public SurfaceRules.Condition apply(SurfaceRules.Context givenContext) { // Gale - dev import deobfuscation fixes
|
||||||
|
final boolean bl = this.surfaceType == CaveSurface.CEILING;
|
||||||
|
|
||||||
|
class StoneDepthCondition extends SurfaceRules.LazyYCondition {
|
||||||
|
StoneDepthCondition() {
|
||||||
|
- super(context);
|
||||||
|
+ super(givenContext); // Gale - dev import deobfuscation fixes
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@@ -756,26 +758,32 @@ public class SurfaceRules {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
- public SurfaceRules.Condition apply(SurfaceRules.Context context) {
|
||||||
|
- final int i = this.trueAtAndBelow().resolveY(context.context);
|
||||||
|
- final int j = this.falseAtAndAbove().resolveY(context.context);
|
||||||
|
- final PositionalRandomFactory positionalRandomFactory = context.randomState.getOrCreateRandomFactory(this.randomName());
|
||||||
|
+ // Gale start - dev import deobfuscation fixes
|
||||||
|
+ public SurfaceRules.Condition apply(SurfaceRules.Context givenContext) {
|
||||||
|
+ final int i = this.trueAtAndBelow().resolveY(givenContext.context);
|
||||||
|
+ final int j = this.falseAtAndAbove().resolveY(givenContext.context);
|
||||||
|
+ final PositionalRandomFactory positionalRandomFactory = givenContext.randomState.getOrCreateRandomFactory(this.randomName());
|
||||||
|
+ // Gale end - dev import deobfuscation fixes
|
||||||
|
|
||||||
|
class VerticalGradientCondition extends SurfaceRules.LazyYCondition {
|
||||||
|
VerticalGradientCondition() {
|
||||||
|
- super(context);
|
||||||
|
+ super(givenContext); // Gale - dev import deobfuscation fixes
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean compute() {
|
||||||
|
- int i = this.context.blockY;
|
||||||
|
- if (i <= i) {
|
||||||
|
+ // Gale start - dev import deobfuscation fixes
|
||||||
|
+ int i2 = this.context.blockY;
|
||||||
|
+ if (i2 <= i) {
|
||||||
|
+ // Gale end - dev import deobfuscation fixes
|
||||||
|
return true;
|
||||||
|
- } else if (i >= j) {
|
||||||
|
+ } else if (i2 >= j) { // Gale - dev import deobfuscation fixes
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
- double d = Mth.map((double)i, (double)i, (double)j, 1.0, 0.0);
|
||||||
|
- RandomSource randomSource = positionalRandomFactory.at(this.context.blockX, i, this.context.blockZ);
|
||||||
|
+ // Gale start - dev import deobfuscation fixes
|
||||||
|
+ double d = Mth.map((double)i2, (double)i, (double)j, 1.0, 0.0);
|
||||||
|
+ RandomSource randomSource = positionalRandomFactory.at(this.context.blockX, i2, this.context.blockZ);
|
||||||
|
+ // Gale end - dev import deobfuscation fixes
|
||||||
|
return (double)randomSource.nextFloat() < d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -803,10 +811,10 @@ public class SurfaceRules {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
- public SurfaceRules.Condition apply(SurfaceRules.Context context) {
|
||||||
|
+ public SurfaceRules.Condition apply(SurfaceRules.Context givenContext) { // Gale - dev import deobfuscation fixes
|
||||||
|
class WaterCondition extends SurfaceRules.LazyYCondition {
|
||||||
|
WaterCondition() {
|
||||||
|
- super(context);
|
||||||
|
+ super(givenContext); // Gale - dev import deobfuscation fixes
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@@ -841,10 +849,10 @@ public class SurfaceRules {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
- public SurfaceRules.Condition apply(SurfaceRules.Context context) {
|
||||||
|
+ public SurfaceRules.Condition apply(SurfaceRules.Context givenContext) { // Gale - dev import deobfuscation fixes
|
||||||
|
class YCondition extends SurfaceRules.LazyYCondition {
|
||||||
|
YCondition() {
|
||||||
|
- super(context);
|
||||||
|
+ super(givenContext); // Gale - dev import deobfuscation fixes
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Wed, 23 Nov 2022 20:18:05 +0100
|
||||||
|
Subject: [PATCH] Remove iterators from Inventory#contains
|
||||||
|
|
||||||
|
Removed since 1.21.4
|
||||||
|
|
||||||
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
This patch is based on the following patch:
|
||||||
|
"Remove iterators from inventory contains"
|
||||||
|
By: Paul Sauve <paul@technove.co>
|
||||||
|
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||||
|
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
|
||||||
|
* Airplane copyright *
|
||||||
|
|
||||||
|
Airplane
|
||||||
|
Copyright (C) 2020 Technove LLC
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) 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 General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/player/Inventory.java b/src/main/java/net/minecraft/world/entity/player/Inventory.java
|
||||||
|
index ad82e5aeb565b23c3ec565fa60e1f31d1710bd4e..5bf4164f0b9a3d4e6b8e9de87d80683c98a21298 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/player/Inventory.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/player/Inventory.java
|
||||||
|
@@ -649,6 +649,8 @@ public class Inventory implements Container, Nameable {
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean contains(ItemStack stack) {
|
||||||
|
+ // Gale start - Airplane - remove iterators from Inventory#contains
|
||||||
|
+ /*
|
||||||
|
Iterator iterator = this.compartments.iterator();
|
||||||
|
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
@@ -685,25 +687,34 @@ public class Inventory implements Container, Nameable {
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
+ */
|
||||||
|
+ for (int i = 0; i < this.compartments.size(); i++) {
|
||||||
|
+ List<ItemStack> list = this.compartments.get(i);
|
||||||
|
+ for (int j = 0; j < list.size(); j++) {
|
||||||
|
+ ItemStack itemstack1 = list.get(j);
|
||||||
|
|
||||||
|
- public boolean contains(Predicate<ItemStack> predicate) {
|
||||||
|
- Iterator iterator = this.compartments.iterator();
|
||||||
|
-
|
||||||
|
- while (iterator.hasNext()) {
|
||||||
|
- List<ItemStack> list = (List) iterator.next();
|
||||||
|
- Iterator iterator1 = list.iterator();
|
||||||
|
+ if (!itemstack1.isEmpty() && ItemStack.isSameItem(itemstack1, stack)) {
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
- while (iterator1.hasNext()) {
|
||||||
|
- ItemStack itemstack = (ItemStack) iterator1.next();
|
||||||
|
+ public boolean containsMatchedMap(Predicate<ItemStack> predicate) {
|
||||||
|
+ for (int i = 0; i < this.compartments.size(); i++) {
|
||||||
|
+ List<ItemStack> list = this.compartments.get(i);
|
||||||
|
+ for (int j = 0; j < list.size(); j++) {
|
||||||
|
+ ItemStack itemstack1 = list.get(j);
|
||||||
|
|
||||||
|
- if (predicate.test(itemstack)) {
|
||||||
|
+ if (!itemstack1.isEmpty() && predicate.test(itemstack1)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
-
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
+ // Gale end - Airplane - remove iterators from Inventory#contains
|
||||||
|
|
||||||
|
public void replaceWith(Inventory other) {
|
||||||
|
for (int i = 0; i < this.getContainerSize(); ++i) {
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
|
||||||
|
index ae321b3b8d98e42ef07fd1f0f738c1a2b428f6db..b15b0c8057e61c6aef05c0865e2c3e06adcf938b 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
|
||||||
|
@@ -294,7 +294,7 @@ public class MapItemSavedData extends SavedData {
|
||||||
|
|
||||||
|
Predicate<ItemStack> predicate = MapItemSavedData.mapMatcher(stack);
|
||||||
|
|
||||||
|
- if (!player.getInventory().contains(predicate)) {
|
||||||
|
+ if (!player.getInventory().containsMatchedMap(predicate)) { // Gale - Airplane - remove iterators from Inventory#contains
|
||||||
|
this.removeDecoration(player.getName().getString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -303,7 +303,7 @@ public class MapItemSavedData extends SavedData {
|
||||||
|
Player entityhuman1 = worldmap_worldmaphumantracker1.player;
|
||||||
|
String s = entityhuman1.getName().getString();
|
||||||
|
|
||||||
|
- if (!entityhuman1.isRemoved() && (entityhuman1.getInventory().contains(predicate) || stack.isFramed())) {
|
||||||
|
+ if (!entityhuman1.isRemoved() && (entityhuman1.getInventory().containsMatchedMap(predicate) || stack.isFramed())) { // Gale - Airplane - remove iterators from Inventory#contains
|
||||||
|
if (!stack.isFramed() && entityhuman1.level().dimension() == this.dimension && this.trackingPosition) {
|
||||||
|
this.addDecoration(MapDecorationTypes.PLAYER, entityhuman1.level(), s, entityhuman1.getX(), entityhuman1.getZ(), (double) entityhuman1.getYRot(), (Component) null);
|
||||||
|
}
|
||||||
@@ -0,0 +1,181 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Wed, 23 Nov 2022 23:19:12 +0100
|
||||||
|
Subject: [PATCH] Reduce entity fluid lookups if no fluids
|
||||||
|
|
||||||
|
Removed since Gale 1.21.3, no need
|
||||||
|
|
||||||
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
This patch is based on the following patch:
|
||||||
|
"Reduce entity fluid lookups if no fluids"
|
||||||
|
By: Paul Sauve <paul@technove.co>
|
||||||
|
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||||
|
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
|
||||||
|
* Airplane copyright *
|
||||||
|
|
||||||
|
Airplane
|
||||||
|
Copyright (C) 2020 Technove LLC
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) 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 General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
|
index b511fa3eb5eb5350fa97dacd56a5208f624e0c5e..158373cf2ebe1e9ac5fb359323ef4607a2acbf72 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
|
@@ -4438,16 +4438,18 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean updateFluidHeightAndDoFluidPushing(TagKey<Fluid> tag, double speed) {
|
||||||
|
- if (this.touchingUnloadedChunk()) {
|
||||||
|
+ if (false && this.touchingUnloadedChunk()) { // Gale - Airplane - reduce entity fluid lookups if no fluids - cost of a lookup here is the same cost as below, so skip
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
AABB axisalignedbb = this.getBoundingBox().deflate(0.001D);
|
||||||
|
- int i = Mth.floor(axisalignedbb.minX);
|
||||||
|
- int j = Mth.ceil(axisalignedbb.maxX);
|
||||||
|
- int k = Mth.floor(axisalignedbb.minY);
|
||||||
|
- int l = Mth.ceil(axisalignedbb.maxY);
|
||||||
|
- int i1 = Mth.floor(axisalignedbb.minZ);
|
||||||
|
- int j1 = Mth.ceil(axisalignedbb.maxZ);
|
||||||
|
+ // Gale start - Airplane - reduce entity fluid lookups if no fluids - rename
|
||||||
|
+ int minBlockX = Mth.floor(axisalignedbb.minX);
|
||||||
|
+ int maxBlockX = Mth.ceil(axisalignedbb.maxX);
|
||||||
|
+ int minBlockY = Mth.floor(axisalignedbb.minY);
|
||||||
|
+ int maxBlockY = Mth.ceil(axisalignedbb.maxY);
|
||||||
|
+ int minBlockZ = Mth.floor(axisalignedbb.minZ);
|
||||||
|
+ int maxBlockZ = Mth.ceil(axisalignedbb.maxZ);
|
||||||
|
+ // Gale end - Airplane - reduce entity fluid lookups if no fluids - rename
|
||||||
|
double d1 = 0.0D;
|
||||||
|
boolean flag = this.isPushedByFluid();
|
||||||
|
boolean flag1 = false;
|
||||||
|
@@ -4455,14 +4457,61 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||||
|
int k1 = 0;
|
||||||
|
BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos();
|
||||||
|
|
||||||
|
- for (int l1 = i; l1 < j; ++l1) {
|
||||||
|
- for (int i2 = k; i2 < l; ++i2) {
|
||||||
|
- for (int j2 = i1; j2 < j1; ++j2) {
|
||||||
|
- blockposition_mutableblockposition.set(l1, i2, j2);
|
||||||
|
- FluidState fluid = this.level().getFluidState(blockposition_mutableblockposition);
|
||||||
|
+ // Gale start - Airplane - reduce entity fluid lookups if no fluids - based off CollisionUtil.getCollisionsForBlocksOrWorldBorder
|
||||||
|
+ final int minSection = ca.spottedleaf.moonrise.common.util.WorldUtil.getMinSection(this.level());
|
||||||
|
+ final int maxSection = ca.spottedleaf.moonrise.common.util.WorldUtil.getMaxSection(this.level());
|
||||||
|
+ final int minBlock = minSection << 4;
|
||||||
|
+ final int maxBlock = (maxSection << 4) | 15;
|
||||||
|
+
|
||||||
|
+ // special cases:
|
||||||
|
+ if (minBlockY > maxBlock || maxBlockY < minBlock) {
|
||||||
|
+ // no point in checking
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ int minYIterate = Math.max(minBlock, minBlockY);
|
||||||
|
+ int maxYIterate = Math.min(maxBlock, maxBlockY);
|
||||||
|
+
|
||||||
|
+ int minChunkX = minBlockX >> 4;
|
||||||
|
+ int maxChunkX = maxBlockX >> 4;
|
||||||
|
+
|
||||||
|
+ int minChunkZ = minBlockZ >> 4;
|
||||||
|
+ int maxChunkZ = maxBlockZ >> 4;
|
||||||
|
+
|
||||||
|
+ for (int currChunkZ = minChunkZ; currChunkZ <= maxChunkZ; ++currChunkZ) {
|
||||||
|
+ int minZ = currChunkZ == minChunkZ ? minBlockZ & 15 : 0; // coordinate in chunk
|
||||||
|
+ int maxZ = currChunkZ == maxChunkZ ? maxBlockZ & 15 : 16; // coordinate in chunk
|
||||||
|
+
|
||||||
|
+ for (int currChunkX = minChunkX; currChunkX <= maxChunkX; ++currChunkX) {
|
||||||
|
+ int minX = currChunkX == minChunkX ? minBlockX & 15 : 0; // coordinate in chunk
|
||||||
|
+ int maxX = currChunkX == maxChunkX ? maxBlockX & 15 : 16; // coordinate in chunk
|
||||||
|
+
|
||||||
|
+ net.minecraft.world.level.chunk.ChunkAccess chunk = this.level().getChunkIfLoadedImmediately(currChunkX, currChunkZ);
|
||||||
|
+ if (chunk == null) {
|
||||||
|
+ return false; // if we're touching an unloaded chunk then it's false
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ net.minecraft.world.level.chunk.LevelChunkSection[] sections = chunk.getSections();
|
||||||
|
+
|
||||||
|
+ for (int currY = minYIterate; currY < maxYIterate; ++currY) {
|
||||||
|
+ net.minecraft.world.level.chunk.LevelChunkSection section = sections[(currY >> 4) - minSection];
|
||||||
|
+
|
||||||
|
+ if (section == null || section.hasOnlyAir() || section.fluidStateCount == 0) { // if no fluids, nothing in this section
|
||||||
|
+ // empty
|
||||||
|
+ // skip to next section
|
||||||
|
+ currY = (currY & ~(15)) + 15; // increment by 15: iterator loop increments by the extra one
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ net.minecraft.world.level.chunk.PalettedContainer<BlockState> blocks = section.states;
|
||||||
|
+
|
||||||
|
+ for (int currZ = minZ; currZ < maxZ; ++currZ) {
|
||||||
|
+ for (int currX = minX; currX < maxX; ++currX) {
|
||||||
|
+ FluidState fluid = blocks.get(currX & 15, currY & 15, currZ & 15).getFluidState();
|
||||||
|
|
||||||
|
if (fluid.is(tag)) {
|
||||||
|
- double d2 = (double) ((float) i2 + fluid.getHeight(this.level(), blockposition_mutableblockposition));
|
||||||
|
+ blockposition_mutableblockposition.set((currChunkX << 4) + currX, currY, (currChunkZ << 4) + currZ);
|
||||||
|
+ double d2 = (double) ((float) currY + fluid.getHeight(this.level(), blockposition_mutableblockposition));
|
||||||
|
|
||||||
|
if (d2 >= axisalignedbb.minY) {
|
||||||
|
flag1 = true;
|
||||||
|
@@ -4484,9 +4533,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||||
|
// CraftBukkit end
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+ // Gale end - Airplane - reduce entity fluid lookups if no fluids - based off CollisionUtil.getCollisionsForBlocksOrWorldBorder
|
||||||
|
|
||||||
|
if (vec3d.length() > 0.0D) {
|
||||||
|
if (k1 > 0) {
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||||
|
index c3b1caa352b988ec44fa2b2eb0536517711f5460..33747ef8211066155cd70ce2818862cf3e79db53 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||||
|
@@ -25,6 +25,7 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
|
||||||
|
public final PalettedContainer<BlockState> states;
|
||||||
|
// CraftBukkit start - read/write
|
||||||
|
private PalettedContainer<Holder<Biome>> biomes;
|
||||||
|
+ public short fluidStateCount; // Gale - Airplane - reduce entity fluid lookups if no fluids
|
||||||
|
|
||||||
|
// Paper start - block counting
|
||||||
|
private static final it.unimi.dsi.fastutil.ints.IntArrayList FULL_LIST = new it.unimi.dsi.fastutil.ints.IntArrayList(16*16*16);
|
||||||
|
@@ -104,6 +105,7 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
|
||||||
|
|
||||||
|
if (!fluid.isEmpty()) {
|
||||||
|
--this.tickingFluidCount;
|
||||||
|
+ --this.fluidStateCount; // Gale - Airplane - reduce entity fluid lookups if no fluids
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!state.isAir()) {
|
||||||
|
@@ -115,6 +117,7 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
|
||||||
|
|
||||||
|
if (!fluid1.isEmpty()) {
|
||||||
|
++this.tickingFluidCount;
|
||||||
|
+ ++this.fluidStateCount; // Gale - Airplane - reduce entity fluid lookups if no fluids
|
||||||
|
}
|
||||||
|
|
||||||
|
// Paper start - block counting
|
||||||
|
@@ -208,6 +211,7 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
|
||||||
|
if (fluid.isRandomlyTicking()) {
|
||||||
|
this.tickingFluidCount += paletteCount;
|
||||||
|
}
|
||||||
|
+ this.fluidStateCount++; // Gale - Airplane - reduce entity fluid lookups if no fluids
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Tue, 29 Nov 2022 15:55:05 +0100
|
||||||
|
Subject: [PATCH] Fix cow rotation when shearing mooshroom
|
||||||
|
|
||||||
|
Removed since Gale 1.21.4, fixed in Minecraft 1.21.2 24w36a
|
||||||
|
|
||||||
|
License: MIT (https://opensource.org/licenses/MIT)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
This patch is based on the following patch:
|
||||||
|
"Fix cow rotation when shearing mooshroom"
|
||||||
|
By: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||||
|
As part of: Purpur (https://github.com/PurpurMC/Purpur)
|
||||||
|
Licensed under: MIT (https://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
* Purpur copyright *
|
||||||
|
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2019-2022 PurpurMC
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java b/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java
|
||||||
|
index eea02ea0d99425a60575f5fa729782494d579080..0047c9f3c6dc901944187784e42cd09a3c6b460c 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java
|
||||||
|
@@ -195,6 +195,15 @@ public class MushroomCow extends Cow implements Shearable, VariantHolder<Mushroo
|
||||||
|
world.playSound((Player) null, (Entity) this, SoundEvents.MOOSHROOM_SHEAR, shearedSoundCategory, 1.0F, 1.0F);
|
||||||
|
this.convertTo(EntityType.COW, ConversionParams.single(this, false, false), (entitycow) -> {
|
||||||
|
world.sendParticles(ParticleTypes.EXPLOSION, this.getX(), this.getY(0.5D), this.getZ(), 1, 0.0D, 0.0D, 0.0D, 0.0D);
|
||||||
|
+ // Gale start - Purpur - fix cow rotation when shearing mooshroom
|
||||||
|
+ if (this.level().galeConfig().gameplayMechanics.fixes.keepMooshroomRotationAfterShearing) {
|
||||||
|
+ entitycow.copyPosition(this);
|
||||||
|
+ entitycow.yBodyRot = this.yBodyRot;
|
||||||
|
+ entitycow.setYHeadRot(this.getYHeadRot());
|
||||||
|
+ entitycow.yRotO = this.yRotO;
|
||||||
|
+ entitycow.xRotO = this.xRotO;
|
||||||
|
+ }
|
||||||
|
+ // Gale end - Purpur - fix cow rotation when shearing mooshroom
|
||||||
|
// Paper start - custom shear drops; moved drop generation to separate method
|
||||||
|
drops.forEach(drop -> {
|
||||||
|
ItemEntity entityitem = new ItemEntity(this.level(), this.getX(), this.getY(1.0D), this.getZ(), drop);
|
||||||
|
diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||||
|
index fff9f552a9b3cc4913837077857c78826bf1bdb0..3fa354ceef3ec5ab9bca3f13f23aca586dfe09c4 100644
|
||||||
|
--- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||||
|
+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||||
|
@@ -99,6 +99,8 @@ public class GaleWorldConfiguration extends ConfigurationPart {
|
||||||
|
public Fixes fixes;
|
||||||
|
public class Fixes extends ConfigurationPart {
|
||||||
|
|
||||||
|
+ public boolean keepMooshroomRotationAfterShearing = true; // Gale - Purpur - fix cow rotation when shearing mooshroom
|
||||||
|
+
|
||||||
|
// Gale start - Purpur - fix MC-238526
|
||||||
|
@Setting("mc-238526")
|
||||||
|
public boolean mc238526 = false;
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Fri, 23 Dec 2022 15:30:58 +0100
|
||||||
|
Subject: [PATCH] Fix MC-110386
|
||||||
|
|
||||||
|
Removed since Gale 1.21.4, fixed in Minecraft 1.21.2 24w33a
|
||||||
|
|
||||||
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
This patch is based on the following patch:
|
||||||
|
"Fix mobs attacking themselves"
|
||||||
|
By: etil2jz <81570777+etil2jz@users.noreply.github.com>
|
||||||
|
As part of: Mirai (https://github.com/etil2jz/Mirai)
|
||||||
|
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
|
||||||
|
* Mirai description *
|
||||||
|
|
||||||
|
If an entity is provoked by a second one using commands,
|
||||||
|
the second will join in the fight against itself,
|
||||||
|
causing it to attack itself repeatedly. See https://bugs.mojang.com/browse/MC-110386.
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java
|
||||||
|
index edfc77ba9c5c7dc4cfe997faff7a34e9b9e9365e..6c72dd5774eccec68d29e04dfc344adb69840abf 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java
|
||||||
|
@@ -114,6 +114,11 @@ public class HurtByTargetGoal extends TargetGoal {
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void alertOther(Mob mob, LivingEntity target) {
|
||||||
|
+ // Gale start - Mirai - fix MC-110386
|
||||||
|
+ if (mob == target && mob.level().galeConfig().gameplayMechanics.fixes.mc110386) {
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ // Gale end - Mirai - fix MC-110386
|
||||||
|
mob.setTarget(target, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true); // CraftBukkit - reason
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||||
|
index c53cb97b271ca5390b544a1af66182e3c4aefc74..266079aed0610e0fa9e35da81680b7f388a8844a 100644
|
||||||
|
--- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||||
|
+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||||
|
@@ -111,6 +111,11 @@ public class GaleWorldConfiguration extends ConfigurationPart {
|
||||||
|
public boolean mc121706 = false;
|
||||||
|
// Gale end - Purpur - fix MC-121706
|
||||||
|
|
||||||
|
+ // Gale start - Mirai - fix MC-110386
|
||||||
|
+ @Setting("mc-110386")
|
||||||
|
+ public boolean mc110386 = true;
|
||||||
|
+ // Gale end - Mirai - fix MC-110386
|
||||||
|
+
|
||||||
|
}
|
||||||
|
|
||||||
|
public double entityWakeUpDurationRatioStandardDeviation = 0.2; // Gale - variable entity wake-up duration
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Thu, 1 Dec 2022 14:18:46 +0100
|
||||||
|
Subject: [PATCH] Cache world generator sea level
|
||||||
|
|
||||||
|
Removed since 1.21.4 hardfork, as the cache captured the wrong value and caused LeavesMC/Leaves#392.
|
||||||
|
Also this opt has been disabled by default in Lithium since 08/12/2022 due to the early access of registry crash.
|
||||||
|
|
||||||
|
License: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
This patch is based on the following mixin:
|
||||||
|
"net/caffeinemc/mods/lithium/mixin/gen/cached_generator_settings/NoiseBasedChunkGeneratorMixin.java"
|
||||||
|
By: SuperCoder7979 <k.pranav@gmail.com>
|
||||||
|
As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric)
|
||||||
|
Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
||||||
|
|
||||||
|
diff --git a/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java b/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
|
||||||
|
index 65728ef17e63d71833677fdcbd5bb90794b4822b..de0f33fd008d8cd08b6da9ab37e98bd7f51ce0ca 100644
|
||||||
|
--- a/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
|
||||||
|
+++ b/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
|
||||||
|
@@ -57,11 +57,19 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator {
|
||||||
|
private static final BlockState AIR = Blocks.AIR.defaultBlockState();
|
||||||
|
public final Holder<NoiseGeneratorSettings> settings;
|
||||||
|
private final Supplier<Aquifer.FluidPicker> globalFluidPicker;
|
||||||
|
+ private int cachedSeaLevel; // Gale - Lithium - cache world generator sea level
|
||||||
|
|
||||||
|
public NoiseBasedChunkGenerator(BiomeSource biomeSource, Holder<NoiseGeneratorSettings> settings) {
|
||||||
|
super(biomeSource);
|
||||||
|
this.settings = settings;
|
||||||
|
- this.globalFluidPicker = Suppliers.memoize(() -> createFluidPicker(settings.value()));
|
||||||
|
+ // Gale start - Lithium - cache world generator sea level
|
||||||
|
+ this.globalFluidPicker = Suppliers.memoize(() -> {
|
||||||
|
+ var fluidPicker = createFluidPicker(settings.value());
|
||||||
|
+ this.cachedSeaLevel = settings.value().seaLevel();
|
||||||
|
+ return fluidPicker;
|
||||||
|
+
|
||||||
|
+ });
|
||||||
|
+ // Gale end - Lithium - cache world generator sea level
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Aquifer.FluidPicker createFluidPicker(NoiseGeneratorSettings settings) {
|
||||||
|
@@ -407,7 +415,7 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSeaLevel() {
|
||||||
|
- return this.settings.value().seaLevel();
|
||||||
|
+ return this.cachedSeaLevel; // Gale - Lithium - cache world generator sea level
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Thu, 22 Dec 2022 15:47:39 +0100
|
||||||
|
Subject: [PATCH] Server thread priority environment variable
|
||||||
|
|
||||||
|
Removed since Gale 1.21.4, this patch is the part of Gale 1.19 threading system
|
||||||
|
|
||||||
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||||
|
index f33fb9b30863dd8ff7207db905fcfb7547b09383..0da1eeab6a2f8336283a62ebcb3aa0d1b1933c85 100644
|
||||||
|
--- a/net/minecraft/server/MinecraftServer.java
|
||||||
|
+++ b/net/minecraft/server/MinecraftServer.java
|
||||||
|
@@ -163,6 +163,7 @@ import net.minecraft.world.phys.Vec3;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTask> implements ServerInfo, ChunkIOErrorReporter, CommandSource, ca.spottedleaf.moonrise.patches.chunk_system.server.ChunkSystemMinecraftServer { // Paper - rewrite chunk system
|
||||||
|
+ public static final int SERVER_THREAD_PRIORITY = Integer.getInteger("gale.thread.priority.server", -1); // Gale - server thread priority environment variable
|
||||||
|
private static MinecraftServer SERVER; // Paper
|
||||||
|
public static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
public static final net.kyori.adventure.text.logger.slf4j.ComponentLogger COMPONENT_LOGGER = net.kyori.adventure.text.logger.slf4j.ComponentLogger.logger(LOGGER.getName()); // Paper
|
||||||
|
@@ -299,6 +300,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
|
|
||||||
|
S minecraftServer = (S)threadFunction.apply(thread);
|
||||||
|
atomicReference.set(minecraftServer);
|
||||||
|
+ // Gale start - server thread priority environment variable
|
||||||
|
+ if (SERVER_THREAD_PRIORITY > 0) {
|
||||||
|
+ thread.setPriority(SERVER_THREAD_PRIORITY);
|
||||||
|
+ }
|
||||||
|
+ // Gale end - server thread priority environment variable
|
||||||
|
thread.start();
|
||||||
|
return minecraftServer;
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ Date: Mon, 7 Oct 2024 10:59:17 -0400
|
|||||||
Subject: [PATCH] Reduce object complexity to make block isValid calls more
|
Subject: [PATCH] Reduce object complexity to make block isValid calls more
|
||||||
efficient
|
efficient
|
||||||
|
|
||||||
|
Removed since Leaf 1.21.3, no need
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BlockEntityType.java b/src/main/java/net/minecraft/world/level/block/entity/BlockEntityType.java
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BlockEntityType.java b/src/main/java/net/minecraft/world/level/block/entity/BlockEntityType.java
|
||||||
index dea945a9b278353647dca3ed001158c198dab668..d3a82a012b8bbb9d4c6936dbb40a1994b21956cc 100644
|
index dea945a9b278353647dca3ed001158c198dab668..d3a82a012b8bbb9d4c6936dbb40a1994b21956cc 100644
|
||||||
@@ -0,0 +1,564 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Tue, 8 Aug 2023 21:12:58 +0200
|
||||||
|
Subject: [PATCH] Add xor-shift random
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
Removed since Gale 1.21.4, not fast enough, replaced by Leaf's faster random generator
|
||||||
|
|
||||||
|
License: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
This patch is based on the following patch:
|
||||||
|
"Apply faster random"
|
||||||
|
By: AlphaKR93 <dev@alpha93.kr>
|
||||||
|
As part of: Plazma (https://github.com/PlazmaMC/Plazma)
|
||||||
|
Class `org.plazmamc.plazma.Random` licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
||||||
|
Other changes licensed under: MIT (https://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
* Plazma copyright *
|
||||||
|
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java b/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java
|
||||||
|
index 861bff267cb397e13e8e1c79bd0776b130c6e5da..30972bf7889973cf63b5f32ad166afdc9800bee1 100644
|
||||||
|
--- a/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java
|
||||||
|
+++ b/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java
|
||||||
|
@@ -21,7 +21,7 @@ import org.checkerframework.framework.qual.DefaultQualifier;
|
||||||
|
@DefaultQualifier(NonNull.class)
|
||||||
|
public class PaperLootableInventoryData {
|
||||||
|
|
||||||
|
- private static final Random RANDOM = new Random();
|
||||||
|
+ public static Random RANDOM; // Gale - xor-shift random - set in GaleGlobalConfiguration
|
||||||
|
|
||||||
|
private long lastFill = -1;
|
||||||
|
private long nextRefill = -1;
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||||
|
index 3f6d60601cbfc138ab004e38bf442d985192fd3f..370266dfa461432b9e22b3ce35d6094949dc2f49 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||||
|
@@ -132,7 +132,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
||||||
|
this.defaultBlockState = empty ? VOID_AIR_BLOCKSTATE : AIR_BLOCKSTATE;
|
||||||
|
// Paper end - get block chunk optimisation
|
||||||
|
|
||||||
|
- this.lightningTick = this.level.simpleRandom.nextInt(100000) << 1; // Gale - Airplane - optimize random calls in chunk ticking - initialize lightning tick
|
||||||
|
+ this.lightningTick = org.galemc.gale.configuration.GaleGlobalConfiguration.get().smallOptimizations.useXorShiftRandom.lightningRandomTick ? new org.galemc.gale.random.XorShiftRandom().nextInt(100000) << 1 : this.level.simpleRandom.nextInt(100000) << 1; // Gale - Airplane - optimize random calls in chunk ticking - initialize lightning tick // Gale - xor-shift random
|
||||||
|
}
|
||||||
|
|
||||||
|
// CraftBukkit start
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||||
|
index 16f07007a0f73ec0c6f421c9b082518e87e8cc7b..b26a5b76cd30c96ce15ced5ac51222a8333bde52 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||||
|
@@ -109,7 +109,7 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche
|
||||||
|
}
|
||||||
|
|
||||||
|
private void backupRegionFile() {
|
||||||
|
- Path backup = this.path.getParent().resolve(this.path.getFileName() + "." + new java.util.Random().nextLong() + ".backup");
|
||||||
|
+ Path backup = this.path.getParent().resolve(this.path.getFileName() + "." + new org.galemc.gale.random.XorShiftRandom().nextLong() + ".backup"); // Gale - xor-shift random
|
||||||
|
this.backupRegionFile(backup);
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||||
|
index 57da11c0da7322e74810e7108e9c8000b0c36520..d39a0785f42c72d7b32af5c1c8067b2857f22a48 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||||
|
@@ -288,7 +288,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||||
|
}
|
||||||
|
// Paper end
|
||||||
|
|
||||||
|
- private static final Random rand = new Random();
|
||||||
|
+ public static Random rand; // Gale - xor-shift random - set in GaleGlobalConfiguration
|
||||||
|
|
||||||
|
public CraftWorld(ServerLevel world, ChunkGenerator gen, BiomeProvider biomeProvider, Environment env) {
|
||||||
|
this.world = world;
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
|
||||||
|
index 759b6e54db93792c9862b1f1625118ac6fa49d7a..4b5e9bc33c25ac98c32aff1bd13788edf0eeee8c 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
|
||||||
|
@@ -14,7 +14,7 @@ import org.bukkit.inventory.meta.FireworkMeta;
|
||||||
|
|
||||||
|
public class CraftFirework extends CraftProjectile implements Firework {
|
||||||
|
|
||||||
|
- private final Random random = new Random();
|
||||||
|
+ private final Random random = org.galemc.gale.configuration.GaleGlobalConfiguration.get().smallOptimizations.useXorShiftRandom.elytraFireworkSpeed ? new org.galemc.gale.random.XorShiftRandom() : new Random(); // Gale - xor-shift random - not thread-safe but it is not really a concern here
|
||||||
|
//private CraftItemStack item; // Paper - Remove usage, not accurate representation of current item.
|
||||||
|
|
||||||
|
public CraftFirework(CraftServer server, FireworkRocketEntity entity) {
|
||||||
|
diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
|
||||||
|
index 3e5efa90180308cbfaaa063d96ad788985720b8c..c57ebf0f37aba2d118e54f3c71697f29bb9a57a0 100644
|
||||||
|
--- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
|
||||||
|
+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
|
||||||
|
@@ -10,6 +10,7 @@ import org.spongepowered.configurate.objectmapping.meta.PostProcess;
|
||||||
|
import org.spongepowered.configurate.objectmapping.meta.Setting;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
+import java.util.Random;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
@SuppressWarnings({"CanBeFinal", "FieldCanBeLocal", "FieldMayBeFinal", "NotNullFieldNotInitialized", "InnerClassMayBeStatic"})
|
||||||
|
@@ -41,13 +42,27 @@ public class GaleGlobalConfiguration extends ConfigurationPart {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
- // Gale start - Pufferfish - SIMD support
|
||||||
|
- public Simd simd;
|
||||||
|
- public class Simd extends ConfigurationPart {
|
||||||
|
- public boolean warnIfDisabled = true;
|
||||||
|
- public boolean logVectorSizesToConsole = false;
|
||||||
|
+ // Gale start - xor-shift random
|
||||||
|
+ public UseXorShiftRandom useXorShiftRandom;
|
||||||
|
+ public class UseXorShiftRandom extends ConfigurationPart {
|
||||||
|
+
|
||||||
|
+ public boolean autoReplenishLootableRefill = true;
|
||||||
|
+ public boolean elytraFireworkSpeed = true;
|
||||||
|
+ public boolean entityWakeUpDuration = true;
|
||||||
|
+ public boolean lightningRandomTick = true;
|
||||||
|
+
|
||||||
|
+ @Setting("generate-tree-with-bukkit-api")
|
||||||
|
+ public boolean generateTreeWithBukkitAPI = true;
|
||||||
|
+
|
||||||
|
+ @PostProcess
|
||||||
|
+ public void postProcess() {
|
||||||
|
+ com.destroystokyo.paper.loottable.PaperLootableInventoryData.RANDOM = autoReplenishLootableRefill ? new org.galemc.gale.random.XorShiftRandom() : new Random();
|
||||||
|
+ org.spigotmc.ActivationRange.wakeUpDurationRandom = entityWakeUpDuration ? new org.galemc.gale.random.XorShiftRandom() : new java.util.Random();
|
||||||
|
+ org.bukkit.craftbukkit.CraftWorld.rand = generateTreeWithBukkitAPI ? new org.galemc.gale.random.XorShiftRandom() : new Random();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
}
|
||||||
|
- // Gale end - Pufferfish - SIMD support
|
||||||
|
+ // Gale end - xor-shift random
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/galemc/gale/random/XorShiftRandom.java b/src/main/java/org/galemc/gale/random/XorShiftRandom.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..60dc2c1deb0749168d03c5d94136e613b09ce534
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/org/galemc/gale/random/XorShiftRandom.java
|
||||||
|
@@ -0,0 +1,404 @@
|
||||||
|
+// Gale - xor-shift random
|
||||||
|
+
|
||||||
|
+package org.galemc.gale.random;
|
||||||
|
+
|
||||||
|
+import java.util.Random;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * A random number generator based on the simple and fast xor-shift pseudo
|
||||||
|
+ * random number generator (RNG) specified in:
|
||||||
|
+ * <br>
|
||||||
|
+ * Marsaglia, George. (2003).
|
||||||
|
+ * <a href="https://www.researchgate.net/publication/5142825_Xorshift_RNGs">Xorshift RNGs</a>.
|
||||||
|
+ * <br>
|
||||||
|
+ * Code from:
|
||||||
|
+ * <br>
|
||||||
|
+ * <a href="https://gist.github.com/Xyene/4637619">Random.java</a>
|
||||||
|
+ * by <a href="https://gist.github.com/Xyene">Xyene</a>.
|
||||||
|
+ * <br>
|
||||||
|
+ * Translated from:
|
||||||
|
+ * <br>
|
||||||
|
+ * <a href="http://www.codeproject.com/Articles/9187/A-fast-equivalent-for-System-Random">
|
||||||
|
+ * A fast equivalent for System.Random</a> by <a href="https://www.codeproject.com/Members/colgreen">colgreen</a>.
|
||||||
|
+ * <br>
|
||||||
|
+ * Licensed under <a href="https://www.gnu.org/licenses/lgpl-3.0.html">GNU Lesser General Public License version 3</a>.
|
||||||
|
+ */
|
||||||
|
+public final class XorShiftRandom extends Random {
|
||||||
|
+ final double REAL_UNIT_INT = 1.0 / (0x7FFFFFFFL);
|
||||||
|
+ final double REAL_UNIT_UINT = 1.0 / (0xFFFFFFFFL);
|
||||||
|
+ final long Y = 842502087L, Z = 3579807591L, W = 273326509L;
|
||||||
|
+ long x, y, z, w;
|
||||||
|
+
|
||||||
|
+ public XorShiftRandom() {
|
||||||
|
+ seed((int) System.currentTimeMillis());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void setSeed(long seed) {
|
||||||
|
+ seed((int) seed);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void seed(int seed) {
|
||||||
|
+ // The only stipulation stated for the xorshift RNG is that at least one of
|
||||||
|
+ // the seeds x,y,z,w is non-zero. We fulfill that requirement by only allowing
|
||||||
|
+ // resetting of the x seed
|
||||||
|
+ x = seed;
|
||||||
|
+ y = Y;
|
||||||
|
+ z = Z;
|
||||||
|
+ w = W;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ long boolBuffer;
|
||||||
|
+ int boolBufferBits = 0;
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean nextBoolean() {
|
||||||
|
+ if (boolBufferBits == 0) {
|
||||||
|
+ boolBuffer = nextUInt();
|
||||||
|
+ boolBufferBits = 32;
|
||||||
|
+ }
|
||||||
|
+ boolBuffer >>= 1;
|
||||||
|
+ boolean bit = (boolBuffer & 1) == 0;
|
||||||
|
+ --boolBufferBits;
|
||||||
|
+ return bit;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void nextBytes(byte[] buffer) {
|
||||||
|
+ // Fill up the bulk of the buffer in chunks of 4 bytes at a time.
|
||||||
|
+ long x = this.x, y = this.y, z = this.z, w = this.w;
|
||||||
|
+ int i = 0;
|
||||||
|
+ long t;
|
||||||
|
+ for (int bound = buffer.length - 3; i < bound; ) {
|
||||||
|
+ // Generate 4 bytes.
|
||||||
|
+ // Increased performance is achieved by generating 4 random bytes per loop.
|
||||||
|
+ // Also note that no mask needs to be applied to zero out the higher order bytes before
|
||||||
|
+ // casting because the cast ignores thos bytes. Thanks to Stefan Trosch黷z for pointing this out.
|
||||||
|
+ t = (x ^ (x << 11));
|
||||||
|
+ x = y;
|
||||||
|
+ y = z;
|
||||||
|
+ z = w;
|
||||||
|
+ w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
|
||||||
|
+
|
||||||
|
+ buffer[i++] = (byte) w;
|
||||||
|
+ buffer[i++] = (byte) (w >> 8);
|
||||||
|
+ buffer[i++] = (byte) (w >> 16);
|
||||||
|
+ buffer[i++] = (byte) (w >> 24);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ // Fill up any remaining bytes in the buffer.
|
||||||
|
+ if (i < buffer.length) {
|
||||||
|
+ // Generate 4 bytes.
|
||||||
|
+ t = (x ^ (x << 11));
|
||||||
|
+ x = y;
|
||||||
|
+ y = z;
|
||||||
|
+ z = w;
|
||||||
|
+ w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
|
||||||
|
+
|
||||||
|
+ buffer[i++] = (byte) w;
|
||||||
|
+ if (i < buffer.length) {
|
||||||
|
+ buffer[i++] = (byte) (w >> 8);
|
||||||
|
+ if (i < buffer.length) {
|
||||||
|
+ buffer[i++] = (byte) (w >> 16);
|
||||||
|
+ if (i < buffer.length) {
|
||||||
|
+ buffer[i] = (byte) (w >> 24);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ this.x = x;
|
||||||
|
+ this.y = y;
|
||||||
|
+ this.z = z;
|
||||||
|
+ this.w = w;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public double nextDouble() {
|
||||||
|
+ long t = (x ^ (x << 11));
|
||||||
|
+ x = y;
|
||||||
|
+ y = z;
|
||||||
|
+ z = w;
|
||||||
|
+
|
||||||
|
+ // Here we can gain a 2x speed improvement by generating a value that can be cast to
|
||||||
|
+ // an int instead of the more easily available uint. If we then explicitly cast to an
|
||||||
|
+ // int the compiler will then cast the int to a double to perform the multiplication,
|
||||||
|
+ // this final cast is a lot faster than casting from a uint to a double. The extra cast
|
||||||
|
+ // to an int is very fast (the allocated bits remain the same) and so the overall effect
|
||||||
|
+ // of the extra cast is a significant performance improvement.
|
||||||
|
+ //
|
||||||
|
+ // Also note that the loss of one bit of precision is equivalent to what occurs within
|
||||||
|
+ // System.Random.
|
||||||
|
+ return (REAL_UNIT_INT * (int) (0x7FFFFFFF & (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)))));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public double random() {
|
||||||
|
+ return nextDouble();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public float nextFloat() {
|
||||||
|
+ return (float) nextDouble();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public int nextInt() {
|
||||||
|
+ long t = (x ^ (x << 11));
|
||||||
|
+ x = y;
|
||||||
|
+ y = z;
|
||||||
|
+ z = w;
|
||||||
|
+ return (int) (0x7FFFFFFF & (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public int nextInt(int upperBound) {
|
||||||
|
+ if (upperBound < 0)
|
||||||
|
+ throw new IllegalArgumentException("upperBound must be >=0");
|
||||||
|
+
|
||||||
|
+ long t = (x ^ (x << 11));
|
||||||
|
+ x = y;
|
||||||
|
+ y = z;
|
||||||
|
+ z = w;
|
||||||
|
+
|
||||||
|
+ return (int) ((REAL_UNIT_INT * (int) (0x7FFFFFFF & (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))))) * upperBound);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public int nextInt(int lowerBound, int upperBound) {
|
||||||
|
+ if (lowerBound > upperBound)
|
||||||
|
+ throw new IllegalArgumentException("upperBound must be >=lowerBound");
|
||||||
|
+
|
||||||
|
+ long t = (x ^ (x << 11));
|
||||||
|
+ x = y;
|
||||||
|
+ y = z;
|
||||||
|
+ z = w;
|
||||||
|
+
|
||||||
|
+ // The explicit int cast before the first multiplication gives better performance.
|
||||||
|
+ // See comments in NextDouble.
|
||||||
|
+ int range = upperBound - lowerBound;
|
||||||
|
+ if (range < 0) {
|
||||||
|
+ // If range is <0 then an overflow has occured and must resort to using long integer arithmetic instead (slower).
|
||||||
|
+ // We also must use all 32 bits of precision, instead of the normal 31, which again is slower.
|
||||||
|
+ return lowerBound + (int) ((REAL_UNIT_UINT * (double) (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)))) * (double) ((long) upperBound - (long) lowerBound));
|
||||||
|
+ }
|
||||||
|
+ // 31 bits of precision will suffice if range<=int.MaxValue. This allows us to cast to an int and gain
|
||||||
|
+ // a little more performance.
|
||||||
|
+ return lowerBound + (int) ((REAL_UNIT_INT * (double) (int) (0x7FFFFFFF & (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))))) * (double) range);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public long nextUInt() {
|
||||||
|
+ long t = (x ^ (x << 11));
|
||||||
|
+ x = y;
|
||||||
|
+ y = z;
|
||||||
|
+ z = w;
|
||||||
|
+ return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))) & (0xFFFFFFFFL);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public long nextLong() {
|
||||||
|
+ return nextUInt() << 32 + nextUInt();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ double gaussNext;
|
||||||
|
+ boolean hasGaussNext;
|
||||||
|
+ final double TWOPI = Math.PI * 2;
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Get a random number in the range [min, max) or [min, max] depending on rounding.
|
||||||
|
+ *
|
||||||
|
+ * @param min Low bound
|
||||||
|
+ * @param max High bound
|
||||||
|
+ * @return A uniformly distributed double
|
||||||
|
+ */
|
||||||
|
+ public double uniform(double min, double max) {
|
||||||
|
+ return min + (max - min) * nextDouble();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Triangular distribution.
|
||||||
|
+ * <p/>
|
||||||
|
+ * Continuous distribution bounded by given lower and upper limits,
|
||||||
|
+ * and having a given mode value in-between.
|
||||||
|
+ * http://en.wikipedia.org/wiki/Triangular_distribution
|
||||||
|
+ *
|
||||||
|
+ * @param low Low bound
|
||||||
|
+ * @param high High bound
|
||||||
|
+ * @param mode Mode
|
||||||
|
+ * @return A number from the triangular distribution specified
|
||||||
|
+ */
|
||||||
|
+ public double triangular(int low, int high, int mode) {
|
||||||
|
+ double u = nextDouble();
|
||||||
|
+ double c = (mode - low) / (high - low);
|
||||||
|
+ if (u > c) {
|
||||||
|
+ u = 1.0 - u;
|
||||||
|
+ c = 1.0 - c;
|
||||||
|
+ int k = low;
|
||||||
|
+ low = high;
|
||||||
|
+ high = k;
|
||||||
|
+ }
|
||||||
|
+ return low + (high - low) * Math.sqrt(u * c);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gaussian distribution, mean is 0 and standard deviation is 1.
|
||||||
|
+ * <p/>
|
||||||
|
+ * mu is the mean, and sigma is the standard deviation.
|
||||||
|
+ *
|
||||||
|
+ * @return A double in Gaussian distribution
|
||||||
|
+ */
|
||||||
|
+ public double gauss() {
|
||||||
|
+ return nextGaussian();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gaussian distribution, with user-specified mean and standard deviation.
|
||||||
|
+ * <p/>
|
||||||
|
+ * mu is the mean, and sigma is the standard deviation.
|
||||||
|
+ *
|
||||||
|
+ * @return A double in Gaussian distribution
|
||||||
|
+ */
|
||||||
|
+ public double gauss(double mu, double sigma) {
|
||||||
|
+ return mu + sigma * nextGaussian();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public double gaussUnsigned(double mu, double sigma) {
|
||||||
|
+ double out = gauss(mu, sigma);
|
||||||
|
+ return out > 1 ? out : 1;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Log normal distribution.
|
||||||
|
+ * <p/>
|
||||||
|
+ * If you take the natural logarithm of this distribution, you'll get a
|
||||||
|
+ * normal distribution with mean mu and standard deviation sigma.
|
||||||
|
+ * mu can have any value, and sigma must be greater than zero.
|
||||||
|
+ *
|
||||||
|
+ * @param mu Mean
|
||||||
|
+ * @param sigma Standard deviation
|
||||||
|
+ * @return A number from the log normal distribution specified
|
||||||
|
+ */
|
||||||
|
+ public double logNormal(double mu, double sigma) {
|
||||||
|
+ return Math.exp(gauss(mu, sigma));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Exponential distribution.
|
||||||
|
+ * <p/>
|
||||||
|
+ * lambda is 1.0 divided by the desired mean. It should be
|
||||||
|
+ * nonzero. Returned values range from 0 to positive infinity
|
||||||
|
+ * if lambda is positive, and from negative infinity to 0
|
||||||
|
+ * if lambda is negative.
|
||||||
|
+ *
|
||||||
|
+ * @param lambda A non-zero value
|
||||||
|
+ */
|
||||||
|
+ public double exponential(double lambda) {
|
||||||
|
+ return -Math.log(1.0 - random()) / lambda;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Circular data distribution.
|
||||||
|
+ * <p/>
|
||||||
|
+ * If kappa is equal to zero, this distribution reduces
|
||||||
|
+ * to a uniform random angle over the range 0 to 2*pi.
|
||||||
|
+ *
|
||||||
|
+ * @param mu the mean angle, expressed in radians between 0 and 2*pi.
|
||||||
|
+ * @param kappa the concentration parameter, which must be greater than or
|
||||||
|
+ * equal to zero.
|
||||||
|
+ * @return A number from the circular data distribution specified
|
||||||
|
+ */
|
||||||
|
+ public double circularData(double mu, double kappa) {
|
||||||
|
+ if (kappa <= 1e-6)
|
||||||
|
+ return TWOPI * nextDouble();
|
||||||
|
+
|
||||||
|
+ double a = 1.0 + Math.sqrt(1.0 + 4.0 * kappa * kappa);
|
||||||
|
+ double b = (a - Math.sqrt(2.0 * a)) / (2.0 * kappa);
|
||||||
|
+ double r = (1.0 + b * b) / (2.0 * b);
|
||||||
|
+ double u1, u2, u3, f, c, z, theta = 0;
|
||||||
|
+
|
||||||
|
+ while (true) {
|
||||||
|
+ u1 = nextDouble();
|
||||||
|
+
|
||||||
|
+ z = Math.cos(Math.PI * u1);
|
||||||
|
+ f = (1.0 + r * z) / (r + z);
|
||||||
|
+ c = kappa * (r - f);
|
||||||
|
+
|
||||||
|
+ u2 = nextDouble();
|
||||||
|
+
|
||||||
|
+ if (u2 < c * (2.0 - c) || u2 <= c * Math.exp(1.0 - c))
|
||||||
|
+ break;
|
||||||
|
+
|
||||||
|
+ u3 = nextDouble();
|
||||||
|
+ if (u3 > 0.5)
|
||||||
|
+ theta = (mu % TWOPI) + Math.acos(f);
|
||||||
|
+ else
|
||||||
|
+ theta = (mu % TWOPI) - Math.acos(f);
|
||||||
|
+ }
|
||||||
|
+ return theta;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+ final double LOG4 = Math.log(4);
|
||||||
|
+ final double SG_MAGICCONST = 1.0 + Math.log(4.5);
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gamma distribution. Not the gamma function!
|
||||||
|
+ * Conditions on the parameters are alpha > 0 and beta > 0.
|
||||||
|
+ * <p/>
|
||||||
|
+ * The probability distribution function is:
|
||||||
|
+ * pdf(x) = (x ** (alpha - 1) * math.exp(-x / beta)) / (math.gamma(alpha) * beta ** alpha)
|
||||||
|
+ *
|
||||||
|
+ * @param alpha Alpha
|
||||||
|
+ * @param beta Beta
|
||||||
|
+ * @return A number from the gamma distribution specified
|
||||||
|
+ */
|
||||||
|
+ public double gamma(double alpha, double beta) {
|
||||||
|
+ if (alpha <= 0.0 || beta <= 0.0)
|
||||||
|
+ throw new IllegalArgumentException("alpha and beta must be > 0.0");
|
||||||
|
+
|
||||||
|
+ if (alpha > 1.0) {
|
||||||
|
+ double ainv = Math.sqrt(2.0 * alpha - 1.0);
|
||||||
|
+ double bbb = alpha - LOG4;
|
||||||
|
+ double ccc = alpha + ainv;
|
||||||
|
+ double u1, u2, v, x, z, r;
|
||||||
|
+
|
||||||
|
+ while (true) {
|
||||||
|
+ u1 = random();
|
||||||
|
+ if (!(1e-7 < u1 && u1 < .9999999))
|
||||||
|
+ continue;
|
||||||
|
+ u2 = 1.0 - random();
|
||||||
|
+ v = Math.log(u1 / (1.0 - u1)) / ainv;
|
||||||
|
+ x = alpha * Math.exp(v);
|
||||||
|
+ z = u1 * u1 * u2;
|
||||||
|
+ r = bbb + ccc * v - x;
|
||||||
|
+ if (r + SG_MAGICCONST - 4.5 * z >= 0.0 || r >= Math.log(z))
|
||||||
|
+ return x * beta;
|
||||||
|
+ }
|
||||||
|
+ } else if (alpha == 1.0) {
|
||||||
|
+ // exponential(1)
|
||||||
|
+ double u;
|
||||||
|
+ u = random();
|
||||||
|
+ while (u <= 1e-7)
|
||||||
|
+ u = random();
|
||||||
|
+ return -Math.log(u) * beta;
|
||||||
|
+ } else {
|
||||||
|
+ // alpha is between 0 and 1 (exclusive)
|
||||||
|
+ // Uses ALGORITHM GS of Statistical Computing -Kennedy & Gentle
|
||||||
|
+
|
||||||
|
+ double u, b, p, x, u1;
|
||||||
|
+ while (true) {
|
||||||
|
+ u = random();
|
||||||
|
+ b = (Math.E + alpha) / Math.E;
|
||||||
|
+ p = b * u;
|
||||||
|
+ if (p <= 1.0)
|
||||||
|
+ x = Math.pow(p, (1.0 / alpha));
|
||||||
|
+ else
|
||||||
|
+ x = -Math.log((b - p) / alpha);
|
||||||
|
+ u1 = random();
|
||||||
|
+ if (p > 1.0) {
|
||||||
|
+ if (u1 <= Math.pow(x, (alpha - 1.0)))
|
||||||
|
+ break;
|
||||||
|
+ } else if (u1 <= Math.exp(-x))
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ return x * beta;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
||||||
|
index f1581caf54012ce4d4b9aecbc56b5b815c67a423..5d1cc9b9150f84bb84cef5dd741e72787c02f089 100644
|
||||||
|
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
||||||
|
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
||||||
|
@@ -92,7 +92,7 @@ public class ActivationRange
|
||||||
|
// Paper end
|
||||||
|
|
||||||
|
// Gale start - variable entity wake-up duration
|
||||||
|
- private static final java.util.Random wakeUpDurationRandom = new java.util.Random();
|
||||||
|
+ public static java.util.Random wakeUpDurationRandom; // Gale - xor-shift random - set in GaleGlobalConfiguration
|
||||||
|
|
||||||
|
private static int getWakeUpDurationWithVariance(Entity entity, int wakeUpDuration) {
|
||||||
|
double deviation = entity.level().galeConfig().gameplayMechanics.entityWakeUpDurationRatioStandardDeviation;
|
||||||
@@ -4,6 +4,8 @@ Date: Fri, 8 Nov 2024 23:38:51 -0500
|
|||||||
Subject: [PATCH] Fix wrong entity behavior in fluid caused by inconsistent
|
Subject: [PATCH] Fix wrong entity behavior in fluid caused by inconsistent
|
||||||
fluid count
|
fluid count
|
||||||
|
|
||||||
|
Removed since Leaf 1.21.3, no need
|
||||||
|
|
||||||
Revert Gale (Airplane)'s `no entity fluid lookup if no fluid`, to fix
|
Revert Gale (Airplane)'s `no entity fluid lookup if no fluid`, to fix
|
||||||
wrong entity behavior on water.
|
wrong entity behavior on water.
|
||||||
This issue caused by inconsistent fluid count, because of a condition change
|
This issue caused by inconsistent fluid count, because of a condition change
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Sat, 4 Feb 2023 10:58:12 +0100
|
||||||
|
Subject: [PATCH] Include time in startup logs
|
||||||
|
|
||||||
|
Removed since 1.21
|
||||||
|
|
||||||
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||||
|
index 6e1f92b45504cef0c4dcbbebf3df339ef4cad0a1..f4106b117c2b82a25616b590e7b0853f05864ea1 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||||
|
@@ -2,6 +2,7 @@ package org.bukkit.craftbukkit;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
+import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Calendar;
|
||||||
|
@@ -25,6 +26,26 @@ public class Main {
|
||||||
|
}
|
||||||
|
// Paper end - Reset loggers after shutdown
|
||||||
|
|
||||||
|
+ // Gale start - include time in startup logs
|
||||||
|
+ private static final DateFormat startupDateFormat = new SimpleDateFormat("HH:mm:ss");
|
||||||
|
+
|
||||||
|
+ private static void printlnStartupToSystemOut(String type, String line) {
|
||||||
|
+ System.out.println("[" + startupDateFormat.format(new Date()) + " " + type + "]: " + line);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static void printlnStartupInfoToSystemOut(String line) {
|
||||||
|
+ printlnStartupToSystemOut("INFO", line);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static void printlnStartupWarningToSystemOut(String line) {
|
||||||
|
+ printlnStartupToSystemOut("WARN", line);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static void printlnStartupErrorToSystemOut(String line) {
|
||||||
|
+ printlnStartupToSystemOut("ERROR", line);
|
||||||
|
+ }
|
||||||
|
+ // Gale end - include time in startup logs
|
||||||
|
+
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// Paper start
|
||||||
|
final String warnWhenLegacyFormattingDetected = String.join(".", "net", "kyori", "adventure", "text", "warnWhenLegacyFormattingDetected");
|
||||||
|
@@ -288,13 +309,13 @@ public class Main {
|
||||||
|
String javaInfo = "Java " + runtimeMX.getSpecVersion() + " (" + runtimeMX.getVmName() + " " + runtimeMX.getVmVersion() + ")";
|
||||||
|
String osInfo = "Host: " + osMX.getName() + " " + osMX.getVersion() + " (" + osMX.getArch() + ")";
|
||||||
|
|
||||||
|
- System.out.println("System Info: " + javaInfo + " " + osInfo);
|
||||||
|
+ printlnStartupInfoToSystemOut("System Info: " + javaInfo + " " + osInfo); // Gale - include time in startup logs
|
||||||
|
} else {
|
||||||
|
- System.out.println("Unable to read system info");
|
||||||
|
+ printlnStartupInfoToSystemOut("Unable to read system info"); // Gale - include time in startup logs
|
||||||
|
}
|
||||||
|
// Paper end - Log Java and OS versioning to help with debugging plugin issues
|
||||||
|
|
||||||
|
- System.out.println("Loading libraries, please wait...");
|
||||||
|
+ printlnStartupInfoToSystemOut("Loading libraries, please wait..."); // Gale - include time in startup logs
|
||||||
|
net.minecraft.server.Main.main(options);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
t.printStackTrace();
|
||||||
@@ -0,0 +1,251 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Sat, 24 Dec 2022 17:56:41 +0100
|
||||||
|
Subject: [PATCH] Include server.properties in timings
|
||||||
|
|
||||||
|
Removed since 1.21
|
||||||
|
|
||||||
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
diff --git a/src/main/java/co/aikar/timings/TimingsExport.java b/src/main/java/co/aikar/timings/TimingsExport.java
|
||||||
|
index 29796a404e210f7864f4b33b3367e02531bca2a0..73e503d0590964ac7f9ea15ac7ee7783f0801b2e 100644
|
||||||
|
--- a/src/main/java/co/aikar/timings/TimingsExport.java
|
||||||
|
+++ b/src/main/java/co/aikar/timings/TimingsExport.java
|
||||||
|
@@ -35,6 +35,7 @@ import org.bukkit.Material;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.configuration.MemorySection;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
+import org.galemc.gale.configuration.timingsexport.VanillaServerPropertiesTimingsExport;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
import org.json.simple.JSONValue;
|
||||||
|
import oshi.SystemInfo;
|
||||||
|
@@ -238,6 +239,7 @@ public class TimingsExport extends Thread {
|
||||||
|
// Information on the users Config
|
||||||
|
|
||||||
|
parent.put("config", createObject(
|
||||||
|
+ pair("server.properties", VanillaServerPropertiesTimingsExport.get()), // Gale - include server.properties in timings
|
||||||
|
pair("spigot", mapAsJSON(Bukkit.spigot().getSpigotConfig(), null)),
|
||||||
|
pair("bukkit", mapAsJSON(Bukkit.spigot().getBukkitConfig(), null)),
|
||||||
|
// Gale start - Gale configuration - include in timings
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
||||||
|
index d6431376184e5650b370cbab204e28bc31f4dac6..bfe9be2e329c2ea2c8c44458e88d22bc75520ed4 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
||||||
|
@@ -67,6 +67,7 @@ public class DedicatedServerProperties extends Settings<DedicatedServerPropertie
|
||||||
|
public final Difficulty difficulty;
|
||||||
|
public final GameType gamemode;
|
||||||
|
public final String levelName;
|
||||||
|
+ public final String levelSeed; // Gale - include server.properties in timings
|
||||||
|
public final int serverPort;
|
||||||
|
@Nullable
|
||||||
|
public final Boolean announcePlayerAchievements;
|
||||||
|
@@ -100,13 +101,14 @@ public class DedicatedServerProperties extends Settings<DedicatedServerPropertie
|
||||||
|
public final boolean hideOnlinePlayers;
|
||||||
|
public final int entityBroadcastRangePercentage;
|
||||||
|
public final String textFilteringConfig;
|
||||||
|
+ public final String resourcePackPrompt; // Gale - include server.properties in timings
|
||||||
|
public final Optional<MinecraftServer.ServerResourcePackInfo> serverResourcePackInfo;
|
||||||
|
public final DataPackConfig initialDataPackConfiguration;
|
||||||
|
public final Settings<DedicatedServerProperties>.MutableValue<Integer> playerIdleTimeout;
|
||||||
|
public final Settings<DedicatedServerProperties>.MutableValue<Boolean> whiteList;
|
||||||
|
public final boolean enforceSecureProfile;
|
||||||
|
public final boolean logIPs;
|
||||||
|
- private final DedicatedServerProperties.WorldDimensionData worldDimensionData;
|
||||||
|
+ public final DedicatedServerProperties.WorldDimensionData worldDimensionData; // Gale - include server.properties in timings - private -> public
|
||||||
|
public final WorldOptions worldOptions;
|
||||||
|
public boolean acceptsTransfers;
|
||||||
|
|
||||||
|
@@ -161,6 +163,7 @@ public class DedicatedServerProperties extends Settings<DedicatedServerPropertie
|
||||||
|
this.logIPs = this.get("log-ips", true);
|
||||||
|
this.acceptsTransfers = this.get("accepts-transfers", false);
|
||||||
|
String s = this.get("level-seed", "");
|
||||||
|
+ this.levelSeed = s; // Gale - include server.properties in timings
|
||||||
|
boolean flag = this.get("generate-structures", true);
|
||||||
|
long i = WorldOptions.parseSeed(s).orElse(WorldOptions.randomSeed());
|
||||||
|
|
||||||
|
@@ -170,7 +173,10 @@ public class DedicatedServerProperties extends Settings<DedicatedServerPropertie
|
||||||
|
}, new JsonObject()), (String) this.get("level-type", (s1) -> {
|
||||||
|
return s1.toLowerCase(Locale.ROOT);
|
||||||
|
}, WorldPresets.NORMAL.location().toString()));
|
||||||
|
- this.serverResourcePackInfo = DedicatedServerProperties.getServerPackInfo(this.get("resource-pack-id", ""), this.get("resource-pack", ""), this.get("resource-pack-sha1", ""), this.getLegacyString("resource-pack-hash"), this.get("require-resource-pack", false), this.get("resource-pack-prompt", ""));
|
||||||
|
+ // Gale start - include server.properties in timings
|
||||||
|
+ this.resourcePackPrompt = this.get("resource-pack-prompt", "");
|
||||||
|
+ this.serverResourcePackInfo = DedicatedServerProperties.getServerPackInfo(this.get("resource-pack-id", ""), this.get("resource-pack", ""), this.get("resource-pack-sha1", ""), this.getLegacyString("resource-pack-hash"), this.get("require-resource-pack", false), this.resourcePackPrompt);
|
||||||
|
+ // Gale end - include server.properties in timings
|
||||||
|
this.initialDataPackConfiguration = DedicatedServerProperties.getDatapackConfig(this.get("initial-enabled-packs", String.join(",", WorldDataConfiguration.DEFAULT.dataPacks().getEnabled())), this.get("initial-disabled-packs", String.join(",", WorldDataConfiguration.DEFAULT.dataPacks().getDisabled())));
|
||||||
|
// Paper start - Configurable rcon ip
|
||||||
|
final String rconIp = this.getStringRaw("rcon.ip");
|
||||||
|
diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
|
||||||
|
index 8f8fd98f96cd390ba43033521982a13044df91cf..dbb0f523608a9208e8c656898b18ce1b9505a1e0 100644
|
||||||
|
--- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
|
||||||
|
+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
|
||||||
|
@@ -27,4 +27,33 @@ public class GaleGlobalConfiguration extends ConfigurationPart {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
+ public Misc misc;
|
||||||
|
+ public class Misc extends ConfigurationPart {
|
||||||
|
+
|
||||||
|
+ public IncludeInTimingsReport includeInTimingsReport;
|
||||||
|
+ public class IncludeInTimingsReport extends ConfigurationPart {
|
||||||
|
+
|
||||||
|
+ // Gale start - include server.properties in timings
|
||||||
|
+ public ServerProperties serverProperties;
|
||||||
|
+ public class ServerProperties extends ConfigurationPart {
|
||||||
|
+ public boolean dataPacks = true;
|
||||||
|
+ public boolean enableRcon = false;
|
||||||
|
+ public boolean generatorSettings = true;
|
||||||
|
+ public boolean levelName = false;
|
||||||
|
+ public boolean motd = false;
|
||||||
|
+ public boolean queryPort = false;
|
||||||
|
+ public boolean rconPort = false;
|
||||||
|
+ public boolean resourcePackPrompt = false;
|
||||||
|
+ @Setting("resource-pack-and-resource-pack-sha1")
|
||||||
|
+ public boolean resourcePackAndResourcePackSha1 = false;
|
||||||
|
+ public boolean serverIp = false;
|
||||||
|
+ public boolean serverPort = false;
|
||||||
|
+ public boolean textFilteringConfig = false;
|
||||||
|
+ }
|
||||||
|
+ // Gale end - include server.properties in timings
|
||||||
|
+
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/galemc/gale/configuration/timingsexport/VanillaServerPropertiesTimingsExport.java b/src/main/java/org/galemc/gale/configuration/timingsexport/VanillaServerPropertiesTimingsExport.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..139d946346594d2a59a8b2930c4eae794c880dbc
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/org/galemc/gale/configuration/timingsexport/VanillaServerPropertiesTimingsExport.java
|
||||||
|
@@ -0,0 +1,129 @@
|
||||||
|
+// Gale - include server.properties in timings
|
||||||
|
+
|
||||||
|
+package org.galemc.gale.configuration.timingsexport;
|
||||||
|
+
|
||||||
|
+import co.aikar.timings.TimingsExport;
|
||||||
|
+import net.minecraft.server.MinecraftServer;
|
||||||
|
+import net.minecraft.server.dedicated.DedicatedServer;
|
||||||
|
+import org.galemc.gale.configuration.GaleGlobalConfiguration;
|
||||||
|
+import org.jetbrains.annotations.NotNull;
|
||||||
|
+import org.json.simple.JSONObject;
|
||||||
|
+
|
||||||
|
+import java.util.Optional;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * Exports the vanilla server.properties to a JSON object, to be included in a timings report.
|
||||||
|
+ *
|
||||||
|
+ * @see TimingsExport
|
||||||
|
+ *
|
||||||
|
+ * @author Martijn Muijsers under GPL-3.0
|
||||||
|
+ */
|
||||||
|
+public final class VanillaServerPropertiesTimingsExport {
|
||||||
|
+
|
||||||
|
+ private VanillaServerPropertiesTimingsExport() {}
|
||||||
|
+
|
||||||
|
+ @SuppressWarnings("unchecked")
|
||||||
|
+ public static @NotNull JSONObject get() {
|
||||||
|
+
|
||||||
|
+ var json = new JSONObject();
|
||||||
|
+ var properties = ((DedicatedServer) MinecraftServer.getServer()).getProperties();
|
||||||
|
+ var includeConfig = GaleGlobalConfiguration.get().misc.includeInTimingsReport.serverProperties;
|
||||||
|
+
|
||||||
|
+ json.put("allow-flight", String.valueOf(properties.allowFlight));
|
||||||
|
+ json.put("allow-nether", String.valueOf(properties.allowNether));
|
||||||
|
+ json.put("broadcast-console-to-ops", String.valueOf(properties.broadcastConsoleToOps));
|
||||||
|
+ json.put("broadcast-rcon-to-ops", String.valueOf(properties.broadcastRconToOps));
|
||||||
|
+ json.put("debug", String.valueOf(properties.debug));
|
||||||
|
+ json.put("difficulty", String.valueOf(properties.difficulty));
|
||||||
|
+ json.put("enable-command-block", String.valueOf(properties.enableCommandBlock));
|
||||||
|
+ json.put("enable-jmx-monitoring", String.valueOf(properties.enableJmxMonitoring));
|
||||||
|
+ json.put("enable-query", String.valueOf(properties.enableQuery));
|
||||||
|
+ if (includeConfig.enableRcon) {
|
||||||
|
+ json.put("enable-rcon", String.valueOf(properties.enableRcon));
|
||||||
|
+ }
|
||||||
|
+ json.put("enable-status", String.valueOf(properties.enableStatus));
|
||||||
|
+ json.put("enforce-secure-profile", String.valueOf(properties.enforceSecureProfile));
|
||||||
|
+ json.put("enforce-whitelist", String.valueOf(properties.enforceWhitelist));
|
||||||
|
+ json.put("entity-broadcast-range-percentage", String.valueOf(properties.entityBroadcastRangePercentage));
|
||||||
|
+ json.put("force-gamemode", String.valueOf(properties.forceGameMode));
|
||||||
|
+ json.put("function-permission-level", String.valueOf(properties.functionPermissionLevel));
|
||||||
|
+ json.put("gamemode", String.valueOf(properties.gamemode));
|
||||||
|
+ Optional.ofNullable(properties.worldOptions).ifPresent(worldOptions -> json.put("generate-structures", String.valueOf(worldOptions.generateStructures())));
|
||||||
|
+ if (includeConfig.generatorSettings) {
|
||||||
|
+ Optional.ofNullable(properties.worldDimensionData).ifPresent(worldDimensionData -> json.put("generator-settings", String.valueOf(worldDimensionData.generatorSettings())));
|
||||||
|
+ }
|
||||||
|
+ json.put("hardcore", String.valueOf(properties.hardcore));
|
||||||
|
+ json.put("hide-online-players", String.valueOf(properties.hideOnlinePlayers));
|
||||||
|
+ if (includeConfig.dataPacks) {
|
||||||
|
+ Optional.ofNullable(properties.initialDataPackConfiguration).ifPresent(initialDataPackConfiguration -> {
|
||||||
|
+ json.put("initial-enabled-packs", String.valueOf(initialDataPackConfiguration.getEnabled()));
|
||||||
|
+ json.put("initial-disabled-packs", String.valueOf(initialDataPackConfiguration.getDisabled()));
|
||||||
|
+ });
|
||||||
|
+ }
|
||||||
|
+ if (includeConfig.levelName) {
|
||||||
|
+ json.put("level-name", String.valueOf(properties.levelName));
|
||||||
|
+ }
|
||||||
|
+ // Note: level-seed is never included to prevent it being leaked
|
||||||
|
+// if (includeConfig.levelSeed) {
|
||||||
|
+// json.put("level-seed", String.valueOf(properties.levelSeed));
|
||||||
|
+// }
|
||||||
|
+ Optional.ofNullable(properties.worldDimensionData).ifPresent(worldDimensionData -> json.put("level-type", String.valueOf(worldDimensionData.levelType())));
|
||||||
|
+ json.put("log-ips", String.valueOf(properties.logIPs));
|
||||||
|
+ json.put("max-chained-neighbor-updates", String.valueOf(properties.maxChainedNeighborUpdates));
|
||||||
|
+ json.put("max-players", String.valueOf(properties.maxPlayers));
|
||||||
|
+ json.put("max-tick-time", String.valueOf(properties.maxTickTime));
|
||||||
|
+ json.put("max-world-size", String.valueOf(properties.maxWorldSize));
|
||||||
|
+ if (includeConfig.motd) {
|
||||||
|
+ json.put("motd", String.valueOf(properties.motd));
|
||||||
|
+ }
|
||||||
|
+ json.put("network-compression-threshold", String.valueOf(properties.networkCompressionThreshold));
|
||||||
|
+ json.put("online-mode", String.valueOf(properties.onlineMode));
|
||||||
|
+ json.put("op-permission-level", String.valueOf(properties.opPermissionLevel));
|
||||||
|
+ Optional.ofNullable(properties.playerIdleTimeout).ifPresent(playerIdleTimeout -> json.put("player-idle-timeout", String.valueOf(playerIdleTimeout.get())));
|
||||||
|
+ json.put("prevent-proxy-connections", String.valueOf(properties.preventProxyConnections));
|
||||||
|
+ json.put("pvp", String.valueOf(properties.pvp));
|
||||||
|
+ if (includeConfig.queryPort) {
|
||||||
|
+ json.put("query-port", String.valueOf(properties.queryPort));
|
||||||
|
+ }
|
||||||
|
+ json.put("rate-limit", String.valueOf(properties.rateLimitPacketsPerSecond));
|
||||||
|
+ // Note: rcon-password is never included to prevent it being leaked
|
||||||
|
+// if (includeConfig.rconPassword) {
|
||||||
|
+// json.put("rcon-password", String.valueOf(properties.rconPassword));
|
||||||
|
+// }
|
||||||
|
+ if (includeConfig.rconPort) {
|
||||||
|
+ json.put("rcon-port", String.valueOf(properties.queryPort));
|
||||||
|
+ }
|
||||||
|
+ properties.serverResourcePackInfo.ifPresent(serverResourcePackInfo -> {
|
||||||
|
+ json.put("require-resource-pack", String.valueOf(serverResourcePackInfo.isRequired()));
|
||||||
|
+ if (includeConfig.resourcePackAndResourcePackSha1) {
|
||||||
|
+ json.put("resource-pack", String.valueOf(serverResourcePackInfo.url()));
|
||||||
|
+ json.put("resource-pack-sha1", String.valueOf(serverResourcePackInfo.hash()));
|
||||||
|
+ }
|
||||||
|
+ });
|
||||||
|
+ if (includeConfig.resourcePackPrompt) {
|
||||||
|
+ json.put("resource-pack-prompt", String.valueOf(properties.resourcePackPrompt));
|
||||||
|
+ }
|
||||||
|
+ if (includeConfig.serverIp) {
|
||||||
|
+ json.put("server-ip", String.valueOf(properties.serverIp));
|
||||||
|
+ }
|
||||||
|
+ if (includeConfig.serverPort) {
|
||||||
|
+ json.put("server-port", String.valueOf(properties.serverPort));
|
||||||
|
+ }
|
||||||
|
+ json.put("simulation-distance", String.valueOf(properties.simulationDistance));
|
||||||
|
+ json.put("spawn-animals", String.valueOf(properties.spawnAnimals));
|
||||||
|
+ json.put("spawn-monsters", String.valueOf(properties.spawnMonsters));
|
||||||
|
+ json.put("spawn-npcs", String.valueOf(properties.spawnNpcs));
|
||||||
|
+ json.put("spawn-protection", String.valueOf(properties.spawnProtection));
|
||||||
|
+ json.put("sync-chunk-writes", String.valueOf(properties.syncChunkWrites));
|
||||||
|
+ if (includeConfig.textFilteringConfig) {
|
||||||
|
+ json.put("text-filtering-config", String.valueOf(properties.textFilteringConfig));
|
||||||
|
+ }
|
||||||
|
+ json.put("use-native-transport", String.valueOf(properties.useNativeTransport));
|
||||||
|
+ json.put("view-distance", String.valueOf(properties.viewDistance));
|
||||||
|
+ Optional.ofNullable(properties.whiteList).ifPresent(whiteList -> json.put("white-list", String.valueOf(whiteList.get())));
|
||||||
|
+
|
||||||
|
+ return json;
|
||||||
|
+
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+}
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Sat, 24 Dec 2022 20:28:31 +0100
|
||||||
|
Subject: [PATCH] Include hardware specs in timings
|
||||||
|
|
||||||
|
Removed since 1.21
|
||||||
|
|
||||||
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
diff --git a/src/main/java/co/aikar/timings/TimingsExport.java b/src/main/java/co/aikar/timings/TimingsExport.java
|
||||||
|
index 758cb80e64520ff085c4ef5ca8b2ed77d4bc0162..f749516e5d3c22e808638f3a7672aab837571b1a 100644
|
||||||
|
--- a/src/main/java/co/aikar/timings/TimingsExport.java
|
||||||
|
+++ b/src/main/java/co/aikar/timings/TimingsExport.java
|
||||||
|
@@ -35,6 +35,7 @@ import org.bukkit.Material;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.configuration.MemorySection;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
+import org.galemc.gale.configuration.GaleGlobalConfiguration;
|
||||||
|
import org.galemc.gale.configuration.timingsexport.VanillaServerPropertiesTimingsExport;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
import org.json.simple.JSONValue;
|
||||||
|
@@ -51,6 +52,8 @@ import java.lang.management.RuntimeMXBean;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.URL;
|
||||||
|
+import java.util.Arrays;
|
||||||
|
+import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
@@ -135,6 +138,59 @@ public class TimingsExport extends Thread {
|
||||||
|
|
||||||
|
HardwareAbstractionLayer hardwareInfo = new SystemInfo().getHardware();
|
||||||
|
|
||||||
|
+ // Gale start - include hardware specs in timings
|
||||||
|
+ var processor = hardwareInfo.getProcessor();
|
||||||
|
+ var processorIdentifier = processor.getProcessorIdentifier();
|
||||||
|
+ var memory = hardwareInfo.getMemory();
|
||||||
|
+
|
||||||
|
+ Map<String, Object> hardwareSpecsMap = new LinkedHashMap<>();
|
||||||
|
+ if (GaleGlobalConfiguration.get().misc.includeInTimingsReport.hardwareSpecs.cpu) {
|
||||||
|
+ hardwareSpecsMap.put("cpu", createObject(
|
||||||
|
+ pair("logicalprocessorcount", processor.getLogicalProcessorCount()),
|
||||||
|
+ pair("physicalprocessorcount", processor.getPhysicalProcessorCount()),
|
||||||
|
+ pair("physicalpackagecount", processor.getPhysicalPackageCount()),
|
||||||
|
+ pair("contextswitches", processor.getContextSwitches()),
|
||||||
|
+ pair("interrupts", processor.getInterrupts()),
|
||||||
|
+ pair("maxfreq", processor.getMaxFreq()),
|
||||||
|
+ pair("currentfreq", Arrays.toString(processor.getCurrentFreq())),
|
||||||
|
+ pair("identifier", createObject(
|
||||||
|
+ pair("vendor", String.valueOf(processorIdentifier.getVendor()).trim()),
|
||||||
|
+ pair("name", String.valueOf(processorIdentifier.getName()).trim()),
|
||||||
|
+ pair("family", String.valueOf(processorIdentifier.getFamily()).trim()),
|
||||||
|
+ pair("model", String.valueOf(processorIdentifier.getModel()).trim()),
|
||||||
|
+ pair("vendor", String.valueOf(processorIdentifier.getVendor()).trim()),
|
||||||
|
+ pair("cpu64bit", processorIdentifier.isCpu64bit()),
|
||||||
|
+ pair("vendorfreq", processorIdentifier.getVendorFreq()),
|
||||||
|
+ pair("microarchitecture", String.valueOf(processorIdentifier.getMicroarchitecture()).trim())
|
||||||
|
+ ))
|
||||||
|
+ ));
|
||||||
|
+ }
|
||||||
|
+ if (GaleGlobalConfiguration.get().misc.includeInTimingsReport.hardwareSpecs.disks) {
|
||||||
|
+ hardwareSpecsMap.put("diskstores", toArrayMapper(hardwareInfo.getDiskStores(), disk -> createObject(
|
||||||
|
+ pair("name", String.valueOf(disk.getName()).trim()),
|
||||||
|
+ pair("model", String.valueOf(disk.getModel()).trim()),
|
||||||
|
+ pair("serial", String.valueOf(disk.getSerial()).trim()),
|
||||||
|
+ pair("size", disk.getSize())
|
||||||
|
+ )));
|
||||||
|
+ }
|
||||||
|
+ if (GaleGlobalConfiguration.get().misc.includeInTimingsReport.hardwareSpecs.gpus) {
|
||||||
|
+ hardwareSpecsMap.put("gpus", toArrayMapper(hardwareInfo.getGraphicsCards(), gpu -> createObject(
|
||||||
|
+ pair("name", String.valueOf(gpu.getName()).trim()),
|
||||||
|
+ pair("deviceid", String.valueOf(gpu.getDeviceId()).trim()),
|
||||||
|
+ pair("vendor", String.valueOf(gpu.getVendor()).trim()),
|
||||||
|
+ pair("versioninfo", String.valueOf(gpu.getVersionInfo()).trim()),
|
||||||
|
+ pair("vram", gpu.getVRam())
|
||||||
|
+ )));
|
||||||
|
+ }
|
||||||
|
+ if (GaleGlobalConfiguration.get().misc.includeInTimingsReport.hardwareSpecs.memory) {
|
||||||
|
+ hardwareSpecsMap.put("memory", createObject(
|
||||||
|
+ pair("total", memory.getTotal()),
|
||||||
|
+ pair("available", memory.getAvailable()),
|
||||||
|
+ pair("pagesize", memory.getPageSize())
|
||||||
|
+ ));
|
||||||
|
+ }
|
||||||
|
+ // Gale end - include hardware specs in timings
|
||||||
|
+
|
||||||
|
parent.put("system", createObject(
|
||||||
|
pair("timingcost", getCost()),
|
||||||
|
pair("loadavg", osInfo.getSystemLoadAverage()),
|
||||||
|
@@ -152,6 +208,7 @@ public class TimingsExport extends Thread {
|
||||||
|
)),
|
||||||
|
pair("cpu", runtime.availableProcessors()),
|
||||||
|
pair("cpuname", hardwareInfo.getProcessor().getProcessorIdentifier().getName().trim()),
|
||||||
|
+ pair("hardwarespecs", hardwareSpecsMap), // Gale - include hardware specs in timings
|
||||||
|
pair("runtime", runtimeBean.getUptime()),
|
||||||
|
pair("flags", StringUtils.join(runtimeBean.getInputArguments(), " ")),
|
||||||
|
pair("gc", toObjectMapper(ManagementFactory.getGarbageCollectorMXBeans(), input -> pair(input.getName(), toArray(input.getCollectionCount(), input.getCollectionTime()))))
|
||||||
|
diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
|
||||||
|
index dbb0f523608a9208e8c656898b18ce1b9505a1e0..2a3cd1baab364126d10a42c8ab59f3da8ca9bdfb 100644
|
||||||
|
--- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
|
||||||
|
+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
|
||||||
|
@@ -32,7 +32,7 @@ public class GaleGlobalConfiguration extends ConfigurationPart {
|
||||||
|
|
||||||
|
public IncludeInTimingsReport includeInTimingsReport;
|
||||||
|
public class IncludeInTimingsReport extends ConfigurationPart {
|
||||||
|
-
|
||||||
|
+
|
||||||
|
// Gale start - include server.properties in timings
|
||||||
|
public ServerProperties serverProperties;
|
||||||
|
public class ServerProperties extends ConfigurationPart {
|
||||||
|
@@ -52,6 +52,16 @@ public class GaleGlobalConfiguration extends ConfigurationPart {
|
||||||
|
}
|
||||||
|
// Gale end - include server.properties in timings
|
||||||
|
|
||||||
|
+ // Gale start - include hardware specs in timings
|
||||||
|
+ public HardwareSpecs hardwareSpecs;
|
||||||
|
+ public class HardwareSpecs extends ConfigurationPart {
|
||||||
|
+ public boolean cpu = true;
|
||||||
|
+ public boolean disks = true;
|
||||||
|
+ public boolean gpus = true;
|
||||||
|
+ public boolean memory = true;
|
||||||
|
+ }
|
||||||
|
+ // Gale end - include hardware specs in timings
|
||||||
|
+
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Thu, 1 Dec 2022 17:26:18 +0100
|
||||||
|
Subject: [PATCH] Use timin.gs by default
|
||||||
|
|
||||||
|
Removed since 1.21
|
||||||
|
|
||||||
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
This patch is based on the following patch:
|
||||||
|
"Optimize default values for configs"
|
||||||
|
By: etil2jz <81570777+etil2jz@users.noreply.github.com>
|
||||||
|
As part of: Mirai (https://github.com/etil2jz/Mirai)
|
||||||
|
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
|
||||||
|
index 379452394679c466a09441d4c12882d0d00d9ef3..b021721efaab5242b7d174a9c859fe06a5ca6054 100644
|
||||||
|
--- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
|
||||||
|
+++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
|
||||||
|
@@ -98,7 +98,7 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||||
|
public class Timings extends ConfigurationPart {
|
||||||
|
public boolean enabled = false;
|
||||||
|
public boolean verbose = true;
|
||||||
|
- public String url = "https://timings.aikar.co/";
|
||||||
|
+ public String url = "https://timin.gs/"; // Gale - use timin.gs by default
|
||||||
|
public boolean serverNamePrivacy = false;
|
||||||
|
public List<String> hiddenConfigEntries = List.of(
|
||||||
|
"database",
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Wed, 23 Nov 2022 16:02:19 +0100
|
||||||
|
Subject: [PATCH] Recommend disabling timings on startup
|
||||||
|
|
||||||
|
Removed since 1.21
|
||||||
|
|
||||||
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
This patch is based on the following patch:
|
||||||
|
"Disable Paper timings by default"
|
||||||
|
By: Paul Sauve <paul@technove.co>
|
||||||
|
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||||
|
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
|
||||||
|
* Airplane copyright *
|
||||||
|
|
||||||
|
Airplane
|
||||||
|
Copyright (C) 2020 Technove LLC
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) 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 General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
|
||||||
|
index b021721efaab5242b7d174a9c859fe06a5ca6054..65c7a798ae69602f586038ecb2c9ab4f7b968fce 100644
|
||||||
|
--- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
|
||||||
|
+++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
|
||||||
|
@@ -97,6 +97,7 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
|
public class Timings extends ConfigurationPart {
|
||||||
|
public boolean enabled = false;
|
||||||
|
+ public boolean warnIfEnabled = true; // Gale - recommend disabling timings on startup
|
||||||
|
public boolean verbose = true;
|
||||||
|
public String url = "https://timin.gs/"; // Gale - use timin.gs by default
|
||||||
|
public boolean serverNamePrivacy = false;
|
||||||
|
@@ -110,6 +111,13 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||||
|
|
||||||
|
@PostProcess
|
||||||
|
private void postProcess() {
|
||||||
|
+ // Gale start - recommend disabling timings on startup
|
||||||
|
+ if (enabled && warnIfEnabled) {
|
||||||
|
+ net.minecraft.server.MinecraftServer.LOGGER.warn("To improve performance, we recommend setting timings.enabled to false in paper-global.yml");
|
||||||
|
+ net.minecraft.server.MinecraftServer.LOGGER.warn("(If you do this, timings will not start on server startup, but you can still start timings later by using /timings on)");
|
||||||
|
+ net.minecraft.server.MinecraftServer.LOGGER.warn("If you would like to disable this message, set timings.warn-if-enabled to false in paper-global.yml.");
|
||||||
|
+ }
|
||||||
|
+ // Gale end - recommend disabling timings on startup
|
||||||
|
MinecraftTimings.processConfig(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Sat, 24 Dec 2022 13:24:18 +0100
|
||||||
|
Subject: [PATCH] Make timings calls final
|
||||||
|
|
||||||
|
Removed since 1.21
|
||||||
|
|
||||||
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
|
index b53c92cf6b172222689674de8554709757b36a84..b157214ca20be2ddd234744e5e2a8064977b1227 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
|
@@ -1577,7 +1577,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
|
}
|
||||||
|
|
||||||
|
public void tickServer(BooleanSupplier shouldKeepTicking) {
|
||||||
|
- co.aikar.timings.TimingsManager.FULL_SERVER_TICK.startTiming(); // Paper
|
||||||
|
+ co.aikar.timings.TimingsManager.FULL_SERVER_TICK.startTimingFullServerTick(); // Paper // Gale - final timings calls
|
||||||
|
long i = Util.getNanos();
|
||||||
|
|
||||||
|
// Paper start - move oversleep into full server tick
|
||||||
|
@@ -1646,7 +1646,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
|
this.logTickMethodTime(i);
|
||||||
|
this.profiler.pop();
|
||||||
|
org.spigotmc.WatchdogThread.tick(); // Spigot
|
||||||
|
- co.aikar.timings.TimingsManager.FULL_SERVER_TICK.stopTiming(); // Paper
|
||||||
|
+ co.aikar.timings.TimingsManager.FULL_SERVER_TICK.stopTimingFullServerTick(); // Paper // Gale - final timings calls
|
||||||
|
}
|
||||||
|
|
||||||
|
private void logTickMethodTime(long tickStartTime) {
|
||||||
@@ -0,0 +1,278 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Wed, 23 Nov 2022 20:35:40 +0100
|
||||||
|
Subject: [PATCH] Improve fluid direction caching
|
||||||
|
|
||||||
|
Removed since 1.21.1, Paper 1.21.3, or Moonrise's imple is a bit faster
|
||||||
|
|
||||||
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
This patch is based on the following patch:
|
||||||
|
"Improve fluid direction caching"
|
||||||
|
By: Paul Sauve <paul@technove.co>
|
||||||
|
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||||
|
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
|
||||||
|
* Airplane description *
|
||||||
|
|
||||||
|
Implements a custom cache that better fits the needs of fluids
|
||||||
|
calculating whether a direction can be moved in or something. There's a
|
||||||
|
big javadoc on the FluidDirectionCache with some more information.
|
||||||
|
|
||||||
|
* Airplane copyright *
|
||||||
|
|
||||||
|
Airplane
|
||||||
|
Copyright (C) 2020 Technove LLC
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) 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 General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
diff --git a/src/main/java/gg/airplane/structs/FluidDirectionCache.java b/src/main/java/gg/airplane/structs/FluidDirectionCache.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..bf6a36c933b686f0e34591dff3d43b3797c29b2b
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/gg/airplane/structs/FluidDirectionCache.java
|
||||||
|
@@ -0,0 +1,143 @@
|
||||||
|
+// Gale - Airplane - improve fluid direction caching
|
||||||
|
+
|
||||||
|
+package gg.airplane.structs;
|
||||||
|
+
|
||||||
|
+import it.unimi.dsi.fastutil.HashCommon;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * This is a replacement for the cache used in FluidTypeFlowing.
|
||||||
|
+ * The requirements for the previous cache were:
|
||||||
|
+ * <ul>
|
||||||
|
+ * <li>Store 200 entries</li>
|
||||||
|
+ * <li>Look for the flag in the cache</li>
|
||||||
|
+ * <li>If it exists, move to front of cache</li>
|
||||||
|
+ * <li>If it doesn't exist, remove last entry in cache and insert in front</li>
|
||||||
|
+ * </ul>
|
||||||
|
+ * This class accomplishes something similar, however has a few different
|
||||||
|
+ * requirements put into place to make this more optimize:
|
||||||
|
+ * <ul>
|
||||||
|
+ * <li>
|
||||||
|
+ * maxDistance is the most amount of entries to be checked, instead
|
||||||
|
+ * of having to check the entire list.
|
||||||
|
+ * </li>
|
||||||
|
+ * <li>
|
||||||
|
+ * In combination with that, entries are all tracked by age and how
|
||||||
|
+ * frequently they're used. This enables us to remove old entries,
|
||||||
|
+ * without constantly shifting any around.
|
||||||
|
+ * </li>
|
||||||
|
+ * </ul>
|
||||||
|
+ * Usage of the previous map would have to reset the head every single usage,
|
||||||
|
+ * shifting the entire map. Here, nothing happens except an increment when
|
||||||
|
+ * the cache is hit, and when it needs to replace an old element only a single
|
||||||
|
+ * element is modified.
|
||||||
|
+ */
|
||||||
|
+public class FluidDirectionCache<T> {
|
||||||
|
+
|
||||||
|
+ private static class FluidDirectionEntry<T> {
|
||||||
|
+ private final T data;
|
||||||
|
+ private final boolean flag;
|
||||||
|
+ private int uses = 0;
|
||||||
|
+ private int age = 0;
|
||||||
|
+
|
||||||
|
+ private FluidDirectionEntry(T data, boolean flag) {
|
||||||
|
+ this.data = data;
|
||||||
|
+ this.flag = flag;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public int getValue() {
|
||||||
|
+ return this.uses - (this.age >> 1); // age isn't as important as uses
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void incrementUses() {
|
||||||
|
+ this.uses = this.uses + 1 & Integer.MAX_VALUE;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void incrementAge() {
|
||||||
|
+ this.age = this.age + 1 & Integer.MAX_VALUE;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private final FluidDirectionEntry[] entries;
|
||||||
|
+ private final int mask;
|
||||||
|
+ private final int maxDistance; // the most amount of entries to check for a value
|
||||||
|
+
|
||||||
|
+ public FluidDirectionCache(int size) {
|
||||||
|
+ int arraySize = HashCommon.nextPowerOfTwo(size);
|
||||||
|
+ this.entries = new FluidDirectionEntry[arraySize];
|
||||||
|
+ this.mask = arraySize - 1;
|
||||||
|
+ this.maxDistance = Math.min(arraySize, 4);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public Boolean getValue(T data) {
|
||||||
|
+ FluidDirectionEntry curr;
|
||||||
|
+ int pos;
|
||||||
|
+
|
||||||
|
+ if ((curr = this.entries[pos = HashCommon.mix(data.hashCode()) & this.mask]) == null) {
|
||||||
|
+ return null;
|
||||||
|
+ } else if (data.equals(curr.data)) {
|
||||||
|
+ curr.incrementUses();
|
||||||
|
+ return curr.flag;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ int checked = 1; // start at 1 because we already checked the first spot above
|
||||||
|
+
|
||||||
|
+ while ((curr = this.entries[pos = (pos + 1) & this.mask]) != null) {
|
||||||
|
+ if (data.equals(curr.data)) {
|
||||||
|
+ curr.incrementUses();
|
||||||
|
+ return curr.flag;
|
||||||
|
+ } else if (++checked >= this.maxDistance) {
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return null;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void putValue(T data, boolean flag) {
|
||||||
|
+ FluidDirectionEntry<T> curr;
|
||||||
|
+ int pos;
|
||||||
|
+
|
||||||
|
+ if ((curr = this.entries[pos = HashCommon.mix(data.hashCode()) & this.mask]) == null) {
|
||||||
|
+ this.entries[pos] = new FluidDirectionEntry<>(data, flag); // add
|
||||||
|
+ return;
|
||||||
|
+ } else if (data.equals(curr.data)) {
|
||||||
|
+ curr.incrementUses();
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ int checked = 1; // start at 1 because we already checked the first spot above
|
||||||
|
+
|
||||||
|
+ while ((curr = this.entries[pos = (pos + 1) & this.mask]) != null) {
|
||||||
|
+ if (data.equals(curr.data)) {
|
||||||
|
+ curr.incrementUses();
|
||||||
|
+ return;
|
||||||
|
+ } else if (++checked >= this.maxDistance) {
|
||||||
|
+ this.forceAdd(data, flag);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ this.entries[pos] = new FluidDirectionEntry<>(data, flag); // add
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private void forceAdd(T data, boolean flag) {
|
||||||
|
+ int expectedPos = HashCommon.mix(data.hashCode()) & this.mask;
|
||||||
|
+
|
||||||
|
+ int toRemovePos = expectedPos;
|
||||||
|
+ FluidDirectionEntry entryToRemove = this.entries[toRemovePos];
|
||||||
|
+
|
||||||
|
+ for (int i = expectedPos + 1; i < expectedPos + this.maxDistance; i++) {
|
||||||
|
+ int pos = i & this.mask;
|
||||||
|
+ FluidDirectionEntry entry = this.entries[pos];
|
||||||
|
+ if (entry.getValue() < entryToRemove.getValue()) {
|
||||||
|
+ toRemovePos = pos;
|
||||||
|
+ entryToRemove = entry;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ entry.incrementAge(); // use this as a mechanism to age the other entries
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ // remove the least used/oldest entry
|
||||||
|
+ this.entries[toRemovePos] = new FluidDirectionEntry(data, flag);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
||||||
|
index 1c0712295695727ee9c4d430d4157b8e17cbd71f..0eac7bc0c56ac17c900737271a965cfc1ccd03d2 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
||||||
|
@@ -45,6 +45,8 @@ public abstract class FlowingFluid extends Fluid {
|
||||||
|
public static final BooleanProperty FALLING = BlockStateProperties.FALLING;
|
||||||
|
public static final IntegerProperty LEVEL = BlockStateProperties.LEVEL_FLOWING;
|
||||||
|
private static final int CACHE_SIZE = 200;
|
||||||
|
+ // Gale start - Airplane - improve fluid direction caching - use our own cache
|
||||||
|
+ /*
|
||||||
|
private static final ThreadLocal<Object2ByteLinkedOpenHashMap<Block.BlockStatePairKey>> OCCLUSION_CACHE = ThreadLocal.withInitial(() -> {
|
||||||
|
Object2ByteLinkedOpenHashMap<Block.BlockStatePairKey> object2bytelinkedopenhashmap = new Object2ByteLinkedOpenHashMap<Block.BlockStatePairKey>(200) {
|
||||||
|
protected void rehash(int i) {}
|
||||||
|
@@ -53,6 +55,14 @@ public abstract class FlowingFluid extends Fluid {
|
||||||
|
object2bytelinkedopenhashmap.defaultReturnValue((byte) 127);
|
||||||
|
return object2bytelinkedopenhashmap;
|
||||||
|
});
|
||||||
|
+ */
|
||||||
|
+
|
||||||
|
+ private static final ThreadLocal<gg.airplane.structs.FluidDirectionCache<Block.BlockStatePairKey>> localFluidDirectionCache = ThreadLocal.withInitial(() -> {
|
||||||
|
+ // Gale - Airplane - TODO - mess with this number for performance
|
||||||
|
+ // with 2048 it seems very infrequent on a small world that it has to remove old entries
|
||||||
|
+ return new gg.airplane.structs.FluidDirectionCache<>(2048);
|
||||||
|
+ });
|
||||||
|
+ // Gale end - Airplane - improve fluid direction caching - use our own cache
|
||||||
|
private final Map<FluidState, VoxelShape> shapes = Maps.newIdentityHashMap();
|
||||||
|
|
||||||
|
public FlowingFluid() {}
|
||||||
|
@@ -240,6 +250,8 @@ public abstract class FlowingFluid extends Fluid {
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean canPassThroughWall(Direction face, BlockGetter world, BlockPos pos, BlockState state, BlockPos fromPos, BlockState fromState) {
|
||||||
|
+ // Gale start - Airplane - improve fluid direction caching - modify to use our cache
|
||||||
|
+ /*
|
||||||
|
Object2ByteLinkedOpenHashMap object2bytelinkedopenhashmap;
|
||||||
|
|
||||||
|
if (!state.getBlock().hasDynamicShape() && !fromState.getBlock().hasDynamicShape()) {
|
||||||
|
@@ -247,9 +259,16 @@ public abstract class FlowingFluid extends Fluid {
|
||||||
|
} else {
|
||||||
|
object2bytelinkedopenhashmap = null;
|
||||||
|
}
|
||||||
|
+ */
|
||||||
|
+ gg.airplane.structs.FluidDirectionCache<Block.BlockStatePairKey> cache = null;
|
||||||
|
+
|
||||||
|
+ if (!state.getBlock().hasDynamicShape() && !fromState.getBlock().hasDynamicShape()) {
|
||||||
|
+ cache = localFluidDirectionCache.get();
|
||||||
|
+ }
|
||||||
|
|
||||||
|
Block.BlockStatePairKey block_a;
|
||||||
|
|
||||||
|
+ /*
|
||||||
|
if (object2bytelinkedopenhashmap != null) {
|
||||||
|
block_a = new Block.BlockStatePairKey(state, fromState, face);
|
||||||
|
byte b0 = object2bytelinkedopenhashmap.getAndMoveToFirst(block_a);
|
||||||
|
@@ -260,11 +279,22 @@ public abstract class FlowingFluid extends Fluid {
|
||||||
|
} else {
|
||||||
|
block_a = null;
|
||||||
|
}
|
||||||
|
+ */
|
||||||
|
+ if (cache != null) {
|
||||||
|
+ block_a = new Block.BlockStatePairKey(state, fromState, face);
|
||||||
|
+ Boolean flag = cache.getValue(block_a);
|
||||||
|
+ if (flag != null) {
|
||||||
|
+ return flag;
|
||||||
|
+ }
|
||||||
|
+ } else {
|
||||||
|
+ block_a = null;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
VoxelShape voxelshape = state.getCollisionShape(world, pos);
|
||||||
|
VoxelShape voxelshape1 = fromState.getCollisionShape(world, fromPos);
|
||||||
|
boolean flag = !Shapes.mergedFaceOccludes(voxelshape, voxelshape1, face);
|
||||||
|
|
||||||
|
+ /*
|
||||||
|
if (object2bytelinkedopenhashmap != null) {
|
||||||
|
if (object2bytelinkedopenhashmap.size() == 200) {
|
||||||
|
object2bytelinkedopenhashmap.removeLastByte();
|
||||||
|
@@ -272,6 +302,11 @@ public abstract class FlowingFluid extends Fluid {
|
||||||
|
|
||||||
|
object2bytelinkedopenhashmap.putAndMoveToFirst(block_a, (byte) (flag ? 1 : 0));
|
||||||
|
}
|
||||||
|
+ */
|
||||||
|
+ if (cache != null) {
|
||||||
|
+ cache.putValue(block_a, flag);
|
||||||
|
+ }
|
||||||
|
+ // Gale end - Airplane - improve fluid direction caching - modify to use our cache
|
||||||
|
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
@@ -0,0 +1,513 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Wed, 23 Nov 2022 22:11:06 +0100
|
||||||
|
Subject: [PATCH] Improve container checking with a bitset
|
||||||
|
|
||||||
|
Removed since 1.21.1, performance regression
|
||||||
|
|
||||||
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
This patch is based on the following patch:
|
||||||
|
"Improve container checking with a bitset"
|
||||||
|
By: Paul Sauve <paul@technove.co>
|
||||||
|
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||||
|
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
|
||||||
|
* Airplane copyright *
|
||||||
|
|
||||||
|
Airplane
|
||||||
|
Copyright (C) 2020 Technove LLC
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) 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 General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
diff --git a/src/main/java/gg/airplane/structs/ItemListWithBitset.java b/src/main/java/gg/airplane/structs/ItemListWithBitset.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..a45b135af87324c99a9fdd6ba9564255e5beb199
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/gg/airplane/structs/ItemListWithBitset.java
|
||||||
|
@@ -0,0 +1,116 @@
|
||||||
|
+// Gale - Airplane - improve container checking with a bitset
|
||||||
|
+
|
||||||
|
+package gg.airplane.structs;
|
||||||
|
+
|
||||||
|
+import net.minecraft.core.NonNullList;
|
||||||
|
+import net.minecraft.world.item.ItemStack;
|
||||||
|
+import org.apache.commons.lang.Validate;
|
||||||
|
+import org.jetbrains.annotations.NotNull;
|
||||||
|
+import org.jetbrains.annotations.Nullable;
|
||||||
|
+
|
||||||
|
+import java.util.AbstractList;
|
||||||
|
+import java.util.Arrays;
|
||||||
|
+import java.util.List;
|
||||||
|
+
|
||||||
|
+public class ItemListWithBitset extends AbstractList<ItemStack> {
|
||||||
|
+ public static ItemListWithBitset fromList(List<ItemStack> list) {
|
||||||
|
+ if (list instanceof ItemListWithBitset ours) {
|
||||||
|
+ return ours;
|
||||||
|
+ }
|
||||||
|
+ return new ItemListWithBitset(list);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static ItemStack[] createArray(int size) {
|
||||||
|
+ ItemStack[] array = new ItemStack[size];
|
||||||
|
+ Arrays.fill(array, ItemStack.EMPTY);
|
||||||
|
+ return array;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private final ItemStack[] items;
|
||||||
|
+
|
||||||
|
+ private long bitSet = 0;
|
||||||
|
+ private final long allBits;
|
||||||
|
+
|
||||||
|
+ private static class OurNonNullList extends NonNullList<ItemStack> {
|
||||||
|
+ protected OurNonNullList(List<ItemStack> delegate) {
|
||||||
|
+ super(delegate, ItemStack.EMPTY);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public final NonNullList<ItemStack> nonNullList = new OurNonNullList(this);
|
||||||
|
+
|
||||||
|
+ private ItemListWithBitset(List<ItemStack> list) {
|
||||||
|
+ this(list.size());
|
||||||
|
+
|
||||||
|
+ for (int i = 0; i < list.size(); i++) {
|
||||||
|
+ this.set(i, list.get(i));
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public ItemListWithBitset(int size) {
|
||||||
|
+ Validate.isTrue(size < Long.BYTES * 8, "size is too large");
|
||||||
|
+
|
||||||
|
+ this.items = createArray(size);
|
||||||
|
+ this.allBits = ((1L << size) - 1);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public boolean isCompletelyEmpty() {
|
||||||
|
+ return this.bitSet == 0;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public boolean hasFullStacks() {
|
||||||
|
+ return (this.bitSet & this.allBits) == allBits;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public ItemStack set(int index, @NotNull ItemStack itemStack) {
|
||||||
|
+ ItemStack existing = this.items[index];
|
||||||
|
+
|
||||||
|
+ this.items[index] = itemStack;
|
||||||
|
+
|
||||||
|
+ if (itemStack == ItemStack.EMPTY) {
|
||||||
|
+ this.bitSet &= ~(1L << index);
|
||||||
|
+ } else {
|
||||||
|
+ this.bitSet |= 1L << index;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return existing;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @NotNull
|
||||||
|
+ @Override
|
||||||
|
+ public ItemStack get(int var0) {
|
||||||
|
+ return this.items[var0];
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public int size() {
|
||||||
|
+ return this.items.length;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void clear() {
|
||||||
|
+ Arrays.fill(this.items, ItemStack.EMPTY);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ // these are unsupported for block inventories which have a static size
|
||||||
|
+ @Override
|
||||||
|
+ public void add(int var0, ItemStack var1) {
|
||||||
|
+ throw new UnsupportedOperationException();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public ItemStack remove(int var0) {
|
||||||
|
+ throw new UnsupportedOperationException();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public String toString() {
|
||||||
|
+ return "ItemListWithBitset{" +
|
||||||
|
+ "items=" + Arrays.toString(items) +
|
||||||
|
+ ", bitSet=" + Long.toString(bitSet, 2) +
|
||||||
|
+ ", allBits=" + Long.toString(allBits, 2) +
|
||||||
|
+ ", size=" + this.items.length +
|
||||||
|
+ '}';
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/CompoundContainer.java b/src/main/java/net/minecraft/world/CompoundContainer.java
|
||||||
|
index 241fec02e6869c638d3a160819b32173a081467b..1380f521de979b8734ebd13dd420b312db15dc04 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/CompoundContainer.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/CompoundContainer.java
|
||||||
|
@@ -1,5 +1,6 @@
|
||||||
|
package net.minecraft.world;
|
||||||
|
|
||||||
|
+import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
|
||||||
|
@@ -64,6 +65,23 @@ public class CompoundContainer implements Container {
|
||||||
|
this.container2 = second;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Gale start - Airplane - improve container checking with a bitset
|
||||||
|
+ @Override
|
||||||
|
+ public boolean hasEmptySlot(Direction enumdirection) {
|
||||||
|
+ return this.container1.hasEmptySlot(null) || this.container2.hasEmptySlot(null);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean isCompletelyFull(Direction enumdirection) {
|
||||||
|
+ return this.container1.isCompletelyFull(null) && this.container2.isCompletelyFull(null);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean isCompletelyEmpty(Direction enumdirection) {
|
||||||
|
+ return this.container1.isCompletelyEmpty(null) && this.container2.isCompletelyEmpty(null);
|
||||||
|
+ }
|
||||||
|
+ // Gale end - Airplane - improve container checking with a bitset
|
||||||
|
+
|
||||||
|
@Override
|
||||||
|
public int getContainerSize() {
|
||||||
|
return this.container1.getContainerSize() + this.container2.getContainerSize();
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/Container.java b/src/main/java/net/minecraft/world/Container.java
|
||||||
|
index 5db5ba026462ca642dcee718af732f80fadabef5..bd31beb514bf7607eeefebf3c027264b2c6949ab 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/Container.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/Container.java
|
||||||
|
@@ -3,6 +3,8 @@ package net.minecraft.world;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
+
|
||||||
|
+import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.item.Item;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
@@ -14,6 +16,63 @@ import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
|
public interface Container extends Clearable {
|
||||||
|
+ // Gale start - Airplane - improve container checking with a bitset - allow the inventory to override and optimize these frequent calls
|
||||||
|
+ default boolean hasEmptySlot(@org.jetbrains.annotations.Nullable Direction enumdirection) { // there is a slot with 0 items in it
|
||||||
|
+ if (this instanceof WorldlyContainer worldlyContainer) {
|
||||||
|
+ for (int i : worldlyContainer.getSlotsForFace(enumdirection)) {
|
||||||
|
+ if (this.getItem(i).isEmpty()) {
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ } else {
|
||||||
|
+ int size = this.getContainerSize();
|
||||||
|
+ for (int i = 0; i < size; i++) {
|
||||||
|
+ if (this.getItem(i).isEmpty()) {
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ default boolean isCompletelyFull(@org.jetbrains.annotations.Nullable Direction enumdirection) { // every stack is maxed
|
||||||
|
+ if (this instanceof WorldlyContainer worldlyContainer) {
|
||||||
|
+ for (int i : worldlyContainer.getSlotsForFace(enumdirection)) {
|
||||||
|
+ ItemStack itemStack = this.getItem(i);
|
||||||
|
+ if (itemStack.getCount() < itemStack.getMaxStackSize()) {
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ } else {
|
||||||
|
+ int size = this.getContainerSize();
|
||||||
|
+ for (int i = 0; i < size; i++) {
|
||||||
|
+ ItemStack itemStack = this.getItem(i);
|
||||||
|
+ if (itemStack.getCount() < itemStack.getMaxStackSize()) {
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ default boolean isCompletelyEmpty(@org.jetbrains.annotations.Nullable Direction enumdirection) {
|
||||||
|
+ if (this instanceof WorldlyContainer worldlyContainer) {
|
||||||
|
+ for (int i : worldlyContainer.getSlotsForFace(enumdirection)) {
|
||||||
|
+ if (!this.getItem(i).isEmpty()) {
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ } else {
|
||||||
|
+ int size = this.getContainerSize();
|
||||||
|
+ for (int i = 0; i < size; i++) {
|
||||||
|
+ if (!this.getItem(i).isEmpty()) {
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+ // Gale end - Airplane - improve container checking with a bitset - allow the inventory to override and optimize these frequent calls
|
||||||
|
|
||||||
|
float DEFAULT_DISTANCE_BUFFER = 4.0F;
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||||
|
index 9549eee0d92f322bd5232abd7e695213660c2e22..297e13ccc47cf1d4fa92f41bb84f04df89322001 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||||
|
@@ -30,7 +30,10 @@ import org.bukkit.inventory.InventoryHolder;
|
||||||
|
|
||||||
|
public abstract class AbstractMinecartContainer extends AbstractMinecart implements ContainerEntity {
|
||||||
|
|
||||||
|
+ // Gale start - Airplane - improve container checking with a bitset
|
||||||
|
private NonNullList<ItemStack> itemStacks;
|
||||||
|
+ private gg.airplane.structs.ItemListWithBitset itemStacksOptimized;
|
||||||
|
+ // Gale end - Airplane - improve container checking with a bitset
|
||||||
|
@Nullable
|
||||||
|
public ResourceKey<LootTable> lootTable;
|
||||||
|
public long lootTableSeed;
|
||||||
|
@@ -86,12 +89,18 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
|
||||||
|
|
||||||
|
protected AbstractMinecartContainer(EntityType<?> type, Level world) {
|
||||||
|
super(type, world);
|
||||||
|
- this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513
|
||||||
|
+ // Gale start - Airplane - improve container checking with a bitset
|
||||||
|
+ this.itemStacksOptimized = new gg.airplane.structs.ItemListWithBitset(this.getContainerSize()); // CraftBukkit - SPIGOT-3513
|
||||||
|
+ this.itemStacks = this.itemStacksOptimized.nonNullList;
|
||||||
|
+ // Gale end - Airplane - improve container checking with a bitset
|
||||||
|
}
|
||||||
|
|
||||||
|
protected AbstractMinecartContainer(EntityType<?> type, double x, double y, double z, Level world) {
|
||||||
|
super(type, world, x, y, z);
|
||||||
|
- this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513
|
||||||
|
+ // Gale start - Airplane - improve container checking with a bitset
|
||||||
|
+ this.itemStacksOptimized = new gg.airplane.structs.ItemListWithBitset(this.getContainerSize()); // CraftBukkit - SPIGOT-3513
|
||||||
|
+ this.itemStacks = this.itemStacksOptimized.nonNullList;
|
||||||
|
+ // Gale end - Airplane - improve container checking with a bitset
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@@ -158,6 +167,10 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
|
||||||
|
@Override
|
||||||
|
protected void readAdditionalSaveData(CompoundTag nbt) {
|
||||||
|
super.readAdditionalSaveData(nbt);
|
||||||
|
+ // Gale start - Airplane - improve container checking with a bitset
|
||||||
|
+ this.itemStacksOptimized = new gg.airplane.structs.ItemListWithBitset(this.getContainerSize());
|
||||||
|
+ this.itemStacks = this.itemStacksOptimized.nonNullList;
|
||||||
|
+ // Gale end - Airplane - improve container checking with a bitset
|
||||||
|
this.readChestVehicleSaveData(nbt, this.registryAccess());
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java
|
||||||
|
index 15fd1fe1b55b6421d2c09e8385c9f69fa0152e56..3450ef306f96ba21bd270ca82ad435b3642c2d54 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java
|
||||||
|
@@ -119,19 +119,7 @@ public abstract class BaseContainerBlockEntity extends BlockEntity implements Co
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty() {
|
||||||
|
- Iterator iterator = this.getItems().iterator();
|
||||||
|
-
|
||||||
|
- ItemStack itemstack;
|
||||||
|
-
|
||||||
|
- do {
|
||||||
|
- if (!iterator.hasNext()) {
|
||||||
|
- return true;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- itemstack = (ItemStack) iterator.next();
|
||||||
|
- } while (itemstack.isEmpty());
|
||||||
|
-
|
||||||
|
- return false;
|
||||||
|
+ return this.isCompletelyEmpty(null); // Gale - Airplane - improve container checking with a bitset - use super
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||||
|
index b88aa184cd06a0485146f58a5b61a56a50911209..bf7ec7196d02553bc26caf87213fa24183312de3 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||||
|
@@ -32,7 +32,10 @@ import org.bukkit.entity.HumanEntity;
|
||||||
|
public class ChestBlockEntity extends RandomizableContainerBlockEntity implements LidBlockEntity {
|
||||||
|
|
||||||
|
private static final int EVENT_SET_OPEN_COUNT = 1;
|
||||||
|
+ // Gale start - Airplane - improve container checking with a bitset
|
||||||
|
private NonNullList<ItemStack> items;
|
||||||
|
+ private gg.airplane.structs.ItemListWithBitset optimizedItems;
|
||||||
|
+ // Gale end - Airplane - improve container checking with a bitset
|
||||||
|
public final ContainerOpenersCounter openersCounter;
|
||||||
|
private final ChestLidController chestLidController;
|
||||||
|
|
||||||
|
@@ -66,9 +69,13 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
|
+ private final boolean isNative = getClass().equals(ChestBlockEntity.class); // Gale - Airplane - improve container checking with a bitset
|
||||||
|
protected ChestBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||||
|
super(type, pos, state);
|
||||||
|
- this.items = NonNullList.withSize(27, ItemStack.EMPTY);
|
||||||
|
+ // Gale start - Airplane - improve container checking with a bitset
|
||||||
|
+ this.optimizedItems = new gg.airplane.structs.ItemListWithBitset(27);
|
||||||
|
+ this.items = this.optimizedItems.nonNullList;
|
||||||
|
+ // Gale end - Airplane - improve container checking with a bitset
|
||||||
|
this.openersCounter = new ContainerOpenersCounter() {
|
||||||
|
@Override
|
||||||
|
protected void onOpen(Level world, BlockPos pos, BlockState state) {
|
||||||
|
@@ -99,6 +106,23 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||||
|
this.chestLidController = new ChestLidController();
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Gale start - Airplane - improve container checking with a bitset
|
||||||
|
+ @Override
|
||||||
|
+ public boolean hasEmptySlot(Direction enumdirection) {
|
||||||
|
+ return isNative ? !this.optimizedItems.hasFullStacks() : super.hasEmptySlot(enumdirection);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean isCompletelyFull(Direction enumdirection) {
|
||||||
|
+ return isNative ? this.optimizedItems.hasFullStacks() && super.isCompletelyFull(enumdirection) : super.isCompletelyFull(enumdirection);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean isCompletelyEmpty(Direction enumdirection) {
|
||||||
|
+ return isNative && this.optimizedItems.isCompletelyEmpty() || super.isCompletelyEmpty(enumdirection);
|
||||||
|
+ }
|
||||||
|
+ // Gale end - Airplane - improve container checking with a bitset
|
||||||
|
+
|
||||||
|
public ChestBlockEntity(BlockPos pos, BlockState state) {
|
||||||
|
this(BlockEntityType.CHEST, pos, state);
|
||||||
|
}
|
||||||
|
@@ -116,7 +140,10 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||||
|
@Override
|
||||||
|
protected void loadAdditional(CompoundTag nbt, HolderLookup.Provider registryLookup) {
|
||||||
|
super.loadAdditional(nbt, registryLookup);
|
||||||
|
- this.items = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY);
|
||||||
|
+ // Gale start - Airplane - improve container checking with a bitset
|
||||||
|
+ this.optimizedItems = new gg.airplane.structs.ItemListWithBitset(this.getContainerSize());
|
||||||
|
+ this.items = this.optimizedItems.nonNullList;
|
||||||
|
+ // Gale end - Airplane - improve container checking with a bitset
|
||||||
|
if (!this.tryLoadLootTable(nbt)) {
|
||||||
|
ContainerHelper.loadAllItems(nbt, this.items, registryLookup);
|
||||||
|
}
|
||||||
|
@@ -188,7 +215,10 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setItems(NonNullList<ItemStack> inventory) {
|
||||||
|
- this.items = inventory;
|
||||||
|
+ // Gale start - Airplane - improve container checking with a bitset
|
||||||
|
+ this.optimizedItems = gg.airplane.structs.ItemListWithBitset.fromList(inventory);
|
||||||
|
+ this.items = this.optimizedItems.nonNullList;
|
||||||
|
+ // Gale end - Airplane - improve container checking with a bitset
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||||
|
index cab403efd471bb61835224eea4e99570d34dcaaa..5611217970bca6d4cc5feb10fb62fa13640b49d7 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||||
|
@@ -47,7 +47,10 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||||
|
public static final int MOVE_ITEM_SPEED = 8;
|
||||||
|
public static final int HOPPER_CONTAINER_SIZE = 5;
|
||||||
|
private static final int[][] CACHED_SLOTS = new int[54][];
|
||||||
|
+ // Gale start - Airplane - improve container checking with a bitset
|
||||||
|
private NonNullList<ItemStack> items;
|
||||||
|
+ private gg.airplane.structs.ItemListWithBitset optimizedItems;
|
||||||
|
+ // Gale end - Airplane - improve container checking with a bitset
|
||||||
|
public int cooldownTime;
|
||||||
|
private long tickedGameTime;
|
||||||
|
private Direction facing;
|
||||||
|
@@ -84,15 +87,38 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||||
|
|
||||||
|
public HopperBlockEntity(BlockPos pos, BlockState state) {
|
||||||
|
super(BlockEntityType.HOPPER, pos, state);
|
||||||
|
- this.items = NonNullList.withSize(5, ItemStack.EMPTY);
|
||||||
|
+ // Gale start - Airplane - improve container checking with a bitset
|
||||||
|
+ this.optimizedItems = new gg.airplane.structs.ItemListWithBitset(5);
|
||||||
|
+ this.items = this.optimizedItems.nonNullList;
|
||||||
|
+ // Gale end - Airplane - improve container checking with a bitset
|
||||||
|
this.cooldownTime = -1;
|
||||||
|
this.facing = (Direction) state.getValue(HopperBlock.FACING);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Gale start - Airplane - improve container checking with a bitset
|
||||||
|
+ @Override
|
||||||
|
+ public boolean hasEmptySlot(Direction enumdirection) {
|
||||||
|
+ return !this.optimizedItems.hasFullStacks();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean isCompletelyFull(Direction enumdirection) {
|
||||||
|
+ return this.optimizedItems.hasFullStacks() && super.isCompletelyFull(enumdirection);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean isCompletelyEmpty(Direction enumdirection) {
|
||||||
|
+ return this.optimizedItems.isCompletelyEmpty() || super.isCompletelyEmpty(enumdirection);
|
||||||
|
+ }
|
||||||
|
+ // Gale end - Airplane - improve container checking with a bitset
|
||||||
|
+
|
||||||
|
@Override
|
||||||
|
protected void loadAdditional(CompoundTag nbt, HolderLookup.Provider registryLookup) {
|
||||||
|
super.loadAdditional(nbt, registryLookup);
|
||||||
|
- this.items = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY);
|
||||||
|
+ // Gale start - Airplane - improve container checking with a bitset
|
||||||
|
+ this.optimizedItems = new gg.airplane.structs.ItemListWithBitset(this.getContainerSize());
|
||||||
|
+ this.items = this.optimizedItems.nonNullList;
|
||||||
|
+ // Gale end - Airplane - improve container checking with a bitset
|
||||||
|
if (!this.tryLoadLootTable(nbt)) {
|
||||||
|
ContainerHelper.loadAllItems(nbt, this.items, registryLookup);
|
||||||
|
}
|
||||||
|
@@ -205,7 +231,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||||
|
flag = HopperBlockEntity.ejectItems(world, pos, blockEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (fullState != HOPPER_IS_FULL || flag) { // Paper - Perf: Optimize Hoppers
|
||||||
|
+ if (!blockEntity.optimizedItems.hasFullStacks() || fullState != HOPPER_IS_FULL || flag) { // Paper - Perf: Optimize Hoppers // Gale - Airplane - improve container checking with a bitset - use bitset first
|
||||||
|
flag |= booleansupplier.getAsBoolean();
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -245,7 +271,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||||
|
skipPushModeEventFire = skipHopperEvents;
|
||||||
|
boolean foundItem = false;
|
||||||
|
for (int i = 0; i < hopper.getContainerSize(); ++i) {
|
||||||
|
- final ItemStack item = hopper.getItem(i);
|
||||||
|
+ final ItemStack item = hopper.getItem(i); // Gale - Airplane - improve container checking with a bitset
|
||||||
|
if (!item.isEmpty()) {
|
||||||
|
foundItem = true;
|
||||||
|
ItemStack origItemStack = item;
|
||||||
|
@@ -733,7 +759,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||||
|
|
||||||
|
if (HopperBlockEntity.canPlaceItemInContainer(to, stack, slot, side)) {
|
||||||
|
boolean flag = false;
|
||||||
|
- boolean flag1 = to.isEmpty();
|
||||||
|
+ boolean flag1 = to.isCompletelyEmpty(side); // Gale - Airplane - improve container checking with a bitset
|
||||||
|
|
||||||
|
if (itemstack1.isEmpty()) {
|
||||||
|
// Spigot start - SPIGOT-6693, InventorySubcontainer#setItem
|
||||||
|
@@ -921,7 +947,10 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setItems(NonNullList<ItemStack> inventory) {
|
||||||
|
- this.items = inventory;
|
||||||
|
+ // Gale start - Airplane - improve container checking with a bitset
|
||||||
|
+ this.optimizedItems = gg.airplane.structs.ItemListWithBitset.fromList(inventory);
|
||||||
|
+ this.items = this.optimizedItems.nonNullList;
|
||||||
|
+ // Gale end - Airplane - improve container checking with a bitset
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void entityInside(Level world, BlockPos pos, BlockState state, Entity entity, HopperBlockEntity blockEntity) {
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Wed, 23 Nov 2022 22:41:54 +0100
|
||||||
|
Subject: [PATCH] Inline level height
|
||||||
|
|
||||||
|
Removed since 1.21.3, replaced by Moonrise optimisation
|
||||||
|
|
||||||
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
This patch is based on the following patch:
|
||||||
|
"Ensure level height is inlined"
|
||||||
|
By: Paul Sauve <paul@technove.co>
|
||||||
|
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||||
|
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
|
||||||
|
* Airplane copyright *
|
||||||
|
|
||||||
|
Airplane
|
||||||
|
Copyright (C) 2020 Technove LLC
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) 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 General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||||
|
index abebc41e69a41cbf940ffd10dae4815202b525dc..a48b1639ffa83ae2d1e614d32a339f08366da57c 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||||
|
@@ -685,6 +685,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||||
|
}
|
||||||
|
// Paper end - optimise random ticking
|
||||||
|
|
||||||
|
+ // Gale start - Airplane - inline level height
|
||||||
|
+ private final int minBuildHeight, levelHeightAccessorMinSection, height, maxBuildHeight, levelHeightAccessorMaxSection;
|
||||||
|
+ @Override public final int getMaxBuildHeight() { return this.maxBuildHeight; }
|
||||||
|
+ @Override public final int getMinSection() { return this.levelHeightAccessorMinSection; }
|
||||||
|
+ @Override public final int getMaxSection() { return this.levelHeightAccessorMaxSection; }
|
||||||
|
+ @Override public final int getMinBuildHeight() { return this.minBuildHeight; }
|
||||||
|
+ @Override public final int getHeight() { return this.height; }
|
||||||
|
+ // Gale end - Airplane - inline level height
|
||||||
|
+
|
||||||
|
protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, RegistryAccess iregistrycustom, Holder<DimensionType> holder, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function<org.spigotmc.SpigotWorldConfig, io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, java.util.function.Function<org.spigotmc.SpigotWorldConfig, GaleWorldConfiguration> galeWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - create paper world config & Anti-Xray // Gale - Gale configuration // Gale - Purpur - remove vanilla profiler
|
||||||
|
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot
|
||||||
|
this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config
|
||||||
|
@@ -704,6 +713,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||||
|
this.dimensionTypeRegistration = holder;
|
||||||
|
final DimensionType dimensionmanager = (DimensionType) holder.value();
|
||||||
|
|
||||||
|
+ // Gale start - Airplane - inline level height
|
||||||
|
+ this.minBuildHeight = LevelAccessor.super.getMinBuildHeight();
|
||||||
|
+ this.levelHeightAccessorMinSection = LevelAccessor.super.getMinSection();
|
||||||
|
+ this.height = LevelAccessor.super.getHeight();
|
||||||
|
+ this.maxBuildHeight = LevelAccessor.super.getMaxBuildHeight();
|
||||||
|
+ this.levelHeightAccessorMaxSection = LevelAccessor.super.getMaxSection();
|
||||||
|
+ // Gale end - Airplane - inline level height
|
||||||
|
this.dimension = resourcekey;
|
||||||
|
this.isClientSide = flag;
|
||||||
|
if (dimensionmanager.coordinateScale() != 1.0D) {
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Wed, 23 Nov 2022 22:53:39 +0100
|
||||||
|
Subject: [PATCH] Remove streams and iterators from range check
|
||||||
|
|
||||||
|
Removed since 1.21.3, replaced by Moonrise optimisation
|
||||||
|
|
||||||
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
This patch is based on the following patch:
|
||||||
|
"Remove streams and iterators from range check"
|
||||||
|
By: Paul Sauve <paul@technove.co>
|
||||||
|
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||||
|
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
|
||||||
|
* Airplane copyright *
|
||||||
|
|
||||||
|
Airplane
|
||||||
|
Copyright (C) 2020 Technove LLC
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) 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 General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||||
|
index 62bd7523e0d7d2dfdce1ee9edb2249c755f1ade3..a9b6f3ceb45ecd6bcc6d6acc097a5d12aeaae620 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||||
|
@@ -1275,8 +1275,30 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||||
|
return ChunkMap.this.level.getServer().getScaledTrackingDistance(initialDistance);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Gale start - Airplane - remove streams and iterators from range check
|
||||||
|
+ private static int getHighestRange(Entity parent, int highest) {
|
||||||
|
+ List<Entity> passengers = parent.getPassengers();
|
||||||
|
+
|
||||||
|
+ for (int i = 0, size = passengers.size(); i < size; i++) {
|
||||||
|
+ Entity entity = passengers.get(i);
|
||||||
|
+ int range = entity.getType().clientTrackingRange() * 16;
|
||||||
|
+ range = org.spigotmc.TrackingRange.getEntityTrackingRange(entity, range); // Paper
|
||||||
|
+
|
||||||
|
+ if (range > highest) { // Paper - we need the lowest range thanks to the fact that our tracker doesn't account for passenger logic // Tuinity - not anymore!
|
||||||
|
+ highest = range;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ highest = getHighestRange(entity, highest);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return highest;
|
||||||
|
+ }
|
||||||
|
+ // Gale end - Airplane - remove streams and iterators from range check
|
||||||
|
+
|
||||||
|
private int getEffectiveRange() {
|
||||||
|
int i = this.range;
|
||||||
|
+ // Gale start - Airplane - remove streams and iterators from range check
|
||||||
|
+ /*
|
||||||
|
Iterator iterator = this.entity.getIndirectPassengers().iterator();
|
||||||
|
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
@@ -1288,6 +1310,9 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||||
|
i = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+ */
|
||||||
|
+ i = getHighestRange(this.entity, i);
|
||||||
|
+ // Gale end - Airplane - remove streams and iterators from range check
|
||||||
|
|
||||||
|
return this.scaledRange(i);
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Wed, 23 Nov 2022 22:49:59 +0100
|
||||||
|
Subject: [PATCH] Use ThreadUnsafeRandom for mob spawning
|
||||||
|
|
||||||
|
Removed since 1.21
|
||||||
|
|
||||||
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
This patch is based on the following patch:
|
||||||
|
"Use thread unsafe random for mob spawning"
|
||||||
|
By: Paul Sauve <paul@technove.co>
|
||||||
|
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||||
|
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
|
||||||
|
* Airplane copyright *
|
||||||
|
|
||||||
|
Airplane
|
||||||
|
Copyright (C) 2020 Technove LLC
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) 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 General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
||||||
|
index 7e707fe1d800debf1eef8800fe98eb4e1dbd800b..d0383cef6e204cc806903666d296287e1c530ed3 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
||||||
|
@@ -406,13 +406,14 @@ public final class NaturalSpawner {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- private static BlockPos getRandomPosWithin(Level world, LevelChunk chunk) {
|
||||||
|
+ private static BlockPos getRandomPosWithin(ServerLevel world, LevelChunk chunk) { // Gale - Airplane - Use ThreadUnsafeRandom for mob spawning - accept ServerLevel
|
||||||
|
ChunkPos chunkcoordintpair = chunk.getPos();
|
||||||
|
- int i = chunkcoordintpair.getMinBlockX() + world.random.nextInt(16);
|
||||||
|
- int j = chunkcoordintpair.getMinBlockZ() + world.random.nextInt(16);
|
||||||
|
+ // Gale start - Airplane - Use ThreadUnsafeRandom for mob spawning - use ThreadUnsafeRandom
|
||||||
|
+ int i = chunkcoordintpair.getMinBlockX() + world.randomTickRandom.nextInt(16);
|
||||||
|
+ int j = chunkcoordintpair.getMinBlockZ() + world.randomTickRandom.nextInt(16);
|
||||||
|
+ // Gale end - Airplane - Use ThreadUnsafeRandom for mob spawning - use ThreadUnsafeRandom
|
||||||
|
int k = chunk.getHeight(Heightmap.Types.WORLD_SURFACE, i, j) + 1;
|
||||||
|
- int l = Mth.randomBetweenInclusive(world.random, world.getMinBuildHeight(), k);
|
||||||
|
-
|
||||||
|
+ int l = Mth.randomBetweenInclusive(world.randomTickRandom, world.getMinBuildHeight(), k); // Gale - Airplane - Use ThreadUnsafeRandom for mob spawning - use ThreadUnsafeRandom
|
||||||
|
return new BlockPos(i, l, j);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Fri, 23 Dec 2022 15:40:22 +0100
|
||||||
|
Subject: [PATCH] Fix MC-31819
|
||||||
|
|
||||||
|
Removed since Gale 1.21.3, Mojang fixed it in 1.21 24w21a
|
||||||
|
|
||||||
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
This patch is based on the following patch:
|
||||||
|
"Fix hunger saturation depleting on peaceful"
|
||||||
|
By: etil2jz <81570777+etil2jz@users.noreply.github.com>
|
||||||
|
As part of: Mirai (https://github.com/etil2jz/Mirai)
|
||||||
|
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
|
||||||
|
* Mirai description *
|
||||||
|
|
||||||
|
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. See 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 61d412c4f1ebd55661cc3f0260468e3ac0efe0bb..7dc22be7e2afeafe0292648a9a20422c39833966 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||||
|
@@ -1853,6 +1853,11 @@ public abstract class Player extends LivingEntity {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void causeFoodExhaustion(float f, EntityExhaustionEvent.ExhaustionReason reason) {
|
||||||
|
+ // Gale start - Mirai - fix MC-31819
|
||||||
|
+ if (this.level().galeConfig().gameplayMechanics.fixes.mc31819 && this.level().getDifficulty() == Difficulty.PEACEFUL) {
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ // Gale end - Mirai - fix MC-31819
|
||||||
|
// CraftBukkit end
|
||||||
|
if (!this.abilities.invulnerable) {
|
||||||
|
if (!this.level().isClientSide) {
|
||||||
|
diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||||
|
index 266079aed0610e0fa9e35da81680b7f388a8844a..e3e4459da020a85a66360e761adbf6e55920c6c5 100644
|
||||||
|
--- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||||
|
+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||||
|
@@ -116,6 +116,11 @@ public class GaleWorldConfiguration extends ConfigurationPart {
|
||||||
|
public boolean mc110386 = true;
|
||||||
|
// Gale end - Mirai - fix MC-110386
|
||||||
|
|
||||||
|
+ // Gale start - Mirai - fix MC-31819
|
||||||
|
+ @Setting("mc-31819")
|
||||||
|
+ public boolean mc31819 = true;
|
||||||
|
+ // Gale end - Mirai - fix MC-31819
|
||||||
|
+
|
||||||
|
}
|
||||||
|
|
||||||
|
public double entityWakeUpDurationRatioStandardDeviation = 0.2; // Gale - variable entity wake-up duration
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Fri, 23 Dec 2022 16:42:04 +0100
|
||||||
|
Subject: [PATCH] Fix MC-26304
|
||||||
|
|
||||||
|
Removed since Gale 1.21.3, Mojang fixed it in 1.21 24w19a
|
||||||
|
|
||||||
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
This patch is based on the following patch:
|
||||||
|
"Fix brewing stands resetting their brewTime when being unloaded"
|
||||||
|
By: etil2jz <81570777+etil2jz@users.noreply.github.com>
|
||||||
|
As part of: Mirai (https://github.com/etil2jz/Mirai)
|
||||||
|
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java
|
||||||
|
index 02fc9ce21c7d367055da350d21be4870d4242f3a..cd64464f68311f61b687257fe5fdacec98e0146d 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java
|
||||||
|
@@ -48,6 +48,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements
|
||||||
|
public static final int DATA_BREW_TIME = 0;
|
||||||
|
public static final int DATA_FUEL_USES = 1;
|
||||||
|
public static final int NUM_DATA_VALUES = 2;
|
||||||
|
+ private static final String[] INGREDIENT_NBT_KEYS = {"Gale.Ingredient", "Mirai.ingredient"}; // Gale - Mirai - fix MC-26304
|
||||||
|
private NonNullList<ItemStack> items;
|
||||||
|
public int brewTime;
|
||||||
|
public int recipeBrewTime = 400; // Paper - Add recipeBrewTime
|
||||||
|
@@ -314,6 +315,25 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements
|
||||||
|
}
|
||||||
|
|
||||||
|
this.fuel = nbt.getByte("Fuel");
|
||||||
|
+ // Gale start - Mirai - fix MC-26304
|
||||||
|
+ if (this.ingredient == null || this.ingredient == Items.AIR) {
|
||||||
|
+ for (String nbtKey : INGREDIENT_NBT_KEYS) {
|
||||||
|
+ try {
|
||||||
|
+ if (nbt.contains(nbtKey)) {
|
||||||
|
+ java.util.Optional<net.minecraft.core.Holder.Reference<Item>> opt = net.minecraft.core.registries.BuiltInRegistries.ITEM.get(net.minecraft.resources.ResourceLocation.parse(nbt.getString(nbtKey)));
|
||||||
|
+ if (opt.isPresent()) {
|
||||||
|
+ this.ingredient = opt.get().value();
|
||||||
|
+ if (this.ingredient != null && this.ingredient != Items.AIR) {
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ } catch (Throwable ignored) {
|
||||||
|
+ // Cannot be helped
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ // Gale end - Mirai - fix MC-26304
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@@ -322,6 +342,18 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements
|
||||||
|
nbt.putShort("BrewTime", (short) this.brewTime);
|
||||||
|
ContainerHelper.saveAllItems(nbt, this.items, registries);
|
||||||
|
nbt.putByte("Fuel", (byte) this.fuel);
|
||||||
|
+ // Gale start - Mirai - fix MC-26304
|
||||||
|
+ if (this.ingredient != null && this.ingredient != Items.AIR) {
|
||||||
|
+ try {
|
||||||
|
+ String value = net.minecraft.core.registries.BuiltInRegistries.ITEM.getKey(this.ingredient).toString();
|
||||||
|
+ for (String nbtKey : INGREDIENT_NBT_KEYS) {
|
||||||
|
+ nbt.putString(nbtKey, value);
|
||||||
|
+ }
|
||||||
|
+ } catch (Throwable ignored) {
|
||||||
|
+ // Cannot be helped
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ // Gale end - Mirai - fix MC-26304
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Wed, 30 Nov 2022 21:15:33 +0100
|
||||||
|
Subject: [PATCH] Avoid Class#isAssignableFrom call in ClassInstanceMultiMap
|
||||||
|
|
||||||
|
Removed since 1.21.1, replaced by VMP optimization
|
||||||
|
|
||||||
|
License: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
This patch is based on the following mixin:
|
||||||
|
"me/jellysquid/mods/lithium/mixin/collections/entity_filtering/TypeFilterableListMixin.java"
|
||||||
|
By: Angeline <jellysquid3@users.noreply.github.com>
|
||||||
|
As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric)
|
||||||
|
Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java b/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java
|
||||||
|
index 4264b3a69b5cbe2e56058927ceb5409389cecf4b..1cdff53d2c39d785b3b3306eef27649a4b092e52 100644
|
||||||
|
--- a/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java
|
||||||
|
+++ b/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java
|
||||||
|
@@ -56,13 +56,33 @@ public class ClassInstanceMultiMap<T> extends AbstractCollection<T> {
|
||||||
|
}
|
||||||
|
|
||||||
|
public <S> Collection<S> find(Class<S> type) {
|
||||||
|
- if (!this.baseClass.isAssignableFrom(type)) {
|
||||||
|
- throw new IllegalArgumentException("Don't know how to search for " + type);
|
||||||
|
- } else {
|
||||||
|
- List<? extends T> list = this.byClass
|
||||||
|
- .computeIfAbsent(type, typeClass -> this.allInstances.stream().filter(typeClass::isInstance).collect(Util.toMutableList()));
|
||||||
|
- return (Collection<S>)Collections.unmodifiableCollection(list);
|
||||||
|
+ // Gale start - Lithium - avoid Class#isAssignableFrom call in ClassInstanceMultiMap
|
||||||
|
+ /*
|
||||||
|
+ Only perform the slow Class#isAssignableFrom(Class) if a list doesn't exist for the type, otherwise
|
||||||
|
+ we can assume it's already valid. The slow-path code is moved to a separate method to help the JVM inline this.
|
||||||
|
+ */
|
||||||
|
+ Collection<T> collection = this.byClass.get(type);
|
||||||
|
+
|
||||||
|
+ if (collection == null) {
|
||||||
|
+ collection = this.createAllOfType(type);
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ return (Collection<S>) Collections.unmodifiableCollection(collection);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private <S> Collection<T> createAllOfType(Class<S> type) {
|
||||||
|
+ List<T> list = new java.util.ArrayList<>(1);
|
||||||
|
+
|
||||||
|
+ for (T allElement : this.allInstances) {
|
||||||
|
+ if (type.isInstance(allElement)) {
|
||||||
|
+ list.add(allElement);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ this.byClass.put(type, list);
|
||||||
|
+
|
||||||
|
+ return list;
|
||||||
|
+ // Gale end - Lithium - avoid Class#isAssignableFrom call in ClassInstanceMultiMap
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Tue, 29 Nov 2022 21:30:27 +0100
|
||||||
|
Subject: [PATCH] End gateway should check if entity can use portal
|
||||||
|
|
||||||
|
Removed since 1.21
|
||||||
|
|
||||||
|
License: MIT (https://opensource.org/licenses/MIT)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
This patch is based on the following patch:
|
||||||
|
"End gateway should check if entity can use portal"
|
||||||
|
By: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||||
|
As part of: Purpur (https://github.com/PurpurMC/Purpur)
|
||||||
|
Licensed under: MIT (https://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
* Purpur copyright *
|
||||||
|
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2019-2022 PurpurMC
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java
|
||||||
|
index 93bd70c1dc2ba8b893a6087730071c81fb1132f4..a39409ba38b28d160aa1abe70a1dd1c5a633c08d 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java
|
||||||
|
@@ -167,6 +167,7 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity {
|
||||||
|
|
||||||
|
public static void teleportEntity(Level world, BlockPos pos, BlockState state, Entity entity, TheEndGatewayBlockEntity blockEntity) {
|
||||||
|
if (world instanceof ServerLevel worldserver && !blockEntity.isCoolingDown()) {
|
||||||
|
+ if (entity.level().galeConfig().gameplayMechanics.fixes.checkCanChangeDimensionsBeforeUseEndGateway && world.galeConfig().gameplayMechanics.fixes.checkCanChangeDimensionsBeforeUseEndGateway && !entity.canChangeDimensions()) return; // Gale - Purpur - end gateway should check if entity can use portal
|
||||||
|
blockEntity.teleportCooldown = 100;
|
||||||
|
BlockPos blockposition1;
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||||
|
index 7f9c5012defeac5ae558e46d8fca6889fb1d0872..56bf02a1f9741fc1c05ede0c0c79fea97d46271b 100644
|
||||||
|
--- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||||
|
+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||||
|
@@ -100,6 +100,7 @@ public class GaleWorldConfiguration extends ConfigurationPart {
|
||||||
|
public class Fixes extends ConfigurationPart {
|
||||||
|
|
||||||
|
public boolean keepMooshroomRotationAfterShearing = true; // Gale - Purpur - fix cow rotation when shearing mooshroom
|
||||||
|
+ public boolean checkCanChangeDimensionsBeforeUseEndGateway = false; // Gale - Purpur - end gateway should check if entity can use portal
|
||||||
|
|
||||||
|
// Gale start - Purpur - fix MC-238526
|
||||||
|
@Setting("mc-238526")
|
||||||
@@ -0,0 +1,305 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Sun, 25 Dec 2022 11:20:37 +0100
|
||||||
|
Subject: [PATCH] Optimize villager data storage
|
||||||
|
|
||||||
|
Removed since Gale 1.21.1, imcompatible with RealisticVillagers
|
||||||
|
|
||||||
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/Container.java b/src/main/java/net/minecraft/world/Container.java
|
||||||
|
index 5db5ba026462ca642dcee718af732f80fadabef5..cd380ceb40d38acc7eef289ded11259388becabd 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/Container.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/Container.java
|
||||||
|
@@ -71,6 +71,20 @@ public interface Container extends Clearable {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Gale start - optimize villager data storage
|
||||||
|
+ default boolean hasAnyOf(Item[] items) {
|
||||||
|
+ for (int i = 0; i < this.getContainerSize(); ++i) {
|
||||||
|
+ ItemStack itemstack = this.getItem(i);
|
||||||
|
+ for (Item item : items) {
|
||||||
|
+ if (itemstack.is(item)) {
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+ // Gale end - optimize villager data storage
|
||||||
|
+
|
||||||
|
default boolean hasAnyMatching(Predicate<ItemStack> predicate) {
|
||||||
|
for (int i = 0; i < this.getContainerSize(); ++i) {
|
||||||
|
ItemStack itemstack = this.getItem(i);
|
||||||
|
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 8508ac7de8cda3127b73e11ff4aee62502e65ead..90ae43979e05839d676ab51feb489955ecbee50e 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
|
||||||
|
@@ -17,7 +17,10 @@ import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.Items;
|
||||||
|
|
||||||
|
public class TradeWithVillager extends Behavior<Villager> {
|
||||||
|
- private Set<Item> trades = ImmutableSet.of();
|
||||||
|
+ // Gale start - optimize villager data storage
|
||||||
|
+ private static final Item[] WHEAT_SINGLETON_ARRAY = {Items.WHEAT};
|
||||||
|
+ private @org.jetbrains.annotations.NotNull Item @org.jetbrains.annotations.Nullable [] trades = null;
|
||||||
|
+ // Gale end - optimize villager data storage
|
||||||
|
|
||||||
|
public TradeWithVillager() {
|
||||||
|
super(
|
||||||
|
@@ -51,16 +54,18 @@ public class TradeWithVillager extends Behavior<Villager> {
|
||||||
|
BehaviorUtils.lockGazeAndWalkToEachOther(entity, villager, 0.5F, 2);
|
||||||
|
entity.gossip(world, villager, time);
|
||||||
|
if (entity.hasExcessFood() && (entity.getVillagerData().getProfession() == VillagerProfession.FARMER || villager.wantsMoreFood())) {
|
||||||
|
- throwHalfStack(entity, Villager.FOOD_POINTS.keySet(), villager);
|
||||||
|
+ throwHalfStack(entity, Villager.FOOD_POINTS_KEY_ARRAY, villager); // Gale - optimize villager data storage
|
||||||
|
}
|
||||||
|
|
||||||
|
if (villager.getVillagerData().getProfession() == VillagerProfession.FARMER
|
||||||
|
&& entity.getInventory().countItem(Items.WHEAT) > Items.WHEAT.getDefaultMaxStackSize() / 2) {
|
||||||
|
- throwHalfStack(entity, ImmutableSet.of(Items.WHEAT), villager);
|
||||||
|
+ throwHalfStack(entity, WHEAT_SINGLETON_ARRAY, villager); // Gale - optimize villager data storage
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (!this.trades.isEmpty() && entity.getInventory().hasAnyOf(this.trades)) {
|
||||||
|
+ // Gale start - optimize villager data storage
|
||||||
|
+ if (this.trades != null && entity.getInventory().hasAnyOf(this.trades)) {
|
||||||
|
throwHalfStack(entity, this.trades, villager);
|
||||||
|
+ // Gale end - optimize villager data storage
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -70,13 +75,36 @@ public class TradeWithVillager extends Behavior<Villager> {
|
||||||
|
villager.getBrain().eraseMemory(MemoryModuleType.INTERACTION_TARGET);
|
||||||
|
}
|
||||||
|
|
||||||
|
- private static Set<Item> figureOutWhatIAmWillingToTrade(Villager entity, Villager target) {
|
||||||
|
- ImmutableSet<Item> immutableSet = target.getVillagerData().getProfession().requestedItems();
|
||||||
|
- ImmutableSet<Item> immutableSet2 = entity.getVillagerData().getProfession().requestedItems();
|
||||||
|
- return immutableSet.stream().filter(item -> !immutableSet2.contains(item)).collect(Collectors.toSet());
|
||||||
|
+ // Gale start - optimize villager data storage
|
||||||
|
+ private static @org.jetbrains.annotations.NotNull Item @org.jetbrains.annotations.Nullable [] figureOutWhatIAmWillingToTrade(Villager entity, Villager target) {
|
||||||
|
+ @org.jetbrains.annotations.NotNull Item @org.jetbrains.annotations.Nullable [] immutableSet = target.getVillagerData().getProfession().requestedItems();
|
||||||
|
+ if (immutableSet == null) {
|
||||||
|
+ return null;
|
||||||
|
+ }
|
||||||
|
+ @org.jetbrains.annotations.NotNull Item @org.jetbrains.annotations.Nullable [] immutableSet2 = entity.getVillagerData().getProfession().requestedItems();
|
||||||
|
+ if (immutableSet2 == null) {
|
||||||
|
+ return immutableSet;
|
||||||
|
+ }
|
||||||
|
+ if (immutableSet == immutableSet2) {
|
||||||
|
+ return null;
|
||||||
|
+ }
|
||||||
|
+ Item[] willingToTrade = new Item[immutableSet.length];
|
||||||
|
+ int willingToTradeSize = 0;
|
||||||
|
+ forImmutableSet:
|
||||||
|
+ for (Item item : immutableSet) {
|
||||||
|
+ for (Item item2 : immutableSet2) {
|
||||||
|
+ if (item == item2) {
|
||||||
|
+ continue forImmutableSet;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ willingToTrade[willingToTradeSize] = item;
|
||||||
|
+ willingToTradeSize++;
|
||||||
|
+ }
|
||||||
|
+ return java.util.Arrays.copyOf(willingToTrade, willingToTradeSize);
|
||||||
|
+ // Gale end - optimize villager data storage
|
||||||
|
}
|
||||||
|
|
||||||
|
- private static void throwHalfStack(Villager villager, Set<Item> validItems, LivingEntity target) {
|
||||||
|
+ private static void throwHalfStack(Villager villager, @org.jetbrains.annotations.NotNull Item @org.jetbrains.annotations.NotNull [] validItems, LivingEntity target) { // Gale - optimize villager data storage
|
||||||
|
SimpleContainer simpleContainer = villager.getInventory();
|
||||||
|
ItemStack itemStack = ItemStack.EMPTY;
|
||||||
|
int i = 0;
|
||||||
|
@@ -89,7 +117,16 @@ public class TradeWithVillager extends Behavior<Villager> {
|
||||||
|
itemStack2 = simpleContainer.getItem(i);
|
||||||
|
if (!itemStack2.isEmpty()) {
|
||||||
|
item = itemStack2.getItem();
|
||||||
|
- if (validItems.contains(item)) {
|
||||||
|
+ // Gale start - optimize villager data storage
|
||||||
|
+ boolean inValidItems = false;
|
||||||
|
+ for (Item validItem : validItems) {
|
||||||
|
+ if (validItem == item) {
|
||||||
|
+ inValidItems = true;
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ if (inValidItems) {
|
||||||
|
+ // Gale end - optimize villager data storage
|
||||||
|
if (itemStack2.getCount() > itemStack2.getMaxStackSize() / 2) {
|
||||||
|
j = itemStack2.getCount() / 2;
|
||||||
|
break label28;
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java
|
||||||
|
index 1595568f3140a62b0f2236644ac2da11db12af05..8bed5992f639f805ccdec56a90101004570dc265 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java
|
||||||
|
@@ -24,21 +24,26 @@ public class SecondaryPoiSensor extends Sensor<Villager> {
|
||||||
|
protected void doTick(ServerLevel world, Villager entity) {
|
||||||
|
// Gale start - Lithium - skip secondary POI sensor if absent
|
||||||
|
var secondaryPoi = entity.getVillagerData().getProfession().secondaryPoi();
|
||||||
|
- if (secondaryPoi.isEmpty()) {
|
||||||
|
+ if (secondaryPoi == null) { // Gale - optimize villager data storage
|
||||||
|
entity.getBrain().eraseMemory(MemoryModuleType.SECONDARY_JOB_SITE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Gale end - Lithium - skip secondary POI sensor if absent
|
||||||
|
ResourceKey<Level> resourceKey = world.dimension();
|
||||||
|
BlockPos blockPos = entity.blockPosition();
|
||||||
|
- List<GlobalPos> list = Lists.newArrayList();
|
||||||
|
+ @org.jetbrains.annotations.Nullable java.util.ArrayList<GlobalPos> list = null; // Gale - optimize villager data storage
|
||||||
|
int i = 4;
|
||||||
|
|
||||||
|
for (int j = -4; j <= 4; j++) {
|
||||||
|
for (int k = -2; k <= 2; k++) {
|
||||||
|
for (int l = -4; l <= 4; l++) {
|
||||||
|
BlockPos blockPos2 = blockPos.offset(j, k, l);
|
||||||
|
- if (entity.getVillagerData().getProfession().secondaryPoi().contains(world.getBlockState(blockPos2).getBlock())) {
|
||||||
|
+ // Gale start - optimize villager data storage
|
||||||
|
+ if (secondaryPoi == world.getBlockState(blockPos2).getBlock()) {
|
||||||
|
+ if (list == null) {
|
||||||
|
+ list = Lists.newArrayList();
|
||||||
|
+ }
|
||||||
|
+ // Gale end - optimize villager data storage
|
||||||
|
list.add(GlobalPos.of(resourceKey, blockPos2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -46,7 +51,10 @@ public class SecondaryPoiSensor extends Sensor<Villager> {
|
||||||
|
}
|
||||||
|
|
||||||
|
Brain<?> brain = entity.getBrain();
|
||||||
|
- if (!list.isEmpty()) {
|
||||||
|
+ // Gale start - optimize villager data storage
|
||||||
|
+ if (list != null) {
|
||||||
|
+ list.trimToSize();
|
||||||
|
+ // Gale end - optimize villager data storage
|
||||||
|
brain.setMemory(MemoryModuleType.SECONDARY_JOB_SITE, list);
|
||||||
|
} else {
|
||||||
|
brain.eraseMemory(MemoryModuleType.SECONDARY_JOB_SITE);
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
||||||
|
index 08c780e9e1e167b84f70dce691bb564c8420b286..de542de264d2a4ffa84699c34d3c576578c3d2a5 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
||||||
|
@@ -105,7 +105,9 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||||
|
private static final EntityDataAccessor<VillagerData> DATA_VILLAGER_DATA = SynchedEntityData.defineId(Villager.class, EntityDataSerializers.VILLAGER_DATA);
|
||||||
|
public static final int BREEDING_FOOD_THRESHOLD = 12;
|
||||||
|
public static final Map<Item, Integer> FOOD_POINTS = ImmutableMap.of(Items.BREAD, 4, Items.POTATO, 1, Items.CARROT, 1, Items.BEETROOT, 1);
|
||||||
|
+ public static final Item[] FOOD_POINTS_KEY_ARRAY = FOOD_POINTS.keySet().toArray(Item[]::new); // Gale - optimize villager data storage
|
||||||
|
private static final int TRADES_PER_LEVEL = 2;
|
||||||
|
+ private static final Item[] WANTED_ITEMS = {Items.WHEAT_SEEDS, Items.POTATO, Items.CARROT, Items.BEETROOT_SEEDS, Items.TORCHFLOWER_SEEDS, Items.PITCHER_POD, Items.BREAD, Items.WHEAT, Items.BEETROOT}; // Gale - optimize villager data storage
|
||||||
|
private static final int MAX_GOSSIP_TOPICS = 10;
|
||||||
|
private static final int GOSSIP_COOLDOWN = 1200;
|
||||||
|
private static final int GOSSIP_DECAY_INTERVAL = 24000;
|
||||||
|
@@ -878,7 +880,30 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||||
|
public boolean wantsToPickUp(ServerLevel world, ItemStack stack) {
|
||||||
|
Item item = stack.getItem();
|
||||||
|
|
||||||
|
- return (stack.is(ItemTags.VILLAGER_PICKS_UP) || this.getVillagerData().getProfession().requestedItems().contains(item)) && this.getInventory().canAddItem(stack);
|
||||||
|
+ // Gale start - optimize villager data storage
|
||||||
|
+ boolean isDesired = false;
|
||||||
|
+ // WANTED_ITEMS same with the items in itemTag ItemTags.VILLAGER_PICKS_UP + ItemTags.VILLAGER_PLANTABLE_SEEDS
|
||||||
|
+ // Also Equal to `stack.is(ItemTags.VILLAGER_PICKS_UP)`
|
||||||
|
+ for (Item wantedItem : WANTED_ITEMS) {
|
||||||
|
+ if (wantedItem == item) {
|
||||||
|
+ isDesired = true;
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ if (!isDesired) {
|
||||||
|
+ var requestedItems = this.getVillagerData().getProfession().requestedItems();
|
||||||
|
+ if (requestedItems == null) {
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+ for (Item requestedItem : requestedItems) {
|
||||||
|
+ if (requestedItem == item) {
|
||||||
|
+ isDesired = true;
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ return isDesired && this.getInventory().canAddItem(stack);
|
||||||
|
+ // Gale end - optimize villager data storage
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasExcessFood() {
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/npc/VillagerProfession.java b/src/main/java/net/minecraft/world/entity/npc/VillagerProfession.java
|
||||||
|
index 8734ab1bd8299bbf43906d81a349c2a13e0981a7..35c4638f5c46310c75b27548223fcaf5f8702113 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/npc/VillagerProfession.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/npc/VillagerProfession.java
|
||||||
|
@@ -22,9 +22,9 @@ public record VillagerProfession(
|
||||||
|
String name,
|
||||||
|
Predicate<Holder<PoiType>> heldJobSite,
|
||||||
|
Predicate<Holder<PoiType>> acquirableJobSite,
|
||||||
|
- ImmutableSet<Item> requestedItems,
|
||||||
|
- ImmutableSet<Block> secondaryPoi,
|
||||||
|
- @Nullable SoundEvent workSound
|
||||||
|
+ @org.jetbrains.annotations.NotNull Item @org.jetbrains.annotations.Nullable [] requestedItems, // Gale - optimize villager data storage
|
||||||
|
+ @org.jetbrains.annotations.Nullable Block secondaryPoi, // Gale - optimize villager data storage
|
||||||
|
+ @org.jetbrains.annotations.Nullable SoundEvent workSound // Gale - optimize villager data storage
|
||||||
|
) {
|
||||||
|
public static final Predicate<Holder<PoiType>> ALL_ACQUIRABLE_JOBS = poiType -> poiType.is(PoiTypeTags.ACQUIRABLE_JOB_SITE);
|
||||||
|
public static final VillagerProfession NONE = register("none", PoiType.NONE, ALL_ACQUIRABLE_JOBS, null);
|
||||||
|
@@ -35,8 +35,8 @@ public record VillagerProfession(
|
||||||
|
public static final VillagerProfession FARMER = register(
|
||||||
|
"farmer",
|
||||||
|
PoiTypes.FARMER,
|
||||||
|
- ImmutableSet.of(Items.WHEAT, Items.WHEAT_SEEDS, Items.BEETROOT_SEEDS, Items.BONE_MEAL),
|
||||||
|
- ImmutableSet.of(Blocks.FARMLAND),
|
||||||
|
+ new Item[] {Items.WHEAT, Items.WHEAT_SEEDS, Items.BEETROOT_SEEDS, Items.BONE_MEAL}, // Gale - optimize villager data storage
|
||||||
|
+ Blocks.FARMLAND, // Gale - optimize villager data storage
|
||||||
|
SoundEvents.VILLAGER_WORK_FARMER
|
||||||
|
);
|
||||||
|
public static final VillagerProfession FISHERMAN = register("fisherman", PoiTypes.FISHERMAN, SoundEvents.VILLAGER_WORK_FISHERMAN);
|
||||||
|
@@ -54,38 +54,40 @@ public record VillagerProfession(
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
- private static VillagerProfession register(String id, ResourceKey<PoiType> heldWorkstation, @Nullable SoundEvent workSound) {
|
||||||
|
+ private static VillagerProfession register(String id, ResourceKey<PoiType> heldWorkstation, @org.jetbrains.annotations.Nullable SoundEvent workSound) { // Gale - optimize villager data storage
|
||||||
|
return register(id, entry -> entry.is(heldWorkstation), entry -> entry.is(heldWorkstation), workSound);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Gale start - optimize villager data storage
|
||||||
|
private static VillagerProfession register(
|
||||||
|
- String id, Predicate<Holder<PoiType>> heldWorkstation, Predicate<Holder<PoiType>> acquirableWorkstation, @Nullable SoundEvent workSound
|
||||||
|
+ String id, Predicate<Holder<PoiType>> heldWorkstation, Predicate<Holder<PoiType>> acquirableWorkstation, @org.jetbrains.annotations.Nullable SoundEvent workSound
|
||||||
|
) {
|
||||||
|
- return register(id, heldWorkstation, acquirableWorkstation, ImmutableSet.of(), ImmutableSet.of(), workSound);
|
||||||
|
+ return register(id, heldWorkstation, acquirableWorkstation, null, null, workSound);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static VillagerProfession register(
|
||||||
|
String id,
|
||||||
|
ResourceKey<PoiType> heldWorkstation,
|
||||||
|
- ImmutableSet<Item> gatherableItems,
|
||||||
|
- ImmutableSet<Block> secondaryJobSites,
|
||||||
|
- @Nullable SoundEvent workSound
|
||||||
|
+ @org.jetbrains.annotations.NotNull Item @org.jetbrains.annotations.Nullable [] gatherableItems,
|
||||||
|
+ @org.jetbrains.annotations.Nullable Block secondaryJobSite,
|
||||||
|
+ @org.jetbrains.annotations.Nullable SoundEvent workSound
|
||||||
|
) {
|
||||||
|
- return register(id, entry -> entry.is(heldWorkstation), entry -> entry.is(heldWorkstation), gatherableItems, secondaryJobSites, workSound);
|
||||||
|
+ return register(id, entry -> entry.is(heldWorkstation), entry -> entry.is(heldWorkstation), gatherableItems, secondaryJobSite, workSound);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static VillagerProfession register(
|
||||||
|
String id,
|
||||||
|
Predicate<Holder<PoiType>> heldWorkstation,
|
||||||
|
Predicate<Holder<PoiType>> acquirableWorkstation,
|
||||||
|
- ImmutableSet<Item> gatherableItems,
|
||||||
|
- ImmutableSet<Block> secondaryJobSites,
|
||||||
|
- @Nullable SoundEvent workSound
|
||||||
|
+ @org.jetbrains.annotations.NotNull Item @org.jetbrains.annotations.Nullable [] gatherableItems,
|
||||||
|
+ @org.jetbrains.annotations.Nullable Block secondaryJobSite,
|
||||||
|
+ @org.jetbrains.annotations.Nullable SoundEvent workSound
|
||||||
|
) {
|
||||||
|
return Registry.register(
|
||||||
|
BuiltInRegistries.VILLAGER_PROFESSION,
|
||||||
|
ResourceLocation.withDefaultNamespace(id),
|
||||||
|
- new VillagerProfession(id, heldWorkstation, acquirableWorkstation, gatherableItems, secondaryJobSites, workSound)
|
||||||
|
+ new VillagerProfession(id, heldWorkstation, acquirableWorkstation, gatherableItems != null && gatherableItems.length == 0 ? null : gatherableItems, secondaryJobSite, workSound)
|
||||||
|
);
|
||||||
|
+ // Gale end - optimize villager data storage
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||||
|
Date: Wed, 26 Jun 2024 18:52:28 +0800
|
||||||
|
Subject: [PATCH] Replace shape full block cache with hashtable
|
||||||
|
|
||||||
|
Removed since 1.21
|
||||||
|
|
||||||
|
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/util/collections/Object2BooleanCacheTable.java b/src/main/java/me/jellysquid/mods/lithium/common/util/collections/Object2BooleanCacheTable.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..5e422708ca0a6161892293a49342f78ae671bf9b
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/me/jellysquid/mods/lithium/common/util/collections/Object2BooleanCacheTable.java
|
||||||
|
@@ -0,0 +1,62 @@
|
||||||
|
+// Gale - Lithium - replace shape full block cache with hashtable - cache table utility
|
||||||
|
+
|
||||||
|
+package me.jellysquid.mods.lithium.common.util.collections;
|
||||||
|
+
|
||||||
|
+import it.unimi.dsi.fastutil.HashCommon;
|
||||||
|
+import net.minecraft.util.Mth;
|
||||||
|
+
|
||||||
|
+import java.util.function.Predicate;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * A lossy hashtable implementation that stores a mapping between an object and a boolean.
|
||||||
|
+ * <p>
|
||||||
|
+ * Any hash collisions will result in an overwrite: this is safe because the correct value can always be recomputed,
|
||||||
|
+ * given that the given operator is deterministic.
|
||||||
|
+ * <p>
|
||||||
|
+ * This implementation is safe to use from multiple threads
|
||||||
|
+ */
|
||||||
|
+public final class Object2BooleanCacheTable<T> {
|
||||||
|
+ private final int mask;
|
||||||
|
+
|
||||||
|
+ private final Node<T>[] nodes;
|
||||||
|
+
|
||||||
|
+ private final Predicate<T> operator;
|
||||||
|
+
|
||||||
|
+ @SuppressWarnings("unchecked")
|
||||||
|
+ public Object2BooleanCacheTable(int capacity, Predicate<T> operator) {
|
||||||
|
+ int capacity1 = Mth.smallestEncompassingPowerOfTwo(capacity);
|
||||||
|
+ this.mask = capacity1 - 1;
|
||||||
|
+
|
||||||
|
+ this.nodes = (Node<T>[]) new Node[capacity1];
|
||||||
|
+
|
||||||
|
+ this.operator = operator;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static <T> int hash(T key) {
|
||||||
|
+ return HashCommon.mix(key.hashCode());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public boolean get(T key) {
|
||||||
|
+ int idx = hash(key) & this.mask;
|
||||||
|
+
|
||||||
|
+ Node<T> node = this.nodes[idx];
|
||||||
|
+ if (node != null && key.equals(node.key)) {
|
||||||
|
+ return node.value;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ boolean test = this.operator.test(key);
|
||||||
|
+ this.nodes[idx] = new Node<>(key, test);
|
||||||
|
+
|
||||||
|
+ return test;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ static class Node<T> {
|
||||||
|
+ final T key;
|
||||||
|
+ final boolean value;
|
||||||
|
+
|
||||||
|
+ Node(T key, boolean value) {
|
||||||
|
+ this.key = key;
|
||||||
|
+ this.value = value;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
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 a7108b2be0746aa1f0e574d8c6f5ffad6d369835..3d703b6cb79939367b73b57df3d3ef497589a580 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/block/Block.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/block/Block.java
|
||||||
|
@@ -68,11 +68,12 @@ public class Block extends BlockBehaviour implements ItemLike {
|
||||||
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
private final Holder.Reference<Block> builtInRegistryHolder;
|
||||||
|
public static final IdMapper<BlockState> BLOCK_STATE_REGISTRY = new IdMapper<>();
|
||||||
|
- private static final LoadingCache<VoxelShape, Boolean> SHAPE_FULL_BLOCK_CACHE = CacheBuilder.newBuilder().maximumSize(512L).weakKeys().build(new CacheLoader<VoxelShape, Boolean>() {
|
||||||
|
- public Boolean load(VoxelShape voxelshape) {
|
||||||
|
- return !Shapes.joinIsNotEmpty(Shapes.block(), voxelshape, BooleanOp.NOT_SAME);
|
||||||
|
- }
|
||||||
|
- });
|
||||||
|
+ // Gale start - Lithium - replace shape full block cache with hashtable
|
||||||
|
+ private static final me.jellysquid.mods.lithium.common.util.collections.Object2BooleanCacheTable<VoxelShape> SHAPE_FULL_BLOCK_CACHE = new me.jellysquid.mods.lithium.common.util.collections.Object2BooleanCacheTable<>(
|
||||||
|
+ 512,
|
||||||
|
+ shape -> !Shapes.joinIsNotEmpty(Shapes.block(), shape, BooleanOp.NOT_SAME)
|
||||||
|
+ );
|
||||||
|
+ // Gale end - Lithium - replace shape full block cache with hashtable
|
||||||
|
public static final int UPDATE_NEIGHBORS = 1;
|
||||||
|
public static final int UPDATE_CLIENTS = 2;
|
||||||
|
public static final int UPDATE_INVISIBLE = 4;
|
||||||
|
@@ -280,7 +281,7 @@ public class Block extends BlockBehaviour implements ItemLike {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isShapeFullBlock(VoxelShape shape) {
|
||||||
|
- return ((ca.spottedleaf.moonrise.patches.collisions.shape.CollisionVoxelShape)shape).moonrise$isFullBlock(); // Paper - optimise collisions
|
||||||
|
+ return SHAPE_FULL_BLOCK_CACHE.get(shape); // Gale - Lithium - replace shape full block cache with hashtable
|
||||||
|
}
|
||||||
|
|
||||||
|
public void animateTick(BlockState state, Level world, BlockPos pos, RandomSource random) {}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Wed, 30 Nov 2022 13:49:11 +0100
|
||||||
|
Subject: [PATCH] Replace AI goal set with optimized collection
|
||||||
|
|
||||||
|
Removed since 1.20.5
|
||||||
|
|
||||||
|
License: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
This patch is based on the following mixin:
|
||||||
|
"me/jellysquid/mods/lithium/mixin/collections/goals/GoalSelectorMixin.java"
|
||||||
|
By: 2No2Name <2No2Name@web.de>
|
||||||
|
As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric)
|
||||||
|
Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
||||||
|
|
||||||
|
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 91d1088dbf1c0cfb3694d37b4e491e601507421c..fc16161d352221be549760dcdd8c62dfba6a6798 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
|
||||||
|
@@ -12,6 +12,8 @@ import java.util.Map.Entry;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
+
|
||||||
|
+import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
public class GoalSelector {
|
||||||
|
@@ -28,7 +30,7 @@ public class GoalSelector {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
private final Map<Goal.Flag, WrappedGoal> lockedFlags = new EnumMap<>(Goal.Flag.class);
|
||||||
|
- private final Set<WrappedGoal> availableGoals = Sets.newLinkedHashSet();
|
||||||
|
+ private final Set<WrappedGoal> availableGoals = new ObjectLinkedOpenHashSet<>(); // Gale - Lithium - replace AI goal set with optimized collection
|
||||||
|
private final EnumSet<Goal.Flag> 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<net.minecraft.world.entity.ai.goal.Goal.Flag> goalTypes = new com.destroystokyo.paper.util.set.OptimizedSmallEnumSet<>(Goal.Flag.class); // Paper - remove streams from pathfindergoalselector
|
||||||
|
private int tickCount;
|
||||||
@@ -0,0 +1,194 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Thu, 1 Dec 2022 14:33:06 +0100
|
||||||
|
Subject: [PATCH] Optimize world generation chunk and block access
|
||||||
|
|
||||||
|
Removed since 1.21
|
||||||
|
|
||||||
|
License: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
This patch is based on the following mixins and classes:
|
||||||
|
* "me/jellysquid/mods/lithium/common/util/Pos.java"
|
||||||
|
* "me/jellysquid/mods/lithium/mixin/gen/chunk_region/ChunkRegionMixin.java"
|
||||||
|
By: SuperCoder7979 <k.pranav@gmail.com>, 2No2Name <2No2Name@web.de>
|
||||||
|
As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric)
|
||||||
|
Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
||||||
|
|
||||||
|
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/util/Pos.java b/src/main/java/me/jellysquid/mods/lithium/common/util/Pos.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..f2f10b651e4fbecdd1ea1bc28ebf40d685a67cee
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/me/jellysquid/mods/lithium/common/util/Pos.java
|
||||||
|
@@ -0,0 +1,95 @@
|
||||||
|
+// Gale - Lithium - position utility
|
||||||
|
+
|
||||||
|
+package me.jellysquid.mods.lithium.common.util;
|
||||||
|
+
|
||||||
|
+import net.minecraft.core.SectionPos;
|
||||||
|
+import net.minecraft.world.level.LevelHeightAccessor;
|
||||||
|
+
|
||||||
|
+public class Pos {
|
||||||
|
+
|
||||||
|
+ public static class BlockCoord {
|
||||||
|
+ public static int getYSize(LevelHeightAccessor view) {
|
||||||
|
+ return view.getHeight();
|
||||||
|
+ }
|
||||||
|
+ public static int getMinY(LevelHeightAccessor view) {
|
||||||
|
+ return view.getMinBuildHeight();
|
||||||
|
+ }
|
||||||
|
+ public static int getMaxYInclusive(LevelHeightAccessor view) {
|
||||||
|
+ return view.getMaxBuildHeight() - 1;
|
||||||
|
+ }
|
||||||
|
+ public static int getMaxYExclusive(LevelHeightAccessor view) {
|
||||||
|
+ return view.getMaxBuildHeight();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static int getMaxInSectionCoord(int sectionCoord) {
|
||||||
|
+ return 15 + getMinInSectionCoord(sectionCoord);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static int getMaxYInSectionIndex(LevelHeightAccessor view, int sectionIndex){
|
||||||
|
+ return getMaxInSectionCoord(SectionYCoord.fromSectionIndex(view, sectionIndex));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static int getMinInSectionCoord(int sectionCoord) {
|
||||||
|
+ return SectionPos.sectionToBlockCoord(sectionCoord);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static int getMinYInSectionIndex(LevelHeightAccessor view, int sectionIndex) {
|
||||||
|
+ return getMinInSectionCoord(SectionYCoord.fromSectionIndex(view, sectionIndex));
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static class ChunkCoord {
|
||||||
|
+ public static int fromBlockCoord(int blockCoord) {
|
||||||
|
+ return SectionPos.blockToSectionCoord(blockCoord);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static int fromBlockSize(int i) {
|
||||||
|
+ return i >> 4; //same method as fromBlockCoord, just be clear about coord/size semantic difference
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static class SectionYCoord {
|
||||||
|
+ public static int getNumYSections(LevelHeightAccessor view) {
|
||||||
|
+ return view.getSectionsCount();
|
||||||
|
+ }
|
||||||
|
+ public static int getMinYSection(LevelHeightAccessor view) {
|
||||||
|
+ return view.getMinSection();
|
||||||
|
+ }
|
||||||
|
+ public static int getMaxYSectionInclusive(LevelHeightAccessor view) {
|
||||||
|
+ return view.getMaxSection() - 1;
|
||||||
|
+ }
|
||||||
|
+ public static int getMaxYSectionExclusive(LevelHeightAccessor view) {
|
||||||
|
+ return view.getMaxSection();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static int fromSectionIndex(LevelHeightAccessor view, int sectionCoord) {
|
||||||
|
+ return sectionCoord + SectionYCoord.getMinYSection(view);
|
||||||
|
+ }
|
||||||
|
+ public static int fromBlockCoord(int blockCoord) {
|
||||||
|
+ return SectionPos.blockToSectionCoord(blockCoord);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static class SectionYIndex {
|
||||||
|
+ public static int getNumYSections(LevelHeightAccessor view) {
|
||||||
|
+ return view.getSectionsCount();
|
||||||
|
+ }
|
||||||
|
+ public static int getMinYSectionIndex(LevelHeightAccessor view) {
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+ public static int getMaxYSectionIndexInclusive(LevelHeightAccessor view) {
|
||||||
|
+ return view.getSectionsCount() - 1;
|
||||||
|
+ }
|
||||||
|
+ public static int getMaxYSectionIndexExclusive(LevelHeightAccessor view) {
|
||||||
|
+ return view.getSectionsCount();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static int fromSectionCoord(LevelHeightAccessor view, int sectionCoord) {
|
||||||
|
+ return sectionCoord - SectionYCoord.getMinYSection(view);
|
||||||
|
+ }
|
||||||
|
+ public static int fromBlockCoord(LevelHeightAccessor view, int blockCoord) {
|
||||||
|
+ return fromSectionCoord(view, SectionPos.blockToSectionCoord(blockCoord));
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/level/WorldGenRegion.java b/src/main/java/net/minecraft/server/level/WorldGenRegion.java
|
||||||
|
index 59b7d9c9a2a0203f8135a9dcdce302bbf0b2d0f4..c8ff093e5bb8295e61e70d6fb447ed86baa350a4 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/level/WorldGenRegion.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/level/WorldGenRegion.java
|
||||||
|
@@ -87,6 +87,10 @@ public class WorldGenRegion implements WorldGenLevel {
|
||||||
|
private Supplier<String> currentlyGenerating;
|
||||||
|
private final AtomicLong subTickCount = new AtomicLong();
|
||||||
|
private static final ResourceLocation WORLDGEN_REGION_RANDOM = new ResourceLocation("worldgen_region_random");
|
||||||
|
+ // Gale start - Lithium - optimize world generation chunk and block access
|
||||||
|
+ private ChunkAccess[] chunksArr;
|
||||||
|
+ private int minChunkX, minChunkZ;
|
||||||
|
+ // Gale end - Lithium - optimize world generation chunk and block access
|
||||||
|
|
||||||
|
public WorldGenRegion(ServerLevel world, List<ChunkAccess> chunks, ChunkStatus status, int placementRadius) {
|
||||||
|
this.generatingStatus = status;
|
||||||
|
@@ -108,6 +112,11 @@ public class WorldGenRegion implements WorldGenLevel {
|
||||||
|
this.firstPos = ((ChunkAccess) chunks.get(0)).getPos();
|
||||||
|
this.lastPos = ((ChunkAccess) chunks.get(chunks.size() - 1)).getPos();
|
||||||
|
}
|
||||||
|
+ // Gale start - Lithium - optimize world generation chunk and block access
|
||||||
|
+ this.minChunkX = this.firstPos.x;
|
||||||
|
+ this.minChunkZ = this.firstPos.z;
|
||||||
|
+ this.chunksArr = chunks.toArray(new ChunkAccess[0]);
|
||||||
|
+ // Gale end - Lithium - optimize world generation chunk and block access
|
||||||
|
}
|
||||||
|
|
||||||
|
// Paper start - starlight
|
||||||
|
@@ -146,8 +155,28 @@ public class WorldGenRegion implements WorldGenLevel {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ChunkAccess getChunk(int chunkX, int chunkZ) {
|
||||||
|
- return this.getChunk(chunkX, chunkZ, ChunkStatus.EMPTY);
|
||||||
|
+ // Gale start - Lithium - optimize world generation chunk and block access - use the chunk array for faster access
|
||||||
|
+ int x = chunkX - this.minChunkX;
|
||||||
|
+ int z = chunkZ - this.minChunkZ;
|
||||||
|
+ int w = this.size;
|
||||||
|
+
|
||||||
|
+ if (x >= 0 && z >= 0 && x < w && z < w) {
|
||||||
|
+ return this.chunksArr[x + z * w];
|
||||||
|
+ } else {
|
||||||
|
+ throw new NullPointerException("No chunk exists at " + new ChunkPos(chunkX, chunkZ));
|
||||||
|
+ }
|
||||||
|
+ // Gale end - Lithium - optimize world generation chunk and block access - use the chunk array for faster access
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ // Gale start - Lithium - optimize world generation chunk and block access
|
||||||
|
+ /**
|
||||||
|
+ * Use our chunk fetch function
|
||||||
|
+ */
|
||||||
|
+ public ChunkAccess getChunk(BlockPos pos) {
|
||||||
|
+ // Skip checking chunk.getStatus().isAtLeast(ChunkStatus.EMPTY) here, because it is always true
|
||||||
|
+ return this.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ()));
|
||||||
|
}
|
||||||
|
+ // Gale end - Lithium - optimize world generation chunk and block access
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
@@ -212,7 +241,17 @@ public class WorldGenRegion implements WorldGenLevel {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getBlockState(BlockPos pos) {
|
||||||
|
- return this.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ())).getBlockState(pos);
|
||||||
|
+ // Gale start - Lithium - optimize world generation chunk and block access - avoid pointer de-referencing, make method easier to inline
|
||||||
|
+ int x = SectionPos.blockToSectionCoord(pos.getX()) - this.minChunkX;
|
||||||
|
+ int z = SectionPos.blockToSectionCoord(pos.getZ()) - this.minChunkZ;
|
||||||
|
+ int w = this.size;
|
||||||
|
+
|
||||||
|
+ if (x >= 0 && z >= 0 && x < w && z < w) {
|
||||||
|
+ return this.chunksArr[x + z * w].getBlockState(pos);
|
||||||
|
+ } else {
|
||||||
|
+ throw new NullPointerException("No chunk exists at " + new ChunkPos(pos));
|
||||||
|
+ }
|
||||||
|
+ // Gale end - Lithium - optimize world generation chunk and block access - avoid pointer de-referencing, make method easier to inline
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Sun, 25 Dec 2022 16:55:45 +0100
|
||||||
|
Subject: [PATCH] Load portal destination chunk before entity teleport
|
||||||
|
|
||||||
|
Removed since Gale 1.21.3, entity can teleport cross dimension since 1.21.1
|
||||||
|
also see 1.21.1 update in mc wiki for more info
|
||||||
|
|
||||||
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
This patch is based on the following patch:
|
||||||
|
"Load chunks when entities go through an end portal"
|
||||||
|
By: PureGero <puregero@gmail.com>
|
||||||
|
As part of: MultiPaper (https://github.com/MultiPaper/MultiPaper)
|
||||||
|
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
|
index ce11e73e7a91c9d45f62552ab1cd7bec47b2a879..4865759b5ad05997b7777a8cd036967083c2ef39 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
|
@@ -4006,6 +4006,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||||
|
if (entity == null) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
+ // Gale start - MultiPaper - load portal destination chunk before entity teleport
|
||||||
|
+ if (world.galeConfig().gameplayMechanics.technical.loadPortalDestinationChunkBeforeEntityTeleport) {
|
||||||
|
+ BlockPos pos = BlockPos.containing(position);
|
||||||
|
+ world.getChunkSource().addRegionTicket(TicketType.PORTAL, new ChunkPos(pos), 1, pos);
|
||||||
|
+ world.getChunkAt(pos);
|
||||||
|
+ }
|
||||||
|
+ // Gale end - MultiPaper - load portal destination chunk before entity teleport
|
||||||
|
// Paper start - Fix item duplication and teleport issues
|
||||||
|
if (this instanceof Leashable leashable) {
|
||||||
|
leashable.dropLeash(true, true); // Paper drop lead
|
||||||
|
diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||||
|
index ecd4cf29a03d6f4ee71450b1c0d952209e40be4a..63ff60f9d5d9a8a5ea36754dd394696b54082d93 100644
|
||||||
|
--- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||||
|
+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||||
|
@@ -119,6 +119,11 @@ public class GaleWorldConfiguration extends ConfigurationPart {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
+ public Technical technical;
|
||||||
|
+ public class Technical extends ConfigurationPart {
|
||||||
|
+ public boolean loadPortalDestinationChunkBeforeEntityTeleport = false; // Gale - MultiPaper - load portal destination chunk before entity teleport
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
public boolean arrowMovementResetsDespawnCounter = true; // Gale - Purpur - make arrow movement resetting despawn counter configurable
|
||||||
|
public double entityWakeUpDurationRatioStandardDeviation = 0.2; // Gale - variable entity wake-up duration
|
||||||
|
public boolean hideFlamesOnEntitiesWithFireResistance = false; // Gale - Slice - hide flames on entities with fire resistance
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Sat, 24 Dec 2022 23:30:35 +0100
|
||||||
|
Subject: [PATCH] Make max interaction distance configurable
|
||||||
|
|
||||||
|
Removed since Gale 1.20.6
|
||||||
|
Mojang added attributes that can control player's `Entity Interaction Range`
|
||||||
|
and `Block Interaction Range` for every player since 1.20.5
|
||||||
|
|
||||||
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||||
|
index a7b217ddbcbf92513bd38101fdfca2075505e267..840dc3c57dd60d5f16155fc0c6f8c9fea49685c9 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||||
|
@@ -174,7 +174,7 @@ public class ServerPlayerGameMode {
|
||||||
|
private void debugLogging(BlockPos pos, boolean success, int sequence, String reason) {}
|
||||||
|
|
||||||
|
public void handleBlockBreakAction(BlockPos pos, ServerboundPlayerActionPacket.Action action, Direction direction, int worldHeight, int sequence) {
|
||||||
|
- if (this.player.getEyePosition().distanceToSqr(Vec3.atCenterOf(pos)) > ServerGamePacketListenerImpl.MAX_INTERACTION_DISTANCE) {
|
||||||
|
+ if (this.player.getEyePosition().distanceToSqr(Vec3.atCenterOf(pos)) > ServerGamePacketListenerImpl.getMaxInteractionDistanceSquared(this.player.level())) { // Gale - make max interaction distance configurable
|
||||||
|
if (true) return; // Paper - Don't allow digging into unloaded chunks; Don't notify if unreasonably far away
|
||||||
|
this.debugLogging(pos, false, sequence, "too far");
|
||||||
|
} else if (pos.getY() >= worldHeight) {
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
|
index ec0cf74e977d3ba4cbd43572af8f7fd4a496462f..9025505e7c8ac81d97a553e0ebbeb5727bd69bb6 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
|
@@ -250,7 +250,7 @@ import org.bukkit.inventory.SmithingInventory;
|
||||||
|
public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl implements ServerGamePacketListener, ServerPlayerConnection, TickablePacketListener {
|
||||||
|
|
||||||
|
static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
- public static final double MAX_INTERACTION_DISTANCE = Mth.square(6.0D);
|
||||||
|
+ public static final double DEFAULT_MAX_INTERACTION_DISTANCE_SQUARED = Mth.square(6.0D); // Gale - make max interaction distance configurable
|
||||||
|
private static final int NO_BLOCK_UPDATES_TO_ACK = -1;
|
||||||
|
private static final int TRACKED_MESSAGE_DISCONNECT_THRESHOLD = 4096;
|
||||||
|
private static final Component CHAT_VALIDATION_FAILED = Component.translatable("multiplayer.disconnect.chat_validation_failed");
|
||||||
|
@@ -328,6 +328,13 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||||
|
private boolean justTeleported = false;
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
|
+ // Gale start - make max interaction distance configurable
|
||||||
|
+ public static double getMaxInteractionDistanceSquared(Level level) {
|
||||||
|
+ var config = level.galeConfig().gameplayMechanics;
|
||||||
|
+ return config.playerMaxInteractionDistance < 0 ? ServerGamePacketListenerImpl.DEFAULT_MAX_INTERACTION_DISTANCE_SQUARED : config.playerMaxInteractionDistanceSquared;
|
||||||
|
+ }
|
||||||
|
+ // Gale end - make max interaction distance configurable
|
||||||
|
+
|
||||||
|
@Override
|
||||||
|
public void tick() {
|
||||||
|
if (this.ackBlockChangesUpTo > -1) {
|
||||||
|
@@ -1928,7 +1935,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||||
|
BlockPos blockposition = movingobjectpositionblock.getBlockPos();
|
||||||
|
Vec3 vec3d1 = Vec3.atCenterOf(blockposition);
|
||||||
|
|
||||||
|
- if (this.player.getEyePosition().distanceToSqr(vec3d1) <= ServerGamePacketListenerImpl.MAX_INTERACTION_DISTANCE) {
|
||||||
|
+ if (this.player.getEyePosition().distanceToSqr(vec3d1) <= ServerGamePacketListenerImpl.getMaxInteractionDistanceSquared(this.player.level())) { // Gale - make max interaction distance configurable
|
||||||
|
Vec3 vec3d2 = vec3d.subtract(vec3d1);
|
||||||
|
double d0 = 1.0000001D;
|
||||||
|
|
||||||
|
@@ -2720,7 +2727,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||||
|
|
||||||
|
AABB axisalignedbb = entity.getBoundingBox();
|
||||||
|
|
||||||
|
- if (axisalignedbb.distanceToSqr(this.player.getEyePosition()) < ServerGamePacketListenerImpl.MAX_INTERACTION_DISTANCE) {
|
||||||
|
+ if (axisalignedbb.distanceToSqr(this.player.getEyePosition()) < ServerGamePacketListenerImpl.getMaxInteractionDistanceSquared(this.player.level())) { // Gale - make max interaction distance configurable
|
||||||
|
packet.dispatch(new ServerboundInteractPacket.Handler() {
|
||||||
|
private void performInteraction(InteractionHand enumhand, ServerGamePacketListenerImpl.EntityInteraction playerconnection_a, PlayerInteractEntityEvent event) { // CraftBukkit
|
||||||
|
ItemStack itemstack = ServerGamePacketListenerImpl.this.player.getItemInHand(enumhand);
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/item/BrushItem.java b/src/main/java/net/minecraft/world/item/BrushItem.java
|
||||||
|
index 9caf067fcfbf74bbf260bf9149122f7ff8f317e4..a0bd0093bd232070c5826eb7271e490d9138db58 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/item/BrushItem.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/item/BrushItem.java
|
||||||
|
@@ -4,6 +4,7 @@ import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.core.particles.BlockParticleOption;
|
||||||
|
import net.minecraft.core.particles.ParticleTypes;
|
||||||
|
+import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||||
|
import net.minecraft.sounds.SoundEvent;
|
||||||
|
import net.minecraft.sounds.SoundEvents;
|
||||||
|
import net.minecraft.sounds.SoundSource;
|
||||||
|
@@ -97,7 +98,7 @@ public class BrushItem extends Item {
|
||||||
|
|
||||||
|
private HitResult calculateHitResult(Player user) {
|
||||||
|
return ProjectileUtil.getHitResultOnViewVector(
|
||||||
|
- user, entity -> !entity.isSpectator() && entity.isPickable(), (double)Player.getPickRange(user.isCreative())
|
||||||
|
+ user, entity -> !entity.isSpectator() && entity.isPickable(), Math.sqrt(ServerGamePacketListenerImpl.getMaxInteractionDistanceSquared(user.level())) - 1.0D // Gale - make max interaction distance configurable
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||||
|
index 5d499e77800466210473e36b2355873807b9f86a..c5b23bafb7909130a8a294e3b5bf94daa313ee11 100644
|
||||||
|
--- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||||
|
+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||||
|
@@ -9,6 +9,7 @@ import io.papermc.paper.configuration.PaperConfigurations;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.spigotmc.SpigotWorldConfig;
|
||||||
|
+import org.spongepowered.configurate.objectmapping.meta.PostProcess;
|
||||||
|
import org.spongepowered.configurate.objectmapping.meta.Setting;
|
||||||
|
|
||||||
|
@SuppressWarnings({"FieldCanBeLocal", "FieldMayBeFinal", "NotNullFieldNotInitialized", "InnerClassMayBeStatic"})
|
||||||
|
@@ -130,6 +131,16 @@ public class GaleWorldConfiguration extends ConfigurationPart {
|
||||||
|
public boolean hideFlamesOnEntitiesWithFireResistance = false; // Gale - Slice - hide flames on entities with fire resistance
|
||||||
|
public boolean tryRespawnEnderDragonAfterEndCrystalPlace = true; // Gale - Pufferfish - make ender dragon respawn attempt after placing end crystals configurable
|
||||||
|
|
||||||
|
+ // Gale start - make max interaction distance configurable
|
||||||
|
+ public double playerMaxInteractionDistance = -1.0;
|
||||||
|
+ public transient double playerMaxInteractionDistanceSquared;
|
||||||
|
+ // Gale end - make max interaction distance configurable
|
||||||
|
+
|
||||||
|
+ @PostProcess
|
||||||
|
+ public void postProcess() {
|
||||||
|
+ this.playerMaxInteractionDistanceSquared = this.playerMaxInteractionDistance * this.playerMaxInteractionDistance; // Gale - make max interaction distance configurable
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Fri, 24 Mar 2023 09:16:33 +0100
|
||||||
|
Subject: [PATCH] Instantly continue on world upgrade finish
|
||||||
|
|
||||||
|
Removed since 1.21
|
||||||
|
|
||||||
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java b/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java
|
||||||
|
index 7f6d1ccd147e5593412567bb2934ce5662da7ef0..c3bc7fab47da974f6b134ca91a79af72c9d44c1c 100644
|
||||||
|
--- a/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java
|
||||||
|
+++ b/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java
|
||||||
|
@@ -26,6 +26,7 @@ import java.util.Optional;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.ThreadFactory;
|
||||||
|
+import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
@@ -101,7 +102,12 @@ public class ThreadedWorldUpgrader {
|
||||||
|
new ChunkStorage(storageInfo, regionFolder.toPath(), this.dataFixer, false), this.removeCaches, this.dimensionType, this.generatorKey);
|
||||||
|
|
||||||
|
long expectedChunks = (long)regionFiles.length * (32L * 32L);
|
||||||
|
+ // Gale start - instantly continue on world upgrade finish
|
||||||
|
+ final long[] finalExpectedChunks = {-1L};
|
||||||
|
|
||||||
|
+ var finishLock = new java.util.concurrent.locks.ReentrantLock();
|
||||||
|
+ var finishCondition = finishLock.newCondition();
|
||||||
|
+ // Gale end - instantly continue on world upgrade finish
|
||||||
|
for (final File regionFile : regionFiles) {
|
||||||
|
final ChunkPos regionPos = RegionFileStorage.getRegionFileCoordinates(regionFile.toPath());
|
||||||
|
if (regionPos == null) {
|
||||||
|
@@ -109,7 +115,23 @@ public class ThreadedWorldUpgrader {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
- this.threadPool.execute(new ConvertTask(info, regionPos.x >> 5, regionPos.z >> 5));
|
||||||
|
+ // Gale start - instantly continue on world upgrade finish
|
||||||
|
+ Runnable taskWithNotification = () -> {
|
||||||
|
+ new ConvertTask(info, regionPos.x >> 5, regionPos.z >> 5).run();
|
||||||
|
+ final long current = info.convertedChunks.get();
|
||||||
|
+ if (current == finalExpectedChunks[0]) {
|
||||||
|
+ while (!finishLock.tryLock()) {
|
||||||
|
+ Thread.onSpinWait();
|
||||||
|
+ }
|
||||||
|
+ try {
|
||||||
|
+ finishCondition.signal();
|
||||||
|
+ } finally {
|
||||||
|
+ finishLock.unlock();
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ };
|
||||||
|
+ this.threadPool.execute(taskWithNotification);
|
||||||
|
+ // Gale end - instantly continue on world upgrade finish
|
||||||
|
// Paper start - Write SavedData IO async
|
||||||
|
this.threadPool.execute(() -> {
|
||||||
|
try {
|
||||||
|
@@ -120,6 +142,7 @@ public class ThreadedWorldUpgrader {
|
||||||
|
});
|
||||||
|
// Paper end - Write SavedData IO async
|
||||||
|
}
|
||||||
|
+ finalExpectedChunks[0] = expectedChunks; // Gale - instantly continue on world upgrade finish
|
||||||
|
this.threadPool.shutdown();
|
||||||
|
|
||||||
|
final DecimalFormat format = new DecimalFormat("#0.00");
|
||||||
|
@@ -131,9 +154,16 @@ public class ThreadedWorldUpgrader {
|
||||||
|
|
||||||
|
LOGGER.info("{}% completed ({} / {} chunks)...", format.format((double)current / (double)expectedChunks * 100.0), current, expectedChunks);
|
||||||
|
|
||||||
|
+ // Gale start - instantly continue on world upgrade finish
|
||||||
|
+ while (!finishLock.tryLock()) {
|
||||||
|
+ Thread.onSpinWait();
|
||||||
|
+ }
|
||||||
|
try {
|
||||||
|
- Thread.sleep(1000L);
|
||||||
|
- } catch (final InterruptedException ignore) {}
|
||||||
|
+ finishCondition.await(1000L, TimeUnit.MILLISECONDS);
|
||||||
|
+ } catch (final InterruptedException ignore) {} finally {
|
||||||
|
+ finishLock.unlock();
|
||||||
|
+ }
|
||||||
|
+ // Gale end - instantly continue on world upgrade finish
|
||||||
|
}
|
||||||
|
|
||||||
|
final long end = System.nanoTime();
|
||||||
@@ -0,0 +1,206 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Wed, 23 Nov 2022 22:33:06 +0100
|
||||||
|
Subject: [PATCH] Use aging cache for biome temperatures
|
||||||
|
|
||||||
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
This patch is based on the following patch:
|
||||||
|
"Use aging cache for biome temperatures"
|
||||||
|
By: Paul Sauve <paul@technove.co>
|
||||||
|
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||||
|
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
|
||||||
|
* Airplane copyright *
|
||||||
|
|
||||||
|
Airplane
|
||||||
|
Copyright (C) 2020 Technove LLC
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) 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 General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
diff --git a/src/main/java/gg/airplane/structs/Long2FloatAgingCache.java b/src/main/java/gg/airplane/structs/Long2FloatAgingCache.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..f3835d6934f4d82980eb068c0b8c238f9c4bae2f
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/gg/airplane/structs/Long2FloatAgingCache.java
|
||||||
|
@@ -0,0 +1,121 @@
|
||||||
|
+// Gale - Airplane - use aging cache for biome temperatures
|
||||||
|
+
|
||||||
|
+package gg.airplane.structs;
|
||||||
|
+
|
||||||
|
+import it.unimi.dsi.fastutil.HashCommon;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * A replacement for the cache used in Biome.
|
||||||
|
+ */
|
||||||
|
+public class Long2FloatAgingCache {
|
||||||
|
+
|
||||||
|
+ private static class AgingEntry {
|
||||||
|
+ private long data;
|
||||||
|
+ private float value;
|
||||||
|
+ private int uses = 0;
|
||||||
|
+ private int age = 0;
|
||||||
|
+
|
||||||
|
+ private AgingEntry(long data, float value) {
|
||||||
|
+ this.data = data;
|
||||||
|
+ this.value = value;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void replace(long data, float flag) {
|
||||||
|
+ this.data = data;
|
||||||
|
+ this.value = flag;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public int getValue() {
|
||||||
|
+ return this.uses - (this.age >> 1); // age isn't as important as uses
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void incrementUses() {
|
||||||
|
+ this.uses = this.uses + 1 & Integer.MAX_VALUE;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void incrementAge() {
|
||||||
|
+ this.age = this.age + 1 & Integer.MAX_VALUE;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private final AgingEntry[] entries;
|
||||||
|
+ private final int mask;
|
||||||
|
+ private final int maxDistance; // the most amount of entries to check for a value
|
||||||
|
+
|
||||||
|
+ public Long2FloatAgingCache(int size) {
|
||||||
|
+ int arraySize = HashCommon.nextPowerOfTwo(size);
|
||||||
|
+ this.entries = new AgingEntry[arraySize];
|
||||||
|
+ this.mask = arraySize - 1;
|
||||||
|
+ this.maxDistance = Math.min(arraySize, 4);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public float getValue(long data) {
|
||||||
|
+ AgingEntry curr;
|
||||||
|
+ int pos;
|
||||||
|
+
|
||||||
|
+ if ((curr = this.entries[pos = HashCommon.mix(HashCommon.long2int(data)) & this.mask]) == null) {
|
||||||
|
+ return Float.NaN;
|
||||||
|
+ } else if (data == curr.data) {
|
||||||
|
+ curr.incrementUses();
|
||||||
|
+ return curr.value;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ int checked = 1; // start at 1 because we already checked the first spot above
|
||||||
|
+
|
||||||
|
+ while ((curr = this.entries[pos = (pos + 1) & this.mask]) != null) {
|
||||||
|
+ if (data == curr.data) {
|
||||||
|
+ curr.incrementUses();
|
||||||
|
+ return curr.value;
|
||||||
|
+ } else if (++checked >= this.maxDistance) {
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return Float.NaN;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void putValue(long data, float value) {
|
||||||
|
+ AgingEntry curr;
|
||||||
|
+ int pos;
|
||||||
|
+
|
||||||
|
+ if ((curr = this.entries[pos = HashCommon.mix(HashCommon.long2int(data)) & this.mask]) == null) {
|
||||||
|
+ this.entries[pos] = new AgingEntry(data, value); // add
|
||||||
|
+ return;
|
||||||
|
+ } else if (data == curr.data) {
|
||||||
|
+ curr.incrementUses();
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ int checked = 1; // start at 1 because we already checked the first spot above
|
||||||
|
+
|
||||||
|
+ while ((curr = this.entries[pos = (pos + 1) & this.mask]) != null) {
|
||||||
|
+ if (data == curr.data) {
|
||||||
|
+ curr.incrementUses();
|
||||||
|
+ return;
|
||||||
|
+ } else if (++checked >= this.maxDistance) {
|
||||||
|
+ this.forceAdd(data, value);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ this.entries[pos] = new AgingEntry(data, value); // add
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private void forceAdd(long data, float value) {
|
||||||
|
+ int expectedPos = HashCommon.mix(HashCommon.long2int(data)) & this.mask;
|
||||||
|
+ AgingEntry entryToRemove = this.entries[expectedPos];
|
||||||
|
+
|
||||||
|
+ for (int i = expectedPos + 1; i < expectedPos + this.maxDistance; i++) {
|
||||||
|
+ int pos = i & this.mask;
|
||||||
|
+ AgingEntry entry = this.entries[pos];
|
||||||
|
+ if (entry.getValue() < entryToRemove.getValue()) {
|
||||||
|
+ entryToRemove = entry;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ entry.incrementAge(); // use this as a mechanism to age the other entries
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ // remove the least used/oldest entry
|
||||||
|
+ entryToRemove.replace(data, value);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/biome/Biome.java b/src/main/java/net/minecraft/world/level/biome/Biome.java
|
||||||
|
index 15f82c9a1ce1fef2e951d1b3c7a65e64b82061ea..115a9adac2131dd875d4bf1b6bc998125a96008d 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/biome/Biome.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/biome/Biome.java
|
||||||
|
@@ -63,13 +63,18 @@ public final class Biome {
|
||||||
|
private final BiomeGenerationSettings generationSettings;
|
||||||
|
private final MobSpawnSettings mobSettings;
|
||||||
|
private final BiomeSpecialEffects specialEffects;
|
||||||
|
- private final ThreadLocal<Long2FloatLinkedOpenHashMap> temperatureCache = ThreadLocal.withInitial(() -> Util.make(() -> {
|
||||||
|
+ // Gale start - Airplane - use aging cache for biome temperatures - use our cache
|
||||||
|
+ private final ThreadLocal<gg.airplane.structs.Long2FloatAgingCache> temperatureCache = ThreadLocal.withInitial(() -> Util.make(() -> {
|
||||||
|
+ /*
|
||||||
|
Long2FloatLinkedOpenHashMap long2FloatLinkedOpenHashMap = new Long2FloatLinkedOpenHashMap(1024, 0.25F) {
|
||||||
|
protected void rehash(int i) {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
long2FloatLinkedOpenHashMap.defaultReturnValue(Float.NaN);
|
||||||
|
return long2FloatLinkedOpenHashMap;
|
||||||
|
+ */
|
||||||
|
+ return new gg.airplane.structs.Long2FloatAgingCache(TEMPERATURE_CACHE_SIZE);
|
||||||
|
+ // Gale end - Airplane - use aging cache for biome temperatures - use our cache
|
||||||
|
}));
|
||||||
|
|
||||||
|
Biome(Biome.ClimateSettings weather, BiomeSpecialEffects effects, BiomeGenerationSettings generationSettings, MobSpawnSettings spawnSettings) {
|
||||||
|
@@ -112,17 +117,15 @@ public final class Biome {
|
||||||
|
@Deprecated
|
||||||
|
public float getTemperature(BlockPos blockPos) {
|
||||||
|
long l = blockPos.asLong();
|
||||||
|
- Long2FloatLinkedOpenHashMap long2FloatLinkedOpenHashMap = this.temperatureCache.get();
|
||||||
|
- float f = long2FloatLinkedOpenHashMap.get(l);
|
||||||
|
+ // Gale start - Airplane - use aging cache for biome temperatures
|
||||||
|
+ gg.airplane.structs.Long2FloatAgingCache cache = this.temperatureCache.get();
|
||||||
|
+ float f = cache.getValue(l);
|
||||||
|
if (!Float.isNaN(f)) {
|
||||||
|
return f;
|
||||||
|
} else {
|
||||||
|
float g = this.getHeightAdjustedTemperature(blockPos);
|
||||||
|
- if (long2FloatLinkedOpenHashMap.size() == 1024) {
|
||||||
|
- long2FloatLinkedOpenHashMap.removeFirstFloat();
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- long2FloatLinkedOpenHashMap.put(l, g);
|
||||||
|
+ cache.putValue(l, g);
|
||||||
|
+ // Gale end - Airplane - use aging cache for biome temperatures
|
||||||
|
return g;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Thu, 24 Nov 2022 22:07:56 +0100
|
||||||
|
Subject: [PATCH] Don't trigger lootable refresh for non-player interaction
|
||||||
|
|
||||||
|
Removed since 1.21
|
||||||
|
Cause trial chamber don't drop items, unless make this configurable
|
||||||
|
|
||||||
|
License: MIT (https://opensource.org/licenses/MIT)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
This patch is based on the following patch:
|
||||||
|
"Don't trigger Lootable Refresh for non player interaction"
|
||||||
|
By: Aikar <aikar@aikar.co>
|
||||||
|
As part of: EmpireCraft (https://github.com/starlis/empirecraft)
|
||||||
|
Licensed under: MIT (https://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/RandomizableContainer.java b/src/main/java/net/minecraft/world/RandomizableContainer.java
|
||||||
|
index a9a80f8bc4a6f250fe3c20482c395058f024fabd..fb60f2a86ff387f46995b6aa71b65e1b56527623 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/RandomizableContainer.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/RandomizableContainer.java
|
||||||
|
@@ -81,6 +81,7 @@ public interface RandomizableContainer extends Container {
|
||||||
|
}
|
||||||
|
|
||||||
|
default void unpackLootTable(@Nullable Player player) {
|
||||||
|
+ if (player == null) return; // Gale - EMC - don't trigger lootable refresh for non-player interaction
|
||||||
|
Level level = this.getLevel();
|
||||||
|
BlockPos blockPos = this.getBlockPos();
|
||||||
|
ResourceKey<LootTable> resourceKey = this.getLootTable();
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Wed, 30 Nov 2022 17:19:01 +0100
|
||||||
|
Subject: [PATCH] Cache CubeVoxelShape shape array
|
||||||
|
|
||||||
|
License: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
This patch is based on the following mixin:
|
||||||
|
"me/jellysquid/mods/lithium/mixin/shapes/precompute_shape_arrays/SimpleVoxelShapeMixin.java"
|
||||||
|
By: Angeline <jellysquid3@users.noreply.github.com>
|
||||||
|
As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric)
|
||||||
|
Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/phys/shapes/CubeVoxelShape.java b/src/main/java/net/minecraft/world/phys/shapes/CubeVoxelShape.java
|
||||||
|
index d812949c7329ae2696b38dc792fa011ba87decb9..746e9e280eb47356475484eb1f658c0728cd65cf 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/phys/shapes/CubeVoxelShape.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/phys/shapes/CubeVoxelShape.java
|
||||||
|
@@ -5,13 +5,24 @@ import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.util.Mth;
|
||||||
|
|
||||||
|
public final class CubeVoxelShape extends VoxelShape {
|
||||||
|
+
|
||||||
|
+ private @org.jetbrains.annotations.NotNull DoubleList @org.jetbrains.annotations.Nullable [] list; // Gale - Lithium - cache CubeVoxelShape shape array
|
||||||
|
+
|
||||||
|
protected CubeVoxelShape(DiscreteVoxelShape voxels) {
|
||||||
|
super(voxels);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DoubleList getCoords(Direction.Axis axis) {
|
||||||
|
- return new CubePointRange(this.shape.getSize(axis));
|
||||||
|
+ // Gale start - Lithium - cache CubeVoxelShape shape array
|
||||||
|
+ if (this.list == null) {
|
||||||
|
+ this.list = new DoubleList[Direction.Axis.VALUES.length];
|
||||||
|
+ for (Direction.Axis existingAxis : Direction.Axis.VALUES) {
|
||||||
|
+ this.list[existingAxis.ordinal()] = new CubePointRange(this.shape.getSize(axis));
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ return this.list[axis.ordinal()];
|
||||||
|
+ // Gale end - Lithium - cache CubeVoxelShape shape array
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@@ -0,0 +1,173 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||||
|
Date: Thu, 1 Dec 2022 00:37:50 +0100
|
||||||
|
Subject: [PATCH] Cache ominous banner item
|
||||||
|
|
||||||
|
License: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
||||||
|
Gale - https://galemc.org
|
||||||
|
|
||||||
|
This patch is based on the following mixin:
|
||||||
|
"me/jellysquid/mods/lithium/mixin/ai/raid/RaiderEntityMixin.java"
|
||||||
|
By: 2No2Name <2No2Name@web.de>
|
||||||
|
As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric)
|
||||||
|
Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/advancements/critereon/EntityEquipmentPredicate.java b/src/main/java/net/minecraft/advancements/critereon/EntityEquipmentPredicate.java
|
||||||
|
index ff9d99feb75a8e0f695b8f2696bd79baccf77e01..1712e45439e3ebcb61703ac30eaa92e85f99b676 100644
|
||||||
|
--- a/src/main/java/net/minecraft/advancements/critereon/EntityEquipmentPredicate.java
|
||||||
|
+++ b/src/main/java/net/minecraft/advancements/critereon/EntityEquipmentPredicate.java
|
||||||
|
@@ -40,7 +40,7 @@ public record EntityEquipmentPredicate(
|
||||||
|
.head(
|
||||||
|
ItemPredicate.Builder.item()
|
||||||
|
.of(Items.WHITE_BANNER)
|
||||||
|
- .hasComponents(DataComponentPredicate.allOf(Raid.getLeaderBannerInstance(bannerPatternLookup).getComponents()))
|
||||||
|
+ .hasComponents(DataComponentPredicate.allOf(Raid.getLeaderBanner(bannerPatternLookup).getComponents())) // Gale - Lithium - cache ominous banner item
|
||||||
|
)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/net/minecraft/data/advancements/packs/VanillaAdventureAdvancements.java b/src/main/java/net/minecraft/data/advancements/packs/VanillaAdventureAdvancements.java
|
||||||
|
index 09d93c4814ee918d4a2d73794bcd5bdda5a4f8eb..3187956a47182951d239a6d3cc5a8c79ba9c5b38 100644
|
||||||
|
--- a/src/main/java/net/minecraft/data/advancements/packs/VanillaAdventureAdvancements.java
|
||||||
|
+++ b/src/main/java/net/minecraft/data/advancements/packs/VanillaAdventureAdvancements.java
|
||||||
|
@@ -394,7 +394,7 @@ public class VanillaAdventureAdvancements implements AdvancementSubProvider {
|
||||||
|
AdvancementHolder advancementHolder8 = Advancement.Builder.advancement()
|
||||||
|
.parent(advancementHolder)
|
||||||
|
.display(
|
||||||
|
- Raid.getLeaderBannerInstance(registryLookup),
|
||||||
|
+ Raid.getLeaderBanner(registryLookup), // Gale - Lithium - cache ominous banner item
|
||||||
|
Component.translatable("advancements.adventure.voluntary_exile.title"),
|
||||||
|
Component.translatable("advancements.adventure.voluntary_exile.description"),
|
||||||
|
null,
|
||||||
|
@@ -413,7 +413,7 @@ public class VanillaAdventureAdvancements implements AdvancementSubProvider {
|
||||||
|
Advancement.Builder.advancement()
|
||||||
|
.parent(advancementHolder8)
|
||||||
|
.display(
|
||||||
|
- Raid.getLeaderBannerInstance(registryLookup),
|
||||||
|
+ Raid.getLeaderBanner(registryLookup), // Gale - Lithium - cache ominous banner item
|
||||||
|
Component.translatable("advancements.adventure.hero_of_the_village.title"),
|
||||||
|
Component.translatable("advancements.adventure.hero_of_the_village.description"),
|
||||||
|
null,
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/commands/RaidCommand.java b/src/main/java/net/minecraft/server/commands/RaidCommand.java
|
||||||
|
index 774bc4b5bc8c56ff3b0997de5eb1c46ef9ea7d2e..468dd8f6372751f52c0bedef19879a12de412789 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/commands/RaidCommand.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/commands/RaidCommand.java
|
||||||
|
@@ -95,7 +95,7 @@ public class RaidCommand {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
raider.setPatrolLeader(true);
|
||||||
|
- raider.setItemSlot(EquipmentSlot.HEAD, Raid.getLeaderBannerInstance(source.registryAccess().lookupOrThrow(Registries.BANNER_PATTERN)));
|
||||||
|
+ raider.setItemSlot(EquipmentSlot.HEAD, Raid.getLeaderBanner(source.registryAccess().lookupOrThrow(Registries.BANNER_PATTERN))); // Gale - Lithium - cache ominous banner item
|
||||||
|
raider.setPos(source.getPosition().x, source.getPosition().y, source.getPosition().z);
|
||||||
|
raider.finalizeSpawn(
|
||||||
|
source.getLevel(), source.getLevel().getCurrentDifficultyAt(BlockPos.containing(source.getPosition())), MobSpawnType.COMMAND, null
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/PatrollingMonster.java b/src/main/java/net/minecraft/world/entity/monster/PatrollingMonster.java
|
||||||
|
index 7e1a4b69291e14dc0323b3f40aa4acce8c4b0acf..1ddc36fdf98b5d7ec1658fe3d2eb38eff6634a52 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/monster/PatrollingMonster.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/monster/PatrollingMonster.java
|
||||||
|
@@ -74,7 +74,7 @@ public abstract class PatrollingMonster extends Monster {
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isPatrolLeader()) {
|
||||||
|
- this.setItemSlot(EquipmentSlot.HEAD, Raid.getLeaderBannerInstance(this.registryAccess().lookupOrThrow(Registries.BANNER_PATTERN)));
|
||||||
|
+ this.setItemSlot(EquipmentSlot.HEAD, Raid.getLeaderBanner(this.registryAccess().lookupOrThrow(Registries.BANNER_PATTERN))); // Gale - Lithium - cache ominous banner item
|
||||||
|
this.setDropChance(EquipmentSlot.HEAD, 2.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/raid/Raid.java b/src/main/java/net/minecraft/world/entity/raid/Raid.java
|
||||||
|
index 5c0e5803284bfc82c2dd8bba9ded0ba7aac4962a..539e17bdeefd0be17a46cb65e034c7e0e4df181c 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/raid/Raid.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/raid/Raid.java
|
||||||
|
@@ -725,7 +725,7 @@ public class Raid {
|
||||||
|
this.level.getRaids().setDirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
- public static ItemStack getLeaderBannerInstance(HolderGetter<BannerPattern> bannerPatternLookup) {
|
||||||
|
+ private static ItemStack createLeaderBanner(HolderGetter<BannerPattern> bannerPatternLookup) { // Gale - Lithium - cache ominous banner item
|
||||||
|
ItemStack itemstack = new ItemStack(Items.WHITE_BANNER);
|
||||||
|
BannerPatternLayers bannerpatternlayers = (new BannerPatternLayers.Builder()).addIfRegistered(bannerPatternLookup, BannerPatterns.RHOMBUS_MIDDLE, DyeColor.CYAN).addIfRegistered(bannerPatternLookup, BannerPatterns.STRIPE_BOTTOM, DyeColor.LIGHT_GRAY).addIfRegistered(bannerPatternLookup, BannerPatterns.STRIPE_CENTER, DyeColor.GRAY).addIfRegistered(bannerPatternLookup, BannerPatterns.BORDER, DyeColor.LIGHT_GRAY).addIfRegistered(bannerPatternLookup, BannerPatterns.STRIPE_MIDDLE, DyeColor.BLACK).addIfRegistered(bannerPatternLookup, BannerPatterns.HALF_HORIZONTAL, DyeColor.LIGHT_GRAY).addIfRegistered(bannerPatternLookup, BannerPatterns.CIRCLE_MIDDLE, DyeColor.LIGHT_GRAY).addIfRegistered(bannerPatternLookup, BannerPatterns.BORDER, DyeColor.BLACK).build();
|
||||||
|
|
||||||
|
@@ -735,6 +735,22 @@ public class Raid {
|
||||||
|
return itemstack;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Gale start - Lithium - cache ominous banner item
|
||||||
|
+ public static ItemStack LEADER_BANNER = ItemStack.EMPTY;
|
||||||
|
+
|
||||||
|
+ public static ItemStack getLeaderBanner(HolderGetter<BannerPattern> bannerPatternLookup) {
|
||||||
|
+ if (LEADER_BANNER.equals(ItemStack.EMPTY)) {
|
||||||
|
+ LEADER_BANNER = createLeaderBanner(bannerPatternLookup);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return LEADER_BANNER;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static ItemStack getLeaderBannerInstance(HolderGetter<BannerPattern> bannerPatternLookup) {
|
||||||
|
+ return getLeaderBanner(bannerPatternLookup).copy();
|
||||||
|
+ }
|
||||||
|
+ // Gale end - Lithium - cache ominous banner item
|
||||||
|
+
|
||||||
|
@Nullable
|
||||||
|
public Raider getLeader(int wave) {
|
||||||
|
return (Raider) this.groupToLeaderMap.get(wave);
|
||||||
|
@@ -803,7 +819,7 @@ public class Raid {
|
||||||
|
|
||||||
|
public void setLeader(int wave, Raider entity) {
|
||||||
|
this.groupToLeaderMap.put(wave, entity);
|
||||||
|
- entity.setItemSlot(EquipmentSlot.HEAD, Raid.getLeaderBannerInstance(entity.registryAccess().lookupOrThrow(Registries.BANNER_PATTERN)));
|
||||||
|
+ entity.setItemSlot(EquipmentSlot.HEAD, Raid.getLeaderBanner(entity.registryAccess().lookupOrThrow(Registries.BANNER_PATTERN))); // Gale - Lithium - cache ominous banner item
|
||||||
|
entity.setDropChance(EquipmentSlot.HEAD, 2.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/raid/Raider.java b/src/main/java/net/minecraft/world/entity/raid/Raider.java
|
||||||
|
index bbf21ea433f9e3963aac0ede597ed8d3c8e50ed8..9c958635f9b9ca82d49062fdc35b7ebadf02bb2f 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/raid/Raider.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/raid/Raider.java
|
||||||
|
@@ -45,7 +45,7 @@ public abstract class Raider extends PatrollingMonster {
|
||||||
|
|
||||||
|
protected static final EntityDataAccessor<Boolean> IS_CELEBRATING = SynchedEntityData.defineId(Raider.class, EntityDataSerializers.BOOLEAN);
|
||||||
|
static final Predicate<ItemEntity> ALLOWED_ITEMS = (entityitem) -> {
|
||||||
|
- return !entityitem.hasPickUpDelay() && entityitem.isAlive() && ItemStack.matches(entityitem.getItem(), Raid.getLeaderBannerInstance(entityitem.registryAccess().lookupOrThrow(Registries.BANNER_PATTERN)));
|
||||||
|
+ return !entityitem.hasPickUpDelay() && entityitem.isAlive() && ItemStack.matches(entityitem.getItem(), Raid.getLeaderBanner(entityitem.registryAccess().lookupOrThrow(Registries.BANNER_PATTERN))); // Gale - Lithium - cache ominous banner item
|
||||||
|
};
|
||||||
|
@Nullable
|
||||||
|
protected Raid raid;
|
||||||
|
@@ -152,7 +152,7 @@ public abstract class Raider extends PatrollingMonster {
|
||||||
|
|
||||||
|
public boolean isCaptain() {
|
||||||
|
ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD);
|
||||||
|
- boolean flag = !itemstack.isEmpty() && ItemStack.matches(itemstack, Raid.getLeaderBannerInstance(this.registryAccess().lookupOrThrow(Registries.BANNER_PATTERN)));
|
||||||
|
+ boolean flag = !itemstack.isEmpty() && ItemStack.matches(itemstack, Raid.getLeaderBanner(this.registryAccess().lookupOrThrow(Registries.BANNER_PATTERN))); // Gale - Lithium - cache ominous banner item
|
||||||
|
boolean flag1 = this.isPatrolLeader();
|
||||||
|
|
||||||
|
return flag && flag1;
|
||||||
|
@@ -224,7 +224,7 @@ public abstract class Raider extends PatrollingMonster {
|
||||||
|
ItemStack itemstack = item.getItem();
|
||||||
|
boolean flag = this.hasActiveRaid() && this.getCurrentRaid().getLeader(this.getWave()) != null;
|
||||||
|
|
||||||
|
- if (this.hasActiveRaid() && !flag && ItemStack.matches(itemstack, Raid.getLeaderBannerInstance(this.registryAccess().lookupOrThrow(Registries.BANNER_PATTERN)))) {
|
||||||
|
+ if (this.hasActiveRaid() && !flag && ItemStack.matches(itemstack, Raid.getLeaderBanner(this.registryAccess().lookupOrThrow(Registries.BANNER_PATTERN)))) { // Gale - Lithium - cache ominous banner item
|
||||||
|
// Paper start - EntityPickupItemEvent fixes
|
||||||
|
if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, item, 0, false).isCancelled()) {
|
||||||
|
return;
|
||||||
|
@@ -302,7 +302,7 @@ public abstract class Raider extends PatrollingMonster {
|
||||||
|
if (!this.mob.level().getGameRules().getBoolean(net.minecraft.world.level.GameRules.RULE_MOBGRIEFING) || !this.mob.canPickUpLoot()) return false; // Paper - respect game and entity rules for picking up items
|
||||||
|
Raid raid = this.mob.getCurrentRaid();
|
||||||
|
|
||||||
|
- if (this.mob.hasActiveRaid() && !this.mob.getCurrentRaid().isOver() && this.mob.canBeLeader() && !ItemStack.matches(this.mob.getItemBySlot(EquipmentSlot.HEAD), Raid.getLeaderBannerInstance(this.mob.registryAccess().lookupOrThrow(Registries.BANNER_PATTERN)))) {
|
||||||
|
+ if (this.mob.hasActiveRaid() && !this.mob.getCurrentRaid().isOver() && this.mob.canBeLeader() && !ItemStack.matches(this.mob.getItemBySlot(EquipmentSlot.HEAD), Raid.getLeaderBanner(this.mob.registryAccess().lookupOrThrow(Registries.BANNER_PATTERN)))) { // Gale - Lithium - cache ominous banner item
|
||||||
|
Raider entityraider = raid.getLeader(this.mob.getWave());
|
||||||
|
|
||||||
|
if (entityraider == null || !entityraider.isAlive()) {
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/item/CreativeModeTabs.java b/src/main/java/net/minecraft/world/item/CreativeModeTabs.java
|
||||||
|
index 3c5f820fb4ee554e94f417a911922af6c4943e3c..509f1fd055fc4e2b50023ef8c29b190c81bca170 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/item/CreativeModeTabs.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/item/CreativeModeTabs.java
|
||||||
|
@@ -1103,7 +1103,7 @@ public class CreativeModeTabs {
|
||||||
|
entries.accept(Items.PURPLE_BANNER);
|
||||||
|
entries.accept(Items.MAGENTA_BANNER);
|
||||||
|
entries.accept(Items.PINK_BANNER);
|
||||||
|
- entries.accept(Raid.getLeaderBannerInstance(displayContext.holders().lookupOrThrow(Registries.BANNER_PATTERN)));
|
||||||
|
+ entries.accept(Raid.getLeaderBanner(displayContext.holders().lookupOrThrow(Registries.BANNER_PATTERN))); // Gale - Lithium - cache ominous banner item
|
||||||
|
entries.accept(Items.SKELETON_SKULL);
|
||||||
|
entries.accept(Items.WITHER_SKELETON_SKULL);
|
||||||
|
entries.accept(Items.PLAYER_HEAD);
|
||||||
Reference in New Issue
Block a user