Add goat horn count

This commit is contained in:
Camotoy 2022-06-06 21:06:02 -04:00
parent 378aa6ed99
commit a397f55e8b
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F
2 changed files with 19 additions and 0 deletions

View file

@ -772,6 +772,8 @@ public final class EntityDefinitions {
.type(EntityType.GOAT)
.height(1.3f).width(0.9f)
.addTranslator(MetadataType.BOOLEAN, GoatEntity::setScreamer)
.addTranslator(MetadataType.BOOLEAN, GoatEntity::setHasLeftHorn)
.addTranslator(MetadataType.BOOLEAN, GoatEntity::setHasRightHorn)
.build();
MOOSHROOM = EntityDefinition.inherited(MooshroomEntity::new, ageableEntityBase)
.type(EntityType.MOOSHROOM)

View file

@ -30,6 +30,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanE
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.protocol.bedrock.data.SoundEvent;
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.inventory.GeyserItemStack;
@ -44,6 +45,8 @@ public class GoatEntity extends AnimalEntity {
private static final float LONG_JUMPING_WIDTH = 0.9f * 0.7f;
private boolean isScreamer;
private boolean hasLeftHorn;
private boolean hasRightHorn;
public GoatEntity(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);
@ -74,4 +77,18 @@ public class GoatEntity extends AnimalEntity {
return super.mobInteract(hand, itemInHand);
}
}
public void setHasLeftHorn(BooleanEntityMetadata entityMetadata) {
hasLeftHorn = entityMetadata.getPrimitiveValue();
setHornCount();
}
public void setHasRightHorn(BooleanEntityMetadata entityMetadata) {
hasRightHorn = entityMetadata.getPrimitiveValue();
setHornCount();
}
private void setHornCount() {
dirtyMetadata.put(EntityData.GOAT_HORN_COUNT, (hasLeftHorn ? 1 : 0) + (hasRightHorn ? 1 : 0));
}
}