Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-25 15:50:14 +01:00
Implement new entity statuses and goat milk sounds
Dieser Commit ist enthalten in:
Ursprung
b41552faf3
Commit
01d7648296
@ -148,7 +148,7 @@
|
||||
<dependency>
|
||||
<groupId>com.github.GeyserMC</groupId>
|
||||
<artifactId>MCProtocolLib</artifactId>
|
||||
<version>bc06ae5</version>
|
||||
<version>2bd966a</version>
|
||||
<!-- <groupId>com.github.steveice10</groupId>-->
|
||||
<!-- <artifactId>mcprotocollib</artifactId>-->
|
||||
<!-- <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.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import lombok.Getter;
|
||||
import org.geysermc.connector.entity.type.EntityType;
|
||||
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_WIDTH = 0.9f * 0.7f;
|
||||
|
||||
@Getter
|
||||
private boolean isScreamer;
|
||||
|
||||
public GoatEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) {
|
||||
super(entityId, geyserId, entityType, position, motion, rotation);
|
||||
}
|
||||
@ -43,7 +47,10 @@ public class GoatEntity extends AnimalEntity {
|
||||
@Override
|
||||
public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) {
|
||||
super.updateBedrockMetadata(entityMetadata, session);
|
||||
|
||||
if (entityMetadata.getId() == 17) {
|
||||
// Not used in Bedrock Edition
|
||||
isScreamer = (boolean) entityMetadata.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -94,6 +94,7 @@ public class JavaEntityStatusTranslator extends PacketTranslator<ServerEntitySta
|
||||
case LIVING_HURT:
|
||||
case LIVING_HURT_SWEET_BERRY_BUSH:
|
||||
case LIVING_HURT_THORNS:
|
||||
case LIVING_FREEZE:
|
||||
entityEventPacket.setType(EntityEventType.HURT);
|
||||
break;
|
||||
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.");
|
||||
}
|
||||
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.protocol.bedrock.data.SoundEvent;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import com.nukkitx.protocol.bedrock.packet.LevelSoundEventPacket;
|
||||
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.translators.item.ItemRegistry;
|
||||
import org.geysermc.connector.network.translators.sound.EntitySoundInteractionHandler;
|
||||
import org.geysermc.connector.network.translators.sound.SoundHandler;
|
||||
|
||||
@SoundHandler(entities = "cow", items = "bucket")
|
||||
public class MilkCowSoundInteractionHandler implements EntitySoundInteractionHandler {
|
||||
@SoundHandler(entities = {"cow", "goat"}, items = "bucket")
|
||||
public class MilkEntitySoundInteractionHandler implements EntitySoundInteractionHandler {
|
||||
|
||||
@Override
|
||||
public void handleInteraction(GeyserSession session, Vector3f position, Entity value) {
|
||||
if (!session.getPlayerInventory().getItemInHand().getItemEntry().getJavaIdentifier().equals("minecraft:bucket")) {
|
||||
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.setPosition(position);
|
||||
levelSoundEventPacket.setBabySound(false);
|
||||
levelSoundEventPacket.setRelativeVolumeDisabled(false);
|
||||
levelSoundEventPacket.setIdentifier(":");
|
||||
levelSoundEventPacket.setSound(SoundEvent.MILK);
|
||||
levelSoundEventPacket.setSound(milkSound);
|
||||
levelSoundEventPacket.setExtraData(-1);
|
||||
session.sendUpstreamPacket(levelSoundEventPacket);
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren