本文整理汇总了Java中net.minecraft.util.EnumHand类的典型用法代码示例。如果您正苦于以下问题:Java EnumHand类的具体用法?Java EnumHand怎么用?Java EnumHand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EnumHand类属于net.minecraft.util包,在下文中一共展示了EnumHand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processInteract
import net.minecraft.util.EnumHand; //导入依赖的package包/类
protected boolean processInteract(EntityPlayer player, EnumHand hand)
{
ItemStack itemstack = player.getHeldItem(hand);
if (itemstack.getItem() == Items.SHEARS && this.isPumpkinEquipped() && !this.world.isRemote)
{
this.setPumpkinEquipped(false);
itemstack.damageItem(1, player);
}
return super.processInteract(player, hand);
}
示例2: onItemRightClick
import net.minecraft.util.EnumHand; //导入依赖的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);
}
示例3: entityInteract
import net.minecraft.util.EnumHand; //导入依赖的package包/类
@SubscribeEvent
public void entityInteract(EntityInteract event) {
if (event.getEntityPlayer().getEntityData().hasKey("renderViewCamera")) {
event.setCanceled(true);
if (event.getSide().isClient() && event.getHand().equals(EnumHand.MAIN_HAND)
&& event.getItemStack() == null) {
System.out.println("EntityInteract,HandType=" + event.getHand());
ActiveTripod(Minecraft.getMinecraft().thePlayer.getName(),
((EntityTripod) event.getWorld()
.getEntityByID(event.getEntityPlayer().getEntityData().getInteger("renderViewCamera")))
.getDelay());
}
return;
}
if (event.getTarget() instanceof EntityTripod) {
Entity target = ((PlayerInteractEvent.EntityInteract) event).getTarget();
EntityPlayer player = event.getEntityPlayer();
if (!player.isSneaking()) {
if (player.inventory.armorInventory[3] != null
&& player.inventory.armorInventory[3].getItem() instanceof ItemGlassesHelmet) {
if (player.getEntityWorld().isRemote) {
// System.out.println("123");
Minecraft.getMinecraft().setRenderViewEntity(target);
Minecraft.getMinecraft().ingameGUI.setRecordPlaying(new TextComponentTranslation("chat.tripod.info"), false);
}
player.getEntityData().setInteger("renderViewCamera", target.getEntityId());
}else if(!event.getWorld().isRemote&&event.getHand().equals(EnumHand.MAIN_HAND)){
player.addChatComponentMessage(new TextComponentTranslation("chat.tripod.mustuseglass"));
}
} else {
player.getEntityData().setInteger("usingGui", target.getEntityId());
player.openGui(MineCamera.instance, GuiElementLoader.GUI_TRIPOD_CAMERA, target.getEntityWorld(),
(int) target.posX, (int) target.posY, (int) target.posZ);
}
}
}
示例4: onItemUse
import net.minecraft.util.EnumHand; //导入依赖的package包/类
@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: renderItem
import net.minecraft.util.EnumHand; //导入依赖的package包/类
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void renderItem(RenderSpecificHandEvent event) {
Minecraft minecraft = Minecraft.getMinecraft();
if (event.getHand() == EnumHand.MAIN_HAND) {
if (minecraft.gameSettings.thirdPersonView != 0
|| minecraft.player.getHeldItem(EnumHand.MAIN_HAND).func_190916_E() <= 0
|| minecraft.player.getHeldItem(EnumHand.MAIN_HAND).getItem() != InfernumItems.KNOWLEDGE_BOOK) {
reset();
return;
}
if ((minecraft.player.getHeldItem(EnumHand.OFF_HAND).equals(ItemStack.field_190927_a))) {
event.setCanceled(true);
try {
ticksOpen++;
doRender(event.getPartialTicks(), minecraft.player.getHeldItem(event.getHand()));
} catch (Throwable throwable) {
}
} else {
reset();
}
}
}
示例6: onItemRightClick
import net.minecraft.util.EnumHand; //导入依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
{
ItemStack stack = player.getHeldItem(hand);
if (player.inventory.hasItemStack(new ItemStack(RegisterItems.marshmallow)))
{
stack.setCount(stack.getCount() - 1);
ItemStack mallowStick = new ItemStack(RegisterItems.roastingStickRawMallow);
if (!player.inventory.addItemStackToInventory(mallowStick))
{
EntityItem drop = new EntityItem(world, player.posX, player.posY, player.posZ, mallowStick);
world.spawnEntity(drop);
}
stack.setCount(stack.getCount() - 1); // Why is this done twice?
if (stack.getCount() <= 0)
{
player.inventory.setItemStack(ItemStack.EMPTY);
ForgeEventFactory.onPlayerDestroyItem(player, stack, hand);
}
}
player.inventoryContainer.detectAndSendChanges();
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
示例7: damageShield
import net.minecraft.util.EnumHand; //导入依赖的package包/类
protected void damageShield(float damage)
{
if (damage >= 3.0F && this.activeItemStack.getItem() == Items.SHIELD)
{
int i = 1 + MathHelper.floor(damage);
this.activeItemStack.damageItem(i, this);
if (this.activeItemStack.func_190926_b())
{
EnumHand enumhand = this.getActiveHand();
if (enumhand == EnumHand.MAIN_HAND)
{
this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, ItemStack.field_190927_a);
}
else
{
this.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, ItemStack.field_190927_a);
}
this.activeItemStack = ItemStack.field_190927_a;
this.playSound(SoundEvents.ITEM_SHIELD_BREAK, 0.8F, 0.8F + this.world.rand.nextFloat() * 0.4F);
}
}
}
示例8: onItemUse
import net.minecraft.util.EnumHand; //导入依赖的package包/类
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if(!worldIn.isRemote && player.isCreative() && worldIn.getMinecraftServer().getPlayerList().canSendCommands(player.getGameProfile())) {
IBlockState clicked = worldIn.getBlockState(pos);
Block block = clicked.getBlock();
if(block.equals(BlocksMM.blockController)) {
PlayerStructureSelectionHelper.finalizeSelection(clicked.getValue(BlockController.FACING), worldIn, pos, player);
PlayerStructureSelectionHelper.purgeSelection(player);
PlayerStructureSelectionHelper.sendSelection(player);
} else {
PlayerStructureSelectionHelper.toggleInSelection(player, pos);
PlayerStructureSelectionHelper.sendSelection(player);
}
}
return EnumActionResult.SUCCESS;
}
示例9: fromBytes
import net.minecraft.util.EnumHand; //导入依赖的package包/类
@Override
public void fromBytes(ByteBuf buf) {
slot = buf.readByte();
this.hand = buf.readBoolean() ? EnumHand.MAIN_HAND : EnumHand.OFF_HAND;
this.readData = new ArrayList<Object[]>();
while (buf.readableBytes() > 0) {
Object[] obj = new Object[3];
obj[0] = buf.readInt();
// obj[1]=buf.readFloat();
// obj[2]=buf.readFloat();
// obj[3]=buf.readFloat();
obj[1] = buf.readBoolean();
obj[2] = buf.readFloat();
this.readData.add(obj);
}
}
示例10: onItemUse
import net.minecraft.util.EnumHand; //导入依赖的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)
{
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;
}
}
示例11: onBlockActivated
import net.minecraft.util.EnumHand; //导入依赖的package包/类
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
if(!player.getHeldItem(hand).isEmpty() && player.getHeldItem(hand).getItem() == AnimaItems.LINKER)
{
return false;
}
TileEntity te = world.getTileEntity(pos);
if (!(te instanceof TileEntitySorter))
{
return false;
}
player.openGui(Anima.Instance, 0, world, pos.getX(), pos.getY(), pos.getZ());
return true;
}
示例12: onItemRightClick
import net.minecraft.util.EnumHand; //导入依赖的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);
}
示例13: onItemUse
import net.minecraft.util.EnumHand; //导入依赖的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: resetTask
import net.minecraft.util.EnumHand; //导入依赖的package包/类
/**
* Resets the task
*/
@Override
public void resetTask() {
if ((this.entityHost.getHeldItem(EnumHand.MAIN_HAND).getItem() instanceof ItemWeapon) &&this.entityHost.getCapability(TF2weapons.WEAPONS_CAP, null).state != 0) {
pressed = false;
((ItemWeapon) this.entityHost.getHeldItem(EnumHand.MAIN_HAND).getItem()).endUse(
this.entityHost.getHeldItem(EnumHand.MAIN_HAND), this.entityHost, this.entityHost.world,
this.entityHost.getCapability(TF2weapons.WEAPONS_CAP, null).state, 0);
this.entityHost.getCapability(TF2weapons.WEAPONS_CAP, null).state = 0;
TF2Util.sendTracking(new TF2Message.ActionMessage(0, entityHost), entityHost);
}
if (this.jump)
this.entityHost.jump = false;
this.attackTarget = null;
this.comeCloser = 0;
this.rangedAttackTime = -1;
}
示例15: onInteraction
import net.minecraft.util.EnumHand; //导入依赖的package包/类
@SubscribeEvent
public void onInteraction(PlayerInteractEvent.RightClickBlock event) {
ItemStack curItem = event.getEntityPlayer().getHeldItemMainhand();
if (!event.getWorld().isRemote && event.getHand() == EnumHand.MAIN_HAND) {
if (curItem.getItem() instanceof ISemiBlockItem) {
boolean success = interact(event, curItem, event.getPos());
//If the block can't be placed in the pos, then try to place it next to the block.
if(!success && event.getFace() != null)
success = interact(event, curItem, event.getPos().offset(event.getFace()));
if(success) event.setCanceled(true);
}
} else if (event.getWorld().isRemote && curItem.getItem() instanceof ISemiBlockItem) {
event.setCancellationResult(EnumActionResult.SUCCESS);
event.setCanceled(true);
}
}