2020-09-02 21:06:17 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Ivan Pekov <ivan@mrivanplays.com>
|
|
|
|
Date: Tue, 1 Sep 2020 19:11:50 +0300
|
|
|
|
Subject: [PATCH] Nuke streams off BlockPosition
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockBase.java b/src/main/java/net/minecraft/server/BlockBase.java
|
2020-09-11 08:03:00 +02:00
|
|
|
index c1f992b2ebac9819085bec74bc40ca3b5384c741..462d3431367f97f9d8506fd1a1adf8dc418b4414 100644
|
2020-09-02 21:06:17 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/BlockBase.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockBase.java
|
|
|
|
@@ -637,6 +637,7 @@ public abstract class BlockBase {
|
|
|
|
return this.getBlock().getInventory(this.p(), world, blockposition);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ public final boolean hasTag(Tag<Block> tag) { return a(tag); } // Yatopia - OBFHELPER
|
|
|
|
public boolean a(Tag<Block> tag) {
|
|
|
|
return this.getBlock().a(tag);
|
|
|
|
}
|
|
|
|
@@ -645,6 +646,7 @@ public abstract class BlockBase {
|
|
|
|
return this.getBlock().a(tag) && predicate.test(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ public final boolean isBlock(Block block) { return a(block); } // Yatopia - OBFHELPER
|
|
|
|
public boolean a(Block block) {
|
|
|
|
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 e6b5a21c523c598f53207d024322301fbae74825..5e0aa6e35b1d4e23fdf42add15420665045ef3ff 100644
|
|
|
|
--- a/src/main/java/net/minecraft/server/BlockPosition.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockPosition.java
|
|
|
|
@@ -318,9 +318,29 @@ public class BlockPosition extends BaseBlockPosition {
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Optional<BlockPosition> a(BlockPosition blockposition, int i, int j, Predicate<BlockPosition> predicate) {
|
|
|
|
- return b(blockposition, i, j, i).filter(predicate).findFirst();
|
|
|
|
+ // Yatopia start - replace
|
|
|
|
+ BlockPosition best = null;
|
|
|
|
+ for (BlockPosition pos : bList(blockposition, i, j, i)) {
|
|
|
|
+ if (predicate.test(pos)) {
|
|
|
|
+ best = pos;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return Optional.ofNullable(best);
|
|
|
|
+ //return b(blockposition, i, j, i).filter(predicate).findFirst();
|
|
|
|
+ // Yatopia end
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Yatopia start
|
|
|
|
+ public static java.util.List<BlockPosition> bList(BlockPosition pos, int i, int j, int k) {
|
|
|
|
+ java.util.List<BlockPosition> ret = new java.util.ArrayList<>();
|
|
|
|
+ Iterable<BlockPosition> iterable = a(pos, i, j, k);
|
|
|
|
+ net.yatopia.server.HoldingConsumer<BlockPosition> consumer = new net.yatopia.server.HoldingConsumer<>();
|
|
|
|
+ java.util.Spliterator<BlockPosition> spliterator = iterable.spliterator();
|
|
|
|
+ while (spliterator.tryAdvance(consumer)) ret.add(consumer.getValue());
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+ // Yatopia end
|
|
|
|
public static Stream<BlockPosition> b(BlockPosition blockposition, int i, int j, int k) {
|
|
|
|
return StreamSupport.stream(a(blockposition, i, j, k).spliterator(), false);
|
|
|
|
}
|
|
|
|
@@ -329,6 +349,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<BlockPosition> bList(BlockPosition pos, BlockPosition pos1) {
|
|
|
|
+ java.util.List<BlockPosition> ret = new java.util.ArrayList<>();
|
|
|
|
+ Iterable<BlockPosition> iterable = a(pos, pos1);
|
|
|
|
+ net.yatopia.server.HoldingConsumer<BlockPosition> consumer = new net.yatopia.server.HoldingConsumer<>();
|
|
|
|
+ java.util.Spliterator<BlockPosition> spliterator = iterable.spliterator();
|
|
|
|
+ while (spliterator.tryAdvance(consumer)) ret.add(consumer.getValue());
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+ // Yatopia end
|
|
|
|
public static Stream<BlockPosition> b(BlockPosition blockposition, BlockPosition blockposition1) {
|
|
|
|
return StreamSupport.stream(a(blockposition, blockposition1).spliterator(), false);
|
|
|
|
}
|
|
|
|
@@ -337,6 +367,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<BlockPosition> 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<BlockPosition> 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
|
2020-09-13 09:00:43 +02:00
|
|
|
index 388be69fb55c6b1cfd5ccc7635b54aa648728768..71210cfb2079e92392323e9df945975fed0ac9d4 100644
|
2020-09-02 21:06:17 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
2020-09-13 09:00:43 +02:00
|
|
|
@@ -800,11 +800,25 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
2020-09-02 21:06:17 +02:00
|
|
|
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
|
2020-09-15 16:42:53 +02:00
|
|
|
index 24842902383820f3ec8dcd2ee57b3d4f2d2e952f..2481bfac2cc1224c32ca96519ceb38f0ea0f1b4a 100644
|
2020-09-02 21:06:17 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityFishingHook.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityFishingHook.java
|
2020-09-15 16:42:53 +02:00
|
|
|
@@ -377,9 +377,23 @@ public class EntityFishingHook extends IProjectile {
|
2020-09-02 21:06:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private EntityFishingHook.WaterPosition a(BlockPosition blockposition, BlockPosition blockposition1) {
|
|
|
|
- return (EntityFishingHook.WaterPosition) BlockPosition.b(blockposition, blockposition1).map(this::c).reduce((entityfishinghook_waterposition, entityfishinghook_waterposition1) -> {
|
2020-09-15 16:42:53 +02:00
|
|
|
- return entityfishinghook_waterposition == entityfishinghook_waterposition1 ? entityfishinghook_waterposition : EntityFishingHook.WaterPosition.INVALID;
|
2020-09-02 21:06:17 +02:00
|
|
|
- }).orElse(EntityFishingHook.WaterPosition.INVALID);
|
2020-09-15 16:42:53 +02:00
|
|
|
+ // Yatopia start - replace stream
|
2020-09-02 21:06:17 +02:00
|
|
|
+ boolean foundAny = false;
|
|
|
|
+ EntityFishingHook.WaterPosition result = null;
|
|
|
|
+ for (BlockPosition pos : BlockPosition.bList(blockposition, blockposition1)) {
|
|
|
|
+ EntityFishingHook.WaterPosition waterPos = this.c(pos);
|
2020-09-15 16:42:53 +02:00
|
|
|
+ if (waterPos != WaterPosition.INVALID) {
|
|
|
|
+ if (!foundAny) {
|
|
|
|
+ foundAny = true;
|
|
|
|
+ result = waterPos;
|
|
|
|
+ } else {
|
|
|
|
+ result = result == waterPos ? waterPos : WaterPosition.INVALID;
|
|
|
|
+ }
|
2020-09-02 21:06:17 +02:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ 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..cd4d53719cc179abb302a3bdd6ceae03fb62acc7 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<IBlockData> aList(AxisAlignedBB box) {
|
|
|
|
+ java.util.List<BlockPosition> posList = BlockPosition.aList(box);
|
|
|
|
+ if (posList.isEmpty()) return java.util.Collections.emptyList();
|
|
|
|
+ java.util.List<IBlockData> ret = new java.util.ArrayList<>();
|
|
|
|
+ for (BlockPosition pos : posList) ret.add(getType(pos));
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+ // Yatopia end
|
|
|
|
default Stream<IBlockData> 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<IBlockData> 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<IBlockData> c(AxisAlignedBB axisalignedbb) {
|
|
|
|
int i = MathHelper.floor(axisalignedbb.minX);
|
|
|
|
int j = MathHelper.floor(axisalignedbb.maxX);
|