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


Java EntityPlayer.getActiveHand方法代码示例

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


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

示例1: songTick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public boolean songTick(EntityPlayer player, ItemStack instrument, int interval, int ticks, int length) {
	if (interval == 0 && ticks == 1) {
		EnumHand hand = player.getActiveHand();
		World world = player.world;
		SoundType t = SoundType.getSoundTypeByName(SoundType.AMBIENT.getTag());
		if (!world.isRemote) {
			EntityHorse horse = new EntityGhostHorse(world);
			horse.setHorseSaddled(true);
			horse.setTamedBy(player);
			horse.setLocationAndAngles(player.posX, player.posY, player.posZ, player.rotationYaw, player.rotationPitch);
			world.spawnEntity(horse);
			player.startRiding(horse);
			NBTTagCompound tag = ItemUtil.getOrCreateTag(instrument);
			tag.setInteger("id", horse.getEntityId());
		}
		player.setActiveHand(hand);
	}
	return true;
}
 
开发者ID:TeamMelodium,项目名称:Melodium,代码行数:21,代码来源:SongHorse.java

示例2: damageShield

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/** 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,代码行数:20,代码来源:CustomShieldHandler.java

示例3: onBlockActivated

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state,EntityPlayer playerIn, EnumHand hand, ItemStack heldItem,EnumFacing side, float hitX, float hitY, float hitZ) {
	super.onBlockActivated(worldIn, pos, state, playerIn, hand, heldItem,side, hitX, hitY, hitZ);
	if(worldIn.isRemote) {
	      return false;
	    }
	if(this.hasTileEntity(this.getDefaultState())){
		if(playerIn.getActiveHand() != null){
		ItemStack stack = playerIn.getHeldItem(playerIn.getActiveHand());
		if(stack != null){
			System.out.println("yep");
			if(stack.getItem() == Items.BUCKET){
				if(stack.stackSize > 0){
					--stack.stackSize;

					TileEntity te = worldIn.getTileEntity(pos);
					if(te instanceof TileTreeTap){
						((TileTreeTap)te).hasBucket = true;
						worldIn.setBlockState(pos, worldIn.getBlockState(pos).withProperty(HASBUCKET, true), 3);
						return true;
					}
				}
			}
		}
		}
	}
	return false;
}
 
开发者ID:MinecraftModDevelopmentMods,项目名称:Got-Wood,代码行数:29,代码来源:BlockTreeTap.java


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