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
No known key found for this signature in database
GPG Key ID: A0168C8E45799B7D
4 changed files with 22 additions and 2 deletions

View File

@ -121,7 +121,7 @@
<dependency>
<groupId>com.github.CloudburstMC.Protocol</groupId>
<artifactId>bedrock-beta</artifactId>
<version>51d4fce</version>
<version>be0cc73</version>
<scope>compile</scope>
<exclusions>
<exclusion>

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) {

@ -1 +1 @@
Subproject commit 7fc4ac178901f2ba2989645d0da44dcfb95575db
Subproject commit e13611fd97b1801d4c4b914cd409351a49d19537