Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-15 19:10:09 +01:00
fe53b0e76f
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: 1d522878 PR-966: Introduce getRespawnLocation as a replacement for getBedSpawnLocation cc01b745 PR-965: Add DragonBattle#setPreviouslyKilled 28e3702f SPIGOT-6921, PR-957: Add methods to remove all enchantments on an ItemStack 8872404e PR-961: Add BlockData#copyTo 4054cc7b PR-956: Add method to get an offline player's location CraftBukkit Changes: 292ec79e0 SPIGOT-7568: Call EntityChangeBlockEvent for DecoratedPot b44bf5aa8 SPIGOT-7575: SuspiciousStewMeta creates invalid PotionEffect data 161784713 PR-1340: Centralize the conversion from and to Minecraft / Bukkit registry items even more and add a test case for them b93c5a30d PR-1338: Introduce getRespawnLocation as a replacement for getBedSpawnLocation fb973486c SPIGOT-7570: PrepareItemCraftEvent#isRepair() always returns false c9c24535e PR-1337: Add DragonBattle#setPreviouslyKilled c8b4da803 SPIGOT-6921, PR-1330: Add methods to remove all enchantments on an ItemStack 95bc1c4f5 PR-1333: Add BlockData#copyTo 36e2f9ce1 PR-1329: Add method to get an offline player's location Spigot Changes: c198da22 SPIGOT-7563: Update to latest release of bungeecord-chat
100 Zeilen
5.0 KiB
Diff
100 Zeilen
5.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Thu, 3 Mar 2016 02:07:55 -0600
|
|
Subject: [PATCH] Optimize isInWorldBounds and getBlockState for inlining
|
|
|
|
Hot methods, so reduce # of instructions for the method.
|
|
|
|
Move is valid location test to the BlockPosition class so that it can access local variables.
|
|
|
|
Replace all calls to the new place to the unnecessary forward.
|
|
|
|
Optimize getType and getBlockData to manually inline and optimize the calls
|
|
|
|
diff --git a/src/main/java/net/minecraft/core/Vec3i.java b/src/main/java/net/minecraft/core/Vec3i.java
|
|
index 369b54b96c682717ef93d05312714b4d30efaceb..beadef19ee136c27601f0d116a86967344c2e403 100644
|
|
--- a/src/main/java/net/minecraft/core/Vec3i.java
|
|
+++ b/src/main/java/net/minecraft/core/Vec3i.java
|
|
@@ -31,6 +31,12 @@ public class Vec3i implements Comparable<Vec3i> {
|
|
});
|
|
}
|
|
|
|
+ // Paper start
|
|
+ public final boolean isInsideBuildHeightAndWorldBoundsHorizontal(net.minecraft.world.level.LevelHeightAccessor levelHeightAccessor) {
|
|
+ return getX() >= -30000000 && getZ() >= -30000000 && getX() < 30000000 && getZ() < 30000000 && !levelHeightAccessor.isOutsideBuildHeight(getY());
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
public Vec3i(int x, int y, int z) {
|
|
this.x = x;
|
|
this.y = y;
|
|
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
|
index 9a0d648f04063dd7701d1cbe548a6d45fc216928..9ea53a55946fbfa35ccceb9c94bb63bd40d3c2f6 100644
|
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
|
@@ -342,7 +342,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
|
// Paper end
|
|
|
|
public boolean isInWorldBounds(BlockPos pos) {
|
|
- return !this.isOutsideBuildHeight(pos) && Level.isInWorldBoundsHorizontal(pos);
|
|
+ return pos.isInsideBuildHeightAndWorldBoundsHorizontal(this); // Paper - use better/optimized check
|
|
}
|
|
|
|
public static boolean isInSpawnableBounds(BlockPos pos) {
|
|
diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
|
|
index 3e5addb60ae8f466dad09edb3ae1fc88fe2681e9..5e8d2e4245757a0889645ea79ee68afb53f7dde4 100644
|
|
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
|
|
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
|
|
@@ -172,6 +172,7 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom
|
|
return GameEventListenerRegistry.NOOP;
|
|
}
|
|
|
|
+ public abstract BlockState getBlockState(final int x, final int y, final int z); // Paper
|
|
@Nullable
|
|
public abstract BlockState setBlockState(BlockPos pos, BlockState state, boolean moved);
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java b/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java
|
|
index 60e760b42dd6471a229dfd45490dcf8c51979d35..4a3ac7dedf5cb1e76f16ec4f18e82afc717d0ced 100644
|
|
--- a/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java
|
|
+++ b/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java
|
|
@@ -91,6 +91,12 @@ public class ImposterProtoChunk extends ProtoChunk {
|
|
public BlockState getBlockState(BlockPos pos) {
|
|
return this.wrapped.getBlockState(pos);
|
|
}
|
|
+ // Paper start
|
|
+ @Override
|
|
+ public final BlockState getBlockState(final int x, final int y, final int z) {
|
|
+ return this.wrapped.getBlockStateFinal(x, y, z);
|
|
+ }
|
|
+ // Paper end
|
|
|
|
@Override
|
|
public FluidState getFluidState(BlockPos pos) {
|
|
diff --git a/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java b/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java
|
|
index 7da1ed9640211b0e064162dcdb0000538e7b30f3..7aa585875dad5296526bb5d67fc5ea0f8875e452 100644
|
|
--- a/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java
|
|
+++ b/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java
|
|
@@ -86,14 +86,18 @@ public class ProtoChunk extends ChunkAccess {
|
|
|
|
@Override
|
|
public BlockState getBlockState(BlockPos pos) {
|
|
- int i = pos.getY();
|
|
- if (this.isOutsideBuildHeight(i)) {
|
|
+ // Paper start
|
|
+ return getBlockState(pos.getX(), pos.getY(), pos.getZ());
|
|
+ }
|
|
+ public BlockState getBlockState(final int x, final int y, final int z) {
|
|
+ if (this.isOutsideBuildHeight(y)) {
|
|
return Blocks.VOID_AIR.defaultBlockState();
|
|
} else {
|
|
- LevelChunkSection levelChunkSection = this.getSection(this.getSectionIndex(i));
|
|
- return levelChunkSection.hasOnlyAir() ? Blocks.AIR.defaultBlockState() : levelChunkSection.getBlockState(pos.getX() & 15, i & 15, pos.getZ() & 15);
|
|
+ LevelChunkSection levelChunkSection = this.getSections()[this.getSectionIndex(y)];
|
|
+ return levelChunkSection.hasOnlyAir() ? Blocks.AIR.defaultBlockState() : levelChunkSection.getBlockState(x & 15, y & 15, z & 15);
|
|
}
|
|
}
|
|
+ // Paper end
|
|
|
|
@Override
|
|
public FluidState getFluidState(BlockPos pos) {
|