本文整理汇总了Java中net.minecraft.util.ActionResult类的典型用法代码示例。如果您正苦于以下问题:Java ActionResult类的具体用法?Java ActionResult怎么用?Java ActionResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ActionResult类属于net.minecraft.util包,在下文中一共展示了ActionResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onItemRightClick
import net.minecraft.util.ActionResult; //导入依赖的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_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!worldIn.isRemote)
{
EntitySnowball entitysnowball = new EntitySnowball(worldIn, playerIn);
entitysnowball.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
worldIn.spawnEntityInWorld(entitysnowball);
}
playerIn.addStat(StatList.getObjectUseStats(this));
return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
示例2: onItemRightClick
import net.minecraft.util.ActionResult; //导入依赖的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);
}
示例3: onItemRightClick
import net.minecraft.util.ActionResult; //导入依赖的package包/类
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
ItemStack itemstack = worldIn.getHeldItem(playerIn);
ItemStack itemstack1 = worldIn.capabilities.isCreativeMode ? itemstack.copy() : itemstack.splitStack(1);
itemStackIn.playSound((EntityPlayer)null, worldIn.posX, worldIn.posY, worldIn.posZ, SoundEvents.ENTITY_SPLASH_POTION_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!itemStackIn.isRemote)
{
EntityPotion entitypotion = new EntityPotion(itemStackIn, worldIn, itemstack1);
entitypotion.setHeadingFromThrower(worldIn, worldIn.rotationPitch, worldIn.rotationYaw, -20.0F, 0.5F, 1.0F);
itemStackIn.spawnEntityInWorld(entitypotion);
}
worldIn.addStat(StatList.getObjectUseStats(this));
return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
示例4: onItemRightClick
import net.minecraft.util.ActionResult; //导入依赖的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));
}
示例5: onItemRightClick
import net.minecraft.util.ActionResult; //导入依赖的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_LINGERINGPOTION_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!worldIn.isRemote)
{
EntityPotion entitypotion = new EntityPotion(worldIn, playerIn, itemStackIn);
entitypotion.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, -20.0F, 0.5F, 1.0F);
worldIn.spawnEntityInWorld(entitypotion);
}
playerIn.addStat(StatList.getObjectUseStats(this));
return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
示例6: onItemRightClick
import net.minecraft.util.ActionResult; //导入依赖的package包/类
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);
}
}
示例7: onItemRightClick
import net.minecraft.util.ActionResult; //导入依赖的package包/类
@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);
}
示例8: onItemRightClick
import net.minecraft.util.ActionResult; //导入依赖的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);
}
示例9: onItemRightClick
import net.minecraft.util.ActionResult; //导入依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {
if(worldIn.isRemote)
{
//check to make sure the player didn't just click on a chalk tile
//it's a little hacky but it gets the job done eh?
if (worldIn.getBlockState(playerIn.rayTrace(5.0f, 0).getBlockPos()).getBlock()!= ModBlocks.chalkBase) {
//if the scrap has nbtdata for text, open it. Otherwise open a blank scrap
if (itemStackIn.getTagCompound() == null || !itemStackIn.getTagCompound().hasKey("text"))
Minecraft.getMinecraft().displayGuiScreen(new GuiPaperScrap(""));
else
Minecraft.getMinecraft().displayGuiScreen(new GuiPaperScrap(itemStackIn.getTagCompound().getString("text")));
}
}
return super.onItemRightClick(itemStackIn, worldIn, playerIn, hand);
}
示例10: onItemRightClick
import net.minecraft.util.ActionResult; //导入依赖的package包/类
/**
* Called when the equipped item is right clicked.
*/
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
{
ItemStack itemstack = playerIn.getHeldItem(handIn);
itemstack.shrink(1);
worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!worldIn.isRemote)
{
EntityEgg entityegg = new CoreEntityEgg(worldIn, playerIn);
entityegg.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
worldIn.spawnEntity(entityegg);
}
playerIn.addStat(StatList.getObjectUseStats(this));
return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
示例11: onItemRightClick
import net.minecraft.util.ActionResult; //导入依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack itemStack = player.getHeldItem(hand);
if (player.isSneaking()) {
return super.onItemRightClick(world, player, hand);
}
if (getItemFreq(itemStack) == 0)
return new ActionResult<>(EnumActionResult.PASS, itemStack);
if (!player.capabilities.isCreativeMode) {
itemStack.shrink(1);
}
if (!world.isRemote) {
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
EntityWirelessTracker tracker = new EntityWirelessTracker(world, getItemFreq(itemStack), player);
world.spawnEntity(tracker);
WRServerPH.sendThrowTracker(tracker, player);
}
return new ActionResult<>(EnumActionResult.SUCCESS, itemStack);
}
示例12: onItemRightClick
import net.minecraft.util.ActionResult; //导入依赖的package包/类
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
if (playerIn.isRiding() && playerIn.getRidingEntity() instanceof EntityPig)
{
EntityPig entitypig = (EntityPig)playerIn.getRidingEntity();
if (itemStackIn.getMaxDamage() - itemStackIn.getMetadata() >= 7 && entitypig.boost())
{
itemStackIn.damageItem(7, playerIn);
if (itemStackIn.stackSize == 0)
{
ItemStack itemstack = new ItemStack(Items.FISHING_ROD);
itemstack.setTagCompound(itemStackIn.getTagCompound());
return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
}
playerIn.addStat(StatList.getObjectUseStats(this));
return new ActionResult(EnumActionResult.PASS, itemStackIn);
}
示例13: onItemRightClick
import net.minecraft.util.ActionResult; //导入依赖的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 (!player.capabilities.isCreativeMode) { return new ActionResult(EnumActionResult.PASS, stack); } // Creative mode only
if (player.isSneaking())
{
this.toggleChunkProtection(player);
}
else
{
this.getFactionInfo(player);
}
return new ActionResult(EnumActionResult.PASS, stack);
}
示例14: onItemRightClick
import net.minecraft.util.ActionResult; //导入依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(World par2World, EntityPlayer player,
EnumHand hand) {
// System.out.println("lel "+stack.getTagCompound().getInteger("wait")+"
// "+this.allowShot(player,stack, par2World));
ItemStack stack=player.getHeldItem(hand);
if (!(stack.hasTagCompound() && stack.getTagCompound().getInteger("wait") > 0)
&& this.allowShot(player, stack, par2World)) {
if (!this.usesBowAnimation(stack))
this.use(stack, par2World, player, 1.8f,
player.inventory.getStackInSlot(this.getSlotForUse(player, stack)), false);
else
// System.out.println("trying");
player.setActiveHand(hand);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
}
return new ActionResult<ItemStack>(EnumActionResult.PASS, stack);
}
示例15: onItemRightClick
import net.minecraft.util.ActionResult; //导入依赖的package包/类
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
ItemStack itemstack = ItemMap.func_190906_a(itemStackIn, worldIn.posX, worldIn.posZ, (byte)0, true, false);
ItemStack itemstack1 = worldIn.getHeldItem(playerIn);
itemstack1.func_190918_g(1);
if (itemstack1.func_190926_b())
{
return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
else
{
if (!worldIn.inventory.addItemStackToInventory(itemstack.copy()))
{
worldIn.dropItem(itemstack, false);
}
worldIn.addStat(StatList.getObjectUseStats(this));
return new ActionResult(EnumActionResult.SUCCESS, itemstack1);
}
}