Optimise getType calls

Remove the map lookup for converting from Block->Bukkit Material
This commit is contained in:
Spottedleaf
2020-06-03 11:37:13 -07:00
parent 093bd60eae
commit f24af9bc9c
6 changed files with 24 additions and 5 deletions

View File

@@ -100,7 +100,7 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
public Material getBlockType(int x, int y, int z) {
this.validateChunkCoordinates(x, y, z);
return CraftBlockType.minecraftToBukkit(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

View File

@@ -220,7 +220,7 @@ public class CraftBlock implements Block {
@Override
public Material getType() {
return CraftBlockType.minecraftToBukkit(this.world.getBlockState(this.position).getBlock());
return this.world.getBlockState(this.position).getBukkitMaterial(); // Paper - optimise getType calls
}
@Override

View File

@@ -175,7 +175,7 @@ public class CraftBlockState implements BlockState {
@Override
public Material getType() {
return CraftBlockType.minecraftToBukkit(this.data.getBlock());
return this.data.getBukkitMaterial(); // Paper - optimise getType calls
}
public void setFlag(int flag) {

View File

@@ -63,7 +63,7 @@ public class CraftBlockData implements BlockData {
@Override
public Material getMaterial() {
return CraftBlockType.minecraftToBukkit(this.state.getBlock());
return this.state.getBukkitMaterial(); // Paper - optimise getType calls
}
public net.minecraft.world.level.block.state.BlockState getState() {

View File

@@ -96,7 +96,7 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData {
@Override
public Material getType(int x, int y, int z) {
return CraftBlockType.minecraftToBukkit(this.getTypeId(x, y, z).getBlock());
return this.getTypeId(x, y, z).getBukkitMaterial(); // Paper - optimise getType calls
}
@Override