diff --git a/patches/server/0040-Nuke-streams-off-BlockPosition.patch b/patches/server/0040-Nuke-streams-off-BlockPosition.patch index caeec73d..4a68b8ed 100644 --- a/patches/server/0040-Nuke-streams-off-BlockPosition.patch +++ b/patches/server/0040-Nuke-streams-off-BlockPosition.patch @@ -25,158 +25,23 @@ index c1f992b2ebac9819085bec74bc40ca3b5384c741..462d3431367f97f9d8506fd1a1adf8dc return this.getBlock().a(block); } diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java -index dbe6f7d555e8c851faba5cafee8831c516256c09..6374f013137fe2b244c68706f58e23ffeb2ea18b 100644 +index dbe6f7d555e8c851faba5cafee8831c516256c09..3bd6d37a93b741043851c6a24ffe61f517774546 100644 --- a/src/main/java/net/minecraft/server/BlockPosition.java +++ b/src/main/java/net/minecraft/server/BlockPosition.java -@@ -318,7 +318,17 @@ public class BlockPosition extends BaseBlockPosition { +@@ -318,7 +318,15 @@ public class BlockPosition extends BaseBlockPosition { } public static Optional a(BlockPosition blockposition, int i, int j, Predicate predicate) { - return b(blockposition, i, j, i).filter(predicate).findFirst(); -+ // Yatopia start - replace -+ BlockPosition best = null; ++ // Yatopia start - avoid using stream ++ // return b(blockposition, i, j, i).filter(predicate).findFirst(); + for (BlockPosition pos : a(blockposition, i, j, i)) { + if (predicate.test(pos)) { -+ best = pos; -+ break; ++ return Optional.of(pos); + } + } -+ return Optional.ofNullable(best); -+ //return b(blockposition, i, j, i).filter(predicate).findFirst(); ++ return Optional.empty(); + // Yatopia end } public static Stream b(BlockPosition blockposition, int i, int j, int k) { -@@ -329,6 +339,16 @@ public class BlockPosition extends BaseBlockPosition { - return b(Math.min(blockposition.getX(), blockposition1.getX()), Math.min(blockposition.getY(), blockposition1.getY()), Math.min(blockposition.getZ(), blockposition1.getZ()), Math.max(blockposition.getX(), blockposition1.getX()), Math.max(blockposition.getY(), blockposition1.getY()), Math.max(blockposition.getZ(), blockposition1.getZ())); - } - -+ // Yatopia start -+ public static java.util.List bList(BlockPosition pos, BlockPosition pos1) { -+ java.util.List ret = new net.yatopia.server.list.GlueList<>(); -+ Iterable iterable = a(pos, pos1); -+ net.yatopia.server.HoldingConsumer consumer = new net.yatopia.server.HoldingConsumer<>(); -+ java.util.Spliterator spliterator = iterable.spliterator(); -+ while (spliterator.tryAdvance(consumer)) ret.add(consumer.getValue()); -+ return ret; -+ } -+ // Yatopia end - public static Stream b(BlockPosition blockposition, BlockPosition blockposition1) { - return StreamSupport.stream(a(blockposition, blockposition1).spliterator(), false); - } -@@ -337,6 +357,11 @@ public class BlockPosition extends BaseBlockPosition { - return a(Math.min(structureboundingbox.a, structureboundingbox.d), Math.min(structureboundingbox.b, structureboundingbox.e), Math.min(structureboundingbox.c, structureboundingbox.f), Math.max(structureboundingbox.a, structureboundingbox.d), Math.max(structureboundingbox.b, structureboundingbox.e), Math.max(structureboundingbox.c, structureboundingbox.f)); - } - -+ // Yatopia start -+ public static java.util.List aList(AxisAlignedBB box) { -+ return getPositions(MathHelper.floor(box.minX), MathHelper.floor(box.minY), MathHelper.floor(box.minZ), MathHelper.floor(box.maxX), MathHelper.floor(box.maxY), MathHelper.floor(box.maxZ)); -+ } -+ // Yatopia end - public static Stream a(AxisAlignedBB axisalignedbb) { - return a(MathHelper.floor(axisalignedbb.minX), MathHelper.floor(axisalignedbb.minY), MathHelper.floor(axisalignedbb.minZ), MathHelper.floor(axisalignedbb.maxX), MathHelper.floor(axisalignedbb.maxY), MathHelper.floor(axisalignedbb.maxZ)); - } -diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index a86f958ad01b5b935413b093540f8d3a2f4fb41a..9f31737afb36e5d7fb50f1d9196f8e6f04b71fa6 100644 ---- a/src/main/java/net/minecraft/server/Entity.java -+++ b/src/main/java/net/minecraft/server/Entity.java -@@ -802,11 +802,25 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke - float f2 = this.getBlockSpeedFactor(); - - this.setMot(this.getMot().d((double) f2, 1.0D, (double) f2)); -+ // Yatopia start - replace -+ /* - if (this.world.c(this.getBoundingBox().shrink(0.001D)).noneMatch((iblockdata1) -> { - return iblockdata1.a((Tag) TagsBlock.FIRE) || iblockdata1.a(Blocks.LAVA); - }) && this.fireTicks <= 0) { - this.setFireTicks(-this.getMaxFireTicks()); - } -+ */ -+ boolean noneMatch = true; -+ for (IBlockData iblockdata1 : world.cList(getBoundingBox().shrink(0.001D))) { -+ if (iblockdata1.hasTag(TagsBlock.FIRE) || iblockdata1.isBlock(Blocks.LAVA)) { -+ noneMatch = false; -+ break; -+ } -+ } -+ if (noneMatch && this.fireTicks <= 0) { -+ this.setFireTicks(-this.getMaxFireTicks()); -+ } -+ // Yatopia end - - if (this.aF() && this.isBurning()) { - this.playSound(SoundEffects.ENTITY_GENERIC_EXTINGUISH_FIRE, 0.7F, 1.6F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); -diff --git a/src/main/java/net/minecraft/server/EntityFishingHook.java b/src/main/java/net/minecraft/server/EntityFishingHook.java -index 24842902383820f3ec8dcd2ee57b3d4f2d2e952f..2481bfac2cc1224c32ca96519ceb38f0ea0f1b4a 100644 ---- a/src/main/java/net/minecraft/server/EntityFishingHook.java -+++ b/src/main/java/net/minecraft/server/EntityFishingHook.java -@@ -377,9 +377,23 @@ public class EntityFishingHook extends IProjectile { - } - - private EntityFishingHook.WaterPosition a(BlockPosition blockposition, BlockPosition blockposition1) { -- return (EntityFishingHook.WaterPosition) BlockPosition.b(blockposition, blockposition1).map(this::c).reduce((entityfishinghook_waterposition, entityfishinghook_waterposition1) -> { -- return entityfishinghook_waterposition == entityfishinghook_waterposition1 ? entityfishinghook_waterposition : EntityFishingHook.WaterPosition.INVALID; -- }).orElse(EntityFishingHook.WaterPosition.INVALID); -+ // Yatopia start - replace stream -+ boolean foundAny = false; -+ EntityFishingHook.WaterPosition result = null; -+ for (BlockPosition pos : BlockPosition.bList(blockposition, blockposition1)) { -+ EntityFishingHook.WaterPosition waterPos = this.c(pos); -+ if (waterPos != WaterPosition.INVALID) { -+ if (!foundAny) { -+ foundAny = true; -+ result = waterPos; -+ } else { -+ result = result == waterPos ? waterPos : WaterPosition.INVALID; -+ } -+ } -+ } -+ if (!foundAny || result == null) result = EntityFishingHook.WaterPosition.INVALID; -+ return result; -+ // Yatopia end - } - - private EntityFishingHook.WaterPosition c(BlockPosition blockposition) { -diff --git a/src/main/java/net/minecraft/server/IBlockAccess.java b/src/main/java/net/minecraft/server/IBlockAccess.java -index b90c9990668f7956e8ef67413bcfc5d7d9616db1..3c6997ef5992c4cec48e57720b34ea6ce678476b 100644 ---- a/src/main/java/net/minecraft/server/IBlockAccess.java -+++ b/src/main/java/net/minecraft/server/IBlockAccess.java -@@ -40,6 +40,15 @@ public interface IBlockAccess { - return 256; - } - -+ // Yatopia start -+ default java.util.List aList(AxisAlignedBB box) { -+ java.util.List posList = BlockPosition.aList(box); -+ if (posList.isEmpty()) return java.util.Collections.emptyList(); -+ java.util.List ret = new net.yatopia.server.list.GlueList<>(); -+ for (BlockPosition pos : posList) ret.add(getType(pos)); -+ return ret; -+ } -+ // Yatopia end - default Stream a(AxisAlignedBB axisalignedbb) { - return BlockPosition.a(axisalignedbb).map(this::getType); - } -diff --git a/src/main/java/net/minecraft/server/IWorldReader.java b/src/main/java/net/minecraft/server/IWorldReader.java -index eb7282c33dd4f0bb26b9ccafc42bd92e6fdb997e..404b90d6de6ade3f442476d051c9947753e2b6f7 100644 ---- a/src/main/java/net/minecraft/server/IWorldReader.java -+++ b/src/main/java/net/minecraft/server/IWorldReader.java -@@ -22,6 +22,18 @@ public interface IWorldReader extends IBlockLightAccess, ICollisionAccess, Biome - return this.d().a(blockposition); - } - -+ // Yatopia start -+ default java.util.List cList(AxisAlignedBB box) { -+ int i = MathHelper.floor(box.minX); -+ int j = MathHelper.floor(box.maxX); -+ int k = MathHelper.floor(box.minY); -+ int l = MathHelper.floor(box.maxY); -+ int i1 = MathHelper.floor(box.minZ); -+ int j1 = MathHelper.floor(box.maxZ); -+ -+ return isAreaLoaded(i, k, i1, j, l, j1) ? aList(box) : java.util.Collections.emptyList(); -+ } -+ // Yatopia end - default Stream c(AxisAlignedBB axisalignedbb) { - int i = MathHelper.floor(axisalignedbb.minX); - int j = MathHelper.floor(axisalignedbb.maxX); diff --git a/patches/server/0059-Use-faster-block-collision-check-for-entity-suffocat.patch b/patches/server/0059-Use-faster-block-collision-check-for-entity-suffocat.patch index dbe85382..8cc9784a 100644 --- a/patches/server/0059-Use-faster-block-collision-check-for-entity-suffocat.patch +++ b/patches/server/0059-Use-faster-block-collision-check-for-entity-suffocat.patch @@ -52,10 +52,10 @@ index 7ed343cfb3130446c85dab2ca04d60f91e2c94fb..194d2f177b05c594c7a27b6191860a3f if (collisionShape != VoxelShapes.empty()) { diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 9f31737afb36e5d7fb50f1d9196f8e6f04b71fa6..dbc0399d4b9be8e3ff3750d2672275070104ce95 100644 +index a86f958ad01b5b935413b093540f8d3a2f4fb41a..9f953cc49d3bd770cb460f5fe6466a4c61ea4186 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java -@@ -2170,9 +2170,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke +@@ -2156,9 +2156,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke float f1 = this.size.width * 0.8F; AxisAlignedBB axisalignedbb = AxisAlignedBB.g((double) f1, 0.10000000149011612D, (double) f1).d(this.locX(), this.getHeadY(), this.locZ());