当前位置: 首页>>代码示例>>Java>>正文


Java EnumHand.MAIN_HAND属性代码示例

本文整理汇总了Java中net.minecraft.util.EnumHand.MAIN_HAND属性的典型用法代码示例。如果您正苦于以下问题:Java EnumHand.MAIN_HAND属性的具体用法?Java EnumHand.MAIN_HAND怎么用?Java EnumHand.MAIN_HAND使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在net.minecraft.util.EnumHand的用法示例。


在下文中一共展示了EnumHand.MAIN_HAND属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: EntityProjectileBase

public EntityProjectileBase(World world, EntityLivingBase shooter, EnumHand hand) {
	this(world);
	this.shootingEntity = shooter;
	this.usedWeapon = shooter.getHeldItem(hand).copy();
	this.usedWeaponOrig=shooter.getHeldItem(hand);
	this.setLocationAndAngles(shooter.posX, shooter.posY + shooter.getEyeHeight(), shooter.posZ,
			shooter.rotationYawHead, shooter.rotationPitch + this.getPitchAddition());
	this.posX -= MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F
			* (hand == EnumHand.MAIN_HAND ? 1 : -1);
	this.posY -= shooter instanceof EntitySentry ? -0.1D : 0.1D;
	this.posZ -= MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F
			* (hand == EnumHand.MAIN_HAND ? 1 : -1);
	this.setPosition(this.posX, this.posY, this.posZ);
	this.motionX = -MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI)
			* MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI);
	this.motionZ = MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI)
			* MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI);
	this.motionY = (-MathHelper.sin(this.rotationPitch / 180.0F * (float) Math.PI));
	this.setThrowableHeading(this.motionX, this.motionY, this.motionZ,
			((ItemWeapon) this.usedWeapon.getItem()).getProjectileSpeed(usedWeapon, shooter),
			((ItemWeapon) this.usedWeapon.getItem()).getWeaponSpread(usedWeapon, shooter));
	if(((ItemWeapon) this.usedWeapon.getItem()).canPenetrate(this.usedWeapon,this.shootingEntity)){
		this.setPenetrate();
	}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:25,代码来源:EntityProjectileBase.java

示例2: notifyDataManagerChange

public void notifyDataManagerChange(DataParameter<?> key)
{
    super.notifyDataManagerChange(key);

    if (HAND_STATES.equals(key))
    {
        boolean flag = (((Byte)this.dataManager.get(HAND_STATES)).byteValue() & 1) > 0;
        EnumHand enumhand = (((Byte)this.dataManager.get(HAND_STATES)).byteValue() & 2) > 0 ? EnumHand.OFF_HAND : EnumHand.MAIN_HAND;

        if (flag && !this.handActive)
        {
            this.setActiveHand(enumhand);
        }
        else if (!flag && this.handActive)
        {
            this.resetActiveHand();
        }
    }

    if (FLAGS.equals(key) && this.isElytraFlying() && !this.wasFallFlying)
    {
        this.mc.getSoundHandler().playSound(new ElytraSound(this));
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:24,代码来源:EntityPlayerSP.java

示例3: damageShield

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);
        }
    }
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:25,代码来源:EntityPlayer.java

示例4: onInteraction

@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);
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:18,代码来源:SemiBlockManager.java

示例5: performEffect

@Override
public void performEffect(RayTraceResult rtrace, EntityLivingBase caster, World world) {
	if (rtrace.typeOfHit == Type.ENTITY && rtrace.entityHit instanceof EntityLivingBase) {
		EntityLivingBase entity = (EntityLivingBase) rtrace.entityHit;
		EnumHand hand = null;
		if (!entity.getHeldItemMainhand().isEmpty()) hand = EnumHand.MAIN_HAND;
		else if (!entity.getHeldItemOffhand().isEmpty()) hand = EnumHand.OFF_HAND;
		if (hand != null) {
			ItemStack stack = entity.getHeldItem(hand).copy();
			entity.setHeldItem(hand, ItemStack.EMPTY);
			if (!(entity instanceof EntityPlayer) && stack.isItemStackDamageable() && stack.getItemDamage() == 0) {
				stack.setItemDamage((int) (stack.getMaxDamage() * (0.5D + 0.5D * Math.random())));
			}
			EntityItem ei = new EntityItem(world, entity.posX, entity.posY, entity.posZ, stack);
			ei.setPickupDelay(200);
			ei.setNoDespawn();
			if (!world.isRemote) world.spawnEntity(ei);
		}
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:20,代码来源:SpellDisarming.java

示例6: onRightClickBlock

@SubscribeEvent
public void onRightClickBlock(RightClickBlock event)
{
	if(!(event.getWorld().getBlockState(event.getPos()).getBlock() instanceof XPBlock) || event.getHand() != EnumHand.MAIN_HAND)
		return;

	if(!event.getWorld().isRemote)
	{
		if(event.getEntityPlayer().isSneaking()) //sneaking = add all player XP to the block
		{
			((TileEntityXPBlock)event.getWorld().getTileEntity(event.getPos())).addXP(event.getEntityPlayer().experienceTotal);
			event.getEntityPlayer().addExperienceLevel(-event.getEntityPlayer().experienceLevel - 1); // set player XP to 0
		}
		else //not sneaking = remove exactly enough XP from the block to get player to the next level
		{
			TileEntityXPBlock te = ((TileEntityXPBlock)event.getWorld().getTileEntity(event.getPos()));
			EntityPlayer player = event.getEntityPlayer();
			int neededXP = player.xpBarCap() - (int)player.experience;
			int availableXP = te.removeXP(neededXP);
			
			player.addExperience(availableXP);
		}
	}
}
 
开发者ID:bl4ckscor3,项目名称:GlobalXP,代码行数:24,代码来源:EventHandler.java

示例7: damageShield

/** Fixed vanilla code */
private void damageShield(EntityPlayer owner, float damage) {
	int i = 1 + MathHelper.floor(damage);
	owner.getActiveItemStack().damageItem(i, owner);

	if (owner.getActiveItemStack().getCount() <= 0) {
		EnumHand enumhand = owner.getActiveHand();
		ForgeEventFactory.onPlayerDestroyItem(owner, owner.getActiveItemStack(), enumhand);

		if(enumhand == EnumHand.MAIN_HAND) {
			owner.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, ItemStack.EMPTY);
		} else {
			owner.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, ItemStack.EMPTY);
		}

		owner.resetActiveHand();
		owner.playSound(SoundEvents.ITEM_SHIELD_BREAK, 0.8F, 0.8F + owner.world.rand.nextFloat() * 0.4F);
	}
}
 
开发者ID:sblectric,项目名称:AdvancedCombat,代码行数:19,代码来源:CustomShieldHandler.java

示例8: renderExtra

private static void renderExtra(float partialTicks) {
	AbstractClientPlayer abstractclientplayer = Minecraft.getMinecraft().player;
	float f = abstractclientplayer.getSwingProgress(partialTicks);
	EnumHand enumhand = (EnumHand) MoreObjects.firstNonNull(abstractclientplayer.swingingHand, EnumHand.MAIN_HAND);
	float f1 = abstractclientplayer.prevRotationPitch
			+ (abstractclientplayer.rotationPitch - abstractclientplayer.prevRotationPitch) * partialTicks;
	float f2 = abstractclientplayer.prevRotationYaw
			+ (abstractclientplayer.rotationYaw - abstractclientplayer.prevRotationYaw) * partialTicks;
	rotateArroundXAndY(f1, f2);
	setLightmap();
	rotateArm(partialTicks);
	GlStateManager.enableRescaleNormal();
           float f3 = enumhand == EnumHand.MAIN_HAND ? f : 0.0F;
           float f5 = 1.0F - (1F);
           renderArmsFirstPerson(f1, f5, f3);

           //float f4 = enumhand == EnumHand.OFF_HAND ? f : 0.0F;
           //float f6 = 1.0F - (0F);
           //renderArmsFirstPerson(f1, f6, f4);
	GlStateManager.disableRescaleNormal();
}
 
开发者ID:the-realest-stu,项目名称:Etheric,代码行数:21,代码来源:SeeingStoneHandler.java

示例9: onItemUse

@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;
    setGPSLocation(player.getHeldItemMainhand(), pos);
    if (!worldIn.isRemote)
        player.sendStatusMessage(new TextComponentString(TextFormatting.GREEN + "[GPS Tool] Set Coordinates to " + pos.getX() + ", " + pos.getY() + ", " + pos.getZ() + "."), false);
    return EnumActionResult.SUCCESS; // we don't want to use the item.
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:8,代码来源:ItemGPSTool.java

示例10: onBlockActivated

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, @Nullable ItemStack stack, EnumFacing side, float hitX, float hitY, float hitZ) {

	TileEntity te = world.getTileEntity(pos);
	if (te != null && te instanceof TileArtisia && hand == EnumHand.MAIN_HAND) {
		if (((TileArtisia)te).getItem() != null && !world.isRemote) {
			ItemStack tilestack = ((TileArtisia)te).getItem().copy();
			((TileArtisia)te).setItem(null);
			ItemHandlerHelper.giveItemToPlayer(player, tilestack);
		}
		((TileArtisia)te).markBlockForUpdate();
	}
	return false;
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:14,代码来源:Artisia.java

示例11: onItemRightClick

@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) {
	if (!worldIn.isRemote) {
		if (!playerIn.isSneaking()) {
			if (hand == EnumHand.MAIN_HAND) {
				System.out.println("HEY");
				playerIn.openGui(Currency.INSTANCE, 1, worldIn, 0, 0, 0);
			} else if (hand == EnumHand.OFF_HAND) {
				playerIn.openGui(Currency.INSTANCE, 2, worldIn, 0, 0, 0);
			}
		}
	}
	return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, playerIn.getHeldItem(hand));
}
 
开发者ID:Zundrel,项目名称:Never-Enough-Currency,代码行数:14,代码来源:ItemWallet.java

示例12: processInteract

public boolean processInteract(EntityPlayer player, EnumHand hand)
{
    ItemStack itemstack = player.getHeldItem(hand);
    boolean flag = itemstack.getItem() == Items.NAME_TAG;

    if (flag)
    {
        itemstack.interactWithEntity(player, this, hand);
        return true;
    }
    else if (!this.func_190669_a(itemstack, this.getClass()) && this.isEntityAlive() && !this.isTrading() && !this.isChild())
    {
        if (this.buyingList == null)
        {
            this.populateBuyingList();
        }

        if (hand == EnumHand.MAIN_HAND)
        {
            player.addStat(StatList.TALKED_TO_VILLAGER);
        }

        if (!this.world.isRemote && !this.buyingList.isEmpty())
        {
            this.setCustomer(player);
            player.displayVillagerTradeGui(this);
        }
        else if (this.buyingList.isEmpty())
        {
            return super.processInteract(player, hand);
        }

        return true;
    }
    else
    {
        return super.processInteract(player, hand);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:39,代码来源:EntityVillager.java

示例13: processInteract

@Override
public boolean processInteract(EntityPlayer player, EnumHand hand) {
	if (player == this.getOwner() && player.getHeldItem(hand).getItem() instanceof ItemDye) {
		if(!world.isRemote) {
			this.setColor(player.getHeldItem(hand).getMetadata());
		}
		return true;
	}
	if (this.world.isRemote && player == this.getOwner() && hand == EnumHand.MAIN_HAND) {
		ClientProxy.showGuiTeleporter(this);
		return true;
	}
	return false;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:14,代码来源:EntityTeleporter.java

示例14: resetEquippedProgress

public void resetEquippedProgress(EnumHand hand)
{
    if (hand == EnumHand.MAIN_HAND)
    {
        this.equippedProgressMainHand = 0.0F;
    }
    else
    {
        this.equippedProgressOffHand = 0.0F;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:11,代码来源:ItemRenderer.java

示例15: LeftClickBlock

public LeftClickBlock(EntityPlayer player, BlockPos pos, EnumFacing face, Vec3d hitVec)
{
    super(player, EnumHand.MAIN_HAND, player.getHeldItem(EnumHand.MAIN_HAND), pos, face);
    this.hitVec = hitVec;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:5,代码来源:PlayerInteractEvent.java


注:本文中的net.minecraft.util.EnumHand.MAIN_HAND属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。