use of com.nukkitx.protocol.bedrock.packet.EntityEventPacket in project Geyser by GeyserMC.
the class BeeEntity method setBeeFlags.
public void setBeeFlags(ByteEntityMetadata entityMetadata) {
byte xd = entityMetadata.getPrimitiveValue();
// Bee is performing sting attack; trigger animation
if ((xd & 0x02) == 0x02) {
EntityEventPacket packet = new EntityEventPacket();
packet.setRuntimeEntityId(geyserId);
packet.setType(EntityEventType.ATTACK_START);
packet.setData(0);
session.sendUpstreamPacket(packet);
}
// If the bee has stung
dirtyMetadata.put(EntityData.MARK_VARIANT, (xd & 0x04) == 0x04 ? 1 : 0);
// If the bee has nectar or not
setFlag(EntityFlag.POWERED, (xd & 0x08) == 0x08);
}
use of com.nukkitx.protocol.bedrock.packet.EntityEventPacket in project Geyser by GeyserMC.
the class AbstractHorseEntity method setHorseFlags.
public void setHorseFlags(ByteEntityMetadata entityMetadata) {
byte xd = entityMetadata.getPrimitiveValue();
boolean tamed = (xd & 0x02) == 0x02;
boolean saddled = (xd & 0x04) == 0x04;
setFlag(EntityFlag.TAMED, tamed);
setFlag(EntityFlag.SADDLED, saddled);
setFlag(EntityFlag.EATING, (xd & 0x10) == 0x10);
setFlag(EntityFlag.STANDING, (xd & 0x20) == 0x20);
// HorseFlags
// Bred 0x10
// Eating 0x20
// Open mouth 0x80
int horseFlags = 0x0;
horseFlags = (xd & 0x40) == 0x40 ? horseFlags | 0x80 : horseFlags;
// Only set eating when we don't have mouth open so a player interaction doesn't trigger the eating animation
horseFlags = (xd & 0x10) == 0x10 && (xd & 0x40) != 0x40 ? horseFlags | 0x20 : horseFlags;
// Set the flags into the display item
dirtyMetadata.put(EntityData.DISPLAY_ITEM, horseFlags);
// doesn't send over what item was used to feed the horse
if ((xd & 0x40) == 0x40) {
EntityEventPacket entityEventPacket = new EntityEventPacket();
entityEventPacket.setRuntimeEntityId(geyserId);
entityEventPacket.setType(EntityEventType.EATING_ITEM);
entityEventPacket.setData(session.getItemMappings().getStoredItems().wheat().getBedrockId() << 16);
session.sendUpstreamPacket(entityEventPacket);
}
// Set container type if tamed
dirtyMetadata.put(EntityData.CONTAINER_TYPE, tamed ? (byte) ContainerType.HORSE.getId() : (byte) 0);
// Shows the jump meter
setFlag(EntityFlag.CAN_POWER_JUMP, saddled);
}
use of com.nukkitx.protocol.bedrock.packet.EntityEventPacket in project Geyser by GeyserMC.
the class ItemEntity method setItem.
public void setItem(EntityMetadata<ItemStack, ?> entityMetadata) {
ItemData item = ItemTranslator.translateToBedrock(session, entityMetadata.getValue());
if (this.item == null) {
this.item = item;
spawnEntity();
} else if (item.equals(this.item, false, true, true)) {
// Don't bother respawning the entity if items are equal
if (this.item.getCount() != item.getCount()) {
// Just item count updated; let's make this easy
this.item = item;
EntityEventPacket packet = new EntityEventPacket();
packet.setRuntimeEntityId(geyserId);
packet.setType(EntityEventType.UPDATE_ITEM_STACK_SIZE);
packet.setData(this.item.getCount());
session.sendUpstreamPacket(packet);
}
} else {
this.item = item;
despawnEntity();
spawnEntity();
}
}
use of com.nukkitx.protocol.bedrock.packet.EntityEventPacket in project Geyser by GeyserMC.
the class PandaEntity method setEatingCounter.
public void setEatingCounter(IntEntityMetadata entityMetadata) {
int count = entityMetadata.getPrimitiveValue();
setFlag(EntityFlag.EATING, count > 0);
dirtyMetadata.put(EntityData.EATING_COUNTER, count);
if (count != 0) {
// Particles and sound
EntityEventPacket packet = new EntityEventPacket();
packet.setRuntimeEntityId(geyserId);
packet.setType(EntityEventType.EATING_ITEM);
packet.setData(session.getItemMappings().getStoredItems().bamboo().getBedrockId() << 16);
session.sendUpstreamPacket(packet);
}
}
Aggregations