1
0
mirror of https://github.com/GeyserMC/Geyser.git synced 2026-01-06 15:41:50 +00:00

Translate Warden sonic boom event

Bump Protocol to fix Sonic boom flag
This commit is contained in:
davchoo
2022-05-31 14:58:40 -04:00
parent eb23a46887
commit 365f8cf7e3
4 changed files with 22 additions and 2 deletions

View File

@@ -44,6 +44,8 @@ public class WardenEntity extends MonsterEntity implements Tickable {
private int heartBeatDelay;
private int tickCount;
private int sonicBoomTickDuration;
public WardenEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) {
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
}
@@ -77,5 +79,17 @@ public class WardenEntity extends MonsterEntity implements Tickable {
packet.setVolume((random.nextFloat() - random.nextFloat()) * 0.2f + 1.0f);
session.sendUpstreamPacket(packet);
}
if (--sonicBoomTickDuration == 0) {
setFlag(EntityFlag.SONIC_BOOM, false);
updateBedrockMetadata();
}
}
public void onSonicBoom() {
setFlag(EntityFlag.SONIC_BOOM, true);
updateBedrockMetadata();
sonicBoomTickDuration = 3 * 20;
}
}

View File

@@ -37,6 +37,7 @@ import org.geysermc.geyser.entity.type.Entity;
import org.geysermc.geyser.entity.type.EvokerFangsEntity;
import org.geysermc.geyser.entity.type.FishingHookEntity;
import org.geysermc.geyser.entity.type.LivingEntity;
import org.geysermc.geyser.entity.type.living.monster.WardenEntity;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.protocol.PacketTranslator;
import org.geysermc.geyser.translator.protocol.Translator;
@@ -245,6 +246,11 @@ public class JavaEntityEventTranslator extends PacketTranslator<ClientboundEntit
entityEventPacket.setType(EntityEventType.VIBRATION_DETECTED);
}
break;
case WARDEN_SONIC_BOOM:
if (entity instanceof WardenEntity wardenEntity) {
wardenEntity.onSonicBoom();
}
break;
}
if (entityEventPacket.getType() != null) {