本文整理了Java中net.minecraft.util.EnumHand.equals()
方法的一些代码示例,展示了EnumHand.equals()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EnumHand.equals()
方法的具体详情如下:
包路径:net.minecraft.util.EnumHand
类名称:EnumHand
方法名:equals
暂无
代码示例来源: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: 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: 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: 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: 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: 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: ldtteam/minecolonies
/**
* Sets the currently held item.
*
* @param hand what hand we're setting
* @param slot from the inventory slot.
*/
public void setHeldItem(final EnumHand hand, final int slot)
{
citizen.getCitizenData().getInventory().setHeldItem(hand, slot);
if (hand.equals(EnumHand.MAIN_HAND))
{
citizen.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, citizen.getCitizenData().getInventory().getStackInSlot(slot));
}
else if (hand.equals(EnumHand.OFF_HAND))
{
citizen.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, citizen.getCitizenData().getInventory().getStackInSlot(slot));
}
}
代码示例来源:origin: ldtteam/minecolonies
if (placer.getActiveHand().equals(EnumHand.MAIN_HAND))
代码示例来源: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;
Expander expander = (Expander) worldIn.getTileEntity(pos);
if (expander == null) {
return true;
}
TurretBase base = expander.getBase();
if (base == null) {
worldIn.destroyBlock(pos, true);
return true;
}
if (PlayerUtil.canPlayerAccessBlock(playerIn, base) && state.getValue(EXPANDER_META) < 5) {
playerIn.openGui(OpenModularTurrets.instance, 2, worldIn, pos.getX(), pos.getY(), pos.getZ());
return true;
}
if (PlayerUtil.isPlayerOwner(playerIn, base)) {
if (playerIn.isSneaking() && playerIn.getHeldItemMainhand().isEmpty()) {
worldIn.destroyBlock(pos, true);
} else if (state.getValue(EXPANDER_META) < 5) {
playerIn.openGui(OpenModularTurrets.instance, 2, worldIn, pos.getX(), pos.getY(), pos.getZ());
} else {
return true;
}
} else {
addChatMessage(playerIn, new TextComponentString(safeLocalize("status.ownership")));
}
return true;
}
代码示例来源:origin: vadis365/TheErebus
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
if (hasTag(stack) && player.isSneaking() && hand.equals(EnumHand.MAIN_HAND)) {
Block block = world.getBlockState(pos).getBlock();
if (!world.isRemote && block != null) {
stack.getTagCompound().setString("dimName", player.getEntityWorld().provider.getDimensionType().getName());
stack.getTagCompound().setInteger("dimID", player.getEntityWorld().provider.getDimension());
stack.getTagCompound().setInteger("homeX", pos.getX());
stack.getTagCompound().setInteger("homeZ", pos.getZ());
return EnumActionResult.SUCCESS;
}
}
return EnumActionResult.FAIL;
}
代码示例来源:origin: vadis365/TheErebus
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if (!world.isRemote && !player.isSneaking() && stack.getTagCompound().hasKey("dimID") && hand.equals(EnumHand.MAIN_HAND)) {
int x = stack.getTagCompound().getInteger("homeX");
int y = stack.getTagCompound().getInteger("homeY");
int z = stack.getTagCompound().getInteger("homeZ");
BlockPos pos = new BlockPos(x, y, z);
int dimension = stack.getTagCompound().getInteger("dimID");
if (player.getEntityWorld().isAirBlock(pos.up(1)) && player.getEntityWorld().isAirBlock(pos.up(2)) && player.dimension == dimension) {
player.setPositionAndUpdate(x + 0.5D, y + 1D, z + 0.5D);
player.getEntityWorld().playSound(null, pos, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.PLAYERS, 1.0F, 1.0F);
}
}
return new ActionResult(EnumActionResult.PASS, stack);
}
代码示例来源:origin: vadis365/TheErebus
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing,
float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
if (hasTag(stack) && player.isSneaking() && hand.equals(EnumHand.MAIN_HAND)) {
Block block = world.getBlockState(pos).getBlock();
if (!world.isRemote && block != null) {
stack.getTagCompound().setString("dimName", player.getEntityWorld().provider.getDimensionType().getName());
stack.getTagCompound().setInteger("dimID", player.getEntityWorld().provider.getDimension());
stack.getTagCompound().setInteger("homeX", pos.getX());
stack.getTagCompound().setInteger("homeY", pos.getY());
stack.getTagCompound().setInteger("homeZ", pos.getZ());
return EnumActionResult.SUCCESS;
}
}
return EnumActionResult.FAIL;
}
内容来源于网络,如有侵权,请联系作者删除!