本文整理汇总了Java中org.spongepowered.api.data.type.HandTypes.OFF_HAND属性的典型用法代码示例。如果您正苦于以下问题:Java HandTypes.OFF_HAND属性的具体用法?Java HandTypes.OFF_HAND怎么用?Java HandTypes.OFF_HAND使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.spongepowered.api.data.type.HandTypes
的用法示例。
在下文中一共展示了HandTypes.OFF_HAND属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleEvent
@Override
protected void handleEvent(EntityProtocolUpdateContext context, EntityEvent event) {
if (event instanceof DamagedEntityEvent) {
context.sendToAll(() -> new MessagePlayOutEntityAnimation(getRootEntityId(), 1));
} else if (event instanceof SwingHandEntityEvent) {
final HandType handType = ((SwingHandEntityEvent) event).getHandType();
if (handType == HandTypes.MAIN_HAND) {
context.sendToAllExceptSelf(() -> new MessagePlayOutEntityAnimation(getRootEntityId(), 0));
} else if (handType == HandTypes.OFF_HAND) {
context.sendToAllExceptSelf(() -> new MessagePlayOutEntityAnimation(getRootEntityId(), 3));
} else {
super.handleEvent(context, event);
}
} else {
super.handleEvent(context, event);
}
}
示例2: decode
@Override
public MessagePlayInUseEntity decode(CodecContext context, ByteBuffer buf) throws CodecException {
final int entityId = buf.readVarInt();
final int action = buf.readVarInt();
if (action == 1) {
return new MessagePlayInUseEntity.Attack(entityId);
} else if (action == 0 || action == 2) {
Vector3d position = null;
if (action == 2) {
final double x = buf.readFloat();
final double y = buf.readFloat();
final double z = buf.readFloat();
position = new Vector3d(x, y, z);
}
final HandType hand = buf.readVarInt() == 0 ? HandTypes.MAIN_HAND : HandTypes.OFF_HAND;
return new MessagePlayInUseEntity.Interact(entityId, hand, position);
} else {
throw new DecoderException("Received a UseEntity message with a unknown action: " + action);
}
}
示例3: getEventHand
public static HandType getEventHand(InteractEvent event) {
HandType hand;
if (event instanceof InteractBlockEvent.Primary.OffHand) {
hand = HandTypes.OFF_HAND;
} else if (event instanceof InteractBlockEvent.Secondary.OffHand) {
hand = HandTypes.OFF_HAND;
} else if (event instanceof InteractEntityEvent.Primary.OffHand) {
hand = HandTypes.OFF_HAND;
} else if (event instanceof InteractEntityEvent.Secondary.OffHand) {
hand = HandTypes.OFF_HAND;
} else {
hand = HandTypes.MAIN_HAND;
}
return hand;
}
示例4: handleEvent
@Override
protected void handleEvent(EntityProtocolUpdateContext context, EntityEvent event) {
if (event instanceof SwingHandEntityEvent) {
final HandType handType = ((SwingHandEntityEvent) event).getHandType();
// Doesn't matter which hand type, just play the swing animation,
// the golem will use both arms at the same time
if (handType == HandTypes.MAIN_HAND || handType == HandTypes.OFF_HAND) {
context.sendToAll(() -> new MessagePlayOutEntityStatus(getRootEntityId(), 4));
}
} else {
super.handleEvent(context, event);
}
}
示例5: getHandData
private byte getHandData() {
final Optional<HandType> activeHand = this.entity.get(LanternKeys.ACTIVE_HAND).orElse(Optional.empty());
byte value;
if (activeHand.isPresent()) {
value = 0x1;
if (activeHand.get() == HandTypes.OFF_HAND) {
value |= 0x2;
}
} else {
value = 0;
}
return value;
}
示例6: decode
@Override
public MessagePlayInPlayerBlockPlacement decode(CodecContext context, ByteBuffer buf) throws CodecException {
final Vector3i position = buf.read(Types.VECTOR_3_I);
final Direction face = fromFace(buf.readVarInt());
final HandType hand = buf.readVarInt() == 0 ? HandTypes.MAIN_HAND : HandTypes.OFF_HAND;
final double ox = buf.readFloat();
final double oy = buf.readFloat();
final double oz = buf.readFloat();
final Vector3d offset = new Vector3d(ox, oy, oz);
return new MessagePlayInPlayerBlockPlacement(position, offset, face, hand);
}
示例7: of
public static SwingHandEntityEvent of(HandType handType) {
checkNotNull(handType, "handType");
return handType == HandTypes.MAIN_HAND ? Holder.MAIN_HAND :
handType == HandTypes.OFF_HAND ? Holder.OFF_HAND : new SwingHandEntityEvent(handType);
}
示例8: handleSwingArm
public void handleSwingArm(MessagePlayInPlayerSwingArm message) {
if (message.getHandType() == HandTypes.OFF_HAND) {
return;
}
this.player.triggerEvent(SwingHandEntityEvent.of(HandTypes.MAIN_HAND));
}
示例9: decode
@Override
public MessagePlayInPlayerUseItem decode(CodecContext context, ByteBuffer buf) throws CodecException {
return new MessagePlayInPlayerUseItem(buf.readVarInt() == 0 ? HandTypes.MAIN_HAND : HandTypes.OFF_HAND);
}
示例10: decode
@Override
public MessagePlayInPlayerSwingArm decode(CodecContext context, ByteBuffer buf) throws CodecException {
return new MessagePlayInPlayerSwingArm(buf.readVarInt() == 0 ? HandTypes.MAIN_HAND : HandTypes.OFF_HAND);
}