UpdateBlockSoundSets class

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

Файл: com/hypixel/hytale/protocol/packets/assets/UpdateBlockSoundSets.java

implements: Packet, ToClientPacket

Поля (31)

МодификаторыТипИмя
final int PACKET_ID
int var1
UpdateBlockSoundSets var1
BlockSoundSet var10
int var10
int var12
BlockSoundSet var13
UpdateBlockSoundSets var16
long var2
ReadCursor var2
byte var2
int var2
Map var2
int var3
var3
int var3
byte var3
var3
long var4
int var4
var4
int var4
ReadCursor var5
int var6
Map var6
var6
Map var7
int var7
var7
long var8
int var9

Методы (29)

МодификаторыВозвратСигнатура
public UpdateBlockSoundSets cloneUpdateBlockSoundSets clone()
for for(int var8 = 0; var8 < var6; var8++)
for for(int var11 = 0; var11 < var10; var11++)
abstract return getBlockSoundSetsreturn getBlockSoundSets(var0, 0)
static int getMaxIdint getMaxId(MemorySegment var0)
static int getMaxIdint getMaxId(MemorySegment var0, int var1)
abstract return getMaxIdreturn getMaxId(var0, 0)
static UpdateType getTypeUpdateType getType(MemorySegment var0)
static UpdateType getTypeUpdateType getType(MemorySegment var0, int var1)
abstract return getTypereturn getType(var0, 0)
static boolean hasBlockSoundSetsboolean hasBlockSoundSets(MemorySegment var0, int var1)
if if(var1 < 0)
if if(var4 == -1L)
if if(var6 > 4096000)
if if(var8 == -1L)
if if(var10 > 4096000)
if if(var2 != null)
if if(this.blockSoundSets != null)
if if(this.blockSoundSets != null)
if if(this.blockSoundSets != null)
if if(this.blockSoundSets != null)
if if(this == var1)
static void requireBoundsvoid requireBounds(MemorySegment var0, int var1)
abstract requireBounds requireBounds(var0, var1)
static UpdateBlockSoundSets toObjectUpdateBlockSoundSets toObject(MemorySegment var0)
static UpdateBlockSoundSets toObjectUpdateBlockSoundSets toObject(MemorySegment var0, int var1)
static UpdateBlockSoundSets toObjectUpdateBlockSoundSets 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.assets;

class="kw">import com.hypixel.hytale.protocol.BlockSoundSet;
class="kw">import com.hypixel.hytale.protocol.NetworkChannel;
class="kw">import com.hypixel.hytale.protocol.Packet;
class="kw">import com.hypixel.hytale.protocol.ToClientPacket;
class="kw">import com.hypixel.hytale.protocol.UpdateType;
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 UpdateBlockSoundSets class="kw">implements Packet, ToClientPacket {
   class="kw">public class="kw">static class="kw">final int PACKET_ID = 42;
   class="kw">public class="kw">static class="kw">final boolean IS_COMPRESSED = true;
   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 = 6;
   class="kw">public class="kw">static class="kw">final int VARIABLE_FIELD_COUNT = 1;
   class="kw">public class="kw">static class="kw">final int VARIABLE_BLOCK_START = 6;
   class="kw">public class="kw">static class="kw">final int MAX_SIZE = 1677721600;
   @Nonnull
   class="kw">public UpdateType type = UpdateType.Init;
   class="kw">public int maxId;
   @Nullable
   class="kw">public Map<Integer, BlockSoundSet> blockSoundSets;

   @Override
   class="kw">public int getId() {
      class="kw">return 42;
   }

   @Override
   class="kw">public NetworkChannel getChannel() {
      class="kw">return NetworkChannel.Default;
   }

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

   class="kw">public UpdateBlockSoundSets(@Nonnull UpdateType var1, int var2, @Nullable Map<Integer, BlockSoundSet> var3) {
      this.type = var1;
      this.maxId = var2;
      this.blockSoundSets = var3;
   }

   class="kw">public UpdateBlockSoundSets(@Nonnull UpdateBlockSoundSets var1) {
      this.type = var1.type;
      this.maxId = var1.maxId;
      this.blockSoundSets = var1.blockSoundSets;
   }

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

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

   class="kw">public class="kw">static UpdateType getType(MemorySegment var0) {
      class="kw">return getType(var0, 0);
   }

   class="kw">public class="kw">static UpdateType getType(MemorySegment var0, int var1) {
      class="kw">return UpdateType.fromValue(var0.get(PacketIO.PROTO_BYTE, var1 + 1));
   }

   class="kw">public class="kw">static int getMaxId(MemorySegment var0) {
      class="kw">return getMaxId(var0, 0);
   }

   class="kw">public class="kw">static int getMaxId(MemorySegment var0, int var1) {
      class="kw">return var0.get(PacketIO.PROTO_INT, var1 + 2);
   }

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

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

      ReadCursor var2 = new ReadCursor();
      int var3 = var1 + 6;
      long var4 = VarInt.getWithLength(var0, var3);
      if (var4 == -1L) {
         throw ProtocolException.invalidVarInt("BlockSoundSets");
      }

      int var6 = (int)var4;
      if (var6 > 4096000) {
         throw ProtocolException.dictionaryTooLarge("BlockSoundSets", var6, 4096000);
      }

      var3 += (int)(var4 >>> 32);
      if (var3 + var6 * 21L > var0.byteSize()) {
         throw ProtocolException.bufferTooSmall("BlockSoundSets", (int)Math.min(var3 + var6 * 21L, 2147483647L), (int)var0.byteSize());
      }

      Map var7 = new HashMap<>(var6);

      for (int var8 = 0; var8 < var6; var8++) {
         int var9 = var0.get(PacketIO.PROTO_INT, var3);
         var3 += 4;
         BlockSoundSet var10 = BlockSoundSet.toObject(var0, var3, var2);
         var3 = var2.position;
         if (var7.put(var9, var10) != null) {
            throw ProtocolException.duplicateKey("BlockSoundSets", var9);
         }
      }

      class="kw">return var7;
   }

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

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

   class="kw">public class="kw">static UpdateBlockSoundSets toObject(MemorySegment var0, int var1, @Nullable ReadCursor var2) {
      requireBounds(var0, var1);
      int var3 = var1 + 6;
      int var4 = 0;
      ReadCursor var5 = var2 != null ? var2 : new ReadCursor();
      Map var6 = null;
      if (hasBlockSoundSets(var0, var1)) {
         int var7 = var3 + var4;
         long var8 = VarInt.getWithLength(var0, var7);
         if (var8 == -1L) {
            throw ProtocolException.invalidVarInt("BlockSoundSets");
         }

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

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

         var6 = new HashMap<>(var10);

         for (int var11 = 0; var11 < var10; var11++) {
            int var12 = var0.get(PacketIO.PROTO_INT, var7);
            var7 += 4;
            BlockSoundSet var13 = BlockSoundSet.toObject(var0, var7, var5);
            var7 = var5.position;
            if (var6.put(var12, var13) != null) {
               throw ProtocolException.duplicateKey("BlockSoundSets", var12);
            }
         }

         var4 = var7 - var3;
      }

      UpdateBlockSoundSets var16 = new UpdateBlockSoundSets(
         UpdateType.fromValue(var0.get(PacketIO.PROTO_BYTE, var1 + 1)), var0.get(PacketIO.PROTO_INT, var1 + 2), var6
      );
      if (var2 != null) {
         var2.position = var3 + var4;
      }

      class="kw">return var16;
   }

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

      var1.set(PacketIO.PROTO_BYTE, var2 + 0, var3);
      var1.set(PacketIO.PROTO_BYTE, var2 + 1, (byte)this.type.getValue());
      var1.set(PacketIO.PROTO_INT, var2 + 2, this.maxId);
      int var4 = var2 + 6;
      if (this.blockSoundSets != null) {
         if (this.blockSoundSets.size() > 4096000) {
            throw ProtocolException.dictionaryTooLarge("BlockSoundSets", this.blockSoundSets.size(), 4096000);
         }

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

         for (Entry var6 : this.blockSoundSets.entrySet()) {
            var1.set(PacketIO.PROTO_INT, var4, var6.getKey());
            var4 += 4;
            var4 += var6.getValue().serialize(var1, var4);
         }
      }

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

   @Override
   class="kw">public int computeSize() {
      int var1 = 6;
      if (this.blockSoundSets != null) {
         int var2 = 0;

         for (Entry var4 : this.blockSoundSets.entrySet()) {
            var2 += 4 + var4.getValue().computeSize();
         }

         var1 += VarInt.size(this.blockSoundSets.size()) + var2;
      }

      class="kw">return var1;
   }

   class="kw">public UpdateBlockSoundSets clone() {
      UpdateBlockSoundSets var1 = new UpdateBlockSoundSets();
      var1.type = this.type;
      var1.maxId = this.maxId;
      if (this.blockSoundSets != null) {
         Map var2 = new HashMap<>();

         for (Entry var4 : this.blockSoundSets.entrySet()) {
            var2.put(var4.getKey(), var4.getValue().clone());
         }

         var1.blockSoundSets = var2;
      }

      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 UpdateBlockSoundSets var2)
            ? false
            : Objects.equals(this.type, var2.type) && this.maxId == var2.maxId && Objects.equals(this.blockSoundSets, var2.blockSoundSets);
      }
   }

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