use of net.minecraft.entity.player.InventoryPlayer in project Armourers-Workshop by RiskyKen.
the class UtilPlayer method getNumberOfItemInInventory.
public static int getNumberOfItemInInventory(EntityPlayer player, Item item) {
int itemCount = 0;
InventoryPlayer inventory = player.inventory;
for (int i = 0; i < inventory.mainInventory.length; i++) {
if (inventory.mainInventory[i].getItem() == item) {
itemCount += inventory.mainInventory[i].stackSize;
}
}
return itemCount;
}
use of net.minecraft.entity.player.InventoryPlayer in project ArsMagica2 by Mithion.
the class AM2Container method slotClickGhost.
public ItemStack slotClickGhost(Slot slot, int mouseButton, int modifier, EntityPlayer player) {
ItemStack stack = null;
if (mouseButton == 2) {
if (((IGhostSlot) slot).canAdjust()) {
slot.putStack(null);
}
} else if (mouseButton == 0 || mouseButton == 1) {
InventoryPlayer playerInv = player.inventory;
slot.onSlotChanged();
ItemStack stackSlot = slot.getStack();
ItemStack stackHeld = playerInv.getItemStack();
if (stackSlot != null) {
stack = stackSlot.copy();
}
if (stackSlot == null) {
if (stackHeld != null && slot.isItemValid(stackHeld)) {
fillGhostSlot(slot, stackHeld, mouseButton, modifier);
}
} else if (stackHeld == null) {
adjustGhostSlot(slot, mouseButton, modifier);
slot.onPickupFromSlot(player, playerInv.getItemStack());
} else if (slot.isItemValid(stackHeld)) {
if (InventoryUtilities.canStacksMerge(stackSlot, stackHeld)) {
adjustGhostSlot(slot, mouseButton, modifier);
} else {
fillGhostSlot(slot, stackHeld, mouseButton, modifier);
}
}
}
return stack;
}
use of net.minecraft.entity.player.InventoryPlayer in project Armourers-Workshop by RiskyKen.
the class EntityEquipmentDataManager method updateWeaponNBT.
private void updateWeaponNBT(EntityPlayer player, ExPropsPlayerSkinData props) {
InventoryPlayer inventory = player.inventory;
EntityEquipmentData equipmentData = props.getEquipmentData();
ItemStack stack = inventory.getCurrentItem();
if (stack != null) {
if (isRenderItem(ItemOverrideType.SWORD, stack.getItem())) {
if (equipmentData.haveEquipment(SkinTypeRegistry.skinSword, 0)) {
SkinNBTHelper.addSkinPointerToStack(stack, (SkinPointer) equipmentData.getSkinPointer(SkinTypeRegistry.skinSword, 0));
} else {
SkinNBTHelper.removeRenderIdFromStack(stack);
}
}
if (isRenderItem(ItemOverrideType.BOW, stack.getItem())) {
if (equipmentData.haveEquipment(SkinTypeRegistry.skinBow, 0)) {
SkinNBTHelper.addSkinPointerToStack(stack, (SkinPointer) equipmentData.getSkinPointer(SkinTypeRegistry.skinBow, 0));
} else {
SkinNBTHelper.removeRenderIdFromStack(stack);
}
}
if (isRenderItem(ItemOverrideType.PICKAXE, stack.getItem())) {
if (equipmentData.haveEquipment(SkinTypeRegistry.skinSword, 1)) {
SkinNBTHelper.addSkinPointerToStack(stack, (SkinPointer) equipmentData.getSkinPointer(SkinTypeRegistry.skinSword, 1));
} else {
SkinNBTHelper.removeRenderIdFromStack(stack);
}
}
if (isRenderItem(ItemOverrideType.AXE, stack.getItem())) {
if (equipmentData.haveEquipment(SkinTypeRegistry.skinSword, 2)) {
SkinNBTHelper.addSkinPointerToStack(stack, (SkinPointer) equipmentData.getSkinPointer(SkinTypeRegistry.skinSword, 2));
} else {
SkinNBTHelper.removeRenderIdFromStack(stack);
}
}
if (isRenderItem(ItemOverrideType.SHOVEL, stack.getItem())) {
if (equipmentData.haveEquipment(SkinTypeRegistry.skinSword, 3)) {
SkinNBTHelper.addSkinPointerToStack(stack, (SkinPointer) equipmentData.getSkinPointer(SkinTypeRegistry.skinSword, 3));
} else {
SkinNBTHelper.removeRenderIdFromStack(stack);
}
}
if (isRenderItem(ItemOverrideType.HOE, stack.getItem())) {
if (equipmentData.haveEquipment(SkinTypeRegistry.skinSword, 4)) {
SkinNBTHelper.addSkinPointerToStack(stack, (SkinPointer) equipmentData.getSkinPointer(SkinTypeRegistry.skinSword, 4));
} else {
SkinNBTHelper.removeRenderIdFromStack(stack);
}
}
}
}
use of net.minecraft.entity.player.InventoryPlayer in project PneumaticCraft by MineMaarten.
the class TileEntityAerialInterface method tickRF.
private void tickRF() {
if (getEnergyStored(null) > 0) {
InventoryPlayer inv = getPlayerInventory();
if (inv != null) {
for (int i = 0; i < inv.getSizeInventory(); i++) {
ItemStack stack = inv.getStackInSlot(i);
if (stack != null && stack.getItem() instanceof IEnergyContainerItem) {
IEnergyContainerItem chargingItem = (IEnergyContainerItem) stack.getItem();
int energyLeft = getEnergyStored(null);
if (energyLeft > 0) {
getEnergy().extractEnergy(chargingItem.receiveEnergy(stack, energyLeft, false), false);
} else {
break;
}
}
}
}
}
}
use of net.minecraft.entity.player.InventoryPlayer in project Minechem by iopleke.
the class MinechemUtil method scanForMoreStacks.
public static void scanForMoreStacks(ItemStack current, EntityPlayer player) {
int getMore = 8 - current.stackSize;
InventoryPlayer inventory = player.inventory;
int maxSlot = player.inventory.getSizeInventory() - 4;
int slot = 0;
do {
if (slot != inventory.currentItem) {
ItemStack slotStack = inventory.getStackInSlot(slot);
if (slotStack != null && slotStack.isItemEqual(current)) {
ItemStack addStack = inventory.decrStackSize(slot, getMore);
current.stackSize += addStack.stackSize;
getMore -= addStack.stackSize;
}
}
slot++;
} while (getMore > 0 && slot < maxSlot);
}
Aggregations