當前位置: 首頁>>代碼示例>>Java>>正文


Java EntityEquipmentSlot.getIndex方法代碼示例

本文整理匯總了Java中net.minecraft.inventory.EntityEquipmentSlot.getIndex方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityEquipmentSlot.getIndex方法的具體用法?Java EntityEquipmentSlot.getIndex怎麽用?Java EntityEquipmentSlot.getIndex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.inventory.EntityEquipmentSlot的用法示例。


在下文中一共展示了EntityEquipmentSlot.getIndex方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: getItemStackFromSlot

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

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

    return itemstack;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:17,代碼來源:EntityArmorStand.java

示例3: 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

示例4: 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

示例5: getSlotTexture

import net.minecraft.inventory.EntityEquipmentSlot; //導入方法依賴的package包/類
@Override
@Nullable
@SideOnly(Side.CLIENT)
public String getSlotTexture() {
	final EntityEquipmentSlot entityequipmentslot = VALID_EQUIPMENT_SLOTS[armorNumber];
	return ItemArmor.EMPTY_SLOT_NAMES[entityequipmentslot.getIndex()];
}
 
開發者ID:Zundrel,項目名稱:Never-Enough-Currency,代碼行數:8,代碼來源:SlotArmor.java

示例6: 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

示例7: 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

示例8: setItemStackToSlot

import net.minecraft.inventory.EntityEquipmentSlot; //導入方法依賴的package包/類
public void setItemStackToSlot(EntityEquipmentSlot slotIn, @Nullable ItemStack stack)
{
    switch (slotIn.getSlotType())
    {
        case HAND:
            this.playEquipSound(stack);
            this.handItems[slotIn.getIndex()] = stack;
            break;
        case ARMOR:
            this.playEquipSound(stack);
            this.armorItems[slotIn.getIndex()] = stack;
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:14,代碼來源: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: 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

示例11: getDurability

import net.minecraft.inventory.EntityEquipmentSlot; //導入方法依賴的package包/類
public int getDurability(EntityEquipmentSlot armorType)
{
    return ItemArmor.MAX_DAMAGE_ARRAY[armorType.getIndex()] * this.maxDamageFactor;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:5,代碼來源:ItemArmor.java

示例12: getDamageReductionAmount

import net.minecraft.inventory.EntityEquipmentSlot; //導入方法依賴的package包/類
public int getDamageReductionAmount(EntityEquipmentSlot armorType)
{
    return this.damageReductionAmountArray[armorType.getIndex()];
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:5,代碼來源:ItemArmor.java

示例13: transferStackInSlot

import net.minecraft.inventory.EntityEquipmentSlot; //導入方法依賴的package包/類
/**
 * Take a stack from the specified inventory slot.
 */
@Override
@Nullable
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
	ItemStack itemstack = ItemStack.EMPTY;
	Slot slot = this.inventorySlots.get(index);

	if (slot != null && slot.getHasStack()) {
		ItemStack itemstack1 = slot.getStack();
		itemstack = itemstack1.copy();
		EntityEquipmentSlot entityequipmentslot = EntityLiving.getSlotForItemStack(itemstack);

		if (index >= 0 && index < 4) {
			if (!this.mergeItemStack(itemstack1, 8, 44, false))
				return ItemStack.EMPTY;
		} else if (index >= 4 && index < 7) {
			if (!this.mergeItemStack(itemstack1, 8, 44, false))
				return ItemStack.EMPTY;
		} else if (entityequipmentslot.getSlotType() == EntityEquipmentSlot.Type.ARMOR
				&& !this.inventorySlots.get(4 - entityequipmentslot.getIndex()).getHasStack()) {
			int i = 4 - entityequipmentslot.getIndex();

			if (!this.mergeItemStack(itemstack1, i, i + 1, false))
				return ItemStack.EMPTY;
		} else if (entityequipmentslot == EntityEquipmentSlot.OFFHAND
				&& !this.inventorySlots.get(44).getHasStack()) {
			if (!this.mergeItemStack(itemstack1, 44, 45, false))
				return ItemStack.EMPTY;
		} else if (itemstack1.getItem() instanceof ItemAmmoBelt
				&& !this.inventorySlots.get(7).getHasStack()) {
			if (!this.mergeItemStack(itemstack1, 7, 8, false))
				return ItemStack.EMPTY;
		} else if (itemstack1.getItem() instanceof ItemWearable && index >= 8) {
			if (!this.mergeItemStack(itemstack1, 4, 7, false))
				return ItemStack.EMPTY;
		} else if (itemstack1.getItem() instanceof ItemAmmo && ammoBelt && index < 44) {
			if (!this.mergeItemStack(itemstack1, 45, 54, false))
				return ItemStack.EMPTY;
		} else if (index >= 8 && index < 35) {
			if (!this.mergeItemStack(itemstack1, 35, 44, false))
				return ItemStack.EMPTY;
		} else if (index >= 35 && index < 44) {
			if (!this.mergeItemStack(itemstack1, 8, 35, false))
				return ItemStack.EMPTY;
		} else if (!this.mergeItemStack(itemstack1, 8, 44, false))
			return ItemStack.EMPTY;

		if (itemstack1.isEmpty())
			slot.putStack(ItemStack.EMPTY);
		else
			slot.onSlotChanged();

		if (itemstack1.getCount() ==itemstack.getCount())
			return ItemStack.EMPTY;

		slot.onTake(playerIn, itemstack1);
	}

	return itemstack;
}
 
開發者ID:rafradek,項目名稱:Mods,代碼行數:63,代碼來源:ContainerWearables.java

示例14: 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 != null && (wasRecentlyHit || flag) && (double)(this.rand.nextFloat() - (float)lootingModifier * 0.01F) < d0)
        {
            if (!flag && itemstack.isItemStackDamageable())
            {
                int i = Math.max(itemstack.getMaxDamage() - 25, 1);
                int j = itemstack.getMaxDamage() - this.rand.nextInt(this.rand.nextInt(i) + 1);

                if (j > i)
                {
                    j = i;
                }

                if (j < 1)
                {
                    j = 1;
                }

                itemstack.setItemDamage(j);
            }

            this.entityDropItem(itemstack, 0.0F);
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:49,代碼來源:EntityLiving.java

示例15: getItemStackFromSlot

import net.minecraft.inventory.EntityEquipmentSlot; //導入方法依賴的package包/類
@Nullable
public ItemStack getItemStackFromSlot(EntityEquipmentSlot slotIn)
{
    return slotIn == EntityEquipmentSlot.MAINHAND ? this.inventory.getCurrentItem() : (slotIn == EntityEquipmentSlot.OFFHAND ? this.inventory.offHandInventory[0] : (slotIn.getSlotType() == EntityEquipmentSlot.Type.ARMOR ? this.inventory.armorInventory[slotIn.getIndex()] : null));
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:6,代碼來源:EntityPlayer.java


注:本文中的net.minecraft.inventory.EntityEquipmentSlot.getIndex方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。