Update effects mappings (#949)

* Update effects mappings

* Use STOP_RECORD as the default record instead of null

* Add comments

* Update mappings submodule

* Update MCProtocolLib and effects

* Change level event used for EVAPORATE effect

The bedrock client plays an additional sound when using CAULDRON_EXPLODE.
The java client does not play any sound.

* Update mappings submodule
This commit is contained in:
AJ Ferguson 2020-08-03 13:42:43 -08:00 committed by GitHub
parent 11c713dc6f
commit 61dbcb0c80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 489 additions and 130 deletions

View file

@ -105,7 +105,7 @@
<dependency>
<groupId>com.github.steveice10</groupId>
<artifactId>mcprotocollib</artifactId>
<version>46b46001f6</version>
<version>f03b176e18</version>
<scope>compile</scope>
<exclusions>
<exclusion>

View file

@ -25,19 +25,18 @@
package org.geysermc.connector.network.translators.effect;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
public class Effect {
private String javaName;
private String bedrockName;
private String type;
private int data;
private String identifier;
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerPlayEffectPacket;
import org.geysermc.connector.network.session.GeyserSession;
/**
* Represents an effect capable of translating itself into bedrock
*/
public interface Effect {
/**
* Translates the given {@link ServerPlayEffectPacket} into bedrock and sends it upstream.
*
* @param session GeyserSession
* @param packet the effect packet to handle
*/
void handleEffectPacket(GeyserSession session, ServerPlayEffectPacket packet);
}

View file

@ -26,6 +26,7 @@
package org.geysermc.connector.network.translators.effect;
import com.fasterxml.jackson.databind.JsonNode;
import com.github.steveice10.mc.protocol.data.game.world.effect.SoundEffect;
import com.github.steveice10.mc.protocol.data.game.world.particle.ParticleType;
import com.nukkitx.protocol.bedrock.data.LevelEventType;
import com.nukkitx.protocol.bedrock.data.SoundEvent;
@ -46,7 +47,7 @@ import java.util.Map;
*/
public class EffectRegistry {
public static final Map<String, Effect> EFFECTS = new HashMap<>();
public static final Map<SoundEffect, Effect> SOUND_EFFECTS = new HashMap<>();
public static final Int2ObjectMap<SoundEvent> RECORDS = new Int2ObjectOpenHashMap<>();
private static Map<ParticleType, LevelEventType> particleTypeMap = new HashMap<>();
@ -97,19 +98,54 @@ public class EffectRegistry {
Iterator<Map.Entry<String, JsonNode>> effectsIterator = effects.fields();
while (effectsIterator.hasNext()) {
Map.Entry<String, JsonNode> entry = effectsIterator.next();
// Separate records database since they're handled differently between the two versions
if (entry.getValue().has("records")) {
JsonNode node = entry.getValue();
try {
String type = node.get("type").asText();
SoundEffect javaEffect = null;
Effect effect = null;
switch (type) {
case "soundLevel": {
javaEffect = SoundEffect.valueOf(entry.getKey());
LevelEventType levelEventType = LevelEventType.valueOf(node.get("name").asText());
int data = node.has("data") ? node.get("data").intValue() : 0;
effect = new SoundLevelEffect(levelEventType, data);
break;
}
case "soundEvent": {
javaEffect = SoundEffect.valueOf(entry.getKey());
SoundEvent soundEvent = SoundEvent.valueOf(node.get("name").asText());
String identifier = node.has("identifier") ? node.get("identifier").asText() : "";
int extraData = node.has("extraData") ? node.get("extraData").intValue() : -1;
effect = new SoundEventEffect(soundEvent, identifier, extraData);
break;
}
case "playSound": {
javaEffect = SoundEffect.valueOf(entry.getKey());
String name = node.get("name").asText();
float volume = node.has("volume") ? node.get("volume").floatValue() : 1.0f;
boolean pitchSub = node.has("pitch_sub") ? node.get("pitch_sub").booleanValue() : false;
float pitchMul = node.has("pitch_mul") ? node.get("pitch_mul").floatValue() : 1.0f;
float pitchAdd = node.has("pitch_add") ? node.get("pitch_add").floatValue() : 0.0f;
boolean relative = node.has("relative") ? node.get("relative").booleanValue() : true;
effect = new PlaySoundEffect(name, volume, pitchSub, pitchMul, pitchAdd, relative);
break;
}
case "record": {
JsonNode records = entry.getValue().get("records");
Iterator<Map.Entry<String, JsonNode>> recordsIterator = records.fields();
while (recordsIterator.hasNext()) {
Map.Entry<String, JsonNode> recordEntry = recordsIterator.next();
RECORDS.put(Integer.parseInt(recordEntry.getKey()), SoundEvent.valueOf(recordEntry.getValue().asText()));
}
break;
}
}
if (javaEffect != null) {
SOUND_EFFECTS.put(javaEffect, effect);
}
} catch (Exception e) {
GeyserConnector.getInstance().getLogger().warning("Failed to map sound effect " + entry.getKey() + " : " + e.toString());
}
String identifier = (entry.getValue().has("identifier")) ? entry.getValue().get("identifier").asText() : "";
int data = (entry.getValue().has("data")) ? entry.getValue().get("data").asInt() : -1;
Effect effect = new Effect(entry.getKey(), entry.getValue().get("name").asText(), entry.getValue().get("type").asText(), data, identifier);
EFFECTS.put(entry.getKey(), effect);
}
}

View file

@ -0,0 +1,81 @@
/*
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* 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
*
*/
package org.geysermc.connector.network.translators.effect;
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerPlayEffectPacket;
import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.protocol.bedrock.packet.PlaySoundPacket;
import lombok.Value;
import org.geysermc.connector.network.session.GeyserSession;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
@Value
public class PlaySoundEffect implements Effect {
/**
* Bedrock playsound identifier
*/
String name;
/**
* Volume of the sound
*/
float volume;
/**
* If true, the initial value used for random pitch is the difference between two random floats.
* If false, it is a single random float
*/
boolean pitchSub;
/**
* Multiplier for random pitch value
*/
float pitchMul;
/**
* Constant addition to random pitch value after multiplier
*/
float pitchAdd;
/**
* True if the sound is meant to be played in 3d space
*/
boolean relative;
@Override
public void handleEffectPacket(GeyserSession session, ServerPlayEffectPacket packet) {
Random rand = ThreadLocalRandom.current();
PlaySoundPacket playSoundPacket = new PlaySoundPacket();
playSoundPacket.setSound(name);
playSoundPacket.setPosition(!relative ? session.getPlayerEntity().getPosition() : Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ()).add(0.5f, 0.5f, 0.5f));
playSoundPacket.setVolume(volume);
playSoundPacket.setPitch((pitchSub ? (rand.nextFloat() - rand.nextFloat()) : rand.nextFloat()) * pitchMul + pitchAdd); //replicates java client randomness
session.sendUpstreamPacket(playSoundPacket);
}
}

View file

@ -0,0 +1,64 @@
/*
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* 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
*
*/
package org.geysermc.connector.network.translators.effect;
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerPlayEffectPacket;
import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.protocol.bedrock.data.SoundEvent;
import com.nukkitx.protocol.bedrock.packet.LevelSoundEventPacket;
import lombok.Value;
import org.geysermc.connector.network.session.GeyserSession;
@Value
public class SoundEventEffect implements Effect {
/**
* Bedrock sound event
*/
SoundEvent soundEvent;
/**
* Entity identifier. Usually an empty string
*/
String identifier;
/**
* Extra data. Usually -1
*/
int extraData;
@Override
public void handleEffectPacket(GeyserSession session, ServerPlayEffectPacket packet) {
LevelSoundEventPacket levelSoundEvent = new LevelSoundEventPacket();
levelSoundEvent.setSound(soundEvent);
levelSoundEvent.setIdentifier(identifier);
levelSoundEvent.setExtraData(extraData);
levelSoundEvent.setRelativeVolumeDisabled(packet.isBroadcast());
levelSoundEvent.setPosition(Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ()).add(0.5f, 0.5f, 0.5f));
levelSoundEvent.setBabySound(false);
session.sendUpstreamPacket(levelSoundEvent);
}
}

View file

@ -0,0 +1,56 @@
/*
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* 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
*
*/
package org.geysermc.connector.network.translators.effect;
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerPlayEffectPacket;
import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.protocol.bedrock.data.LevelEventType;
import com.nukkitx.protocol.bedrock.packet.LevelEventPacket;
import lombok.Value;
import org.geysermc.connector.network.session.GeyserSession;
@Value
public class SoundLevelEffect implements Effect {
/**
* Bedrock level event type
*/
LevelEventType levelEventType;
/**
* Event data. Usually 0
*/
int data;
@Override
public void handleEffectPacket(GeyserSession session, ServerPlayEffectPacket packet) {
LevelEventPacket eventPacket = new LevelEventPacket();
eventPacket.setType(levelEventType);
eventPacket.setData(data);
eventPacket.setPosition(Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ()).add(0.5f, 0.5f, 0.5f));
session.sendUpstreamPacket(eventPacket);
}
}

View file

@ -45,93 +45,29 @@ import org.geysermc.connector.utils.LocaleUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
@Translator(packet = ServerPlayEffectPacket.class)
public class JavaPlayEffectTranslator extends PacketTranslator<ServerPlayEffectPacket> {
// TODO: Update mappings since they're definitely all going to be wrong now
@Override
public void translate(ServerPlayEffectPacket packet, GeyserSession session) {
LevelEventPacket effect = new LevelEventPacket();
// Some things here are particles, others are not
if (packet.getEffect() instanceof ParticleEffect) {
ParticleEffect particleEffect = (ParticleEffect) packet.getEffect();
Effect geyserEffect = EffectRegistry.EFFECTS.get(particleEffect.name());
if (geyserEffect != null) {
String name = geyserEffect.getBedrockName();
effect.setType(LevelEventType.valueOf(name));
} else {
switch (particleEffect) {
// TODO: BREAK_SPLASH_POTION has additional data
case BONEMEAL_GROW:
effect.setType(LevelEventType.PARTICLE_CROP_GROWTH);
BonemealGrowEffectData growEffectData = (BonemealGrowEffectData) packet.getData();
effect.setData(growEffectData.getParticleCount());
break;
//TODO: Block break particles when under fire
case BREAK_BLOCK:
effect.setType(LevelEventType.PARTICLE_DESTROY_BLOCK); // TODO: Check to make sure this is right
BreakBlockEffectData breakBlockEffectData = (BreakBlockEffectData) packet.getData();
effect.setData(BlockTranslator.getBedrockBlockId(breakBlockEffectData.getBlockState()));
break;
case EXPLOSION:
effect.setType(LevelEventType.PARTICLE_EXPLOSION);
break;
case MOB_SPAWN:
effect.setType(LevelEventType.PARTICLE_MOB_BLOCK_SPAWN); // TODO: Check, but I don't think I really verified this ever went into effect on Java
break;
// Done with a dispenser
case SMOKE:
// Might need to be SHOOT
effect.setType(LevelEventType.PARTICLE_SMOKE);
break;
case COMPOSTER:
effect.setType(LevelEventType.PARTICLE_CROP_GROWTH);
ComposterEffectData composterEffectData = (ComposterEffectData) packet.getData();
LevelSoundEventPacket soundEvent = new LevelSoundEventPacket();
soundEvent.setSound(SoundEvent.valueOf("COMPOSTER_" + composterEffectData.name()));
soundEvent.setPosition(Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ()));
soundEvent.setIdentifier(":");
soundEvent.setExtraData(-1);
soundEvent.setBabySound(false);
soundEvent.setRelativeVolumeDisabled(false);
session.sendUpstreamPacket(soundEvent);
break;
case BLOCK_LAVA_EXTINGUISH:
effect.setType(LevelEventType.PARTICLE_SHOOT);
effect.setPosition(Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY() + 1, packet.getPosition().getZ()));
session.sendUpstreamPacket(effect);
LevelSoundEventPacket soundEventPacket = new LevelSoundEventPacket();
soundEventPacket.setSound(SoundEvent.EXTINGUISH_FIRE);
soundEventPacket.setPosition(Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ()));
soundEventPacket.setIdentifier(":");
soundEventPacket.setExtraData(-1);
soundEventPacket.setBabySound(false);
soundEventPacket.setRelativeVolumeDisabled(false);
session.sendUpstreamPacket(soundEventPacket);
return;
default:
GeyserConnector.getInstance().getLogger().debug("No effect handling for particle effect: " + packet.getEffect());
}
}
effect.setPosition(Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ()));
session.sendUpstreamPacket(effect);
} else if (packet.getEffect() instanceof SoundEffect) {
SoundEffect soundEffect = (SoundEffect) packet.getEffect();
Effect geyserEffect = EffectRegistry.EFFECTS.get(soundEffect.name());
if (geyserEffect != null) {
// Some events are LevelEventTypes, some are SoundEvents.
if (geyserEffect.getType().equals("soundLevel")) {
effect.setType(LevelEventType.valueOf(geyserEffect.getBedrockName()));
} else if (geyserEffect.getType().equals("soundEvent")) {
LevelSoundEventPacket soundEvent = new LevelSoundEventPacket();
// Separate case since each RecordEffectData in Java is an individual track in Bedrock
if (geyserEffect.getJavaName().equals("RECORD")) {
if (packet.getEffect() == SoundEffect.RECORD) {
RecordEffectData recordEffectData = (RecordEffectData) packet.getData();
soundEvent.setSound(EffectRegistry.RECORDS.get(recordEffectData.getRecordId()));
if (EffectRegistry.RECORDS.get(recordEffectData.getRecordId()) != SoundEvent.STOP_RECORD) {
SoundEvent soundEvent = EffectRegistry.RECORDS.getOrDefault(recordEffectData.getRecordId(), SoundEvent.STOP_RECORD);
Vector3f pos = Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ()).add(0.5f, 0.5f, 0.5f);
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);
if (soundEvent != SoundEvent.STOP_RECORD) {
// Send text packet as it seems to be handled in Java Edition client-side.
TextPacket textPacket = new TextPacket();
textPacket.setType(TextPacket.Type.JUKEBOX_POPUP);
@ -141,27 +77,214 @@ public class JavaPlayEffectTranslator extends PacketTranslator<ServerPlayEffectP
textPacket.setSourceName(null);
textPacket.setMessage("record.nowPlaying");
List<String> params = new ArrayList<>();
String recordString = "%item." + EffectRegistry.RECORDS.get(recordEffectData.getRecordId()).name().toLowerCase() + ".desc";
String recordString = "%item." + soundEvent.name().toLowerCase(Locale.ROOT) + ".desc";
params.add(LocaleUtils.getLocaleString(recordString, session.getClientData().getLanguageCode()));
textPacket.setParameters(params);
session.sendUpstreamPacket(textPacket);
}
} else {
soundEvent.setSound(SoundEvent.valueOf(geyserEffect.getBedrockName()));
}
soundEvent.setExtraData(geyserEffect.getData());
soundEvent.setIdentifier(geyserEffect.getIdentifier());
soundEvent.setPosition(Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ()));
session.sendUpstreamPacket(soundEvent);
}
} else {
GeyserConnector.getInstance().getLogger().debug("No effect handling for sound effect: " + packet.getEffect());
}
}
if (effect.getType() != null) {
effect.setPosition(Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ()));
session.sendUpstreamPacket(effect);
return;
}
if (packet.getEffect() instanceof SoundEffect) {
SoundEffect soundEffect = (SoundEffect) packet.getEffect();
Effect geyserEffect = EffectRegistry.SOUND_EFFECTS.get(soundEffect);
if (geyserEffect != null) {
geyserEffect.handleEffectPacket(session, packet);
return;
}
GeyserConnector.getInstance().getLogger().debug("Unhandled sound effect: " + soundEffect.name());
} else if (packet.getEffect() instanceof ParticleEffect) {
ParticleEffect particleEffect = (ParticleEffect) packet.getEffect();
Vector3f pos = Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ()).add(0.5f, 0.5f, 0.5f);
LevelEventPacket effectPacket = new LevelEventPacket();
effectPacket.setPosition(pos);
effectPacket.setData(0);
switch (particleEffect) {
case COMPOSTER: {
effectPacket.setType(LevelEventType.PARTICLE_CROP_GROWTH);
ComposterEffectData composterEffectData = (ComposterEffectData) packet.getData();
LevelSoundEventPacket soundEventPacket = new LevelSoundEventPacket();
switch (composterEffectData) {
case FILL:
soundEventPacket.setSound(SoundEvent.COMPOSTER_FILL);
break;
case FILL_SUCCESS:
soundEventPacket.setSound(SoundEvent.COMPOSTER_FILL_LAYER);
break;
}
soundEventPacket.setPosition(pos);
soundEventPacket.setIdentifier("");
soundEventPacket.setExtraData(-1);
soundEventPacket.setBabySound(false);
soundEventPacket.setRelativeVolumeDisabled(false);
session.sendUpstreamPacket(soundEventPacket);
break;
}
case BLOCK_LAVA_EXTINGUISH: {
effectPacket.setType(LevelEventType.PARTICLE_EVAPORATE);
effectPacket.setPosition(pos.add(-0.5f, 0.7f, -0.5f));
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);
break;
}
case BLOCK_REDSTONE_TORCH_BURNOUT: {
effectPacket.setType(LevelEventType.PARTICLE_EVAPORATE);
effectPacket.setPosition(pos.add(-0.5f, 0, -0.5f));
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);
break;
}
case BLOCK_END_PORTAL_FRAME_FILL: {
effectPacket.setType(LevelEventType.PARTICLE_EVAPORATE);
effectPacket.setPosition(pos.add(-0.5f, 0.3125f, -0.5f));
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);
break;
}
case SMOKE: {
effectPacket.setType(LevelEventType.PARTICLE_SHOOT);
SmokeEffectData smokeEffectData = (SmokeEffectData) packet.getData();
int data = 0;
switch (smokeEffectData) {
case DOWN:
data = 4;
pos = pos.add(0, -0.9f, 0);
break;
case UP:
data = 4;
pos = pos.add(0, 0.5f, 0);
break;
case NORTH:
data = 1;
pos = pos.add(0, -0.2f, -0.7f);
break;
case SOUTH:
data = 7;
pos = pos.add(0, -0.2f, 0.7f);
break;
case WEST:
data = 3;
pos = pos.add(-0.7f, -0.2f, 0);
break;
case EAST:
data = 5;
pos = pos.add(0.7f, -0.2f, 0);
break;
}
effectPacket.setPosition(pos);
effectPacket.setData(data);
break;
}
//TODO: Block break particles when under fire
case BREAK_BLOCK: {
effectPacket.setType(LevelEventType.PARTICLE_DESTROY_BLOCK);
BreakBlockEffectData breakBlockEffectData = (BreakBlockEffectData) packet.getData();
effectPacket.setData(BlockTranslator.getBedrockBlockId(breakBlockEffectData.getBlockState()));
break;
}
case BREAK_SPLASH_POTION: {
effectPacket.setType(LevelEventType.PARTICLE_POTION_SPLASH);
effectPacket.setPosition(pos.add(0, -0.5f, 0));
BreakPotionEffectData splashPotionData = (BreakPotionEffectData) packet.getData();
effectPacket.setData(splashPotionData.getPotionId());
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);
break;
}
case BREAK_EYE_OF_ENDER: {
effectPacket.setType(LevelEventType.PARTICLE_EYE_OF_ENDER_DEATH);
break;
}
case MOB_SPAWN: {
effectPacket.setType(LevelEventType.PARTICLE_MOB_BLOCK_SPAWN); // TODO: Check, but I don't think I really verified this ever went into effect on Java
break;
}
case BONEMEAL_GROW: {
effectPacket.setType(LevelEventType.PARTICLE_CROP_GROWTH);
BonemealGrowEffectData growEffectData = (BonemealGrowEffectData) packet.getData();
effectPacket.setData(growEffectData.getParticleCount());
break;
}
case ENDERDRAGON_FIREBALL_EXPLODE: {
effectPacket.setType(LevelEventType.PARTICLE_EYE_OF_ENDER_DEATH); // TODO
DragonFireballEffectData fireballEffectData = (DragonFireballEffectData) packet.getData();
if (fireballEffectData == DragonFireballEffectData.HAS_SOUND) {
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);
}
break;
}
case EXPLOSION: {
effectPacket.setType(LevelEventType.PARTICLE_GENERIC_SPAWN);
effectPacket.setData(61);
break;
}
case EVAPORATE: {
effectPacket.setType(LevelEventType.PARTICLE_EVAPORATE_WATER);
effectPacket.setPosition(pos.add(-0.5f, 0.5f, -0.5f));
break;
}
case END_GATEWAY_SPAWN: {
effectPacket.setType(LevelEventType.PARTICLE_EXPLOSION);
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);
break;
}
default: {
GeyserConnector.getInstance().getLogger().debug("Unhandled particle effect: " + particleEffect.name());
return;
}
}
session.sendUpstreamPacket(effectPacket);
}
}
}

@ -1 +1 @@
Subproject commit 47179bc5ee12cab11370b650ab5f3a641aba1390
Subproject commit 8d6400da19d07085d60c6bbc11b23c1d391c056f