Vaerys_Dawn

Illegal argument exception trying to send client sync message

Jan 21st, 2021
932
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // EnderBeeconTileEntity
  2.  
  3.     // error occurs here --V
  4.     public static void syncApiaryToPlayersUsing(World world, BlockPos pos, CompoundNBT data) {
  5.         NetPacketHandler.sendToAllLoaded(new UpdateClientBeeconMessage(pos, data), world, pos);
  6.     }
  7.  
  8.     public void updateBeeconEffect(ResourceLocation effectLocation, boolean active) {
  9.         Effect effect = ForgeRegistries.POTIONS.getValue(effectLocation);
  10.         for (BeeconEffect e : effects) {
  11.             if (e.effect == effect) {
  12.                 e.active = active;
  13.             }
  14.         }
  15.         syncApiaryToPlayersUsing(this.world, this.getPos(), this.writeNBT(new CompoundNBT()));
  16.     }
  17.  
  18. // EnderBeeconScreen
  19.  
  20.     public void onPress() {
  21.         NetPacketHandler.sendToServer(new UpdateBeeconMessage(effect.getRegistryName(), !this.isSelected(), tileEntity.getPos()));
  22.         this.setSelected(!this.isSelected());
  23.  
  24.         EnderBeeconScreen.this.tick();
  25.         EnderBeeconScreen.this.init();
  26.     }
  27.  
  28. public class UpdateBeeconMessage {
  29.  
  30.     private final ResourceLocation effectLocation;
  31.     private final boolean active;
  32.     private final BlockPos blockPos;
  33.  
  34.     public UpdateBeeconMessage(ResourceLocation effectName, boolean active, BlockPos blockPos) {
  35.         this.effectLocation = effectName;
  36.         this.active = active;
  37.         this.blockPos = blockPos;
  38.     }
  39.  
  40.     public static void encode(UpdateBeeconMessage message, PacketBuffer buffer) {
  41.         buffer.writeResourceLocation(message.effectLocation);
  42.         buffer.writeBoolean(message.active);
  43.         buffer.writeBlockPos(message.blockPos);
  44.     }
  45.  
  46.     public static UpdateBeeconMessage decode(PacketBuffer buffer) {
  47.         return new UpdateBeeconMessage(buffer.readResourceLocation(), buffer.readBoolean(), buffer.readBlockPos());
  48.     }
  49.  
  50.     public static void handle(UpdateBeeconMessage message, Supplier<NetworkEvent.Context> context) {
  51.         context.get().enqueueWork(() -> {
  52.             ServerPlayerEntity player = context.get().getSender();
  53.             if (player != null) {
  54.                 if (player.world.isBlockLoaded(message.blockPos)){
  55.                     TileEntity tileEntity = player.world.getTileEntity(message.blockPos);
  56.                     if (tileEntity instanceof EnderBeeconTileEntity) {
  57.                         EnderBeeconTileEntity beecon = (EnderBeeconTileEntity) tileEntity;
  58.                         beecon.updateBeeconEffect(message.effectLocation, message.active);
  59.                     }
  60.                 }
  61.             }
  62.         });
  63.         context.get().setPacketHandled(true);
  64.     }
  65. }
  66.  
  67. public class UpdateClientBeeconMessage {
  68.     private final BlockPos pos;
  69.     private final CompoundNBT data;
  70.  
  71.     public UpdateClientBeeconMessage(BlockPos pos, CompoundNBT data){
  72.         this.pos = pos;
  73.         this.data = data;
  74.     }
  75.  
  76.     public static void encode(UpdateClientBeeconMessage message, PacketBuffer buffer){
  77.         buffer.writeBlockPos(message.pos);
  78.         buffer.writeCompoundTag(message.data);
  79.     }
  80.  
  81.     public static UpdateClientBeeconMessage decode(PacketBuffer buffer){
  82.         return new UpdateClientBeeconMessage(buffer.readBlockPos(), buffer.readCompoundTag());
  83.     }
  84.  
  85.     public static void handle(UpdateClientBeeconMessage message, Supplier<NetworkEvent.Context> context){
  86.         context.get().enqueueWork(() -> {
  87.             ClientPlayerEntity player = Minecraft.getInstance().player;
  88.             if (player != null) {
  89.                 if (player.world.isBlockLoaded(message.pos)) {
  90.                     TileEntity tileEntity = player.world.getTileEntity(message.pos);
  91.                     if (tileEntity instanceof EnderBeeconTileEntity) {
  92.                         EnderBeeconTileEntity beeconTileEntity = (EnderBeeconTileEntity) tileEntity;
  93.                         beeconTileEntity.readNBT(message.data);
  94.                     }
  95.                 }
  96.             }
  97.         });
  98.         context.get().setPacketHandled(true);
  99.     }
  100. }
  101.  
  102.  
  103. [07:21:00] [Server thread/ERROR] [ne.mi.fm.ne.si.IndexedMessageCodec/SIMPLENET]: Received invalid message com.resourcefulbees.resourcefulbees.network.packets.UpdateClientBeeconMessage on channel resourcefulbees:main_channel
  104. [07:21:00] [Server thread/FATAL] [minecraft/ThreadTaskExecutor]: Error executing task on Server
  105. java.lang.IllegalArgumentException: Invalid message com.resourcefulbees.resourcefulbees.network.packets.UpdateClientBeeconMessage
  106.     at net.minecraftforge.fml.network.simple.IndexedMessageCodec.build(IndexedMessageCodec.java:145) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading}
  107.     at net.minecraftforge.fml.network.simple.SimpleChannel.encodeMessage(SimpleChannel.java:85) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading}
  108.     at net.minecraftforge.fml.network.simple.SimpleChannel.toBuffer(SimpleChannel.java:98) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading}
  109.     at net.minecraftforge.fml.network.simple.SimpleChannel.toVanillaPacket(SimpleChannel.java:129) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading}
  110.     at net.minecraftforge.fml.network.simple.SimpleChannel.send(SimpleChannel.java:124) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading}
  111.     at com.resourcefulbees.resourcefulbees.network.NetPacketHandler.sendToAllLoaded(NetPacketHandler.java:43) ~[main/:?] {re:classloading}
  112.     at com.resourcefulbees.resourcefulbees.tileentity.EnderBeeconTileEntity.syncApiaryToPlayersUsing(EnderBeeconTileEntity.java:328) ~[main/:?] {re:classloading}
  113.     at com.resourcefulbees.resourcefulbees.tileentity.EnderBeeconTileEntity.updateBeeconEffect(EnderBeeconTileEntity.java:445) ~[main/:?] {re:classloading}
  114.     at com.resourcefulbees.resourcefulbees.network.packets.UpdateBeeconMessage.lambda$handle$0(UpdateBeeconMessage.java:44) ~[main/:?] {re:classloading}
  115.     at net.minecraftforge.fml.network.NetworkEvent$Context.enqueueWork(NetworkEvent.java:215) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading}
  116.     at com.resourcefulbees.resourcefulbees.network.packets.UpdateBeeconMessage.handle(UpdateBeeconMessage.java:37) ~[main/:?] {re:classloading}
  117.     at net.minecraftforge.fml.network.simple.IndexedMessageCodec.lambda$tryDecode$3(IndexedMessageCodec.java:128) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading}
  118.     at java.util.Optional.ifPresent(Optional.java:159) ~[?:1.8.0_271] {}
  119.     at net.minecraftforge.fml.network.simple.IndexedMessageCodec.tryDecode(IndexedMessageCodec.java:128) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading}
  120.     at net.minecraftforge.fml.network.simple.IndexedMessageCodec.consume(IndexedMessageCodec.java:162) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading}
  121.     at net.minecraftforge.fml.network.simple.SimpleChannel.networkEventListener(SimpleChannel.java:80) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading}
  122.     at net.minecraftforge.eventbus.EventBus.doCastFilter(EventBus.java:247) ~[eventbus-3.0.5-service.jar:?] {}
  123.     at net.minecraftforge.eventbus.EventBus.lambda$addListener$11(EventBus.java:239) ~[eventbus-3.0.5-service.jar:?] {}
  124.     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:297) ~[eventbus-3.0.5-service.jar:?] {}
  125.     at net.minecraftforge.fml.network.NetworkInstance.dispatch(NetworkInstance.java:84) ~[forge:?] {re:classloading}
  126.     at net.minecraftforge.fml.network.NetworkHooks.lambda$onCustomPayload$1(NetworkHooks.java:88) ~[forge:?] {re:classloading}
  127.     at java.util.Optional.map(Optional.java:215) ~[?:1.8.0_271] {}
  128.     at net.minecraftforge.fml.network.NetworkHooks.onCustomPayload(NetworkHooks.java:88) ~[forge:?] {re:classloading}
  129.     at net.minecraft.network.play.ServerPlayNetHandler.processCustomPayload(ServerPlayNetHandler.java:1500) ~[forge:?] {re:classloading,pl:accesstransformer:B}
  130.     at net.minecraft.network.play.client.CCustomPayloadPacket.processPacket(CCustomPayloadPacket.java:48) ~[forge:?] {re:classloading}
  131.     at net.minecraft.network.play.client.CCustomPayloadPacket.processPacket(CCustomPayloadPacket.java:12) ~[forge:?] {re:classloading}
  132.     at net.minecraft.network.PacketThreadUtil.lambda$checkThreadAndEnqueue$0(PacketThreadUtil.java:19) ~[forge:?] {re:classloading}
  133.     at net.minecraft.util.concurrent.TickDelayedTask.run(TickDelayedTask.java:20) ~[forge:?] {re:classloading}
  134.     at net.minecraft.util.concurrent.ThreadTaskExecutor.run(ThreadTaskExecutor.java:139) ~[forge:?] {re:classloading,pl:accesstransformer:B}
  135.     at net.minecraft.util.concurrent.RecursiveEventLoop.run(RecursiveEventLoop.java:22) ~[forge:?] {re:classloading}
  136.     at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:757) ~[forge:?] {re:classloading,pl:accesstransformer:B}
  137.     at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:159) ~[forge:?] {re:classloading,pl:accesstransformer:B}
  138.     at net.minecraft.util.concurrent.ThreadTaskExecutor.driveOne(ThreadTaskExecutor.java:109) ~[forge:?] {re:classloading,pl:accesstransformer:B}
  139.     at net.minecraft.server.MinecraftServer.func_213205_aW(MinecraftServer.java:740) ~[forge:?] {re:classloading,pl:accesstransformer:B}
  140.     at net.minecraft.server.MinecraftServer.driveOne(MinecraftServer.java:734) ~[forge:?] {re:classloading,pl:accesstransformer:B}
  141.     at net.minecraft.util.concurrent.ThreadTaskExecutor.driveUntil(ThreadTaskExecutor.java:122) ~[forge:?] {re:classloading,pl:accesstransformer:B}
  142.     at net.minecraft.server.MinecraftServer.runScheduledTasks(MinecraftServer.java:720) ~[forge:?] {re:classloading,pl:accesstransformer:B}
  143.     at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:666) ~[forge:?] {re:classloading,pl:accesstransformer:B}
  144.     at net.minecraft.server.MinecraftServer.lambda$startServer$0(MinecraftServer.java:232) ~[forge:?] {re:classloading,pl:accesstransformer:B}
  145.     at java.lang.Thread.run(Thread.java:748) [?:1.8.0_271] {}
  146.  
  147.  
RAW Paste Data