Updated upstream and sidestream (Tuinity/Purpur)

Closes #289
Also dropped some patches which are useless.

Changes in Purpur: Paper upstream updates
Changes in Tuinity: Paper updated
This commit is contained in:
Ivan Pekov 2020-11-20 09:14:39 +02:00
parent 74bcf06dd5
commit 37e61be6c2
No known key found for this signature in database
GPG Key ID: BC975C392D9CA3A3
65 changed files with 106 additions and 1709 deletions

View File

@ -56,7 +56,6 @@ This is an overview over all patches that are currently used.
| server | Dont send useless entity packets | William Blake Galbreath | |
| server | Ensure pools create daemon threads | Ivan Pekov | |
| server | Entity lifespan | William Blake Galbreath | |
| server | Fix "Unable to save chunk" error | Ivan Pekov | |
| server | Fix 'outdated server' showing in ping before server fully | William Blake Galbreath | |
| server | Fix Bukkit.createInventory() with type LECTERN | willies952002 | |
| server | Fix IndexOutOfBoundsException when sending too many changes | Ivan Pekov | |
@ -77,7 +76,6 @@ This is an overview over all patches that are currently used.
| server | Lagging threshold | William Blake Galbreath | |
| server | MC-168772 Fix - Add turtle egg block options | William Blake Galbreath | |
| server | MC-4 Fix - Item position desync | William Blake Galbreath | |
| server | Make sure the block is cauldron before proceeding | Ivan Pekov | |
| api | Modify POM | YatopiaMC | |
| server | Modify POM | YatopiaMC | |
| server | Modify default configs | tr7zw | |
@ -121,7 +119,6 @@ This is an overview over all patches that are currently used.
| server | Use Glue List as delegate for NonNullList | Mykyta Komarn | |
| server | Use Glue List in WeightedList | Ivan Pekov | |
| server | Use GlueList for some list initialisations in packets | Ivan Pekov | |
| server | Use faster block collision check for entity suffocation check | Mykyta Komarn | |
| server | Use offline uuids if we need to | Ivan Pekov | |
| server | Utilities | YatopiaMC | Mykyta Komarnytskyy, Ivan Pekov |
| api | Yatopia API Bundle | YatopiaMC | |
@ -130,16 +127,12 @@ This is an overview over all patches that are currently used.
| server | dont load chunks for physics | Aikar | |
| server | lithium MixinBiome | JellySquid | |
| server | lithium MixinBox | JellySquid | |
| server | lithium MixinChunkSection | JellySquid | |
| server | lithium MixinDirection | JellySquid | |
| server | lithium MixinGoalSelector | JellySquid | |
| server | lithium MixinLandPathNodeMaker | JellySquid | |
| server | lithium NoiseChunkGeneratorMixin | JellySquid | |
| server | lithium PerlinNoiseSamplerMixin | JellySquid | Bud Gidiere |
| server | lithium VoronoiBiomeAccessTypeMixin | JellySquid | |
| server | lithium VoxelShapesMixin | JellySquid | Ivan Pekov |
| server | lithium collision optimizations | JellySquid | Ivan Pekov |
| server | lithium enum_values | JellySquid | |
| server | lithium reduce allocations | JellySquid | Mykyta Komarnytskyy |
| server | lithium-MixinChunkGeneratorAbstract | JellySquid | tr7zw |
| server | lithium-MixinDataWatcher | JellySquid | tr7zw |

2
Purpur

@ -1 +1 @@
Subproject commit 56569681b43e3fec3426cca43271b04eaf93f100
Subproject commit b8fb7ff5b5de02aa0c46d76d65f6f481f2fd6929

@ -1 +1 @@
Subproject commit 47a29f8434891ecac58dced9716aa8ba11dadbc4
Subproject commit ecc046e8a9b6d606b1359fe714ebec7bde3e6f75

View File

@ -1044,6 +1044,19 @@ index f5c0ccfcbfeda191e3a077bb4313a8c8b8b4178d..00000000000000000000000000000000
- // CraftBukkit start - PlayerTeleportEvent
- PlayerTeleportEvent tpEvent = new PlayerTeleportEvent(this.getBukkitEntity(), enter, exit, cause);
- Bukkit.getServer().getPluginManager().callEvent(tpEvent);
diff --git a/src/main/java/net/minecraft/server/EntitySlice.java b/src/main/java/net/minecraft/server/EntitySlice.java
index 1250c3cbe915815939627701c153ba6254fc05f0..ac7b5bc179a3e174ae09b3444b3ba89b5627a174 100644
--- a/src/main/java/net/minecraft/server/EntitySlice.java
+++ b/src/main/java/net/minecraft/server/EntitySlice.java
@@ -65,7 +65,7 @@ public class EntitySlice<T> extends AbstractCollection<T> {
if (!this.b.isAssignableFrom(oclass)) {
throw new IllegalArgumentException("Don't know how to search for " + oclass);
} else {
- List<T> list = (List) this.a.computeIfAbsent(oclass, (oclass1) -> {
+ List<S> list = (List<S>) this.a.computeIfAbsent(oclass, (oclass1) -> { // Yatopia - decompile fix - why is this still being here?
Stream stream = this.c.stream();
oclass1.getClass();
diff --git a/src/main/java/net/minecraft/server/EntityVillager.java b/src/main/java/net/minecraft/server/EntityVillager.java
index a02f54ab3ac721a5697f8efea474d2999a0fd7bd..9dc054e2e189f8c65a9d12f70e180e7ded79a997 100644
--- a/src/main/java/net/minecraft/server/EntityVillager.java
@ -1244,7 +1257,7 @@ index dd52a8fe4fd46e57a5d1af49ba1965a483cf4fcc..00000000000000000000000000000000
- IChunkAccess ichunkaccess = iworldreader.getChunkAt(chunkcoordintpair.x, chunkcoordintpair.z, ChunkStatus.STRUCTURE_STARTS, !(iworldreader instanceof World) || !((World) iworldreader).origamiConfig.onlyFindGeneratedFeatures);
- if (ichunkaccess == null) {
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index bb7ae7deb67172776e702b80c5f66b526a36a8e6..9626f736353249ceb219ee565efc022fd2a32a93 100644
index cf43f47c27992b119e07d38a7a79ecc183e12844..50eedfe5a0fe897f1e3b748bcae5c1d0c53b1467 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -96,6 +96,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
@ -1256,7 +1269,7 @@ index bb7ae7deb67172776e702b80c5f66b526a36a8e6..9626f736353249ceb219ee565efc022f
public final co.aikar.timings.WorldTimingsHandler timings; // Paper
public static BlockPosition lastPhysicsProblem; // Spigot
@@ -157,6 +158,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
this.paperConfig = new com.destroystokyo.paper.PaperWorldConfig((((WorldDataServer)worlddatamutable).getName()), this.spigotConfig); // Paper
this.paperConfig = new com.destroystokyo.paper.PaperWorldConfig(((WorldDataServer) worlddatamutable).getName(), this.spigotConfig); // Paper
this.tuinityConfig = new com.tuinity.tuinity.config.TuinityConfig.WorldConfig(((WorldDataServer)worlddatamutable).getName()); // Tuinity - Server Config
this.purpurConfig = new net.pl3x.purpur.PurpurWorldConfig((((WorldDataServer)worlddatamutable).getName())); // Purpur
+ this.origamiConfig = new de.minebench.origami.OrigamiConfig.WorldConfig(((WorldDataServer)worlddatamutable).getName()); // Origami

View File

@ -18,7 +18,7 @@ index 6ab0a51b421dc696aec292f2db955311c9cc31e3..82591dcebdbf34649728b60b22d8f78a
TimingsManager.privacy = getBoolean("timings.server-name-privacy", false);
TimingsManager.hiddenConfigs = getList("timings.hidden-config-entries", Lists.newArrayList("database", "settings.bungeecord-addresses"));
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index ff0e4447b6574e91bf8815de4e04ce881ed7026d..590fd78ec0751a561305a4ad2190b343fe6d5280 100644
index 80b0c08cef9a5326492b1faec020929fca59ff77..f0354d591f8efe10c5fc8cb91345f6d467902cf6 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -598,7 +598,7 @@ public class PaperWorldConfig {

View File

@ -1,92 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: JellySquid <jellysquid+atwork@protonmail.com>
Date: Mon, 11 May 2020 22:56:27 +0200
Subject: [PATCH] lithium MixinLandPathNodeMaker
Original code by JellySquid, licensed under GNU Lesser General Public License v3.0
you can find the original code on https://github.com/jellysquid3/lithium-fabric/tree/1.16.x/fabric (Yarn mappings)
diff --git a/src/main/java/net/minecraft/server/PathfinderNormal.java b/src/main/java/net/minecraft/server/PathfinderNormal.java
index 33804e68931e8b4145b896eedeab79bde78779f2..5954fa5e2b1d4f18df13f6de738d4f3662d7f028 100644
--- a/src/main/java/net/minecraft/server/PathfinderNormal.java
+++ b/src/main/java/net/minecraft/server/PathfinderNormal.java
@@ -7,9 +7,15 @@ import it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap;
import java.util.EnumSet;
import java.util.Iterator;
import javax.annotation.Nullable;
+import it.unimi.dsi.fastutil.objects.Reference2ReferenceMap; // Yatopia
+import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap; // Yatopia
public class PathfinderNormal extends PathfinderAbstract {
+ // Yatopia start - this is not thread safe!
+ private static final Reference2ReferenceMap<IBlockData, PathType> commonTypes = new Reference2ReferenceOpenHashMap<>();
+ // Yatopia end
+
protected float j;
private final Long2ObjectMap<PathType> k = new Long2ObjectOpenHashMap();
private final Object2BooleanMap<AxisAlignedBB> l = new Object2BooleanOpenHashMap();
@@ -518,8 +524,22 @@ public class PathfinderNormal extends PathfinderAbstract {
}
protected static PathType getStaticTypeSlow(IBlockAccess iblockaccess, BlockPosition blockposition, IBlockData iblockdata) {
// Tuinity end - reduce pathfinder branches
- Block block = iblockdata.getBlock();
- Material material = iblockdata.getMaterial();
+ // Yatopia start - replaced logic
+ //Block block = iblockdata.getBlock();
+ //Material material = iblockdata.getMaterial();
+ if (iblockdata.isAir()) return PathType.OPEN;
+ PathType type = commonTypes.get(iblockdata);
+ if (type == null) {
+ commonTypes.put(iblockdata, type = getPathType(iblockdata));
+ }
+
+ if (type == PathType.OPEN) {
+ if (!iblockdata.a(iblockaccess, blockposition, PathMode.LAND)) {
+ return PathType.BLOCKED;
+ }
+ }
+
+ /*
if (iblockdata.isAir()) {
return PathType.OPEN;
@@ -540,7 +560,38 @@ public class PathfinderNormal extends PathfinderAbstract {
} else {
return PathType.TRAPDOOR;
}
+ */
+ return type;
+ // Yatopia end
+ }
+
+ // Yatopia start
+ private static PathType getPathType(IBlockData iblockdata) {
+ Block block = iblockdata.getBlock();
+ if (!block.a(TagsBlock.TRAPDOORS) && block != Blocks.LILY_PAD) {
+ if (block == Blocks.FIRE) {
+ return PathType.DAMAGE_FIRE;
+ } else if (block == Blocks.CACTUS) {
+ return PathType.DAMAGE_CACTUS;
+ } else if (iblockdata.a(Blocks.SWEET_BERRY_BUSH)) {
+ return PathType.DAMAGE_OTHER;
+ } else if (iblockdata.a(Blocks.HONEY_BLOCK)) {
+ return PathType.STICKY_HONEY;
+ } else if (iblockdata.a(Blocks.COCOA)) {
+ return PathType.COCOA;
+ } else {
+ Fluid fluid = iblockdata.getFluid(); // Tuinity - remove another get type call
+
+ if (fluid.a(TagsFluid.WATER)) return PathType.WATER;
+ if (fluid.a(TagsFluid.LAVA)) return PathType.LAVA;
+
+ return PathType.OPEN;
+ }
+ } else {
+ return PathType.TRAPDOOR;
+ }
}
+ // Yatopia end
private static boolean a(IBlockData iblockdata) {
return iblockdata.a((Tag) TagsBlock.FIRE) || iblockdata.a(Blocks.LAVA) || iblockdata.a(Blocks.MAGMA_BLOCK) || BlockCampfire.g(iblockdata);

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Optimize TileEntity load/unload
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 9626f736353249ceb219ee565efc022fd2a32a93..6422cd2a84203f893fe19e866c02207784b043c8 100644
index 50eedfe5a0fe897f1e3b748bcae5c1d0c53b1467..1742399920cf6420082760049d5b8f2835704273 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -42,9 +42,9 @@ public abstract class World implements GeneratorAccess, AutoCloseable {

View File

@ -1,189 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: JellySquid <jellysquid+atwork@protonmail.com>
Date: Tue, 4 Aug 2020 21:06:02 +0200
Subject: [PATCH] lithium-MixinChunkGeneratorAbstract
Original code by JellySquid, licensed under GNU Lesser General Public License v3.0
you can find the original code on https://github.com/jellysquid3/lithium-fabric/tree/1.16.x/fabric (Yarn mappings)
Co-authored-by: tr7zw <tr7zw@live.de>
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/world/noise/SimplexNoiseCache.java b/src/main/java/me/jellysquid/mods/lithium/common/world/noise/SimplexNoiseCache.java
new file mode 100644
index 0000000000000000000000000000000000000000..e6cd19e75a88f4dbf38d3cc63883068d95aa67d4
--- /dev/null
+++ b/src/main/java/me/jellysquid/mods/lithium/common/world/noise/SimplexNoiseCache.java
@@ -0,0 +1,135 @@
+package me.jellysquid.mods.lithium.common.world.noise;
+
+import it.unimi.dsi.fastutil.HashCommon;
+
+import net.minecraft.server.ChunkCoordIntPair;
+import net.minecraft.server.MathHelper;
+import net.minecraft.server.NoiseGenerator3Handler;
+
+import java.util.Arrays;
+
+/**
+ * A cache for the End's noise generator that caches computed values. Through the caching, we can eliminate a large
+ * amount of overhead in computing the noise values several hundred thousand times per chunk. This code uses the same
+ * array backed lossy cache as FastCachingLayerSampler.
+ */
+public class SimplexNoiseCache {
+ private static final int GRID_SIZE = 2;
+ private static final float MIN = -100.0F;
+ private static final float MAX = 80.0F;
+ private static final float ISLAND_RADIUS = 100.0F;
+ // The smallest encompassing power of two that can store all of the noise values in a chunk.
+ private static final int CACHE_SIZE = 8192;
+
+ private final int mask;
+ private final long[] keys;
+ private final float[] values;
+
+ private final NoiseGenerator3Handler sampler;
+
+ public SimplexNoiseCache(NoiseGenerator3Handler sampler) {
+ this.sampler = sampler;
+
+ this.mask = CACHE_SIZE - 1;
+
+ // Initialize default values
+ this.keys = new long[CACHE_SIZE];
+ Arrays.fill(this.keys, Long.MIN_VALUE);
+ this.values = new float[CACHE_SIZE];
+ }
+
+ /**
+ * Attempt to get the cached distance factor, saving computation time.
+ */
+ private float getDistanceFactor(int x, int z) {
+ // Hash key and get index
+ long key = ChunkCoordIntPair.pair(x, z);
+ int idx = (int) HashCommon.mix(key) & this.mask;
+
+ if (this.keys[idx] == key) {
+ // Cache hit, return cached value
+ return this.values[idx];
+ }
+
+ // Cache miss, compute and store value
+
+ // A marker for no value.
+ float value = -1.0F;
+
+ long lx = x;
+ long lz = z;
+ long distanceFromOriginSq = lx * lx + lz * lz;
+
+ // Ensure we are 64 grid cells away from the origin.
+ if (distanceFromOriginSq > 64 * 64) {
+ // Reduce the number of island-forming grid cells by sampling noise with a threshold
+ if (this.sampler.a(x, z) < -0.9) {
+ // Generate a pseudo-random value from 9 to 21
+ value = (Math.abs(x) * 3439.0F + Math.abs(z) * 147.0F) %13.0F + 9.0F;
+ }
+ }
+
+ // Store values in cache
+ this.keys[idx] = key;
+ this.values[idx] = value;
+
+ return value;
+ }
+
+ /**
+ * Mapped and cleaned up implementation of the End biome source's sampler. Tries to use cached values wherever
+ * possible.
+ */
+ public float getNoiseAt(int x, int z) {
+ // [VanillaCopy] TheEndBiomeSource#getNoiseAt
+
+ int gridX = x / GRID_SIZE;
+ int gridZ = z / GRID_SIZE;
+
+ // This is the "center point", offset to center around the current grid cell
+ int gridOriginX = x % GRID_SIZE;
+ int gridOriginZ = z % GRID_SIZE;
+
+ // Initialize density for the central island
+ float density = ISLAND_RADIUS - MathHelper.sqrt(x * x + z * z) * 8.0F;
+ if (density >= MAX) {
+ return MAX;
+ }
+
+ // Iterate through 25x25 grid cells
+ for (int offsetX = -12; offsetX <= 12; offsetX++) {
+ for (int offsetZ = -12; offsetZ <= 12; offsetZ++) {
+ int globalGridX = gridX + offsetX;
+ int globalGridZ = gridZ + offsetZ;
+
+ // Try to retrieve values from cache
+ float distanceFactor = getDistanceFactor(globalGridX, globalGridZ);
+ if (distanceFactor != -1.0F) {
+ // Compute the distance to the origin
+ float deltaX = gridOriginX - offsetX * GRID_SIZE;
+ float deltaZ = gridOriginZ - offsetZ * GRID_SIZE;
+
+ // Calculate the density at this grid cell
+ float scaledDistance = MathHelper.sqrt(deltaX * deltaX + deltaZ * deltaZ) * distanceFactor;
+ float densityHere = ISLAND_RADIUS - scaledDistance;
+
+ // Try to return early if we're over the max
+ if (densityHere > density) {
+ if (densityHere >= MAX) {
+ return MAX;
+ }
+
+ density = densityHere;
+ }
+ }
+ }
+ }
+
+ // Avoid a call to Math.max because the density cannot be bigger than the max.
+ if (density < MIN) {
+ return MIN;
+ }
+
+ return density;
+ }
+}
diff --git a/src/main/java/net/minecraft/server/ChunkGeneratorAbstract.java b/src/main/java/net/minecraft/server/ChunkGeneratorAbstract.java
index 321ebe8891defb46f3ad3dfea37c9bb6e2025ad7..119804e5c12aca3f4fbfeaf424f46152f43b3941 100644
--- a/src/main/java/net/minecraft/server/ChunkGeneratorAbstract.java
+++ b/src/main/java/net/minecraft/server/ChunkGeneratorAbstract.java
@@ -57,12 +57,13 @@ public final class ChunkGeneratorAbstract extends ChunkGenerator {
private final NoiseGenerator t;
private final NoiseGeneratorOctaves u;
@Nullable
- private final NoiseGenerator3Handler v;
+ private final NoiseGenerator3Handler v; // Yatopia - yarn "SimplexNoiseSampler"
protected final IBlockData f;
protected final IBlockData g;
private final long w;
protected final Supplier<GeneratorSettingBase> h;
private final int x;
+ private ThreadLocal<me.jellysquid.mods.lithium.common.world.noise.SimplexNoiseCache> tlCache; // Yatopia
public ChunkGeneratorAbstract(WorldChunkManager worldchunkmanager, long i, Supplier<GeneratorSettingBase> supplier) {
this(worldchunkmanager, worldchunkmanager, i, supplier);
@@ -99,7 +100,7 @@ public final class ChunkGeneratorAbstract extends ChunkGenerator {
} else {
this.v = null;
}
-
+ this.tlCache = ThreadLocal.withInitial(() -> new me.jellysquid.mods.lithium.common.world.noise.SimplexNoiseCache(v)); // Yatopia
}
@Override
@@ -164,7 +165,8 @@ public final class ChunkGeneratorAbstract extends ChunkGenerator {
double d3;
if (this.v != null) {
- d0 = (double) (WorldChunkManagerTheEnd.a(this.v, i, j) - 8.0F);
+ //d0 = (double) (WorldChunkManagerTheEnd.a(this.v, i, j) - 8.0F); // Yatopia
+ d0 = tlCache.get().getNoiseAt(i, j) - 8.0F; // Yatopia
if (d0 > 0.0D) {
d1 = 0.25D;
} else {

View File

@ -21,7 +21,7 @@ index 92ab79532d29341e8840341ff5ee8f5203cb4aad..bc7b9d0b4d9e3f7519bb013054eeec51
public abstract EnumAxisCycle a();
diff --git a/src/main/java/net/minecraft/server/VoxelShape.java b/src/main/java/net/minecraft/server/VoxelShape.java
index 98f9ded42264cb88cff701a85d22d99e203ef7cf..b94f08dcc911cd632a9c4fb93dcbc4d47aceca94 100644
index 700660dd93b3090334bb3033d5f5fdd6ab684744..fd34dffa63995c1fc277eac28eb1cd23e3a5e105 100644
--- a/src/main/java/net/minecraft/server/VoxelShape.java
+++ b/src/main/java/net/minecraft/server/VoxelShape.java
@@ -148,6 +148,7 @@ public abstract class VoxelShape {
@ -33,10 +33,10 @@ index 98f9ded42264cb88cff701a85d22d99e203ef7cf..b94f08dcc911cd632a9c4fb93dcbc4d4
return this.a(EnumAxisCycle.a(enumdirection_enumaxis, EnumDirection.EnumAxis.X), axisalignedbb, d0);
}
diff --git a/src/main/java/net/minecraft/server/VoxelShapes.java b/src/main/java/net/minecraft/server/VoxelShapes.java
index 877ef81bd8285167ce11c116b8ad803fda63c6c9..1bf27c47c8fcc2fb0a712b7d10a8c50cea677926 100644
index db735e29d427cc8f4bd4ba54c7a44daf9fed9e61..641e40dd24082cfe1450e5a3a29312bd07ad2155 100644
--- a/src/main/java/net/minecraft/server/VoxelShapes.java
+++ b/src/main/java/net/minecraft/server/VoxelShapes.java
@@ -279,6 +279,21 @@ public final class VoxelShapes {
@@ -272,6 +272,21 @@ public final class VoxelShapes {
return 0.0D;
} else {
EnumAxisCycle enumaxiscycle1 = enumaxiscycle.a();

View File

@ -8,14 +8,49 @@ major release and reimplemented again if mojang changes stuff with
villagers again.
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/util/Producer.java b/src/main/java/me/jellysquid/mods/lithium/common/util/Producer.java
index f3224ea636fef95d368b934ed4b3e9060c4b10a2..f2d5878d235fdbfc11c74f87b95f029330c70309 100644
--- a/src/main/java/me/jellysquid/mods/lithium/common/util/Producer.java
new file mode 100644
index 0000000000000000000000000000000000000000..18666522e08153093bc5457b2524622a4b619233
--- /dev/null
+++ b/src/main/java/me/jellysquid/mods/lithium/common/util/Producer.java
@@ -46,6 +46,16 @@ public interface Producer<T> {
}
}
+ // also checks contains and is thus only 1 generic
@@ -0,0 +1,54 @@
+package me.jellysquid.mods.lithium.common.util;
+
+import java.util.List;
+import java.util.Spliterator;
+import java.util.Spliterators;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
+import net.yatopia.server.HoldingConsumer;
+
+public interface Producer<T> {
+ /**
+ * Computes the next sequence of values in a collection. If a null value is passed for {@param consumer}, then
+ * the producer will only return whether or not elements existed.
+ *
+ * @param consumer The (nullable) consumer which will accept the computed values during this run.
+ * @return True if the producer produced any values, otherwise false
+ */
+ boolean computeNext(Consumer<? super T> consumer);
+
+ default <U> Producer<U> map(Function<T, U> mapper) {
+ return consumer -> {
+ Consumer<? super T> con = (t) -> consumer.accept(mapper.apply(t));
+ return Producer.this.computeNext(con);
+ };
+ }
+
+ static <T> Stream<T> asStream(Producer<T> producer) {
+ return StreamSupport.stream(new Spliterators.AbstractSpliterator<T>(Long.MAX_VALUE, Spliterator.ORDERED | Spliterator.NONNULL) {
+ @Override
+ public boolean tryAdvance(Consumer<? super T> action) {
+ return producer.computeNext(action);
+ }
+ }, false);
+ }
+
+ static <T> void fillList(Producer<T> producer, List<T> list) {
+ HoldingConsumer<T> consumer = new HoldingConsumer<>();
+ while (producer.computeNext(consumer)) {
@ -25,9 +60,13 @@ index f3224ea636fef95d368b934ed4b3e9060c4b10a2..f2d5878d235fdbfc11c74f87b95f0293
+ }
+ }
+
Producer<?> EMPTY_PRODUCER = consumer -> false;
@SuppressWarnings("unchecked")
+ Producer<?> EMPTY_PRODUCER = consumer -> false;
+
+ @SuppressWarnings("unchecked")
+ static <T> Producer<T> empty() {
+ return (Producer<T>) EMPTY_PRODUCER;
+ }
+}
diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java
index 6fcc7ed7c129e6a33386d65b37cbba4a44e96f0f..dbe6f7d555e8c851faba5cafee8831c516256c09 100644
--- a/src/main/java/net/minecraft/server/BlockPosition.java
@ -383,6 +422,29 @@ index f43bc1f7d693d63c6bbdba976c048d2d0c8767b1..8b9f5797a6bee47ff16ee713777b5220
})).add(villageplacerecord);
return true;
}
diff --git a/src/main/java/net/yatopia/server/HoldingConsumer.java b/src/main/java/net/yatopia/server/HoldingConsumer.java
new file mode 100644
index 0000000000000000000000000000000000000000..fca24201a721f0ac6c962e79119c4613734e8108
--- /dev/null
+++ b/src/main/java/net/yatopia/server/HoldingConsumer.java
@@ -0,0 +1,17 @@
+package net.yatopia.server;
+
+import java.util.function.Consumer;
+
+public class HoldingConsumer<T> implements Consumer<T> {
+
+ private T value;
+
+ @Override
+ public void accept(T t) {
+ this.value = t;
+ }
+
+ public T getValue() {
+ return value;
+ }
+}
diff --git a/src/main/java/net/yatopia/server/YatopiaChunkPos.java b/src/main/java/net/yatopia/server/YatopiaChunkPos.java
new file mode 100644
index 0000000000000000000000000000000000000000..871e305356103f87c2c1ad1487c804b60e13c076

File diff suppressed because it is too large Load Diff

View File

@ -5,10 +5,10 @@ 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
index a3ead1e695245aacde118daa12e21669f2064a00..7e59a5e620e8a2ccffd494d643a7d51a8944dec1 100644
index fdfd955aad65b758696b72a71521ec74e9aa122a..7c3e792b53329c869fbd21e298961b3f254c6ef5 100644
--- a/src/main/java/net/minecraft/server/BlockBase.java
+++ b/src/main/java/net/minecraft/server/BlockBase.java
@@ -641,6 +641,7 @@ public abstract class BlockBase {
@@ -639,6 +639,7 @@ public abstract class BlockBase {
return this.getBlock().getInventory(this.p(), world, blockposition);
}
@ -16,7 +16,7 @@ index a3ead1e695245aacde118daa12e21669f2064a00..7e59a5e620e8a2ccffd494d643a7d51a
public boolean a(Tag<Block> tag) {
return this.getBlock().a(tag);
}
@@ -649,6 +650,7 @@ public abstract class BlockBase {
@@ -647,6 +648,7 @@ public abstract class BlockBase {
return this.getBlock().a(tag) && predicate.test(this);
}

View File

@ -1,83 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: JellySquid <jellysquid+atwork@protonmail.com>
Date: Thu, 20 Aug 2020 17:25:11 +0300
Subject: [PATCH] lithium MixinChunkSection
Original code by JellySquid, licensed under LGPLv3
you can find the original code on https://github.com/jellysquid3/lithium-fabric/ (Yarn mappings)
diff --git a/src/main/java/net/minecraft/server/BlockBase.java b/src/main/java/net/minecraft/server/BlockBase.java
index fdfd955aad65b758696b72a71521ec74e9aa122a..a3ead1e695245aacde118daa12e21669f2064a00 100644
--- a/src/main/java/net/minecraft/server/BlockBase.java
+++ b/src/main/java/net/minecraft/server/BlockBase.java
@@ -352,6 +352,8 @@ public abstract class BlockBase {
}
// Tuinity end
+ public final boolean shapeExceedsCubeUncached() { return this.a == null || this.a.c; } // Yatopia - uncached shapeExceedsCube due to collisions stuff
+
public void a() {
this.fluid = this.getBlock().d(this.p()); // Paper - moved from getFluid()
this.isTicking = this.getBlock().isTicking(this.p()); // Paper - moved from isTicking()
diff --git a/src/main/java/net/minecraft/server/ChunkSection.java b/src/main/java/net/minecraft/server/ChunkSection.java
index cebd808e273dbdb88feb16920dd7a2f60390b34f..d210ac3d5775491e9beb885dde608f5e8fda8eb2 100644
--- a/src/main/java/net/minecraft/server/ChunkSection.java
+++ b/src/main/java/net/minecraft/server/ChunkSection.java
@@ -4,7 +4,7 @@ import java.util.function.Predicate;
import com.destroystokyo.paper.antixray.ChunkPacketInfo; // Paper - Anti-Xray - Add chunk packet info
import javax.annotation.Nullable;
-public class ChunkSection {
+public class ChunkSection implements me.jellysquid.mods.lithium.common.entity.movement.ChunkAwareBlockCollisionSweeper.OversizedBlocksCounter { // Yatopia
public static final DataPalette<IBlockData> GLOBAL_PALETTE = new DataPaletteGlobal<>(Block.REGISTRY_ID, Blocks.AIR.getBlockData());
final int yPos; // Paper - private -> package-private
@@ -12,6 +12,7 @@ public class ChunkSection {
short tickingBlockCount; // Paper - private -> package-private
private short e;
final DataPaletteBlock<IBlockData> blockIds; // Paper - package-private
+ private short oversizedBlockCount = 0; // Yatopia
final com.destroystokyo.paper.util.maplist.IBlockDataList tickingList = new com.destroystokyo.paper.util.maplist.IBlockDataList(); // Paper
@@ -67,6 +68,7 @@ public class ChunkSection {
if (!iblockdata1.isAir()) {
--this.nonEmptyBlockCount;
+ if (iblockdata1.shapeExceedsCubeUncached()) this.oversizedBlockCount--; // Yatopia
if (iblockdata1.isTicking()) {
--this.tickingBlockCount;
// Paper start
@@ -81,6 +83,7 @@ public class ChunkSection {
if (!iblockdata.isAir()) {
++this.nonEmptyBlockCount;
+ if (iblockdata.shapeExceedsCubeUncached()) this.oversizedBlockCount++; // Yatopia
if (iblockdata.isTicking()) {
++this.tickingBlockCount;
// Paper start
@@ -126,10 +129,12 @@ public class ChunkSection {
// Paper start
this.tickingList.clear();
// Paper end
+ this.oversizedBlockCount = 0; // Yatopia
this.nonEmptyBlockCount = 0;
this.tickingBlockCount = 0;
this.e = 0;
this.blockIds.forEachLocation((iblockdata, location) -> { // Paper
+ if (iblockdata.shapeExceedsCubeUncached()) this.oversizedBlockCount += location; // Yatopia
Fluid fluid = iblockdata.getFluid();
if (!iblockdata.isAir()) {
@@ -173,4 +178,11 @@ public class ChunkSection {
public boolean a(Predicate<IBlockData> predicate) {
return this.blockIds.contains(predicate);
}
+
+ // Yatopia start
+ @Override
+ public boolean hasOversizedBlocks() {
+ return this.oversizedBlockCount > 0;
+ }
+ // Yatopia end
}

View File

@ -18,10 +18,10 @@ index 2f9c97dd4e1d705a87772d18c7ab4883a876af08..f3494ac1ad659352ca5595adf9e6919b
return this.size == 0 && this.pendingTasks.isEmpty();
}
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index a728b5a95a02e713c288e52dd6b8e309e55241e8..d2e3cab67cdcb195747710ae719693dedc092038 100644
index 9417032aecb79916a9dbde71e2447d00018e3b28..abc62fb1e95f75355871e06341d6687433d74e94 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -1911,6 +1911,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
@@ -1905,6 +1905,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
}
// Paper end

View File

@ -1,19 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ivan Pekov <ivan@mrivanplays.com>
Date: Thu, 10 Sep 2020 10:36:21 +0300
Subject: [PATCH] Fix "Unable to save chunk" error
diff --git a/src/main/java/net/minecraft/server/EntitySlice.java b/src/main/java/net/minecraft/server/EntitySlice.java
index cdf54580a8275f40730f9cbdc1c0c4b4a3999a90..cf4da23e790af36e450fb1ffee9cab84b1c5f508 100644
--- a/src/main/java/net/minecraft/server/EntitySlice.java
+++ b/src/main/java/net/minecraft/server/EntitySlice.java
@@ -114,7 +114,7 @@ public class EntitySlice<T> extends AbstractCollection<T> implements me.jellysqu
}
public Iterator<T> iterator() {
- return (Iterator) (this.c.isEmpty() ? Collections.emptyIterator() : Iterators.unmodifiableIterator(this.c.iterator()));
+ return (this.c.isEmpty() ? Collections.emptyIterator() : this.c.iterator()); // Yatopia - fix unable to save chunk
}
public List<T> a() {

View File

@ -1,70 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Mykyta Komarn <nkomarn@hotmail.com>
Date: Tue, 29 Sep 2020 17:27:30 -0700
Subject: [PATCH] Use faster block collision check for entity suffocation check
Improves the speed of checks by ~3,000ns per entity on average.
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/entity/movement/ChunkAwareBlockCollisionSweeper.java b/src/main/java/me/jellysquid/mods/lithium/common/entity/movement/ChunkAwareBlockCollisionSweeper.java
index 7ed343cfb3130446c85dab2ca04d60f91e2c94fb..194d2f177b05c594c7a27b6191860a3f89394f06 100644
--- a/src/main/java/me/jellysquid/mods/lithium/common/entity/movement/ChunkAwareBlockCollisionSweeper.java
+++ b/src/main/java/me/jellysquid/mods/lithium/common/entity/movement/ChunkAwareBlockCollisionSweeper.java
@@ -16,6 +16,7 @@ import net.minecraft.server.VoxelShape;
import net.minecraft.server.VoxelShapeCollision;
import net.minecraft.server.VoxelShapes;
+import java.util.function.BiPredicate; // Yatopia
import static me.jellysquid.mods.lithium.common.entity.LithiumEntityCollisions.EPSILON;
/**
@@ -59,6 +60,21 @@ public class ChunkAwareBlockCollisionSweeper {
private ChunkSection cachedChunkSection;
private boolean needEntityCollisionCheck;
+ // Yatopia start
+ private boolean checkSuffocation;
+ private final BiPredicate<IBlockData, BlockPosition> suffocationPredicate = new BiPredicate<IBlockData, BlockPosition>() {
+ @Override
+ public boolean test(IBlockData iBlockData, BlockPosition blockPosition) {
+ return iBlockData.o(view, blockPosition);
+ }
+ };
+
+ public ChunkAwareBlockCollisionSweeper(ICollisionAccess view, Entity entity, AxisAlignedBB box, boolean checkSuffocation) {
+ this(view, entity, box);
+ this.checkSuffocation = checkSuffocation;
+ }
+ // Yatopia end
+
public ChunkAwareBlockCollisionSweeper(ICollisionAccess view, Entity entity, AxisAlignedBB box) {
this.box = box;
this.shape = VoxelShapes.of(box);
@@ -206,6 +222,11 @@ public class ChunkAwareBlockCollisionSweeper {
if (canInteractWithBlock(state, edgesHit)) {
this.pos.setValues(x, y, z);
+ // Yatopia start
+ if (checkSuffocation && !suffocationPredicate.test(state, this.pos)) {
+ continue;
+ }
+ // Yatopia end
VoxelShape collisionShape = state.getCollisionShape(this.view, this.pos, this.context);
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 6b96c392fb3eadd20f87675b797337d6d30cc7be..52d5f11edccd936eea85dc3610b91558e1409117 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -2186,9 +2186,12 @@ 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());
+ /* TODO Tuinity optimized method overridden
return ((WorldServer)this.world).collidesWithAnyBlockOrWorldBorder(this, axisalignedbb, false, false, (iblockdata, blockposition) -> { // Tuinity - use optimised method
return iblockdata.o(this.world, blockposition);
}); // Tuinity - use optimised method
+ */
+ return new me.jellysquid.mods.lithium.common.entity.movement.ChunkAwareBlockCollisionSweeper(this.world, this, axisalignedbb, true).getNextCollidedShape() != null; // Yatopia - fast suffocation check
}
}

View File

@ -8,7 +8,7 @@ Original code by SuperCoder79, licensed under LGPLv3
you can find the original code on https://github.com/jellysquid3/lithium-fabric/ (Yarn mappings)
diff --git a/src/main/java/net/minecraft/server/ChunkGeneratorAbstract.java b/src/main/java/net/minecraft/server/ChunkGeneratorAbstract.java
index 119804e5c12aca3f4fbfeaf424f46152f43b3941..e012510612a25fee850e583b3733ff49e8e41319 100644
index 321ebe8891defb46f3ad3dfea37c9bb6e2025ad7..fa60285c0c48147ad09b9197bfe577f504dd34bd 100644
--- a/src/main/java/net/minecraft/server/ChunkGeneratorAbstract.java
+++ b/src/main/java/net/minecraft/server/ChunkGeneratorAbstract.java
@@ -5,6 +5,8 @@ import com.mojang.serialization.codecs.RecordCodecBuilder;
@ -20,7 +20,7 @@ index 119804e5c12aca3f4fbfeaf424f46152f43b3941..e012510612a25fee850e583b3733ff49
import java.util.Iterator;
import java.util.List;
import java.util.Random;
@@ -112,7 +114,15 @@ public final class ChunkGeneratorAbstract extends ChunkGenerator {
@@ -111,7 +113,15 @@ public final class ChunkGeneratorAbstract extends ChunkGenerator {
return this.w == i && ((GeneratorSettingBase) this.h.get()).a(resourcekey);
}
@ -36,7 +36,7 @@ index 119804e5c12aca3f4fbfeaf424f46152f43b3941..e012510612a25fee850e583b3733ff49
double d4 = 0.0D;
double d5 = 0.0D;
double d6 = 0.0D;
@@ -148,7 +158,85 @@ public final class ChunkGeneratorAbstract extends ChunkGenerator {
@@ -147,7 +157,85 @@ public final class ChunkGeneratorAbstract extends ChunkGenerator {
}
return MathHelper.b(d4 / 512.0D, d5 / 512.0D, (d6 / 10.0D + 1.0D) / 2.0D);
@ -122,7 +122,7 @@ index 119804e5c12aca3f4fbfeaf424f46152f43b3941..e012510612a25fee850e583b3733ff49
private double[] b(int i, int j) {
double[] adouble = new double[this.o + 1];
@@ -275,7 +363,7 @@ public final class ChunkGeneratorAbstract extends ChunkGenerator {
@@ -273,7 +361,7 @@ public final class ChunkGeneratorAbstract extends ChunkGenerator {
double d2 = d1 * 24.575625D - 2.0D;
@ -131,7 +131,7 @@ index 119804e5c12aca3f4fbfeaf424f46152f43b3941..e012510612a25fee850e583b3733ff49
}
@Override
@@ -292,10 +380,10 @@ public final class ChunkGeneratorAbstract extends ChunkGenerator {
@@ -290,10 +378,10 @@ public final class ChunkGeneratorAbstract extends ChunkGenerator {
}
private int a(int i, int j, @Nullable IBlockData[] aiblockdata, @Nullable Predicate<IBlockData> predicate) {
@ -146,7 +146,7 @@ index 119804e5c12aca3f4fbfeaf424f46152f43b3941..e012510612a25fee850e583b3733ff49
double d0 = (double) i1 / (double) this.m;
double d1 = (double) j1 / (double) this.m;
double[][] adouble = new double[][]{this.b(k, l), this.b(k, l + 1), this.b(k + 1, l), this.b(k + 1, l + 1)};
@@ -534,9 +622,9 @@ public final class ChunkGeneratorAbstract extends ChunkGenerator {
@@ -532,9 +620,9 @@ public final class ChunkGeneratorAbstract extends ChunkGenerator {
StructurePiece structurepiece = (StructurePiece) objectlistiterator.next();
StructureBoundingBox structureboundingbox = structurepiece.g();
@ -158,7 +158,7 @@ index 119804e5c12aca3f4fbfeaf424f46152f43b3941..e012510612a25fee850e583b3733ff49
}
objectlistiterator.back(objectlist.size());
@@ -591,7 +679,7 @@ public final class ChunkGeneratorAbstract extends ChunkGenerator {
@@ -589,7 +677,7 @@ public final class ChunkGeneratorAbstract extends ChunkGenerator {
double d0 = (double) (i * i + k * k);
double d1 = (double) j + 0.5D;
double d2 = d1 * d1;

View File

@ -1,19 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ivan Pekov <ivan@mrivanplays.com>
Date: Thu, 29 Oct 2020 09:19:32 +0200
Subject: [PATCH] Make sure the block is cauldron before proceeding
Bandaid fixes 272. We need a proper solution for that tho
diff --git a/src/main/java/net/minecraft/server/BlockCauldron.java b/src/main/java/net/minecraft/server/BlockCauldron.java
index 9fed3883828e7d6ca917a5eca7a7a3e37582f983..0183efdcbdad89d24b658e0e72392cb29ea119ad 100644
--- a/src/main/java/net/minecraft/server/BlockCauldron.java
+++ b/src/main/java/net/minecraft/server/BlockCauldron.java
@@ -235,6 +235,7 @@ public class BlockCauldron extends Block {
if (f >= 0.15F) {
IBlockData iblockdata = world.getType(blockposition);
+ if (!iblockdata.isBlock(Blocks.CAULDRON)) return; // Yatopia - bandaid issue until we find what's actually going wrong
if ((Integer) iblockdata.get(BlockCauldron.LEVEL) < 3) {
this.a(world, blockposition, (IBlockData) iblockdata.a((IBlockState) BlockCauldron.LEVEL), 2); // CraftBukkit
}