From 2c5c72f85fd1f15beefb26ce1a5794e593f98ca7 Mon Sep 17 00:00:00 2001 From: Kevin Ludwig <32491319+valaphee@users.noreply.github.com> Date: Fri, 23 Sep 2022 16:04:15 +0200 Subject: [PATCH] Replace particle explosion with particle block explosion in JavaExplodePacket (#3301) --- build-logic/src/main/kotlin/Versions.kt | 1 - core/build.gradle.kts | 2 -- .../java/level/JavaExplodeTranslator.java | 26 +++++++++++++------ .../java/level/JavaLevelEventTranslator.java | 6 ++--- .../level/JavaLevelParticlesTranslator.java | 2 +- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/build-logic/src/main/kotlin/Versions.kt b/build-logic/src/main/kotlin/Versions.kt index 47f35726d..d492022ba 100644 --- a/build-logic/src/main/kotlin/Versions.kt +++ b/build-logic/src/main/kotlin/Versions.kt @@ -29,7 +29,6 @@ object Versions { const val nettyVersion = "4.1.80.Final" const val guavaVersion = "29.0-jre" const val gsonVersion = "2.3.1" // Provided by Spigot 1.8.8 - const val nbtVersion = "2.1.0" const val websocketVersion = "1.5.1" const val protocolVersion = "fed46166" const val raknetVersion = "1.6.28-20220125.214016-6" diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 4e8b92fef..1bf227e58 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -16,8 +16,6 @@ dependencies { api("com.fasterxml.jackson.dataformat", "jackson-dataformat-yaml", Versions.jacksonVersion) api("com.google.guava", "guava", Versions.guavaVersion) - api("com.nukkitx", "nbt", Versions.nbtVersion) - // Fastutil Maps implementation("com.nukkitx.fastutil", "fastutil-int-int-maps", Versions.fastutilVersion) implementation("com.nukkitx.fastutil", "fastutil-int-long-maps", Versions.fastutilVersion) diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/level/JavaExplodeTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/level/JavaExplodeTranslator.java index d5ac1abba..51c508e57 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/level/JavaExplodeTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/level/JavaExplodeTranslator.java @@ -28,9 +28,11 @@ package org.geysermc.geyser.translator.protocol.java.level; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundExplodePacket; import com.nukkitx.math.vector.Vector3f; import com.nukkitx.math.vector.Vector3i; +import com.nukkitx.nbt.NbtMap; +import com.nukkitx.nbt.NbtMapBuilder; import com.nukkitx.protocol.bedrock.data.LevelEventType; import com.nukkitx.protocol.bedrock.data.SoundEvent; -import com.nukkitx.protocol.bedrock.packet.LevelEventPacket; +import com.nukkitx.protocol.bedrock.packet.LevelEventGenericPacket; import com.nukkitx.protocol.bedrock.packet.LevelSoundEventPacket; import com.nukkitx.protocol.bedrock.packet.SetEntityMotionPacket; import org.geysermc.geyser.level.block.BlockStateValues; @@ -44,19 +46,27 @@ public class JavaExplodeTranslator extends PacketTranslator= 2.0f ? LevelEventType.PARTICLE_HUGE_EXPLODE : LevelEventType.PARTICLE_EXPLOSION); - levelEventPacket.setData(0); - levelEventPacket.setPosition(pos); + levelEventPacket.setTag(builder.build()); session.sendUpstreamPacket(levelEventPacket); + Vector3f pos = Vector3f.from(packet.getX(), packet.getY(), packet.getZ()); LevelSoundEventPacket levelSoundEventPacket = new LevelSoundEventPacket(); levelSoundEventPacket.setRelativeVolumeDisabled(false); levelSoundEventPacket.setBabySound(false); diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/level/JavaLevelEventTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/level/JavaLevelEventTranslator.java index b9fccc80a..797699e2b 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/level/JavaLevelEventTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/level/JavaLevelEventTranslator.java @@ -263,7 +263,7 @@ public class JavaLevelEventTranslator extends PacketTranslator 0) { - levelEventPacket.setEventId(2037); + levelEventPacket.setEventId(2037/*LevelEventType.SCULK_CHARGE*/); levelEventPacket.setTag( NbtMap.builder() .putInt("x", packet.getPosition().getX()) @@ -274,7 +274,7 @@ public class JavaLevelEventTranslator extends PacketTranslator { LevelEventGenericPacket levelEventPacket = new LevelEventGenericPacket(); - levelEventPacket.setEventId(2035); + levelEventPacket.setEventId(2035/*LevelEventType.PARTICLE_SCULK_SHRIEK*/); levelEventPacket.setTag( NbtMap.builder() .putInt("originX", packet.getPosition().getX()) diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/level/JavaLevelParticlesTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/level/JavaLevelParticlesTranslator.java index c77caadee..94466a1ab 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/level/JavaLevelParticlesTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/level/JavaLevelParticlesTranslator.java @@ -157,7 +157,7 @@ public class JavaLevelParticlesTranslator extends PacketTranslator { LevelEventGenericPacket packet = new LevelEventGenericPacket(); - packet.setEventId(2027); + packet.setEventId(2027/*LevelEventType.PARTICLE_VIBRATION_SIGNAL*/); packet.setTag( NbtMap.builder() .putCompound("origin", buildVec3PositionTag(position))