Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Addons required: ThatPacketAddon, ProtocolLib and skript-mirror 2.0
- #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)
- option ver:
- get:
- return console.getServer().getClass().getPackage().getName().split("\.")[3]
- import:
- java.util.Optional
- net.minecraft.server.{@ver}.BlockPosition
- net.minecraft.server.{@ver}.EntityPose
- com.comphenix.protocol.wrappers.WrappedDataWatcher
- com.comphenix.protocol.wrappers.WrappedDataWatcher$Registry as DataWatcherRegistry
- com.comphenix.protocol.wrappers.WrappedDataWatcher$WrappedDataWatcherObject as DataWatcherObject
- effect (make|force) [the] %players% [to] (swim|crawl) for %players%:
- trigger:
- set {_PacketMetadata} to new play_server_entity_metadata packet
- set {_WDW} to new WrappedDataWatcher()
- {_WDW}.setObject(6, DataWatcherRegistry.get(EntityPose) and EntityPose.SWIMMING)
- set watchable collection field 0 of {_PacketMetadata} to {_WDW}
- loop expressions-1:
- set int pnum 0 of {_PacketMetadata} to (loop-value-1).getEntityId()
- loop expressions-2:
- send packet {_PacketMetadata} to loop-value-2
- set {IsSwimming::%(loop-value-1).getEntityId()%::%loop-value-2%} to true
- effect (make|force) [the] %players% [to] stand [up] for %players%:
- trigger:
- set {_PacketMetadata} to new play_server_entity_metadata packet
- set {_WDW} to new WrappedDataWatcher()
- {_WDW}.setObject(6, DataWatcherRegistry.get(EntityPose) and EntityPose.STANDING)
- set watchable collection field 0 of {_PacketMetadata} to {_WDW}
- loop expressions-1:
- set int pnum 0 of {_PacketMetadata} to (loop-value-1).getEntityId()
- loop expressions-2:
- clear {IsSwimming::%(loop-value-1).getEntityId()%::%loop-value-2%}
- send packet {_PacketMetadata} to loop-value-2
- on packet event play_server_entity_metadata: #To avoid the player waking up when he sneaks for instance (if the boolean is true)
- {IsSwimming::%int pnum 0 of event-packet%::%player%} is true
- set {_WC} to watchable collection field 0 of event-packet
- "%{_WC}.getObject(6)%" is not "SWIMMING" or "<none>"
- cancel event #If we replace this field instead of canceling, it causes weird things to happen for the client
- on packet event play_server_named_entity_spawn: #To make the player swim when he comes in visible range
- {IsSwimming::%int pnum 0 of event-packet%::%player%} is true
- make {Id::%int pnum 0 of event-packet%} swim for player
- on quit: #This means that the player won't swim when he'll log back, you can remove that if you want
- clear {IsSwimming::%player.getEntityId()%::*}
- on join: #Mandatory to avoid looping all players to get a player from an entity id
- set {Id::%player.getEntityId()%} to player
- command /swim:
- trigger:
- make the player swim for all players
- command /stand:
- trigger:
- make the player stand for all players
Add Comment
Please, Sign In to add comment