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


Java EntityLivingBase.setItemStackToSlot方法代码示例

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


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

示例1: apply

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void apply(World world, BlockPos pos, EntityLivingBase entity, int amplifier, int tick) {
	if (!entity.world.isRemote) {
		int i = entity.getRNG().nextInt(4 + 16 / (amplifier + 1));
		switch (i) {
			case 0:
				spawnItem(entity, entity.getItemStackFromSlot(EntityEquipmentSlot.FEET));
				entity.setItemStackToSlot(EntityEquipmentSlot.FEET, ItemStack.EMPTY);
				break;
			case 1:
				spawnItem(entity, entity.getItemStackFromSlot(EntityEquipmentSlot.LEGS));
				entity.setItemStackToSlot(EntityEquipmentSlot.LEGS, ItemStack.EMPTY);
				break;
			case 2:
				spawnItem(entity, entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST));
				entity.setItemStackToSlot(EntityEquipmentSlot.CHEST, ItemStack.EMPTY);
				break;
			case 3:
				spawnItem(entity, entity.getItemStackFromSlot(EntityEquipmentSlot.HEAD));
				entity.setItemStackToSlot(EntityEquipmentSlot.HEAD, ItemStack.EMPTY);
				break;
		}
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:25,代码来源:DisrobingBrew.java

示例2: dispenseArmor

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public static ItemStack dispenseArmor(IBlockSource blockSource, ItemStack stack)
{
    BlockPos blockpos = blockSource.getBlockPos().offset((EnumFacing)blockSource.getBlockState().getValue(BlockDispenser.FACING));
    List<EntityLivingBase> list = blockSource.getWorld().<EntityLivingBase>getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(blockpos), Predicates.<EntityLivingBase> and (EntitySelectors.NOT_SPECTATING, new EntitySelectors.ArmoredMob(stack)));

    if (list.isEmpty())
    {
        return ItemStack.field_190927_a;
    }
    else
    {
        EntityLivingBase entitylivingbase = (EntityLivingBase)list.get(0);
        EntityEquipmentSlot entityequipmentslot = EntityLiving.getSlotForItemStack(stack);
        ItemStack itemstack = stack.splitStack(1);
        entitylivingbase.setItemStackToSlot(entityequipmentslot, itemstack);

        if (entitylivingbase instanceof EntityLiving)
        {
            ((EntityLiving)entitylivingbase).setDropChance(entityequipmentslot, 2.0F);
        }

        return stack;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:25,代码来源:ItemArmor.java

示例3: dispenseArmor

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public static ItemStack dispenseArmor(IBlockSource blockSource, ItemStack stack)
{
    BlockPos blockpos = blockSource.getBlockPos().offset((EnumFacing)blockSource.getBlockState().getValue(BlockDispenser.FACING));
    List<EntityLivingBase> list = blockSource.getWorld().<EntityLivingBase>getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(blockpos), Predicates.<EntityLivingBase>and(EntitySelectors.NOT_SPECTATING, new EntitySelectors.ArmoredMob(stack)));

    if (list.isEmpty())
    {
        return null;
    }
    else
    {
        EntityLivingBase entitylivingbase = (EntityLivingBase)list.get(0);
        EntityEquipmentSlot entityequipmentslot = EntityLiving.getSlotForItemStack(stack);
        ItemStack itemstack = stack.copy();
        itemstack.stackSize = 1;
        entitylivingbase.setItemStackToSlot(entityequipmentslot, itemstack);

        if (entitylivingbase instanceof EntityLiving)
        {
            ((EntityLiving)entitylivingbase).setDropChance(entityequipmentslot, 2.0F);
        }

        --stack.stackSize;
        return stack;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:27,代码来源:ItemArmor.java

示例4: onEntityUpdate

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@SubscribeEvent
public void onEntityUpdate(LivingUpdateEvent event)
{
	EntityLivingBase living = event.getEntityLiving();
	if(living instanceof IBurnInDay && living.world.isDaytime() && !living.world.isRemote && !living.isChild() && ((IBurnInDay)living).shouldBurn() && living.getBrightness() > 0.5F && 
			living.getRNG().nextFloat() * 30.0F < (living.getBrightness() - 0.4F) * 2.0F && living.world.canSeeSky(new BlockPos(living.posX, living.posY + (double)living.getEyeHeight(), living.posZ)))
	{
		boolean flag = true;
           ItemStack itemstack = living.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
           if (!itemstack.isEmpty())
           {
               if (itemstack.isItemStackDamageable())
               {
                   itemstack.setItemDamage(itemstack.getItemDamage() + living.getRNG().nextInt(2));

                   if (itemstack.getItemDamage() >= itemstack.getMaxDamage())
                   {
                   	living.renderBrokenItemStack(itemstack);
                   	living.setItemStackToSlot(EntityEquipmentSlot.HEAD, ItemStack.EMPTY);
                   }
               }

               flag = false;
           }

           if (flag)
           {
           	living.setFire(8);
           }
	}
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:32,代码来源:HandlerBurnInDaylight.java

示例5: damageShield

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
void damageShield(EntityLivingBase attacked, EntityLivingBase attacker, float f)
{
    ItemStack shield = null;
    if(Prep1_11.isValid(attacked.getHeldItemOffhand()) && attacked.getHeldItemOffhand().getItem() == RegisterItems.wickerShield)
    shield = attacked.getHeldItemOffhand();
    else if(Prep1_11.isValid(attacked.getHeldItemMainhand()) && attacked.getHeldItemMainhand().getItem() == RegisterItems.wickerShield)
    shield = attacked.getHeldItemMainhand();

    //Copied from EntityPlayer#damageShield() START
    if(Prep1_11.isEmpty(shield)) return;
    shield.damageItem(1 + MathHelper.floor(f), attacker);
    if (shield.getCount() <= 0)
    {
        EnumHand enumhand = attacked.getActiveHand();
        if(attacked instanceof EntityPlayer) net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem((EntityPlayer) attacked, attacked.getActiveItemStack(), enumhand);

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

        attacked.resetActiveHand();
        attacked.playSound(SoundEvents.ITEM_SHIELD_BREAK, 0.8F, 0.8F + attacked.world.rand.nextFloat() * 0.4F);
    }
    //Copied from EntityPlayer#damageShield() END
}
 
开发者ID:einsteinsci,项目名称:BetterBeginningsReborn,代码行数:31,代码来源:ItemWickerShield.java


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