本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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()];
}
示例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);
}
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例11: getDurability
import net.minecraft.inventory.EntityEquipmentSlot; //导入方法依赖的package包/类
public int getDurability(EntityEquipmentSlot armorType)
{
return ItemArmor.MAX_DAMAGE_ARRAY[armorType.getIndex()] * this.maxDamageFactor;
}
示例12: getDamageReductionAmount
import net.minecraft.inventory.EntityEquipmentSlot; //导入方法依赖的package包/类
public int getDamageReductionAmount(EntityEquipmentSlot armorType)
{
return this.damageReductionAmountArray[armorType.getIndex()];
}
示例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;
}
示例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);
}
}
}
示例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));
}