mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 19:15:32 +01:00
928bcc8d3a
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: 09943450 Update SnakeYAML version 5515734f SPIGOT-7162: Incorrect description for Entity#getVehicle javadoc 6f82b381 PR-788: Add getHand() to all relevant events CraftBukkit Changes: aaf484f6f SPIGOT-7163: CraftMerchantRecipe doesn't copy demand and specialPrice from BukkitMerchantRecipe 5329dd6fd PR-1107: Add getHand() to all relevant events 93061706e SPIGOT-7045: Ocelots never spawn with babies with spawn reason OCELOT_BABY
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 76133c77e8ebce7c9e5402e3e7cd50b30aa1c2e0..348a91a760bd728f8e732e1a35c86ab75d8fc0f1 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(Registry.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 0511ac55c4e6d9736ec12e94c9899eb04d5cd2e3..75193684a71d694736087d1a368b8fb6a8c8363b 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java
|
|
@@ -84,7 +84,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 396fb96abed1e77893d8ee8a15cff18cad804475..2c1efaecf220588d8b74946194bf340871e57004 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 0a755f38fae9dc84440f43113920c5b4c6d8218b..7b9e943b391c061782fccd2b8d705ceec8db50fe 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
|
@@ -166,7 +166,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 d02a5e383190fc4713141d953efc111bb2f7f89c..aae7f7ab4931db8f955c3055157fe01f99931ec7 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
|
|
@@ -50,7 +50,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 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 ee88ff2ee86bbd3ccf3e4a0b2310f020f137ef4f..5e15feb408b8a05ec5ee393a604c8d39a91ff106 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java
|
|
@@ -96,7 +96,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
|