Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-20 06:50:09 +01:00
Fix various mob attack animations (#4627)
* Fix various mob attack animations * Fix error * Don't set piglin target unless attacking * Fix piglin and hoglin shaking effect * Fix piglin attack animation when switching weapons
Dieser Commit ist enthalten in:
Ursprung
cda7a19a08
Commit
627c2babe9
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity;
|
package org.geysermc.geyser.entity;
|
||||||
|
|
||||||
|
import org.geysermc.geyser.entity.type.living.monster.raid.RavagerEntity;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.MetadataType;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.MetadataType;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.FloatEntityMetadata;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.FloatEntityMetadata;
|
||||||
@ -132,7 +133,7 @@ public final class EntityDefinitions {
|
|||||||
public static final EntityDefinition<ThrownPotionEntity> POTION;
|
public static final EntityDefinition<ThrownPotionEntity> POTION;
|
||||||
public static final EntityDefinition<PufferFishEntity> PUFFERFISH;
|
public static final EntityDefinition<PufferFishEntity> PUFFERFISH;
|
||||||
public static final EntityDefinition<RabbitEntity> RABBIT;
|
public static final EntityDefinition<RabbitEntity> RABBIT;
|
||||||
public static final EntityDefinition<RaidParticipantEntity> RAVAGER;
|
public static final EntityDefinition<RavagerEntity> RAVAGER;
|
||||||
public static final EntityDefinition<AbstractFishEntity> SALMON;
|
public static final EntityDefinition<AbstractFishEntity> SALMON;
|
||||||
public static final EntityDefinition<SheepEntity> SHEEP;
|
public static final EntityDefinition<SheepEntity> SHEEP;
|
||||||
public static final EntityDefinition<ShulkerEntity> SHULKER;
|
public static final EntityDefinition<ShulkerEntity> SHULKER;
|
||||||
@ -745,9 +746,9 @@ public final class EntityDefinitions {
|
|||||||
.type(EntityType.PILLAGER)
|
.type(EntityType.PILLAGER)
|
||||||
.height(1.8f).width(0.6f)
|
.height(1.8f).width(0.6f)
|
||||||
.offset(1.62f)
|
.offset(1.62f)
|
||||||
.addTranslator(null) // Charging; doesn't have an equivalent on Bedrock //TODO check
|
.addTranslator(MetadataType.BOOLEAN, PillagerEntity::setChargingCrossbow)
|
||||||
.build();
|
.build();
|
||||||
RAVAGER = EntityDefinition.inherited(raidParticipantEntityBase.factory(), raidParticipantEntityBase)
|
RAVAGER = EntityDefinition.inherited(RavagerEntity::new, raidParticipantEntityBase)
|
||||||
.type(EntityType.RAVAGER)
|
.type(EntityType.RAVAGER)
|
||||||
.height(1.9f).width(1.2f)
|
.height(1.9f).width(1.2f)
|
||||||
.build();
|
.build();
|
||||||
|
@ -352,6 +352,15 @@ public class LivingEntity extends Entity {
|
|||||||
session.sendUpstreamPacket(offHandPacket);
|
session.sendUpstreamPacket(offHandPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a SWING_ARM animation packet is received
|
||||||
|
*
|
||||||
|
* @return true if an ATTACK_START event should be used instead
|
||||||
|
*/
|
||||||
|
public boolean useArmSwingAttack() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attributes are properties of an entity that are generally more runtime-based instead of permanent properties.
|
* Attributes are properties of an entity that are generally more runtime-based instead of permanent properties.
|
||||||
* Movement speed, current attack damage with a weapon, current knockback resistance.
|
* Movement speed, current attack damage with a weapon, current knockback resistance.
|
||||||
|
@ -27,6 +27,7 @@ package org.geysermc.geyser.entity.type.living.animal;
|
|||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
@ -40,6 +41,8 @@ public class HoglinEntity extends AnimalEntity {
|
|||||||
|
|
||||||
public HoglinEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) {
|
public HoglinEntity(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);
|
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||||
|
dirtyMetadata.put(EntityDataTypes.TARGET_EID, session.getPlayerEntity().getGeyserId());
|
||||||
|
setFlag(EntityFlag.SHAKING, isShaking());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setImmuneToZombification(BooleanEntityMetadata entityMetadata) {
|
public void setImmuneToZombification(BooleanEntityMetadata entityMetadata) {
|
||||||
@ -68,4 +71,9 @@ public class HoglinEntity extends AnimalEntity {
|
|||||||
protected boolean isEnemy() {
|
protected boolean isEnemy() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean useArmSwingAttack() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,9 @@
|
|||||||
package org.geysermc.geyser.entity.type.living.monster;
|
package org.geysermc.geyser.entity.type.living.monster;
|
||||||
|
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
|
import org.cloudburstmc.protocol.bedrock.data.definitions.ItemDefinition;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||||
@ -45,5 +47,17 @@ public class AbstractSkeletonEntity extends MonsterEntity {
|
|||||||
byte xd = entityMetadata.getPrimitiveValue();
|
byte xd = entityMetadata.getPrimitiveValue();
|
||||||
// A bit of a loophole so the hands get raised - set the target ID to its own ID
|
// A bit of a loophole so the hands get raised - set the target ID to its own ID
|
||||||
dirtyMetadata.put(EntityDataTypes.TARGET_EID, ((xd & 4) == 4) ? geyserId : 0);
|
dirtyMetadata.put(EntityDataTypes.TARGET_EID, ((xd & 4) == 4) ? geyserId : 0);
|
||||||
|
|
||||||
|
if ((xd & 4) == 4) {
|
||||||
|
ItemDefinition bow = session.getItemMappings().getStoredItems().bow().getBedrockDefinition();
|
||||||
|
setFlag(EntityFlag.FACING_TARGET_TO_RANGE_ATTACK, this.hand.getDefinition() == bow || this.offhand.getDefinition() == bow);
|
||||||
|
} else {
|
||||||
|
setFlag(EntityFlag.FACING_TARGET_TO_RANGE_ATTACK, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean useArmSwingAttack() {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,13 @@
|
|||||||
package org.geysermc.geyser.entity.type.living.monster;
|
package org.geysermc.geyser.entity.type.living.monster;
|
||||||
|
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||||
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||||
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.type.EntityType;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -38,6 +41,16 @@ public class BasePiglinEntity extends MonsterEntity {
|
|||||||
|
|
||||||
public BasePiglinEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) {
|
public BasePiglinEntity(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);
|
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||||
|
// Both TARGET_EID and BLOCK are needed for melee attack animation
|
||||||
|
dirtyMetadata.put(EntityDataTypes.BLOCK, session.getBlockMappings().getDefinition(1));
|
||||||
|
setFlag(EntityFlag.SHAKING, isShaking());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setMobFlags(ByteEntityMetadata entityMetadata) {
|
||||||
|
super.setMobFlags(entityMetadata);
|
||||||
|
byte xd = entityMetadata.getPrimitiveValue();
|
||||||
|
dirtyMetadata.put(EntityDataTypes.TARGET_EID, (xd & 4) == 4 ? session.getPlayerEntity().getGeyserId() : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setImmuneToZombification(BooleanEntityMetadata entityMetadata) {
|
public void setImmuneToZombification(BooleanEntityMetadata entityMetadata) {
|
||||||
@ -50,4 +63,9 @@ public class BasePiglinEntity extends MonsterEntity {
|
|||||||
protected boolean isShaking() {
|
protected boolean isShaking() {
|
||||||
return (!isImmuneToZombification && !session.getDimensionType().piglinSafe()) || super.isShaking();
|
return (!isImmuneToZombification && !session.getDimensionType().piglinSafe()) || super.isShaking();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean useArmSwingAttack() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,16 +27,22 @@ package org.geysermc.geyser.entity.type.living.monster;
|
|||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
|
import org.cloudburstmc.protocol.bedrock.data.inventory.ContainerId;
|
||||||
|
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
|
||||||
|
import org.cloudburstmc.protocol.bedrock.packet.MobEquipmentPacket;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
import org.geysermc.geyser.inventory.GeyserItemStack;
|
||||||
import org.geysermc.geyser.item.Items;
|
import org.geysermc.geyser.item.Items;
|
||||||
|
import org.geysermc.geyser.registry.type.ItemMapping;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
import org.geysermc.geyser.util.InteractionResult;
|
||||||
import org.geysermc.geyser.util.InteractiveTag;
|
import org.geysermc.geyser.util.InteractiveTag;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand;
|
||||||
|
import org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -55,13 +61,61 @@ public class PiglinEntity extends BasePiglinEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setChargingCrossbow(BooleanEntityMetadata entityMetadata) {
|
public void setChargingCrossbow(BooleanEntityMetadata entityMetadata) {
|
||||||
setFlag(EntityFlag.CHARGING, entityMetadata.getPrimitiveValue());
|
boolean charging = entityMetadata.getPrimitiveValue();
|
||||||
|
setFlag(EntityFlag.CHARGING, charging);
|
||||||
|
dirtyMetadata.put(EntityDataTypes.CHARGE_AMOUNT, charging ? (byte) 64 : (byte) 0); // TODO: gradually increase
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDancing(BooleanEntityMetadata entityMetadata) {
|
public void setDancing(BooleanEntityMetadata entityMetadata) {
|
||||||
setFlag(EntityFlag.DANCING, entityMetadata.getPrimitiveValue());
|
setFlag(EntityFlag.DANCING, entityMetadata.getPrimitiveValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setHand(ItemStack stack) {
|
||||||
|
ItemMapping crossbow = session.getItemMappings().getStoredItems().crossbow();
|
||||||
|
boolean toCrossbow = stack != null && stack.getId() == crossbow.getJavaItem().javaId();
|
||||||
|
|
||||||
|
if (toCrossbow ^ this.hand.getDefinition() == crossbow.getBedrockDefinition()) { // If switching to/from crossbow
|
||||||
|
dirtyMetadata.put(EntityDataTypes.BLOCK, session.getBlockMappings().getDefinition(toCrossbow ? 0 : 1));
|
||||||
|
dirtyMetadata.put(EntityDataTypes.CHARGE_AMOUNT, (byte) 0);
|
||||||
|
setFlag(EntityFlag.CHARGED, false);
|
||||||
|
setFlag(EntityFlag.USING_ITEM, false);
|
||||||
|
updateBedrockMetadata();
|
||||||
|
|
||||||
|
if (this.hand.isValid()) {
|
||||||
|
MobEquipmentPacket mobEquipmentPacket = new MobEquipmentPacket();
|
||||||
|
mobEquipmentPacket.setRuntimeEntityId(geyserId);
|
||||||
|
mobEquipmentPacket.setContainerId(ContainerId.INVENTORY);
|
||||||
|
mobEquipmentPacket.setInventorySlot(0);
|
||||||
|
mobEquipmentPacket.setHotbarSlot(-1);
|
||||||
|
mobEquipmentPacket.setItem(ItemData.AIR);
|
||||||
|
session.sendUpstreamPacket(mobEquipmentPacket);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
super.setHand(stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateMainHand(GeyserSession session) {
|
||||||
|
super.updateMainHand(session);
|
||||||
|
|
||||||
|
if (this.hand.getDefinition() == session.getItemMappings().getStoredItems().crossbow().getBedrockDefinition()) {
|
||||||
|
if (this.hand.getTag() != null && this.hand.getTag().containsKey("chargedItem")) {
|
||||||
|
dirtyMetadata.put(EntityDataTypes.CHARGE_AMOUNT, Byte.MAX_VALUE);
|
||||||
|
setFlag(EntityFlag.CHARGING, false);
|
||||||
|
setFlag(EntityFlag.CHARGED, true);
|
||||||
|
setFlag(EntityFlag.USING_ITEM, true);
|
||||||
|
} else if (getFlag(EntityFlag.CHARGED)) {
|
||||||
|
dirtyMetadata.put(EntityDataTypes.CHARGE_AMOUNT, (byte) 0);
|
||||||
|
setFlag(EntityFlag.CHARGED, false);
|
||||||
|
setFlag(EntityFlag.USING_ITEM, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateBedrockMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateOffHand(GeyserSession session) {
|
public void updateOffHand(GeyserSession session) {
|
||||||
// Check if the Piglin is holding Gold and set the ADMIRING flag accordingly so its pose updates
|
// Check if the Piglin is holding Gold and set the ADMIRING flag accordingly so its pose updates
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
package org.geysermc.geyser.entity.type.living.monster;
|
package org.geysermc.geyser.entity.type.living.monster;
|
||||||
|
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
@ -37,6 +38,7 @@ public class ZoglinEntity extends MonsterEntity {
|
|||||||
|
|
||||||
public ZoglinEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) {
|
public ZoglinEntity(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);
|
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||||
|
dirtyMetadata.put(EntityDataTypes.TARGET_EID, session.getPlayerEntity().getGeyserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBaby(BooleanEntityMetadata entityMetadata) {
|
public void setBaby(BooleanEntityMetadata entityMetadata) {
|
||||||
@ -64,4 +66,9 @@ public class ZoglinEntity extends MonsterEntity {
|
|||||||
protected boolean isEnemy() {
|
protected boolean isEnemy() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean useArmSwingAttack() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,4 +57,9 @@ public class ZombieEntity extends MonsterEntity {
|
|||||||
protected boolean isShaking() {
|
protected boolean isShaking() {
|
||||||
return convertingToDrowned || super.isShaking();
|
return convertingToDrowned || super.isShaking();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean useArmSwingAttack() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,13 @@
|
|||||||
package org.geysermc.geyser.entity.type.living.monster.raid;
|
package org.geysermc.geyser.entity.type.living.monster.raid;
|
||||||
|
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
|
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.registry.type.ItemMapping;
|
import org.geysermc.geyser.registry.type.ItemMapping;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -39,16 +42,22 @@ public class PillagerEntity extends AbstractIllagerEntity {
|
|||||||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setChargingCrossbow(BooleanEntityMetadata entityMetadata) {
|
||||||
|
boolean charging = entityMetadata.getPrimitiveValue();
|
||||||
|
setFlag(EntityFlag.CHARGING, charging);
|
||||||
|
dirtyMetadata.put(EntityDataTypes.CHARGE_AMOUNT, charging ? (byte) 64 : (byte) 0); // TODO: gradually increase
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateMainHand(GeyserSession session) { //TODO
|
public void updateMainHand(GeyserSession session) {
|
||||||
checkForCrossbow();
|
updateCrossbow();
|
||||||
|
|
||||||
super.updateMainHand(session);
|
super.updateMainHand(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateOffHand(GeyserSession session) {
|
public void updateOffHand(GeyserSession session) {
|
||||||
checkForCrossbow();
|
updateCrossbow();
|
||||||
|
|
||||||
super.updateOffHand(session);
|
super.updateOffHand(session);
|
||||||
}
|
}
|
||||||
@ -56,12 +65,27 @@ public class PillagerEntity extends AbstractIllagerEntity {
|
|||||||
/**
|
/**
|
||||||
* Check for a crossbow in either the mainhand or offhand. If one exists, indicate that the pillager should be posing
|
* Check for a crossbow in either the mainhand or offhand. If one exists, indicate that the pillager should be posing
|
||||||
*/
|
*/
|
||||||
protected void checkForCrossbow() {
|
protected void updateCrossbow() {
|
||||||
ItemMapping crossbow = session.getItemMappings().getStoredItems().crossbow();
|
ItemMapping crossbow = session.getItemMappings().getStoredItems().crossbow();
|
||||||
boolean hasCrossbow = this.hand.getDefinition() == crossbow.getBedrockDefinition()
|
ItemData activeCrossbow = null;
|
||||||
|| this.offhand.getDefinition() == crossbow.getBedrockDefinition();
|
if (this.hand.getDefinition() == crossbow.getBedrockDefinition()) {
|
||||||
setFlag(EntityFlag.USING_ITEM, hasCrossbow);
|
activeCrossbow = this.hand;
|
||||||
setFlag(EntityFlag.CHARGED, hasCrossbow);
|
} else if (this.offhand.getDefinition() == crossbow.getBedrockDefinition()) {
|
||||||
|
activeCrossbow = this.offhand;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (activeCrossbow != null) {
|
||||||
|
if (activeCrossbow.getTag() != null && activeCrossbow.getTag().containsKey("chargedItem")) {
|
||||||
|
dirtyMetadata.put(EntityDataTypes.CHARGE_AMOUNT, Byte.MAX_VALUE);
|
||||||
|
setFlag(EntityFlag.CHARGING, false);
|
||||||
|
setFlag(EntityFlag.CHARGED, true);
|
||||||
|
setFlag(EntityFlag.USING_ITEM, true);
|
||||||
|
} else if (getFlag(EntityFlag.CHARGED)) {
|
||||||
|
dirtyMetadata.put(EntityDataTypes.CHARGE_AMOUNT, (byte) 0);
|
||||||
|
setFlag(EntityFlag.CHARGED, false);
|
||||||
|
setFlag(EntityFlag.USING_ITEM, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
updateBedrockMetadata();
|
updateBedrockMetadata();
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019-2024 GeyserMC. http://geysermc.org
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @author GeyserMC
|
||||||
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.geysermc.geyser.entity.type.living.monster.raid;
|
||||||
|
|
||||||
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
public class RavagerEntity extends RaidParticipantEntity {
|
||||||
|
|
||||||
|
public RavagerEntity(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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean useArmSwingAttack() {
|
||||||
|
setFlag(EntityFlag.DELAYED_ATTACK, false);
|
||||||
|
updateBedrockMetadata();
|
||||||
|
|
||||||
|
session.scheduleInEventLoop(() -> {
|
||||||
|
setFlag(EntityFlag.DELAYED_ATTACK, true);
|
||||||
|
updateBedrockMetadata();
|
||||||
|
}, 75, TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -26,6 +26,7 @@
|
|||||||
package org.geysermc.geyser.entity.type.living.monster.raid;
|
package org.geysermc.geyser.entity.type.living.monster.raid;
|
||||||
|
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
@ -37,6 +38,7 @@ public class VindicatorEntity extends AbstractIllagerEntity {
|
|||||||
|
|
||||||
public VindicatorEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) {
|
public VindicatorEntity(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);
|
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||||
|
dirtyMetadata.put(EntityDataTypes.TARGET_EID, session.getPlayerEntity().getGeyserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -46,4 +48,9 @@ public class VindicatorEntity extends AbstractIllagerEntity {
|
|||||||
byte xd = entityMetadata.getPrimitiveValue();
|
byte xd = entityMetadata.getPrimitiveValue();
|
||||||
setFlag(EntityFlag.ANGRY, (xd & 4) == 4);
|
setFlag(EntityFlag.ANGRY, (xd & 4) == 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean useArmSwingAttack() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ import java.util.Map;
|
|||||||
public class StoredItemMappings {
|
public class StoredItemMappings {
|
||||||
private final ItemMapping banner;
|
private final ItemMapping banner;
|
||||||
private final ItemMapping barrier;
|
private final ItemMapping barrier;
|
||||||
|
private final ItemMapping bow;
|
||||||
private final ItemMapping compass;
|
private final ItemMapping compass;
|
||||||
private final ItemMapping crossbow;
|
private final ItemMapping crossbow;
|
||||||
private final ItemMapping egg;
|
private final ItemMapping egg;
|
||||||
@ -57,6 +58,7 @@ public class StoredItemMappings {
|
|||||||
public StoredItemMappings(Map<Item, ItemMapping> itemMappings) {
|
public StoredItemMappings(Map<Item, ItemMapping> itemMappings) {
|
||||||
this.banner = load(itemMappings, Items.WHITE_BANNER); // As of 1.17.10, all banners have the same Bedrock ID
|
this.banner = load(itemMappings, Items.WHITE_BANNER); // As of 1.17.10, all banners have the same Bedrock ID
|
||||||
this.barrier = load(itemMappings, Items.BARRIER);
|
this.barrier = load(itemMappings, Items.BARRIER);
|
||||||
|
this.bow = load(itemMappings, Items.BOW);
|
||||||
this.compass = load(itemMappings, Items.COMPASS);
|
this.compass = load(itemMappings, Items.COMPASS);
|
||||||
this.crossbow = load(itemMappings, Items.CROSSBOW);
|
this.crossbow = load(itemMappings, Items.CROSSBOW);
|
||||||
this.egg = load(itemMappings, Items.EGG);
|
this.egg = load(itemMappings, Items.EGG);
|
||||||
|
@ -26,10 +26,13 @@
|
|||||||
package org.geysermc.geyser.translator.protocol.java.entity;
|
package org.geysermc.geyser.translator.protocol.java.entity;
|
||||||
|
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.AnimateEntityPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.AnimateEntityPacket;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.AnimatePacket;
|
import org.cloudburstmc.protocol.bedrock.packet.AnimatePacket;
|
||||||
|
import org.cloudburstmc.protocol.bedrock.packet.EntityEventPacket;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.SpawnParticleEffectPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.SpawnParticleEffectPacket;
|
||||||
import org.geysermc.geyser.entity.type.Entity;
|
import org.geysermc.geyser.entity.type.Entity;
|
||||||
|
import org.geysermc.geyser.entity.type.LivingEntity;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||||
import org.geysermc.geyser.translator.protocol.Translator;
|
import org.geysermc.geyser.translator.protocol.Translator;
|
||||||
@ -57,6 +60,14 @@ public class JavaAnimateTranslator extends PacketTranslator<ClientboundAnimatePa
|
|||||||
animatePacket.setRuntimeEntityId(entity.getGeyserId());
|
animatePacket.setRuntimeEntityId(entity.getGeyserId());
|
||||||
switch (animation) {
|
switch (animation) {
|
||||||
case SWING_ARM -> {
|
case SWING_ARM -> {
|
||||||
|
if (entity instanceof LivingEntity livingEntity && livingEntity.useArmSwingAttack()) {
|
||||||
|
EntityEventPacket entityEventPacket = new EntityEventPacket();
|
||||||
|
entityEventPacket.setRuntimeEntityId(entity.getGeyserId());
|
||||||
|
entityEventPacket.setType(EntityEventType.ATTACK_START);
|
||||||
|
session.sendUpstreamPacket(entityEventPacket);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
animatePacket.setAction(AnimatePacket.Action.SWING_ARM);
|
animatePacket.setAction(AnimatePacket.Action.SWING_ARM);
|
||||||
if (entity.getEntityId() == session.getPlayerEntity().getEntityId()) {
|
if (entity.getEntityId() == session.getPlayerEntity().getEntityId()) {
|
||||||
session.activateArmAnimationTicking();
|
session.activateArmAnimationTicking();
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren