mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-12-25 02:27:39 +01:00
Compatibility fixes (#363)
* Retain BiomeStorage vanilla compatibility * remove networking patches Co-authored-by: Simon Gardling <titaniumtown@gmail.com>
This commit is contained in:
parent
d059af01b6
commit
49133cb643
@ -240,7 +240,6 @@ # Patches
|
||||
| server | Multi-Threaded Server Ticking Vanilla | Spottedleaf | |
|
||||
| server | Multi-Threaded ticking CraftBukkit | Spottedleaf | |
|
||||
| server | Name craft scheduler threads according to the plugin using | Spottedleaf | |
|
||||
| server | New Network System | Hugo Planque | Ivan Pekov |
|
||||
| server | Nuke streams off BlockPosition | Ivan Pekov | |
|
||||
| server | Nuke streams off SectionPosition | Ivan Pekov | |
|
||||
| server | Optimise EntityInsentient#checkDespawn | Spottedleaf | |
|
||||
@ -290,7 +289,6 @@ # Patches
|
||||
| server | Players should not cram to death | William Blake Galbreath | |
|
||||
| server | Populator seed controls | Spottedleaf | |
|
||||
| server | Port hydrogen | JellySquid | |
|
||||
| server | Port krypton | Andrew Steinborn | Hugo Planque |
|
||||
| server | Prevent light queue overfill when no players are online | Spottedleaf | |
|
||||
| server | Prevent long map entry creation in light engine | Spottedleaf | |
|
||||
| server | Prevent unload() calls removing tickets for sync loads | Spottedleaf | |
|
||||
|
@ -333,177 +333,6 @@ index 0000000000000000000000000000000000000000..a5314a0396f4a8f373d855e873820ddd
|
||||
+ return this.indices.addOrGet(ints);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/BiomeStorage.java b/src/main/java/net/minecraft/server/BiomeStorage.java
|
||||
index b7f5c932197529c0ea045cfe696fd5da1ccc7202..af6245ba0c6b1389703722596ab7aa50deaf9e9f 100644
|
||||
--- a/src/main/java/net/minecraft/server/BiomeStorage.java
|
||||
+++ b/src/main/java/net/minecraft/server/BiomeStorage.java
|
||||
@@ -1,23 +1,32 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import it.unimi.dsi.fastutil.objects.Reference2ShortMap;
|
||||
+import it.unimi.dsi.fastutil.objects.Reference2ShortOpenHashMap;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class BiomeStorage implements BiomeManager.Provider {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
- private static final int e = (int) Math.round(Math.log(16.0D) / Math.log(2.0D)) - 2;
|
||||
+ private static final int e = (int) Math.round(Math.log(16.0D) / Math.log(2.0D)) - 2; public static final int HORIZONTAL_SECTION_COUNT = e; // Yatopia - OBFHELPER
|
||||
private static final int f = (int) Math.round(Math.log(256.0D) / Math.log(2.0D)) - 2;
|
||||
public static final int a = 1 << BiomeStorage.e + BiomeStorage.e + BiomeStorage.f;
|
||||
- public static final int b = (1 << BiomeStorage.e) - 1;
|
||||
- public static final int c = (1 << BiomeStorage.f) - 1;
|
||||
+ public static final int b = (1 << BiomeStorage.e) - 1; public static final int HORIZONTAL_BIT_MASK = b; // Yatopia - OBFHELPER
|
||||
+ public static final int c = (1 << BiomeStorage.f) - 1; public static final int VERTICAL_BIT_MASK = c; // Yatopia - OBFHELPER
|
||||
public final Registry<BiomeBase> registry;
|
||||
- private final BiomeBase[] h;
|
||||
+ private BiomeBase[] h; private BiomeBase[] getData() { return h; } // Yatopia - OBFHELPER , remove final
|
||||
+
|
||||
+ // Yatopia start - Port hydrogen
|
||||
+ private BiomeBase[] palette;
|
||||
+ private DataBits intArray;
|
||||
+ // Yatopia end
|
||||
|
||||
public BiomeStorage(Registry<BiomeBase> registry, BiomeBase[] abiomebase) {
|
||||
this.registry = registry;
|
||||
this.h = abiomebase;
|
||||
+ this.createCompact(); // Yatopia - Port hydrogen
|
||||
}
|
||||
|
||||
private BiomeStorage(Registry<BiomeBase> registry) {
|
||||
@@ -37,6 +46,7 @@ public class BiomeStorage implements BiomeManager.Provider {
|
||||
this.h[k] = worldchunkmanager.getBiome(i + l, i1, j + j1);
|
||||
}
|
||||
|
||||
+ this.createCompact(); // Yatopia - Port hydrogen
|
||||
}
|
||||
|
||||
public BiomeStorage(Registry<BiomeBase> registry, ChunkCoordIntPair chunkcoordintpair, WorldChunkManager worldchunkmanager, @Nullable int[] aint) {
|
||||
@@ -67,9 +77,11 @@ public class BiomeStorage implements BiomeManager.Provider {
|
||||
}
|
||||
}
|
||||
|
||||
+ this.createCompact(); // Yatopia - Port hydrogen
|
||||
}
|
||||
|
||||
public int[] a() {
|
||||
+ /* // Yatopia start - Port hydrogen
|
||||
int[] aint = new int[this.h.length];
|
||||
|
||||
for (int i = 0; i < this.h.length; ++i) {
|
||||
@@ -77,15 +89,33 @@ public class BiomeStorage implements BiomeManager.Provider {
|
||||
}
|
||||
|
||||
return aint;
|
||||
+ */
|
||||
+ int size = this.intArray.getSize();
|
||||
+ int[] array = new int[size];
|
||||
+
|
||||
+ for (int i = 0; i < size; ++i) {
|
||||
+ array[i] = this.registry.a(this.palette[this.intArray.get(i)]);
|
||||
+ }
|
||||
+
|
||||
+ return array;
|
||||
+ // Yatopia end
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeBase getBiome(int i, int j, int k) {
|
||||
+ /* // Yatopia start - Port hydrogen
|
||||
int l = i & BiomeStorage.b;
|
||||
int i1 = MathHelper.clamp(j, 0, BiomeStorage.c);
|
||||
int j1 = k & BiomeStorage.b;
|
||||
|
||||
return this.h[i1 << BiomeStorage.e + BiomeStorage.e | j1 << BiomeStorage.e | l];
|
||||
+ */
|
||||
+ int x = i & HORIZONTAL_BIT_MASK;
|
||||
+ int y = MathHelper.clamp(j, 0, VERTICAL_BIT_MASK);
|
||||
+ int z = k & HORIZONTAL_BIT_MASK;
|
||||
+
|
||||
+ return this.palette[this.intArray.get(y << HORIZONTAL_SECTION_COUNT + HORIZONTAL_SECTION_COUNT | z << HORIZONTAL_SECTION_COUNT | x)];
|
||||
+ // Yatopia end
|
||||
}
|
||||
|
||||
// CraftBukkit start
|
||||
@@ -94,7 +124,74 @@ public class BiomeStorage implements BiomeManager.Provider {
|
||||
int i1 = MathHelper.clamp(j, 0, BiomeStorage.c);
|
||||
int j1 = k & BiomeStorage.b;
|
||||
|
||||
- this.h[i1 << BiomeStorage.e + BiomeStorage.e | j1 << BiomeStorage.e | l] = biome;
|
||||
+ this.palette[this.intArray.get(l << HORIZONTAL_SECTION_COUNT + HORIZONTAL_SECTION_COUNT | i1 << HORIZONTAL_SECTION_COUNT | j1)] = biome; // Yatopia - Port Hydrogen
|
||||
}
|
||||
// CraftBukkit end
|
||||
+
|
||||
+
|
||||
+ // Yatopia Start - Port Hydrogen
|
||||
+ private void createCompact() {
|
||||
+ if (this.intArray != null || this.getData()[0] == null) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ Reference2ShortOpenHashMap<BiomeBase> paletteTable = this.createPalette();
|
||||
+ BiomeBase[] paletteIndexed = new BiomeBase[paletteTable.size()];
|
||||
+
|
||||
+ for (Reference2ShortMap.Entry<BiomeBase> entry : paletteTable.reference2ShortEntrySet()) {
|
||||
+ paletteIndexed[entry.getShortValue()] = entry.getKey();
|
||||
+ }
|
||||
+
|
||||
+ int packedIntSize = Math.max(2, MathHelper.e(paletteTable.size()));
|
||||
+ DataBits integerArray = new DataBits(packedIntSize, a);
|
||||
+
|
||||
+ BiomeBase prevBiome = null;
|
||||
+ short prevId = -1;
|
||||
+
|
||||
+ for (int i = 0; i < this.getData().length; i++) {
|
||||
+ BiomeBase biome = this.getData()[i];
|
||||
+ short id;
|
||||
+
|
||||
+ if (prevBiome == biome) {
|
||||
+ id = prevId;
|
||||
+ } else {
|
||||
+ id = paletteTable.getShort(biome);
|
||||
+
|
||||
+ if (id < 0) {
|
||||
+ throw new IllegalStateException("Palette is missing entry: " + biome);
|
||||
+ }
|
||||
+
|
||||
+ prevId = id;
|
||||
+ prevBiome = biome;
|
||||
+ }
|
||||
+
|
||||
+ integerArray.set(i, id);
|
||||
+ }
|
||||
+
|
||||
+ this.palette = paletteIndexed;
|
||||
+ this.intArray = integerArray;
|
||||
+ this.h = null;
|
||||
+ }
|
||||
+
|
||||
+ private Reference2ShortOpenHashMap<BiomeBase> createPalette() {
|
||||
+ Reference2ShortOpenHashMap<BiomeBase> map = new Reference2ShortOpenHashMap<>();
|
||||
+ map.defaultReturnValue(Short.MIN_VALUE);
|
||||
+
|
||||
+ BiomeBase prevObj = null;
|
||||
+ short id = 0;
|
||||
+
|
||||
+ for (BiomeBase obj : this.getData()) {
|
||||
+ if (obj == prevObj) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ if (map.getShort(obj) < 0) {
|
||||
+ map.put(obj, id++);
|
||||
+ }
|
||||
+
|
||||
+ prevObj = obj;
|
||||
+ }
|
||||
+
|
||||
+ return map;
|
||||
+ } // Yatopia end
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index 8b7fd21e6b366196fbc9cd44a340335c4cf9205f..8b8ecc2d8925b3c209d99e101f6e478b08d86db9 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
Loading…
Reference in New Issue
Block a user