Skip to content

Commit

Permalink
Updated Upstream (Pufferfish)
Browse files Browse the repository at this point in the history
Upstream has released updates that appear to apply and compile correctly

Pufferfish Changes:
pufferfish-gg/Pufferfish@3b6f245 Updated Upstream (Paper)
pufferfish-gg/Pufferfish@fb16f9c Updated Upstream (Paper)
pufferfish-gg/Pufferfish@9d12215 Updated Upstream (Paper)
pufferfish-gg/Pufferfish@852ea89 Updated Upstream (Paper)
  • Loading branch information
granny committed Apr 16, 2024
1 parent 0b95a80 commit f2a5ca8
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 66 deletions.
87 changes: 39 additions & 48 deletions patches/server/0001-Pufferfish-Server-Changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -616,10 +616,10 @@ index 0000000000000000000000000000000000000000..020368da69b9a492155f6de6297f7473
+}
diff --git a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..f6a3364175476c57a7763a087ff55e1689474800
index 0000000000000000000000000000000000000000..6464682e2f93659e73aca491031c8051ab000033
--- /dev/null
+++ b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java
@@ -0,0 +1,301 @@
@@ -0,0 +1,302 @@
+package gg.pufferfish.pufferfish;
+
+import gg.pufferfish.pufferfish.simd.SIMDDetection;
Expand Down Expand Up @@ -912,6 +912,7 @@ index 0000000000000000000000000000000000000000..f6a3364175476c57a7763a087ff55e16
+ "the ender dragon whenever a player places an end crystal.");
+ }
+
+
+ public static boolean disableMethodProfiler;
+ public static boolean disableOutOfOrderChat;
+ private static void miscSettings() {
Expand Down Expand Up @@ -1729,7 +1730,7 @@ index 529ab44baaf573b97cf7e89560c548642733188f..db55ad9aaabfa1ea998754f3ac352d16
this.wasOnGround = this.entity.onGround();
this.teleportDelay = 0;
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 502bdc726b7890b00ee36871d905dea44e8719e3..4bd83e1605fb6540be1847dc3691e74b95f260ad 100644
index 502bdc726b7890b00ee36871d905dea44e8719e3..fbffe3dab1b7812b50df5d6bddf4fbdb2e583339 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -894,6 +894,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
Expand All @@ -1755,7 +1756,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..4bd83e1605fb6540be1847dc3691e74b
+ final String msg = String.format("Entity threw exception at %s:%s,%s,%s", entity.level().getWorld().getName(), entity.getX(), entity.getY(), entity.getZ());
+ MinecraftServer.LOGGER.error(msg, throwable);
+ getCraftServer().getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerInternalException(msg, throwable)));
+ entity.discard();
+ entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD);
+ // Paper end
+ }
+ // Pufferfish end
Expand Down Expand Up @@ -2171,7 +2172,7 @@ index 2439f8d48daca7329049436414f06a36b4b79029..4cf2963fdbe9003fd18ac8c2035ccded
this.level().getProfiler().pop();
}
diff --git a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
index b99a080ab27e24d8131fda931ca70d6d271bb01c..fe95cc1d931a5dfed45773b63c565e6036541a90 100644
index b99a080ab27e24d8131fda931ca70d6d271bb01c..8d6954d05d2bf6d6c1c4953db3127b011a858cec 100644
--- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
+++ b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
@@ -23,9 +23,11 @@ public class AttributeMap {
Expand All @@ -2182,7 +2183,7 @@ index b99a080ab27e24d8131fda931ca70d6d271bb01c..fe95cc1d931a5dfed45773b63c565e60

public AttributeMap(AttributeSupplier defaultAttributes) {
this.supplier = defaultAttributes;
+ this.createInstance = attribute -> this.supplier.createInstance(this::onAttributeModified, attribute); // Pufferfish
+ this.createInstance = attributex -> this.supplier.createInstance(this::onAttributeModified, attributex); // Pufferfish
}

private void onAttributeModified(AttributeInstance instance) {
Expand Down Expand Up @@ -2247,7 +2248,7 @@ index de7c3654b5d134e380c0d7e8800beb6c10d8a22a..3e544a1b957e7a9bc2c5548baf7f6499
this.blockPos = mutableBlockPos;
this.mob.movingTarget = mutableBlockPos == BlockPos.ZERO ? null : mutableBlockPos.immutable(); // Paper
diff --git a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java b/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java
index d2f0c3b26d4beedb49d86e0242d843590d469d02..2848f0562de085c0c934455c12d785194b7a9dbf 100644
index d2f0c3b26d4beedb49d86e0242d843590d469d02..28cff997a1b263784e245f692adbff2a888a2d53 100644
--- a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java
+++ b/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java
@@ -76,9 +76,18 @@ public class TargetingConditions {
Expand All @@ -2265,8 +2266,8 @@ index d2f0c3b26d4beedb49d86e0242d843590d469d02..2848f0562de085c0c934455c12d78519
+ return false;
+ }
+
+ double d = this.testInvisible ? targetEntity.getVisibilityPercent(baseEntity) : 1.0D;
+ double e = Math.max((followRangeRaw) * d, 2.0D); // Paper - Fix MC-145656
+ double d = this.testInvisible ? targetEntity.getVisibilityPercent(baseEntity) : 1.0;
+ double e = Math.max((followRangeRaw) * d, 2.0); // Paper - Fix MC-145656
+ // Pufferfish end
if (f > e * e) {
return false;
Expand Down Expand Up @@ -2686,19 +2687,19 @@ index 27b0a79f7a7c47047216aae42944bac2a2151181..a097cfc528f709c80575f35483b68783
autorecipestackmanager.initialize(this); // Paper - better exact choice recipes
int i = 0;
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index ca89d1593bf1b46c79a882db528cbca1359dc9d4..15186884c67f8b75a6b40e244c8b18797f098fd1 100644
index ca89d1593bf1b46c79a882db528cbca1359dc9d4..a82de7111915b19cdc3f065910465a5e7e843aff 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -216,6 +216,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -215,6 +215,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
// Paper end

public abstract ResourceKey<LevelStem> getTypeKey();

+
+ protected final io.papermc.paper.util.math.ThreadUnsafeRandom randomTickRandom = new io.papermc.paper.util.math.ThreadUnsafeRandom(java.util.concurrent.ThreadLocalRandom.current().nextLong()); public net.minecraft.util.RandomSource getThreadUnsafeRandom() { return this.randomTickRandom; } // Pufferfish - move thread unsafe random initialization // Pufferfish - getter
+
protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, RegistryAccess iregistrycustom, Holder<DimensionType> holder, Supplier<ProfilerFiller> supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function<org.spigotmc.SpigotWorldConfig, io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - create paper world config; Async-Anti-Xray: Pass executor
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot
this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config
@@ -1317,14 +1319,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -1317,13 +1319,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
try {
tickConsumer.accept(entity);
MinecraftServer.getServer().executeMidTickTasks(); // Paper - execute chunk tasks mid tick
Expand All @@ -2710,12 +2711,10 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..15186884c67f8b75a6b40e244c8b1879
MinecraftServer.LOGGER.error(msg, throwable);
getCraftServer().getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerInternalException(msg, throwable))); // Paper - ServerExceptionEvent
- entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD);
- // Paper end - Prevent block entity and entity crashes
+ entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD); // Pufferfish - diff on change ServerLevel.tick
+ // Paper end
// Paper end - Prevent block entity and entity crashes
}
}
// Paper start - Option to prevent armor stands from doing entity lookups
@@ -1797,6 +1799,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
}

Expand Down Expand Up @@ -2746,37 +2745,29 @@ index da7489986848316fed029b71d1bc4e1248c9c9a8..661acdf4b1f33d150b0caf179e925d31
return new BlockPos(i, l, j);
}
diff --git a/src/main/java/net/minecraft/world/level/biome/Biome.java b/src/main/java/net/minecraft/world/level/biome/Biome.java
index b865115dc5a8c000521abf668251ab1bd8104505..57f3193ff761cbe45846a02a15d8da9c9e2e87ee 100644
index b865115dc5a8c000521abf668251ab1bd8104505..42af3888a155f114901a90d4028bafed5789f58f 100644
--- a/src/main/java/net/minecraft/world/level/biome/Biome.java
+++ b/src/main/java/net/minecraft/world/level/biome/Biome.java
@@ -63,14 +63,19 @@ public final class Biome {
@@ -63,13 +63,18 @@ public final class Biome {
private final BiomeGenerationSettings generationSettings;
private final MobSpawnSettings mobSettings;
private final BiomeSpecialEffects specialEffects;
- private final ThreadLocal<Long2FloatLinkedOpenHashMap> temperatureCache = ThreadLocal.withInitial(() -> Util.make(() -> {
- Long2FloatLinkedOpenHashMap long2FloatLinkedOpenHashMap = new Long2FloatLinkedOpenHashMap(1024, 0.25F) {
- protected void rehash(int i) {
- }
- };
- long2FloatLinkedOpenHashMap.defaultReturnValue(Float.NaN);
- return long2FloatLinkedOpenHashMap;
- }));
+ // Pufferfish start - use our cache
+ private final ThreadLocal<gg.airplane.structs.Long2FloatAgingCache> temperatureCache = ThreadLocal.withInitial(() -> Util.make(() -> {
+ /*
+ Long2FloatLinkedOpenHashMap long2FloatLinkedOpenHashMap = new Long2FloatLinkedOpenHashMap(1024, 0.25F) {
+ protected void rehash(int i) {
+ }
+ };
+ long2FloatLinkedOpenHashMap.defaultReturnValue(Float.NaN);
+ return long2FloatLinkedOpenHashMap;
+ */
+ return new gg.airplane.structs.Long2FloatAgingCache(TEMPERATURE_CACHE_SIZE);
+ // Pufferfish end
+ }));
+ /*
Long2FloatLinkedOpenHashMap long2FloatLinkedOpenHashMap = new Long2FloatLinkedOpenHashMap(1024, 0.25F) {
protected void rehash(int i) {
}
};
long2FloatLinkedOpenHashMap.defaultReturnValue(Float.NaN);
return long2FloatLinkedOpenHashMap;
+ */
+ return new gg.airplane.structs.Long2FloatAgingCache(TEMPERATURE_CACHE_SIZE);
+ // Pufferfish end
}));

Biome(Biome.ClimateSettings weather, BiomeSpecialEffects effects, BiomeGenerationSettings generationSettings, MobSpawnSettings spawnSettings) {
this.climateSettings = weather;
@@ -112,17 +117,15 @@ public final class Biome {
@Deprecated
public float getTemperature(BlockPos blockPos) {
Expand Down Expand Up @@ -3180,7 +3171,7 @@ index 37a0002bbe6539648db5219bb373e0404ae48dc0..ca0571d232e102c4b177a1ea44b96f5f
}

diff --git a/src/main/java/net/minecraft/world/phys/shapes/EntityCollisionContext.java b/src/main/java/net/minecraft/world/phys/shapes/EntityCollisionContext.java
index 1132658b063c6cd3feb1783ab4d5f5141ab75140..a971c3b079e76a16b0de24a827f71cde7944b7e1 100644
index 1132658b063c6cd3feb1783ab4d5f5141ab75140..284c76ddb9724b44bb2e93f590685c728e843e6d 100644
--- a/src/main/java/net/minecraft/world/phys/shapes/EntityCollisionContext.java
+++ b/src/main/java/net/minecraft/world/phys/shapes/EntityCollisionContext.java
@@ -17,50 +17,69 @@ public class EntityCollisionContext implements CollisionContext {
Expand Down Expand Up @@ -3224,13 +3215,13 @@ index 1132658b063c6cd3feb1783ab4d5f5141ab75140..a971c3b079e76a16b0de24a827f71cde
- entity
- );
+ // Pufferfish start - remove this
+ /*this(
+ entity.isDescending(),
+ entity.getY(),
+ entity instanceof LivingEntity ? ((LivingEntity)entity).getMainHandItem() : ItemStack.EMPTY,
+ entity instanceof LivingEntity ? ((LivingEntity)entity)::canStandOnFluid : fluidState -> false,
+ entity
+ );*/
+ // this(
+ // entity.isDescending(),
+ // entity.getY(),
+ // entity instanceof LivingEntity ? ((LivingEntity)entity).getMainHandItem() : ItemStack.EMPTY,
+ // entity instanceof LivingEntity ? ((LivingEntity)entity)::canStandOnFluid : fluidState -> false,
+ // entity
+ // );
+ // Pufferfish end
+ this.entity = entity;
}
Expand Down Expand Up @@ -3268,7 +3259,7 @@ index 1132658b063c6cd3feb1783ab4d5f5141ab75140..a971c3b079e76a16b0de24a827f71cde
@Override
public boolean isAbove(VoxelShape shape, BlockPos pos, boolean defaultValue) {
- return this.entityBottom > pos.getY() + shape.max(Direction.Axis.Y) - 1.0E-5F;
+ return (this.entity == null ? -Double.MAX_VALUE : entity.getY()) > pos.getY() + shape.max(Direction.Axis.Y) - 1.0E-5F; // Pufferfish
+ return (this.entity == null ? -Double.MAX_VALUE : entity.getY()) > (double)pos.getY() + shape.max(Direction.Axis.Y) - 1.0E-5F; // Pufferfish
}

@Nullable
Expand Down
23 changes: 8 additions & 15 deletions patches/server/0003-Fix-pufferfish-issues.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] Fix pufferfish issues


diff --git a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java
index f6a3364175476c57a7763a087ff55e1689474800..8b8fe02b9db5192a3adb8d4a3bb3c2105f90544d 100644
index 6464682e2f93659e73aca491031c8051ab000033..5a73aa17a963ae2d57e9bd5b5e3e5b0030d06216 100644
--- a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java
+++ b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java
@@ -86,7 +86,7 @@ public class PufferfishConfig {
Expand Down Expand Up @@ -45,18 +45,9 @@ index f6a3364175476c57a7763a087ff55e1689474800..8b8fe02b9db5192a3adb8d4a3bb3c210
"This can improve performance by a few percent, but has minor gameplay implications.");
}
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 4bd83e1605fb6540be1847dc3691e74b95f260ad..7f5749c15f017624af11b81b497efd229b81efd9 100644
index fbffe3dab1b7812b50df5d6bddf4fbdb2e583339..881ba370b098a4a202fbfb9c5c3d9304719d155e 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -924,7 +924,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
final String msg = String.format("Entity threw exception at %s:%s,%s,%s", entity.level().getWorld().getName(), entity.getX(), entity.getY(), entity.getZ());
MinecraftServer.LOGGER.error(msg, throwable);
getCraftServer().getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerInternalException(msg, throwable)));
- entity.discard();
+ entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD); // Purpur
// Paper end
}
// Pufferfish end
@@ -992,7 +992,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
}
// Paper start - optimise random block ticking
Expand All @@ -67,7 +58,7 @@ index 4bd83e1605fb6540be1847dc3691e74b95f260ad..7f5749c15f017624af11b81b497efd22

private int currentIceAndSnowTick = 0; protected void resetIceAndSnowTick() { this.currentIceAndSnowTick = this.randomTickRandom.nextInt(16); } // Pufferfish
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 5298be16774b23b71d2de3b8697a758c73255912..f664ab1748aab367ae0c468cfd54dad3ade42ec3 100644
index 1aa45e64e49ea011c2ba5e943b4e72c4f3a47176..6f7b34357788faecf8368cc9a27d26585935f789 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -825,7 +825,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
Expand All @@ -93,14 +84,16 @@ index 837f68825f601971f374be47952b23108bf66ba6..2a8a8030feefae84e394460612405887
return;
}
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 15186884c67f8b75a6b40e244c8b18797f098fd1..d70b6dd93702fcd5590b19eceba0281ce39e9de4 100644
index a82de7111915b19cdc3f065910465a5e7e843aff..fc32b6342b7553265f2a012f91f4dd9c0386f8f2 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -216,7 +216,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -215,8 +215,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
// Paper end

public abstract ResourceKey<LevelStem> getTypeKey();

-
- protected final io.papermc.paper.util.math.ThreadUnsafeRandom randomTickRandom = new io.papermc.paper.util.math.ThreadUnsafeRandom(java.util.concurrent.ThreadLocalRandom.current().nextLong()); public net.minecraft.util.RandomSource getThreadUnsafeRandom() { return this.randomTickRandom; } // Pufferfish - move thread unsafe random initialization // Pufferfish - getter
+
+ //protected final io.papermc.paper.util.math.ThreadUnsafeRandom randomTickRandom = new io.papermc.paper.util.math.ThreadUnsafeRandom(java.util.concurrent.ThreadLocalRandom.current().nextLong()); public net.minecraft.util.RandomSource getThreadUnsafeRandom() { return this.randomTickRandom; } // Pufferfish - move thread unsafe random initialization // Pufferfish - getter // Purpur - dont break ABI

protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, RegistryAccess iregistrycustom, Holder<DimensionType> holder, Supplier<ProfilerFiller> supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function<org.spigotmc.SpigotWorldConfig, io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - create paper world config; Async-Anti-Xray: Pass executor
Expand Down
Loading

0 comments on commit f2a5ca8

Please sign in to comment.