mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
more patches (#5799)
This commit is contained in:
parent
bfc788437f
commit
51d9594fe8
@ -38,7 +38,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
@Override
|
@Override
|
||||||
public long getInhabitedTime() {
|
public long getInhabitedTime() {
|
||||||
- return this.inhabitedTime;
|
- return this.inhabitedTime;
|
||||||
+ return world.paperConfig.fixedInhabitedTime < 0 ? this.inhabitedTime : world.paperConfig.fixedInhabitedTime; // Paper
|
+ return this.level.paperConfig.fixedInhabitedTime < 0 ? this.inhabitedTime : this.level.paperConfig.fixedInhabitedTime; // Paper
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -26,11 +26,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
@@ -0,0 +0,0 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
|
@@ -0,0 +0,0 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
|
||||||
blockposition = this.findLightingTargetAround(this.getBlockRandomPos(j, 0, k, 15));
|
blockposition = this.findLightningTargetAround(this.getBlockRandomPos(j, 0, k, 15));
|
||||||
if (this.isRainingAt(blockposition)) {
|
if (this.isRainingAt(blockposition)) {
|
||||||
DifficultyInstance difficultydamagescaler = this.getCurrentDifficultyAt(blockposition);
|
DifficultyInstance difficultydamagescaler = this.getCurrentDifficultyAt(blockposition);
|
||||||
- boolean flag1 = this.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && this.random.nextDouble() < (double) difficultydamagescaler.getEffectiveDifficulty() * 0.01D;
|
- boolean flag1 = this.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && this.random.nextDouble() < (double) difficultydamagescaler.getEffectiveDifficulty() * 0.01D && !this.getBlockState(blockposition.below()).is(Blocks.LIGHTNING_ROD);
|
||||||
+ boolean flag1 = this.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && this.random.nextDouble() < (double) difficultydamagescaler.getEffectiveDifficulty() * paperConfig.skeleHorseSpawnChance; // Paper
|
+ boolean flag1 = this.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && this.random.nextDouble() < (double) difficultydamagescaler.getEffectiveDifficulty() * paperConfig.skeleHorseSpawnChance && !this.getBlockState(blockposition.below()).is(Blocks.LIGHTNING_ROD); // Paper
|
||||||
|
|
||||||
if (flag1) {
|
if (flag1) {
|
||||||
SkeletonHorse entityhorseskeleton = (SkeletonHorse) EntityType.SKELETON_HORSE.create((net.minecraft.world.level.Level) this);
|
SkeletonHorse entityhorseskeleton = (SkeletonHorse) EntityType.SKELETON_HORSE.create((net.minecraft.world.level.Level) this);
|
@ -11,7 +11,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
@@ -0,0 +0,0 @@ public abstract class PathNavigation {
|
@@ -0,0 +0,0 @@ public abstract class PathNavigation {
|
||||||
private BlockPos targetPos;
|
private BlockPos targetPos;
|
||||||
private int reachRange;
|
private int reachRange;
|
||||||
private float maxVisitedNodesMultiplier;
|
private float maxVisitedNodesMultiplier = 1.0F;
|
||||||
- private final PathFinder pathFinder;
|
- private final PathFinder pathFinder;
|
||||||
+ private final PathFinder pathFinder; public PathFinder getPathfinder() { return this.pathFinder; } // Paper - OBFHELPER
|
+ private final PathFinder pathFinder; public PathFinder getPathfinder() { return this.pathFinder; } // Paper - OBFHELPER
|
||||||
private boolean isStuck;
|
private boolean isStuck;
|
||||||
@ -22,34 +22,34 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
--- a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
|
--- a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
|
+++ b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
|
||||||
@@ -0,0 +0,0 @@ public class PathFinder {
|
@@ -0,0 +0,0 @@ public class PathFinder {
|
||||||
|
private static final float FUDGING = 1.5F;
|
||||||
private final Node[] neighbors = new Node[32];
|
private final Node[] neighbors = new Node[32];
|
||||||
private final int maxVisitedNodes;
|
private final int maxVisitedNodes;
|
||||||
- private final NodeEvaluator nodeEvaluator;
|
- private final NodeEvaluator nodeEvaluator;
|
||||||
+ private final NodeEvaluator nodeEvaluator; public NodeEvaluator getPathfinder() { return this.nodeEvaluator; } // Paper - OBFHELPER
|
+ private final NodeEvaluator nodeEvaluator; public NodeEvaluator getPathfinder() { return this.nodeEvaluator; } // Paper - OBFHELPER
|
||||||
|
private static final boolean DEBUG = false;
|
||||||
private final BinaryHeap openSet = new BinaryHeap();
|
private final BinaryHeap openSet = new BinaryHeap();
|
||||||
|
|
||||||
public PathFinder(NodeEvaluator pathNodeMaker, int range) {
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java b/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
|
diff --git a/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java b/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
|
--- a/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
|
+++ b/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
|
||||||
@@ -0,0 +0,0 @@ public class WalkNodeEvaluator extends NodeEvaluator {
|
@@ -0,0 +0,0 @@ public class WalkNodeEvaluator extends NodeEvaluator {
|
||||||
for (int j1 = -1; j1 <= 1; ++j1) {
|
for(int n = -1; n <= 1; ++n) {
|
||||||
if (l != 0 || j1 != 0) {
|
if (l != 0 || n != 0) {
|
||||||
blockposition_mutableblockposition.set(i + l, j + i1, k + j1);
|
pos.set(i + l, j + m, k + n);
|
||||||
- BlockState iblockdata = iblockaccess.getBlockState(blockposition_mutableblockposition);
|
- BlockState blockState = world.getBlockState(pos);
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ BlockState iblockdata = iblockaccess.getTypeIfLoaded(blockposition_mutableblockposition);
|
+ BlockState blockState = world.getTypeIfLoaded(pos);
|
||||||
+ if (iblockdata == null) {
|
+ if (blockState == null) {
|
||||||
+ pathtype = BlockPathTypes.BLOCKED;
|
+ return BlockPathTypes.BLOCKED;
|
||||||
+ } else {
|
+ } else {
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
|
if (blockState.is(Blocks.CACTUS)) {
|
||||||
if (iblockdata.is(Blocks.CACTUS)) {
|
|
||||||
return BlockPathTypes.DANGER_CACTUS;
|
return BlockPathTypes.DANGER_CACTUS;
|
||||||
|
}
|
||||||
@@ -0,0 +0,0 @@ public class WalkNodeEvaluator extends NodeEvaluator {
|
@@ -0,0 +0,0 @@ public class WalkNodeEvaluator extends NodeEvaluator {
|
||||||
if (iblockaccess.getFluidState(blockposition_mutableblockposition).is((Tag) FluidTags.WATER)) {
|
if (world.getFluidState(pos).is(FluidTags.WATER)) {
|
||||||
return BlockPathTypes.WATER_BORDER;
|
return BlockPathTypes.WATER_BORDER;
|
||||||
}
|
}
|
||||||
+ } // Paper
|
+ } // Paper
|
||||||
@ -59,10 +59,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
@@ -0,0 +0,0 @@ public class WalkNodeEvaluator extends NodeEvaluator {
|
@@ -0,0 +0,0 @@ public class WalkNodeEvaluator extends NodeEvaluator {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static BlockPathTypes getBlockPathTypeRaw(BlockGetter iblockaccess, BlockPos blockposition) {
|
protected static BlockPathTypes getBlockPathTypeRaw(BlockGetter world, BlockPos pos) {
|
||||||
- BlockState iblockdata = iblockaccess.getBlockState(blockposition);
|
- BlockState blockState = world.getBlockState(pos);
|
||||||
+ BlockState iblockdata = iblockaccess.getTypeIfLoaded(blockposition); // Paper
|
+ BlockState blockState = world.getTypeIfLoaded(pos); // Paper
|
||||||
+ if (iblockdata == null) return BlockPathTypes.BLOCKED; // Paper
|
+ if (blockState == null) return BlockPathTypes.BLOCKED; // Paper
|
||||||
Block block = iblockdata.getBlock();
|
Block block = blockState.getBlock();
|
||||||
Material material = iblockdata.getMaterial();
|
Material material = blockState.getMaterial();
|
||||||
|
if (blockState.isAir()) {
|
@ -8,15 +8,6 @@ diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/mai
|
|||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
@@ -0,0 +0,0 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
|
|
||||||
if (entity instanceof Mob) {
|
|
||||||
this.navigations.remove(((Mob) entity).getNavigation());
|
|
||||||
}
|
|
||||||
-
|
|
||||||
+ new com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent(entity.getBukkitEntity()).callEvent(); // Paper - fire while valid
|
|
||||||
entity.valid = false; // CraftBukkit
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -0,0 +0,0 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
|
@@ -0,0 +0,0 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
|
||||||
entity.origin = entity.getBukkitEntity().getLocation();
|
entity.origin = entity.getBukkitEntity().getLocation();
|
||||||
}
|
}
|
||||||
@ -25,3 +16,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +0,0 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
|
||||||
|
}
|
||||||
|
|
||||||
|
entity.valid = false; // CraftBukkit
|
||||||
|
+ new com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent(entity.getBukkitEntity()).callEvent(); // Paper - fire while valid
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -36,9 +36,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
||||||
@@ -0,0 +0,0 @@ import net.minecraft.core.BlockPos;
|
@@ -0,0 +0,0 @@ import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Position;
|
|
||||||
import net.minecraft.core.Vec3i;
|
import net.minecraft.core.Vec3i;
|
||||||
import net.minecraft.network.protocol.game.DebugPackets;
|
import net.minecraft.network.protocol.game.DebugPackets;
|
||||||
|
import net.minecraft.tags.BlockTags;
|
||||||
+import net.minecraft.server.MCUtil;
|
+import net.minecraft.server.MCUtil;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
@ -46,7 +46,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
@@ -0,0 +0,0 @@ import net.minecraft.world.phys.Vec3;
|
@@ -0,0 +0,0 @@ import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
public abstract class PathNavigation {
|
public abstract class PathNavigation {
|
||||||
|
private static final int MAX_TIME_RECOMPUTE = 20;
|
||||||
- protected final Mob mob;
|
- protected final Mob mob;
|
||||||
+ protected final Mob mob; public Entity getEntity() { return mob; } // Paper - OBFHELPER
|
+ protected final Mob mob; public Entity getEntity() { return mob; } // Paper - OBFHELPER
|
||||||
protected final Level level;
|
protected final Level level;
|
||||||
@ -60,66 +60,59 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ // Paper start - add target parameter
|
+ // Paper start - add target parameter
|
||||||
+ return this.a(target, null, distance);
|
+ return this.a(target, null, distance);
|
||||||
+ }
|
+ }
|
||||||
+ @Nullable public Path a(BlockPos blockposition, Entity target, int i) {
|
+ @Nullable public Path a(BlockPos blockposition, Entity target, int distance) {
|
||||||
+ return this.a(ImmutableSet.of(blockposition), target, 8, false, i);
|
+ return this.createPath(ImmutableSet.of(blockposition), target, 8, false, distance);
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@@ -0,0 +0,0 @@ public abstract class PathNavigation {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Path createPath(Entity entity, int distance) {
|
public Path createPath(Entity entity, int distance) {
|
||||||
- return this.createPath(ImmutableSet.of(entity.blockPosition()), 16, true, distance);
|
- return this.createPath(ImmutableSet.of(entity.blockPosition()), 16, true, distance);
|
||||||
+ return this.a(ImmutableSet.of(entity.blockPosition()), entity, 16, true, distance); // Paper
|
+ return this.createPath(ImmutableSet.of(entity.blockPosition()), entity, 16, true, distance); // Paper
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
+ // Paper start - Add target
|
@@ -0,0 +0,0 @@ public abstract class PathNavigation {
|
||||||
protected Path createPath(Set<BlockPos> positions, int range, boolean flag, int distance) {
|
|
||||||
- if (positions.isEmpty()) {
|
@Nullable
|
||||||
+ return this.a(positions, null, range, flag, distance);
|
protected Path createPath(Set<BlockPos> positions, int range, boolean useHeadPos, int distance, float followRange) {
|
||||||
|
+ return this.createPath(positions, null, range, useHeadPos, distance, (float) this.mob.getAttributeValue(Attributes.FOLLOW_RANGE));
|
||||||
+ }
|
+ }
|
||||||
+ @Nullable protected Path a(Set<BlockPos> set, Entity target, int i, boolean flag, int j) {
|
+
|
||||||
|
+ @Nullable
|
||||||
|
+ protected Path createPath(Set<BlockPos> positions, Entity target, int range, boolean useHeadPos, int distance) {
|
||||||
|
+ return this.createPath(positions, target, range, useHeadPos, distance, (float) this.mob.getAttributeValue(Attributes.FOLLOW_RANGE));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Nullable protected Path createPath(Set<BlockPos> positions, Entity target, int range, boolean useHeadPos, int distance, float followRange) {
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
+ if (set.isEmpty()) {
|
if (positions.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
} else if (this.mob.getY() < 0.0D) {
|
} else if (this.mob.getY() < (double)this.level.getMinBuildHeight()) {
|
||||||
return null;
|
@@ -0,0 +0,0 @@ public abstract class PathNavigation {
|
||||||
} else if (!this.canUpdatePath()) {
|
} else if (this.path != null && !this.path.isDone() && positions.contains(this.targetPos)) {
|
||||||
return null;
|
|
||||||
- } else if (this.path != null && !this.path.isDone() && positions.contains(this.targetPos)) {
|
|
||||||
+ } else if (this.path != null && !this.path.isDone() && set.contains(this.targetPos)) {
|
|
||||||
return this.path;
|
return this.path;
|
||||||
} else {
|
} else {
|
||||||
+ // Paper start - Pathfind event
|
+ // Paper start - Pathfind event
|
||||||
+ boolean copiedSet = false;
|
+ boolean copiedSet = false;
|
||||||
+ for (BlockPos possibleTarget : set) {
|
+ for (BlockPos possibleTarget : positions) {
|
||||||
+ if (!new com.destroystokyo.paper.event.entity.EntityPathfindEvent(getEntity().getBukkitEntity(),
|
+ if (!new com.destroystokyo.paper.event.entity.EntityPathfindEvent(getEntity().getBukkitEntity(),
|
||||||
+ MCUtil.toLocation(getEntity().level, possibleTarget), target == null ? null : target.getBukkitEntity()).callEvent()) {
|
+ MCUtil.toLocation(getEntity().level, possibleTarget), target == null ? null : target.getBukkitEntity()).callEvent()) {
|
||||||
+ if (!copiedSet) {
|
+ if (!copiedSet) {
|
||||||
+ copiedSet = true;
|
+ copiedSet = true;
|
||||||
+ set = new java.util.HashSet<>(set);
|
+ positions = new java.util.HashSet<>(positions);
|
||||||
+ }
|
+ }
|
||||||
+ // note: since we copy the set this remove call is safe, since we're iterating over the old copy
|
+ // note: since we copy the set this remove call is safe, since we're iterating over the old copy
|
||||||
+ set.remove(possibleTarget);
|
+ positions.remove(possibleTarget);
|
||||||
+ if (set.isEmpty()) {
|
+ if (positions.isEmpty()) {
|
||||||
+ return null;
|
+ return null;
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
this.level.getProfiler().push("pathfind");
|
this.level.getProfiler().push("pathfind");
|
||||||
float f = (float) this.mob.getAttributeValue(Attributes.FOLLOW_RANGE);
|
BlockPos blockPos = useHeadPos ? this.mob.blockPosition().above() : this.mob.blockPosition();
|
||||||
BlockPos blockposition = flag ? this.mob.blockPosition().above() : this.mob.blockPosition();
|
int i = (int)(followRange + (float)range);
|
||||||
- int k = (int) (f + (float) range);
|
|
||||||
+ int k = (int) (f + (float) i);
|
|
||||||
PathNavigationRegion chunkcache = new PathNavigationRegion(this.level, blockposition.offset(-k, -k, -k), blockposition.offset(k, k, k));
|
|
||||||
- Path pathentity = this.pathFinder.findPath(chunkcache, this.mob, positions, f, distance, this.maxVisitedNodesMultiplier);
|
|
||||||
+ Path pathentity = this.pathFinder.findPath(chunkcache, this.mob, set, f, j, this.maxVisitedNodesMultiplier);
|
|
||||||
|
|
||||||
this.level.getProfiler().pop();
|
|
||||||
if (pathentity != null && pathentity.getTarget() != null) {
|
|
||||||
this.targetPos = pathentity.getTarget();
|
|
||||||
- this.reachRange = distance;
|
|
||||||
+ this.reachRange = j;
|
|
||||||
this.resetStuckTimeout();
|
|
||||||
}
|
|
||||||
|
|
@ -48,23 +48,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
CraftWorld world = ((ServerLevel) this).getWorld();
|
CraftWorld world = ((ServerLevel) this).getWorld();
|
||||||
- if (world != null) {
|
- if (world != null) {
|
||||||
+ if (world != null && ((ServerLevel)this).hasPhysicsEvent) { // Paper
|
+ if (world != null && ((ServerLevel)this).hasPhysicsEvent) { // Paper
|
||||||
BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(sourcePos.getX(), sourcePos.getY(), sourcePos.getZ()), CraftBlockData.fromData(iblockdata), world.getBlockAt(neighborPos.getX(), neighborPos.getY(), neighborPos.getZ()));
|
BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(pos.getX(), pos.getY(), pos.getZ()), CraftBlockData.fromData(iblockdata), world.getBlockAt(neighborPos.getX(), neighborPos.getY(), neighborPos.getZ()));
|
||||||
this.getCraftServer().getPluginManager().callEvent(event);
|
this.getCraftServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/BushBlock.java b/src/main/java/net/minecraft/world/level/block/BushBlock.java
|
diff --git a/src/main/java/net/minecraft/world/level/block/BushBlock.java b/src/main/java/net/minecraft/world/level/block/BushBlock.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/BushBlock.java
|
--- a/src/main/java/net/minecraft/world/level/block/BushBlock.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/BushBlock.java
|
+++ b/src/main/java/net/minecraft/world/level/block/BushBlock.java
|
||||||
@@ -0,0 +0,0 @@ package net.minecraft.world.level.block;
|
@@ -0,0 +0,0 @@ import net.minecraft.core.BlockPos;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.tags.BlockTags;
|
||||||
|
import net.minecraft.tags.Tag;
|
||||||
+import net.minecraft.server.level.ServerLevel;
|
+import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.world.level.BlockGetter;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.level.LevelAccessor;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
import net.minecraft.world.level.LevelReader;
|
import net.minecraft.world.level.LevelReader;
|
||||||
@@ -0,0 +0,0 @@ public class BushBlock extends Block {
|
@@ -0,0 +0,0 @@ public class BushBlock extends Block {
|
||||||
public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world, BlockPos pos, BlockPos posFrom) {
|
public BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
if (!state.canSurvive(world, pos)) {
|
if (!state.canSurvive(world, pos)) {
|
||||||
- if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world, pos).isCancelled()) {
|
- if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world, pos).isCancelled()) {
|
||||||
@ -76,10 +76,10 @@ diff --git a/src/main/java/net/minecraft/world/level/block/DoublePlantBlock.java
|
|||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/DoublePlantBlock.java
|
--- a/src/main/java/net/minecraft/world/level/block/DoublePlantBlock.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/DoublePlantBlock.java
|
+++ b/src/main/java/net/minecraft/world/level/block/DoublePlantBlock.java
|
||||||
@@ -0,0 +0,0 @@ package net.minecraft.world.level.block;
|
@@ -0,0 +0,0 @@ import javax.annotation.Nullable;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.util.Mth;
|
||||||
+import net.minecraft.server.level.ServerLevel;
|
+import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
@ -17,15 +17,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
--- a/src/main/java/net/minecraft/core/Vec3i.java
|
--- a/src/main/java/net/minecraft/core/Vec3i.java
|
||||||
+++ b/src/main/java/net/minecraft/core/Vec3i.java
|
+++ b/src/main/java/net/minecraft/core/Vec3i.java
|
||||||
@@ -0,0 +0,0 @@ public class Vec3i implements Comparable<Vec3i> {
|
@@ -0,0 +0,0 @@ public class Vec3i implements Comparable<Vec3i> {
|
||||||
private int y;public final void setY(final int y) { this.y = y; } // Paper - OBFHELPER
|
private int y;
|
||||||
private int z;public final void setZ(final int z) { this.z = z; } // Paper - OBFHELPER
|
private int z;
|
||||||
|
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ public boolean isValidLocation() {
|
+ public boolean isValidLocation(net.minecraft.world.level.Level level) {
|
||||||
+ return getX() >= -30000000 && getZ() >= -30000000 && getX() < 30000000 && getZ() < 30000000 && getY() >= 0 && getY() < 256;
|
+ return getX() >= -30000000 && getZ() >= -30000000 && getX() < 30000000 && getZ() < 30000000 && !level.isOutsideBuildHeight(getY());
|
||||||
+ }
|
+ }
|
||||||
+ public boolean isInvalidYLocation() {
|
+ public boolean isInvalidYLocation(net.minecraft.world.level.Level level) {
|
||||||
+ return y < 0 || y >= 256;
|
+ return level.isOutsideBuildHeight(getY());
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
+
|
+
|
||||||
@ -39,9 +39,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isInWorldBounds(BlockPos pos) {
|
public boolean isInWorldBounds(BlockPos pos) {
|
||||||
- return !isOutsideBuildHeight(pos) && isInWorldBoundsHorizontal(pos);
|
- return !this.isOutsideBuildHeight(pos) && Level.isInWorldBoundsHorizontal(pos);
|
||||||
+ return pos.isValidLocation(); // Paper - use better/optimized check
|
+ return pos.isValidLocation(this); // Paper - use better/optimized check
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isInSpawnableBounds(BlockPos pos) {
|
public static boolean isInSpawnableBounds(BlockPos pos) {
|
||||||
@ -49,9 +49,9 @@ diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java b/sr
|
|||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
|
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
|
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
|
||||||
@@ -0,0 +0,0 @@ import org.apache.logging.log4j.LogManager;
|
@@ -0,0 +0,0 @@ public interface ChunkAccess extends BlockGetter, FeatureAccess {
|
||||||
|
return GameEventDispatcher.NOOP;
|
||||||
public interface ChunkAccess extends BlockGetter, FeatureAccess {
|
}
|
||||||
|
|
||||||
+ BlockState getType(final int x, final int y, final int z); // Paper
|
+ BlockState getType(final int x, final int y, final int z); // Paper
|
||||||
@Nullable
|
@Nullable
|
||||||
@ -61,17 +61,8 @@ diff --git a/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java
|
|||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java
|
--- a/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java
|
+++ b/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java
|
||||||
@@ -0,0 +0,0 @@ import net.minecraft.world.phys.AABB;
|
|
||||||
|
|
||||||
public class EmptyLevelChunk extends LevelChunk {
|
|
||||||
|
|
||||||
- private static final Biome[] BIOMES = (Biome[]) Util.make((Object) (new Biome[ChunkBiomeContainer.BIOMES_SIZE]), (abiomebase) -> {
|
|
||||||
+ private static final Biome[] BIOMES = Util.make((new Biome[ChunkBiomeContainer.BIOMES_SIZE]), (abiomebase) -> { // Paper - decompile error
|
|
||||||
Arrays.fill(abiomebase, Biomes.PLAINS);
|
|
||||||
});
|
|
||||||
|
|
||||||
@@ -0,0 +0,0 @@ public class EmptyLevelChunk extends LevelChunk {
|
@@ -0,0 +0,0 @@ public class EmptyLevelChunk extends LevelChunk {
|
||||||
super(world, pos, new ChunkBiomeContainer(world.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), EmptyLevelChunk.BIOMES));
|
super(world, pos, new EmptyLevelChunk.EmptyChunkBiomeContainer(world));
|
||||||
}
|
}
|
||||||
|
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
@ -106,32 +97,32 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
return this.sections;
|
return this.sections;
|
||||||
}
|
}
|
||||||
|
|
||||||
- @Override
|
|
||||||
+ // Paper start - Optimize getBlockData to reduce instructions
|
+ // Paper start - Optimize getBlockData to reduce instructions
|
||||||
+ public final BlockState getBlockData(BlockPos pos) { return getBlockData(pos.getX(), pos.getY(), pos.getZ()); } // Paper
|
@Override
|
||||||
public BlockState getBlockState(BlockPos pos) {
|
public BlockState getBlockState(BlockPos pos) {
|
||||||
- int i = pos.getX();
|
- int i = pos.getX();
|
||||||
- int j = pos.getY();
|
- int j = pos.getY();
|
||||||
- int k = pos.getZ();
|
- int k = pos.getZ();
|
||||||
+ return this.getBlockData(pos.getX(), pos.getY(), pos.getZ());
|
+ return this.getBlockData(pos.getX(), pos.getY(), pos.getZ());
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
+ public BlockState getType(final int x, final int y, final int z) {
|
+ public BlockState getType(final int x, final int y, final int z) {
|
||||||
+ return getBlockData(x, y, z);
|
+ return this.getBlockData(x, y, z);
|
||||||
+ }
|
+ }
|
||||||
+ public final BlockState getBlockData(final int x, final int y, final int z) {
|
+ public final BlockState getBlockData(final int x, final int y, final int z) {
|
||||||
+ // Method body / logic copied from below
|
+ // Method body / logic copied from below
|
||||||
+ final int i = y >> 4;
|
+ final int i = this.getSectionIndex(y);
|
||||||
+ if (y < 0 || i >= this.sections.length || this.sections[i] == null || this.sections[i].nonEmptyBlockCount == 0) {
|
+ if (i < 0 || i >= this.sections.length || this.sections[i] == null || this.sections[i].nonEmptyBlockCount == 0) {
|
||||||
+ return Blocks.AIR.defaultBlockState();
|
+ return Blocks.AIR.defaultBlockState();
|
||||||
+ }
|
+ }
|
||||||
+ // Inlined ChunkSection.getType() and DataPaletteBlock.a(int,int,int)
|
+ // Inlined ChunkSection.getType() and DataPaletteBlock.a(int,int,int)
|
||||||
+ return this.sections[i].states.get((y & 15) << 8 | (z & 15) << 4 | x & 15);
|
+ return this.sections[i].states.get((y & 15) << 8 | (z & 15) << 4 | x & 15);
|
||||||
|
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public BlockState getBlockData_unused(int i, int j, int k) {
|
+ public BlockState getBlockData_unused(int i, int j, int k) {
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
if (this.world.isDebug()) {
|
if (this.level.isDebug()) {
|
||||||
BlockState iblockdata = null;
|
BlockState iblockdata = null;
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
|
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||||
@ -139,7 +130,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
|
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
|
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||||
@@ -0,0 +0,0 @@ public class LevelChunkSection {
|
@@ -0,0 +0,0 @@ public class LevelChunkSection {
|
||||||
|
public static final int SECTION_SIZE = 4096;
|
||||||
public static final Palette<BlockState> GLOBAL_BLOCKSTATE_PALETTE = new GlobalPalette<>(Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState());
|
public static final Palette<BlockState> GLOBAL_BLOCKSTATE_PALETTE = new GlobalPalette<>(Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState());
|
||||||
private final int bottomBlockY;
|
private final int bottomBlockY;
|
||||||
- private short nonEmptyBlockCount;
|
- private short nonEmptyBlockCount;
|
||||||
@ -150,14 +141,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ final PalettedContainer<BlockState> states; // Paper - package-private
|
+ final PalettedContainer<BlockState> states; // Paper - package-private
|
||||||
|
|
||||||
public LevelChunkSection(int yOffset) {
|
public LevelChunkSection(int yOffset) {
|
||||||
this(yOffset, (short) 0, (short) 0, (short) 0);
|
this(yOffset, (short)0, (short)0, (short)0);
|
||||||
@@ -0,0 +0,0 @@ public class LevelChunkSection {
|
@@ -0,0 +0,0 @@ public class LevelChunkSection {
|
||||||
this.states = new PalettedContainer<>(LevelChunkSection.GLOBAL_BLOCKSTATE_PALETTE, Block.BLOCK_STATE_REGISTRY, NbtUtils::readBlockState, NbtUtils::writeBlockState, Blocks.AIR.defaultBlockState());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- public BlockState getBlockState(int x, int y, int z) {
|
public BlockState getBlockState(int x, int y, int z) {
|
||||||
- return (BlockState) this.states.get(x, y, z);
|
- return this.states.get(x, y, z);
|
||||||
+ public final BlockState getBlockState(int x, int y, int z) { // Paper
|
|
||||||
+ return this.states.get(y << 8 | z << 4 | x); // Paper - inline
|
+ return this.states.get(y << 8 | z << 4 | x); // Paper - inline
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,19 +173,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
@Override
|
@Override
|
||||||
public BlockState getBlockState(BlockPos pos) {
|
public BlockState getBlockState(BlockPos pos) {
|
||||||
- int i = pos.getY();
|
- int i = pos.getY();
|
||||||
-
|
- if (this.isOutsideBuildHeight(i)) {
|
||||||
- if (Level.isOutsideBuildHeight(i)) {
|
+ // Paper start
|
||||||
+ return getType(pos.getX(), pos.getY(), pos.getZ());
|
+ return getType(pos.getX(), pos.getY(), pos.getZ());
|
||||||
+ }
|
+ }
|
||||||
+ // Paper start
|
|
||||||
+ public BlockState getType(final int x, final int y, final int z) {
|
+ public BlockState getType(final int x, final int y, final int z) {
|
||||||
+ if (y < 0 || y >= 256) {
|
+ if (this.isOutsideBuildHeight(y)) {
|
||||||
return Blocks.VOID_AIR.defaultBlockState();
|
return Blocks.VOID_AIR.defaultBlockState();
|
||||||
} else {
|
} else {
|
||||||
- LevelChunkSection chunksection = this.getSections()[i >> 4];
|
- LevelChunkSection levelChunkSection = this.getSections()[this.getSectionIndex(i)];
|
||||||
-
|
- return LevelChunkSection.isEmpty(levelChunkSection) ? Blocks.AIR.defaultBlockState() : levelChunkSection.getBlockState(pos.getX() & 15, i & 15, pos.getZ() & 15);
|
||||||
- return LevelChunkSection.isEmpty(chunksection) ? Blocks.AIR.defaultBlockState() : chunksection.getBlockState(pos.getX() & 15, i & 15, pos.getZ() & 15);
|
+ LevelChunkSection chunksection = this.getSections()[this.getSectionIndex(y)];
|
||||||
+ LevelChunkSection chunksection = this.getSections()[y >> 4];
|
|
||||||
+ return chunksection == LevelChunk.EMPTY_CHUNK_SECTION || chunksection.isEmpty() ? Blocks.AIR.defaultBlockState() : chunksection.getBlockState(x & 15, y & 15, z & 15);
|
+ return chunksection == LevelChunk.EMPTY_CHUNK_SECTION || chunksection.isEmpty() ? Blocks.AIR.defaultBlockState() : chunksection.getBlockState(x & 15, y & 15, z & 15);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,7 +9,7 @@ diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/jav
|
|||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
|
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
|
||||||
return tag.contains("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level;
|
return tag.contains("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,10 +31,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
private CraftEntity bukkitEntity;
|
private CraftEntity bukkitEntity;
|
||||||
|
|
||||||
public CraftEntity getBukkitEntity() {
|
public CraftEntity getBukkitEntity() {
|
||||||
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
|
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
|
||||||
|
this.bb = Entity.INITIAL_AABB;
|
||||||
this.stuckSpeedMultiplier = Vec3.ZERO;
|
this.stuckSpeedMultiplier = Vec3.ZERO;
|
||||||
this.nextStep = 1.0F;
|
this.nextStep = 1.0F;
|
||||||
this.nextFlap = 1.0F;
|
|
||||||
- this.random = new Random();
|
- this.random = new Random();
|
||||||
+ this.random = SHARED_RANDOM; // Paper
|
+ this.random = SHARED_RANDOM; // Paper
|
||||||
this.remainingFireTicks = -this.getFireImmuneTicks();
|
this.remainingFireTicks = -this.getFireImmuneTicks();
|
Loading…
Reference in New Issue
Block a user