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


Java EntityEquipmentSlot.getSlotType方法代码示例

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


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

示例1: setEnchantmentBasedOnDifficulty

import net.minecraft.inventory.EntityEquipmentSlot; //导入方法依赖的package包/类
/**
 * Enchants Entity's current equipments based on given DifficultyInstance
 */
protected void setEnchantmentBasedOnDifficulty(DifficultyInstance difficulty)
{
    float f = difficulty.getClampedAdditionalDifficulty();

    if (this.getHeldItemMainhand() != null && this.rand.nextFloat() < 0.25F * f)
    {
        EnchantmentHelper.addRandomEnchantment(this.rand, this.getHeldItemMainhand(), (int)(5.0F + f * (float)this.rand.nextInt(18)), false);
    }

    for (EntityEquipmentSlot entityequipmentslot : EntityEquipmentSlot.values())
    {
        if (entityequipmentslot.getSlotType() == EntityEquipmentSlot.Type.ARMOR)
        {
            ItemStack itemstack = this.getItemStackFromSlot(entityequipmentslot);

            if (itemstack != null && this.rand.nextFloat() < 0.5F * f)
            {
                EnchantmentHelper.addRandomEnchantment(this.rand, itemstack, (int)(5.0F + f * (float)this.rand.nextInt(18)), false);
            }
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:26,代码来源:EntityLiving.java

示例2: setItemStackToSlot

import net.minecraft.inventory.EntityEquipmentSlot; //导入方法依赖的package包/类
public void setItemStackToSlot(EntityEquipmentSlot slotIn, @Nullable ItemStack stack)
{
    if (slotIn == EntityEquipmentSlot.MAINHAND)
    {
        this.playEquipSound(stack);
        this.inventory.mainInventory[this.inventory.currentItem] = stack;
    }
    else if (slotIn == EntityEquipmentSlot.OFFHAND)
    {
        this.playEquipSound(stack);
        this.inventory.offHandInventory[0] = stack;
    }
    else if (slotIn.getSlotType() == EntityEquipmentSlot.Type.ARMOR)
    {
        this.playEquipSound(stack);
        this.inventory.armorInventory[slotIn.getIndex()] = stack;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:19,代码来源:EntityPlayer.java

示例3: setItemStackToSlot

import net.minecraft.inventory.EntityEquipmentSlot; //导入方法依赖的package包/类
public void setItemStackToSlot(EntityEquipmentSlot slotIn, ItemStack stack)
{
    if (slotIn == EntityEquipmentSlot.MAINHAND)
    {
        this.playEquipSound(stack);
        this.inventory.mainInventory.set(this.inventory.currentItem, stack);
    }
    else if (slotIn == EntityEquipmentSlot.OFFHAND)
    {
        this.playEquipSound(stack);
        this.inventory.offHandInventory.set(0, stack);
    }
    else if (slotIn.getSlotType() == EntityEquipmentSlot.Type.ARMOR)
    {
        this.playEquipSound(stack);
        this.inventory.armorInventory.set(slotIn.getIndex(), stack);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:19,代码来源:EntityPlayer.java

示例4: onContainerClosed

import net.minecraft.inventory.EntityEquipmentSlot; //导入方法依赖的package包/类
public void onContainerClosed(EntityPlayer playerIn)
{
    super.onContainerClosed(playerIn);
    if(!this.mercenary.world.isRemote) {
     for(int i=0;i<3;i++) {
     	if(!this.mercenary.loadoutHeld.getStackInSlot(i).isEmpty()) {
     		ItemStack buf = this.mercenary.loadout.getStackInSlot(i);
     		this.mercenary.loadout.setStackInSlot(i, this.mercenary.loadoutHeld.getStackInSlot(0));
     		this.mercenary.loadoutHeld.setStackInSlot(i, buf);
     	}
     }
     this.mercenary.switchSlot(this.mercenary.preferredSlot);
     
     for(EntityEquipmentSlot slot : EntityEquipmentSlot.values()) {
     	if(slot.getSlotType() == Type.ARMOR) {
     		//System.out.println("Not empt:" + slot);
     		this.mercenary.setDropChance(slot, !this.mercenary.getItemStackFromSlot(slot).isEmpty() ? 2.0f : 0.25f);
     	}
     }
     
     if(this.mercenary.getItemStackFromSlot(EntityEquipmentSlot.HEAD).isEmpty() && this.mercenary.loadoutHeld.getStackInSlot(3).getItem() instanceof ItemWearable) {
     	this.mercenary.setItemStackToSlot(EntityEquipmentSlot.HEAD, this.mercenary.loadoutHeld.getStackInSlot(3));
     	this.mercenary.loadoutHeld.setStackInSlot(3, ItemStack.EMPTY);
     }
    }
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:27,代码来源:ContainerMercenary.java

示例5: getItemStackFromSlot

import net.minecraft.inventory.EntityEquipmentSlot; //导入方法依赖的package包/类
@Nullable
public ItemStack getItemStackFromSlot(EntityEquipmentSlot slotIn)
{
    ItemStack itemstack = null;

    switch (slotIn.getSlotType())
    {
        case HAND:
            itemstack = this.inventoryHands[slotIn.getIndex()];
            break;
        case ARMOR:
            itemstack = this.inventoryArmor[slotIn.getIndex()];
    }

    return itemstack;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:17,代码来源:EntityLiving.java

示例6: insertItem

import net.minecraft.inventory.EntityEquipmentSlot; //导入方法依赖的package包/类
@Override
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate)
{
    EntityEquipmentSlot equ = null;
    for (EntityEquipmentSlot s : EntityEquipmentSlot.values())
    {
        if (s.getSlotType() == EntityEquipmentSlot.Type.ARMOR && s.getIndex() == slot)
        {
            equ = s;
            break;
        }
    }
    // check if it's valid for the armor slot
    if (slot < 4 && stack != null && stack.getItem().isValidArmor(stack, equ, getInventoryPlayer().player))
    {
        return super.insertItem(slot, stack, simulate);
    }
    return stack;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:20,代码来源:PlayerArmorInvWrapper.java

示例7: onEntityTick

import net.minecraft.inventory.EntityEquipmentSlot; //导入方法依赖的package包/类
@SubscribeEvent
public void onEntityTick(LivingUpdateEvent event)
{
	int i = 0;
	for(EntityEquipmentSlot slot : EntityEquipmentSlot.values())
		if(slot.getSlotType() == Type.ARMOR && allArmour.contains(event.getEntityLiving().getItemStackFromSlot(slot).getItem()))
			i++;
	if(i == 4)
	{
		event.getEntityLiving().addPotionEffect(new PotionEffect(MobEffects.NIGHT_VISION, 225, 0, false, false));
		event.getEntityLiving().addPotionEffect(new PotionEffect(MobEffects.SPEED, 30, 0, false, false));
		event.getEntityLiving().addPotionEffect(new PotionEffect(HarshenPotions.potionSoulless, 330, 0, false, false));
	}
			
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:16,代码来源:HandlerHarshenArmourEffects.java

示例8: setItemStackToSlot

import net.minecraft.inventory.EntityEquipmentSlot; //导入方法依赖的package包/类
public void setItemStackToSlot(EntityEquipmentSlot slotIn, ItemStack stack)
{
    switch (slotIn.getSlotType())
    {
        case HAND:
            this.playEquipSound(stack);
            this.handItems.set(slotIn.getIndex(), stack);
            break;

        case ARMOR:
            this.playEquipSound(stack);
            this.armorItems.set(slotIn.getIndex(), stack);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:15,代码来源:EntityArmorStand.java

示例9: setItemStackToSlot

import net.minecraft.inventory.EntityEquipmentSlot; //导入方法依赖的package包/类
public void setItemStackToSlot(EntityEquipmentSlot slotIn, @Nullable ItemStack stack)
{
    switch (slotIn.getSlotType())
    {
        case HAND:
            this.inventoryHands[slotIn.getIndex()] = stack;
            break;
        case ARMOR:
            this.inventoryArmor[slotIn.getIndex()] = stack;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:12,代码来源:EntityLiving.java

示例10: dropEquipment

import net.minecraft.inventory.EntityEquipmentSlot; //导入方法依赖的package包/类
/**
 * Drop the equipment for this entity.
 */
protected void dropEquipment(boolean wasRecentlyHit, int lootingModifier)
{
    for (EntityEquipmentSlot entityequipmentslot : EntityEquipmentSlot.values())
    {
        ItemStack itemstack = this.getItemStackFromSlot(entityequipmentslot);
        double d0;

        switch (entityequipmentslot.getSlotType())
        {
            case HAND:
                d0 = (double)this.inventoryHandsDropChances[entityequipmentslot.getIndex()];
                break;

            case ARMOR:
                d0 = (double)this.inventoryArmorDropChances[entityequipmentslot.getIndex()];
                break;

            default:
                d0 = 0.0D;
        }

        boolean flag = d0 > 1.0D;

        if (!itemstack.func_190926_b() && !EnchantmentHelper.func_190939_c(itemstack) && (wasRecentlyHit || flag) && (double)(this.rand.nextFloat() - (float)lootingModifier * 0.01F) < d0)
        {
            if (!flag && itemstack.isItemStackDamageable())
            {
                itemstack.setItemDamage(itemstack.getMaxDamage() - this.rand.nextInt(1 + this.rand.nextInt(Math.max(itemstack.getMaxDamage() - 3, 1))));
            }

            this.entityDropItem(itemstack, 0.0F);
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:38,代码来源:EntityLiving.java

示例11: setDropChance

import net.minecraft.inventory.EntityEquipmentSlot; //导入方法依赖的package包/类
public void setDropChance(EntityEquipmentSlot slotIn, float chance)
{
    switch (slotIn.getSlotType())
    {
        case HAND:
            this.inventoryHandsDropChances[slotIn.getIndex()] = chance;
            break;

        case ARMOR:
            this.inventoryArmorDropChances[slotIn.getIndex()] = chance;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:13,代码来源:EntityLiving.java

示例12: setDropChance

import net.minecraft.inventory.EntityEquipmentSlot; //导入方法依赖的package包/类
public void setDropChance(EntityEquipmentSlot slotIn, float chance)
{
    switch (slotIn.getSlotType())
    {
        case HAND:
            this.inventoryHandsDropChances[slotIn.getIndex()] = chance;
            break;
        case ARMOR:
            this.inventoryArmorDropChances[slotIn.getIndex()] = chance;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:12,代码来源:EntityLiving.java

示例13: isValidArmorSlot

import net.minecraft.inventory.EntityEquipmentSlot; //导入方法依赖的package包/类
public static boolean isValidArmorSlot(EntityEquipmentSlot slot) {
    return slot.getSlotType() == EntityEquipmentSlot.Type.ARMOR;
}
 
开发者ID:ichttt,项目名称:FirstAid,代码行数:4,代码来源:CommonUtils.java

示例14: getItemStackFromSlot

import net.minecraft.inventory.EntityEquipmentSlot; //导入方法依赖的package包/类
public ItemStack getItemStackFromSlot(EntityEquipmentSlot slotIn)
{
    return slotIn == EntityEquipmentSlot.MAINHAND ? this.inventory.getCurrentItem() : (slotIn == EntityEquipmentSlot.OFFHAND ? (ItemStack)this.inventory.offHandInventory.get(0) : (slotIn.getSlotType() == EntityEquipmentSlot.Type.ARMOR ? (ItemStack)this.inventory.armorInventory.get(slotIn.getIndex()) : ItemStack.field_190927_a));
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:5,代码来源:EntityPlayer.java

示例15: setEquipmentBasedOnDifficulty

import net.minecraft.inventory.EntityEquipmentSlot; //导入方法依赖的package包/类
/**
 * Gives armor or weapon for entity based on given DifficultyInstance
 */
protected void setEquipmentBasedOnDifficulty(DifficultyInstance difficulty)
{
    if (this.rand.nextFloat() < 0.15F * difficulty.getClampedAdditionalDifficulty())
    {
        int i = this.rand.nextInt(2);
        float f = this.worldObj.getDifficulty() == EnumDifficulty.HARD ? 0.1F : 0.25F;

        if (this.rand.nextFloat() < 0.095F)
        {
            ++i;
        }

        if (this.rand.nextFloat() < 0.095F)
        {
            ++i;
        }

        if (this.rand.nextFloat() < 0.095F)
        {
            ++i;
        }

        boolean flag = true;

        for (EntityEquipmentSlot entityequipmentslot : EntityEquipmentSlot.values())
        {
            if (entityequipmentslot.getSlotType() == EntityEquipmentSlot.Type.ARMOR)
            {
                ItemStack itemstack = this.getItemStackFromSlot(entityequipmentslot);

                if (!flag && this.rand.nextFloat() < f)
                {
                    break;
                }

                flag = false;

                if (itemstack == null)
                {
                    Item item = getArmorByChance(entityequipmentslot, i);

                    if (item != null)
                    {
                        this.setItemStackToSlot(entityequipmentslot, new ItemStack(item));
                    }
                }
            }
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:54,代码来源:EntityLiving.java


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