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


Java EntityPlayer.setCurrentItemOrArmor方法代码示例

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


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

示例1: doRepair

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public static void doRepair(EntityPlayer player, Entity_AA turret, ItemStack stack)
{
	//if (this.hasArmorUpgrade) { return; }	// Already has an armor upgrade
	//this.hasArmorUpgrade = true;			// Adding one
	
	if (turret.getHealth() >= turret.getMaxHealth()) { return; }	// No repairs required
	
	turret.heal(20);
	
	// SFX
	NetHelper.sendParticleMessage(player, turret.getEntityId(), (byte) 2, (byte) 4); // Firework sparks particles (2)
	turret.worldObj.playSoundAtEntity(turret, "random.anvil_use", 0.7f, 1.0f);
	
	if (player.capabilities.isCreativeMode) { return; }	// Not deducting from creative mode players
	
	player.getHeldItem().stackSize -= 1;
	if (player.getHeldItem().stackSize <= 0) { player.setCurrentItemOrArmor(0, null); }	// Used up
}
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:19,代码来源:AI_Properties.java

示例2: onItemUse

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float sideX, float sideY, float sideZ)
   {
	if (world.isRemote) { return true; }	// Not doing this on client side
	
	Entity_BB turret = new Entity_BB(world, player);
	
	turret.setPosition(x + 0.5, y + 1 , z + 0.5);		
	world.spawnEntityInWorld(turret);
	
	// Custom name
	if (stack.hasDisplayName())	{ AI_Properties.applyNameTag(player, turret, stack, false); }
	
	if (player.capabilities.isCreativeMode) { return true; }	// Not deducting them in creative mode

	stack.stackSize -= 1;
	if (stack.stackSize <= 0)	// Used up
	{
		player.setCurrentItemOrArmor(0, null);
	}
	
	return true;
   }
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:24,代码来源:PackedUpBB.java

示例3: itemInteractionForEntity

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public boolean itemInteractionForEntity(ItemStack item, EntityPlayer player, EntityLivingBase entity) {
    if (entity.worldObj.isRemote) {
        return false;
    }
    if (entity instanceof IMob) {
        if (item.hasTagCompound())
            return false;
        item.setTagCompound(new NBTTagCompound());
        NBTTagCompound mainTag = new NBTTagCompound();
        NBTTagCompound entityTag = new NBTTagCompound();
        entity.writeToNBT(entityTag);
        mainTag.setFloat("health",entity.getHealth());
        mainTag.setTag("data", entityTag);
        mainTag.setString("id", EntityList.getEntityString(entity));
        if (entity instanceof EntitySlime) {
            mainTag.setInteger("slimesize", ((EntitySlime) entity).getSlimeSize());
        }
        if(entity instanceof EntityZombie){
            mainTag.setBoolean("isBabyZombie",entity.isChild());
        }
        item.getTagCompound().setTag("entity",mainTag);
        player.setCurrentItemOrArmor(0, item);
        entity.setDead();
        return true;
    }
    return super.itemInteractionForEntity(item, player, entity);
}
 
开发者ID:SihenZhang,项目名称:CursedLasso,代码行数:29,代码来源:ItemCursedLasso.java

示例4: onItemRightClick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    int i = EntityLiving.getArmorPosition(itemStackIn) - 1;
    ItemStack itemstack = playerIn.getCurrentArmor(i);

    if (itemstack == null)
    {
        playerIn.setCurrentItemOrArmor(i, itemStackIn.copy());
        itemStackIn.stackSize = 0;
    }

    return itemStackIn;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:17,代码来源:ItemArmor.java

示例5: applyNameTag

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public static void applyNameTag(EntityPlayer player, Entity_AA turret, ItemStack stack, boolean consumeItem)
{
	if (stack.hasDisplayName()) { turret.setCustomNameTag(stack.getDisplayName()); }	// Applying the name
	
	if (player.capabilities.isCreativeMode) { return; }	// Not deducting from creative mode players
	if (!consumeItem) { return; }						// Don't want me to consume this thing, so probably restoring properties from the packed up AA
	
	player.getHeldItem().stackSize -= 1;
	if (player.getHeldItem().stackSize <= 0) { player.setCurrentItemOrArmor(0, null); }	// Used up
}
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:11,代码来源:AI_Properties.java

示例6: onItemUse

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float sideX, float sideY, float sideZ)
   {
	if (world.isRemote) { return true; }	// Not doing this on client side
	
	Entity_AA turret = new Entity_AA(world, player);
	
	turret.setPosition(x + 0.5, y +1 , z + 0.5);		
	world.spawnEntityInWorld(turret);
	
	// Custom name
	if (stack.hasDisplayName())	{ AI_Properties.applyNameTag(player, turret, stack, false); }
	
	// Applying upgrades
	if (stack.hasTagCompound())
	{
		if (stack.getTagCompound().getBoolean("hasArmorUpgrade")) { AI_Properties.applyArmorUpgrade(turret); }
		if (stack.getTagCompound().getBoolean("hasHeavyPlatingUpgrade")) { AI_Properties.applyPlatingUpgrade(turret); }
		if (stack.getTagCompound().getBoolean("hasMobilityUpgrade")) { AI_Properties.applyMobilityUpgrade(turret); }
		if (stack.getTagCompound().getBoolean("hasStorageUpgrade")) { AI_Properties.applyStorageUpgrade(turret); }
		if (stack.getTagCompound().getBoolean("hasWeaponUpgrade")) { AI_Properties.applyWeaponUpgrade(turret); }
		if (stack.getTagCompound().getBoolean("hasRidingUpgrade")) { AI_Properties.applyRidingUpgrade(turret); }
		if (stack.getTagCompound().getBoolean("hasCommunicationUpgrade")) { AI_Properties.applyCommunicationUpgrade(turret); }
		
		if (stack.getTagCompound().getInteger("currentHealth") > 0)	// Tracking health and reapplying it
		{
			turret.setHealth(stack.getTagCompound().getInteger("currentHealth"));
		}
	}
	
	if (player.capabilities.isCreativeMode) { return true; }	// Not deducting them in creative mode

	stack.stackSize -= 1;
	if (stack.stackSize <= 0)	// Used up
	{
		player.setCurrentItemOrArmor(0, null);
	}
	
	return true;
   }
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:41,代码来源:PackedUpAA.java

示例7: onItemUse

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public boolean onItemUse(ItemStack item, EntityPlayer player, World world, int x, int y, int z, int facing, float hitX, float hitY, float hitZ) {
    if (world.isRemote) {
        return true;
    }
    if (!item.hasTagCompound()) {
        return false;
    }
    if(player == null) {
        return false;
    }

    String entityId = item.stackTagCompound.getCompoundTag("entity").getString("id");
    Entity entityToSpawn = EntityList.createEntityByName(entityId, world);

    Block blk = world.getBlock(x,y,z);
    double spawnX = x + Facing.offsetsXForSide[facing] + 0.5;
    double spawnY = y + Facing.offsetsYForSide[facing];
    double spawnZ = z + Facing.offsetsZForSide[facing] + 0.5;
    if(facing == ForgeDirection.UP.ordinal() && (blk instanceof BlockFence || blk instanceof BlockWall)) {
        spawnY += 0.5;
    }
    if(entityToSpawn instanceof EntitySlime) {
        ((EntitySlime) entityToSpawn).setSlimeSize(item.stackTagCompound.getCompoundTag("entity").getInteger("slimesize"));
    }
    if(entityToSpawn instanceof EntityZombie){
        if(item.stackTagCompound.getCompoundTag("entity").getBoolean("isBabyZombie"))
            ((EntityZombie) entityToSpawn).setChild(true);
        else
            ((EntityZombie) entityToSpawn).setChild(false);
    }
    entityToSpawn.setLocationAndAngles(spawnX, spawnY, spawnZ, world.rand.nextFloat() * 360.0F, 0);
    world.spawnEntityInWorld(entityToSpawn);
    if(entityToSpawn instanceof EntityLiving) {
        ((EntityLiving)entityToSpawn).playLivingSound();
        ((EntityLiving)entityToSpawn).setHealth(item.stackTagCompound.getCompoundTag("entity").getFloat("health"));
    }

    Entity riddenByEntity = entityToSpawn.riddenByEntity;
    while(riddenByEntity != null) {
        riddenByEntity.setLocationAndAngles(spawnX, spawnY, spawnZ, world.rand.nextFloat() * 360.0F, 0.0F);
        world.spawnEntityInWorld(riddenByEntity);
        if(riddenByEntity instanceof EntityLiving) {
            ((EntityLiving)riddenByEntity).playLivingSound();
        }
        riddenByEntity = riddenByEntity.riddenByEntity;
    }
    item.setTagCompound(null);
    player.setCurrentItemOrArmor(0, item);
    return true;
}
 
开发者ID:SihenZhang,项目名称:CursedLasso,代码行数:52,代码来源:ItemCursedLasso.java

示例8: interact

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public boolean interact(EntityPlayer player)
   {
	if (this.worldObj.isRemote) { return true; }	// Client side. Doesn't have the same info, so makes a different decision. Ugh.
													// They'll just shoot when trying to equip this with a weapon
	if (!player.getDisplayName().equals(this.ownerName)) { return false; }	// Not the owner, so not doing this
	
	ItemStack itemstack = player.inventory.getCurrentItem();
	
	// Isn't holding anything
	if (itemstack == null) 
	{
		if (player.isSneaking())	// They're sneaking, so removing our weapon now
		{
			if (!this.hasFirstWeapon)	// Not holding a primary weapon, meaning I'm not holding anything right now. So folding myself up
			{
				AI_Storage.dropSelf(this);
			}
			else	// Holding a weapon, so dropping it and all ammo
			{
				AI_Storage.dropFirstWeapon(this);
				AI_Storage.dropSecondWeapon(this);
				AI_Storage.dropStoredItems(this);
			}
			
			return true;
		}
		else if (this.hasRidingUpgrade)	// Not sneaking and we have the riding upgrade, so the owner can giddy up
        {
			player.mountEntity(this);	
            return true;
        }
		
		return false; 
	}
	
	// Holding a weapon
	else if (itemstack.getItem() instanceof _WeaponBase) 
	{
		if (!player.capabilities.isCreativeMode) { player.setCurrentItemOrArmor(0, null); }	// Taking that
		
		if (this.hasWeaponUpgrade && player.isSneaking())
		{
			AI_WeaponHandler.setSecondWeapon(this, itemstack.copy());	// Equipping it in the second weapon slot, since we have that space
		}
		else	// Either not sneaking or doesn't have that weapon upgrade. Works for me
		{
			AI_WeaponHandler.setFirstWeapon(this, itemstack.copy());	// Equipping it
		}
		
		return true;
	}
	
	else if (itemstack.getItem() == Item.getItemFromBlock(Blocks.iron_block)) // Holding repair material
	{
		AI_Properties.doRepair(player, this, itemstack);
	}
	
	else if (itemstack.getItem() == Items.name_tag) // Holding a name tag
	{
		AI_Properties.applyNameTag(player, this, itemstack, true);
	}
	
	else	// Holding whatever
	{
		AI_Storage.addItem(player, this, itemstack);
		return true;
	}
	
	return false;
   }
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:72,代码来源:Entity_AA.java

示例9: addItem

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public static void addItem(EntityPlayer player, Entity_AA turret, ItemStack playerStack)
{
	int slot = 0;
	
	while (slot < turret.storage.length)
	{
		if (turret.storage[slot] == null)	// That spot is free
		{
			turret.storage[slot] = playerStack.copy();	// Stored
			if (!player.capabilities.isCreativeMode) { player.setCurrentItemOrArmor(0, null); }	// Empty
			
			if (playerStack.getItem() == Items.writable_book && AI_Targeting.isNameOnWhitelist(turret, Commands.cmdStayStationary))
			{
				//System.out.println("[ARMS ASSISTANT] Received a book with STAY command. Setting target position");
				turret.stationaryX = turret.posX;
				turret.stationaryY = turret.posY;
				turret.stationaryZ = turret.posZ;
			}
			
			// Informing the client about this change
			NetHelper.sendTurretInventoryMessageToPlayersInRange(turret.worldObj, turret, 
					Item.getIdFromItem(turret.storage[slot].getItem()), slot, turret.storage[slot].getItemDamage());
			
			return;	// We're done here
		}
		// else, there's something in there
		
		slot += 1;
	}
	
	// No free spot found. What about existing ones?
	slot = 0;
	
	while (slot < turret.storage.length)
	{
		if (turret.storage[slot] != null)
		{				
			boolean skip = false;
			
			if (!(turret.storage[slot].getItem() instanceof _AmmoBase)) { skip = true; }	// Not ammunition, hm?
			
			if (turret.storage[slot].getItemDamage() < turret.storage[slot].getMaxDamage()) { skip = true; }	// Not empty
			
			if (!skip)
			{					
				// Has an empty magazine in there, so replacing that now
				dropSingleItem(turret, turret.storage[slot].copy());
				turret.storage[slot] = playerStack.copy();	// Stored
				
				if (!player.capabilities.isCreativeMode) { player.setCurrentItemOrArmor(0, null); }	// Empty
				
				// Informing the client about this change
				NetHelper.sendTurretInventoryMessageToPlayersInRange(turret.worldObj, turret, 
						Item.getIdFromItem(turret.storage[slot].getItem()), slot, turret.storage[slot].getItemDamage());
				return;
			}
			// else, not a magazine
		}
		// else, no free spot found but this is null? Da fuq?
		
		slot += 1;
	}
}
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:64,代码来源:AI_Storage.java


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