本文整理汇总了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;
}
示例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);
}
}
示例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;
}