2016-01-02 13:38:18 +00:00
|
|
|
package net.minecraftforge.items.wrapper;
|
|
|
|
|
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
2016-03-09 22:11:56 +00:00
|
|
|
import net.minecraft.inventory.EntityEquipmentSlot;
|
2016-01-02 13:38:18 +00:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
2016-03-22 01:31:33 +00:00
|
|
|
public class PlayerArmorInvWrapper extends RangedWrapper
|
2016-01-02 13:38:18 +00:00
|
|
|
{
|
|
|
|
public final InventoryPlayer inventoryPlayer;
|
|
|
|
|
|
|
|
public PlayerArmorInvWrapper(InventoryPlayer inv)
|
|
|
|
{
|
2016-03-22 01:31:33 +00:00
|
|
|
super(new InvWrapper(inv), inv.mainInventory.length, inv.mainInventory.length + inv.armorInventory.length);
|
2016-01-02 13:38:18 +00:00
|
|
|
inventoryPlayer = inv;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate)
|
|
|
|
{
|
2016-03-09 22:11:56 +00:00
|
|
|
EntityEquipmentSlot equ = null;
|
|
|
|
for (EntityEquipmentSlot s : EntityEquipmentSlot.values())
|
|
|
|
{
|
2016-03-13 01:40:03 +00:00
|
|
|
if (s.getSlotType() == EntityEquipmentSlot.Type.ARMOR && s.getIndex() == slot)
|
2016-03-09 22:11:56 +00:00
|
|
|
{
|
|
|
|
equ = s;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-01-02 13:38:18 +00:00
|
|
|
// check if it's valid for the armor slot
|
2016-03-09 22:11:56 +00:00
|
|
|
if (slot < 4 && stack != null && stack.getItem().isValidArmor(stack, equ, inventoryPlayer.player))
|
2016-01-02 13:38:18 +00:00
|
|
|
{
|
2016-03-22 01:31:33 +00:00
|
|
|
return super.insertItem(slot, stack, simulate);
|
2016-01-02 13:38:18 +00:00
|
|
|
}
|
|
|
|
return stack;
|
|
|
|
}
|
|
|
|
}
|