本文整理匯總了Java中net.minecraft.util.EnumActionResult.FAIL屬性的典型用法代碼示例。如果您正苦於以下問題:Java EnumActionResult.FAIL屬性的具體用法?Java EnumActionResult.FAIL怎麽用?Java EnumActionResult.FAIL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類net.minecraft.util.EnumActionResult
的用法示例。
在下文中一共展示了EnumActionResult.FAIL屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onItemRightClick
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
{
Stats statsCap = (Stats) player.getCapability(CapabilityPlayerStats.STATS, null);
PlayerInformation playerInfo = (PlayerInformation) player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
if (statsCap != null && playerInfo != null)
{
if (statsCap.getMana() - this.manaPerUse >= 0 && playerInfo.getPlayerLevel() >= NBTHelper.loadStackNBT(player.inventory.getCurrentItem()).getInteger("Level"))
{
player.setActiveHand(hand);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, player.inventory.getCurrentItem());
}
}
if (playerInfo.getPlayerLevel() < NBTHelper.loadStackNBT(player.inventory.getCurrentItem()).getInteger("Level"))
{
player.sendMessage(new TextComponentString(TextFormatting.RED + "WARNING: You are using a high-leveled item. It will be useless and will take significantly more damage if it is not removed."));
}
return new ActionResult<ItemStack>(EnumActionResult.FAIL, player.inventory.getCurrentItem());
}
示例2: onItemRightClick
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn){
ItemStack stack = playerIn.getHeldItem(handIn);
if (stack.getMetadata() == 0){
RayTraceResult raytraceresult = this.rayTrace(worldIn, playerIn, true);
if (raytraceresult != null && raytraceresult.typeOfHit != null && raytraceresult.typeOfHit == Type.BLOCK){
IBlockState state = worldIn.getBlockState(raytraceresult.getBlockPos());
if (state.getBlock() == Blocks.WATER){
stack.setItemDamage(1);
playerIn.setHeldItem(handIn, stack);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS,stack);
}
}
}
return new ActionResult<ItemStack>(EnumActionResult.FAIL,stack);
}
示例3: onItemRightClick
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
EntityEquipmentSlot entityequipmentslot = EntityLiving.getSlotForItemStack(itemStackIn);
ItemStack itemstack = playerIn.getItemStackFromSlot(entityequipmentslot);
if (itemstack == null)
{
playerIn.setItemStackToSlot(entityequipmentslot, itemStackIn.copy());
itemStackIn.stackSize = 0;
return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
else
{
return new ActionResult(EnumActionResult.FAIL, itemStackIn);
}
}
示例4: onItemUse
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
net.minecraft.block.state.IBlockState state = worldIn.getBlockState(pos);
if (facing == EnumFacing.UP && playerIn.canPlayerEdit(pos.offset(facing), facing, stack) && (state.getBlock()== net.minecraft.init.Blocks.GRASS ||state.getBlock()==net.minecraft.init.Blocks.DIRT|| state.getBlock()==net.minecraft.init.Blocks.SAND) && worldIn.isAirBlock(pos.up()))
{
worldIn.setBlockState(pos.up(), Block.REGISTRY.getObject(new ResourceLocation(GotWood.MODID, "palm_sapling")).getDefaultState());
--stack.stackSize;
return EnumActionResult.SUCCESS;
}
else
{
return EnumActionResult.FAIL;
}
}
示例5: onItemUse
/**
* Called when a Block is right-clicked with this Item
*/
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
boolean flag = worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos);
BlockPos blockpos = flag ? pos : pos.offset(facing);
if (playerIn.canPlayerEdit(blockpos, facing, stack) && worldIn.canBlockBePlaced(worldIn.getBlockState(blockpos).getBlock(), blockpos, false, facing, (Entity)null, stack) && Blocks.REDSTONE_WIRE.canPlaceBlockAt(worldIn, blockpos))
{
--stack.stackSize;
worldIn.setBlockState(blockpos, Blocks.REDSTONE_WIRE.getDefaultState());
return EnumActionResult.SUCCESS;
}
else
{
return EnumActionResult.FAIL;
}
}
示例6: onItemUse
/**
* Called when a Block is right-clicked with this Item
*/
public EnumActionResult onItemUse(EntityPlayer stack, World playerIn, BlockPos worldIn, EnumHand pos, EnumFacing hand, float facing, float hitX, float hitY)
{
ItemStack itemstack = stack.getHeldItem(pos);
if (hand == EnumFacing.UP && stack.canPlayerEdit(worldIn.offset(hand), hand, itemstack) && playerIn.getBlockState(worldIn).getBlock() == this.soilBlockID && playerIn.isAirBlock(worldIn.up()))
{
playerIn.setBlockState(worldIn.up(), this.crops.getDefaultState());
itemstack.func_190918_g(1);
return EnumActionResult.SUCCESS;
}
else
{
return EnumActionResult.FAIL;
}
}
示例7: onItemUse
/**
* Called when a Block is right-clicked with this Item
*/
public EnumActionResult onItemUse(EntityPlayer stack, World playerIn, BlockPos worldIn, EnumHand pos, EnumFacing hand, float facing, float hitX, float hitY)
{
worldIn = worldIn.offset(hand);
ItemStack itemstack = stack.getHeldItem(pos);
if (!stack.canPlayerEdit(worldIn, hand, itemstack))
{
return EnumActionResult.FAIL;
}
else
{
if (playerIn.getBlockState(worldIn).getMaterial() == Material.AIR)
{
playerIn.playSound(stack, worldIn, SoundEvents.ITEM_FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0F, itemRand.nextFloat() * 0.4F + 0.8F);
playerIn.setBlockState(worldIn, Blocks.FIRE.getDefaultState(), 11);
}
itemstack.damageItem(1, stack);
return EnumActionResult.SUCCESS;
}
}
示例8: onItemUse
/**
* Called when a Block is right-clicked with this Item
*/
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
pos = pos.offset(facing);
if (!playerIn.canPlayerEdit(pos, facing, stack))
{
return EnumActionResult.FAIL;
}
else
{
if (worldIn.isAirBlock(pos))
{
worldIn.playSound(playerIn, pos, SoundEvents.ITEM_FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0F, itemRand.nextFloat() * 0.4F + 0.8F);
worldIn.setBlockState(pos, Blocks.FIRE.getDefaultState(), 11);
}
stack.damageItem(1, playerIn);
return EnumActionResult.SUCCESS;
}
}
示例9: onItemRightClick
/**
* Called when the equipped item is right clicked.
*/
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
{
ItemStack itemstack = playerIn.getHeldItem(handIn);
boolean flag = !this.findAmmo(playerIn).isEmpty();
ActionResult<ItemStack> ret = net.minecraftforge.event.ForgeEventFactory.onArrowNock(itemstack, worldIn, playerIn, handIn, flag);
if (ret != null) return ret;
if (!playerIn.capabilities.isCreativeMode && !flag)
{
return flag ? new ActionResult(EnumActionResult.PASS, itemstack) : new ActionResult(EnumActionResult.FAIL, itemstack);
}
else
{
playerIn.setActiveHand(handIn);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack);
}
}
示例10: onItemUse
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
if (!player.getEntityWorld().isRemote)
{
return EnumActionResult.SUCCESS;
}
return EnumActionResult.FAIL;
}
示例11: onItemUse
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
if (player.getEntityWorld().isRemote) return EnumActionResult.FAIL;
if (!containsEntity(stack)) return EnumActionResult.FAIL;
Entity entity = getEntityFromStack(stack, worldIn, true);
BlockPos blockPos = pos.offset(facing);
entity.setPositionAndRotation(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5, 0, 0);
stack.setTagCompound(new NBTTagCompound());
player.setHeldItem(hand, stack);
worldIn.spawnEntity(entity);
if (entity instanceof EntityLiving) ((EntityLiving) entity).playLivingSound();
return EnumActionResult.SUCCESS;
}
示例12: onItemUse
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
if (worldIn.isRemote)
{
return EnumActionResult.FAIL;
}
TileEntity tile = worldIn.getTileEntity(pos);
if (tile != null && tile.hasCapability(ExPFarmlandCapability.farmlandCap, EnumFacing.UP))
{
if (worldIn.isAirBlock(pos.up()))
{
// FIXME fix packet pipeline render issues!
try
{
ItemStack held = player.getHeldItem(hand);
CapabilityExPSeeds seedsCap = (CapabilityExPSeeds) held.getCapability(ExPSeedsCapability.seedsCap, null);
CropStats stats = new CropStats(seedsCap.getOrCreateStats());
worldIn.setBlockState(pos.up(), ExPBlocks.crop.getDefaultState());
TileCrop cropTile = (TileCrop) worldIn.getTileEntity(pos.up());
ExPCrop cropCap = (ExPCrop) IExPCrop.of(cropTile);
cropCap.stats = stats;
cropCap.timeKeeper = new Calendar(IExPWorld.of(worldIn).today().getTime());
NBTTagCompound sent = new NBTTagCompound();
sent.setTag("tileData", cropTile.serializeNBT());
sent.setTag("blockPosData", new DimBlockPos(pos.up(), worldIn.provider.getDimension()).serializeNBT());
VoidNetwork.sendDataToAllAround(PacketType.TileData, sent, new TargetPoint(worldIn.provider.getDimension(), pos.getX(), pos.up().getY(), pos.getZ(), 96));
held.shrink(1);
return EnumActionResult.SUCCESS;
}
catch (Exception ex)
{
ExPMisc.modLogger.log(LogLevel.Error, "Unable to place seeds at %s!", ex, pos.toString());
}
}
}
return super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ);
}
示例13: onItemRightClick
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
{
if(!hasDrinkEffect(playerIn, handIn))
return new ActionResult<ItemStack>(EnumActionResult.FAIL, playerIn.getHeldItem(handIn));
playerIn.setActiveHand(handIn);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, playerIn.getHeldItem(handIn));
}
示例14: onItemUse
/**
* Called when a Block is right-clicked with this Item
*/
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
if (worldIn.isRemote)
{
return EnumActionResult.SUCCESS;
}
else
{
pos = pos.offset(facing);
if (!playerIn.canPlayerEdit(pos, facing, stack))
{
return EnumActionResult.FAIL;
}
else
{
if (worldIn.getBlockState(pos).getMaterial() == Material.AIR)
{
worldIn.playSound((EntityPlayer)null, pos, SoundEvents.ITEM_FIRECHARGE_USE, SoundCategory.BLOCKS, 1.0F, (itemRand.nextFloat() - itemRand.nextFloat()) * 0.2F + 1.0F);
worldIn.setBlockState(pos, Blocks.FIRE.getDefaultState());
}
if (!playerIn.capabilities.isCreativeMode)
{
--stack.stackSize;
}
return EnumActionResult.SUCCESS;
}
}
}
示例15: onItemUse
/**
* Called when a Block is right-clicked with this Item
*/
public EnumActionResult onItemUse(EntityPlayer stack, World playerIn, BlockPos worldIn, EnumHand pos, EnumFacing hand, float facing, float hitX, float hitY)
{
if (playerIn.isRemote)
{
return EnumActionResult.SUCCESS;
}
else if (hand != EnumFacing.UP)
{
return EnumActionResult.FAIL;
}
else
{
IBlockState iblockstate = playerIn.getBlockState(worldIn);
Block block = iblockstate.getBlock();
boolean flag = block.isReplaceable(playerIn, worldIn);
if (!flag)
{
worldIn = worldIn.up();
}
int i = MathHelper.floor((double)(stack.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
EnumFacing enumfacing = EnumFacing.getHorizontal(i);
BlockPos blockpos = worldIn.offset(enumfacing);
ItemStack itemstack = stack.getHeldItem(pos);
if (stack.canPlayerEdit(worldIn, hand, itemstack) && stack.canPlayerEdit(blockpos, hand, itemstack))
{
IBlockState iblockstate1 = playerIn.getBlockState(blockpos);
boolean flag1 = iblockstate1.getBlock().isReplaceable(playerIn, blockpos);
boolean flag2 = flag || playerIn.isAirBlock(worldIn);
boolean flag3 = flag1 || playerIn.isAirBlock(blockpos);
if (flag2 && flag3 && playerIn.getBlockState(worldIn.down()).isFullyOpaque() && playerIn.getBlockState(blockpos.down()).isFullyOpaque())
{
IBlockState iblockstate2 = Blocks.BED.getDefaultState().withProperty(BlockBed.OCCUPIED, Boolean.valueOf(false)).withProperty(BlockBed.FACING, enumfacing).withProperty(BlockBed.PART, BlockBed.EnumPartType.FOOT);
playerIn.setBlockState(worldIn, iblockstate2, 10);
playerIn.setBlockState(blockpos, iblockstate2.withProperty(BlockBed.PART, BlockBed.EnumPartType.HEAD), 10);
playerIn.notifyNeighborsRespectDebug(worldIn, block, false);
playerIn.notifyNeighborsRespectDebug(blockpos, iblockstate1.getBlock(), false);
SoundType soundtype = iblockstate2.getBlock().getSoundType();
playerIn.playSound((EntityPlayer)null, worldIn, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
itemstack.func_190918_g(1);
return EnumActionResult.SUCCESS;
}
else
{
return EnumActionResult.FAIL;
}
}
else
{
return EnumActionResult.FAIL;
}
}
}