ItemSoundSet class

Пакет: com.hypixel.hytale.protocol

Файл: com/hypixel/hytale/protocol/ItemSoundSet.java

Поля (33)

МодификаторыТипИмя
final int NULLABLE_BIT_FIELD_SIZE
int var1
ItemSoundSet var1
int var10
ItemSoundEvent var12
int var13
Map var14
var14
int var15
ItemSoundSet var18
long var2
int var2
byte var2
byte var2
long var3
int var3
byte var3
var3
var3
int var4
int var4
var4
int var4
int var5
int var5
String var5
var5
Map var6
int var6
long var7
ItemSoundEvent var8
long var8
int var9

Методы (36)

МодификаторыВозвратСигнатура
public ItemSoundSet cloneItemSoundSet clone()
public int computeSizeint computeSize()
for for(int var7 = 0; var7 < var5; var7++)
for for(int var11 = 0; var11 < var10; var11++)
abstract return getIdreturn getId(var0, 0)
abstract return getSoundEventIndicesreturn getSoundEventIndices(var0, 0)
static int getValidatedOffsetint getValidatedOffset(MemorySegment var0, int var1, int var2, int var3, String var4)
static boolean hasIdboolean hasId(MemorySegment var0, int var1)
static boolean hasSoundEventIndicesboolean hasSoundEventIndices(MemorySegment var0, int var1)
if if(var1 < 0)
if if(var3 == -1L)
if if(var5 > 4096000)
if if(var4 != var2)
if if(var8 == -1L)
if if(var10 > 4096000)
if if(var2 != null)
if if(this.id != null)
if if(this.soundEventIndices != null)
if if(this.id != null)
if if(this.soundEventIndices != null)
if if(this.id != null)
if if(this.soundEventIndices != 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 + 1, var4, "Id")
abstract requireSlot requireSlot(var0, var1 + 1, -1, "Id")
abstract requireSlot requireSlot(var0, var1 + 5, var4, "SoundEventIndices")
abstract requireSlot requireSlot(var0, var1 + 5, -1, "SoundEventIndices")
public int serializeint serialize(@Nonnull MemorySegment var1, int var2)
static ItemSoundSet toObjectItemSoundSet toObject(MemorySegment var0)
static ItemSoundSet toObjectItemSoundSet toObject(MemorySegment var0, int var1)
static ItemSoundSet toObjectItemSoundSet 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;

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.HashMap;
class="kw">import java.util.Map;
class="kw">import java.util.Objects;
class="kw">import java.util.Map.Entry;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class ItemSoundSet {
   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 = 1;
   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 = 9;
   class="kw">public class="kw">static class="kw">final int MAX_SIZE = 36864019;
   @Nullable
   class="kw">public String id;
   @Nullable
   class="kw">public Map<ItemSoundEvent, Integer> soundEventIndices;

   class="kw">public ItemSoundSet() {
   }

   class="kw">public ItemSoundSet(@Nullable String var1, @Nullable Map<ItemSoundEvent, Integer> var2) {
      this.id = var1;
      this.soundEventIndices = var2;
   }

   class="kw">public ItemSoundSet(@Nonnull ItemSoundSet var1) {
      this.id = var1.id;
      this.soundEventIndices = var1.soundEventIndices;
   }

   class="kw">public class="kw">static void requireBounds(MemorySegment var0, int var1) {
      if (var1 < 0) {
         throw ProtocolException.invalidOffset("ItemSoundSet", var1, (int)var0.byteSize());
      }

      long var2 = var1 + 9L;
      if (var2 > var0.byteSize()) {
         throw ProtocolException.bufferTooSmall("ItemSoundSet", (int)Math.min(var2, 2147483647L), (int)var0.byteSize());
      }
   }

   @Nullable
   class="kw">public class="kw">static String getId(MemorySegment var0) {
      class="kw">return getId(var0, 0);
   }

   @Nullable
   class="kw">public class="kw">static String getId(MemorySegment var0, int var1) {
      class="kw">return hasId(var0, var1) ? PacketIO.readVarString("Id", var0, var1 + getValidatedOffset(var0, var1, 1, 9, "Id"), 4096000) : null;
   }

   @Nullable
   class="kw">public class="kw">static Map<ItemSoundEvent, Integer> getSoundEventIndices(MemorySegment var0) {
      class="kw">return getSoundEventIndices(var0, 0);
   }

   @Nullable
   class="kw">public class="kw">static Map<ItemSoundEvent, Integer> getSoundEventIndices(MemorySegment var0, int var1) {
      if (!hasSoundEventIndices(var0, var1)) {
         class="kw">return null;
      }

      int var2 = var1 + getValidatedOffset(var0, var1, 5, 9, "SoundEventIndices");
      long var3 = VarInt.getWithLength(var0, var2);
      if (var3 == -1L) {
         throw ProtocolException.invalidVarInt("SoundEventIndices");
      }

      int var5 = (int)var3;
      if (var5 > 4096000) {
         throw ProtocolException.dictionaryTooLarge("SoundEventIndices", var5, 4096000);
      }

      var2 += (int)(var3 >>> 32);
      if (var2 + var5 * 5L > var0.byteSize()) {
         throw ProtocolException.bufferTooSmall("SoundEventIndices", (int)Math.min(var2 + var5 * 5L, 2147483647L), (int)var0.byteSize());
      }

      Map var6 = new HashMap<>(var5);

      for (int var7 = 0; var7 < var5; var7++) {
         ItemSoundEvent var8 = ItemSoundEvent.fromValue(var0.get(PacketIO.PROTO_BYTE, var2));
         int var9 = var0.get(PacketIO.PROTO_INT, ++var2);
         var2 += 4;
         if (var6.put(var8, var9) != null) {
            throw ProtocolException.duplicateKey("SoundEventIndices", var8);
         }
      }

      class="kw">return var6;
   }

   class="kw">public class="kw">static boolean hasId(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 hasSoundEventIndices(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 ItemSoundSet toObject(MemorySegment var0) {
      class="kw">return toObject(var0, 0, null);
   }

   class="kw">public class="kw">static ItemSoundSet toObject(MemorySegment var0, int var1) {
      class="kw">return toObject(var0, var1, null);
   }

   class="kw">public class="kw">static ItemSoundSet toObject(MemorySegment var0, int var1, @Nullable ReadCursor var2) {
      requireBounds(var0, var1);
      int var3 = var1 + 9;
      int var4 = 0;
      String var5 = null;
      if (hasId(var0, var1)) {
         requireSlot(var0, var1 + 1, var4, "Id");
         int var6 = var3 + var4;
         long var7 = VarInt.getWithLength(var0, var6);
         var5 = PacketIO.readVarString("Id", var0, var6, 0, 4096000, var7);
         var4 += (int)var7 + (int)(var7 >>> 32);
      } else {
         requireSlot(var0, var1 + 1, -1, "Id");
      }

      Map var14 = null;
      if (hasSoundEventIndices(var0, var1)) {
         requireSlot(var0, var1 + 5, var4, "SoundEventIndices");
         int var15 = var3 + var4;
         long var8 = VarInt.getWithLength(var0, var15);
         if (var8 == -1L) {
            throw ProtocolException.invalidVarInt("SoundEventIndices");
         }

         int var10 = (int)var8;
         if (var10 > 4096000) {
            throw ProtocolException.dictionaryTooLarge("SoundEventIndices", var10, 4096000);
         }

         var15 += (int)(var8 >>> 32);
         if (var15 + var10 * 5L > var0.byteSize()) {
            throw ProtocolException.bufferTooSmall("SoundEventIndices", (int)Math.min(var15 + var10 * 5L, 2147483647L), (int)var0.byteSize());
         }

         var14 = new HashMap<>(var10);

         for (int var11 = 0; var11 < var10; var11++) {
            ItemSoundEvent var12 = ItemSoundEvent.fromValue(var0.get(PacketIO.PROTO_BYTE, var15));
            int var13 = var0.get(PacketIO.PROTO_INT, ++var15);
            var15 += 4;
            if (var14.put(var12, var13) != null) {
               throw ProtocolException.duplicateKey("SoundEventIndices", var12);
            }
         }

         var4 = var15 - var3;
      } else {
         requireSlot(var0, var1 + 5, -1, "SoundEventIndices");
      }

      ItemSoundSet var18 = new ItemSoundSet(var5, var14);
      if (var2 != null) {
         var2.position = var3 + var4;
      }

      class="kw">return var18;
   }

   class="kw">public int serialize(@Nonnull MemorySegment var1, int var2) {
      byte var3 = 0;
      if (this.id != null) {
         var3 = (byte)(var3 | 1);
      }

      if (this.soundEventIndices != null) {
         var3 = (byte)(var3 | 2);
      }

      var1.set(PacketIO.PROTO_BYTE, var2 + 0, var3);
      int var4 = var2 + 9;
      if (this.id != null) {
         var1.set(PacketIO.PROTO_INT, var2 + 1, var4 - var2 - 9);
         var4 += PacketIO.writeVarString(var1, var4, this.id, 4096000);
      } else {
         var1.set(PacketIO.PROTO_INT, var2 + 1, -1);
      }

      if (this.soundEventIndices != null) {
         var1.set(PacketIO.PROTO_INT, var2 + 5, var4 - var2 - 9);
         if (this.soundEventIndices.size() > 4096000) {
            throw ProtocolException.dictionaryTooLarge("SoundEventIndices", this.soundEventIndices.size(), 4096000);
         }

         var4 += VarInt.set(var1, var4, this.soundEventIndices.size());

         for (Entry var6 : this.soundEventIndices.entrySet()) {
            var1.set(PacketIO.PROTO_BYTE, var4, (byte)var6.getKey().getValue());
            var1.set(PacketIO.PROTO_INT, ++var4, var6.getValue());
            var4 += 4;
         }
      } else {
         var1.set(PacketIO.PROTO_INT, var2 + 5, -1);
      }

      class="kw">return var4 - var2;
   }

   class="kw">public int computeSize() {
      int var1 = 9;
      if (this.id != null) {
         var1 += PacketIO.stringSize(this.id);
      }

      if (this.soundEventIndices != null) {
         var1 += VarInt.size(this.soundEventIndices.size()) + this.soundEventIndices.size() * 5;
      }

      class="kw">return var1;
   }

   class="kw">public ItemSoundSet clone() {
      ItemSoundSet var1 = new ItemSoundSet();
      var1.id = this.id;
      var1.soundEventIndices = this.soundEventIndices != null ? new HashMap<>(this.soundEventIndices) : 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 ItemSoundSet var2)
            ? false
            : Objects.equals(this.id, var2.id) && Objects.equals(this.soundEventIndices, var2.soundEventIndices);
      }
   }

   @Override
   class="kw">public int hashCode() {
      class="kw">return Objects.hash(this.id, this.soundEventIndices);
   }
}