9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-29 20:09:17 +00:00

Some minecraft patches work

This commit is contained in:
Dreeam
2025-03-28 19:38:27 -04:00
parent 45016fbaff
commit 25c453a1c8
48 changed files with 407 additions and 542 deletions

View File

@@ -0,0 +1,123 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Wed, 23 Nov 2022 22:03:33 +0100
Subject: [PATCH] Make EntityCollisionContext a live representation
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:
"Make EntityCollisionContext a live representation"
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 *
While Context is in the name, it is not used as a context. Instead it is
always created, use temporarily, then thrown away. This means having a
lot of fields to initialize and make space for is useless. I cannot find
anywhere in the codebase where this is used as a context which may be
saved for later, so this should be safe assuming plugins don't use it
for some strange reason.
* 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/net/minecraft/world/phys/shapes/EntityCollisionContext.java b/net/minecraft/world/phys/shapes/EntityCollisionContext.java
index ebc9360ea64a248418fcac8b446664b0dd019335..b09d1b7c76410580663f2419e3b5e917fedabd54 100644
--- a/net/minecraft/world/phys/shapes/EntityCollisionContext.java
+++ b/net/minecraft/world/phys/shapes/EntityCollisionContext.java
@@ -19,27 +19,39 @@ public class EntityCollisionContext implements CollisionContext {
return canAscend;
}
};
+ // Gale start - Airplane - make EntityCollisionContext a live representation - remove these and pray no plugin uses them
+ /*
private final boolean descending;
private final double entityBottom;
private final boolean placement;
private final ItemStack heldItem;
private final Predicate<FluidState> canStandOnFluid;
+ */
+ // Gale end - Airplane - make EntityCollisionContext a live representation - remove these and pray no plugin uses them
+ private final boolean placement;
@Nullable
private final Entity entity;
protected EntityCollisionContext(
boolean descending, boolean placement, double entityBottom, ItemStack heldItem, Predicate<FluidState> canStandOnFluid, @Nullable Entity entity
) {
+ // Gale start - Airplane - make EntityCollisionContext a live representation - remove these and pray no plugin uses them
+ /*
this.descending = descending;
this.placement = placement;
this.entityBottom = entityBottom;
this.heldItem = heldItem;
this.canStandOnFluid = canStandOnFluid;
+ */
+ // Gale end - Airplane - make EntityCollisionContext a live representation - remove these and pray no plugin uses them
+ this.placement = placement;
this.entity = entity;
}
@Deprecated
protected EntityCollisionContext(Entity entity, boolean canStandOnFluid, boolean placement) {
+ // Gale start - Airplane - make EntityCollisionContext a live representation - remove unneeded things
+ /*
this(
entity.isDescending(),
placement,
@@ -50,16 +62,20 @@ public class EntityCollisionContext implements CollisionContext {
: (entity instanceof LivingEntity livingEntity ? fluidState -> livingEntity.canStandOnFluid(fluidState) : fluidState -> false),
entity
);
+ */
+ this.placement = placement;
+ this.entity = entity;
+ // Gale end - Airplane - make EntityCollisionContext a live representation - remove unneeded things
}
@Override
public boolean isHoldingItem(Item item) {
- return this.heldItem.is(item);
+ return this.entity instanceof LivingEntity livingEntity ? livingEntity.getMainHandItem().is(item) : ItemStack.EMPTY.is(item); // Gale - Airplane - make EntityCollisionContext a live representation
}
@Override
public boolean canStandOnFluid(FluidState fluid1, FluidState fluid2) {
- return this.canStandOnFluid.test(fluid2) && !fluid1.getType().isSame(fluid2.getType());
+ return this.entity instanceof LivingEntity livingEntity && livingEntity.canStandOnFluid(fluid2) && !fluid1.getType().isSame(fluid2.getType()); // Gale - Airplane - make EntityCollisionContext a live representation
}
@Override
@@ -69,12 +85,12 @@ public class EntityCollisionContext implements CollisionContext {
@Override
public boolean isDescending() {
- return this.descending;
+ return this.entity != null && this.entity.isDescending(); // Gale - Airplane - make EntityCollisionContext a live representation
}
@Override
public boolean isAbove(VoxelShape shape, BlockPos pos, boolean canAscend) {
- return this.entityBottom > pos.getY() + shape.max(Direction.Axis.Y) - 1.0E-5F;
+ return (this.entity == null ? -Double.MAX_VALUE : entity.getY()) > (double) pos.getY() + shape.max(Direction.Axis.Y) - (double) 1.0E-5F; // Gale - Airplane - make EntityCollisionContext a live representation
}
@Nullable

View File

@@ -0,0 +1,73 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Wed, 23 Nov 2022 22:26:37 +0100
Subject: [PATCH] Better checking for useless move packets
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:
"Better checking for useless move packets"
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/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java
index 3f83a589442a80e9c16b5e9cd0f50792defd12bc..e945564034f1f0a83dcdd39b8889c7aa61bfd199 100644
--- a/net/minecraft/server/level/ServerEntity.java
+++ b/net/minecraft/server/level/ServerEntity.java
@@ -172,19 +172,25 @@ public class ServerEntity {
packet = ClientboundEntityPositionSyncPacket.of(this.entity);
flag3 = true;
flag4 = true;
- } else if ((!flag2 || !flag) && !(this.entity instanceof AbstractArrow)) {
- if (flag2) {
- packet = new ClientboundMoveEntityPacket.Pos(this.entity.getId(), (short)l, (short)l1, (short)l2, this.entity.onGround());
- flag3 = true;
- } else if (flag) {
- packet = new ClientboundMoveEntityPacket.Rot(this.entity.getId(), b, b1, this.entity.onGround());
- flag4 = true;
- }
+ // Gale start - Airplane - better checking for useless move packets
} else {
- packet = new ClientboundMoveEntityPacket.PosRot(this.entity.getId(), (short)l, (short)l1, (short)l2, b, b1, this.entity.onGround());
- flag3 = true;
- flag4 = true;
+ if (flag2 || flag || this.entity instanceof AbstractArrow) {
+ if ((!flag2 || !flag) && !(this.entity instanceof AbstractArrow)) {
+ if (flag2) {
+ packet = new ClientboundMoveEntityPacket.Pos(this.entity.getId(), (short) l, (short) l1, (short) l2, this.entity.onGround());
+ flag3 = true;
+ } else if (flag) {
+ packet = new ClientboundMoveEntityPacket.Rot(this.entity.getId(), b, b1, this.entity.onGround());
+ flag4 = true;
+ }
+ } else {
+ packet = new ClientboundMoveEntityPacket.PosRot(this.entity.getId(), (short) l, (short) l1, (short) l2, b, b1, this.entity.onGround());
+ flag3 = true;
+ flag4 = true;
+ }
+ }
}
+ // Gale end - Airplane - better checking for useless move packets
if (this.entity.hasImpulse || this.trackDelta || this.entity instanceof LivingEntity && ((LivingEntity)this.entity).isFallFlying()) {
Vec3 deltaMovement = this.entity.getDeltaMovement();

View File

@@ -0,0 +1,44 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Wed, 23 Nov 2022 23:05:45 +0100
Subject: [PATCH] Block goal does not load chunks
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 Paper#6045, block goal shouldn't load chunks"
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/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java b/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java
index d0ab3db7bbd2942db19f473474371b20ce822608..3f080b15543bf8c5fa0774b62d7f12e13b82511a 100644
--- a/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java
+++ b/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java
@@ -119,6 +119,7 @@ public abstract class MoveToBlockGoal extends Goal {
for (int i4 = 0; i4 <= i3; i4 = i4 > 0 ? -i4 : 1 - i4) {
for (int i5 = i4 < i3 && i4 > -i3 ? i3 : 0; i5 <= i3; i5 = i5 > 0 ? -i5 : 1 - i5) {
mutableBlockPos.setWithOffset(blockPos, i4, i2 - 1, i5);
+ if (!this.mob.level().hasChunkAt(mutableBlockPos)) continue; // Gale - Airplane - block goal does not load chunks - if this block isn't loaded, continue
if (this.mob.isWithinRestriction(mutableBlockPos) && this.isValidTarget(this.mob.level(), mutableBlockPos)) {
this.blockPos = mutableBlockPos;
this.mob.movingTarget = mutableBlockPos == BlockPos.ZERO ? null : mutableBlockPos.immutable(); // Paper

View File

@@ -0,0 +1,57 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Wed, 23 Nov 2022 23:10:56 +0100
Subject: [PATCH] Reduce entity allocations
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 allocations"
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/net/minecraft/world/entity/ai/attributes/AttributeMap.java b/net/minecraft/world/entity/ai/attributes/AttributeMap.java
index bed9b564c493cd84bf53fc49368fda736f3fbc2b..5b22ad7d56754f82ce8448382ab6bafc2055f413 100644
--- a/net/minecraft/world/entity/ai/attributes/AttributeMap.java
+++ b/net/minecraft/world/entity/ai/attributes/AttributeMap.java
@@ -18,9 +18,11 @@ public class AttributeMap {
private final Set<AttributeInstance> attributesToSync = new ObjectOpenHashSet<>();
private final Set<AttributeInstance> attributesToUpdate = new ObjectOpenHashSet<>();
private final AttributeSupplier supplier;
+ private final java.util.function.Function<Holder<Attribute>, AttributeInstance> createInstance; // Gale - Airplane - reduce entity allocations
public AttributeMap(AttributeSupplier supplier) {
this.supplier = supplier;
+ this.createInstance = holder -> this.supplier.createInstance(this::onAttributeModified, holder); // Gale - Airplane - reduce entity allocations
}
private void onAttributeModified(AttributeInstance instance) {
@@ -44,7 +46,7 @@ public class AttributeMap {
@Nullable
public AttributeInstance getInstance(Holder<Attribute> attribute) {
- return this.attributes.computeIfAbsent(attribute, holder -> this.supplier.createInstance(this::onAttributeModified, (Holder<Attribute>)holder));
+ return this.attributes.computeIfAbsent(attribute, this.createInstance); // Gale - Airplane - reduce entity allocations - cache lambda, as for some reason java allocates it anyways
}
public boolean hasAttribute(Holder<Attribute> attribute) {

View File

@@ -0,0 +1,72 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Wed, 23 Nov 2022 23:13:56 +0100
Subject: [PATCH] Remove lambda from ticking guard
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 lambda from ticking guard"
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/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index db5327dfcaaa4ac767466f6abeec30c50d32db73..679c94142eac06ec0bc6f3b819ee4f7e831c4626 100644
--- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java
@@ -545,7 +545,19 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
entity.stopRiding();
}
- this.guardEntityTick(this::tickNonPassenger, entity);
+ // Gale start - Airplane - remove lambda from ticking guard - copied from guardEntityTick
+ try {
+ this.tickNonPassenger(entity); // Gale - Airplane - remove lambda from ticking guard - changed
+ } catch (Throwable var6) {
+ // Paper start - Prevent block entity and entity crashes
+ final String msg = String.format("Entity threw exception at %s:%s,%s,%s", entity.level().getWorld().getName(), entity.getX(), entity.getY(), entity.getZ());
+ MinecraftServer.LOGGER.error(msg, var6);
+ getCraftServer().getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerInternalException(msg, var6))); // Paper - ServerExceptionEvent
+ entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD);
+ // Paper end - Prevent block entity and entity crashes
+ }
+ //this.moonrise$midTickTasks(); // Paper - rewrite chunk system
+ // Gale end - Airplane - remove lambda from ticking guard - copied from guardEntityTick
}
}
}
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index e813588e03234e4b12b531cd77f725f7d7f9c50c..b20e92a6232b96521f8d5dd7a289007e98863b9e 100644
--- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java
@@ -850,8 +850,9 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
final String msg = String.format("Entity threw exception at %s:%s,%s,%s", entity.level().getWorld().getName(), entity.getX(), entity.getY(), entity.getZ());
MinecraftServer.LOGGER.error(msg, var6);
getCraftServer().getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerInternalException(msg, var6))); // Paper - ServerExceptionEvent
- entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD);
+ entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD); // Gale - Airplane - remove lambda from ticking guard - diff on change ServerLevel#tick
// Paper end - Prevent block entity and entity crashes
+ //this.moonrise$midTickTasks(); // Paper - rewrite chunk system // Gale - Airplane - remove lambda from ticking guard - diff on change ServerLevel#tick
}
}

View File

@@ -0,0 +1,32 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Thu, 24 Nov 2022 01:19:12 +0100
Subject: [PATCH] SIMD support
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:
"Add SIMD utilities"
By: Kevin Raneri <kevin.raneri@gmail.com>
As part of: Pufferfish (https://github.com/pufferfish-gg/Pufferfish)
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java
index c71034e9077280ccd7b4d7a9986eb6ec1536472a..a86ede54cfeb416a8c0c85fe90862e65e6505b62 100644
--- a/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/net/minecraft/server/dedicated/DedicatedServer.java
@@ -190,6 +190,13 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics
com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now
+ // Gale start - Pufferfish - SIMD support
+ // Initialize vectorization
+ try {
+ gg.pufferfish.pufferfish.simd.SIMDDetection.initialize();
+ } catch (Throwable ignored) {}
+ // Gale end - Pufferfish - SIMD support
+
this.setPvpAllowed(properties.pvp);
this.setFlightAllowed(properties.allowFlight);
this.setMotd(properties.motd);

View File

@@ -0,0 +1,39 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Mon, 26 Dec 2022 02:11:29 +0100
Subject: [PATCH] Make book writing configurable
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:
"Add option to disable books"
By: Kevin Raneri <kevin.raneri@gmail.com>
As part of: Pufferfish (https://github.com/pufferfish-gg/Pufferfish)
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
* Pufferfish description *
Books are commonly the target of duping-related exploits. If you
anticipate that your server will be an early target of duping attacks in
the event that new exploits are found, you may want to consider removing
the ability for non-privileged players to edit books. This patch allows
you to easily disable books, should you want to preemptively remove this
functionality before additional exploits are found.
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 5e921c490814be31fc2843327c0e2cc76bda6620..df7142bbfec170966373dcf4ac50e4bbc5ba4e53 100644
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1191,6 +1191,11 @@ public class ServerGamePacketListenerImpl
@Override
public void handleEditBook(ServerboundEditBookPacket packet) {
+ // Gale start - Pufferfish - make book writing configurable
+ if (!(org.galemc.gale.configuration.GaleGlobalConfiguration.get().gameplayMechanics.enableBookWriting || this.player.getBukkitEntity().hasPermission(org.bukkit.craftbukkit.util.permissions.CraftDefaultPermissions.writeBooks) || this.player.getBukkitEntity().hasPermission("pufferfish.usebooks"))) {
+ return;
+ }
+ // Gale end - Pufferfish - make book writing configurable
// Paper start - Book size limits
final io.papermc.paper.configuration.type.number.IntOr.Disabled pageMax = io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.bookSize.pageMax;
if (!this.cserver.isPrimaryThread() && pageMax.enabled()) {

View File

@@ -0,0 +1,58 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Thu, 24 Nov 2022 10:31:38 +0100
Subject: [PATCH] Reduce in wall checks
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 suffocation"
By: Kevin Raneri <kevin.raneri@gmail.com>
As part of: Pufferfish (https://github.com/pufferfish-gg/Pufferfish)
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
* Pufferfish description *
The isInWall check to determine suffocation is quite expensive, and
often is completely unnecessary to check. We do two things here to
improve this:
1. We only check for suffocation once per 20 ticks. The maximum
no-damage ticks value means that this change should be extremely
difficult, if not impossible, for players to notice.
2. We additionally execute a check to see if the player can even take
damage in the first place. This check doesn't improve performance much
but is so much cheaper than the suffocation check that it's worth
keeping it.
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
index bb687f048be9edfde75d13354dd3265593e83e9f..ac86ea5fc03aab1445712a7143f7714eea31b124 100644
--- a/net/minecraft/world/entity/LivingEntity.java
+++ b/net/minecraft/world/entity/LivingEntity.java
@@ -419,7 +419,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
if (this.isAlive() && this.level() instanceof ServerLevel serverLevel1) {
boolean flag = this instanceof Player;
- if (this.isInWall()) {
+ // Gale start - Pufferfish - reduce in wall checks
+ long checkStuckInWallInterval = this.level().galeConfig().smallOptimizations.reducedIntervals.checkStuckInWall;
+ if ((checkStuckInWallInterval <= 1 || (tickCount % checkStuckInWallInterval == 0 && couldPossiblyBeHurt(1.0F))) && this.isInWall()) {
+ // Gale end - Pufferfish - reduce in wall checks
this.hurtServer(serverLevel1, this.damageSources().inWall(), 1.0F);
} else if (flag && !serverLevel1.getWorldBorder().isWithinBounds(this.getBoundingBox())) {
double d = serverLevel1.getWorldBorder().getDistanceToBorder(this) + serverLevel1.getWorldBorder().getDamageSafeZone();
@@ -1367,6 +1370,12 @@ public abstract class LivingEntity extends Entity implements Attackable {
return this.getHealth() <= 0.0F;
}
+ // Gale start - Pufferfish - reduce in wall checks
+ private boolean couldPossiblyBeHurt(float amount) {
+ return !((float) this.invulnerableTime > (float) this.invulnerableDuration / 2.0F) || !(amount <= this.lastHurt);
+ }
+ // Gale end - Pufferfish - reduce in wall checks
+
@Override
public boolean hurtServer(ServerLevel level, DamageSource damageSource, float amount) {
if (this.isInvulnerableTo(level, damageSource)) {

View File

@@ -0,0 +1,27 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Mon, 26 Dec 2022 05:22:43 +0100
Subject: [PATCH] Make chat order verification configurable
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:
"Add option to disable out-of-order chat"
By: Kevin Raneri <kevin.raneri@gmail.com>
As part of: Pufferfish (https://github.com/pufferfish-gg/Pufferfish)
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
diff --git a/net/minecraft/network/chat/SignedMessageChain.java b/net/minecraft/network/chat/SignedMessageChain.java
index f6eed34b2fd72ab74cc9dc4b99ca184d512c0a66..23872fac07fa36f10ef090df2423c978998dcb99 100644
--- a/net/minecraft/network/chat/SignedMessageChain.java
+++ b/net/minecraft/network/chat/SignedMessageChain.java
@@ -45,7 +45,7 @@ public class SignedMessageChain {
SignedMessageLink signedMessageLink = SignedMessageChain.this.nextLink;
if (signedMessageLink == null) {
throw new SignedMessageChain.DecodeException(SignedMessageChain.DecodeException.CHAIN_BROKEN);
- } else if (body.timeStamp().isBefore(SignedMessageChain.this.lastTimeStamp)) {
+ } else if (body.timeStamp().isBefore(SignedMessageChain.this.lastTimeStamp) && org.galemc.gale.configuration.GaleGlobalConfiguration.get().misc.verifyChatOrder) { // Gale - Pufferfish - make chat order verification configurable
this.setChainBroken();
throw new SignedMessageChain.DecodeException(SignedMessageChain.DecodeException.OUT_OF_ORDER_CHAT, org.bukkit.event.player.PlayerKickEvent.Cause.OUT_OF_ORDER_CHAT); // Paper - kick event causes
} else {

View File

@@ -0,0 +1,44 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Mon, 7 Aug 2023 21:35:57 +0200
Subject: [PATCH] Make ender dragon respawn attempt after placing end crystals
configurable
The original Pufferfish description has been included below for reference,
but please note that on Gale, there is no need to disable end crystal
spawning for performance: Gale already contains other performance
enhancements that make the end crystal checks very fast.
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:
"Option to disable end crystal dragon respawning"
By: Kevin Raneri <kevin.raneri@gmail.com>
As part of: Pufferfish (https://github.com/pufferfish-gg/Pufferfish)
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
* Pufferfish description *
On servers that expect end crystal fights in the end dimension,
disabling this will prevent the server from performing an expensive
search to attempt respawning the ender dragon whenever a player places
an end crystal.
diff --git a/net/minecraft/world/item/EndCrystalItem.java b/net/minecraft/world/item/EndCrystalItem.java
index 05ec512839898f96d9769bb0d00f6ba11dda0c4b..49f94f242a0906e74eb58313cf095a0b04c304c4 100644
--- a/net/minecraft/world/item/EndCrystalItem.java
+++ b/net/minecraft/world/item/EndCrystalItem.java
@@ -49,10 +49,12 @@ public class EndCrystalItem extends Item {
// CraftBukkit end
level.addFreshEntity(endCrystal);
level.gameEvent(context.getPlayer(), GameEvent.ENTITY_PLACE, blockPos);
+ if (level.galeConfig().gameplayMechanics.tryRespawnEnderDragonAfterEndCrystalPlace) { // Gale - Pufferfish - make ender dragon respawn attempt after placing end crystals configurable
EndDragonFight dragonFight = ((ServerLevel)level).getDragonFight();
if (dragonFight != null) {
dragonFight.tryRespawn(aboveBlockPos); // Paper - Perf: Do crystal-portal proximity check before entity lookup
}
+ } // Gale - Pufferfish - make ender dragon respawn attempt after placing end crystals configurable
}
context.getItemInHand().shrink(1);

View File

@@ -0,0 +1,37 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Mon, 26 Dec 2022 07:30:30 +0100
Subject: [PATCH] Make saving fireworks configurable
License: MIT (https://opensource.org/licenses/MIT)
Gale - https://galemc.org
This patch is based on the following patch:
"Don't save Fireworks"
By: Aikar <aikar@aikar.co>
As part of: EmpireCraft (https://github.com/starlis/empirecraft)
Licensed under: MIT (https://opensource.org/licenses/MIT)
* EmpireCraft description *
Fireworks can bug out and not detonate, and an automated
launcher can very easily fill a chunk.
Prevent saving Fireworks so that chunk unloads will wipe a chunks fireworks in this case.
diff --git a/net/minecraft/world/entity/projectile/FireworkRocketEntity.java b/net/minecraft/world/entity/projectile/FireworkRocketEntity.java
index e0e193078e550225e163149638bf9e053c0531f8..70197071db4e46cd93579d92ff2f8aa7a49083cb 100644
--- a/net/minecraft/world/entity/projectile/FireworkRocketEntity.java
+++ b/net/minecraft/world/entity/projectile/FireworkRocketEntity.java
@@ -354,4 +354,11 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier {
double d1 = entity.position().z - this.position().z;
return DoubleDoubleImmutablePair.of(d, d1);
}
+
+ // Gale start - EMC - make saving fireworks configurable
+ @Override
+ public boolean shouldBeSaved() {
+ return this.level().galeConfig().smallOptimizations.saveFireworks;
+ }
+ // Gale end - EMC - make saving fireworks configurable
}

View File

@@ -0,0 +1,154 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Thu, 24 Nov 2022 23:03:52 +0100
Subject: [PATCH] Reduce hopper item checks
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 Hopper Performance"
By: Aikar <aikar@aikar.co>
As part of: EmpireCraft (https://github.com/starlis/empirecraft)
Licensed under: MIT (https://opensource.org/licenses/MIT)
* EmpireCraft description *
Only do an item "suck in" action once per second
diff --git a/net/minecraft/world/entity/item/ItemEntity.java b/net/minecraft/world/entity/item/ItemEntity.java
index 6c0ebfb2be4e8b884456a2aa3d5fdc87e45a0e3c..bf2f81232ac40218c6d0241b7a0a26cb2272e06b 100644
--- a/net/minecraft/world/entity/item/ItemEntity.java
+++ b/net/minecraft/world/entity/item/ItemEntity.java
@@ -150,7 +150,13 @@ public class ItemEntity extends Entity implements TraceableEntity {
}
// CraftBukkit end
this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
+ return; // Gale - EMC - reduce hopper item checks
}
+ // Gale start - EMC - reduce hopper item checks
+ if (level().galeConfig().smallOptimizations.reducedIntervals.checkNearbyItem.hopper.minecart.temporaryImmunity.checkForMinecartNearItemWhileInactive) {
+ this.markNearbyHopperCartsAsImmune();
+ }
+ // Gale end - EMC - reduce hopper item checks
}
// Paper end - EAR 2
@@ -234,9 +240,31 @@ public class ItemEntity extends Entity implements TraceableEntity {
}
// CraftBukkit end
this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
+ return; // Gale - EMC - reduce hopper item checks
+ }
+ this.markNearbyHopperCartsAsImmune(); // Gale - EMC - reduce hopper item checks
+ }
+ }
+
+ // Gale start - EMC - reduce hopper item checks
+ private void markNearbyHopperCartsAsImmune() {
+ var config = this.level().galeConfig().smallOptimizations.reducedIntervals.checkNearbyItem.hopper.minecart;
+
+ // No need to mark hopper minecarts as immune if they can pull every tick anyway
+ if (config.interval <= 1) {
+ return;
+ }
+
+ if (config.temporaryImmunity.duration > 0 && this.isAlive() && this.onGround && !this.isRemoved() && (config.temporaryImmunity.nearbyItemMaxAge == -1 || this.age <= config.temporaryImmunity.nearbyItemMaxAge) && this.age % Math.max(1, config.temporaryImmunity.checkForMinecartNearItemInterval) == 0 && config.temporaryImmunity.maxItemHorizontalDistance >= 0 && config.temporaryImmunity.maxItemVerticalDistance >= 0) {
+ net.minecraft.world.phys.AABB aabb = this.getBoundingBox().inflate(config.temporaryImmunity.maxItemHorizontalDistance, config.temporaryImmunity.maxItemVerticalDistance, config.temporaryImmunity.maxItemHorizontalDistance);
+ for (Entity entity : this.level().getEntities(this, aabb)) {
+ if (entity instanceof net.minecraft.world.entity.vehicle.MinecartHopper hopper) {
+ hopper.pickupImmunity = net.minecraft.server.MinecraftServer.currentTick + config.temporaryImmunity.duration;
+ }
}
}
}
+ // Gale end - EMC - reduce hopper item checks
@Override
public BlockPos getBlockPosBelowThatAffectsMyMovement() {
diff --git a/net/minecraft/world/entity/vehicle/MinecartHopper.java b/net/minecraft/world/entity/vehicle/MinecartHopper.java
index a56d9cdeb6589a053ffaaf2cd599a98ae0a0989a..df5eda70d1d2eafcd32606fb93bb62409e5a8943 100644
--- a/net/minecraft/world/entity/vehicle/MinecartHopper.java
+++ b/net/minecraft/world/entity/vehicle/MinecartHopper.java
@@ -22,6 +22,7 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper
private static final boolean DEFAULT_ENABLED = true;
private boolean enabled = true;
private boolean consumedItemThisFrame = false;
+ public int pickupImmunity = 0; // Gale - EMC - reduce hopper item checks
public MinecartHopper(EntityType<? extends MinecartHopper> entityType, Level level) {
super(entityType, level);
@@ -150,4 +151,12 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper
}
// Paper end
+ // Gale start - EMC - reduce hopper item checks
+ private long tickAttempts = 0;
+ @Override
+ public long getAndIncrementAttemptCounter() {
+ return tickAttempts++;
+ }
+ // Gale end EMC - - reduce hopper item checks
+
}
diff --git a/net/minecraft/world/level/block/entity/Hopper.java b/net/minecraft/world/level/block/entity/Hopper.java
index 484c2ba2752fbf3ad929e46c2f078e906f6f0637..6ced5a7e27703a7cf5a7495dc3a1a290ce0d18eb 100644
--- a/net/minecraft/world/level/block/entity/Hopper.java
+++ b/net/minecraft/world/level/block/entity/Hopper.java
@@ -11,6 +11,8 @@ public interface Hopper extends Container {
return SUCK_AABB;
}
+ long getAndIncrementAttemptCounter(); // Gale - EMC - reduce hopper item checks
+
double getLevelX();
double getLevelY();
diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java
index 9a03934dd4d96184f37b9ff5661eb7bd76150464..c7591bb0b4755f28dffc2b3e6c4600d22480bbf1 100644
--- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java
@@ -302,7 +302,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
return false;
} else {
boolean flag = hopper.isGridAligned() && blockState.isCollisionShapeFullBlock(level, blockPos) && !blockState.is(BlockTags.DOES_NOT_BLOCK_HOPPERS);
- if (!flag) {
+ if (!flag && shouldSuckIn(level, hopper)) { // Gale - EMC - reduce hopper item checks
for (ItemEntity itemEntity : getItemsAtAndAbove(level, hopper)) {
if (addItem(hopper, itemEntity)) {
return true;
@@ -565,6 +565,34 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
return stack1.getCount() <= stack1.getMaxStackSize() && ItemStack.isSameItemSameComponents(stack1, stack2);
}
+ // Gale start - EMC - reduce hopper item checks
+ private long tickAttempts = 0;
+ @Override
+ public long getAndIncrementAttemptCounter() {
+ return tickAttempts++;
+ }
+ private static boolean shouldSuckIn(Level level, Hopper hopper) {
+ int suckInterval;
+ if (hopper instanceof net.minecraft.world.entity.vehicle.MinecartHopper minecartHopper) {
+ if (minecartHopper.pickupImmunity > net.minecraft.server.MinecraftServer.currentTick) {
+ return true;
+ }
+
+ suckInterval = level.galeConfig().smallOptimizations.reducedIntervals.checkNearbyItem.hopper.minecart.interval;
+ } else {
+ suckInterval = level.galeConfig().smallOptimizations.reducedIntervals.checkNearbyItem.hopper.interval;
+ }
+
+ if (suckInterval <= 1) {
+ return true;
+ }
+
+ final int hopperId = (int) hopper.getLevelX() + (int) hopper.getLevelY() + (int) hopper.getLevelZ();
+
+ return (hopper.getAndIncrementAttemptCounter() + hopperId) % suckInterval == 0;
+ }
+ // Gale end - EMC - reduce hopper item checks
+
@Override
public double getLevelX() {
return this.worldPosition.getX() + 0.5;

View File

@@ -0,0 +1,42 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Thu, 24 Nov 2022 23:15:49 +0100
Subject: [PATCH] Reduce villager item re-pickup
License: MIT (https://opensource.org/licenses/MIT)
Gale - https://galemc.org
This patch is based on the following patch:
"Slow down villager pickup of thrown items"
By: Aikar <aikar@aikar.co>
As part of: EmpireCraft (https://github.com/starlis/empirecraft)
Licensed under: MIT (https://opensource.org/licenses/MIT)
* EmpireCraft description *
Helps 1.8 Farms let hoppers pick it up before Villager
due to our hopper changes
diff --git a/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java b/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java
index 2664d72c3b6906d0505df2e63c0e5075eba9461b..e7f74b4f54069ffdf74f029639cbf0756f2db095 100644
--- a/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java
+++ b/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java
@@ -87,7 +87,17 @@ public class BehaviorUtils {
Vec3 vec3 = offset.subtract(entity.position());
vec3 = vec3.normalize().multiply(speedMultiplier.x, speedMultiplier.y, speedMultiplier.z);
itemEntity.setDeltaMovement(vec3);
- itemEntity.setDefaultPickUpDelay();
+ // Gale start - EMC - reduce villager item re-pickup
+ if (entity instanceof net.minecraft.world.entity.npc.Villager) {
+ int repickupDelay = entity.level().galeConfig().smallOptimizations.reducedIntervals.villagerItemRepickup;
+
+ if (repickupDelay <= -1) {
+ itemEntity.setDefaultPickUpDelay();
+ } else {
+ itemEntity.pickupDelay = repickupDelay;
+ }
+ }
+ // Gale end - EMC - reduce villager item re-pickup
// CraftBukkit start
org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(entity.getBukkitEntity(), (org.bukkit.entity.Item) itemEntity.getBukkitEntity());
itemEntity.level().getCraftServer().getPluginManager().callEvent(event);

View File

@@ -0,0 +1,58 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Wed, 22 Mar 2023 00:18:15 +0100
Subject: [PATCH] Variable entity wake-up duration
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
Gale - https://galemc.org
diff --git a/io/papermc/paper/entity/activation/ActivationRange.java b/io/papermc/paper/entity/activation/ActivationRange.java
index 602ed4c5556723e54a80ccc3481af31109d5a0a6..bdbbbc5e0c06c71584e7514623d0c8be168befd7 100644
--- a/io/papermc/paper/entity/activation/ActivationRange.java
+++ b/io/papermc/paper/entity/activation/ActivationRange.java
@@ -53,27 +53,41 @@ public final class ActivationRange {
if (entity.activationType == ActivationType.VILLAGER) {
if (inactiveFor > config.wakeUpInactiveVillagersEvery && world.wakeupInactiveRemainingVillagers > 0) {
world.wakeupInactiveRemainingVillagers--;
- return config.wakeUpInactiveVillagersFor;
+ return getWakeUpDurationWithVariance(entity, config.wakeUpInactiveVillagersFor); // Gale - variable entity wake-up duration
}
} else if (entity.activationType == ActivationType.ANIMAL) {
if (inactiveFor > config.wakeUpInactiveAnimalsEvery && world.wakeupInactiveRemainingAnimals > 0) {
world.wakeupInactiveRemainingAnimals--;
- return config.wakeUpInactiveAnimalsFor;
+ return getWakeUpDurationWithVariance(entity, config.wakeUpInactiveAnimalsFor); // Gale - variable entity wake-up duration
}
} else if (entity.activationType == ActivationType.FLYING_MONSTER) {
if (inactiveFor > config.wakeUpInactiveFlyingEvery && world.wakeupInactiveRemainingFlying > 0) {
world.wakeupInactiveRemainingFlying--;
- return config.wakeUpInactiveFlyingFor;
+ return getWakeUpDurationWithVariance(entity, config.wakeUpInactiveFlyingFor); // Gale - variable entity wake-up duration
}
} else if (entity.activationType == ActivationType.MONSTER || entity.activationType == ActivationType.RAIDER) {
if (inactiveFor > config.wakeUpInactiveMonstersEvery && world.wakeupInactiveRemainingMonsters > 0) {
world.wakeupInactiveRemainingMonsters--;
- return config.wakeUpInactiveMonstersFor;
+ return getWakeUpDurationWithVariance(entity, config.wakeUpInactiveMonstersFor); // Gale - variable entity wake-up duration
}
}
return -1;
}
+ // Gale start - variable entity wake-up duration
+ private static final java.util.Random wakeUpDurationRandom = new java.util.Random();
+
+ private static int getWakeUpDurationWithVariance(Entity entity, int wakeUpDuration) {
+ double deviation = entity.level().galeConfig().gameplayMechanics.entityWakeUpDurationRatioStandardDeviation;
+
+ if (deviation <= 0) {
+ return wakeUpDuration;
+ }
+
+ return (int) Math.min(Integer.MAX_VALUE, Math.max(1, Math.round(wakeUpDuration * wakeUpDurationRandom.nextGaussian(1, deviation))));
+ }
+ // Gale end - variable entity wake-up duration
+
static AABB maxBB = new AABB(0, 0, 0, 0, 0, 0);
/**

View File

@@ -0,0 +1,52 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Tue, 29 Nov 2022 15:33:32 +0100
Subject: [PATCH] Do not process chat/commands before player has joined
License: MIT (https://opensource.org/licenses/MIT)
Gale - https://galemc.org
This patch is based on the following patch:
"Do not process chat/commands before player has joined"
By: chickeneer <emcchickeneer@gmail.com>
As part of: EmpireCraft (https://github.com/starlis/empirecraft)
Licensed under: MIT (https://opensource.org/licenses/MIT)
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
index 20b6cfe278f2bd87dfe2cbf7befef745d36bb845..4973de0813f07d657a1e7b1930af7ab583a39f65 100644
--- a/net/minecraft/server/level/ServerPlayer.java
+++ b/net/minecraft/server/level/ServerPlayer.java
@@ -416,6 +416,7 @@ public class ServerPlayer extends Player {
public boolean sentListPacket = false;
public boolean supressTrackerForLogin = false; // Paper - Fire PlayerJoinEvent when Player is actually ready
// CraftBukkit end
+ public boolean didPlayerJoinEvent = false; // Gale - EMC - do not process chat/commands before player has joined
public boolean isRealPlayer; // Paper
public @Nullable com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent
public @Nullable String clientBrandName = null; // Paper - Brand support
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index df7142bbfec170966373dcf4ac50e4bbc5ba4e53..dea2a849a1d1f2dcfc1e63eb873ada999780bf66 100644
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -2334,7 +2334,7 @@ public class ServerGamePacketListenerImpl
this.disconnectAsync(Component.translatable("multiplayer.disconnect.illegal_characters"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_CHARACTERS); // Paper - add proper async disconnect
} else if (this.player.isRemoved() || this.player.getChatVisibility() == ChatVisiblity.HIDDEN) { // CraftBukkit - dead men tell no tales
this.send(new ClientboundSystemChatPacket(Component.translatable("chat.disabled.options").withStyle(ChatFormatting.RED), false));
- } else {
+ } else if (player.didPlayerJoinEvent) { // Gale - EMC - do not process chat/commands before player has joined
this.player.resetLastActionTime();
// CraftBukkit start
if (sync) {
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
index 48eae4ea5999aee4faa5b24a72e7b0b51c598fc8..2726f72c86368fe804dce43dc6c337bfe213cc58 100644
--- a/net/minecraft/server/players/PlayerList.java
+++ b/net/minecraft/server/players/PlayerList.java
@@ -334,6 +334,8 @@ public abstract class PlayerList {
return;
}
+ player.didPlayerJoinEvent = true; // Gale - EMC - do not process chat/commands before player has joined
+
final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage();
if (jm != null && !jm.equals(net.kyori.adventure.text.Component.empty())) { // Paper - Adventure

View File

@@ -0,0 +1,40 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Thu, 24 Nov 2022 23:39:32 +0100
Subject: [PATCH] Do not log invalid statistics
License: MIT (https://opensource.org/licenses/MIT)
Gale - https://galemc.org
This patch is based on the following patch:
"Ignore statistics warnings"
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/net/minecraft/stats/ServerStatsCounter.java b/net/minecraft/stats/ServerStatsCounter.java
index b147df7479da03fae19294587cded62c210ea590..dfaead7716ac718bcdbf4c3021aed1b57676af50 100644
--- a/net/minecraft/stats/ServerStatsCounter.java
+++ b/net/minecraft/stats/ServerStatsCounter.java
@@ -117,16 +117,18 @@ public class ServerStatsCounter extends StatsCounter {
this.stats
.putAll(
STATS_CODEC.parse(dynamic.get("stats").orElseEmptyMap())
- .resultOrPartial(string -> LOGGER.error("Failed to parse statistics for {}: {}", this.file, string))
+ .resultOrPartial(string -> {
+ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.invalidStatistics) LOGGER.error("Failed to parse statistics for {}: {}", this.file, string); // Gale - EMC - do not log invalid statistics
+ })
.orElse(Map.of())
);
return;
}
- LOGGER.error("Unable to parse Stat data from {}", this.file);
+ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.invalidStatistics) LOGGER.error("Unable to parse Stat data from {}", this.file); // Gale - EMC - do not log invalid statistics
}
} catch (IOException | JsonParseException var8) {
- LOGGER.error("Unable to parse Stat data from {}", this.file, var8);
+ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.invalidStatistics) LOGGER.error("Unable to parse Stat data from {}", this.file, var8); // Gale - EMC - do not log invalid statistics
}
}

View File

@@ -0,0 +1,21 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Thu, 24 Nov 2022 23:45:57 +0100
Subject: [PATCH] Do not log empty message warnings
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
Gale - https://galemc.org
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index dea2a849a1d1f2dcfc1e63eb873ada999780bf66..804afc38f2be37258ee68d601674a2832b61bfc6 100644
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -2416,7 +2416,7 @@ public class ServerGamePacketListenerImpl
// CraftBukkit start
String rawMessage = message.signedContent();
if (rawMessage.isEmpty()) {
- LOGGER.warn("{} tried to send an empty message", this.player.getScoreboardName());
+ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.chat.emptyMessageWarning) LOGGER.warn("{} tried to send an empty message", this.player.getScoreboardName()); // Gale - do not log empty message warnings
} else if (this.getCraftPlayer().isConversing()) {
final String conversationInput = rawMessage;
this.server.processQueue.add(() -> ServerGamePacketListenerImpl.this.getCraftPlayer().acceptConversationInput(conversationInput));

View File

@@ -0,0 +1,51 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Fri, 25 Nov 2022 13:18:54 +0100
Subject: [PATCH] Do not log ignored advancements
License: MIT (https://opensource.org/licenses/MIT)
Gale - https://galemc.org
This patch is based on the following patch:
"Logger settings (suppressing pointless logs)"
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/net/minecraft/server/PlayerAdvancements.java b/net/minecraft/server/PlayerAdvancements.java
index 52e0ae233a7b1c88bfbbc27707ef5f18453ec865..741894ed6df81fce41d9f906d6198d038aab44a8 100644
--- a/net/minecraft/server/PlayerAdvancements.java
+++ b/net/minecraft/server/PlayerAdvancements.java
@@ -148,7 +148,7 @@ public class PlayerAdvancements {
AdvancementHolder advancementHolder = advancementManager.get(path);
if (advancementHolder == null) {
if (!path.getNamespace().equals(ResourceLocation.DEFAULT_NAMESPACE)) return; // CraftBukkit
- LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", path, this.playerSavePath);
+ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.ignoredAdvancements) LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", path, this.playerSavePath); // Gale - Purpur - do not log ignored advancements
} else {
this.startProgress(advancementHolder, progress);
this.progressChanged.add(advancementHolder);

View File

@@ -0,0 +1,51 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Fri, 25 Nov 2022 13:28:38 +0100
Subject: [PATCH] Do not log setBlock in far chunks
License: MIT (https://opensource.org/licenses/MIT)
Gale - https://galemc.org
This patch is based on the following patch:
"Logger settings (suppressing pointless logs)"
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/net/minecraft/server/level/WorldGenRegion.java b/net/minecraft/server/level/WorldGenRegion.java
index b30f56fbc1fd17259a1d05dc9155fffcab292ca1..1aa26a70177e4ecf9d859fca44adc6a96b853c30 100644
--- a/net/minecraft/server/level/WorldGenRegion.java
+++ b/net/minecraft/server/level/WorldGenRegion.java
@@ -284,7 +284,7 @@ public class WorldGenRegion implements WorldGenLevel {
return true;
} else {
// Paper start - Buffer OOB setBlock calls
- if (!hasSetFarWarned) {
+ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.setBlockInFarChunk && !hasSetFarWarned) { // Gale - Purpur - do not log setBlock in far chunks
Util.logAndPauseIfInIde(
"Detected setBlock in a far chunk ["
+ sectionPosX

View File

@@ -0,0 +1,51 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Fri, 25 Nov 2022 15:01:30 +0100
Subject: [PATCH] Do not log unrecognized recipes
License: MIT (https://opensource.org/licenses/MIT)
Gale - https://galemc.org
This patch is based on the following patch:
"Logger settings (suppressing pointless logs)"
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/net/minecraft/stats/ServerRecipeBook.java b/net/minecraft/stats/ServerRecipeBook.java
index 2158b20458de63897131db3d425d1efcc358cace..40944806284921bd084901c94595fefa78b2c20b 100644
--- a/net/minecraft/stats/ServerRecipeBook.java
+++ b/net/minecraft/stats/ServerRecipeBook.java
@@ -133,7 +133,7 @@ public class ServerRecipeBook extends RecipeBook {
private void loadRecipes(List<ResourceKey<Recipe<?>>> recipes, Consumer<ResourceKey<Recipe<?>>> output, Predicate<ResourceKey<Recipe<?>>> isRecognized) {
for (ResourceKey<Recipe<?>> resourceKey : recipes) {
if (!isRecognized.test(resourceKey)) {
- LOGGER.error("Tried to load unrecognized recipe: {} removed now.", resourceKey);
+ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.unrecognizedRecipes) LOGGER.error("Tried to load unrecognized recipe: {} removed now.", resourceKey); // Gale - Purpur - do not log unrecognized recipes
} else {
output.accept(resourceKey);
}

View File

@@ -0,0 +1,21 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Fri, 25 Nov 2022 15:07:55 +0100
Subject: [PATCH] Do not log expired message warnings
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
Gale - https://galemc.org
diff --git a/net/minecraft/network/chat/SignedMessageChain.java b/net/minecraft/network/chat/SignedMessageChain.java
index 23872fac07fa36f10ef090df2423c978998dcb99..44b166f5802468d7b1aefc8641496e0fefd6998f 100644
--- a/net/minecraft/network/chat/SignedMessageChain.java
+++ b/net/minecraft/network/chat/SignedMessageChain.java
@@ -56,7 +56,7 @@ public class SignedMessageChain {
throw new SignedMessageChain.DecodeException(SignedMessageChain.DecodeException.INVALID_SIGNATURE);
} else {
if (playerChatMessage.hasExpiredServer(Instant.now())) {
- SignedMessageChain.LOGGER.warn("Received expired chat: '{}'. Is the client/server system time unsynchronized?", body.content());
+ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.chat.expiredMessageWarning) SignedMessageChain.LOGGER.warn("Received expired chat: '{}'. Is the client/server system time unsynchronized?", body.content()); // Gale - do not log expired message warnings
}
SignedMessageChain.this.nextLink = signedMessageLink.advance();

View File

@@ -0,0 +1,21 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Fri, 25 Nov 2022 15:13:38 +0100
Subject: [PATCH] Do not log Not Secure marker
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
Gale - https://galemc.org
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
index 2726f72c86368fe804dce43dc6c337bfe213cc58..5abc0655ffc68ce81248467e7420051b2a2f0359 100644
--- a/net/minecraft/server/players/PlayerList.java
+++ b/net/minecraft/server/players/PlayerList.java
@@ -1252,7 +1252,7 @@ public abstract class PlayerList {
public void broadcastChatMessage(PlayerChatMessage message, Predicate<ServerPlayer> shouldFilterMessageTo, @Nullable ServerPlayer sender, ChatType.Bound boundChatType, @Nullable Function<net.kyori.adventure.audience.Audience, Component> unsignedFunction) {
// Paper end
boolean flag = this.verifyChatTrusted(message);
- this.server.logChatMessage((unsignedFunction == null ? message.decoratedContent() : unsignedFunction.apply(this.server.console)), boundChatType, flag ? null : "Not Secure"); // Paper
+ this.server.logChatMessage((unsignedFunction == null ? message.decoratedContent() : unsignedFunction.apply(this.server.console)), boundChatType, flag || !org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.chat.notSecureMarker ? null : "Not Secure"); // Paper // Gale - do not log Not Secure marker
OutgoingChatMessage outgoingChatMessage = OutgoingChatMessage.create(message);
boolean flag1 = false;

View File

@@ -0,0 +1,38 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Sat, 29 Jul 2023 11:20:35 +0200
Subject: [PATCH] Do not log disconnections with null id
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:
"Add option to suppress null ID disconnections"
By: Kevin Raneri <kevin.raneri@gmail.com>
As part of: Pufferfish (https://github.com/pufferfish-gg/Pufferfish)
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
* Pufferfish description *
This can help to hide annoying scanning bots from showing up in console.
diff --git a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index 7950f4f88d8a83ed5610b7af4e134557d32da3f0..27fa7bbfc64dd103b7cd1c1216482af3719e3dbb 100644
--- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -145,6 +145,15 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
public void disconnect(Component reason) {
try {
+ // Gale start - Pufferfish - do not log disconnections with null id
+ if (!org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.nullIdDisconnections && this.authenticatedProfile != null && this.authenticatedProfile.getId() == null) {
+ var reasonString = reason.getString();
+
+ if ("Disconnected".equals(reasonString) || Component.translatable("multiplayer.disconnect.generic").getString().equals(reasonString)) {
+ return;
+ }
+ }
+ // Gale end - Pufferfish - do not log disconnections with null id
LOGGER.info("Disconnecting {}: {}", this.getUserName(), reason.getString());
this.connection.send(new ClientboundLoginDisconnectPacket(reason));
this.connection.disconnect(reason);

View File

@@ -0,0 +1,55 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Thu, 1 Dec 2022 16:43:50 +0100
Subject: [PATCH] Do not log run as root warning
License: MIT (https://opensource.org/licenses/MIT)
Gale - https://galemc.org
This patch is based on the following patch:
"Options of warnings"
By: nostalgic853 <yuu8583@proton.me>
As part of: KeYi (https://github.com/MC-Multithreading-Lab/KeYi-MT)
Licensed under: MIT (https://opensource.org/licenses/MIT)
* KeYi description *
Let users decide if we should warn while running in a root user
* KeYi copyright *
MIT License
Copyright (c) 2022 KeYiMC
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/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java
index a86ede54cfeb416a8c0c85fe90862e65e6505b62..65fa22ea82076542d42d651227e5332692981cc3 100644
--- a/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/net/minecraft/server/dedicated/DedicatedServer.java
@@ -142,7 +142,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
}
// Paper start - detect running as root
- if (io.papermc.paper.util.ServerEnvironment.userIsRootOrAdmin()) {
+ if (!"false".equalsIgnoreCase(System.getProperty("gale.log.warning.root")) && io.papermc.paper.util.ServerEnvironment.userIsRootOrAdmin()) { // Gale - KeYi - do not log run as root warning
LOGGER.warn("****************************");
LOGGER.warn("YOU ARE RUNNING THIS SERVER AS AN ADMINISTRATIVE OR ROOT USER. THIS IS NOT ADVISED.");
LOGGER.warn("YOU ARE OPENING YOURSELF UP TO POTENTIAL RISKS WHEN DOING THIS.");

View File

@@ -0,0 +1,55 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Thu, 1 Dec 2022 16:52:27 +0100
Subject: [PATCH] Do not log offline mode warning
License: MIT (https://opensource.org/licenses/MIT)
Gale - https://galemc.org
This patch is based on the following patch:
"Options of warnings"
By: nostalgic853 <yuu8583@proton.me>
As part of: KeYi (https://github.com/MC-Multithreading-Lab/KeYi-MT)
Licensed under: MIT (https://opensource.org/licenses/MIT)
* KeYi description *
Let users decide if we should warn while running in offline mode
* KeYi copyright *
MIT License
Copyright (c) 2022 KeYiMC
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/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java
index 65fa22ea82076542d42d651227e5332692981cc3..a880ace4cfc64ea8359f08938f20294ec936ba9c 100644
--- a/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/net/minecraft/server/dedicated/DedicatedServer.java
@@ -253,7 +253,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
String proxyFlavor = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "Velocity" : "BungeeCord";
String proxyLink = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "https://docs.papermc.io/velocity/security" : "http://www.spigotmc.org/wiki/firewall-guide/";
// Paper end - Add Velocity IP Forwarding Support
- if (!this.usesAuthentication()) {
+ if (!"false".equalsIgnoreCase(System.getProperty("gale.log.warning.offline.mode")) && !this.usesAuthentication()) { // Gale - KeYi - do not log offline mode warning
LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
LOGGER.warn("The server will make no attempt to authenticate usernames. Beware.");
// Spigot start

View File

@@ -0,0 +1,51 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Tue, 29 Nov 2022 15:50:22 +0100
Subject: [PATCH] Fix 'outdated server' showing in ping before server fully
boots
License: MIT (https://opensource.org/licenses/MIT)
Gale - https://galemc.org
This patch is based on the following patch:
"Fix 'outdated server' showing in ping before server fully boots"
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/net/minecraft/server/network/ServerStatusPacketListenerImpl.java b/net/minecraft/server/network/ServerStatusPacketListenerImpl.java
index 465559113071a47e706f77a5b0996597ee986b3d..74f698da88ed6432bee3105d3c35648b6f38f234 100644
--- a/net/minecraft/server/network/ServerStatusPacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerStatusPacketListenerImpl.java
@@ -37,6 +37,7 @@ public class ServerStatusPacketListenerImpl implements ServerStatusPacketListene
} else {
this.hasRequestedStatus = true;
// this.connection.send(new ClientboundStatusResponsePacket(this.status)); // Paper
+ if (net.minecraft.server.MinecraftServer.getServer().getStatus().version().isEmpty()) return; // Gale - Purpur - fix 'outdated server' showing in ping before server fully boots - do not respond to pings before we know the protocol version
com.destroystokyo.paper.network.StandardPaperServerListPingEventImpl.processRequest(net.minecraft.server.MinecraftServer.getServer(), this.connection); // Paper - handle status request
}
}

View File

@@ -0,0 +1,56 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Tue, 29 Nov 2022 16:16:35 +0100
Subject: [PATCH] Fix MC-238526
License: MIT (https://opensource.org/licenses/MIT)
Gale - https://galemc.org
This patch is based on the following patch:
"MC-238526 - Fix spawner not spawning water animals correctly"
By: BillyGalbreath <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/net/minecraft/world/entity/animal/WaterAnimal.java b/net/minecraft/world/entity/animal/WaterAnimal.java
index 2b5e091b6ebe17e30d8d0e73999e19eed49e9a9f..ace8766a3640106cf471883029fa6a6272a890e7 100644
--- a/net/minecraft/world/entity/animal/WaterAnimal.java
+++ b/net/minecraft/world/entity/animal/WaterAnimal.java
@@ -76,8 +76,11 @@ public abstract class WaterAnimal extends PathfinderMob {
seaLevel = level.getMinecraftWorld().paperConfig().entities.spawning.wateranimalSpawnHeight.maximum.or(seaLevel);
i = level.getMinecraftWorld().paperConfig().entities.spawning.wateranimalSpawnHeight.minimum.or(i);
// Paper end - Make water animal spawn height configurable
- return pos.getY() >= i
- && pos.getY() <= seaLevel
+ // Gale start - Purpur - fix MC-238526
+ boolean shouldFixMC238526 = spawnReason == EntitySpawnReason.SPAWNER && level.getMinecraftWorld().galeConfig().gameplayMechanics.fixes.mc238526;
+ boolean isAllowedHeight = pos.getY() >= i && pos.getY() <= seaLevel;
+ return (shouldFixMC238526 || isAllowedHeight)
+ // Gale end - Purpur - fix MC-238526
&& level.getFluidState(pos.below()).is(FluidTags.WATER)
&& level.getBlockState(pos.above()).is(Blocks.WATER);
}

View File

@@ -0,0 +1,67 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Tue, 29 Nov 2022 16:42:48 +0100
Subject: [PATCH] Fix MC-121706
License: MIT (https://opensource.org/licenses/MIT)
Gale - https://galemc.org
This patch is based on the following patch:
"MC-121706 - Fix mobs not looking up and down when strafing"
By: Krakenied <Krakenied1@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/net/minecraft/world/entity/ai/goal/RangedBowAttackGoal.java b/net/minecraft/world/entity/ai/goal/RangedBowAttackGoal.java
index 722f378bb3726200b6fe88948bf1e1d3514a7b5c..b896f13f5aea09dafb1f1e74e1ef90dc53eae2ae 100644
--- a/net/minecraft/world/entity/ai/goal/RangedBowAttackGoal.java
+++ b/net/minecraft/world/entity/ai/goal/RangedBowAttackGoal.java
@@ -103,7 +103,11 @@ public class RangedBowAttackGoal<T extends Monster & RangedAttackMob> extends Go
this.strafingTime = 0;
}
- if (this.strafingTime > -1) {
+ // Gale start - Purpur - fix MC-121706
+ boolean hasStrafingTime = this.strafingTime > -1;
+
+ if (hasStrafingTime) {
+ // Gale end - Purpur - fix MC-121706
if (d > this.attackRadiusSqr * 0.75F) {
this.strafingBackwards = false;
} else if (d < this.attackRadiusSqr * 0.25F) {
@@ -116,7 +120,10 @@ public class RangedBowAttackGoal<T extends Monster & RangedAttackMob> extends Go
}
this.mob.lookAt(target, 30.0F, 30.0F);
- } else {
+ // Gale start - Purpur - fix MC-121706
+ }
+ if (!hasStrafingTime || this.mob.level().galeConfig().gameplayMechanics.fixes.mc121706) {
+ // Gale end - Purpur - fix MC-121706
this.mob.getLookControl().setLookAt(target, 30.0F, 30.0F);
}

View File

@@ -0,0 +1,56 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Tue, 29 Nov 2022 21:37:22 +0100
Subject: [PATCH] Make arrow movement resetting despawn counter configurable
License: MIT (https://opensource.org/licenses/MIT)
Gale - https://galemc.org
This patch is based on the following patch:
"Arrows should not reset despawn counter"
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 description *
This prevents keeping arrows alive indefinitely (such as when the block
the arrow is stuck in gets removed, like a piston head going up/down)
* 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/net/minecraft/world/entity/projectile/AbstractArrow.java b/net/minecraft/world/entity/projectile/AbstractArrow.java
index 595cdb7d013eb0b9282b133a22f51ee865d18623..b8f04b98d2117cfb274a5888d34b9836d3390ae9 100644
--- a/net/minecraft/world/entity/projectile/AbstractArrow.java
+++ b/net/minecraft/world/entity/projectile/AbstractArrow.java
@@ -352,7 +352,7 @@ public abstract class AbstractArrow extends Projectile {
this.setInGround(false);
Vec3 deltaMovement = this.getDeltaMovement();
this.setDeltaMovement(deltaMovement.multiply(this.random.nextFloat() * 0.2F, this.random.nextFloat() * 0.2F, this.random.nextFloat() * 0.2F));
- this.life = 0;
+ if (this.level().galeConfig().gameplayMechanics.arrowMovementResetsDespawnCounter) this.life = 0; // Gale - Purpur - make arrow movement resetting despawn counter configurable
}
public boolean isInGround() {

View File

@@ -0,0 +1,32 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Mon, 26 Dec 2022 00:17:40 +0100
Subject: [PATCH] Make logging login locations configurable
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:
"configurable logging of player login location"
By: Simon Gardling <titaniumtown@gmail.com>
As part of: JettPack (https://gitlab.com/Titaniumtown/JettPack)
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
index 5abc0655ffc68ce81248467e7420051b2a2f0359..029003ccbd4820b60369894b2c3d4bd47f697d93 100644
--- a/net/minecraft/server/players/PlayerList.java
+++ b/net/minecraft/server/players/PlayerList.java
@@ -402,7 +402,13 @@ public abstract class PlayerList {
scoreboard.addPlayerToTeam(player.getScoreboardName(), collideRuleTeam);
}
// Paper end - Configurable player collision
+ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.playerLoginLocations) { // Gale - JettPack - make logging login location configurable
PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", player.getName().getString(), loggableAddress, player.getId(), serverLevel.serverLevelData.getLevelName(), player.getX(), player.getY(), player.getZ());
+ // Gale start - JettPack - make logging login location configurable
+ } else {
+ PlayerList.LOGGER.info("{}[{}] logged in with entity id {}", player.getName().getString(), loggableAddress, player.getId());
+ }
+ // Gale end - JettPack - make logging login location configurable
// Paper start - Send empty chunk, so players aren't stuck in the world loading screen with our chunk system not sending chunks when dead
if (player.isDeadOrDying()) {
net.minecraft.core.Holder<net.minecraft.world.level.biome.Biome> plains = serverLevel.registryAccess().lookupOrThrow(net.minecraft.core.registries.Registries.BIOME)

View File

@@ -0,0 +1,235 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Sat, 26 Nov 2022 11:25:45 +0100
Subject: [PATCH] Reduce array allocations
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 allocs"
By: Simon Gardling <titaniumtown@gmail.com>
As part of: JettPack (https://gitlab.com/Titaniumtown/JettPack)
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
diff --git a/net/minecraft/nbt/ByteArrayTag.java b/net/minecraft/nbt/ByteArrayTag.java
index 6fbb131b472a3093b137d8ced9889777a133bd5b..cecfd48f57bc11b84c18b4e5a723228fd3c18e23 100644
--- a/net/minecraft/nbt/ByteArrayTag.java
+++ b/net/minecraft/nbt/ByteArrayTag.java
@@ -144,7 +144,7 @@ public final class ByteArrayTag implements CollectionTag {
@Override
public void clear() {
- this.data = new byte[0];
+ this.data = me.titaniumtown.ArrayConstants.emptyByteArray; // Gale - JettPack - reduce array allocations
}
@Override
diff --git a/net/minecraft/nbt/IntArrayTag.java b/net/minecraft/nbt/IntArrayTag.java
index a8ea2aeb5a02903a37376fb78b49c10745147411..e50bbf1318e9f16f83723eab1389c189baf840a2 100644
--- a/net/minecraft/nbt/IntArrayTag.java
+++ b/net/minecraft/nbt/IntArrayTag.java
@@ -151,7 +151,7 @@ public final class IntArrayTag implements CollectionTag {
@Override
public void clear() {
- this.data = new int[0];
+ this.data = me.titaniumtown.ArrayConstants.emptyIntArray; // Gale - JettPack - reduce array allocations
}
@Override
diff --git a/net/minecraft/nbt/LongArrayTag.java b/net/minecraft/nbt/LongArrayTag.java
index c90024aecb4b2424b3ef37194b0686734ab43db9..fd8a4bfe065698ea320800bc2b22474b1c5c4ca9 100644
--- a/net/minecraft/nbt/LongArrayTag.java
+++ b/net/minecraft/nbt/LongArrayTag.java
@@ -150,7 +150,7 @@ public final class LongArrayTag implements CollectionTag {
@Override
public void clear() {
- this.data = new long[0];
+ this.data = me.titaniumtown.ArrayConstants.emptyLongArray; // Gale - JettPack - reduce array allocations
}
@Override
diff --git a/net/minecraft/network/CipherBase.java b/net/minecraft/network/CipherBase.java
index 121685cacef111fbec0057d386f748497bc3a36d..b4a4fafec1a8e279ec1e31e58fee2d5d34fb8289 100644
--- a/net/minecraft/network/CipherBase.java
+++ b/net/minecraft/network/CipherBase.java
@@ -7,8 +7,8 @@ import javax.crypto.ShortBufferException;
public class CipherBase {
private final Cipher cipher;
- private byte[] heapIn = new byte[0];
- private byte[] heapOut = new byte[0];
+ private byte[] heapIn = me.titaniumtown.ArrayConstants.emptyByteArray; // Gale - JettPack - reduce array allocations
+ private byte[] heapOut = me.titaniumtown.ArrayConstants.emptyByteArray; // Gale - JettPack - reduce array allocations
protected CipherBase(Cipher cipher) {
this.cipher = cipher;
diff --git a/net/minecraft/network/chat/contents/TranslatableContents.java b/net/minecraft/network/chat/contents/TranslatableContents.java
index 8ef16f98996b1ec0c9c3f158248ac95f1b07328f..6780b2493d625603b74e635c4996bb8303ce5b9a 100644
--- a/net/minecraft/network/chat/contents/TranslatableContents.java
+++ b/net/minecraft/network/chat/contents/TranslatableContents.java
@@ -29,7 +29,7 @@ import net.minecraft.util.ExtraCodecs;
import net.minecraft.world.entity.Entity;
public class TranslatableContents implements ComponentContents {
- public static final Object[] NO_ARGS = new Object[0];
+ public static final Object[] NO_ARGS = me.titaniumtown.ArrayConstants.emptyObjectArray; // Gale - JettPack - reduce array allocations
private static final Codec<Object> PRIMITIVE_ARG_CODEC = ExtraCodecs.JAVA.validate(TranslatableContents::filterAllowedArguments);
private static final Codec<Object> ARG_CODEC = Codec.either(PRIMITIVE_ARG_CODEC, ComponentSerialization.CODEC)
.xmap(
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index 679c94142eac06ec0bc6f3b819ee4f7e831c4626..0d8fe6a658c1ad15f6243af5d2562505c41e3e8d 100644
--- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java
@@ -937,7 +937,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
public static List<Entity> getCurrentlyTickingEntities() {
Entity ticking = currentlyTickingEntity.get();
- List<Entity> ret = java.util.Arrays.asList(ticking == null ? new Entity[0] : new Entity[] { ticking });
+ List<Entity> ret = java.util.Arrays.asList(ticking == null ? me.titaniumtown.ArrayConstants.emptyEntityArray : new Entity[] { ticking }); // Gale - JettPack - reduce array allocations
return ret;
}
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 804afc38f2be37258ee68d601674a2832b61bfc6..7142de40a5ff9d1009bb06e73172877e8bf80962 100644
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -2706,7 +2706,7 @@ public class ServerGamePacketListenerImpl
// SPIGOT-7136 - Allays
if (target instanceof net.minecraft.world.entity.animal.allay.Allay || target instanceof net.minecraft.world.entity.animal.horse.AbstractHorse) { // Paper - Fix horse armor desync
ServerGamePacketListenerImpl.this.send(new net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket(
- target.getId(), java.util.Arrays.stream(net.minecraft.world.entity.EquipmentSlot.values())
+ target.getId(), java.util.Arrays.stream(net.minecraft.world.entity.EquipmentSlot.VALUES_ARRAY) // Gale - JettPack - reduce array allocations
.map((slot) -> com.mojang.datafixers.util.Pair.of(slot, ((LivingEntity) target).getItemBySlot(slot).copy()))
.collect(Collectors.toList()), true)); // Paper - sanitize
}
diff --git a/net/minecraft/server/players/StoredUserList.java b/net/minecraft/server/players/StoredUserList.java
index d445e8f126f077d8419c52fa5436ea963a1a42a4..39483f7b453d6faedeccc1ab1eda76669395ea5a 100644
--- a/net/minecraft/server/players/StoredUserList.java
+++ b/net/minecraft/server/players/StoredUserList.java
@@ -70,7 +70,7 @@ public abstract class StoredUserList<K, V extends StoredUserEntry<K>> {
}
public String[] getUserList() {
- return this.map.keySet().toArray(new String[0]);
+ return this.map.keySet().toArray(me.titaniumtown.ArrayConstants.emptyStringArray); // Gale - JettPack - reduce array allocations
}
public boolean isEmpty() {
diff --git a/net/minecraft/util/ZeroBitStorage.java b/net/minecraft/util/ZeroBitStorage.java
index 8cc5c0716392ba06501542ff5cbe71ee43979e5d..64945449807e49115b9115ee114cd3acad3d1ef8 100644
--- a/net/minecraft/util/ZeroBitStorage.java
+++ b/net/minecraft/util/ZeroBitStorage.java
@@ -5,7 +5,7 @@ import java.util.function.IntConsumer;
import org.apache.commons.lang3.Validate;
public class ZeroBitStorage implements BitStorage {
- public static final long[] RAW = new long[0];
+ public static final long[] RAW = me.titaniumtown.ArrayConstants.emptyLongArray; // Gale - JettPack - reduce array allocations
private final int size;
public ZeroBitStorage(int size) {
diff --git a/net/minecraft/world/entity/EquipmentSlot.java b/net/minecraft/world/entity/EquipmentSlot.java
index 0e44397c9d53ff30a96c9e8e392a363fa9ae0c55..dbf31389f0e9796c80afbffddf6a20cbaf184e6e 100644
--- a/net/minecraft/world/entity/EquipmentSlot.java
+++ b/net/minecraft/world/entity/EquipmentSlot.java
@@ -20,9 +20,12 @@ public enum EquipmentSlot implements StringRepresentable {
SADDLE(EquipmentSlot.Type.SADDLE, 0, 1, 7, "saddle");
public static final int NO_COUNT_LIMIT = 0;
- public static final List<EquipmentSlot> VALUES = List.of(values());
- public static final IntFunction<EquipmentSlot> BY_ID = ByIdMap.continuous(equipmentSlot -> equipmentSlot.id, values(), ByIdMap.OutOfBoundsStrategy.ZERO);
- public static final StringRepresentable.EnumCodec<EquipmentSlot> CODEC = StringRepresentable.fromEnum(EquipmentSlot::values);
+ // Gale start - JettPack - reduce array allocations
+ public static final EquipmentSlot[] VALUES_ARRAY = values();
+ public static final List<EquipmentSlot> VALUES = List.of(VALUES_ARRAY);
+ public static final IntFunction<EquipmentSlot> BY_ID = ByIdMap.continuous(equipmentSlot -> equipmentSlot.id, VALUES_ARRAY, ByIdMap.OutOfBoundsStrategy.ZERO);
+ public static final StringRepresentable.EnumCodec<EquipmentSlot> CODEC = StringRepresentable.fromEnum(() -> VALUES_ARRAY);
+ // Gale end - JettPack - reduce array allocations
public static final StreamCodec<ByteBuf, EquipmentSlot> STREAM_CODEC = ByteBufCodecs.idMapper(BY_ID, equipmentSlot -> equipmentSlot.id);
private final EquipmentSlot.Type type;
private final int index;
diff --git a/net/minecraft/world/entity/EquipmentSlotGroup.java b/net/minecraft/world/entity/EquipmentSlotGroup.java
index 381e0a1c0af7e339713ed1df1c2f21121c1bbd0f..4e847c3f9d761da5dda11dec60582d9d9e630b37 100644
--- a/net/minecraft/world/entity/EquipmentSlotGroup.java
+++ b/net/minecraft/world/entity/EquipmentSlotGroup.java
@@ -24,6 +24,7 @@ public enum EquipmentSlotGroup implements StringRepresentable, Iterable<Equipmen
BODY(9, "body", EquipmentSlot.BODY),
SADDLE(10, "saddle", EquipmentSlot.SADDLE);
+ public static final EquipmentSlotGroup[] VALUES_ARRAY = EquipmentSlotGroup.values(); // Gale - JettPack - reduce array allocations
public static final IntFunction<EquipmentSlotGroup> BY_ID = ByIdMap.continuous(
equipmentSlotGroup -> equipmentSlotGroup.id, values(), ByIdMap.OutOfBoundsStrategy.ZERO
);
diff --git a/net/minecraft/world/item/ItemStack.java b/net/minecraft/world/item/ItemStack.java
index c206187e2e4a3600681caadd4efd6293e42a9177..3958cd983242fc60c1868ce2a3ec804047d118c0 100644
--- a/net/minecraft/world/item/ItemStack.java
+++ b/net/minecraft/world/item/ItemStack.java
@@ -1168,7 +1168,7 @@ public final class ItemStack implements DataComponentHolder {
private void addAttributeTooltips(Consumer<Component> tooltipAdder, TooltipDisplay tooltipDisplay, @Nullable Player player) {
if (tooltipDisplay.shows(DataComponents.ATTRIBUTE_MODIFIERS)) {
- for (EquipmentSlotGroup equipmentSlotGroup : EquipmentSlotGroup.values()) {
+ for (EquipmentSlotGroup equipmentSlotGroup : EquipmentSlotGroup.VALUES_ARRAY) { // Gale - JettPack - reduce array allocations
MutableBoolean mutableBoolean = new MutableBoolean(true);
this.forEachModifier(equipmentSlotGroup, (attribute, modifier) -> {
if (mutableBoolean.isTrue()) {
diff --git a/net/minecraft/world/item/crafting/ShapedRecipePattern.java b/net/minecraft/world/item/crafting/ShapedRecipePattern.java
index bfda76974ea8d4397e2c2ebf5bdcb5d7e5f0bab5..cabbc93409ca99180d115e2f23419ee1824d5801 100644
--- a/net/minecraft/world/item/crafting/ShapedRecipePattern.java
+++ b/net/minecraft/world/item/crafting/ShapedRecipePattern.java
@@ -121,7 +121,7 @@ public final class ShapedRecipePattern {
}
if (pattern.size() == i3) {
- return new String[0];
+ return me.titaniumtown.ArrayConstants.emptyStringArray; // Gale - JettPack - reduce array allocations
} else {
String[] strings = new String[pattern.size() - i3 - i2];
diff --git a/net/minecraft/world/level/block/ComposterBlock.java b/net/minecraft/world/level/block/ComposterBlock.java
index a647d76d365a60b95a3eb7927ac426bf70d417f3..7977ecd013c55359f179b4b7f895099b7eb02294 100644
--- a/net/minecraft/world/level/block/ComposterBlock.java
+++ b/net/minecraft/world/level/block/ComposterBlock.java
@@ -419,7 +419,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
@Override
public int[] getSlotsForFace(Direction side) {
- return new int[0];
+ return me.titaniumtown.ArrayConstants.emptyIntArray; // Gale - JettPack - reduce array allocations
}
@Override
@@ -454,7 +454,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
@Override
public int[] getSlotsForFace(Direction side) {
- return side == Direction.UP ? new int[]{0} : new int[0];
+ return side == Direction.UP ? me.titaniumtown.ArrayConstants.zeroSingletonIntArray : me.titaniumtown.ArrayConstants.emptyIntArray; // Gale - JettPack - reduce array allocations
}
@Override
@@ -505,7 +505,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
@Override
public int[] getSlotsForFace(Direction side) {
- return side == Direction.DOWN ? new int[]{0} : new int[0];
+ return side == Direction.DOWN ? me.titaniumtown.ArrayConstants.zeroSingletonIntArray : me.titaniumtown.ArrayConstants.emptyIntArray; // Gale - JettPack - reduce array allocations
}
@Override
diff --git a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
index c5b3b5e5f621f8db152aa190374ae0fe567d6828..f6c3dac2a2a17760ab7015fe75c5a4dd04c11319 100644
--- a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
@@ -44,7 +44,7 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
protected static final int SLOT_FUEL = 1;
protected static final int SLOT_RESULT = 2;
public static final int DATA_LIT_TIME = 0;
- private static final int[] SLOTS_FOR_UP = new int[]{0};
+ private static final int[] SLOTS_FOR_UP = me.titaniumtown.ArrayConstants.zeroSingletonIntArray; // Gale - JettPack - reduce array allocations
private static final int[] SLOTS_FOR_DOWN = new int[]{2, 1};
private static final int[] SLOTS_FOR_SIDES = new int[]{1};
public static final int DATA_LIT_DURATION = 1;

View File

@@ -0,0 +1,85 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Wed, 30 Nov 2022 23:04:59 +0100
Subject: [PATCH] Optimize sun burn tick
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:
"some entity micro opts"
By: Simon Gardling <titaniumtown@gmail.com>
As part of: JettPack (https://gitlab.com/Titaniumtown/JettPack)
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index c3c480cb21f7f952cc09b36e24c462822b663b28..91185d7f8f2206fea9cb1d96611b8409f82694f2 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -1865,10 +1865,20 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@Deprecated
public float getLightLevelDependentMagicValue() {
+ return this.getLightLevelDependentMagicValue(BlockPos.containing(this.getX(), this.getEyeY(), this.getZ())); // Gale - JettPack - optimize sun burn tick - allow passing BlockPos to getLightLevelDependentMagicValue
+ }
+
+ // Gale start - JettPack - optimize sun burn tick - allow passing BlockPos to getLightLevelDependentMagicValue
+ /**
+ * @deprecated
+ */
+ @Deprecated
+ public float getLightLevelDependentMagicValue(BlockPos pos) {
return this.level().hasChunkAt(this.getBlockX(), this.getBlockZ())
- ? this.level().getLightLevelDependentMagicValue(BlockPos.containing(this.getX(), this.getEyeY(), this.getZ()))
+ ? this.level.getLightLevelDependentMagicValue(pos)
: 0.0F;
}
+ // Gale end - JettPack - optimize sun burn tick - allow passing BlockPos to getLightLevelDependentMagicValue
public void absSnapTo(double x, double y, double z, float yRot, float xRot) {
this.absSnapTo(x, y, z);
diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java
index 7f5981f71e6380c09e40a0c80db6a77e74d5113d..6cc000611dc58a5487034ad87af4156059dd37d7 100644
--- a/net/minecraft/world/entity/Mob.java
+++ b/net/minecraft/world/entity/Mob.java
@@ -1474,20 +1474,31 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
protected void playAttackSound() {
}
+ // Gale start - JettPack - optimize sun burn tick - cache eye blockpos
+ private BlockPos cached_eye_blockpos;
+ private net.minecraft.world.phys.Vec3 cached_position;
+ // Gale end - JettPack - optimize sun burn tick - cache eye blockpos
public boolean isSunBurnTick() {
if (this.level().isBrightOutside() && !this.level().isClientSide) {
- float lightLevelDependentMagicValue = this.getLightLevelDependentMagicValue();
- BlockPos blockPos = BlockPos.containing(this.getX(), this.getEyeY(), this.getZ());
- boolean flag = this.isInWaterOrRain() || this.isInPowderSnow || this.wasInPowderSnow;
- if (lightLevelDependentMagicValue > 0.5F
- && this.random.nextFloat() * 30.0F < (lightLevelDependentMagicValue - 0.4F) * 2.0F
- && !flag
- && this.level().canSeeSky(blockPos)) {
- return true;
+ // Gale start - JettPack - optimize sun burn tick - optimizations and cache eye blockpos
+ if (this.cached_position != this.position) {
+ this.cached_eye_blockpos = BlockPos.containing(this.getX(), this.getEyeY(), this.getZ());
+ this.cached_position = this.position;
}
+
+ float lightLevelDependentMagicValue = this.getLightLevelDependentMagicValue(cached_eye_blockpos); // Pass BlockPos to getBrightness
+
+ // Check brightness first
+ if (lightLevelDependentMagicValue <= 0.5F) return false;
+ if (this.random.nextFloat() * 30.0F >= (lightLevelDependentMagicValue - 0.4F) * 2.0F) return false;
+ // Gale end - JettPack - optimize sun burn tick - optimizations and cache eye blockpos
+
+ boolean flag = this.isInWaterOrRain() || this.isInPowderSnow || this.wasInPowderSnow;
+
+ return !flag && this.level().canSeeSky(this.cached_eye_blockpos); // Gale - JettPack - optimize sun burn tick - optimizations and cache eye blockpos
}
- return false;
+ return false; // Gale - JettPack - optimize sun burn tick - optimizations and cache eye blockpos - diff on change
}
@Override

View File

@@ -0,0 +1,42 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Sat, 26 Nov 2022 16:28:23 +0100
Subject: [PATCH] Reduce lambda and Optional allocation in
EntityBasedExplosionDamageCalculator
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/alloc/explosion_behavior/EntityBasedExplosionDamageCalculatorMixin.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/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java b/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java
index 52cb2dcd714cf8c16f167466333eeb923e4ff183..c6fabcfd373ee74e418e24e6913b0fa7364812eb 100644
--- a/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java
+++ b/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java
@@ -15,8 +15,20 @@ public class EntityBasedExplosionDamageCalculator extends ExplosionDamageCalcula
@Override
public Optional<Float> getBlockExplosionResistance(Explosion explosion, BlockGetter reader, BlockPos pos, BlockState state, FluidState fluid) {
- return super.getBlockExplosionResistance(explosion, reader, pos, state, fluid)
- .map(resistance -> this.source.getBlockExplosionResistance(explosion, reader, pos, state, fluid, resistance));
+ // Gale start - Lithium - reduce lambda and Optional allocation in EntityBasedExplosionDamageCalculator
+ Optional<Float> optionalBlastResistance = super.getBlockExplosionResistance(explosion, reader, pos, state, fluid);
+
+ if (optionalBlastResistance.isPresent()) {
+ float blastResistance = optionalBlastResistance.get();
+ float effectiveExplosionResistance = this.source.getBlockExplosionResistance(explosion, reader, pos, state, fluid, blastResistance);
+
+ if (effectiveExplosionResistance != blastResistance) {
+ return Optional.of(effectiveExplosionResistance);
+ }
+ }
+
+ return optionalBlastResistance;
+ // Gale end - Lithium - reduce lambda and Optional allocation in EntityBasedExplosionDamageCalculator
}
@Override

View File

@@ -0,0 +1,27 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Wed, 30 Nov 2022 17:35:06 +0100
Subject: [PATCH] Replace game rules map with optimized collection
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/collections/gamerules/GameRulesMixin.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/net/minecraft/world/level/GameRules.java b/net/minecraft/world/level/GameRules.java
index ea9ac158fcb98b90dfda997e3a1dfa34455f34a1..bceb900e2ceeb46faebc9925a5dc5275ac16d31c 100644
--- a/net/minecraft/world/level/GameRules.java
+++ b/net/minecraft/world/level/GameRules.java
@@ -277,7 +277,7 @@ public class GameRules {
}
private GameRules(Map<GameRules.Key<?>, GameRules.Value<?>> rules, FeatureFlagSet enabledFeatures) {
- this.rules = rules;
+ this.rules = new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>(rules); // Gale - Lithium - replace game rules map with optimized collection
this.enabledFeatures = enabledFeatures;
// Paper start - Perf: Use array for gamerule storage

View File

@@ -0,0 +1,33 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Wed, 30 Nov 2022 20:54:31 +0100
Subject: [PATCH] Replace AI attributes with optimized collections
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/collections/attributes/AttributeMapMixin.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/net/minecraft/world/entity/ai/attributes/AttributeMap.java b/net/minecraft/world/entity/ai/attributes/AttributeMap.java
index 5b22ad7d56754f82ce8448382ab6bafc2055f413..93a079df455e371a0ca7ada253dc8b7e16b0146f 100644
--- a/net/minecraft/world/entity/ai/attributes/AttributeMap.java
+++ b/net/minecraft/world/entity/ai/attributes/AttributeMap.java
@@ -14,9 +14,11 @@ import net.minecraft.nbt.ListTag;
import net.minecraft.resources.ResourceLocation;
public class AttributeMap {
- private final Map<Holder<Attribute>, AttributeInstance> attributes = new Object2ObjectOpenHashMap<>();
- private final Set<AttributeInstance> attributesToSync = new ObjectOpenHashSet<>();
- private final Set<AttributeInstance> attributesToUpdate = new ObjectOpenHashSet<>();
+ // Gale start - Lithium - replace AI attributes with optimized collections
+ private final Map<Holder<Attribute>, AttributeInstance> attributes = new it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap<>(0);
+ private final Set<AttributeInstance> attributesToSync = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<>(0);
+ private final Set<AttributeInstance> attributesToUpdate = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<>(0);
+ // Gale end - Lithium - replace AI attributes with optimized collections
private final AttributeSupplier supplier;
private final java.util.function.Function<Holder<Attribute>, AttributeInstance> createInstance; // Gale - Airplane - reduce entity allocations

View File

@@ -0,0 +1,27 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Wed, 30 Nov 2022 21:02:43 +0100
Subject: [PATCH] Replace class map with optimized collection
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/collections/entity_by_type/ClassInstanceMultiMapMixin.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/net/minecraft/util/ClassInstanceMultiMap.java b/net/minecraft/util/ClassInstanceMultiMap.java
index 2a708ae0d5bb209650b525e3c56051f8b5655074..3bc4aba806e254a01ce5c71c723196ac01393192 100644
--- a/net/minecraft/util/ClassInstanceMultiMap.java
+++ b/net/minecraft/util/ClassInstanceMultiMap.java
@@ -14,7 +14,7 @@ import java.util.Map.Entry;
import net.minecraft.Util;
public class ClassInstanceMultiMap<T> extends AbstractCollection<T> {
- private final Map<Class<?>, List<T>> byClass = Maps.newHashMap();
+ private final Map<Class<?>, List<T>> byClass = new it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap<>(2); // Gale - Lithium - replace class map with optimized collection
private final Class<T> baseClass;
private final List<T> allInstances = Lists.newArrayList();

View File

@@ -0,0 +1,27 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
Date: Sun, 18 Aug 2024 22:44:48 -0400
Subject: [PATCH] Replace instance list with optimized collection
License: MIT (https://opensource.org/licenses/MIT)
Gale - https://galemc.org
This patch is based on the following mixin:
"com/ishland/vmp/mixins/general/collections/MixinTypeFilterableList.java"
By: ishland <ishlandmc@yeah.net>
As part of: VMP (https://github.com/RelativityMC/VMP-fabric)
Licensed under: MIT (https://opensource.org/licenses/MIT)
diff --git a/net/minecraft/util/ClassInstanceMultiMap.java b/net/minecraft/util/ClassInstanceMultiMap.java
index 3bc4aba806e254a01ce5c71c723196ac01393192..4cd1b8ce60f7befca63a5b6396c0781ae3583dcd 100644
--- a/net/minecraft/util/ClassInstanceMultiMap.java
+++ b/net/minecraft/util/ClassInstanceMultiMap.java
@@ -16,7 +16,7 @@ import net.minecraft.Util;
public class ClassInstanceMultiMap<T> extends AbstractCollection<T> {
private final Map<Class<?>, List<T>> byClass = new it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap<>(2); // Gale - Lithium - replace class map with optimized collection
private final Class<T> baseClass;
- private final List<T> allInstances = Lists.newArrayList();
+ private final List<T> allInstances = new it.unimi.dsi.fastutil.objects.ObjectArrayList<>(); // Gale - VMP - replace instance map with optimized collection
public ClassInstanceMultiMap(Class<T> baseClass) {
this.baseClass = baseClass;

View File

@@ -0,0 +1,56 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Fri, 23 Dec 2022 22:22:47 +0100
Subject: [PATCH] Replace throttle tracker map with optimized collection
License: MIT (https://opensource.org/licenses/MIT)
Gale - https://galemc.org
This patch is based on the following patch:
"Use more fastutil data structures"
By: nopjmp <kthompson@hey.com>
As part of: Dionysus (https://github.com/nopjmp/Dionysus)
Licensed under: MIT (https://opensource.org/licenses/MIT)
* Dionysus description *
Use them in more places.
* Dionysus copyright *
Copyright 2021 Kayla Thompson
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/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java b/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
index 5677a1d1ca2fc5d179034e2747f334a708a7cc79..e9d1c3c8cd637361e732010950e2a60cfc598c7c 100644
--- a/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
@@ -20,7 +20,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
static final java.util.regex.Pattern PROP_PATTERN = java.util.regex.Pattern.compile("\\w{0,16}");
// Spigot end
// CraftBukkit start - add fields
- private static final java.util.HashMap<java.net.InetAddress, Long> throttleTracker = new java.util.HashMap<>();
+ private static final it.unimi.dsi.fastutil.objects.Object2LongMap<java.net.InetAddress> throttleTracker = new it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap<>(); // Gale - Dionysus - replace throttle tracker map with optimized collection
private static int throttleCounter = 0;
// CraftBukkit end
private static final boolean BYPASS_HOSTCHECK = Boolean.getBoolean("Paper.bypassHostCheck"); // Paper
@@ -79,7 +79,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
java.net.InetAddress address = ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getAddress();
synchronized (ServerHandshakePacketListenerImpl.throttleTracker) {
- if (ServerHandshakePacketListenerImpl.throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - ServerHandshakePacketListenerImpl.throttleTracker.get(address) < connectionThrottle) {
+ if (ServerHandshakePacketListenerImpl.throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - ServerHandshakePacketListenerImpl.throttleTracker.getLong(address) < connectionThrottle) { // Gale - Dionysus - replace throttle tracker map with optimized collection
ServerHandshakePacketListenerImpl.throttleTracker.put(address, currentTime);
Component chatmessage = io.papermc.paper.adventure.PaperAdventure.asVanilla(io.papermc.paper.configuration.GlobalConfiguration.get().messages.kick.connectionThrottle); // Paper - Configurable connection throttle kick message
this.connection.send(new ClientboundLoginDisconnectPacket(chatmessage));

View File

@@ -0,0 +1,72 @@
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
License: MIT (https://opensource.org/licenses/MIT)
Gale - https://galemc.org
This patch is based on the following mixins:
"com/ishland/vmp/mixins/general/collections/MixinTypeFilterableList.java"
By: ishland <ishlandmc@yeah.net>
As part of: VMP (https://github.com/RelativityMC/VMP-fabric)
Licensed under: MIT (https://opensource.org/licenses/MIT)
"net/caffeinemc/mods/lithium/mixin/collections/entity_filtering/ClassInstanceMultiMapMixin.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/net/minecraft/util/ClassInstanceMultiMap.java b/net/minecraft/util/ClassInstanceMultiMap.java
index 4cd1b8ce60f7befca63a5b6396c0781ae3583dcd..c79aaf21566fe84fd45c8666230c6c5f4fe1db27 100644
--- a/net/minecraft/util/ClassInstanceMultiMap.java
+++ b/net/minecraft/util/ClassInstanceMultiMap.java
@@ -56,18 +56,41 @@ 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, clazz -> this.allInstances.stream().filter(clazz::isInstance).collect(Util.toMutableList()));
- return (Collection<S>)Collections.unmodifiableCollection(list);
+ // Gale start - Lithium/VMP - 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>) collection;
+ }
+
+ private <S> Collection<T> createAllOfType(Class<S> type) {
+ return this.byClass.computeIfAbsent(
+ type,
+ clazz -> {
+ it.unimi.dsi.fastutil.objects.ObjectArrayList<T> ts = new it.unimi.dsi.fastutil.objects.ObjectArrayList<>(this.allInstances.size());
+
+ for (T _allElement : ((it.unimi.dsi.fastutil.objects.ObjectArrayList<T>) this.allInstances).elements()) {
+ if (clazz.isInstance(_allElement)) {
+ ts.add(_allElement);
+ }
+ }
+
+ return ts;
+ }
+ );
+ // Gale end - Lithium/VMP - avoid Class#isAssignableFrom call in ClassInstanceMultiMap
}
@Override
public Iterator<T> iterator() {
- return (Iterator<T>)(this.allInstances.isEmpty() ? Collections.emptyIterator() : Iterators.unmodifiableIterator(this.allInstances.iterator()));
+ return this.allInstances.isEmpty() ? Collections.emptyIterator() : Iterators.unmodifiableIterator(this.allInstances.iterator());
}
public List<T> getAllInstances() {

View File

@@ -0,0 +1,57 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Wed, 30 Nov 2022 15:51:59 +0100
Subject: [PATCH] Cache BlockStatePairKey hash
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/cached_hashcode/FlowingFluid$BlockStatePairKeyMixin.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/net/minecraft/world/level/material/FlowingFluid.java b/net/minecraft/world/level/material/FlowingFluid.java
index ab8babd32b7d71bc14049c8778525499e715bd12..95ffd0195b9e0792c6b84115d1a1196231b39cec 100644
--- a/net/minecraft/world/level/material/FlowingFluid.java
+++ b/net/minecraft/world/level/material/FlowingFluid.java
@@ -484,7 +484,26 @@ public abstract class FlowingFluid extends Fluid {
: this.shapes.computeIfAbsent(state, fluidState -> Shapes.box(0.0, 0.0, 0.0, 1.0, fluidState.getHeight(level, pos), 1.0));
}
- record BlockStatePairKey(BlockState first, BlockState second, Direction direction) {
+ // Gale start - Lithium - cache BlockStatePairKey hash
+ static class BlockStatePairKey {
+
+ private final BlockState first;
+ private final BlockState second;
+ private final Direction direction;
+ private final int hash;
+
+ private BlockStatePairKey(BlockState first, BlockState second, Direction direction) {
+ this.first = first;
+ this.second = second;
+ this.direction = direction;
+ int hash = System.identityHashCode(this.first);
+
+ hash = 31 * hash + System.identityHashCode(this.second);
+ hash = 31 * hash + this.direction.hashCode();
+ this.hash = hash;
+ }
+ // Gale end - Lithium - cache BlockStatePairKey hash
+
@Override
public boolean equals(Object object) {
return object instanceof FlowingFluid.BlockStatePairKey blockStatePairKey
@@ -495,9 +514,7 @@ public abstract class FlowingFluid extends Fluid {
@Override
public int hashCode() {
- int i = System.identityHashCode(this.first);
- i = 31 * i + System.identityHashCode(this.second);
- return 31 * i + this.direction.hashCode();
+ return this.hash; // Gale - Lithium - cache BlockStatePairKey hash
}
}

View File

@@ -0,0 +1,41 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
Date: Thu, 12 Dec 2024 02:58:34 -0500
Subject: [PATCH] Cache ShapePairKey hash
diff --git a/net/minecraft/world/level/block/Block.java b/net/minecraft/world/level/block/Block.java
index 95bd1139401d49ddf443a64faca8cd30ca3b1a1d..b545ec55430105f74a09d6ae81d4cdc198121f17 100644
--- a/net/minecraft/world/level/block/Block.java
+++ b/net/minecraft/world/level/block/Block.java
@@ -610,7 +610,20 @@ public class Block extends BlockBehaviour implements ItemLike {
}
// CraftBukkit end
- record ShapePairKey(VoxelShape first, VoxelShape second) {
+ // Gale start - cache ShapePairKey hash
+ static class ShapePairKey {
+
+ private final VoxelShape first;
+ private final VoxelShape second;
+ private final int hash;
+
+ private ShapePairKey(VoxelShape first, VoxelShape second) {
+ this.first = first;
+ this.second = second;
+ this.hash = System.identityHashCode(this.first) * 31 + System.identityHashCode(this.second);
+ }
+ // Gale end - cache ShapePairKey hash
+
@Override
public boolean equals(Object other) {
return other instanceof Block.ShapePairKey shapePairKey && this.first == shapePairKey.first && this.second == shapePairKey.second;
@@ -618,7 +631,7 @@ public class Block extends BlockBehaviour implements ItemLike {
@Override
public int hashCode() {
- return System.identityHashCode(this.first) * 31 + System.identityHashCode(this.second);
+ return this.hash; // Gale - cache ShapePairKey hash
}
}
}

View File

@@ -0,0 +1,40 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Wed, 30 Nov 2022 17:24:24 +0100
Subject: [PATCH] Replace division by multiplication in CubePointRange
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/shapes/precompute_shape_arrays/CubePointRangeMixin.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/net/minecraft/world/phys/shapes/CubePointRange.java b/net/minecraft/world/phys/shapes/CubePointRange.java
index 62aea61c5f240aa59b8489dd0bbb3d1b69b54b1c..513adb0e75fb70d26f6056d22fe2be30b1a39296 100644
--- a/net/minecraft/world/phys/shapes/CubePointRange.java
+++ b/net/minecraft/world/phys/shapes/CubePointRange.java
@@ -4,6 +4,7 @@ import it.unimi.dsi.fastutil.doubles.AbstractDoubleList;
public class CubePointRange extends AbstractDoubleList {
private final int parts;
+ private final double scale; // Gale - Lithium - replace division by multiplication in CubePointRange
public CubePointRange(int parts) {
if (parts <= 0) {
@@ -11,11 +12,12 @@ public class CubePointRange extends AbstractDoubleList {
} else {
this.parts = parts;
}
+ this.scale = 1.0D / parts; // Gale - Lithium - replace division by multiplication in CubePointRange
}
@Override
public double getDouble(int value) {
- return (double)value / this.parts;
+ return value * this.scale; // Gale - Lithium - replace division by multiplication in CubePointRange
}
@Override

View File

@@ -0,0 +1,37 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Wed, 30 Nov 2022 17:28:37 +0100
Subject: [PATCH] Replace parts by size in CubePointRange
License: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
Gale - https://galemc.org
diff --git a/net/minecraft/world/phys/shapes/CubePointRange.java b/net/minecraft/world/phys/shapes/CubePointRange.java
index 513adb0e75fb70d26f6056d22fe2be30b1a39296..9838c090a6476d9ab7b17f2556a74cba7f8b4bd9 100644
--- a/net/minecraft/world/phys/shapes/CubePointRange.java
+++ b/net/minecraft/world/phys/shapes/CubePointRange.java
@@ -3,14 +3,14 @@ package net.minecraft.world.phys.shapes;
import it.unimi.dsi.fastutil.doubles.AbstractDoubleList;
public class CubePointRange extends AbstractDoubleList {
- private final int parts;
+ private final int size; // Gale - replace parts by size in CubePointRange
private final double scale; // Gale - Lithium - replace division by multiplication in CubePointRange
public CubePointRange(int parts) {
if (parts <= 0) {
throw new IllegalArgumentException("Need at least 1 part");
} else {
- this.parts = parts;
+ this.size = parts + 1; // Gale - replace parts by size in CubePointRange
}
this.scale = 1.0D / parts; // Gale - Lithium - replace division by multiplication in CubePointRange
}
@@ -22,6 +22,6 @@ public class CubePointRange extends AbstractDoubleList {
@Override
public int size() {
- return this.parts + 1;
+ return this.size; // Gale - replace parts by size in CubePointRange
}
}

View File

@@ -0,0 +1,38 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Wed, 30 Nov 2022 20:17:41 +0100
Subject: [PATCH] Check frozen ticks before landing block
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/entity/fast_powder_snow_check/LivingEntityMixin.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/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
index ac86ea5fc03aab1445712a7143f7714eea31b124..6e93836570859929e4f35d23d9dbcc2ebbc8fb27 100644
--- a/net/minecraft/world/entity/LivingEntity.java
+++ b/net/minecraft/world/entity/LivingEntity.java
@@ -521,10 +521,9 @@ public abstract class LivingEntity extends Entity implements Attackable {
}
protected void tryAddFrost() {
- if (!this.getBlockStateOnLegacy().isAir()) {
int ticksFrozen = this.getTicksFrozen();
if (ticksFrozen > 0) {
- AttributeInstance attribute = this.getAttribute(Attributes.MOVEMENT_SPEED);
+ AttributeInstance attribute = this.getBlockStateOnLegacy().isAir() ? null : this.getAttribute(Attributes.MOVEMENT_SPEED); // Gale - Lithium - check frozen ticks before landing block
if (attribute == null) {
return;
}
@@ -532,7 +531,6 @@ public abstract class LivingEntity extends Entity implements Attackable {
float f = -0.05F * this.getPercentFrozen();
attribute.addTransientModifier(new AttributeModifier(SPEED_MODIFIER_POWDER_SNOW_ID, f, AttributeModifier.Operation.ADD_VALUE));
}
- }
}
protected void onChangedBlock(ServerLevel level, BlockPos pos) {