Hafixie93

Animasi berenang

Dec 7th, 2020
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Addons required: ThatPacketAddon, ProtocolLib and skript-mirror 2.0
  2. #Working in 1.15.2 (FIY, the player won't see himself swim but other people will, it's not my fault & it's probably not possible, remember that this is not intended by minecraft and that packets can't do everything)
  3. option ver:
  4.     get:
  5.         return console.getServer().getClass().getPackage().getName().split("\.")[3]
  6. import:
  7.     java.util.Optional
  8.     net.minecraft.server.{@ver}.BlockPosition
  9.     net.minecraft.server.{@ver}.EntityPose
  10.     com.comphenix.protocol.wrappers.WrappedDataWatcher
  11.     com.comphenix.protocol.wrappers.WrappedDataWatcher$Registry as DataWatcherRegistry
  12.     com.comphenix.protocol.wrappers.WrappedDataWatcher$WrappedDataWatcherObject as DataWatcherObject
  13. effect (make|force) [the] %players% [to] (swim|crawl) for %players%:
  14.     trigger:
  15.         set {_PacketMetadata} to new play_server_entity_metadata packet
  16.         set {_WDW} to new WrappedDataWatcher()
  17.         {_WDW}.setObject(6, DataWatcherRegistry.get(EntityPose) and EntityPose.SWIMMING)
  18.         set watchable collection field 0 of {_PacketMetadata} to {_WDW}
  19.         loop expressions-1:
  20.             set int pnum 0 of {_PacketMetadata} to (loop-value-1).getEntityId()
  21.             loop expressions-2:
  22.                 send packet {_PacketMetadata} to loop-value-2
  23.                 set {IsSwimming::%(loop-value-1).getEntityId()%::%loop-value-2%} to true
  24. effect (make|force) [the] %players% [to] stand [up] for %players%:
  25.     trigger:
  26.         set {_PacketMetadata} to new play_server_entity_metadata packet
  27.         set {_WDW} to new WrappedDataWatcher() 
  28.         {_WDW}.setObject(6, DataWatcherRegistry.get(EntityPose) and EntityPose.STANDING)
  29.         set watchable collection field 0 of {_PacketMetadata} to {_WDW}
  30.         loop expressions-1:
  31.             set int pnum 0 of {_PacketMetadata} to (loop-value-1).getEntityId()
  32.             loop expressions-2:
  33.                 clear {IsSwimming::%(loop-value-1).getEntityId()%::%loop-value-2%}
  34.                 send packet {_PacketMetadata} to loop-value-2
  35. on packet event play_server_entity_metadata: #To avoid the player waking up when he sneaks for instance (if the boolean is true)
  36.     {IsSwimming::%int pnum 0 of event-packet%::%player%} is true
  37.     set {_WC} to watchable collection field 0 of event-packet
  38.     "%{_WC}.getObject(6)%" is not "SWIMMING" or "<none>"
  39.     cancel event #If we replace this field instead of canceling, it causes weird things to happen for the client
  40. on packet event play_server_named_entity_spawn: #To make the player swim when he comes in visible range
  41.     {IsSwimming::%int pnum 0 of event-packet%::%player%} is true
  42.     make {Id::%int pnum 0 of event-packet%} swim for player
  43. on quit: #This means that the player won't swim when he'll log back, you can remove that if you want
  44.     clear {IsSwimming::%player.getEntityId()%::*}
  45. on join: #Mandatory to avoid looping all players to get a player from an entity id
  46.     set {Id::%player.getEntityId()%} to player
  47.  
  48. command /swim:
  49.     trigger:
  50.         make the player swim for all players
  51. command /stand:
  52.     trigger:
  53.         make the player stand for all players
Add Comment
Please, Sign In to add comment