Fix of the purpur-46 fix

also made it so that there's no limit for Chunk section positions
This commit is contained in:
Ivan Pekov 2020-09-10 18:45:06 +03:00
parent 838aa2bd51
commit 80a494c570
No known key found for this signature in database
GPG Key ID: BC975C392D9CA3A3
2 changed files with 31 additions and 61 deletions

View File

@ -7,27 +7,6 @@ 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 e6660fe1a552635e563103aa6fa078d422e6c0c7..0f2c992d35a552f53550f9890a7e674c10a152a4 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
@@ -40,6 +40,16 @@ public interface Producer<T> {
while (producer.computeNext(consumer)) list.add(consumer.getValue());
}
+ static <T> void fillList(Producer<T> producer, List<T> list, int boundSize) {
+ HoldingConsumer<T> consumer = new HoldingConsumer<>();
+ while (producer.computeNext(consumer)) {
+ if (list.size() >= boundSize) {
+ break;
+ }
+ list.add(consumer.getValue());
+ }
+ }
+
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
@ -409,7 +388,7 @@ index 0000000000000000000000000000000000000000..c7942b83b5c2d49e31c14eb51297baa3
+}
diff --git a/src/main/java/net/yatopia/server/YatopiaChunkSectionPos.java b/src/main/java/net/yatopia/server/YatopiaChunkSectionPos.java
new file mode 100644
index 0000000000000000000000000000000000000000..ba916bb61514e682b3cd074f8f07bf34af4ad026
index 0000000000000000000000000000000000000000..d76e96eb055731338b670c6df2e3d9fcdc7e9a03
--- /dev/null
+++ b/src/main/java/net/yatopia/server/YatopiaChunkSectionPos.java
@@ -0,0 +1,32 @@
@ -426,7 +405,7 @@ index 0000000000000000000000000000000000000000..ba916bb61514e682b3cd074f8f07bf34
+
+ public static List<SectionPosition> getChunkSectionPosList(int i, int j, int k, int l, int i1, int j1) {
+ List<SectionPosition> list = new LinkedList<>();
+ Producer.fillList(getChunkSectionPosProducer(i, j, k, l, i1, j1), list, (l - i + 1) * (i1 - j + 1) * (j1 - k + 1));
+ Producer.fillList(getChunkSectionPosProducer(i, j, k, l, i1, j1), list);
+ return list;
+ }
+

View File

@ -6,48 +6,39 @@ Subject: [PATCH] Respect permissions when constructing InventoryEnderChest
Fixes Purpur-46
diff --git a/src/main/java/net/minecraft/server/InventoryEnderChest.java b/src/main/java/net/minecraft/server/InventoryEnderChest.java
index d147377e5d2ee818f941f50f7392a1bc7f584ffb..6df8bb07b62979561d7c3773a542aba7c74857e4 100644
index d147377e5d2ee818f941f50f7392a1bc7f584ffb..fc83c50831feb73f5549ce709dc928a1047f87ab 100644
--- a/src/main/java/net/minecraft/server/InventoryEnderChest.java
+++ b/src/main/java/net/minecraft/server/InventoryEnderChest.java
@@ -20,7 +20,27 @@ public class InventoryEnderChest extends InventorySubcontainer {
}
public InventoryEnderChest(EntityHuman owner) {
- super(net.pl3x.purpur.PurpurConfig.enderChestSixRows ? 54 : 27); // Purpur
+ super(() -> { // Yatopia start
+ if (net.pl3x.purpur.PurpurConfig.enderChestSixRows) {
+ if (net.pl3x.purpur.PurpurConfig.enderChestPermissionRows) {
+ if (owner.getBukkitEntity().hasPermission("purpur.enderchest.rows.six")) {
+ return 54;
+ } else if (owner.getBukkitEntity().hasPermission("purpur.enderchest.rows.five")) {
+ return 45;
+ } else if (owner.getBukkitEntity().hasPermission("purpur.enderchest.rows.four")) {
+ return 36;
+ } else if (owner.getBukkitEntity().hasPermission("purpur.enderchest.rows.three")) {
+ return 27;
+ } else if (owner.getBukkitEntity().hasPermission("purpur.enderchest.rows.two")) {
+ return 18;
+ } else if (owner.getBukkitEntity().hasPermission("purpur.enderchest.rows.one")) {
+ return 9;
+ } else { /* prevent breakage */ return 27; }
+ } else {
+ return 54;
+ }
+ } else { return 27; }
+ }); // Purpur // Yatopia end
this.owner = owner;
@@ -25,6 +25,32 @@ public class InventoryEnderChest extends InventorySubcontainer {
// CraftBukkit end
}
diff --git a/src/main/java/net/minecraft/server/InventorySubcontainer.java b/src/main/java/net/minecraft/server/InventorySubcontainer.java
index 4cf5dad0939ecb636752e19ad19aec2c882d5efc..5bb7699397c98473197c1134acf8444533cb8507 100644
--- a/src/main/java/net/minecraft/server/InventorySubcontainer.java
+++ b/src/main/java/net/minecraft/server/InventorySubcontainer.java
@@ -58,6 +58,8 @@ public class InventorySubcontainer implements IInventory, AutoRecipeOutput {
return null;
}
+ public InventorySubcontainer(java.util.function.Supplier<Integer> size) { this(size.get()); } // Yatopia
+ // Yatopia start
+ @Override
+ public int getSize() {
+ if (owner != null && owner.getProfile() != null) {
+ if (net.pl3x.purpur.PurpurConfig.enderChestSixRows) {
+ if (net.pl3x.purpur.PurpurConfig.enderChestPermissionRows) {
+ org.bukkit.craftbukkit.entity.CraftHumanEntity bukkit = owner.getBukkitEntity();
+ if (bukkit.hasPermission("purpur.enderchest.rows.six")) {
+ return 54;
+ } else if (bukkit.hasPermission("purpur.enderchest.rows.five")) {
+ return 45;
+ } else if (bukkit.hasPermission("purpur.enderchest.rows.four")) {
+ return 36;
+ } else if (bukkit.hasPermission("purpur.enderchest.rows.three")) {
+ return 27;
+ } else if (bukkit.hasPermission("purpur.enderchest.rows.two")) {
+ return 18;
+ } else if (bukkit.hasPermission("purpur.enderchest.rows.one")) {
+ return 9;
+ } else { /* prevent breakage */ return 54; }
+ } else { return 54; }
+ } else { return 27; }
+ } else { return net.pl3x.purpur.PurpurConfig.enderChestSixRows ? 54 : 27; }
+ }
+ // Yatopia end
+
public InventorySubcontainer(int i) {
this(i, null);
public void a(TileEntityEnderChest tileentityenderchest) {
this.a = tileentityenderchest;
}