mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Implement new entity statuses and goat milk sounds
This commit is contained in:
parent
b41552faf3
commit
01d7648296
4 changed files with 43 additions and 7 deletions
|
@ -148,7 +148,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.GeyserMC</groupId>
|
<groupId>com.github.GeyserMC</groupId>
|
||||||
<artifactId>MCProtocolLib</artifactId>
|
<artifactId>MCProtocolLib</artifactId>
|
||||||
<version>bc06ae5</version>
|
<version>2bd966a</version>
|
||||||
<!-- <groupId>com.github.steveice10</groupId>-->
|
<!-- <groupId>com.github.steveice10</groupId>-->
|
||||||
<!-- <artifactId>mcprotocollib</artifactId>-->
|
<!-- <artifactId>mcprotocollib</artifactId>-->
|
||||||
<!-- <version>1.17-rc1-SNAPSHOT</version>-->
|
<!-- <version>1.17-rc1-SNAPSHOT</version>-->
|
||||||
|
|
|
@ -29,6 +29,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadat
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Pose;
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Pose;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import com.nukkitx.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||||
|
import lombok.Getter;
|
||||||
import org.geysermc.connector.entity.type.EntityType;
|
import org.geysermc.connector.entity.type.EntityType;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
|
|
||||||
|
@ -36,6 +37,9 @@ public class GoatEntity extends AnimalEntity {
|
||||||
private static final float LONG_JUMPING_HEIGHT = 1.3f * 0.7f;
|
private static final float LONG_JUMPING_HEIGHT = 1.3f * 0.7f;
|
||||||
private static final float LONG_JUMPING_WIDTH = 0.9f * 0.7f;
|
private static final float LONG_JUMPING_WIDTH = 0.9f * 0.7f;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private boolean isScreamer;
|
||||||
|
|
||||||
public GoatEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) {
|
public GoatEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) {
|
||||||
super(entityId, geyserId, entityType, position, motion, rotation);
|
super(entityId, geyserId, entityType, position, motion, rotation);
|
||||||
}
|
}
|
||||||
|
@ -43,7 +47,10 @@ public class GoatEntity extends AnimalEntity {
|
||||||
@Override
|
@Override
|
||||||
public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) {
|
public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) {
|
||||||
super.updateBedrockMetadata(entityMetadata, session);
|
super.updateBedrockMetadata(entityMetadata, session);
|
||||||
|
if (entityMetadata.getId() == 17) {
|
||||||
|
// Not used in Bedrock Edition
|
||||||
|
isScreamer = (boolean) entityMetadata.getValue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -94,6 +94,7 @@ public class JavaEntityStatusTranslator extends PacketTranslator<ServerEntitySta
|
||||||
case LIVING_HURT:
|
case LIVING_HURT:
|
||||||
case LIVING_HURT_SWEET_BERRY_BUSH:
|
case LIVING_HURT_SWEET_BERRY_BUSH:
|
||||||
case LIVING_HURT_THORNS:
|
case LIVING_HURT_THORNS:
|
||||||
|
case LIVING_FREEZE:
|
||||||
entityEventPacket.setType(EntityEventType.HURT);
|
entityEventPacket.setType(EntityEventType.HURT);
|
||||||
break;
|
break;
|
||||||
case LIVING_DEATH:
|
case LIVING_DEATH:
|
||||||
|
@ -213,8 +214,25 @@ public class JavaEntityStatusTranslator extends PacketTranslator<ServerEntitySta
|
||||||
session.getConnector().getLogger().debug("Got status message to swap hands for a non-living entity.");
|
session.getConnector().getLogger().debug("Got status message to swap hands for a non-living entity.");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
case GOAT_LOWERING_HEAD:
|
||||||
|
if (entity.getEntityType() == EntityType.GOAT) {
|
||||||
|
entityEventPacket.setType(EntityEventType.ATTACK_START);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case GOAT_STOP_LOWERING_HEAD:
|
||||||
|
if (entity.getEntityType() == EntityType.GOAT) {
|
||||||
|
entityEventPacket.setType(EntityEventType.ATTACK_STOP);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MAKE_POOF_PARTICLES:
|
||||||
|
if (entity instanceof LivingEntity) {
|
||||||
|
entityEventPacket.setType(EntityEventType.DEATH_SMOKE_CLOUD);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
session.sendUpstreamPacket(entityEventPacket);
|
if (entityEventPacket.getType() != null) {
|
||||||
|
session.sendUpstreamPacket(entityEventPacket);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,27 +27,38 @@ package org.geysermc.connector.network.translators.sound.entity;
|
||||||
|
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import com.nukkitx.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.data.SoundEvent;
|
import com.nukkitx.protocol.bedrock.data.SoundEvent;
|
||||||
|
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import com.nukkitx.protocol.bedrock.packet.LevelSoundEventPacket;
|
import com.nukkitx.protocol.bedrock.packet.LevelSoundEventPacket;
|
||||||
import org.geysermc.connector.entity.Entity;
|
import org.geysermc.connector.entity.Entity;
|
||||||
|
import org.geysermc.connector.entity.living.animal.GoatEntity;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.translators.item.ItemRegistry;
|
|
||||||
import org.geysermc.connector.network.translators.sound.EntitySoundInteractionHandler;
|
import org.geysermc.connector.network.translators.sound.EntitySoundInteractionHandler;
|
||||||
import org.geysermc.connector.network.translators.sound.SoundHandler;
|
import org.geysermc.connector.network.translators.sound.SoundHandler;
|
||||||
|
|
||||||
@SoundHandler(entities = "cow", items = "bucket")
|
@SoundHandler(entities = {"cow", "goat"}, items = "bucket")
|
||||||
public class MilkCowSoundInteractionHandler implements EntitySoundInteractionHandler {
|
public class MilkEntitySoundInteractionHandler implements EntitySoundInteractionHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleInteraction(GeyserSession session, Vector3f position, Entity value) {
|
public void handleInteraction(GeyserSession session, Vector3f position, Entity value) {
|
||||||
if (!session.getPlayerInventory().getItemInHand().getItemEntry().getJavaIdentifier().equals("minecraft:bucket")) {
|
if (!session.getPlayerInventory().getItemInHand().getItemEntry().getJavaIdentifier().equals("minecraft:bucket")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (value.getMetadata().getFlags().getFlag(EntityFlag.BABY)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SoundEvent milkSound;
|
||||||
|
if (value instanceof GoatEntity && ((GoatEntity) value).isScreamer()) {
|
||||||
|
milkSound = SoundEvent.MILK_SCREAMER;
|
||||||
|
} else {
|
||||||
|
milkSound = SoundEvent.MILK;
|
||||||
|
}
|
||||||
LevelSoundEventPacket levelSoundEventPacket = new LevelSoundEventPacket();
|
LevelSoundEventPacket levelSoundEventPacket = new LevelSoundEventPacket();
|
||||||
levelSoundEventPacket.setPosition(position);
|
levelSoundEventPacket.setPosition(position);
|
||||||
levelSoundEventPacket.setBabySound(false);
|
levelSoundEventPacket.setBabySound(false);
|
||||||
levelSoundEventPacket.setRelativeVolumeDisabled(false);
|
levelSoundEventPacket.setRelativeVolumeDisabled(false);
|
||||||
levelSoundEventPacket.setIdentifier(":");
|
levelSoundEventPacket.setIdentifier(":");
|
||||||
levelSoundEventPacket.setSound(SoundEvent.MILK);
|
levelSoundEventPacket.setSound(milkSound);
|
||||||
levelSoundEventPacket.setExtraData(-1);
|
levelSoundEventPacket.setExtraData(-1);
|
||||||
session.sendUpstreamPacket(levelSoundEventPacket);
|
session.sendUpstreamPacket(levelSoundEventPacket);
|
||||||
}
|
}
|
Loading…
Reference in a new issue