mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
Cache map ids on item frames
This commit is contained in:
parent
88464f509b
commit
4c98f21716
2 changed files with 25 additions and 8 deletions
|
@ -71,8 +71,9 @@
|
||||||
ItemStack itemstack = entityitemframe.getItem();
|
ItemStack itemstack = entityitemframe.getItem();
|
||||||
|
|
||||||
- if (itemstack.getItem() instanceof MapItem) {
|
- if (itemstack.getItem() instanceof MapItem) {
|
||||||
|
- MapId mapid = (MapId) itemstack.get(DataComponents.MAP_ID);
|
||||||
+ 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
|
+ 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
|
||||||
MapId mapid = (MapId) itemstack.get(DataComponents.MAP_ID);
|
+ MapId mapid = entityitemframe.cachedMapId; // Paper - Perf: Cache map ids on item frames
|
||||||
MapItemSavedData worldmap = MapItem.getSavedData(mapid, this.level);
|
MapItemSavedData worldmap = MapItem.getSavedData(mapid, this.level);
|
||||||
|
|
||||||
if (worldmap != null) {
|
if (worldmap != null) {
|
||||||
|
|
|
@ -8,7 +8,15 @@
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.component.DataComponents;
|
import net.minecraft.core.component.DataComponents;
|
||||||
@@ -91,9 +92,15 @@
|
@@ -50,6 +51,7 @@
|
||||||
|
private static final float HEIGHT = 0.75F;
|
||||||
|
public float dropChance;
|
||||||
|
public boolean fixed;
|
||||||
|
+ public @Nullable MapId cachedMapId; // Paper - Perf: Cache map ids on item frames
|
||||||
|
|
||||||
|
public ItemFrame(EntityType<? extends ItemFrame> type, Level world) {
|
||||||
|
super(type, world);
|
||||||
|
@@ -91,9 +93,15 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AABB calculateBoundingBox(BlockPos pos, Direction side) {
|
protected AABB calculateBoundingBox(BlockPos pos, Direction side) {
|
||||||
|
@ -26,7 +34,7 @@
|
||||||
double d0 = enumdirection_enumaxis == Direction.Axis.X ? 0.0625D : 0.75D;
|
double d0 = enumdirection_enumaxis == Direction.Axis.X ? 0.0625D : 0.75D;
|
||||||
double d1 = enumdirection_enumaxis == Direction.Axis.Y ? 0.0625D : 0.75D;
|
double d1 = enumdirection_enumaxis == Direction.Axis.Y ? 0.0625D : 0.75D;
|
||||||
double d2 = enumdirection_enumaxis == Direction.Axis.Z ? 0.0625D : 0.75D;
|
double d2 = enumdirection_enumaxis == Direction.Axis.Z ? 0.0625D : 0.75D;
|
||||||
@@ -123,9 +130,9 @@
|
@@ -123,9 +131,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -38,7 +46,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -155,6 +162,18 @@
|
@@ -155,6 +163,18 @@
|
||||||
if (this.isInvulnerableToBase(source)) {
|
if (this.isInvulnerableToBase(source)) {
|
||||||
return false;
|
return false;
|
||||||
} else if (this.shouldDamageDropItem(source)) {
|
} else if (this.shouldDamageDropItem(source)) {
|
||||||
|
@ -57,7 +65,7 @@
|
||||||
this.dropItem(world, source.getEntity(), false);
|
this.dropItem(world, source.getEntity(), false);
|
||||||
this.gameEvent(GameEvent.BLOCK_CHANGE, source.getEntity());
|
this.gameEvent(GameEvent.BLOCK_CHANGE, source.getEntity());
|
||||||
this.playSound(this.getRemoveItemSound(), 1.0F, 1.0F);
|
this.playSound(this.getRemoveItemSound(), 1.0F, 1.0F);
|
||||||
@@ -251,7 +270,15 @@
|
@@ -251,7 +271,15 @@
|
||||||
|
|
||||||
public ItemStack getItem() {
|
public ItemStack getItem() {
|
||||||
return (ItemStack) this.getEntityData().get(ItemFrame.DATA_ITEM);
|
return (ItemStack) this.getEntityData().get(ItemFrame.DATA_ITEM);
|
||||||
|
@ -73,7 +81,7 @@
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public MapId getFramedMapId(ItemStack stack) {
|
public MapId getFramedMapId(ItemStack stack) {
|
||||||
@@ -267,17 +294,23 @@
|
@@ -267,17 +295,23 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItem(ItemStack value, boolean update) {
|
public void setItem(ItemStack value, boolean update) {
|
||||||
|
@ -103,7 +111,15 @@
|
||||||
this.level().updateNeighbourForOutputSignal(this.pos, Blocks.AIR);
|
this.level().updateNeighbourForOutputSignal(this.pos, Blocks.AIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -386,7 +419,13 @@
|
@@ -301,6 +335,7 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onItemChanged(ItemStack stack) {
|
||||||
|
+ this.cachedMapId = stack.getComponents().get(net.minecraft.core.component.DataComponents.MAP_ID); // Paper - Perf: Cache map ids on item frames
|
||||||
|
if (!stack.isEmpty() && stack.getFrame() != this) {
|
||||||
|
stack.setEntityRepresentation(this);
|
||||||
|
}
|
||||||
|
@@ -386,7 +421,13 @@
|
||||||
if (worldmap != null && worldmap.isTrackedCountOverLimit(256)) {
|
if (worldmap != null && worldmap.isTrackedCountOverLimit(256)) {
|
||||||
return InteractionResult.FAIL;
|
return InteractionResult.FAIL;
|
||||||
} else {
|
} else {
|
||||||
|
@ -118,7 +134,7 @@
|
||||||
this.gameEvent(GameEvent.BLOCK_CHANGE, player);
|
this.gameEvent(GameEvent.BLOCK_CHANGE, player);
|
||||||
itemstack.consume(1, player);
|
itemstack.consume(1, player);
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
@@ -395,6 +434,13 @@
|
@@ -395,6 +436,13 @@
|
||||||
return InteractionResult.PASS;
|
return InteractionResult.PASS;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue