net.minecraft.util.EnumHand类的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(116)

本文整理了Java中net.minecraft.util.EnumHand类的一些代码示例,展示了EnumHand类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EnumHand类的具体详情如下:
包路径:net.minecraft.util.EnumHand
类名称:EnumHand

EnumHand介绍

暂无

代码示例

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

public PacketPartPlacement( final ByteBuf stream )
{
  this.x = stream.readInt();
  this.y = stream.readInt();
  this.z = stream.readInt();
  this.face = stream.readByte();
  this.eyeHeight = stream.readFloat();
  this.hand = EnumHand.values()[stream.readByte()];
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

public PacketPartPlacement( final BlockPos pos, final EnumFacing face, final float eyeHeight, final EnumHand hand )
{
  final ByteBuf data = Unpooled.buffer();
  data.writeInt( this.getPacketID() );
  data.writeInt( pos.getX() );
  data.writeInt( pos.getY() );
  data.writeInt( pos.getZ() );
  data.writeByte( face.ordinal() );
  data.writeFloat( eyeHeight );
  data.writeByte( hand.ordinal() );
  this.configureWrite( data );
}

代码示例来源:origin: CyclopsMC/EvilCraft

/**
 * Make a new instance.
 * @param itemIndex The index of the crafter in the player inventory.
 * @param hand The hand the item is in.
 */
public ExaltedCrafterOpenPacket(int itemIndex, EnumHand hand) {
  this.itemIndex = itemIndex;
  this.mainHand = EnumHand.MAIN_HAND.equals(hand);
}

代码示例来源:origin: Mine-and-blade-admin/Battlegear2

@Override
  public float apply(@Nonnull ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
    if (stack.getItem() instanceof IArrowContainer2 && entityIn != null && entityIn.isHandActive()) {
      EnumHand hand = EnumHand.values()[entityIn.getActiveHand().ordinal() + 1 % 2];
      if(entityIn.getHeldItem(hand) == stack){
        return 1;
      }
    }
    return 0;
  }
};

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

public PacketClick( final ByteBuf stream )
{
  this.x = stream.readInt();
  this.y = stream.readInt();
  this.z = stream.readInt();
  byte side = stream.readByte();
  if( side != -1 )
  {
    this.side = EnumFacing.values()[side];
  }
  else
  {
    this.side = null;
  }
  this.hitX = stream.readFloat();
  this.hitY = stream.readFloat();
  this.hitZ = stream.readFloat();
  this.hand = EnumHand.values()[stream.readByte()];
  this.leftClick = stream.readBoolean();
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

public PacketClick( final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final EnumHand hand, boolean leftClick )
{
  final ByteBuf data = Unpooled.buffer();
  data.writeInt( this.getPacketID() );
  data.writeInt( this.x = pos.getX() );
  data.writeInt( this.y = pos.getY() );
  data.writeInt( this.z = pos.getZ() );
  if( side == null )
  {
    data.writeByte( -1 );
  }
  else
  {
    data.writeByte( side.ordinal() );
  }
  data.writeFloat( this.hitX = hitX );
  data.writeFloat( this.hitY = hitY );
  data.writeFloat( this.hitZ = hitZ );
  data.writeByte( hand.ordinal() );
  data.writeBoolean( this.leftClick = leftClick );
  this.configureWrite( data );
}

代码示例来源:origin: ldtteam/minecolonies

/**
 * Set item to be held by citizen.
 *
 * @param slot Slot index with item to be held by citizen.
 */
public void setHeldItem(final EnumHand hand, final int slot)
{
  if (hand.equals(EnumHand.MAIN_HAND))
  {
    this.mainItem = slot;
  }
  this.offhandItem = slot;
}

代码示例来源:origin: SleepyTrousers/EnderIO

@Override
public void fromBytes(ByteBuf buffer) {
 hand = EnumHand.values()[buffer.readByte()];
}

代码示例来源:origin: SleepyTrousers/EnderIO

public PacketDrainStaff(int powerUse, EnumHand hand) {
 this.powerUse = powerUse;
 this.hand = hand.ordinal();
}

代码示例来源:origin: ldtteam/minecolonies

/**
 * Gets slot that hold item that is being held by citizen.
 *
 * @return Slot index of held item
 */
public int getHeldItemSlot(final EnumHand hand)
{
  if (hand.equals(EnumHand.MAIN_HAND))
  {
    return mainItem;
  }
  return offhandItem;
}

代码示例来源:origin: JurassiCraftTeam/JurassiCraft2

@Override
  public void fromBytes(ByteBuf buffer) {
    this.x = buffer.readInt();
    this.y = buffer.readInt();
    this.z = buffer.readInt();
    this.dino = buffer.readInt();
    this.facing = EnumFacing.getFront(buffer.readByte());
    this.hand = EnumHand.values()[buffer.readByte()];
    this.pos = new BlockPos(this.x, this.y, this.z);
  }
}

代码示例来源:origin: SleepyTrousers/EnderIO

public PacketDrainStaff(int powerUse, EnumHand hand) {
 this.powerUse = powerUse;
 this.hand = hand.ordinal();
}

代码示例来源:origin: ldtteam/minecolonies

/**
 * Returns the item that is currently being held by citizen.
 *
 * @return {@link ItemStack} currently being held by citizen.
 */
public ItemStack getHeldItem(final EnumHand hand)
{
  if (hand.equals(EnumHand.MAIN_HAND))
  {
    return getStackInSlot(mainItem);
  }
  return getStackInSlot(offhandItem);
}

代码示例来源:origin: ForestryMC/ForestryMC

@Nullable
protected EnumHand getHand() {
  for (EnumHand hand : EnumHand.values()) {
    ItemStack held = player.getHeldItem(hand);
    if (isSameItemInventory(held, parent)) {
      return hand;
    }
  }
  return null;
}

代码示例来源:origin: SleepyTrousers/EnderIO

@Override
public void toBytes(ByteBuf buffer) {
 buffer.writeByte(hand.ordinal());
}

代码示例来源:origin: OpenModularTurretsTeam/OpenModularTurrets

@Override
@ParametersAreNonnullByDefault
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
  if (hand.equals(EnumHand.OFF_HAND)) return true;
  BaseAddon baseAddon = (BaseAddon) worldIn.getTileEntity(pos);
  if (baseAddon == null) {
    return true;
  }
  TurretBase base = baseAddon.getBase();
  if (base == null) {
    worldIn.destroyBlock(pos, true);
    return true;
  }
  return true;
}

代码示例来源:origin: ForestryMC/ForestryMC

protected ItemStack getParent() {
  for (EnumHand hand : EnumHand.values()) {
    ItemStack held = player.getHeldItem(hand);
    if (isSameItemInventory(held, parent)) {
      return held;
    }
  }
  return parent;
}

代码示例来源:origin: JurassiCraftTeam/JurassiCraft2

@Override
public void toBytes(ByteBuf buffer) {
  buffer.writeInt(this.x);
  buffer.writeInt(this.y);
  buffer.writeInt(this.z);
  buffer.writeInt(this.dino);
  buffer.writeByte((byte) this.facing.getIndex());
  buffer.writeByte((byte) this.hand.ordinal());
}

代码示例来源:origin: ldtteam/minecolonies

/**
 * Get the strength against a block.
 *
 * @param state the block.
 * @return the float value.
 */
public float getStrVsBlock(final EnumHand hand, final IBlockState state)
{
  float f = 1.0F;
  if (hand.equals(EnumHand.MAIN_HAND))
  {
    if (!(this.mainInventory.get(this.mainItem)).isEmpty())
    {
      f *= (this.mainInventory.get(this.mainItem)).getDestroySpeed(state);
    }
  }
  else if (hand.equals(EnumHand.OFF_HAND)
        && !(this.mainInventory.get(this.offhandItem)).isEmpty())
  {
    f *= (this.mainInventory.get(this.offhandItem)).getDestroySpeed(state);
  }
  return f;
}

代码示例来源:origin: PenguinSquad/Harvest-Festival

@SuppressWarnings("unchecked")
public static <S> EnumHand getHandItemIsIn(EntityPlayer player, Matcher<S> matcher, S search, int... amount) {
  int count = amount == null || amount.length == 0 ? 1 : amount[0];
  for (EnumHand hand: EnumHand.values()) {
    if (getStackSizeOfHand(player, matcher, search, hand) != 0) {
      if (getCount(player, search, matcher) >= count) {
        return hand;
      }
    }
  }
  return null;
}

相关文章

微信公众号

最新文章

更多