mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Recreate the death smoke particles to work around double death noises
Fixes #2363
This commit is contained in:
parent
1c11a2ef01
commit
881352daaf
1 changed files with 25 additions and 2 deletions
|
@ -26,14 +26,15 @@
|
||||||
package org.geysermc.geyser.translator.protocol.java.entity;
|
package org.geysermc.geyser.translator.protocol.java.entity;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundEntityEventPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundEntityEventPacket;
|
||||||
|
import com.nukkitx.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.LevelEventType;
|
import com.nukkitx.protocol.bedrock.data.LevelEventType;
|
||||||
import com.nukkitx.protocol.bedrock.data.SoundEvent;
|
import com.nukkitx.protocol.bedrock.data.SoundEvent;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityEventType;
|
import com.nukkitx.protocol.bedrock.data.entity.EntityEventType;
|
||||||
import com.nukkitx.protocol.bedrock.data.inventory.ItemData;
|
import com.nukkitx.protocol.bedrock.data.inventory.ItemData;
|
||||||
import com.nukkitx.protocol.bedrock.packet.*;
|
import com.nukkitx.protocol.bedrock.packet.*;
|
||||||
import org.geysermc.geyser.entity.type.Entity;
|
|
||||||
import org.geysermc.geyser.entity.EntityDefinitions;
|
import org.geysermc.geyser.entity.EntityDefinitions;
|
||||||
|
import org.geysermc.geyser.entity.type.Entity;
|
||||||
import org.geysermc.geyser.entity.type.EvokerFangsEntity;
|
import org.geysermc.geyser.entity.type.EvokerFangsEntity;
|
||||||
import org.geysermc.geyser.entity.type.FishingHookEntity;
|
import org.geysermc.geyser.entity.type.FishingHookEntity;
|
||||||
import org.geysermc.geyser.entity.type.LivingEntity;
|
import org.geysermc.geyser.entity.type.LivingEntity;
|
||||||
|
@ -41,6 +42,7 @@ import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||||
import org.geysermc.geyser.translator.protocol.Translator;
|
import org.geysermc.geyser.translator.protocol.Translator;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
@Translator(packet = ClientboundEntityEventPacket.class)
|
@Translator(packet = ClientboundEntityEventPacket.class)
|
||||||
|
@ -234,7 +236,28 @@ public class JavaEntityEventTranslator extends PacketTranslator<ClientboundEntit
|
||||||
break;
|
break;
|
||||||
case MAKE_POOF_PARTICLES:
|
case MAKE_POOF_PARTICLES:
|
||||||
if (entity instanceof LivingEntity) {
|
if (entity instanceof LivingEntity) {
|
||||||
entityEventPacket.setType(EntityEventType.DEATH_SMOKE_CLOUD);
|
// Not ideal, but...
|
||||||
|
// LevelEventType.PARTICLE_DEATH_SMOKE doesn't work (as of 1.18.2 Bedrock)
|
||||||
|
// EntityEventType.DEATH_SMOKE_CLOUD also plays the entity noise
|
||||||
|
// I wasn't able to figure out how the vanilla Bedrock server does it,
|
||||||
|
// but it appears to use neither of these.
|
||||||
|
Vector3f position = entity.getPosition();
|
||||||
|
float baseX = position.getX();
|
||||||
|
float baseY = position.getY();
|
||||||
|
float baseZ = position.getZ();
|
||||||
|
float height = entity.getDefinition().height();
|
||||||
|
float width = entity.getDefinition().width();
|
||||||
|
Random random = ThreadLocalRandom.current();
|
||||||
|
for (int i = 0; i < 20; i++) {
|
||||||
|
// Reconstruct the Java Edition (1.18.1) logic, but in floats
|
||||||
|
float x = baseX + width * (2.0f * random.nextFloat() - 1f);
|
||||||
|
float y = baseY + height * random.nextFloat();
|
||||||
|
float z = baseZ + width * (2.0f * random.nextFloat() - 1f);
|
||||||
|
LevelEventPacket levelEventPacket = new LevelEventPacket();
|
||||||
|
levelEventPacket.setPosition(Vector3f.from(x, y, z));
|
||||||
|
levelEventPacket.setType(LevelEventType.PARTICLE_EXPLODE);
|
||||||
|
//session.sendUpstreamPacket(levelEventPacket);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue