Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 16:12:42 +01:00
Temp arrays are evil, (memory optimisation)
Dieser Commit ist enthalten in:
Ursprung
a92a7d6e02
Commit
012eec47b5
@ -60,11 +60,11 @@ public class NetUtil {
|
|||||||
chunks[ind] = new Chunk(sky || hasSkyLight);
|
chunks[ind] = new Chunk(sky || hasSkyLight);
|
||||||
|
|
||||||
buf.position(pos / 2);
|
buf.position(pos / 2);
|
||||||
short[] tempData = new short[4096];
|
int buffPos = buf.position();
|
||||||
buf.get(tempData, 0, tempData.length);
|
|
||||||
// convert short array to new one
|
// convert short array to new one
|
||||||
int index = 0;
|
|
||||||
for(short ss:tempData){
|
for (int index = 0; index < 4096; index++) {
|
||||||
|
short ss = buf.get(buffPos + index);
|
||||||
// s is 16 bits, 12 bits id and 4 bits data
|
// s is 16 bits, 12 bits id and 4 bits data
|
||||||
int data = ss & 0xF;
|
int data = ss & 0xF;
|
||||||
int id = (ss >> 4) << 4 | data;
|
int id = (ss >> 4) << 4 | data;
|
||||||
@ -72,9 +72,8 @@ public class NetUtil {
|
|||||||
int newCombined = id; // test
|
int newCombined = id; // test
|
||||||
|
|
||||||
chunks[ind].getBlocks().set(index, newCombined);
|
chunks[ind].getBlocks().set(index, newCombined);
|
||||||
index++;
|
|
||||||
}
|
}
|
||||||
pos += tempData.length * 2;
|
pos += 4096 * 2;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren