当前位置: 首页>>代码示例>>Java>>正文


Java HandTypes.OFF_HAND属性代码示例

本文整理汇总了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);
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:17,代码来源:LivingEntityProtocol.java

示例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);
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:20,代码来源:CodecPlayInUseEntity.java

示例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;
}
 
开发者ID:simon816,项目名称:Industrialization,代码行数:15,代码来源:Utils.java

示例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);
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:13,代码来源:IronGolemEntityProcotol.java

示例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;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:13,代码来源:LivingEntityProtocol.java

示例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);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:11,代码来源:CodecPlayInPlayerBlockPlacement.java

示例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);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:5,代码来源:SwingHandEntityEvent.java

示例8: handleSwingArm

public void handleSwingArm(MessagePlayInPlayerSwingArm message) {
    if (message.getHandType() == HandTypes.OFF_HAND) {
        return;
    }
    this.player.triggerEvent(SwingHandEntityEvent.of(HandTypes.MAIN_HAND));
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:6,代码来源:PlayerInteractionHandler.java

示例9: decode

@Override
public MessagePlayInPlayerUseItem decode(CodecContext context, ByteBuffer buf) throws CodecException {
    return new MessagePlayInPlayerUseItem(buf.readVarInt() == 0 ? HandTypes.MAIN_HAND : HandTypes.OFF_HAND);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:4,代码来源:CodecPlayInPlayerUseItem.java

示例10: decode

@Override
public MessagePlayInPlayerSwingArm decode(CodecContext context, ByteBuffer buf) throws CodecException {
    return new MessagePlayInPlayerSwingArm(buf.readVarInt() == 0 ? HandTypes.MAIN_HAND : HandTypes.OFF_HAND);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:4,代码来源:CodecPlayInPlayerSwingArm.java


注:本文中的org.spongepowered.api.data.type.HandTypes.OFF_HAND属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。