Some small patches

Fixes an issue with limits being ignored with per player spawning
Fixes an issue where you would be respawned south no matter the rotation of your spawn point.

Additionally, removed Producer#fillList(Producer, List) from the collisions patch and moved it
where it is first used. That's a misc maintainability change, but we have to be consistent!
This commit is contained in:
Ivan Pekov 2020-09-28 16:33:03 +03:00
parent 88dc76b64a
commit e37628ad1e
No known key found for this signature in database
GPG Key ID: BC975C392D9CA3A3
5 changed files with 86 additions and 27 deletions

View File

@ -56,6 +56,7 @@ # Patches
| server | Fix LightEngineThreaded memory leak | Ivan Pekov | |
| server | Fix exp drop of zombie pigmen (MC-56653) | Phoenix616 | |
| server | Fix lead fall dmg config | tr7zw | |
| server | Fix merging spawning values | Mariell Hoversholm | |
| server | Fix recipe crash | Ivan Pekov | |
| server | Fix the dead lagging the server | William Blake Galbreath | |
| server | Fix villager dupe | Ivan Pekov | |
@ -107,6 +108,7 @@ # Patches
| server | Remove stream for ender teleport | Sotr | |
| server | Remove vanilla profiler callers | Sotr | |
| server | Respect PlayerKickEvent leaveMessage | Ivan Pekov | |
| server | Respect rotation when respawning | Ivan Pekov | |
| server | Send more packets immediately | MrIvanPlays | |
| server | Shutdown Bootstrap thread pool | foss-mc | |
| server | Skip events if there's no listeners | William Blake Galbreath | |

View File

@ -155,7 +155,7 @@ index 0000000000000000000000000000000000000000..20f80ae80de91615ea02f0771f7c020c
+}
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/entity/LithiumEntityCollisions.java b/src/main/java/me/jellysquid/mods/lithium/common/entity/LithiumEntityCollisions.java
new file mode 100644
index 0000000000000000000000000000000000000000..ef9c294c986df8f1b19df79bdb3f88ab314c561b
index 0000000000000000000000000000000000000000..786cbf11f9699d8e2124a8c6196bc5cf202eb69b
--- /dev/null
+++ b/src/main/java/me/jellysquid/mods/lithium/common/entity/LithiumEntityCollisions.java
@@ -0,0 +1,188 @@
@ -200,7 +200,7 @@ index 0000000000000000000000000000000000000000..ef9c294c986df8f1b19df79bdb3f88ab
+ return;
+ }
+
+ Producer.fillList2(
+ Producer.fillList(
+ getBlockCollisionProducer(world, entity, box),
+ filled,
+ (voxelShape, axisAlignedBBS) -> VoxelShapes.addBoxesToIfIntersects(voxelShape, box, axisAlignedBBS)
@ -265,7 +265,7 @@ index 0000000000000000000000000000000000000000..ef9c294c986df8f1b19df79bdb3f88ab
+ return;
+ }
+
+ Producer.fillList2(
+ Producer.fillList(
+ getEntityCollisionProducer(view, entity, box.grow(EPSILON), EntityFilter.getFilter(entity), loadChunks),
+ filled,
+ (voxelShape, axisAlignedBBS) -> axisAlignedBBS.add(voxelShape.getBoundingBox())
@ -633,10 +633,10 @@ index 0000000000000000000000000000000000000000..7ed343cfb3130446c85dab2ca04d60f9
+}
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
new file mode 100644
index 0000000000000000000000000000000000000000..e1bd0d9282533b0236eb18c7287e9c0de40a7a6f
index 0000000000000000000000000000000000000000..e563e35089f26a7d76858f99b32440cd2eceabf1
--- /dev/null
+++ b/src/main/java/me/jellysquid/mods/lithium/common/util/Producer.java
@@ -0,0 +1,88 @@
@@ -0,0 +1,67 @@
+package me.jellysquid.mods.lithium.common.util;
+
+import java.util.List;
@ -675,29 +675,8 @@ index 0000000000000000000000000000000000000000..e1bd0d9282533b0236eb18c7287e9c0d
+ }, false);
+ }
+
+ static <T> void fillList(Producer<T> producer, List<T> list) {
+ HoldingConsumer<T> consumer = new HoldingConsumer<>();
+ while (producer.computeNext(consumer)) {
+ T value = consumer.getValue();
+ if (value == null || list.contains(value)) { continue; }
+ list.add(value);
+ }
+ if (!list.isEmpty()) {
+ boolean allComparable = true;
+ for (T value : list) {
+ if (!(value instanceof Comparable)) {
+ allComparable = false;
+ break;
+ }
+ }
+ if (allComparable) {
+ list.sort((o1, o2) -> ((Comparable<T>)o1).compareTo(o2));
+ }
+ }
+ }
+
+ // WARNING: does not check contains, you have to do that in the add function
+ static <T, R> void fillList2(Producer<T> producer, List<R> list, BiConsumer<T, List<R>> addFunction) {
+ static <T, R> void fillList(Producer<T> producer, List<R> list, BiConsumer<T, List<R>> addFunction) {
+ HoldingConsumer<T> consumer = new HoldingConsumer<>();
+ while (producer.computeNext(consumer)) {
+ T value = consumer.getValue();

View File

@ -7,6 +7,39 @@ Replaced all streams I could. I expect this to be dropped in the next
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 e563e35089f26a7d76858f99b32440cd2eceabf1..343cb58abb3deaf8766ea9bc4e425d40249c5acc 100644
--- a/src/main/java/me/jellysquid/mods/lithium/common/util/Producer.java
+++ b/src/main/java/me/jellysquid/mods/lithium/common/util/Producer.java
@@ -58,6 +58,28 @@ public interface Producer<T> {
}
}
+ // also checks contains and is thus only 1 generic
+ static <T> void fillList(Producer<T> producer, List<T> list) {
+ HoldingConsumer<T> consumer = new HoldingConsumer<>();
+ while (producer.computeNext(consumer)) {
+ T value = consumer.getValue();
+ if (value == null || list.contains(value)) { continue; }
+ list.add(value);
+ }
+ if (!list.isEmpty()) {
+ boolean allComparable = true;
+ for (T value : list) {
+ if (!(value instanceof Comparable)) {
+ allComparable = false;
+ break;
+ }
+ }
+ if (allComparable) {
+ list.sort((o1, o2) -> ((Comparable<T>)o1).compareTo(o2));
+ }
+ }
+ }
+
Producer<?> EMPTY_PRODUCER = consumer -> false;
@SuppressWarnings("unchecked")
diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java
index 6fcc7ed7c129e6a33386d65b37cbba4a44e96f0f..e6b5a21c523c598f53207d024322301fbae74825 100644
--- a/src/main/java/net/minecraft/server/BlockPosition.java

View File

@ -0,0 +1,19 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ivan Pekov <ivan@mrivanplays.com>
Date: Mon, 28 Sep 2020 16:23:11 +0300
Subject: [PATCH] Respect rotation when respawning
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index 25186df83c41ae168bca30b28149005f4b9f45e9..95cd25230601d22f02a31667b048bfd1ecda6009 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -812,7 +812,7 @@ public abstract class PlayerList {
entityplayer1.setRespawnPosition(worldserver1.getDimensionKey(), blockposition, f, flag1, false);
flag2 = !flag && flag3;
isBedSpawn = true;
- location = new Location(worldserver1.getWorld(), vec3d.x, vec3d.y, vec3d.z);
+ location = new Location(worldserver1.getWorld(), vec3d.x, vec3d.y, vec3d.z, f1, 0.0F); // Yatopia - respect rotation
} else if (blockposition != null) {
entityplayer1.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.a, 0.0F));
}

View File

@ -0,0 +1,26 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Mariell Hoversholm <proximyst@proximyst.com>
Date: Mon, 28 Sep 2020 16:25:34 +0300
Subject: [PATCH] Fix merging spawning values
diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java
index 62e7282b4baf375d57f881241231ebf2ce1b82ad..7e99aa27fc4cac2e553d0b84dcf85f8f637d5451 100644
--- a/src/main/java/net/minecraft/server/SpawnerCreature.java
+++ b/src/main/java/net/minecraft/server/SpawnerCreature.java
@@ -161,9 +161,12 @@ public final class SpawnerCreature {
spawnercreature_d.a(entityinsentient, ichunkaccess);
},
difference, worldserver.paperConfig.perPlayerMobSpawns ? worldserver.getChunkProvider().playerChunkMap::updatePlayerMobTypeMap : null);
- spawnercreature_d.getEntityCountsByType().mergeInt(enumcreaturetype, spawnCount, (keyInMap, valueInMap) -> {
- return Integer.valueOf(spawnCount + valueInMap.intValue());
- });
+ // Yatopia start - fix this
+ //spawnercreature_d.getEntityCountsByType().mergeInt(enumcreaturetype, spawnCount, (keyInMap, valueInMap) -> {
+ // return Integer.valueOf(spawnCount + valueInMap.intValue());
+ //});
+ spawnercreature_d.getEntityCountsByType().mergeInt(enumcreaturetype, spawnCount, Integer::sum);
+ // Yatopia end
// Paper end - per player mob spawning
}
}