Paper/patches/server/0843-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-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-29 16:54:40 +01:00
index d431ee93cd7e87a24ff4079288facd089053d725..bbdaaa1cc0b4aed28bc39385508d221055b99d4d 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);
}