3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-15 11:00:06 +01:00
Paper/patches/server/0844-Cache-map-ids-on-item-frames.patch

40 Zeilen
2.5 KiB
Diff

2023-08-12 15:33:24 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Warrior <50800980+Warriorrrr@users.noreply.github.com>
Date: Mon, 7 Aug 2023 12:58:28 +0200
Subject: [PATCH] Cache map ids on item frames
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
2024-10-24 10:42:29 +02:00
index 3cdcc4f44608d24550f2a8c6f3f5ce675d7777c5..7118e1f806af98159ec292f9340d7e4004e2b486 100644
2023-08-12 15:33:24 +02:00
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
2024-10-24 10:42:29 +02:00
@@ -121,7 +121,7 @@ public class ServerEntity {
2023-08-12 15:33:24 +02:00
ItemStack itemstack = entityitemframe.getItem();
if (this.level.paperConfig().maps.itemFrameCursorUpdateInterval > 0 && this.tickCount % this.level.paperConfig().maps.itemFrameCursorUpdateInterval == 0 && itemstack.getItem() instanceof MapItem) { // CraftBukkit - Moved this.tickCounter % 10 logic here so item frames do not enter the other blocks // Paper - Make item frame map cursor update interval configurable
2024-04-25 00:36:49 +02:00
- MapId mapid = (MapId) itemstack.get(DataComponents.MAP_ID);
2024-04-25 07:16:04 +02:00
+ MapId mapid = entityitemframe.cachedMapId; // Paper - Perf: Cache map ids on item frames
2024-04-25 00:36:49 +02:00
MapItemSavedData worldmap = MapItem.getSavedData(mapid, this.level);
2023-08-12 15:33:24 +02:00
if (worldmap != null) {
diff --git a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
2024-10-25 13:34:01 +02:00
index 65f7f1f98f415a564aadb440d3a67143699e43db..d6f835320014c07f9d174d05929ed8cc16a10c10 100644
2023-08-12 15:33:24 +02:00
--- a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
+++ b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
2024-10-24 10:42:29 +02:00
@@ -51,6 +51,7 @@ public class ItemFrame extends HangingEntity {
2024-06-14 10:17:11 +02:00
private static final float HEIGHT = 0.75F;
2023-08-12 15:33:24 +02:00
public float dropChance;
public boolean fixed;
2024-04-25 07:16:04 +02:00
+ public @Nullable MapId cachedMapId; // Paper - Perf: Cache map ids on item frames
2023-08-12 15:33:24 +02:00
public ItemFrame(EntityType<? extends ItemFrame> type, Level world) {
super(type, world);
2024-10-24 10:42:29 +02:00
@@ -334,6 +335,7 @@ public class ItemFrame extends HangingEntity {
2023-08-12 15:33:24 +02:00
}
private void onItemChanged(ItemStack stack) {
2024-04-25 07:16:04 +02:00
+ this.cachedMapId = stack.getComponents().get(net.minecraft.core.component.DataComponents.MAP_ID); // Paper - Perf: Cache map ids on item frames
2023-08-12 15:33:24 +02:00
if (!stack.isEmpty() && stack.getFrame() != this) {
stack.setEntityRepresentation(this);
}