Paper/patches/server/0879-Cache-map-ids-on-item-frames.patch

40 lines
2.5 KiB
Diff
Raw Normal View History

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-04-25 07:16:04 +02:00
index 979571cc12f81e09df8570f7deb32f4c604188bd..0373b2de2b992b648f346d6df3960a3586a54567 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
@@ -118,7 +118,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-04-25 07:16:04 +02:00
index 6bf89686ce5cf700ac06ec1e38f53af745098fa3..da0d1c9a1c4ae081bff9ca4230c9a1503885c354 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-04-25 00:36:49 +02:00
@@ -49,6 +49,7 @@ public class ItemFrame extends HangingEntity {
2023-08-12 15:33:24 +02:00
public static final int NUM_ROTATIONS = 8;
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-04-25 00:36:49 +02:00
@@ -364,6 +365,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);
}