mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2025-02-16 20:32:32 +01:00
Replace ArrayList and LinkedList usage in our code with GlueList
Some stuff wouldn't be _that_ heavy with this change. Is not a very big deal, but it provides extra performance.
This commit is contained in:
parent
f18a93c223
commit
e7043ccbff
@ -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 bbbbeaafe8d699d59b04fe44a09b6b5fd9f1fac5..9cbd38663c5e1e8d096f3e4a5383ed9ddbf691fe 100644
|
||||
index bbbbeaafe8d699d59b04fe44a09b6b5fd9f1fac5..47dcc1b9242cb6d035d554ab0ed235b11238f469 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 {
|
||||
@ -15,9 +15,9 @@ index bbbbeaafe8d699d59b04fe44a09b6b5fd9f1fac5..9cbd38663c5e1e8d096f3e4a5383ed9d
|
||||
- public final List<TileEntity> tileEntityListTick = Lists.newArrayList();
|
||||
- protected final List<TileEntity> tileEntityListPending = Lists.newArrayList();
|
||||
- protected final java.util.Set<TileEntity> tileEntityListUnload = com.google.common.collect.Sets.newHashSet();
|
||||
+ public final List<TileEntity> tileEntityListTick = me.jellysquid.mods.lithium.common.util.collections.HashedList.wrapper(Lists.newArrayList()); // Yatopia
|
||||
+ protected final List<TileEntity> tileEntityListPending = me.jellysquid.mods.lithium.common.util.collections.HashedList.wrapper(Lists.newArrayList()); // Yatopia
|
||||
+ protected final List<TileEntity> tileEntityListUnload = me.jellysquid.mods.lithium.common.util.collections.HashedList.wrapper(Lists.newArrayList()); // Yatopia
|
||||
+ public final List<TileEntity> tileEntityListTick = me.jellysquid.mods.lithium.common.util.collections.HashedList.wrapper(new net.yatopia.server.list.GlueList<>()); // Yatopia
|
||||
+ protected final List<TileEntity> tileEntityListPending = me.jellysquid.mods.lithium.common.util.collections.HashedList.wrapper(new net.yatopia.server.list.GlueList<>()); // Yatopia
|
||||
+ protected final List<TileEntity> tileEntityListUnload = me.jellysquid.mods.lithium.common.util.collections.HashedList.wrapper(new net.yatopia.server.list.GlueList<>()); // Yatopia
|
||||
public final Thread serverThread;
|
||||
private final boolean debugWorld;
|
||||
private int d;
|
@ -5,7 +5,7 @@ Subject: [PATCH] Optimize BehaviorController
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/BehaviorController.java b/src/main/java/net/minecraft/server/BehaviorController.java
|
||||
index ae2905b403a63396d9cdc61444586ea5548f2974..4ad7f42158bb945088a4d1c574c63dd6c15fa53c 100644
|
||||
index ae2905b403a63396d9cdc61444586ea5548f2974..6b8da8303a19bbd65a4b38c664c49a6a8ac646a4 100644
|
||||
--- a/src/main/java/net/minecraft/server/BehaviorController.java
|
||||
+++ b/src/main/java/net/minecraft/server/BehaviorController.java
|
||||
@@ -53,13 +53,16 @@ public class BehaviorController<E extends EntityLiving> {
|
||||
@ -21,7 +21,7 @@ index ae2905b403a63396d9cdc61444586ea5548f2974..4ad7f42158bb945088a4d1c574c63dd6
|
||||
- });
|
||||
+ // Yatopia start
|
||||
+ // about previous impl: WHY ? WHO DID THIS TO YOU?
|
||||
+ Collection<T> candidates = new java.util.ArrayList<>();
|
||||
+ Collection<T> candidates = new net.yatopia.server.list.GlueList<>();
|
||||
+ for (MemoryModuleType<?> moduleType : collection) {
|
||||
+ moduleType.getSerializer()
|
||||
+ .map(c -> IRegistry.MEMORY_MODULE_TYPE.getKey(moduleType))
|
||||
@ -79,7 +79,7 @@ index ae2905b403a63396d9cdc61444586ea5548f2974..4ad7f42158bb945088a4d1c574c63dd6
|
||||
|
||||
+ // Yatopia start
|
||||
+ private List<BehaviorController.a<?>> memoriesList() {
|
||||
+ List<BehaviorController.a<?>> ret = new java.util.ArrayList<>();
|
||||
+ List<BehaviorController.a<?>> ret = new net.yatopia.server.list.GlueList<>();
|
||||
+ for (Map.Entry<MemoryModuleType<?>, Optional<? extends ExpirableMemory<?>>> entry : memories.entrySet()) {
|
||||
+ ret.add(BehaviorController.a.b(entry.getKey(), (Optional) entry.getValue()));
|
||||
+ }
|
@ -10,7 +10,7 @@ Co-authored-by: Ivan Pekov <ivan@mrivanplays.com>
|
||||
|
||||
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/entity/EntityClassGroup.java b/src/main/java/me/jellysquid/mods/lithium/common/entity/EntityClassGroup.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..b400a5870b64b9eb92b6a8311793f5c8ea8df9af
|
||||
index 0000000000000000000000000000000000000000..91608928dc5cd2f600f1ce57ef7931078f354ea6
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/jellysquid/mods/lithium/common/entity/EntityClassGroup.java
|
||||
@@ -0,0 +1,101 @@
|
||||
@ -34,7 +34,7 @@ index 0000000000000000000000000000000000000000..b400a5870b64b9eb92b6a8311793f5c8
|
||||
+ //Keep a set of classes that were already added to matching class groups, so we only analyse them once.
|
||||
+ private static final Map<Class<?>, Object> knownEntityClasses = new ConcurrentHashMap<>(); //value unused, no set variant available
|
||||
+ //Keep track of available class groups for updating them in case an entity class is instantiated for the first time
|
||||
+ private static final List<EntityClassGroup> entityClassGroups = new ArrayList<>();
|
||||
+ private static final List<EntityClassGroup> entityClassGroups = new net.yatopia.server.list.GlueList<>(); // Yatopia - GlueList
|
||||
+
|
||||
+ public static final EntityClassGroup COLLISION_BOX_OVERRIDE = new EntityClassGroup(
|
||||
+ (entityClass) -> {
|
||||
@ -862,7 +862,7 @@ index 798ce0029c980d340d74dff53d702ef3cd00e33e..eec6dbda1b5a34122a75f11dfa82506f
|
||||
// Paper end
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/EntitySlice.java b/src/main/java/net/minecraft/server/EntitySlice.java
|
||||
index 1250c3cbe915815939627701c153ba6254fc05f0..e0cbcc0a15f8089c29957badc20b0a786831c64b 100644
|
||||
index 1250c3cbe915815939627701c153ba6254fc05f0..06a51ca13d484dd319aa96364b2f1b533b184c36 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntitySlice.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntitySlice.java
|
||||
@@ -14,18 +14,35 @@ import java.util.Map.Entry;
|
||||
@ -880,10 +880,11 @@ index 1250c3cbe915815939627701c153ba6254fc05f0..e0cbcc0a15f8089c29957badc20b0a78
|
||||
|
||||
private final Map<Class<?>, List<T>> a = Maps.newHashMap();
|
||||
private final Class<T> b;
|
||||
private final List<T> c = Lists.newArrayList();
|
||||
|
||||
+ private Reference2ReferenceOpenHashMap<EntityClassGroup, ReferenceLinkedOpenHashSet<T>> entitiesByGroup; // Yatopia
|
||||
- private final List<T> c = Lists.newArrayList();
|
||||
+ private final List<T> c = new net.yatopia.server.list.GlueList<>(); // Yatopia
|
||||
+
|
||||
+ private Reference2ReferenceOpenHashMap<EntityClassGroup, ReferenceLinkedOpenHashSet<T>> entitiesByGroup; // Yatopia
|
||||
|
||||
public EntitySlice(Class<T> oclass) {
|
||||
this.b = oclass;
|
||||
this.a.put(oclass, this.c);
|
||||
@ -925,7 +926,7 @@ index 1250c3cbe915815939627701c153ba6254fc05f0..e0cbcc0a15f8089c29957badc20b0a78
|
||||
- return (List) stream.filter(oclass1::isInstance).collect(Collectors.toList());
|
||||
+ List<S> list = (List<S>) this.a.computeIfAbsent(oclass, (oclass1) -> { // Yatopia - decompile fix
|
||||
+ // Yatopia start - how about we nuke stream?
|
||||
+ List<T> ret = Lists.newArrayList();
|
||||
+ List<T> ret = new net.yatopia.server.list.GlueList<>();
|
||||
+ for (T t : c) {
|
||||
+ if (oclass1.isInstance(t)) {
|
||||
+ ret.add(t);
|
@ -6,7 +6,7 @@ Subject: [PATCH] Fix recipe crash
|
||||
Caused due to slow streams, was kabooming tps when you were crafting F A S T
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/CraftingManager.java b/src/main/java/net/minecraft/server/CraftingManager.java
|
||||
index 64adf87f2fe9921e49bf7a76170bb9908dfdaf19..a707c85f2f6b0177781755decc8bc2e0d1eacd4a 100644
|
||||
index 64adf87f2fe9921e49bf7a76170bb9908dfdaf19..09b8065156a66a72ad5d09c6e8be0551970ffb56 100644
|
||||
--- a/src/main/java/net/minecraft/server/CraftingManager.java
|
||||
+++ b/src/main/java/net/minecraft/server/CraftingManager.java
|
||||
@@ -78,9 +78,15 @@ public class CraftingManager extends ResourceDataJson {
|
||||
@ -32,7 +32,7 @@ index 64adf87f2fe9921e49bf7a76170bb9908dfdaf19..a707c85f2f6b0177781755decc8bc2e0
|
||||
+ // Yatopia start - WHY?! WHO DID THIS TO YOU!?!
|
||||
+ Collection<IRecipe<C>> recipeCollection = this.b(recipes).values();
|
||||
+ if (recipeCollection.isEmpty()) return java.util.Collections.emptyList();
|
||||
+ List<T> ret = new java.util.ArrayList<>();
|
||||
+ List<T> ret = new net.yatopia.server.list.GlueList<>();
|
||||
+ for (IRecipe<C> iRecipe : recipeCollection) recipes.a(iRecipe, world, c0).ifPresent(ret::add);
|
||||
+ ret.sort(Comparator.comparing((iRecipe) -> iRecipe.getResult().getTranslationKey()));
|
||||
+ return ret;
|
@ -29,7 +29,7 @@ index f3224ea636fef95d368b934ed4b3e9060c4b10a2..f2d5878d235fdbfc11c74f87b95f0293
|
||||
|
||||
@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
|
||||
index 6fcc7ed7c129e6a33386d65b37cbba4a44e96f0f..dbe6f7d555e8c851faba5cafee8831c516256c09 100644
|
||||
--- a/src/main/java/net/minecraft/server/BlockPosition.java
|
||||
+++ b/src/main/java/net/minecraft/server/BlockPosition.java
|
||||
@@ -341,6 +341,16 @@ public class BlockPosition extends BaseBlockPosition {
|
||||
@ -38,7 +38,7 @@ index 6fcc7ed7c129e6a33386d65b37cbba4a44e96f0f..e6b5a21c523c598f53207d024322301f
|
||||
|
||||
+ // Yatopia start
|
||||
+ public static java.util.List<BlockPosition> getPositions(int i, int j, int k, int l, int i1, int j1) {
|
||||
+ java.util.List<BlockPosition> ret = new java.util.ArrayList<>();
|
||||
+ java.util.List<BlockPosition> ret = new net.yatopia.server.list.GlueList<>();
|
||||
+ Iterable<BlockPosition> iterable = b(i, j, k, l, i1, j1);
|
||||
+ net.yatopia.server.HoldingConsumer<BlockPosition> consumer = new net.yatopia.server.HoldingConsumer<>();
|
||||
+ java.util.Spliterator<BlockPosition> spliterator = iterable.spliterator();
|
||||
@ -70,7 +70,7 @@ index dcaf9f8574a9c913b64ba3a1d8b02220db720225..3df4ae0f0921670c19abe17a115da428
|
||||
int i = Math.abs(chunkcoordintpair.x - chunkcoordintpair1.x) + 1;
|
||||
int j = Math.abs(chunkcoordintpair.z - chunkcoordintpair1.z) + 1;
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityBee.java b/src/main/java/net/minecraft/server/EntityBee.java
|
||||
index b1ff30fb1569ddf59f46240266ce32f0aa96da1a..68deb623508326841cf750fca45b53841d97d612 100644
|
||||
index b1ff30fb1569ddf59f46240266ce32f0aa96da1a..25e35d7b88cd93f70a3dbef86995b0bb2b69dc81 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityBee.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityBee.java
|
||||
@@ -720,15 +720,24 @@ public class EntityBee extends EntityAnimal implements IEntityAngerable, EntityB
|
||||
@ -83,7 +83,7 @@ index b1ff30fb1569ddf59f46240266ce32f0aa96da1a..68deb623508326841cf750fca45b5384
|
||||
}, blockposition, 20, VillagePlace.Occupancy.ANY);
|
||||
-
|
||||
+ // Yatopia start
|
||||
+ List<BlockPosition> ret = new java.util.ArrayList<>();
|
||||
+ List<BlockPosition> ret = new net.yatopia.server.list.GlueList<>();
|
||||
+ for (VillagePlaceRecord record : stream) {
|
||||
+ BlockPosition pos = record.getPosition();
|
||||
+ if (i(pos)) { ret.add(pos); }
|
||||
@ -171,7 +171,7 @@ index f95925f1c5d091f1a129d0437bb6e175c6ac080f..6796b1a832779b65d337c63d6b600e2a
|
||||
return StreamSupport.stream(new AbstractSpliterator<SectionPosition>((long) ((l - i + 1) * (i1 - j + 1) * (j1 - k + 1)), 64) {
|
||||
final CursorPosition a = new CursorPosition(i, j, k, l, i1, j1);
|
||||
diff --git a/src/main/java/net/minecraft/server/VillagePlace.java b/src/main/java/net/minecraft/server/VillagePlace.java
|
||||
index 6ab80cf7908437309a7346d71e42cf128a6f13d9..07a36d1955037524715181461cc2aa5d911b6efd 100644
|
||||
index 6ab80cf7908437309a7346d71e42cf128a6f13d9..d47f433d37408c4467a018386aed28586180fd54 100644
|
||||
--- a/src/main/java/net/minecraft/server/VillagePlace.java
|
||||
+++ b/src/main/java/net/minecraft/server/VillagePlace.java
|
||||
@@ -46,7 +46,7 @@ public class VillagePlace extends RegionFileSection<VillagePlaceSection> {
|
||||
@ -192,7 +192,7 @@ index 6ab80cf7908437309a7346d71e42cf128a6f13d9..07a36d1955037524715181461cc2aa5d
|
||||
+ int j = Math.floorDiv(i, 16) + 1;
|
||||
+
|
||||
+ java.util.List<ChunkCoordIntPair> list = ChunkCoordIntPair.streamList(new ChunkCoordIntPair(pos), j);
|
||||
+ java.util.List<VillagePlaceRecord> ret = new java.util.ArrayList<>();
|
||||
+ java.util.List<VillagePlaceRecord> ret = new net.yatopia.server.list.GlueList<>();
|
||||
+ for (ChunkCoordIntPair chunkPos : list) {
|
||||
+ for (int k = 0; k < 16; k++) { // ITS THE LAW
|
||||
+ this.d(SectionPosition.a(chunkPos, k).asLong()).ifPresent(section -> ret.addAll(section.aList(filter, occupancy)));
|
||||
@ -202,7 +202,7 @@ index 6ab80cf7908437309a7346d71e42cf128a6f13d9..07a36d1955037524715181461cc2aa5d
|
||||
+ }
|
||||
+ public java.util.List<VillagePlaceRecord> cList(Predicate<VillagePlaceType> predicate, BlockPosition pos, int i, VillagePlace.Occupancy occupancy) {
|
||||
+ int j = i * i;
|
||||
+ java.util.List<VillagePlaceRecord> ret = new java.util.ArrayList<>();
|
||||
+ java.util.List<VillagePlaceRecord> ret = new net.yatopia.server.list.GlueList<>();
|
||||
+ for (VillagePlaceRecord record : this.bList(predicate, pos, i, occupancy)) {
|
||||
+ if (record.getPosition().distanceSquared(pos) <= j) { ret.add(record); }
|
||||
+ }
|
||||
@ -218,7 +218,7 @@ index 6ab80cf7908437309a7346d71e42cf128a6f13d9..07a36d1955037524715181461cc2aa5d
|
||||
|
||||
+ // Yatopia start
|
||||
+ public java.util.List<BlockPosition> aList(Predicate<VillagePlaceType> predicate, Predicate<BlockPosition> posFilter, BlockPosition pos, int i, VillagePlace.Occupancy occupancy) {
|
||||
+ java.util.List<BlockPosition> ret = new java.util.ArrayList<>();
|
||||
+ java.util.List<BlockPosition> ret = new net.yatopia.server.list.GlueList<>();
|
||||
+ for (VillagePlaceRecord record : this.cList(predicate, pos, i, occupancy)) {
|
||||
+ BlockPosition recordPosition = record.getPosition();
|
||||
+ if (posFilter.test(recordPosition)) ret.add(recordPosition);
|
||||
@ -270,7 +270,7 @@ index 6ab80cf7908437309a7346d71e42cf128a6f13d9..07a36d1955037524715181461cc2aa5d
|
||||
public Optional<BlockPosition> a(Predicate<VillagePlaceType> predicate, Predicate<BlockPosition> predicate1, BlockPosition blockposition, int i) {
|
||||
+ // Yatopia start
|
||||
+ java.util.List<VillagePlaceRecord> list = this.cList(predicate, blockposition, i, VillagePlace.Occupancy.HAS_SPACE);
|
||||
+ java.util.List<VillagePlaceRecord> filtered = new java.util.ArrayList<>();
|
||||
+ java.util.List<VillagePlaceRecord> filtered = new net.yatopia.server.list.GlueList<>();
|
||||
+ for (VillagePlaceRecord record : list) {
|
||||
+ if (predicate1.test(record.getPosition())) {
|
||||
+ filtered.add(record);
|
||||
@ -331,7 +331,7 @@ index 6ab80cf7908437309a7346d71e42cf128a6f13d9..07a36d1955037524715181461cc2aa5d
|
||||
|
||||
final class a extends LightEngineGraphSection {
|
||||
diff --git a/src/main/java/net/minecraft/server/VillagePlaceSection.java b/src/main/java/net/minecraft/server/VillagePlaceSection.java
|
||||
index 77c66bc9952542d2444b402896a3d9f622ca2ff9..b47abdabb592cfff6a4bf9ee638dd72f8a825499 100644
|
||||
index 77c66bc9952542d2444b402896a3d9f622ca2ff9..c4571e8a78396cc0c1554183258f1b4928f401eb 100644
|
||||
--- a/src/main/java/net/minecraft/server/VillagePlaceSection.java
|
||||
+++ b/src/main/java/net/minecraft/server/VillagePlaceSection.java
|
||||
@@ -28,7 +28,7 @@ public class VillagePlaceSection {
|
||||
@ -349,7 +349,7 @@ index 77c66bc9952542d2444b402896a3d9f622ca2ff9..b47abdabb592cfff6a4bf9ee638dd72f
|
||||
|
||||
+ // Yatopia start
|
||||
+ public java.util.List<VillagePlaceRecord> aList(Predicate<VillagePlaceType> predicate, VillagePlace.Occupancy occupancy) {
|
||||
+ java.util.List<VillagePlaceRecord> ret = new java.util.ArrayList<>();
|
||||
+ java.util.List<VillagePlaceRecord> ret = new net.yatopia.server.list.GlueList<>();
|
||||
+ for (Map.Entry<VillagePlaceType, Set<VillagePlaceRecord>> entry : c.entrySet()) {
|
||||
+ if (predicate.test(entry.getKey())) {
|
||||
+ for (VillagePlaceRecord record : entry.getValue()) { if (occupancy.a().test(record)) ret.add(record); }
|
||||
@ -363,22 +363,22 @@ index 77c66bc9952542d2444b402896a3d9f622ca2ff9..b47abdabb592cfff6a4bf9ee638dd72f
|
||||
return predicate.test(entry.getKey());
|
||||
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..c7942b83b5c2d49e31c14eb51297baa365bb364f
|
||||
index 0000000000000000000000000000000000000000..871e305356103f87c2c1ad1487c804b60e13c076
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/net/yatopia/server/YatopiaChunkPos.java
|
||||
@@ -0,0 +1,54 @@
|
||||
+package net.yatopia.server;
|
||||
+
|
||||
+import java.util.LinkedList;
|
||||
+import java.util.List;
|
||||
+import java.util.function.Consumer;
|
||||
+import me.jellysquid.mods.lithium.common.util.Producer;
|
||||
+import net.minecraft.server.ChunkCoordIntPair;
|
||||
+import net.yatopia.server.list.GlueList;
|
||||
+
|
||||
+public class YatopiaChunkPos {
|
||||
+
|
||||
+ public static List<ChunkCoordIntPair> asList(ChunkCoordIntPair pos1, ChunkCoordIntPair pos2) {
|
||||
+ List<ChunkCoordIntPair> list = new LinkedList<>();
|
||||
+ List<ChunkCoordIntPair> list = new GlueList<>();
|
||||
+ Producer.fillList(getStreamProducer(pos1, pos2), list);
|
||||
+ return list;
|
||||
+ }
|
||||
@ -423,23 +423,23 @@ 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..d76e96eb055731338b670c6df2e3d9fcdc7e9a03
|
||||
index 0000000000000000000000000000000000000000..134c761c7897f37c20b5209866374dd79dc5b0e4
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/net/yatopia/server/YatopiaChunkSectionPos.java
|
||||
@@ -0,0 +1,32 @@
|
||||
+package net.yatopia.server;
|
||||
+
|
||||
+import java.util.LinkedList;
|
||||
+import java.util.List;
|
||||
+import java.util.function.Consumer;
|
||||
+import me.jellysquid.mods.lithium.common.util.Producer;
|
||||
+import net.minecraft.server.CursorPosition;
|
||||
+import net.minecraft.server.SectionPosition;
|
||||
+import net.yatopia.server.list.GlueList;
|
||||
+
|
||||
+public class YatopiaChunkSectionPos {
|
||||
+
|
||||
+ public static List<SectionPosition> getChunkSectionPosList(int i, int j, int k, int l, int i1, int j1) {
|
||||
+ List<SectionPosition> list = new LinkedList<>();
|
||||
+ List<SectionPosition> list = new GlueList<>();
|
||||
+ Producer.fillList(getChunkSectionPosProducer(i, j, k, l, i1, j1), list);
|
||||
+ return list;
|
||||
+ }
|
@ -25,7 +25,7 @@ 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 e6b5a21c523c598f53207d024322301fbae74825..160783a6660048b660e49382cd874ef89b47fb5c 100644
|
||||
index dbe6f7d555e8c851faba5cafee8831c516256c09..6374f013137fe2b244c68706f58e23ffeb2ea18b 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 {
|
||||
@ -53,7 +53,7 @@ index e6b5a21c523c598f53207d024322301fbae74825..160783a6660048b660e49382cd874ef8
|
||||
|
||||
+ // Yatopia start
|
||||
+ public static java.util.List<BlockPosition> bList(BlockPosition pos, BlockPosition pos1) {
|
||||
+ java.util.List<BlockPosition> ret = new java.util.ArrayList<>();
|
||||
+ java.util.List<BlockPosition> ret = new net.yatopia.server.list.GlueList<>();
|
||||
+ Iterable<BlockPosition> iterable = a(pos, pos1);
|
||||
+ net.yatopia.server.HoldingConsumer<BlockPosition> consumer = new net.yatopia.server.HoldingConsumer<>();
|
||||
+ java.util.Spliterator<BlockPosition> spliterator = iterable.spliterator();
|
||||
@ -138,7 +138,7 @@ index 24842902383820f3ec8dcd2ee57b3d4f2d2e952f..2481bfac2cc1224c32ca96519ceb38f0
|
||||
|
||||
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
|
||||
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 {
|
||||
@ -149,7 +149,7 @@ index b90c9990668f7956e8ef67413bcfc5d7d9616db1..cd4d53719cc179abb302a3bdd6ceae03
|
||||
+ 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<>();
|
||||
+ java.util.List<IBlockData> ret = new net.yatopia.server.list.GlueList<>();
|
||||
+ for (BlockPosition pos : posList) ret.add(getType(pos));
|
||||
+ return ret;
|
||||
+ }
|
@ -5,7 +5,7 @@ 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 e0cbcc0a15f8089c29957badc20b0a786831c64b..b90cb567f443eadc15270f8f2da30caaba8c00cb 100644
|
||||
index 06a51ca13d484dd319aa96364b2f1b533b184c36..70bfc97601059ab585f20e62163e59a8a31dc48e 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntitySlice.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntitySlice.java
|
||||
@@ -104,7 +104,7 @@ public class EntitySlice<T> extends AbstractCollection<T> implements me.jellysqu
|
@ -10,7 +10,7 @@ added.
|
||||
These changes aim to reduce that load whenever you are using the /whitelist command.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/CommandWhitelist.java b/src/main/java/net/minecraft/server/CommandWhitelist.java
|
||||
index 893d2c1c74ed28dcdb83b71762ccdcbfd50a8f9d..107091a4cae0e4eaba93f69ae91239ab891a90d9 100644
|
||||
index 893d2c1c74ed28dcdb83b71762ccdcbfd50a8f9d..f9e97d28ab182ff1b9e216b2c451642855d52738 100644
|
||||
--- a/src/main/java/net/minecraft/server/CommandWhitelist.java
|
||||
+++ b/src/main/java/net/minecraft/server/CommandWhitelist.java
|
||||
@@ -12,8 +12,8 @@ public class CommandWhitelist {
|
||||
@ -64,7 +64,7 @@ index 893d2c1c74ed28dcdb83b71762ccdcbfd50a8f9d..107091a4cae0e4eaba93f69ae91239ab
|
||||
return i;
|
||||
}
|
||||
+ */
|
||||
+ java.util.List<WhiteListEntry> toAdd = new java.util.ArrayList<>();
|
||||
+ java.util.List<WhiteListEntry> toAdd = new net.yatopia.server.list.GlueList<>();
|
||||
+ for (GameProfile profile : collection) {
|
||||
+ if (!whitelist.isWhitelisted(profile)) {
|
||||
+ toAdd.add(new WhiteListEntry(profile));
|
||||
@ -92,7 +92,7 @@ index 893d2c1c74ed28dcdb83b71762ccdcbfd50a8f9d..107091a4cae0e4eaba93f69ae91239ab
|
||||
return i;
|
||||
}
|
||||
+ */
|
||||
+ java.util.List<JsonListEntry<GameProfile>> toRemove = new java.util.ArrayList<>();
|
||||
+ java.util.List<JsonListEntry<GameProfile>> toRemove = new net.yatopia.server.list.GlueList<>();
|
||||
+ for (GameProfile profile : collection) {
|
||||
+ if (whitelist.isWhitelisted(profile)) {
|
||||
+ toRemove.add(new WhiteListEntry(profile));
|
@ -1,41 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: gegy1000 <gegy1000@gmail.com>
|
||||
Date: Mon, 28 Sep 2020 14:20:17 -0500
|
||||
Subject: [PATCH] tic-tacs Threading Fix
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/WeightedList.java b/src/main/java/net/minecraft/server/WeightedList.java
|
||||
index 5d9d58411f2fad9d5da703f964d269b4a7c2b205..b9c0037cdfe54fcd5ed6c887f9902be3a2deadba 100644
|
||||
--- a/src/main/java/net/minecraft/server/WeightedList.java
|
||||
+++ b/src/main/java/net/minecraft/server/WeightedList.java
|
||||
@@ -64,9 +64,30 @@ public class WeightedList<U> {
|
||||
return this.list.stream().map(WeightedList.a::a); // Paper - decompile conflict
|
||||
}
|
||||
|
||||
+ // Yatopia Start - Tic Tacs threading fix
|
||||
+ public U b(Random random) {
|
||||
+ WeightedList.a<U> selectedEntry = null;
|
||||
+ double selectedValue = 0.0;
|
||||
+
|
||||
+ for (WeightedList.a<U> entry : this.list) {
|
||||
+ double value = Math.pow(random.nextFloat(), 1.0F / entry.b);
|
||||
+ if (value > selectedValue) {
|
||||
+ selectedEntry = entry;
|
||||
+ selectedValue = value;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (selectedEntry == null) {
|
||||
+ throw new IllegalStateException("no entries in WeightedList");
|
||||
+ }
|
||||
+
|
||||
+ return selectedEntry.a();
|
||||
+ }
|
||||
+ /*
|
||||
public U b(Random random) {
|
||||
return this.a(random).c().findFirst().orElseThrow(RuntimeException::new);
|
||||
}
|
||||
+ */ //Yatopia End
|
||||
|
||||
public String toString() {
|
||||
return "WeightedList[" + this.list + "]"; // Paper - decompile conflict
|
79
patches/server/0058-tic-tacs-Threading-Fix.patch
Normal file
79
patches/server/0058-tic-tacs-Threading-Fix.patch
Normal file
@ -0,0 +1,79 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: gegy1000 <gegy1000@gmail.com>
|
||||
Date: Mon, 28 Sep 2020 14:20:17 -0500
|
||||
Subject: [PATCH] tic-tacs Threading Fix
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/WeightedList.java b/src/main/java/net/minecraft/server/WeightedList.java
|
||||
index 5d9d58411f2fad9d5da703f964d269b4a7c2b205..a7575ec7c1324c30f6865b78386b880df5de2fe8 100644
|
||||
--- a/src/main/java/net/minecraft/server/WeightedList.java
|
||||
+++ b/src/main/java/net/minecraft/server/WeightedList.java
|
||||
@@ -21,7 +21,7 @@ public class WeightedList<U> {
|
||||
// Paper start - add useClone option
|
||||
public WeightedList() { this(true); }
|
||||
public WeightedList(boolean isUnsafe) {
|
||||
- this(Lists.newArrayList(), isUnsafe);
|
||||
+ this(new net.yatopia.server.list.GlueList<>(), isUnsafe);
|
||||
}
|
||||
|
||||
private WeightedList(List<WeightedList.a<U>> list) { this(list, true); }
|
||||
@@ -29,7 +29,14 @@ public class WeightedList<U> {
|
||||
this.isUnsafe = isUnsafe;
|
||||
// Paper end
|
||||
this.b = new Random();
|
||||
- this.list = Lists.newArrayList(list); // Paper - decompile conflict
|
||||
+ // Yatopia start
|
||||
+ if (!(list instanceof net.yatopia.server.list.GlueList)) {
|
||||
+ this.list = new net.yatopia.server.list.GlueList<>(list);
|
||||
+ } else {
|
||||
+ this.list = list;
|
||||
+ }
|
||||
+ //this.list = Lists.newArrayList(list); // Paper - decompile conflict
|
||||
+ // Yatopia end
|
||||
}
|
||||
|
||||
public static <U> Codec<WeightedList<U>> a(Codec<U> codec) {
|
||||
@@ -49,7 +56,7 @@ public class WeightedList<U> {
|
||||
|
||||
public WeightedList<U> a(Random random) {
|
||||
// Paper start - make concurrent safe, work off a clone of the list
|
||||
- List<WeightedList.a<U>> list = isUnsafe ? new java.util.ArrayList<WeightedList.a<U>>(this.list) : this.list;
|
||||
+ List<WeightedList.a<U>> list = isUnsafe ? new net.yatopia.server.list.GlueList<>(this.list) : this.list; // Yatopia
|
||||
list.forEach((weightedlist_a) -> weightedlist_a.a(random.nextFloat()));
|
||||
list.sort(Comparator.comparingDouble(a::c));
|
||||
return isUnsafe ? new WeightedList<>(list, isUnsafe) : this;
|
||||
@@ -65,7 +72,25 @@ public class WeightedList<U> {
|
||||
}
|
||||
|
||||
public U b(Random random) {
|
||||
- return this.a(random).c().findFirst().orElseThrow(RuntimeException::new);
|
||||
+ // Yatopia start - replace this
|
||||
+ //return this.a(random).c().findFirst().orElseThrow(RuntimeException::new);
|
||||
+ WeightedList.a<U> selectedEntry = null;
|
||||
+ double selectedValue = 0.0;
|
||||
+
|
||||
+ for (WeightedList.a<U> entry : this.list) {
|
||||
+ double value = Math.pow(random.nextFloat(), 1.0F / entry.b);
|
||||
+ if (value > selectedValue) {
|
||||
+ selectedEntry = entry;
|
||||
+ selectedValue = value;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (selectedEntry == null) {
|
||||
+ throw new IllegalStateException("no entries in WeightedList");
|
||||
+ }
|
||||
+
|
||||
+ return selectedEntry.getElement();
|
||||
+ // Yatopia end
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
@@ -91,6 +116,7 @@ public class WeightedList<U> {
|
||||
this.c = -Math.pow((double) f, (double) (1.0F / (float) this.b));
|
||||
}
|
||||
|
||||
+ public final T getElement() { return a; } // Yatopia - OBFHELPER
|
||||
public T a() {
|
||||
return this.a;
|
||||
}
|
@ -10,7 +10,7 @@ GlueList was also used as a replacement for ArrayList as it is substantially fas
|
||||
These changes knock off an extra ~10ms of tick duration with a sample of ~7,700 running furnaces on a server.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/CraftingManager.java b/src/main/java/net/minecraft/server/CraftingManager.java
|
||||
index a707c85f2f6b0177781755decc8bc2e0d1eacd4a..bd4bc17245d32772aef60e53eae4a572ffc6d1c2 100644
|
||||
index 09b8065156a66a72ad5d09c6e8be0551970ffb56..bd4bc17245d32772aef60e53eae4a572ffc6d1c2 100644
|
||||
--- a/src/main/java/net/minecraft/server/CraftingManager.java
|
||||
+++ b/src/main/java/net/minecraft/server/CraftingManager.java
|
||||
@@ -25,6 +25,10 @@ public class CraftingManager extends ResourceDataJson {
|
||||
@ -24,7 +24,7 @@ index a707c85f2f6b0177781755decc8bc2e0d1eacd4a..bd4bc17245d32772aef60e53eae4a572
|
||||
|
||||
public CraftingManager() {
|
||||
super(CraftingManager.a, "recipes");
|
||||
@@ -108,19 +112,25 @@ public class CraftingManager extends ResourceDataJson {
|
||||
@@ -108,12 +112,18 @@ public class CraftingManager extends ResourceDataJson {
|
||||
}
|
||||
|
||||
public <C extends IInventory, T extends IRecipe<C>> List<T> a(Recipes<T> recipes) {
|
||||
@ -43,14 +43,6 @@ index a707c85f2f6b0177781755decc8bc2e0d1eacd4a..bd4bc17245d32772aef60e53eae4a572
|
||||
}
|
||||
|
||||
public <C extends IInventory, T extends IRecipe<C>> List<T> b(Recipes<T> recipes, C c0, World world) {
|
||||
// Yatopia start - WHY?! WHO DID THIS TO YOU!?!
|
||||
Collection<IRecipe<C>> recipeCollection = this.b(recipes).values();
|
||||
if (recipeCollection.isEmpty()) return java.util.Collections.emptyList();
|
||||
- List<T> ret = new java.util.ArrayList<>();
|
||||
+ List<T> ret = new net.yatopia.server.list.GlueList<>();
|
||||
for (IRecipe<C> iRecipe : recipeCollection) recipes.a(iRecipe, world, c0).ifPresent(ret::add);
|
||||
ret.sort(Comparator.comparing((iRecipe) -> iRecipe.getResult().getTranslationKey()));
|
||||
return ret;
|
||||
@@ -134,7 +144,7 @@ public class CraftingManager extends ResourceDataJson {
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user