mirror of
https://github.com/Dreeam-qwq/Gale.git
synced 2025-12-19 14:59:29 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@a6e82d90 [ci/skip] Clarify getChunkAtAsyncUrgently javadocs (#12125) PaperMC/Paper@cb25c0cf [ci/skip] Fix annotation fields used in NMS getBukkitEntity (#12120) PaperMC/Paper@00701267 [ci/skip] improvement example in javadoc for DatapackRegistrar (#12122) PaperMC/Paper@608f004a add method on ItemStack to edit pdc (#12022) PaperMC/Paper@7bee9971 Cleanup damage source a bit (#12106) PaperMC/Paper@b9023b5d Add EntityAttemptSmashAttackEvent (#12113) PaperMC/Paper@a3781ff3 Separate tick count to ensure vanilla parity (#12077) PaperMC/Paper@2a4a1154 Add EntityEquipmentChangedEvent (#12011) PaperMC/Paper@06f96dd6 Improvement in /plugins command (#12121) PaperMC/Paper@28d07dc5 use correct spigot plugin count PaperMC/Paper@60394c5b Fix PlayerReadyArrowEvent cancellation desync (#12111) PaperMC/Paper@b27e11cc Fix bad world to chunk coordinate example in javadocs (#12131) PaperMC/Paper@88cdd220 Fixup luck and random implementation in CB loot-tables (#11926) PaperMC/Paper@84609dc0 Don't auto-create any brig redirects (#11954) PaperMC/Paper@8eb8e44a Allow For Default Titles in InventoryView Builders (#12013)
70 lines
3.3 KiB
Diff
70 lines
3.3 KiB
Diff
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/Entity.java b/net/minecraft/world/entity/Entity.java
|
|
index a01491bc87d982adadd1890f72e31b893dfa7619..eee00c4d23a8b4c7e66d45d843ffc087fb183702 100644
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
@@ -361,6 +361,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
return this.originWorld;
|
|
}
|
|
// Paper end - Entity origin API
|
|
+
|
|
public float getBukkitYaw() {
|
|
return this.yRot;
|
|
}
|
|
diff --git a/net/minecraft/world/entity/ai/attributes/AttributeMap.java b/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
|
index 4c808c7ef336de74048f40bd1cc8b14131a9325d..beebe81e13c99c6ddd9ffb2c7a3fdd74cb9c7afa 100644
|
|
--- a/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
|
+++ b/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
|
@@ -23,9 +23,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) {
|
|
@@ -49,7 +51,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) {
|