2020-04-23 04:40:49 +00:00
/ *
2022-01-01 19:03:05 +00:00
* Copyright ( c ) 2019 - 2022 GeyserMC . http : //geysermc.org
2020-04-23 04:40:49 +00:00
*
* Permission is hereby granted , free of charge , to any person obtaining a copy
* of this software and associated documentation files ( the " Software " ) , to deal
* in the Software without restriction , including without limitation the rights
* to use , copy , modify , merge , publish , distribute , sublicense , and / or sell
* copies of the Software , and to permit persons to whom the Software is
* furnished to do so , subject to the following conditions :
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software .
*
* THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR
* IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY ,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER
* LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM ,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE .
*
* @author GeyserMC
* @link https : //github.com/GeyserMC/Geyser
* /
2021-11-20 23:29:46 +00:00
package org.geysermc.geyser.translator.protocol.java.level ;
2020-04-23 04:40:49 +00:00
2022-05-27 15:54:38 +00:00
import com.github.steveice10.mc.protocol.data.game.entity.object.Direction ;
2022-02-09 03:57:03 +00:00
import com.github.steveice10.mc.protocol.data.game.level.event.* ;
2021-11-13 03:44:15 +00:00
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundLevelEventPacket ;
2022-10-30 00:23:21 +00:00
import org.cloudburstmc.math.vector.Vector3f ;
import org.cloudburstmc.math.vector.Vector3i ;
2022-12-21 00:47:45 +00:00
import org.cloudburstmc.nbt.NbtMap ;
2023-09-29 21:14:49 +00:00
import org.cloudburstmc.protocol.bedrock.data.ParticleType ;
2022-10-30 00:23:21 +00:00
import org.cloudburstmc.protocol.bedrock.data.SoundEvent ;
2022-12-21 00:47:45 +00:00
import org.cloudburstmc.protocol.bedrock.packet.LevelEventGenericPacket ;
import org.cloudburstmc.protocol.bedrock.packet.LevelEventPacket ;
import org.cloudburstmc.protocol.bedrock.packet.LevelSoundEventPacket ;
import org.cloudburstmc.protocol.bedrock.packet.TextPacket ;
2021-11-20 21:34:30 +00:00
import org.geysermc.geyser.GeyserImpl ;
2022-02-09 03:57:03 +00:00
import org.geysermc.geyser.registry.Registries ;
2021-11-22 19:52:26 +00:00
import org.geysermc.geyser.session.GeyserSession ;
2022-02-09 03:57:03 +00:00
import org.geysermc.geyser.text.MinecraftLocale ;
import org.geysermc.geyser.translator.level.event.LevelEventTranslator ;
2021-11-20 23:29:46 +00:00
import org.geysermc.geyser.translator.protocol.PacketTranslator ;
import org.geysermc.geyser.translator.protocol.Translator ;
2020-05-13 21:08:52 +00:00
2021-03-31 18:15:55 +00:00
import java.util.Collections ;
2020-08-03 21:42:43 +00:00
import java.util.Locale ;
2022-05-27 15:54:38 +00:00
import java.util.Set ;
2020-04-23 04:40:49 +00:00
2021-11-13 03:44:15 +00:00
@Translator ( packet = ClientboundLevelEventPacket . class )
2021-11-13 04:01:45 +00:00
public class JavaLevelEventTranslator extends PacketTranslator < ClientboundLevelEventPacket > {
2020-04-23 04:40:49 +00:00
@Override
2021-11-22 19:52:26 +00:00
public void translate ( GeyserSession session , ClientboundLevelEventPacket packet ) {
2023-05-03 15:01:31 +00:00
if ( ! ( packet . getEvent ( ) instanceof LevelEventType levelEvent ) ) {
return ;
}
2021-11-14 05:07:24 +00:00
// Separate case since each RecordEventData in Java is an individual track in Bedrock
2023-05-03 15:01:31 +00:00
if ( levelEvent = = LevelEventType . RECORD ) {
2021-11-14 05:07:24 +00:00
RecordEventData recordEventData = ( RecordEventData ) packet . getData ( ) ;
2023-04-27 17:09:38 +00:00
SoundEvent soundEvent = Registries . RECORDS . get ( recordEventData . getRecordId ( ) ) ;
if ( soundEvent = = null ) {
return ;
}
2022-05-26 17:11:39 +00:00
Vector3i origin = packet . getPosition ( ) ;
Vector3f pos = Vector3f . from ( origin . getX ( ) + 0 . 5f , origin . getY ( ) + 0 . 5f , origin . getZ ( ) + 0 . 5f ) ;
2020-08-03 21:42:43 +00:00
LevelSoundEventPacket levelSoundEvent = new LevelSoundEventPacket ( ) ;
levelSoundEvent . setIdentifier ( " " ) ;
levelSoundEvent . setSound ( soundEvent ) ;
levelSoundEvent . setPosition ( pos ) ;
levelSoundEvent . setRelativeVolumeDisabled ( packet . isBroadcast ( ) ) ;
levelSoundEvent . setExtraData ( - 1 ) ;
levelSoundEvent . setBabySound ( false ) ;
session . sendUpstreamPacket ( levelSoundEvent ) ;
2023-04-27 17:09:38 +00:00
// Send text packet as it seems to be handled in Java Edition client-side.
TextPacket textPacket = new TextPacket ( ) ;
textPacket . setType ( TextPacket . Type . JUKEBOX_POPUP ) ;
textPacket . setNeedsTranslation ( true ) ;
textPacket . setXuid ( " " ) ;
textPacket . setPlatformChatId ( " " ) ;
textPacket . setSourceName ( null ) ;
textPacket . setMessage ( " record.nowPlaying " ) ;
String recordString = " %item. " + soundEvent . name ( ) . toLowerCase ( Locale . ROOT ) + " .desc " ;
textPacket . setParameters ( Collections . singletonList ( MinecraftLocale . getLocaleString ( recordString , session . locale ( ) ) ) ) ;
session . sendUpstreamPacket ( textPacket ) ;
2020-08-03 21:42:43 +00:00
return ;
}
2022-05-26 23:57:45 +00:00
// Check for a sound event translator
LevelEventTranslator transformer = Registries . SOUND_LEVEL_EVENTS . get ( packet . getEvent ( ) ) ;
if ( transformer ! = null ) {
transformer . translate ( session , packet ) ;
return ;
}
2020-08-03 21:42:43 +00:00
2022-05-26 23:57:45 +00:00
Vector3i origin = packet . getPosition ( ) ;
Vector3f pos = Vector3f . from ( origin . getX ( ) + 0 . 5f , origin . getY ( ) + 0 . 5f , origin . getZ ( ) + 0 . 5f ) ;
2020-08-03 21:42:43 +00:00
2022-05-26 23:57:45 +00:00
LevelEventPacket effectPacket = new LevelEventPacket ( ) ;
effectPacket . setPosition ( pos ) ;
effectPacket . setData ( 0 ) ;
2023-05-03 15:01:31 +00:00
switch ( levelEvent ) {
2023-09-29 21:14:49 +00:00
case BRUSH_BLOCK_COMPLETE - > {
effectPacket . setType ( ParticleType . BRUSH_DUST ) ;
session . playSoundEvent ( SoundEvent . BRUSH_COMPLETED , pos ) ; // todo 1.20.2 verify this
}
2022-05-26 23:57:45 +00:00
case COMPOSTER - > {
2022-10-30 03:02:11 +00:00
effectPacket . setType ( org . cloudburstmc . protocol . bedrock . data . LevelEvent . PARTICLE_CROP_GROWTH ) ;
2020-08-03 21:42:43 +00:00
2022-05-26 23:57:45 +00:00
ComposterEventData composterEventData = ( ComposterEventData ) packet . getData ( ) ;
LevelSoundEventPacket soundEventPacket = new LevelSoundEventPacket ( ) ;
switch ( composterEventData ) {
case FILL - > soundEventPacket . setSound ( SoundEvent . COMPOSTER_FILL ) ;
case FILL_SUCCESS - > soundEventPacket . setSound ( SoundEvent . COMPOSTER_FILL_LAYER ) ;
2020-08-03 21:42:43 +00:00
}
2022-05-26 23:57:45 +00:00
soundEventPacket . setPosition ( pos ) ;
soundEventPacket . setIdentifier ( " " ) ;
soundEventPacket . setExtraData ( - 1 ) ;
soundEventPacket . setBabySound ( false ) ;
soundEventPacket . setRelativeVolumeDisabled ( false ) ;
session . sendUpstreamPacket ( soundEventPacket ) ;
}
case BLOCK_LAVA_EXTINGUISH - > {
2022-10-30 03:02:11 +00:00
effectPacket . setType ( org . cloudburstmc . protocol . bedrock . data . LevelEvent . PARTICLE_EVAPORATE ) ;
2022-05-26 23:57:45 +00:00
effectPacket . setPosition ( pos . add ( - 0 . 5f , 0 . 7f , - 0 . 5f ) ) ;
2020-08-03 21:42:43 +00:00
2022-05-26 23:57:45 +00:00
LevelSoundEventPacket soundEventPacket = new LevelSoundEventPacket ( ) ;
soundEventPacket . setSound ( SoundEvent . EXTINGUISH_FIRE ) ;
soundEventPacket . setPosition ( pos ) ;
soundEventPacket . setIdentifier ( " " ) ;
soundEventPacket . setExtraData ( - 1 ) ;
soundEventPacket . setBabySound ( false ) ;
soundEventPacket . setRelativeVolumeDisabled ( false ) ;
session . sendUpstreamPacket ( soundEventPacket ) ;
}
case BLOCK_REDSTONE_TORCH_BURNOUT - > {
2022-10-30 03:02:11 +00:00
effectPacket . setType ( org . cloudburstmc . protocol . bedrock . data . LevelEvent . PARTICLE_EVAPORATE ) ;
2022-05-26 23:57:45 +00:00
effectPacket . setPosition ( pos . add ( - 0 . 5f , 0 , - 0 . 5f ) ) ;
2020-05-04 04:56:07 +00:00
2022-05-26 23:57:45 +00:00
LevelSoundEventPacket soundEventPacket = new LevelSoundEventPacket ( ) ;
soundEventPacket . setSound ( SoundEvent . EXTINGUISH_FIRE ) ;
soundEventPacket . setPosition ( pos ) ;
soundEventPacket . setIdentifier ( " " ) ;
soundEventPacket . setExtraData ( - 1 ) ;
soundEventPacket . setBabySound ( false ) ;
soundEventPacket . setRelativeVolumeDisabled ( false ) ;
session . sendUpstreamPacket ( soundEventPacket ) ;
}
case BLOCK_END_PORTAL_FRAME_FILL - > {
2022-10-30 03:02:11 +00:00
effectPacket . setType ( org . cloudburstmc . protocol . bedrock . data . LevelEvent . PARTICLE_EVAPORATE ) ;
2022-05-26 23:57:45 +00:00
effectPacket . setPosition ( pos . add ( - 0 . 5f , 0 . 3125f , - 0 . 5f ) ) ;
2020-08-03 21:42:43 +00:00
2022-05-26 23:57:45 +00:00
LevelSoundEventPacket soundEventPacket = new LevelSoundEventPacket ( ) ;
soundEventPacket . setSound ( SoundEvent . BLOCK_END_PORTAL_FRAME_FILL ) ;
soundEventPacket . setPosition ( pos ) ;
soundEventPacket . setIdentifier ( " " ) ;
soundEventPacket . setExtraData ( - 1 ) ;
soundEventPacket . setBabySound ( false ) ;
soundEventPacket . setRelativeVolumeDisabled ( false ) ;
session . sendUpstreamPacket ( soundEventPacket ) ;
}
case SMOKE - > {
2022-10-30 03:02:11 +00:00
effectPacket . setType ( org . cloudburstmc . protocol . bedrock . data . LevelEvent . PARTICLE_SHOOT ) ;
2020-08-03 21:42:43 +00:00
2022-05-26 23:57:45 +00:00
SmokeEventData smokeEventData = ( SmokeEventData ) packet . getData ( ) ;
int data = 0 ;
2023-03-11 01:51:51 +00:00
switch ( smokeEventData . getDirection ( ) ) {
2022-05-26 23:57:45 +00:00
case DOWN - > {
data = 4 ;
pos = pos . add ( 0 , - 0 . 9f , 0 ) ;
}
case UP - > {
data = 4 ;
pos = pos . add ( 0 , 0 . 5f , 0 ) ;
}
case NORTH - > {
data = 1 ;
pos = pos . add ( 0 , - 0 . 2f , - 0 . 7f ) ;
}
case SOUTH - > {
data = 7 ;
pos = pos . add ( 0 , - 0 . 2f , 0 . 7f ) ;
}
case WEST - > {
data = 3 ;
pos = pos . add ( - 0 . 7f , - 0 . 2f , 0 ) ;
}
case EAST - > {
data = 5 ;
pos = pos . add ( 0 . 7f , - 0 . 2f , 0 ) ;
2020-08-03 21:42:43 +00:00
}
}
2022-05-26 23:57:45 +00:00
effectPacket . setPosition ( pos ) ;
effectPacket . setData ( data ) ;
}
2021-09-10 18:10:56 +00:00
2022-05-26 23:57:45 +00:00
//TODO: Block break particles when under fire
case BREAK_BLOCK - > {
2022-10-30 03:02:11 +00:00
effectPacket . setType ( org . cloudburstmc . protocol . bedrock . data . LevelEvent . PARTICLE_DESTROY_BLOCK ) ;
2020-08-03 21:42:43 +00:00
2022-05-26 23:57:45 +00:00
BreakBlockEventData breakBlockEventData = ( BreakBlockEventData ) packet . getData ( ) ;
effectPacket . setData ( session . getBlockMappings ( ) . getBedrockBlockId ( breakBlockEventData . getBlockState ( ) ) ) ;
}
case BREAK_SPLASH_POTION , BREAK_SPLASH_POTION2 - > {
2022-10-30 03:02:11 +00:00
effectPacket . setType ( org . cloudburstmc . protocol . bedrock . data . LevelEvent . PARTICLE_POTION_SPLASH ) ;
2022-05-26 23:57:45 +00:00
effectPacket . setPosition ( pos . add ( 0 , - 0 . 5f , 0 ) ) ;
2020-08-03 21:42:43 +00:00
2022-05-26 23:57:45 +00:00
BreakPotionEventData splashPotionData = ( BreakPotionEventData ) packet . getData ( ) ;
effectPacket . setData ( splashPotionData . getPotionId ( ) ) ;
2020-08-03 21:42:43 +00:00
2022-05-26 23:57:45 +00:00
LevelSoundEventPacket soundEventPacket = new LevelSoundEventPacket ( ) ;
soundEventPacket . setSound ( SoundEvent . GLASS ) ;
soundEventPacket . setPosition ( pos ) ;
soundEventPacket . setIdentifier ( " " ) ;
soundEventPacket . setExtraData ( - 1 ) ;
soundEventPacket . setBabySound ( false ) ;
soundEventPacket . setRelativeVolumeDisabled ( false ) ;
session . sendUpstreamPacket ( soundEventPacket ) ;
}
2022-10-30 03:02:11 +00:00
case BREAK_EYE_OF_ENDER - > effectPacket . setType ( org . cloudburstmc . protocol . bedrock . data . LevelEvent . PARTICLE_EYE_OF_ENDER_DEATH ) ;
case MOB_SPAWN - > effectPacket . setType ( org . cloudburstmc . protocol . bedrock . data . LevelEvent . PARTICLE_MOB_BLOCK_SPAWN ) ; // TODO: Check, but I don't think I really verified this ever went into effect on Java
2022-05-26 23:57:45 +00:00
case BONEMEAL_GROW_WITH_SOUND , BONEMEAL_GROW - > {
2023-05-03 15:01:31 +00:00
effectPacket . setType ( levelEvent = = LevelEventType . BONEMEAL_GROW ? org . cloudburstmc . protocol . bedrock . data . LevelEvent . PARTICLE_TURTLE_EGG : org . cloudburstmc . protocol . bedrock . data . LevelEvent . PARTICLE_CROP_GROWTH ) ;
2020-08-03 21:42:43 +00:00
2022-05-26 23:57:45 +00:00
BonemealGrowEventData growEventData = ( BonemealGrowEventData ) packet . getData ( ) ;
effectPacket . setData ( growEventData . getParticleCount ( ) ) ;
}
2023-09-29 21:14:49 +00:00
case EGG_CRACK - > effectPacket . setType ( ParticleType . VILLAGER_HAPPY ) ; // both the lil green sparkle
2022-05-26 23:57:45 +00:00
case ENDERDRAGON_FIREBALL_EXPLODE - > {
2022-10-30 03:02:11 +00:00
effectPacket . setType ( org . cloudburstmc . protocol . bedrock . data . LevelEvent . PARTICLE_EYE_OF_ENDER_DEATH ) ; // TODO
2020-08-03 21:42:43 +00:00
2022-05-26 23:57:45 +00:00
DragonFireballEventData fireballEventData = ( DragonFireballEventData ) packet . getData ( ) ;
if ( fireballEventData = = DragonFireballEventData . HAS_SOUND ) {
2020-08-03 21:42:43 +00:00
LevelSoundEventPacket soundEventPacket = new LevelSoundEventPacket ( ) ;
soundEventPacket . setSound ( SoundEvent . EXPLODE ) ;
soundEventPacket . setPosition ( pos ) ;
soundEventPacket . setIdentifier ( " " ) ;
soundEventPacket . setExtraData ( - 1 ) ;
soundEventPacket . setBabySound ( false ) ;
soundEventPacket . setRelativeVolumeDisabled ( false ) ;
session . sendUpstreamPacket ( soundEventPacket ) ;
2021-06-16 23:09:35 +00:00
}
2020-04-23 04:40:49 +00:00
}
2022-05-26 23:57:45 +00:00
case EXPLOSION - > {
2022-10-30 03:02:11 +00:00
effectPacket . setType ( org . cloudburstmc . protocol . bedrock . data . LevelEvent . PARTICLE_GENERIC_SPAWN ) ;
2022-05-26 23:57:45 +00:00
effectPacket . setData ( 61 ) ;
}
case EVAPORATE - > {
2022-10-30 03:02:11 +00:00
effectPacket . setType ( org . cloudburstmc . protocol . bedrock . data . LevelEvent . PARTICLE_EVAPORATE_WATER ) ;
2022-05-26 23:57:45 +00:00
effectPacket . setPosition ( pos . add ( - 0 . 5f , 0 . 5f , - 0 . 5f ) ) ;
}
case END_GATEWAY_SPAWN - > {
2022-10-30 03:02:11 +00:00
effectPacket . setType ( org . cloudburstmc . protocol . bedrock . data . LevelEvent . PARTICLE_EXPLOSION ) ;
2022-05-26 23:57:45 +00:00
LevelSoundEventPacket soundEventPacket = new LevelSoundEventPacket ( ) ;
soundEventPacket . setSound ( SoundEvent . EXPLODE ) ;
soundEventPacket . setPosition ( pos ) ;
soundEventPacket . setIdentifier ( " " ) ;
soundEventPacket . setExtraData ( - 1 ) ;
soundEventPacket . setBabySound ( false ) ;
soundEventPacket . setRelativeVolumeDisabled ( false ) ;
session . sendUpstreamPacket ( soundEventPacket ) ;
}
2022-10-30 03:02:11 +00:00
case DRIPSTONE_DRIP - > effectPacket . setType ( org . cloudburstmc . protocol . bedrock . data . LevelEvent . PARTICLE_DRIPSTONE_DRIP ) ;
case ELECTRIC_SPARK - > effectPacket . setType ( org . cloudburstmc . protocol . bedrock . data . LevelEvent . PARTICLE_ELECTRIC_SPARK ) ; // Matches with a Bedrock server but doesn't seem to match up with Java
case WAX_ON - > effectPacket . setType ( org . cloudburstmc . protocol . bedrock . data . LevelEvent . PARTICLE_WAX_ON ) ;
case WAX_OFF - > effectPacket . setType ( org . cloudburstmc . protocol . bedrock . data . LevelEvent . PARTICLE_WAX_OFF ) ;
case SCRAPE - > effectPacket . setType ( org . cloudburstmc . protocol . bedrock . data . LevelEvent . PARTICLE_SCRAPE ) ;
2022-05-27 15:54:38 +00:00
case SCULK_BLOCK_CHARGE - > {
SculkBlockChargeEventData eventData = ( SculkBlockChargeEventData ) packet . getData ( ) ;
LevelEventGenericPacket levelEventPacket = new LevelEventGenericPacket ( ) ;
// TODO add SCULK_BLOCK_CHARGE sound
if ( eventData . getCharge ( ) > 0 ) {
2022-12-21 00:47:45 +00:00
levelEventPacket . setType ( org . cloudburstmc . protocol . bedrock . data . LevelEvent . SCULK_CHARGE ) ;
2022-05-27 15:54:38 +00:00
levelEventPacket . setTag (
NbtMap . builder ( )
. putInt ( " x " , packet . getPosition ( ) . getX ( ) )
. putInt ( " y " , packet . getPosition ( ) . getY ( ) )
. putInt ( " z " , packet . getPosition ( ) . getZ ( ) )
. putShort ( " charge " , ( short ) eventData . getCharge ( ) )
. putShort ( " facing " , encodeFacing ( eventData . getBlockFaces ( ) ) ) // TODO check if this is actually correct
. build ( )
) ;
} else {
2022-12-21 00:47:45 +00:00
levelEventPacket . setType ( org . cloudburstmc . protocol . bedrock . data . LevelEvent . SCULK_CHARGE_POP ) ;
2022-05-27 15:54:38 +00:00
levelEventPacket . setTag (
NbtMap . builder ( )
. putInt ( " x " , packet . getPosition ( ) . getX ( ) )
. putInt ( " y " , packet . getPosition ( ) . getY ( ) )
. putInt ( " z " , packet . getPosition ( ) . getZ ( ) )
. build ( )
) ;
2020-04-23 04:40:49 +00:00
}
2022-05-27 15:54:38 +00:00
session . sendUpstreamPacket ( levelEventPacket ) ;
return ;
}
case SCULK_SHRIEKER_SHRIEK - > {
LevelEventGenericPacket levelEventPacket = new LevelEventGenericPacket ( ) ;
2022-12-21 00:47:45 +00:00
levelEventPacket . setType ( org . cloudburstmc . protocol . bedrock . data . LevelEvent . PARTICLE_SCULK_SHRIEK ) ;
2022-05-27 15:54:38 +00:00
levelEventPacket . setTag (
NbtMap . builder ( )
. putInt ( " originX " , packet . getPosition ( ) . getX ( ) )
. putInt ( " originY " , packet . getPosition ( ) . getY ( ) )
. putInt ( " originZ " , packet . getPosition ( ) . getZ ( ) )
. build ( )
) ;
session . sendUpstreamPacket ( levelEventPacket ) ;
LevelSoundEventPacket soundEventPacket = new LevelSoundEventPacket ( ) ;
soundEventPacket . setSound ( SoundEvent . SCULK_SHRIEKER_SHRIEK ) ;
soundEventPacket . setPosition ( packet . getPosition ( ) . toFloat ( ) ) ;
soundEventPacket . setExtraData ( - 1 ) ;
soundEventPacket . setIdentifier ( " " ) ;
soundEventPacket . setBabySound ( false ) ;
soundEventPacket . setRelativeVolumeDisabled ( false ) ;
session . sendUpstreamPacket ( soundEventPacket ) ;
return ;
2020-04-23 04:40:49 +00:00
}
2023-04-27 17:09:38 +00:00
case STOP_RECORD - > {
LevelSoundEventPacket levelSoundEvent = new LevelSoundEventPacket ( ) ;
levelSoundEvent . setIdentifier ( " " ) ;
levelSoundEvent . setSound ( SoundEvent . STOP_RECORD ) ;
levelSoundEvent . setPosition ( pos ) ;
levelSoundEvent . setRelativeVolumeDisabled ( false ) ;
levelSoundEvent . setExtraData ( - 1 ) ;
levelSoundEvent . setBabySound ( false ) ;
session . sendUpstreamPacket ( levelSoundEvent ) ;
return ;
}
2022-05-26 23:57:45 +00:00
default - > {
GeyserImpl . getInstance ( ) . getLogger ( ) . debug ( " Unhandled level event: " + packet . getEvent ( ) ) ;
return ;
}
2020-04-23 04:40:49 +00:00
}
2022-05-26 23:57:45 +00:00
session . sendUpstreamPacket ( effectPacket ) ;
2020-04-23 04:40:49 +00:00
}
2022-05-27 15:54:38 +00:00
private short encodeFacing ( Set < Direction > blockFaces ) {
short facing = 0 ;
if ( blockFaces . contains ( Direction . DOWN ) ) {
facing | = 1 ;
}
if ( blockFaces . contains ( Direction . UP ) ) {
facing | = 1 < < 1 ;
}
if ( blockFaces . contains ( Direction . SOUTH ) ) {
facing | = 1 < < 2 ;
}
if ( blockFaces . contains ( Direction . WEST ) ) {
facing | = 1 < < 3 ;
}
if ( blockFaces . contains ( Direction . NORTH ) ) {
facing | = 1 < < 4 ;
}
if ( blockFaces . contains ( Direction . EAST ) ) {
facing | = 1 < < 5 ;
2020-04-23 04:40:49 +00:00
}
2022-05-27 15:54:38 +00:00
return facing ;
2020-04-23 04:40:49 +00:00
}
}