mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-12-22 14:34:59 +01:00
Replace particle explosion with particle block explosion in JavaExplodePacket (#3301)
This commit is contained in:
parent
d2b7b8c392
commit
2c5c72f85f
5 changed files with 22 additions and 15 deletions
|
@ -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"
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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<ClientboundExplodePa
|
|||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ClientboundExplodePacket packet) {
|
||||
LevelEventGenericPacket levelEventPacket = new LevelEventGenericPacket();
|
||||
levelEventPacket.setEventId(2026/*LevelEventType.PARTICLE_BLOCK_EXPLOSION*/);
|
||||
NbtMapBuilder builder = NbtMap.builder();
|
||||
builder.putFloat("originX", packet.getX());
|
||||
builder.putFloat("originY", packet.getY());
|
||||
builder.putFloat("originZ", packet.getZ());
|
||||
builder.putFloat("radius", packet.getRadius());
|
||||
builder.putInt("size", packet.getExploded().size());
|
||||
int i = 0;
|
||||
for (Vector3i position : packet.getExploded()) {
|
||||
Vector3i pos = Vector3i.from(packet.getX() + position.getX(), packet.getY() + position.getY(), packet.getZ() + position.getZ());
|
||||
ChunkUtils.updateBlock(session, BlockStateValues.JAVA_AIR_ID, pos);
|
||||
builder.putFloat("pos" + i + "x", pos.getX());
|
||||
builder.putFloat("pos" + i + "y", pos.getY());
|
||||
builder.putFloat("pos" + i + "z", pos.getZ());
|
||||
i++;
|
||||
}
|
||||
|
||||
Vector3f pos = Vector3f.from(packet.getX(), packet.getY(), packet.getZ());
|
||||
// Since bedrock does not play an explosion sound and particles sound, we have to manually do so
|
||||
LevelEventPacket levelEventPacket = new LevelEventPacket();
|
||||
levelEventPacket.setType(packet.getRadius() >= 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);
|
||||
|
|
|
@ -263,7 +263,7 @@ public class JavaLevelEventTranslator extends PacketTranslator<ClientboundLevelE
|
|||
LevelEventGenericPacket levelEventPacket = new LevelEventGenericPacket();
|
||||
// TODO add SCULK_BLOCK_CHARGE sound
|
||||
if (eventData.getCharge() > 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<ClientboundLevelE
|
|||
.build()
|
||||
);
|
||||
} else {
|
||||
levelEventPacket.setEventId(2038);
|
||||
levelEventPacket.setEventId(2038/*LevelEventType.SCULK_CHARGE_POP*/);
|
||||
levelEventPacket.setTag(
|
||||
NbtMap.builder()
|
||||
.putInt("x", packet.getPosition().getX())
|
||||
|
@ -288,7 +288,7 @@ public class JavaLevelEventTranslator extends PacketTranslator<ClientboundLevelE
|
|||
}
|
||||
case SCULK_SHRIEKER_SHRIEK -> {
|
||||
LevelEventGenericPacket levelEventPacket = new LevelEventGenericPacket();
|
||||
levelEventPacket.setEventId(2035);
|
||||
levelEventPacket.setEventId(2035/*LevelEventType.PARTICLE_SCULK_SHRIEK*/);
|
||||
levelEventPacket.setTag(
|
||||
NbtMap.builder()
|
||||
.putInt("originX", packet.getPosition().getX())
|
||||
|
|
|
@ -157,7 +157,7 @@ public class JavaLevelParticlesTranslator extends PacketTranslator<ClientboundLe
|
|||
|
||||
return (position) -> {
|
||||
LevelEventGenericPacket packet = new LevelEventGenericPacket();
|
||||
packet.setEventId(2027);
|
||||
packet.setEventId(2027/*LevelEventType.PARTICLE_VIBRATION_SIGNAL*/);
|
||||
packet.setTag(
|
||||
NbtMap.builder()
|
||||
.putCompound("origin", buildVec3PositionTag(position))
|
||||
|
|
Loading…
Reference in a new issue