本文整理匯總了Java中net.minecraft.util.EnumActionResult類的典型用法代碼示例。如果您正苦於以下問題:Java EnumActionResult類的具體用法?Java EnumActionResult怎麽用?Java EnumActionResult使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
EnumActionResult類屬於net.minecraft.util包,在下文中一共展示了EnumActionResult類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onItemRightClick
import net.minecraft.util.EnumActionResult; //導入依賴的package包/類
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
ItemStack itemstack = worldIn.getHeldItem(playerIn);
if (!worldIn.capabilities.isCreativeMode)
{
itemstack.func_190918_g(1);
}
itemStackIn.playSound((EntityPlayer)null, worldIn.posX, worldIn.posY, worldIn.posZ, SoundEvents.ENTITY_ENDERPEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
worldIn.getCooldownTracker().setCooldown(this, 20);
if (!itemStackIn.isRemote)
{
EntityEnderPearl entityenderpearl = new EntityEnderPearl(itemStackIn, worldIn);
entityenderpearl.setHeadingFromThrower(worldIn, worldIn.rotationPitch, worldIn.rotationYaw, 0.0F, 1.5F, 1.0F);
itemStackIn.spawnEntityInWorld(entityenderpearl);
}
worldIn.addStat(StatList.getObjectUseStats(this));
return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
示例2: onItemUse
import net.minecraft.util.EnumActionResult; //導入依賴的package包/類
/**
* 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)
{
Block block = playerIn.getBlockState(worldIn).getBlock();
if (!(block instanceof BlockFence))
{
return EnumActionResult.PASS;
}
else
{
if (!playerIn.isRemote)
{
attachToFence(stack, playerIn, worldIn);
}
return EnumActionResult.SUCCESS;
}
}
示例3: onItemRightClick
import net.minecraft.util.EnumActionResult; //導入依賴的package包/類
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
List<EntityLivingBase> elb = acquireAllLookTargets(player, 32, 3);
for (EntityLivingBase target : elb) {
if (target.canEntityBeSeen(player) && !(target instanceof EntityPlayer)) {
BlockPos targetpos = target.getPosition();
BlockPos playerpos = player.getPosition();
if (!world.isRemote) {
target.setPositionAndUpdate(playerpos.getX(), playerpos.getY(), playerpos.getZ());
player.setPositionAndUpdate(targetpos.getX(), targetpos.getY(), targetpos.getZ());
if (target instanceof EntityWolf && world.rand.nextInt(100) == 0)
target.entityDropItem(UCItems.generic.createStack(EnumItems.DOGRESIDUE), 1);
stack.damageItem(1, player);
return new ActionResult(EnumActionResult.SUCCESS, stack);
}
}
}
return new ActionResult(EnumActionResult.PASS, stack);
}
示例4: onPlayerClickBlock
import net.minecraft.util.EnumActionResult; //導入依賴的package包/類
@SubscribeEvent
public void onPlayerClickBlock(PlayerInteractEvent.RightClickBlock event) {
if (event.getEntityPlayer() == null || !event.getEntityPlayer().isSneaking()) {
return;
}
if (event.getItemStack().getItem() == ModItems.hammer && !event.getEntityPlayer().getCooldownTracker().hasCooldown(ModItems.hammer)) {
if (!event.getWorld().isRemote) {
BlockPos pos = event.getPos().offset(event.getFace());
event.getWorld().createExplosion(event.getEntityPlayer(), pos.getX() + 0.5, pos.getY() + 0.5,
pos.getZ() + 0.5, 3, false);
}
event.getEntityPlayer().swingArm(event.getHand());
event.getEntityPlayer().setActiveHand(event.getHand());
event.getEntityPlayer().getCooldownTracker().setCooldown(ModItems.hammer, 200);
ModItems.hammer.setDamage(event.getItemStack(), ModItems.hammer.getDamage(event.getItemStack()) - 10);
event.setCancellationResult(EnumActionResult.SUCCESS);
event.setResult(Event.Result.ALLOW);
event.setCanceled(true);
}
}
示例5: onItemUse
import net.minecraft.util.EnumActionResult; //導入依賴的package包/類
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (hand != EnumHand.MAIN_HAND) return EnumActionResult.PASS;
TileEntity te = worldIn.getTileEntity(pos);
if (te == null) return EnumActionResult.PASS;
if (te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing)) {
if (!worldIn.isRemote) {
setLiquidProvidingLocation(player.getHeldItemMainhand(), pos, worldIn.provider.getDimension());
player.sendStatusMessage(new TextComponentTranslation("message.amadronTable.setLiquidProvidingLocation", pos.getX(), pos.getY(), pos.getZ(),
worldIn.provider.getDimension(), worldIn.provider.getDimensionType().toString()), false);
}
} else if (te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing)) {
if (!worldIn.isRemote) {
setItemProvidingLocation(player.getHeldItemMainhand(), pos, worldIn.provider.getDimension());
player.sendStatusMessage(new TextComponentTranslation("message.amadronTable.setItemProvidingLocation", pos.getX(), pos.getY(), pos.getZ(),
worldIn.provider.getDimension(), worldIn.provider.getDimensionType().toString()), false);
}
} else {
return EnumActionResult.PASS;
}
return EnumActionResult.SUCCESS;
}
示例6: onItemRightClick
import net.minecraft.util.EnumActionResult; //導入依賴的package包/類
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
if (!playerIn.capabilities.isCreativeMode)
{
--itemStackIn.stackSize;
}
worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_ENDERPEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
playerIn.getCooldownTracker().setCooldown(this, 20);
if (!worldIn.isRemote)
{
EntityEnderPearl entityenderpearl = new EntityEnderPearl(worldIn, playerIn);
entityenderpearl.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
worldIn.spawnEntityInWorld(entityenderpearl);
}
playerIn.addStat(StatList.getObjectUseStats(this));
return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
示例7: onItemRightClick
import net.minecraft.util.EnumActionResult; //導入依賴的package包/類
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer player, EnumHand handIn) {
Mouse.setGrabbed(false); // TODO Remove debug
ItemStack is = player.getHeldItem(handIn);
if (player.getHeldItemMainhand().getCount() > 4) {
if (worldIn.isRemote) {
GuiKnapping.staticMaterial = CraftMat.CLAY;
GuiKnapping.staticMaterialSub = this.getSubName(is.getItemDamage());
player.openGui(FirmaMod.instance, GuiHandler.GUI_KNAPPING, player.world, (int) player.posX, (int) player.posY, (int) player.posZ);
} else {
PlayerData pd = PlayerData.getPlayerData(player.getUniqueID());
pd.resetKnapCraft();
pd.setItemStack(player.getHeldItemMainhand());
pd.setCraftingMaterial(CraftMat.CLAY);
}
}
return new ActionResult<ItemStack>(EnumActionResult.PASS, is);
}
示例8: onItemRightClick
import net.minecraft.util.EnumActionResult; //導入依賴的package包/類
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer player, EnumHand handIn) {
ItemStack is = player.getHeldItem(handIn);
if (player.getHeldItemMainhand().getCount() > 1) {
if (worldIn.isRemote) {
GuiKnapping.staticMaterial = CraftMat.STONE;
GuiKnapping.staticMaterialSub = this.getSubName(is.getItemDamage());
} else {
PlayerData pd = PlayerData.getPlayerData(player.getUniqueID());
pd.resetKnapCraft();
pd.setItemStack(player.getHeldItemMainhand());
pd.setCraftingMaterial(CraftMat.STONE);
}
}
player.openGui(FirmaMod.instance, GuiHandler.GUI_KNAPPING, player.world, (int) player.posX, (int) player.posY, (int) player.posZ);
return new ActionResult<ItemStack>(EnumActionResult.PASS, is);
}
示例9: onItemRightClick
import net.minecraft.util.EnumActionResult; //導入依賴的package包/類
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
{
if (world.isRemote) { return new ActionResult(EnumActionResult.PASS, stack); } // Not doing this on client side
if (stack.hasTagCompound() && stack.getTagCompound().getInteger("cooldown") > 0) { return new ActionResult(EnumActionResult.PASS, stack); } // Not yet
if (TerritoryHandler.addChunkToFaction(player)) { stack.stackSize -= 1; }
else // Failed, so adding a cooldown
{
if (!stack.hasTagCompound()) { stack.setTagCompound(new NBTTagCompound()); } // Init
stack.getTagCompound().setInteger("cooldown", 20); // Can only try once a second
}
return new ActionResult(EnumActionResult.PASS, stack);
}
示例10: onItemRightClick
import net.minecraft.util.EnumActionResult; //導入依賴的package包/類
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
if (!world.isRemote) {
IBaublesItemHandler baubles = BaublesApi.getBaublesHandler(player);
for (int i = 0; i < baubles.getSlots(); i++)
if (baubles.getStackInSlot(i).isEmpty() && baubles.isItemValidForSlot(i, player.getHeldItem(hand), player)) {
baubles.setStackInSlot(i, player.getHeldItem(hand).copy());
if (!player.capabilities.isCreativeMode) {
player.setHeldItem(hand, ItemStack.EMPTY);
}
onEquipped(player.getHeldItem(hand), player);
break;
}
}
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, player.getHeldItem(hand));
}
示例11: onItemUse
import net.minecraft.util.EnumActionResult; //導入依賴的package包/類
@Override
@Nonnull
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 (!(stack.getItem() instanceof MooncakeMold))
return EnumActionResult.PASS;
if (!stack.hasTagCompound())
return EnumActionResult.PASS;
if (world.getBlockState(pos).getBlock() == Blocks.IRON_BLOCK) {
if (!stack.getTagCompound().hasKey("hitCount"))
stack.getTagCompound().setInteger("hitCount", 0);
stack.getTagCompound().setInteger("hitCount", stack.getTagCompound().getInteger("hitCount") + 1);
if (stack.getTagCompound().getInteger("hitCount") >= 5) {
ItemHandlerHelper.giveItemToPlayer(player, new ItemStack(MooncakeConstants.RAW_MOONCAKE_ITEM, 1, stack.getTagCompound().getInteger("meta")));
stack.setTagCompound(null);
}
return EnumActionResult.SUCCESS;
}
return EnumActionResult.PASS;
}
示例12: onItemRightClick
import net.minecraft.util.EnumActionResult; //導入依賴的package包/類
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
ItemStack toConvert = convertEdibles(stack);
if (!UniqueCrops.baublesLoaded) {
if (!world.isRemote)
player.setHeldItem(hand, toConvert);
return ActionResult.newResult(EnumActionResult.PASS, toConvert);
} else {
ItemStack bauble = BaublesApi.getBaublesHandler(player).getStackInSlot(6);
if (bauble == null || (bauble != null && bauble.getItem() != UCBaubles.emblemIronstomach)) {
if (!world.isRemote) {
player.setHeldItem(hand, toConvert);
}
return ActionResult.newResult(EnumActionResult.PASS, toConvert);
}
}
return super.onItemRightClick(stack, world, player, hand);
}
示例13: onItemUse
import net.minecraft.util.EnumActionResult; //導入依賴的package包/類
/**
* 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)
{
IBlockState iblockstate = worldIn.getBlockState(pos);
if (iblockstate.getBlock() == Blocks.JUKEBOX && !((Boolean)iblockstate.getValue(BlockJukebox.HAS_RECORD)).booleanValue())
{
if (!worldIn.isRemote)
{
((BlockJukebox)Blocks.JUKEBOX).insertRecord(worldIn, pos, iblockstate, stack);
worldIn.playEvent((EntityPlayer)null, 1010, pos, Item.getIdFromItem(this));
--stack.stackSize;
playerIn.addStat(StatList.RECORD_PLAYED);
}
return EnumActionResult.SUCCESS;
}
else
{
return EnumActionResult.PASS;
}
}
示例14: onItemUse
import net.minecraft.util.EnumActionResult; //導入依賴的package包/類
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (stack.getItemDamage() == EnumItems.TIMEMEAL.ordinal() && player.canPlayerEdit(pos, facing, stack)) {
Block crops = world.getBlockState(pos).getBlock();
if (crops != null && crops instanceof BlockCrops) {
if (crops != UCBlocks.cropMerlinia)
world.setBlockState(pos, ((BlockCrops)crops).withAge(0), 2);
else if (crops == UCBlocks.cropMerlinia)
((Merlinia)crops).merliniaGrowth(world, pos, world.rand.nextInt(1) + 1);
else if (crops instanceof BlockNetherWart)
((BlockNetherWart)crops).updateTick(world, pos, world.getBlockState(pos), world.rand);
if (!player.capabilities.isCreativeMode && !player.worldObj.isRemote)
stack.stackSize--;
UCPacketHandler.sendToNearbyPlayers(world, pos, new PacketUCEffect(EnumParticleTypes.VILLAGER_HAPPY, pos.getX() - 0.5D, pos.getY(), pos.getZ() - 0.5D, 6));
return EnumActionResult.SUCCESS;
}
}
return super.onItemUse(stack, player, world, pos, hand, facing, hitX, hitY, hitZ);
}
示例15: onItemRightClick
import net.minecraft.util.EnumActionResult; //導入依賴的package包/類
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
{
ItemStack stack = player.getHeldItem(hand);
if (!player.capabilities.isCreativeMode)
{
stack.shrink(1);
}
world.playSound((EntityPlayer)null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!world.isRemote)
{
EntityCurseOrb entity = new EntityCurseOrb(world, player);
entity.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0.0F, 1.5F, 1.0F);
world.spawnEntity(entity);
}
// playerIn.addStat(StatList.getObjectUseStats(this));
return new ActionResult(EnumActionResult.SUCCESS, stack);
}