本文整理汇总了Java中net.minecraft.item.ItemStack.useItemRightClick方法的典型用法代码示例。如果您正苦于以下问题:Java ItemStack.useItemRightClick方法的具体用法?Java ItemStack.useItemRightClick怎么用?Java ItemStack.useItemRightClick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.item.ItemStack
的用法示例。
在下文中一共展示了ItemStack.useItemRightClick方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: work
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public float work() {
if (WorkUtils.isDisabled(this.getBlockType())) return 0;
List<BlockPos> blockPos = BlockUtils.getBlockPosInAABB(getWorkingArea());
++pointer;
if (pointer >= blockPos.size()) pointer = 0;
if (pointer < blockPos.size()) {
BlockPos pos = blockPos.get(pointer);
if (this.world.isAirBlock(pos) && !this.world.isAirBlock(pos.down())) {
FakePlayer player = IndustrialForegoing.getFakePlayer(this.world);
ItemStack stack = inPlant.getStackInSlot(getFilteredSlot(pos));
if (stack.isEmpty() && inPlant.getLocked()) {
ItemStack filter = inPlant.getFilterStack(getFilteredSlot(pos));
for (int i = 0; i < inPlant.getSlots(); ++i) {
if (!inPlant.getStackInSlot(i).isEmpty() && inPlant.getStackInSlot(i).isItemEqual(filter)) {
stack = inPlant.getStackInSlot(i);
break;
}
}
}
if (!stack.isEmpty()) {
if (!ItemStackUtils.isChorusFlower(stack) && !ItemStackUtils.isStackOreDict(stack, "treeSapling") && (this.world.getBlockState(pos.offset(EnumFacing.DOWN)).getBlock().equals(Blocks.DIRT) || this.world.getBlockState(pos.offset(EnumFacing.DOWN)).getBlock().equals(Blocks.GRASS))) {
this.world.setBlockState(pos.offset(EnumFacing.DOWN), Blocks.FARMLAND.getDefaultState());
}
player.setHeldItem(EnumHand.MAIN_HAND, stack);
if (stack.getItem().getRegistryName() != null && stack.getItem().getRegistryName().getResourceDomain().equals("forestry")) {
player.setPositionAndRotation(pos.getX(), pos.getY(), pos.getZ(), 90, 90);
stack.useItemRightClick(this.world, player, EnumHand.MAIN_HAND);
return 1;
}
EnumActionResult result = stack.onItemUse(player, this.world, pos.down(), EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0);
return result == EnumActionResult.SUCCESS ? 1 : 0;
}
}
} else {
pointer = 0;
}
return 0.1f;
}
示例2: sendUseItem
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Notifies the server of things like consuming food, etc...
*/
public boolean sendUseItem(EntityPlayer playerIn, World worldIn, ItemStack itemStackIn)
{
if (this.currentGameType == WorldSettings.GameType.SPECTATOR)
{
return false;
}
else
{
this.syncCurrentPlayItem();
this.netClientHandler.addToSendQueue(new C08PacketPlayerBlockPlacement(playerIn.inventory.getCurrentItem()));
int i = itemStackIn.stackSize;
ItemStack itemstack = itemStackIn.useItemRightClick(worldIn, playerIn);
if (itemstack != itemStackIn || itemstack != null && itemstack.stackSize != i)
{
playerIn.inventory.mainInventory[playerIn.inventory.currentItem] = itemstack;
if (itemstack.stackSize == 0)
{
playerIn.inventory.mainInventory[playerIn.inventory.currentItem] = null;
}
return true;
}
else
{
return false;
}
}
}
示例3: processRightClick
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public EnumActionResult processRightClick(EntityPlayer player, World worldIn, EnumHand stack)
{
if (this.currentGameType == GameType.SPECTATOR)
{
return EnumActionResult.PASS;
}
else
{
this.syncCurrentPlayItem();
this.connection.sendPacket(new CPacketPlayerTryUseItem(stack));
ItemStack itemstack = player.getHeldItem(stack);
if (player.getCooldownTracker().hasCooldown(itemstack.getItem()))
{
return EnumActionResult.PASS;
}
else
{
int i = itemstack.func_190916_E();
ActionResult<ItemStack> actionresult = itemstack.useItemRightClick(worldIn, player, stack);
ItemStack itemstack1 = actionresult.getResult();
if (itemstack1 != itemstack || itemstack1.func_190916_E() != i)
{
player.setHeldItem(stack, itemstack1);
}
return actionresult.getType();
}
}
}
示例4: processRightClick
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public EnumActionResult processRightClick(EntityPlayer player, World worldIn, EnumHand stack)
{
if (this.currentGameType == GameType.SPECTATOR)
{
return EnumActionResult.PASS;
}
else
{
this.syncCurrentPlayItem();
this.connection.sendPacket(new CPacketPlayerTryUseItem(stack));
ItemStack itemstack = player.getHeldItem(stack);
if (player.getCooldownTracker().hasCooldown(itemstack.getItem()))
{
return EnumActionResult.PASS;
}
else
{
int i = itemstack.func_190916_E();
ActionResult<ItemStack> actionresult = itemstack.useItemRightClick(worldIn, player, stack);
ItemStack itemstack1 = (ItemStack)actionresult.getResult();
if (itemstack1 != itemstack || itemstack1.func_190916_E() != i)
{
player.setHeldItem(stack, itemstack1);
}
return actionresult.getType();
}
}
}
示例5: processRightClick
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public EnumActionResult processRightClick(EntityPlayer player, World worldIn, ItemStack stack, EnumHand hand)
{
if (this.currentGameType == GameType.SPECTATOR)
{
return EnumActionResult.PASS;
}
else
{
this.syncCurrentPlayItem();
this.connection.sendPacket(new CPacketPlayerTryUseItem(hand));
if (player.getCooldownTracker().hasCooldown(stack.getItem()))
{
return EnumActionResult.PASS;
}
else
{
if (net.minecraftforge.common.ForgeHooks.onItemRightClick(player, hand, stack)) return net.minecraft.util.EnumActionResult.PASS;
int i = stack.stackSize;
ActionResult<ItemStack> actionresult = stack.useItemRightClick(worldIn, player, hand);
ItemStack itemstack = (ItemStack)actionresult.getResult();
if (itemstack != stack || itemstack.stackSize != i)
{
player.setHeldItem(hand, itemstack);
if (itemstack.stackSize <= 0)
{
player.setHeldItem(hand, (ItemStack)null);
net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, itemstack, hand);
}
}
return actionresult.getType();
}
}
}
示例6: tryUseItem
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Attempts to right-click use an item by the given EntityPlayer in the given World
*/
public boolean tryUseItem(EntityPlayer player, World worldIn, ItemStack stack)
{
if (this.gameType == WorldSettings.GameType.SPECTATOR)
{
return false;
}
else
{
int i = stack.stackSize;
int j = stack.getMetadata();
ItemStack itemstack = stack.useItemRightClick(worldIn, player);
if (itemstack != stack || itemstack != null && (itemstack.stackSize != i || itemstack.getMaxItemUseDuration() > 0 || itemstack.getMetadata() != j))
{
player.inventory.mainInventory[player.inventory.currentItem] = itemstack;
if (this.isCreative())
{
itemstack.stackSize = i;
if (itemstack.isItemStackDamageable())
{
itemstack.setItemDamage(j);
}
}
if (itemstack.stackSize == 0)
{
player.inventory.mainInventory[player.inventory.currentItem] = null;
}
if (!player.isUsingItem())
{
((EntityPlayerMP)player).sendContainerToPlayer(player.inventoryContainer);
}
return true;
}
else
{
return false;
}
}
}
示例7: processRightClick
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public EnumActionResult processRightClick(EntityPlayer player, World worldIn, ItemStack stack, EnumHand hand)
{
if (this.gameType == GameType.SPECTATOR)
{
return EnumActionResult.PASS;
}
else if (player.getCooldownTracker().hasCooldown(stack.getItem()))
{
return EnumActionResult.PASS;
}
else
{
int i = stack.func_190916_E();
int j = stack.getMetadata();
ActionResult<ItemStack> actionresult = stack.useItemRightClick(worldIn, player, hand);
ItemStack itemstack = (ItemStack)actionresult.getResult();
if (itemstack == stack && itemstack.func_190916_E() == i && itemstack.getMaxItemUseDuration() <= 0 && itemstack.getMetadata() == j)
{
return actionresult.getType();
}
else if (actionresult.getType() == EnumActionResult.FAIL && itemstack.getMaxItemUseDuration() > 0 && !player.isHandActive())
{
return actionresult.getType();
}
else
{
player.setHeldItem(hand, itemstack);
if (this.isCreative())
{
itemstack.func_190920_e(i);
if (itemstack.isItemStackDamageable())
{
itemstack.setItemDamage(j);
}
}
if (itemstack.func_190926_b())
{
player.setHeldItem(hand, ItemStack.field_190927_a);
}
if (!player.isHandActive())
{
((EntityPlayerMP)player).sendContainerToPlayer(player.inventoryContainer);
}
return actionresult.getType();
}
}
}
示例8: processRightClick
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public EnumActionResult processRightClick(EntityPlayer player, World worldIn, ItemStack stack, EnumHand hand)
{
if (this.gameType == GameType.SPECTATOR)
{
return EnumActionResult.PASS;
}
else if (player.getCooldownTracker().hasCooldown(stack.getItem()))
{
return EnumActionResult.PASS;
}
else
{
if (net.minecraftforge.common.ForgeHooks.onItemRightClick(player, hand, stack)) return net.minecraft.util.EnumActionResult.PASS;
int i = stack.stackSize;
int j = stack.getMetadata();
ActionResult<ItemStack> actionresult = stack.useItemRightClick(worldIn, player, hand);
ItemStack itemstack = (ItemStack)actionresult.getResult();
if (itemstack == stack && itemstack.stackSize == i && itemstack.getMaxItemUseDuration() <= 0 && itemstack.getMetadata() == j)
{
return actionresult.getType();
}
else
{
player.setHeldItem(hand, itemstack);
if (this.isCreative())
{
itemstack.stackSize = i;
if (itemstack.isItemStackDamageable())
{
itemstack.setItemDamage(j);
}
}
if (itemstack.stackSize == 0)
{
player.setHeldItem(hand, (ItemStack)null);
net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, itemstack, hand);
}
if (!player.isHandActive())
{
((EntityPlayerMP)player).sendContainerToPlayer(player.inventoryContainer);
}
return actionresult.getType();
}
}
}