-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@72e87ab Strip raytracing for EntityLiving#hasLineOfSight Purpur Changes: PurpurMC/Purpur@39bdf3d Updated Upstream (Paper)
- Loading branch information
1 parent
a76facf
commit d8856b5
Showing
7 changed files
with
28 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
purpurCommit = 671c31a78762994ead0b11a46e0257d6b9fafd0e | ||
purpurCommit = 39bdf3d2e045857f328bd628f785c54be951e9bd | ||
pufferfishCommit = e32a780bcab6821e3804846a63a9153fdeee44f4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: AlphaKR93 <[email protected]> | ||
Date: Sat, 9 Sep 2023 16:24:45 +0000 | ||
Date: Mon, 11 Sep 2023 01:06:55 +0000 | ||
Subject: [PATCH] Pufferfish API Changes | ||
|
||
Original: Kevin Raneri <[email protected]> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: AlphaKR93 <[email protected]> | ||
Date: Sat, 9 Sep 2023 16:32:10 +0000 | ||
Date: Mon, 11 Sep 2023 01:08:35 +0000 | ||
Subject: [PATCH] Purpur API Changes | ||
|
||
Original: PurpurMC | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: AlphaKR93 <[email protected]> | ||
Date: Sat, 9 Sep 2023 16:24:45 +0000 | ||
Date: Mon, 11 Sep 2023 01:06:55 +0000 | ||
Subject: [PATCH] Pufferfish Server Changes | ||
|
||
Original: Kevin Raneri <[email protected]> | ||
|
@@ -2134,7 +2134,7 @@ index 9afc81ccb237c3655d64cdbe8a0db9a4d7791043..aa5cec6d56d7a8e80861aa4c9b4a74ca | |
private String descriptionId; | ||
@Nullable | ||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java | ||
index e11d7283662834047b2ff81a2fd25a4263792deb..e07140ef2f4c5b0019550eb3100c724699e7a05c 100644 | ||
index 7763450e85146d43fcf84d380d0e7a8183d83747..0059ceabaed9c1888a6773efb906e761fd1ca252 100644 | ||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java | ||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java | ||
@@ -142,7 +142,6 @@ import org.bukkit.event.entity.EntityTeleportEvent; | ||
|
@@ -2195,18 +2195,6 @@ index e11d7283662834047b2ff81a2fd25a4263792deb..e07140ef2f4c5b0019550eb3100c7246 | |
public boolean onClimbable() { | ||
if (this.isSpectator()) { | ||
return false; | ||
@@ -3651,7 +3677,10 @@ public abstract class LivingEntity extends Entity implements Attackable { | ||
Vec3 vec3d1 = new Vec3(entity.getX(), entity.getEyeY(), entity.getZ()); | ||
|
||
// Paper - diff on change - used in CraftLivingEntity#hasLineOfSight(Location) and CraftWorld#lineOfSightExists | ||
- return vec3d1.distanceToSqr(vec3d) > 128D * 128D ? false : this.level().clip(new ClipContext(vec3d, vec3d1, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this)).getType() == HitResult.Type.MISS; | ||
+ // Pufferfish start | ||
+ //return vec3d1.distanceToSqr(vec3d) > 128D * 128D ? false : this.level().clip(new ClipContext(vec3d, vec3d1, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this)).getType() == HitResult.Type.MISS; | ||
+ return vec3d1.distanceToSqr(vec3d) > 128D * 128D ? false : this.level().rayTraceDirect(vec3d, vec3d1, net.minecraft.world.phys.shapes.CollisionContext.of(this)) == net.minecraft.world.phys.BlockHitResult.Type.MISS; | ||
+ // Pufferfish end | ||
} | ||
} | ||
|
||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java | ||
index e2a25c29ec74147b3e66aa0b3deb85a8f6ee53a5..f6eb032897c6d5d16ab5c8c287e49e189c24571c 100644 | ||
--- a/src/main/java/net/minecraft/world/entity/Mob.java | ||
|
@@ -2281,18 +2269,6 @@ index dd1102d5291ef6f18e82400a6d8a0a376cc071e9..e283eb57c25f7de222f9d09dca851169 | |
} | ||
|
||
@Nullable | ||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java b/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java | ||
index d4c91e0a0c64fcb7f1145de3f30134cb1f1f8ee6..fe502445a77afe7e3807afae48d7bf03f370e290 100644 | ||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java | ||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java | ||
@@ -47,6 +47,7 @@ public class AcquirePoi { | ||
return false; | ||
} else { | ||
mutableLong.setValue(time + 20L + (long)world.getRandom().nextInt(20)); | ||
+ if (entity.getNavigation().isStuck()) mutableLong.add(200); // Pufferfish - wait an additional 10s to check again if they're stuck | ||
PoiManager poiManager = world.getPoiManager(); | ||
long2ObjectMap.long2ObjectEntrySet().removeIf((entry) -> { | ||
return !entry.getValue().isStillValid(time); | ||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/VillagerPanicTrigger.java b/src/main/java/net/minecraft/world/entity/ai/behavior/VillagerPanicTrigger.java | ||
index 646d9a121d908a2fc3e4e302484dd5cd1bfc6804..e546ecdccde352502e26a8668eaaafe048d6e282 100644 | ||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/VillagerPanicTrigger.java | ||
|
@@ -2492,27 +2468,6 @@ index 1e07febcf7a3dfb281728cc5e3e4f15dd776d7e0..c65ab566c6241dd6a44bd11a449ef0c4 | |
@Override | ||
protected SoundEvent getAmbientSound() { | ||
return SoundEvents.WITHER_AMBIENT; | ||
diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java | ||
index 52196431a6538872755344859a0454a0e50c3b6e..80fc7918cb294b0d88a293bd6a920441cb55c3ad 100644 | ||
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java | ||
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java | ||
@@ -270,10 +270,16 @@ public class ItemEntity extends Entity implements TraceableEntity { | ||
if (entityitem.isMergable()) { | ||
// Paper Start - Fix items merging through walls | ||
if (this.level().paperConfig().fixes.fixItemsMergingThroughWalls) { | ||
+ // Pufferfish start - skip the allocations | ||
+ /* | ||
net.minecraft.world.level.ClipContext rayTrace = new net.minecraft.world.level.ClipContext(this.position(), entityitem.position(), | ||
net.minecraft.world.level.ClipContext.Block.COLLIDER, net.minecraft.world.level.ClipContext.Fluid.NONE, this); | ||
net.minecraft.world.phys.BlockHitResult rayTraceResult = this.level().clip(rayTrace); | ||
if (rayTraceResult.getType() == net.minecraft.world.phys.HitResult.Type.BLOCK) continue; | ||
+ */ | ||
+ if (level().rayTraceDirect(this.position(), entityitem.position(), net.minecraft.world.phys.shapes.CollisionContext.of(this)) == | ||
+ net.minecraft.world.phys.HitResult.Type.BLOCK) continue; | ||
+ // Pufferfish end | ||
} | ||
// Paper End | ||
this.tryToMerge(entityitem); | ||
diff --git a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java | ||
index b62457313a1e30aad0c5313d608667b5d3811455..410f10ad93935d1c078447a4596023f367a8e9b7 100644 | ||
--- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java | ||
|
@@ -2801,29 +2756,8 @@ index 2e60bdc44c33d434bfd9ca5bf8f75de799c6768c..565318c2afaa1661ed9963453a6354df | |
StackedContents autorecipestackmanager = new StackedContents(); | ||
autorecipestackmanager.initialize(this); // Paper - better exact choice recipes | ||
int i = 0; | ||
diff --git a/src/main/java/net/minecraft/world/level/BlockGetter.java b/src/main/java/net/minecraft/world/level/BlockGetter.java | ||
index 0e8746759752b692668886370181aa5db1fd0bb0..58e5ce2afabf480f5dfd9adf43f8fc12666861c6 100644 | ||
--- a/src/main/java/net/minecraft/world/level/BlockGetter.java | ||
+++ b/src/main/java/net/minecraft/world/level/BlockGetter.java | ||
@@ -68,6 +68,16 @@ public interface BlockGetter extends LevelHeightAccessor { | ||
}); | ||
} | ||
|
||
+ // Pufferfish start - broken down variant of below rayTraceBlock, used by World#rayTraceDirect | ||
+ default net.minecraft.world.phys.BlockHitResult.Type rayTraceBlockDirect(Vec3 vec3d, Vec3 vec3d1, BlockPos blockposition, BlockState iblockdata, net.minecraft.world.phys.shapes.CollisionContext voxelshapecoll) { | ||
+ if (iblockdata.isAir()) return null; // Tuinity - optimise air cases | ||
+ VoxelShape voxelshape = ClipContext.Block.COLLIDER.get(iblockdata, this, blockposition, voxelshapecoll); | ||
+ net.minecraft.world.phys.BlockHitResult movingobjectpositionblock = this.clipWithInteractionOverride(vec3d, vec3d1, blockposition, voxelshape, iblockdata); | ||
+ | ||
+ return movingobjectpositionblock == null ? null : movingobjectpositionblock.getType(); | ||
+ } | ||
+ // Pufferfish end | ||
+ | ||
// CraftBukkit start - moved block handling into separate method for use by Block#rayTrace | ||
default BlockHitResult clip(ClipContext raytrace1, BlockPos blockposition) { | ||
// Paper start - Prevent raytrace from loading chunks | ||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java | ||
index f39ab10c5b0b8d86b579a5b683491204c51db70b..d8d4a1ca2eb062af8b2de4ab44503983587cdd77 100644 | ||
index 773bfdd3ed457a352b5329f280c0d10297d579ba..5c83d703211725ddc36602bb480545288d6a06d9 100644 | ||
--- a/src/main/java/net/minecraft/world/level/Level.java | ||
+++ b/src/main/java/net/minecraft/world/level/Level.java | ||
@@ -273,6 +273,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable { | ||
|
@@ -2858,99 +2792,7 @@ index f39ab10c5b0b8d86b579a5b683491204c51db70b..d8d4a1ca2eb062af8b2de4ab44503983 | |
this.dimension = resourcekey; | ||
this.isClientSide = flag; | ||
if (dimensionmanager.coordinateScale() != 1.0D) { | ||
@@ -412,6 +430,91 @@ public abstract class Level implements LevelAccessor, AutoCloseable { | ||
return null; | ||
} | ||
|
||
+ // Pufferfish start - broken down method of raytracing for EntityLiving#hasLineOfSight, replaces IBlockAccess#rayTrace(RayTrace) | ||
+ public net.minecraft.world.phys.BlockHitResult.Type rayTraceDirect(net.minecraft.world.phys.Vec3 vec3d, net.minecraft.world.phys.Vec3 vec3d1, net.minecraft.world.phys.shapes.CollisionContext voxelshapecoll) { | ||
+ // most of this code comes from IBlockAccess#a(RayTrace, BiFunction, Function), but removes the needless functions | ||
+ if (vec3d.equals(vec3d1)) { | ||
+ return net.minecraft.world.phys.BlockHitResult.Type.MISS; | ||
+ } | ||
+ | ||
+ double endX = Mth.lerp(-1.0E-7D, vec3d1.x, vec3d.x); | ||
+ double endY = Mth.lerp(-1.0E-7D, vec3d1.y, vec3d.y); | ||
+ double endZ = Mth.lerp(-1.0E-7D, vec3d1.z, vec3d.z); | ||
+ | ||
+ double startX = Mth.lerp(-1.0E-7D, vec3d.x, vec3d1.x); | ||
+ double startY = Mth.lerp(-1.0E-7D, vec3d.y, vec3d1.y); | ||
+ double startZ = Mth.lerp(-1.0E-7D, vec3d.z, vec3d1.z); | ||
+ | ||
+ int currentX = Mth.floor(startX); | ||
+ int currentY = Mth.floor(startY); | ||
+ int currentZ = Mth.floor(startZ); | ||
+ | ||
+ BlockPos.MutableBlockPos currentBlock = new BlockPos.MutableBlockPos(currentX, currentY, currentZ); | ||
+ | ||
+ LevelChunk chunk = this.getChunkIfLoaded(currentBlock); | ||
+ if (chunk == null) { | ||
+ return net.minecraft.world.phys.BlockHitResult.Type.MISS; | ||
+ } | ||
+ | ||
+ net.minecraft.world.phys.BlockHitResult.Type initialCheck = this.rayTraceBlockDirect(vec3d, vec3d1, currentBlock, chunk.getBlockState(currentBlock), voxelshapecoll); | ||
+ | ||
+ if (initialCheck != null) { | ||
+ return initialCheck; | ||
+ } | ||
+ | ||
+ double diffX = endX - startX; | ||
+ double diffY = endY - startY; | ||
+ double diffZ = endZ - startZ; | ||
+ | ||
+ int xDirection = Mth.sign(diffX); | ||
+ int yDirection = Mth.sign(diffY); | ||
+ int zDirection = Mth.sign(diffZ); | ||
+ | ||
+ double normalizedX = xDirection == 0 ? Double.MAX_VALUE : (double) xDirection / diffX; | ||
+ double normalizedY = yDirection == 0 ? Double.MAX_VALUE : (double) yDirection / diffY; | ||
+ double normalizedZ = zDirection == 0 ? Double.MAX_VALUE : (double) zDirection / diffZ; | ||
+ | ||
+ double normalizedXDirection = normalizedX * (xDirection > 0 ? 1.0D - Mth.frac(startX) : Mth.frac(startX)); | ||
+ double normalizedYDirection = normalizedY * (yDirection > 0 ? 1.0D - Mth.frac(startY) : Mth.frac(startY)); | ||
+ double normalizedZDirection = normalizedZ * (zDirection > 0 ? 1.0D - Mth.frac(startZ) : Mth.frac(startZ)); | ||
+ | ||
+ net.minecraft.world.phys.BlockHitResult.Type result; | ||
+ | ||
+ do { | ||
+ if (normalizedXDirection > 1.0D && normalizedYDirection > 1.0D && normalizedZDirection > 1.0D) { | ||
+ return net.minecraft.world.phys.BlockHitResult.Type.MISS; | ||
+ } | ||
+ | ||
+ if (normalizedXDirection < normalizedYDirection) { | ||
+ if (normalizedXDirection < normalizedZDirection) { | ||
+ currentX += xDirection; | ||
+ normalizedXDirection += normalizedX; | ||
+ } else { | ||
+ currentZ += zDirection; | ||
+ normalizedZDirection += normalizedZ; | ||
+ } | ||
+ } else if (normalizedYDirection < normalizedZDirection) { | ||
+ currentY += yDirection; | ||
+ normalizedYDirection += normalizedY; | ||
+ } else { | ||
+ currentZ += zDirection; | ||
+ normalizedZDirection += normalizedZ; | ||
+ } | ||
+ | ||
+ currentBlock.set(currentX, currentY, currentZ); | ||
+ if (chunk.getPos().x != currentBlock.getX() >> 4 || chunk.getPos().z != currentBlock.getZ() >> 4) { | ||
+ chunk = this.getChunkIfLoaded(currentBlock); | ||
+ if (chunk == null) { | ||
+ return net.minecraft.world.phys.BlockHitResult.Type.MISS; | ||
+ } | ||
+ } | ||
+ result = this.rayTraceBlockDirect(vec3d, vec3d1, currentBlock, chunk.getBlockState(currentBlock), voxelshapecoll); | ||
+ } while (result == null); | ||
+ | ||
+ return result; | ||
+ } | ||
+ // Pufferfish end | ||
+ | ||
public boolean isInWorldBounds(BlockPos pos) { | ||
return pos.isInsideBuildHeightAndWorldBoundsHorizontal(this); // Paper - use better/optimized check | ||
} | ||
@@ -919,13 +1022,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable { | ||
@@ -1003,13 +1021,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable { | ||
try { | ||
tickConsumer.accept(entity); | ||
MinecraftServer.getServer().executeMidTickTasks(); // Paper - execute chunk tasks mid tick | ||
|
@@ -2966,7 +2808,7 @@ index f39ab10c5b0b8d86b579a5b683491204c51db70b..d8d4a1ca2eb062af8b2de4ab44503983 | |
// Paper end | ||
} | ||
} | ||
@@ -1380,6 +1483,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { | ||
@@ -1464,6 +1482,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { | ||
} | ||
|
||
public ProfilerFiller getProfiler() { | ||
|
Oops, something went wrong.