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


Java EntityPlayer.getHeldItemOffhand方法代码示例

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


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

示例1: isUsingShears

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
private static boolean isUsingShears(EntityPlayer player)
{
	ItemStack stack = player.getHeldItemMainhand();
	if (!stack.isEmpty() && stack.getItem() instanceof ItemShears)
	{
		return true;
	}

	stack = player.getHeldItemOffhand();
	if (!stack.isEmpty() && stack.getItem() instanceof ItemShears)
	{
		return true;
	}

	return false;
}
 
开发者ID:DarkMorford,项目名称:BetterThanWeagles,代码行数:17,代码来源:EventHandlerShears.java

示例2: getClientGuiElement

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
	if (ID == 0) {
		return new GuiATM(player);
	} else if (ID == 1) {
		return new GuiWallet(new ContainerItem(player, player.inventory, new InventoryItem(player.getHeldItemMainhand())));
	} else if (ID == 2) {
		return new GuiWallet(new ContainerItem(player, player.inventory, new InventoryItem(player.getHeldItemOffhand())));
	} else if (ID == 3) {
		return new GuiShopController(new BlockPos(x, y, z), world);
	} else if (ID == 4) {
		return new GuiStockCrate(player, new BlockPos(x, y, z), player.inventory, (TileEntityStockCrate) world.getTileEntity(new BlockPos(x, y, z)));
	} else if (ID == 5) {
		return new GuiShoppingList(player);
	}

	return null;
}
 
开发者ID:Zundrel,项目名称:Never-Enough-Currency,代码行数:19,代码来源:GuiHandler.java

示例3: playerAndHandToItemStack

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public static ItemStack playerAndHandToItemStack(EntityPlayer player, EnumHand hand)
{
	ItemStack stack = null;

	// okay, find the itemstack
	if (hand == EnumHand.MAIN_HAND) {
		stack = player.getHeldItemMainhand();
	} else if (hand == EnumHand.OFF_HAND) {
		stack = player.getHeldItemOffhand();
	} else {
		// uhh... what?
		Util.logger.error("Found invalid EnumHand value!");
	}

	return stack;
}
 
开发者ID:orbwoi,项目名称:UniversalRemote,代码行数:17,代码来源:Util.java

示例4: canAdvance

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public boolean canAdvance(World world, BlockPos pos, IBlockState state) {

	if (getTile(world, pos) == null)
		return false;
	
	List<EntityPlayer> players = world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(pos.add(-range, -range, -range), pos.add(range, range, range)));
	for (EntityPlayer player : players) {
		if (player.getUniqueID().equals(getTile(world, pos).getOwner())) {
			ItemStack hand = player.getHeldItemMainhand();
			ItemStack offhand = player.getHeldItemOffhand();
			if ((hand != null && hand.getItem() == Item.getItemFromBlock(Blocks.TORCH)) || (offhand != null && offhand.getItem() == Item.getItemFromBlock(Blocks.TORCH)))
				return true;
		}
	}
	return false;
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:18,代码来源:GrowthSteps.java

示例5: searchForWatches

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public static Tuple<Integer, ItemStack> searchForWatches(EntityLivingBase living) {
	if (living instanceof EntitySpy)
		return new Tuple<>(3, ((EntitySpy)living).loadout.getStackInSlot(3));
	if (living instanceof EntityPlayer) {
		EntityPlayer player = (EntityPlayer) living;
		if (!player.getHeldItemOffhand().isEmpty() && player.getHeldItemOffhand().getItem() instanceof ItemCloak
				&& player.getHeldItemOffhand().getTagCompound().getBoolean("Active"))
			// System.out.println("Found offhand");
			return new Tuple<>(40,player.getHeldItemOffhand());
		for (int i=0;i<player.inventory.mainInventory.size();i++) {
			ItemStack stack=player.inventory.mainInventory.get(i);
			if (!stack.isEmpty() && stack.getItem() instanceof ItemCloak
					&& stack.getTagCompound().getBoolean("Active"))
				// System.out.println("Found hand");
				return new Tuple<>(i,stack);
		}

	}
	return new Tuple<>(-1, ItemStack.EMPTY);
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:21,代码来源:ItemCloak.java

示例6: canBeSteered

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * returns true if all the conditions for steering the entity are met. For pigs, this is true if it is being ridden
 * by a player and the player is holding a carrot-on-a-stick
 */
public boolean canBeSteered()
{
    Entity entity = this.getControllingPassenger();

    if (!(entity instanceof EntityPlayer))
    {
        return false;
    }
    else
    {
        EntityPlayer entityplayer = (EntityPlayer)entity;
        ItemStack itemstack = entityplayer.getHeldItemMainhand();

        if (itemstack != null && itemstack.getItem() == Items.CARROT_ON_A_STICK)
        {
            return true;
        }
        else
        {
            itemstack = entityplayer.getHeldItemOffhand();
            return itemstack != null && itemstack.getItem() == Items.CARROT_ON_A_STICK;
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:29,代码来源:EntityPig.java

示例7: onExecutionTick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void onExecutionTick(EntityPlayer player, int progress)
{
	player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_NODAMAGE, SoundCategory.PLAYERS, 1, 2F);
	Vec3d look = player.getLookVec().scale(3);
	Vec3d pos = player.getPositionVector();
	List<EntityLivingBase> targets = Helpers.rayTraceEntities(player.world, pos.addVector(0, player.getEyeHeight(), 0), look, Optional.of(e -> e != player), EntityLivingBase.class);
	EntityLivingBase assumedToBeLookedAt = Helpers.getClosest(targets, player);
	if (assumedToBeLookedAt != null)
	{
		assumedToBeLookedAt.hurtResistantTime = 0;
		assumedToBeLookedAt.attackEntityFrom(DamageSource.causePlayerDamage(player), Math.max(1, (float) player.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue() / 10));
		player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_NODAMAGE, SoundCategory.PLAYERS, 1, 0.1F);
		Vec3d targetPos = assumedToBeLookedAt.getPositionVector();
		player.world.spawnParticle(EnumParticleTypes.CRIT, targetPos.x + player.world.rand.nextDouble() / 2 - player.world.rand.nextDouble() / 2, targetPos.y + assumedToBeLookedAt.getEyeHeight() + player.world.rand.nextDouble() / 2 - player.world.rand.nextDouble() / 2, targetPos.z + player.world.rand.nextDouble() / 2 - player.world.rand.nextDouble() / 2, 0, 0, 0);
		if (!player.world.isRemote)
		{
			ItemStack is = player.getHeldItemMainhand().isEmpty() ? player.getHeldItemOffhand() : player.getHeldItemMainhand();
			is.damageItem(1, player);
		}
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:23,代码来源:Stab.java

示例8: onExecutionStart

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void onExecutionStart(EntityPlayer player)
{
	ItemStack is = player.getHeldItemMainhand().isEmpty() ? player.getHeldItemOffhand() : player.getHeldItemMainhand();
	EnumWeaponWeight weight = EnumWeaponWeight.getWeaponWeight(is);
	player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_NODAMAGE, SoundCategory.PLAYERS, 1, 1F);
	Vec3d look = player.getLookVec().scale(5);
	Vec3d pos = player.getPositionVector();
	List<EntityLivingBase> targets = Helpers.rayTraceEntities(player.world, pos.addVector(0, player.getEyeHeight(), 0), look, Optional.of(e -> e != player), EntityLivingBase.class);
	EntityLivingBase assumedToBeLookedAt = Helpers.getClosest(targets, player);
	if (assumedToBeLookedAt != null)
	{
		if (!player.world.isRemote)
		{
			assumedToBeLookedAt.addPotionEffect(new PotionEffect(ExPPotions.stunned, weight == EnumWeaponWeight.NORMAL ? 20 : 30, 0, false, false));
		}
		
		player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_KNOCKBACK, SoundCategory.PLAYERS, 1, 1F);
		Vec3d targetPos = assumedToBeLookedAt.getPositionVector();
		assumedToBeLookedAt.knockBack(player, 1, pos.x - targetPos.x, pos.z - targetPos.z);
		for (int i = 0; i < 50; ++i)
		{
			player.world.spawnParticle(EnumParticleTypes.CRIT_MAGIC, targetPos.x + player.world.rand.nextDouble() - player.world.rand.nextDouble(), targetPos.z + assumedToBeLookedAt.getEyeHeight() + player.world.rand.nextDouble() - player.world.rand.nextDouble(), targetPos.z + player.world.rand.nextDouble() - player.world.rand.nextDouble(), 0, -0.1, 0);
		}
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:27,代码来源:DownStrike.java

示例9: onStarted

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void onStarted(EntityPlayer player, IRitualHandler tile, World world, BlockPos pos, NBTTagCompound data) {
	ItemStack chalk = player.getHeldItemOffhand();
	data.setInteger("chalkType", chalk.getMetadata());
	if (!player.isCreative()) {
		int usesLeft = chalk.getTagCompound().getInteger("usesLeft") - coords.size();
		chalk.getTagCompound().setInteger("usesLeft", usesLeft);
		if (usesLeft < 1)
			chalk.setCount(0);
	}
	player.setHeldItem(EnumHand.OFF_HAND, chalk);
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:13,代码来源:RitualDrawing.java

示例10: isStackInHand

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
private boolean isStackInHand(ItemStack itemStackIn) {
	EntityPlayer player = EasyMappings.player();
	if ((player.getHeldItemMainhand() == itemStackIn) || (player.getHeldItemOffhand() == itemStackIn)) {
		return true;
	}
	return false;
}
 
开发者ID:p455w0rd,项目名称:DankNull,代码行数:8,代码来源:DankNullRenderer.java

示例11: getClientGuiElement

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
	if (ID == GuiLearnSpell.MAIN_ID){
		return new GuiLearnSpell(player, EnumHand.MAIN_HAND, player.getHeldItemMainhand());
	}
	if (ID == GuiLearnSpell.OFF_ID){
		return new GuiLearnSpell(player, EnumHand.OFF_HAND, player.getHeldItemOffhand());
	}
	return null;
}
 
开发者ID:TeamMelodium,项目名称:Melodium,代码行数:11,代码来源:MelodiumGuiHandler.java

示例12: getClientGuiElement

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
@SideOnly(Side.CLIENT)
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
    BlockPos pos = new BlockPos(x, y, z);
    if (ID == RandoresGuiType.FORGE.ordinal()) {
        TileEntity entity = world.getTileEntity(pos);
        if (entity instanceof CraftiniumForgeTileEntity) {
            return new CraftiniumForgeGui((CraftiniumForgeTileEntity) entity, player.inventory);
        }
    } else if (ID == RandoresGuiType.TABLE.ordinal()) {
        return new CraftiniumTableGui(player.inventory, world, pos);
    } else if (ID == RandoresGuiType.TOME.ordinal()) {
        ItemStack[] stacks = new ItemStack[] {player.getHeldItemMainhand(), player.getHeldItemOffhand()};
        for(ItemStack stack : stacks) {
            if(stack.getItem() instanceof TomeItem && RandoresItemData.hasData(stack)) {
                RandoresItemData data = new RandoresItemData(stack);
                if(RandoresWorldData.contains(data)) {
                    return new TomeGui(RandoresWorldData.get(data).buildPages());
                }
            }
        }

        return new TomeGui(Arrays.asList(new TomeGui.StringElement("An example text page: \n" + TextFormatting.RED + "This tome has no data associated with it, so it instead displays examples of the different kinds of pages in a tome.", "Example"),
                new TomeGui.CraftingElement("An example crafting recipe page: ", new ItemStack[][]{
                           {new ItemStack(Items.IRON_INGOT), new ItemStack(Items.IRON_INGOT), new ItemStack(Items.IRON_INGOT)},
                           {null, new ItemStack(Items.STICK), null},
                           {null, new ItemStack(Items.STICK), null}
                   }, new ItemStack(Items.IRON_PICKAXE), "Example"),
                new TomeGui.FurnaceElement("An example furnace recipe page: ", new ItemStack(Items.STICK), new ItemStack(Blocks.IRON_ORE), new ItemStack(Items.IRON_INGOT), "Example")));
    } else if (ID == RandoresGuiType.CONVERTER.ordinal()) {
        return new CraftiniumConverterGui(player.inventory, world, pos);
    }
    return null;
}
 
开发者ID:Randores,项目名称:Randores2,代码行数:35,代码来源:RandoresGuiHandler.java

示例13: getServerGuiElement

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
	if (ID == 1) {
		return new ContainerItem(player, player.inventory, new InventoryItem(player.getHeldItemMainhand()));
	} else if (ID == 2) {
		return new ContainerItem(player, player.inventory, new InventoryItem(player.getHeldItemOffhand()));
	} else if (ID == 4) {
		return new ContainerStockCrate(player.inventory, (TileEntityStockCrate) world.getTileEntity(new BlockPos(x, y, z)));
	}

	return null;
}
 
开发者ID:Zundrel,项目名称:Never-Enough-Currency,代码行数:13,代码来源:GuiHandler.java

示例14: processClick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public static void processClick(EntityPlayer player, boolean rightClick)
{
	if (!player.getHeldItemMainhand().isEmpty() || (!player.getHeldItemOffhand().isEmpty() && rightClick))
	{
		ItemStack is = !player.getHeldItemMainhand().isEmpty() ? player.getHeldItemMainhand() : player.getHeldItemOffhand();
		for (SpecialAttack attack : SpecialAttack.sortedData)
		{
			if (attack.canExecute(player, WeaponType.getType(is), EnumWeaponWeight.getWeaponWeight(is), rightClick))
			{
				boolean b = true;
				for (IExecuteCondition condition : attack.executeConditions)
				{
					if (!condition.isMet())
					{
						b = false;
						break;
					}
				}
				
				if (!b)
				{
					continue;
				}
				
				NBTTagCompound tag = NBTChain.startChain().withString("uuid", player.getPersistentID().toString()).withString("attackID", attack.id).withBool("rightClick", rightClick).endChain();
				VoidNetwork.sendDataToServer(ExPPackets.SPECIAL_ATTACK, tag);
				return;
			}
		}
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:32,代码来源:ClientCombatHandler.java

示例15: onExecutionStart

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void onExecutionStart(EntityPlayer player)
{
	ItemStack is = player.getHeldItemMainhand().isEmpty() ? player.getHeldItemOffhand() : player.getHeldItemMainhand();
	EnumWeaponWeight weight = EnumWeaponWeight.getWeaponWeight(is);
	player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, SoundCategory.PLAYERS, 1, 1F);
	Vec3d playerLook = player.getLookVec();
	Vec3d playerPos = player.getPositionVector();
	player.world.spawnParticle(EnumParticleTypes.SWEEP_ATTACK, playerPos.x + playerLook.x, playerPos.y + player.getEyeHeight() * 0.5F, playerPos.z + playerLook.z, 0, 0, 0);
	AxisAlignedBB aabb = new AxisAlignedBB(playerPos.addVector(-3, -1, -3), playerPos.addVector(3, 3, 3));
	List<EntityLivingBase> lst = player.world.getEntitiesWithinAABB(EntityLivingBase.class, aabb, e -> e != player);
	for (EntityLivingBase ent : lst)
	{
		if (ent instanceof EntityTameable && ((EntityTameable)ent).getOwner() == player)
		{
			continue;
		}
		
		Vec3d ePos = ent.getPositionVector();
		Vec3d player2ent = ePos.subtract(playerPos).normalize();
		float angle = (float) Math.toDegrees(Math.acos(player2ent.dotProduct(playerLook)));
		if (angle > 60)
		{
			continue;
		}
		
		ent.attackEntityFrom(DamageSource.causePlayerDamage(player), (float) (player.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue() * 0.85F));
		player.world.playSound(player, ent.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, SoundCategory.PLAYERS, 1, 2F);
		if (!player.world.isRemote && weight == EnumWeaponWeight.HEAVY && player.world.rand.nextBoolean())
		{
			ent.addPotionEffect(new PotionEffect(ExPPotions.stunned, 100, 0, false, false));
		}
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:35,代码来源:Slash.java


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