Java 类net.minecraft.inventory.EntityEquipmentSlot.Type 实例源码

项目:Mods    文件:ContainerMercenary.java   
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);
     }
    }
}
项目:harshencastle    文件:HandlerHarshenArmourEffects.java   
@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));
    }

}
项目:geomastery    文件:SlotArmour.java   
@Override
@SideOnly(Side.CLIENT)
public String getSlotTexture() {

    return this.type.getSlotType() == Type.ARMOR ?
            ItemArmor.EMPTY_SLOT_NAMES[this.type.getIndex()] : null;
}
项目:TaleCraft    文件:NPCInventoryData.java   
public static boolean isAcceptable(EntityEquipmentSlot slot, Item item){
    if(slot.getSlotType() == Type.ARMOR){
        if(item instanceof ItemArmor){
            ItemArmor armor = (ItemArmor) item;
            if(armor.armorType == slot) return true;
            else if(slot == EntityEquipmentSlot.HEAD && item instanceof ItemBlock) return true;
            else return false;
        }else return false;
    }else{
        return true;
    }
}
项目:EnderIO    文件:ContainerCapBank.java   
private boolean mergeItemStackIntoArmor(EntityPlayer entityPlayer, ItemStack origStack, int slotIndex) {
  if (origStack == null || EntityLiving.getSlotForItemStack(origStack).getSlotType() != EntityEquipmentSlot.Type.ARMOR) {
    return false;
  }
  int index = EntityLiving.getSlotForItemStack(origStack).getIndex();
  NonNullList<ItemStack> ai = entityPlayer.inventory.armorInventory;
  if (ai.get(index).isEmpty()) {
    ai.set(index, origStack.copy());
    origStack.setCount(0);
    return true;
  }
  return false;
}
项目:Mods    文件:ContainerMercenary.java   
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 equip = EntityLiving.getSlotForItemStack(itemstack);

        if (index == 2)
        {
            if (!this.mergeItemStack(itemstack1, 3, 39, true))
            {
                return ItemStack.EMPTY;
            }

            slot.onSlotChange(itemstack1, itemstack);
        }
        else if (index != 0 && index != 1)
        {
            if (equip.getSlotType() == EntityEquipmentSlot.Type.ARMOR && !(index >= 40 && index < 44)) {
                if(!this.mergeItemStack(itemstack1, 43-equip.getIndex(), 44-equip.getIndex(), false))
                    return ItemStack.EMPTY;
            }
            else if (itemstack1.getItem() instanceof ItemUsable && !(index >= 44 && index < 47) ) {
                for(int i = 0; i < 3; i++) {
                    if(!this.getSlot(i + 44).isItemValid(itemstack1) || !this.mergeItemStack(itemstack1, i + 44, i + 45, false))
                        return ItemStack.EMPTY;
                }
            }
            else if (index >= 3 && index < 30)
            {
                if (!this.mergeItemStack(itemstack1, 30, 39, false))
                {
                    return ItemStack.EMPTY;
                }
            }
            else if (index >= 30 && index < 39 && !this.mergeItemStack(itemstack1, 3, 30, false))
            {
                return ItemStack.EMPTY;
            }
        }
        else if (!this.mergeItemStack(itemstack1, 3, 39, 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;
}