MapImage class
Пакет: com.hypixel.hytale.protocol.packets.worldmap
Файл: com/hypixel/hytale/protocol/packets/worldmap/MapImage.java
Поля (44)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
int |
NULLABLE_BIT_FIELD_SIZE |
|
int |
var1 |
|
MapImage |
var1 |
|
int |
var1 |
|
|
var1 |
|
|
var1 |
|
|
var1 |
|
|
var1 |
|
int |
var10 |
|
int |
var11 |
|
byte[] |
var13 |
|
|
var13 |
|
int |
var14 |
|
MapImage |
var16 |
|
int |
var17 |
|
long |
var2 |
|
int |
var2 |
|
int |
var2 |
|
byte |
var2 |
|
byte |
var2 |
|
long |
var3 |
|
long |
var3 |
|
int |
var3 |
|
byte |
var3 |
|
|
var3 |
|
|
var3 |
|
int |
var4 |
|
int |
var4 |
|
|
var4 |
|
|
var4 |
|
int |
var4 |
|
int |
var5 |
|
int |
var5 |
|
int |
var5 |
|
int[] |
var5 |
|
|
var5 |
|
int |
var6 |
|
int |
var6 |
|
int |
var6 |
|
int[] |
var7 |
|
byte[] |
var7 |
|
long |
var7 |
|
long |
var8 |
|
int |
var9 |
Методы (49)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
public |
MapImage |
cloneMapImage clone() |
public |
int |
computeSizeint computeSize() |
static |
byte |
getBitsPerIndexbyte getBitsPerIndex(MemorySegment var0) |
static |
byte |
getBitsPerIndexbyte getBitsPerIndex(MemorySegment var0, int var1) |
abstract |
return |
getBitsPerIndexreturn getBitsPerIndex(var0, 0) |
static |
int |
getHeightint getHeight(MemorySegment var0) |
static |
int |
getHeightint getHeight(MemorySegment var0, int var1) |
abstract |
return |
getHeightreturn getHeight(var0, 0) |
abstract |
return |
getPackedIndicesreturn getPackedIndices(var0, 0) |
abstract |
return |
getPalettereturn getPalette(var0, 0) |
static |
int |
getValidatedOffsetint getValidatedOffset(MemorySegment var0, int var1, int var2, int var3, String var4) |
static |
int |
getWidthint getWidth(MemorySegment var0) |
static |
int |
getWidthint getWidth(MemorySegment var0, int var1) |
abstract |
return |
getWidthreturn getWidth(var0, 0) |
static |
boolean |
hasPackedIndicesboolean hasPackedIndices(MemorySegment var0, int var1) |
static |
boolean |
hasPaletteboolean hasPalette(MemorySegment var0, int var1) |
|
|
if if(var1 < 0) |
|
|
if if(var3 == -1L) |
|
|
if if(var5 > 4096000) |
|
|
if if(var3 == -1L) |
|
|
if if(var5 > 4096000) |
|
|
if if(var4 != var2) |
|
|
if if(var7 == -1L) |
|
|
if if(var9 > 4096000) |
|
|
if if(var8 == -1L) |
|
|
if if(var17 > 4096000) |
|
|
if if(var2 != null) |
|
|
if if(this.palette != null) |
|
|
if if(this.packedIndices != null) |
|
|
if if(this.palette != null) |
|
|
if if(this.palette.length > 4096000) |
|
|
if if(this.packedIndices != null) |
|
|
if if(this.packedIndices.length > 4096000) |
|
|
if if(this.palette != null) |
|
|
if if(this.packedIndices != null) |
|
|
if if(this == var1) |
static |
void |
requireBoundsvoid requireBounds(MemorySegment var0, int var1) |
abstract |
|
requireBounds requireBounds(var0, var1) |
static |
void |
requireSlotvoid requireSlot(MemorySegment var0, int var1, int var2, String var3) |
abstract |
|
requireSlot requireSlot(var0, var1 + 10, var4, "Palette") |
abstract |
|
requireSlot requireSlot(var0, var1 + 10, -1, "Palette") |
abstract |
|
requireSlot requireSlot(var0, var1 + 14, var4, "PackedIndices") |
abstract |
|
requireSlot requireSlot(var0, var1 + 14, -1, "PackedIndices") |
public |
int |
serializeint serialize(@Nonnull MemorySegment var1, int var2) |
static |
MapImage |
toObjectMapImage toObject(MemorySegment var0) |
static |
MapImage |
toObjectMapImage toObject(MemorySegment var0, int var1) |
static |
MapImage |
toObjectMapImage toObject(MemorySegment var0, int var1, @Nullable ReadCursor var2) |
abstract |
return |
toObjectreturn toObject(var0, 0, null) |
abstract |
return |
toObjectreturn toObject(var0, var1, null) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.protocol.packets.worldmap;
class="kw">import com.hypixel.hytale.protocol.io.PacketIO;
class="kw">import com.hypixel.hytale.protocol.io.ProtocolException;
class="kw">import com.hypixel.hytale.protocol.io.ReadCursor;
class="kw">import com.hypixel.hytale.protocol.io.VarInt;
class="kw">import java.lang.foreign.MemorySegment;
class="kw">import java.util.Arrays;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">public class MapImage {
class="kw">public class="kw">static class="kw">final int NULLABLE_BIT_FIELD_SIZE = 1;
class="kw">public class="kw">static class="kw">final int FIXED_BLOCK_SIZE = 10;
class="kw">public class="kw">static class="kw">final int VARIABLE_FIELD_COUNT = 2;
class="kw">public class="kw">static class="kw">final int VARIABLE_BLOCK_START = 18;
class="kw">public class="kw">static class="kw">final int MAX_SIZE = 20480028;
class="kw">public int width;
class="kw">public int height;
@Nullable
class="kw">public int[] palette;
class="kw">public byte bitsPerIndex;
@Nullable
class="kw">public byte[] packedIndices;
class="kw">public MapImage() {
}
class="kw">public MapImage(int var1, int var2, @Nullable int[] var3, byte var4, @Nullable byte[] var5) {
this.width = var1;
this.height = var2;
this.palette = var3;
this.bitsPerIndex = var4;
this.packedIndices = var5;
}
class="kw">public MapImage(@Nonnull MapImage var1) {
this.width = var1.width;
this.height = var1.height;
this.palette = var1.palette;
this.bitsPerIndex = var1.bitsPerIndex;
this.packedIndices = var1.packedIndices;
}
class="kw">public class="kw">static void requireBounds(MemorySegment var0, int var1) {
if (var1 < 0) {
throw ProtocolException.invalidOffset("MapImage", var1, (int)var0.byteSize());
}
long var2 = var1 + 18L;
if (var2 > var0.byteSize()) {
throw ProtocolException.bufferTooSmall("MapImage", (int)Math.min(var2, 2147483647L), (int)var0.byteSize());
}
}
class="kw">public class="kw">static int getWidth(MemorySegment var0) {
class="kw">return getWidth(var0, 0);
}
class="kw">public class="kw">static int getWidth(MemorySegment var0, int var1) {
class="kw">return var0.get(PacketIO.PROTO_INT, var1 + 1);
}
class="kw">public class="kw">static int getHeight(MemorySegment var0) {
class="kw">return getHeight(var0, 0);
}
class="kw">public class="kw">static int getHeight(MemorySegment var0, int var1) {
class="kw">return var0.get(PacketIO.PROTO_INT, var1 + 5);
}
@Nullable
class="kw">public class="kw">static int[] getPalette(MemorySegment var0) {
class="kw">return getPalette(var0, 0);
}
@Nullable
class="kw">public class="kw">static int[] getPalette(MemorySegment var0, int var1) {
if (!hasPalette(var0, var1)) {
class="kw">return null;
}
int var2 = var1 + getValidatedOffset(var0, var1, 10, 18, "Palette");
long var3 = VarInt.getWithLength(var0, var2);
if (var3 == -1L) {
throw ProtocolException.invalidVarInt("Palette");
}
int var5 = (int)var3;
if (var5 > 4096000) {
throw ProtocolException.arrayTooLong("Palette", var5, 4096000);
}
int var6 = (int)(var3 >>> 32);
if (var2 + var6 + var5 * 4L > var0.byteSize()) {
throw ProtocolException.bufferTooSmall("Palette", (int)Math.min(var2 + var6 + var5 * 4L, 2147483647L), (int)var0.byteSize());
}
var2 += var6;
int[] var7 = new int[var5];
MemorySegment.copy(var0, PacketIO.PROTO_INT, var2, var7, 0, var5);
class="kw">return var7;
}
class="kw">public class="kw">static byte getBitsPerIndex(MemorySegment var0) {
class="kw">return getBitsPerIndex(var0, 0);
}
class="kw">public class="kw">static byte getBitsPerIndex(MemorySegment var0, int var1) {
class="kw">return var0.get(PacketIO.PROTO_BYTE, var1 + 9);
}
@Nullable
class="kw">public class="kw">static byte[] getPackedIndices(MemorySegment var0) {
class="kw">return getPackedIndices(var0, 0);
}
@Nullable
class="kw">public class="kw">static byte[] getPackedIndices(MemorySegment var0, int var1) {
if (!hasPackedIndices(var0, var1)) {
class="kw">return null;
}
int var2 = var1 + getValidatedOffset(var0, var1, 14, 18, "PackedIndices");
long var3 = VarInt.getWithLength(var0, var2);
if (var3 == -1L) {
throw ProtocolException.invalidVarInt("PackedIndices");
}
int var5 = (int)var3;
if (var5 > 4096000) {
throw ProtocolException.arrayTooLong("PackedIndices", var5, 4096000);
}
int var6 = (int)(var3 >>> 32);
if (var2 + var6 + var5 > var0.byteSize()) {
throw ProtocolException.bufferTooSmall("PackedIndices", Math.min(var2 + var6 + var5, Integer.MAX_VALUE), (int)var0.byteSize());
}
var2 += var6;
byte[] var7 = new byte[var5];
MemorySegment.copy(var0, PacketIO.PROTO_BYTE, var2, var7, 0, var5);
class="kw">return var7;
}
class="kw">public class="kw">static boolean hasPalette(MemorySegment var0, int var1) {
byte var2 = var0.get(PacketIO.PROTO_BYTE, var1 + 0);
class="kw">return (var2 & 1) != 0;
}
class="kw">public class="kw">static boolean hasPackedIndices(MemorySegment var0, int var1) {
byte var2 = var0.get(PacketIO.PROTO_BYTE, var1 + 0);
class="kw">return (var2 & 2) != 0;
}
class="kw">private class="kw">static int getValidatedOffset(MemorySegment var0, int var1, int var2, int var3, String var4) {
int var5 = var0.get(PacketIO.PROTO_INT, var1 + var2);
if (var5 >= 0 && var5 <= var0.byteSize() - var1 - var3) {
class="kw">return var3 + var5;
} else {
throw ProtocolException.invalidOffset(var4, var5, (int)var0.byteSize());
}
}
class="kw">private class="kw">static void requireSlot(MemorySegment var0, int var1, int var2, String var3) {
int var4 = var0.get(PacketIO.PROTO_INT, var1);
if (var4 != var2) {
throw ProtocolException.nonCanonicalLayout(var3, var4, var2);
}
}
class="kw">public class="kw">static MapImage toObject(MemorySegment var0) {
class="kw">return toObject(var0, 0, null);
}
class="kw">public class="kw">static MapImage toObject(MemorySegment var0, int var1) {
class="kw">return toObject(var0, var1, null);
}
class="kw">public class="kw">static MapImage toObject(MemorySegment var0, int var1, @Nullable ReadCursor var2) {
requireBounds(var0, var1);
int var3 = var1 + 18;
int var4 = 0;
int[] var5 = null;
if (hasPalette(var0, var1)) {
requireSlot(var0, var1 + 10, var4, "Palette");
int var6 = var3 + var4;
long var7 = VarInt.getWithLength(var0, var6);
if (var7 == -1L) {
throw ProtocolException.invalidVarInt("Palette");
}
int var9 = (int)var7;
if (var9 > 4096000) {
throw ProtocolException.arrayTooLong("Palette", var9, 4096000);
}
int var10 = (int)(var7 >>> 32);
if (var6 + var10 + var9 * 4L > var0.byteSize()) {
throw ProtocolException.bufferTooSmall("Palette", (int)Math.min(var6 + var10 + var9 * 4L, 2147483647L), (int)var0.byteSize());
}
var6 += var10;
var5 = new int[var9];
MemorySegment.copy(var0, PacketIO.PROTO_INT, var6, var5, 0, var9);
var4 = var6 + var9 * 4 - var3;
} else {
requireSlot(var0, var1 + 10, -1, "Palette");
}
byte[] var13 = null;
if (hasPackedIndices(var0, var1)) {
requireSlot(var0, var1 + 14, var4, "PackedIndices");
int var14 = var3 + var4;
long var8 = VarInt.getWithLength(var0, var14);
if (var8 == -1L) {
throw ProtocolException.invalidVarInt("PackedIndices");
}
int var17 = (int)var8;
if (var17 > 4096000) {
throw ProtocolException.arrayTooLong("PackedIndices", var17, 4096000);
}
int var11 = (int)(var8 >>> 32);
if (var14 + var11 + var17 > var0.byteSize()) {
throw ProtocolException.bufferTooSmall("PackedIndices", Math.min(var14 + var11 + var17, Integer.MAX_VALUE), (int)var0.byteSize());
}
var14 += var11;
var13 = new byte[var17];
MemorySegment.copy(var0, PacketIO.PROTO_BYTE, var14, var13, 0, var17);
var4 = var14 + var17 - var3;
} else {
requireSlot(var0, var1 + 14, -1, "PackedIndices");
}
MapImage var16 = new MapImage(
var0.get(PacketIO.PROTO_INT, var1 + 1), var0.get(PacketIO.PROTO_INT, var1 + 5), var5, var0.get(PacketIO.PROTO_BYTE, var1 + 9), var13
);
if (var2 != null) {
var2.position = var3 + var4;
}
class="kw">return var16;
}
class="kw">public int serialize(@Nonnull MemorySegment var1, int var2) {
byte var3 = 0;
if (this.palette != null) {
var3 = (byte)(var3 | 1);
}
if (this.packedIndices != null) {
var3 = (byte)(var3 | 2);
}
var1.set(PacketIO.PROTO_BYTE, var2 + 0, var3);
var1.set(PacketIO.PROTO_INT, var2 + 1, this.width);
var1.set(PacketIO.PROTO_INT, var2 + 5, this.height);
var1.set(PacketIO.PROTO_BYTE, var2 + 9, this.bitsPerIndex);
int var4 = var2 + 18;
if (this.palette != null) {
var1.set(PacketIO.PROTO_INT, var2 + 10, var4 - var2 - 18);
if (this.palette.length > 4096000) {
throw ProtocolException.arrayTooLong("Palette", this.palette.length, 4096000);
}
var4 += VarInt.set(var1, var4, this.palette.length);
MemorySegment.copy(this.palette, 0, var1, PacketIO.PROTO_INT, var4, this.palette.length);
var4 += this.palette.length * 4;
} else {
var1.set(PacketIO.PROTO_INT, var2 + 10, -1);
}
if (this.packedIndices != null) {
var1.set(PacketIO.PROTO_INT, var2 + 14, var4 - var2 - 18);
if (this.packedIndices.length > 4096000) {
throw ProtocolException.arrayTooLong("PackedIndices", this.packedIndices.length, 4096000);
}
var4 += VarInt.set(var1, var4, this.packedIndices.length);
MemorySegment.copy(this.packedIndices, 0, var1, PacketIO.PROTO_BYTE, var4, this.packedIndices.length);
var4 += this.packedIndices.length * 1;
} else {
var1.set(PacketIO.PROTO_INT, var2 + 14, -1);
}
class="kw">return var4 - var2;
}
class="kw">public int computeSize() {
int var1 = 18;
if (this.palette != null) {
var1 += VarInt.size(this.palette.length) + this.palette.length * 4;
}
if (this.packedIndices != null) {
var1 += VarInt.size(this.packedIndices.length) + this.packedIndices.length * 1;
}
class="kw">return var1;
}
class="kw">public MapImage clone() {
MapImage var1 = new MapImage();
var1.width = this.width;
var1.height = this.height;
var1.palette = this.palette != null ? Arrays.copyOf(this.palette, this.palette.length) : null;
var1.bitsPerIndex = this.bitsPerIndex;
var1.packedIndices = this.packedIndices != null ? Arrays.copyOf(this.packedIndices, this.packedIndices.length) : null;
class="kw">return var1;
}
@Override
class="kw">public boolean equals(Object var1) {
if (this == var1) {
class="kw">return true;
} else {
class="kw">return !(var1 class="kw">instanceof MapImage var2)
? false
: this.width == var2.width
&& this.height == var2.height
&& Arrays.equals(this.palette, var2.palette)
&& this.bitsPerIndex == var2.bitsPerIndex
&& Arrays.equals(this.packedIndices, var2.packedIndices);
}
}
@Override
class="kw">public int hashCode() {
int var1 = 1;
var1 = 31 * var1 + Integer.hashCode(this.width);
var1 = 31 * var1 + Integer.hashCode(this.height);
var1 = 31 * var1 + Arrays.hashCode(this.palette);
var1 = 31 * var1 + Byte.hashCode(this.bitsPerIndex);
class="kw">return 31 * var1 + Arrays.hashCode(this.packedIndices);
}
}