mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 11:06:29 +01:00
c0936a71bd
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 01aa02eb PR-858: Add LivingEntity#playHurtAnimation() 9421320f PR-884: Refinements to new ban API for improved compatibility and correctness 37a60b45 SPIGOT-6455, SPIGOT-7030, PR-750: Improve ban API 4eeb174b All smithing inventories are now the new smithing inventory f2bb168e PR-880: Add methods to get/set FallingBlock CancelDrop e7a807fa PR-879: Add Player#sendHealthUpdate() 692b8e96 SPIGOT-7370: Remove float value conversion in plugin.yml 2d033390 SPIGOT-7403: Add direct API for waxed signs 16a08373 PR-876: Add missing Raider API and 'no action ticks' CraftBukkit Changes: b60a95c8c PR-1189: Add LivingEntity#playHurtAnimation() 95c335c63 PR-1226: Fix VehicleEnterEvent not being called for certain entities 0a0fc3bee PR-1227: Refinements to new ban API for improved compatibility and correctness 0d0b1e5dc Revert bad change to PathfinderGoalSit causing all cats to sit 648196070 SPIGOT-6455, SPIGOT-7030, PR-1054: Improve ban API 31fe848d6 All smithing inventories are now the new smithing inventory 9a919a143 SPIGOT-7416: SmithItemEvent not firing in Smithing Table 9f64f0d22 PR-1221: Add methods to get/set FallingBlock CancelDrop 3be9ac171 PR-1220: Add Player#sendHealthUpdate() c1279f775 PR-1209: Clean up various patches c432e4397 Fix Raider#setCelebrating() implementation 504d96665 SPIGOT-7403: Add direct API for waxed signs c68c1f1b3 PR-1216: Add missing Raider API and 'no action ticks' 85b89c3dd Increase outdated build delay Spigot Changes: 9ebce8af Rebuild patches 64b565e6 Rebuild patches
95 lines
5.1 KiB
Diff
95 lines
5.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
Date: Wed, 3 Jun 2020 11:37:13 -0700
|
|
Subject: [PATCH] Optimise getType calls
|
|
|
|
Remove the map lookup for converting from Block->Bukkit Material
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockState.java b/src/main/java/net/minecraft/world/level/block/state/BlockState.java
|
|
index da878e180c6b94f98dc82c6e8395f63ecc9b2c1e..a9b0f5950b6f97ea4c2a1075946b92008b62c9d9 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/state/BlockState.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/state/BlockState.java
|
|
@@ -10,6 +10,17 @@ import net.minecraft.world.level.block.state.properties.Property;
|
|
public class BlockState extends BlockBehaviour.BlockStateBase {
|
|
public static final Codec<BlockState> CODEC = codec(BuiltInRegistries.BLOCK.byNameCodec(), Block::defaultBlockState).stable();
|
|
|
|
+ // Paper start - optimise getType calls
|
|
+ org.bukkit.Material cachedMaterial;
|
|
+
|
|
+ public final org.bukkit.Material getBukkitMaterial() {
|
|
+ if (this.cachedMaterial == null) {
|
|
+ this.cachedMaterial = org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(this.getBlock());
|
|
+ }
|
|
+
|
|
+ return this.cachedMaterial;
|
|
+ }
|
|
+ // Paper end - optimise getType calls
|
|
public BlockState(Block block, ImmutableMap<Property<?>, Comparable<?>> propertyMap, MapCodec<BlockState> codec) {
|
|
super(block, propertyMap, codec);
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java b/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java
|
|
index eebac2ea211f58c385b2ceb36ab911ac5e115296..d1aaca5de055fd5e3bf2c6d39ef397bbb2deeaae 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java
|
|
@@ -98,7 +98,7 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
|
|
public Material getBlockType(int x, int y, int z) {
|
|
this.validateChunkCoordinates(x, y, z);
|
|
|
|
- return CraftMagicNumbers.getMaterial(this.blockids[this.getSectionIndex(y)].get(x, y & 0xF, z).getBlock());
|
|
+ return this.blockids[this.getSectionIndex(y)].get(x, y & 0xF, z).getBukkitMaterial(); // Paper - optimise getType calls
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
index d2d5a43cfdf294ccc9353258250f5a990e205b88..2749f81fd74e466fa6b7c1c5f08d8defc5203b3e 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
@@ -224,7 +224,7 @@ public class CraftBlock implements Block {
|
|
|
|
@Override
|
|
public Material getType() {
|
|
- return CraftMagicNumbers.getMaterial(this.world.getBlockState(position).getBlock());
|
|
+ return this.world.getBlockState(this.position).getBukkitMaterial(); // Paper - optimise getType calls
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
|
index 2773f47d4e7a9432ab1ccebfcdc22317ef762099..b722a207c0e745bb172d93b90e1241d7bfa173ce 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
|
@@ -161,7 +161,7 @@ public class CraftBlockState implements BlockState {
|
|
|
|
@Override
|
|
public Material getType() {
|
|
- return CraftMagicNumbers.getMaterial(this.data.getBlock());
|
|
+ return this.data.getBukkitMaterial(); // Paper - optimise getType calls
|
|
}
|
|
|
|
public void setFlag(int flag) {
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
|
|
index 68dc8455427b6e3f60a4472db3a625028c413561..68ffdb2140bdf8d00ed86db19d316735d9a6b2d1 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
|
|
@@ -59,7 +59,7 @@ public class CraftBlockData implements BlockData {
|
|
|
|
@Override
|
|
public Material getMaterial() {
|
|
- return CraftMagicNumbers.getMaterial(this.state.getBlock());
|
|
+ return this.state.getBukkitMaterial(); // Paper - optimise getType calls
|
|
}
|
|
|
|
public net.minecraft.world.level.block.state.BlockState getState() {
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java b/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java
|
|
index 79b6f88a32ea5eaf77757b8cc3824b6dac1558a7..7bfb9bc9689c5d9899b572862f3fbe53812f36b1 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java
|
|
@@ -95,7 +95,7 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData {
|
|
|
|
@Override
|
|
public Material getType(int x, int y, int z) {
|
|
- return CraftMagicNumbers.getMaterial(this.getTypeId(x, y, z).getBlock());
|
|
+ return this.getTypeId(x, y, z).getBukkitMaterial(); // Paper - optimise getType calls
|
|
}
|
|
|
|
@Override
|