Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 00:22:51 +01:00
Memory efficiency
Dieser Commit ist enthalten in:
Ursprung
459de30e9a
Commit
dc90652853
@ -135,7 +135,12 @@ public class ChunkSection1_13 implements ChunkSection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read blocks
|
// Read blocks
|
||||||
Long[] blockData = Type.LONG_ARRAY.read(input);
|
// Long[] blockData = Type.LONG_ARRAY.read(input);
|
||||||
|
long[] blockData = new long[Type.VAR_INT.read(input)];
|
||||||
|
for (int i = 0; i < blockData.length; i++) {
|
||||||
|
blockData[i] = input.readLong();
|
||||||
|
}
|
||||||
|
|
||||||
if (blockData.length > 0) {
|
if (blockData.length > 0) {
|
||||||
for (int i = 0; i < blocks.length; i++) {
|
for (int i = 0; i < blocks.length; i++) {
|
||||||
int bitIndex = i * bitsPerBlock;
|
int bitIndex = i * bitsPerBlock;
|
||||||
@ -222,7 +227,7 @@ public class ChunkSection1_13 implements ChunkSection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (long l : data) {
|
for (long l : data) {
|
||||||
Type.LONG.write(output, l);
|
output.writeLong(l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,7 +270,7 @@ public class ChunkSection1_13 implements ChunkSection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (long l : data) {
|
for (long l : data) {
|
||||||
Type.LONG.write(output, l);
|
output.writeLong(l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@ import com.google.common.collect.HashBiMap;
|
|||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
import io.netty.util.collection.IntObjectHashMap;
|
||||||
|
import io.netty.util.collection.IntObjectMap;
|
||||||
import us.myles.ViaVersion.util.GsonUtil;
|
import us.myles.ViaVersion.util.GsonUtil;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -14,7 +16,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class MappingData {
|
public class MappingData {
|
||||||
public static Map<Integer, Integer> oldToNewBlocks = new HashMap<>();
|
public static IntObjectMap<Integer> oldToNewBlocks = new IntObjectHashMap<>();
|
||||||
public static BiMap<Integer, Integer> oldToNewItems = HashBiMap.create();
|
public static BiMap<Integer, Integer> oldToNewItems = HashBiMap.create();
|
||||||
public static Map<String, Integer[]> blockTags = new HashMap<>();
|
public static Map<String, Integer[]> blockTags = new HashMap<>();
|
||||||
public static Map<String, Integer[]> itemTags = new HashMap<>();
|
public static Map<String, Integer[]> itemTags = new HashMap<>();
|
||||||
@ -52,6 +54,17 @@ public class MappingData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void mapIdentifiers(IntObjectMap<Integer> output, JsonObject oldIdentifiers, JsonObject newIdentifiers) {
|
||||||
|
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
|
||||||
|
Map.Entry<String, JsonElement> value = findValue(newIdentifiers, entry.getValue().getAsString());
|
||||||
|
if (value == null) {
|
||||||
|
System.out.println("No key for " + entry.getValue() + " :( ");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
output.put(Integer.parseInt(entry.getKey()), Integer.parseInt(value.getKey()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Map.Entry<String, JsonElement> findValue(JsonObject object, String needle) {
|
private static Map.Entry<String, JsonElement> findValue(JsonObject object, String needle) {
|
||||||
for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
|
for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
|
||||||
String value = entry.getValue().getAsString();
|
String value = entry.getValue().getAsString();
|
||||||
|
@ -153,7 +153,11 @@ public class ChunkSection1_9_3_4 implements ChunkSection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read blocks
|
// Read blocks
|
||||||
Long[] blockData = Type.LONG_ARRAY.read(input);
|
//Long[] blockData = Type.LONG_ARRAY.read(input);
|
||||||
|
long[] blockData = new long[Type.VAR_INT.read(input)];
|
||||||
|
for (int i = 0; i < blockData.length; i++) {
|
||||||
|
blockData[i] = input.readLong();
|
||||||
|
}
|
||||||
if (blockData.length > 0) {
|
if (blockData.length > 0) {
|
||||||
for (int i = 0; i < blocks.length; i++) {
|
for (int i = 0; i < blocks.length; i++) {
|
||||||
int bitIndex = i * bitsPerBlock;
|
int bitIndex = i * bitsPerBlock;
|
||||||
@ -245,7 +249,7 @@ public class ChunkSection1_9_3_4 implements ChunkSection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (long l : data) {
|
for (long l : data) {
|
||||||
Type.LONG.write(output, l);
|
output.writeLong(l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,7 +292,7 @@ public class ChunkSection1_9_3_4 implements ChunkSection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (long l : data) {
|
for (long l : data) {
|
||||||
Type.LONG.write(output, l);
|
output.writeLong(l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +145,11 @@ public class ChunkSection1_9_1_2 implements ChunkSection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read blocks
|
// Read blocks
|
||||||
Long[] blockData = Type.LONG_ARRAY.read(input);
|
// Long[] blockData = Type.LONG_ARRAY.read(input);
|
||||||
|
long[] blockData = new long[Type.VAR_INT.read(input)];
|
||||||
|
for (int i = 0; i < blockData.length; i++) {
|
||||||
|
blockData[i] = input.readLong();
|
||||||
|
}
|
||||||
if (blockData.length > 0) {
|
if (blockData.length > 0) {
|
||||||
for (int i = 0; i < blocks.length; i++) {
|
for (int i = 0; i < blocks.length; i++) {
|
||||||
int bitIndex = i * bitsPerBlock;
|
int bitIndex = i * bitsPerBlock;
|
||||||
@ -237,7 +241,7 @@ public class ChunkSection1_9_1_2 implements ChunkSection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (long l : data) {
|
for (long l : data) {
|
||||||
Type.LONG.write(output, l);
|
output.writeLong(l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,7 +284,7 @@ public class ChunkSection1_9_1_2 implements ChunkSection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (long l : data) {
|
for (long l : data) {
|
||||||
Type.LONG.write(output, l);
|
output.writeLong(l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ public class ChunkSection1_9to1_8 implements ChunkSection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (long l : data) {
|
for (long l : data) {
|
||||||
Type.LONG.write(output, l);
|
output.writeLong(l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ public class ChunkSection1_9to1_8 implements ChunkSection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (long l : data) {
|
for (long l : data) {
|
||||||
Type.LONG.write(output, l);
|
output.writeLong(l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
pom.xml
2
pom.xml
@ -98,7 +98,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.netty</groupId>
|
<groupId>io.netty</groupId>
|
||||||
<artifactId>netty-all</artifactId>
|
<artifactId>netty-all</artifactId>
|
||||||
<version>4.0.20.Final</version>
|
<version>4.0.23.Final</version> <!-- Let's break 1.8 -->
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren