use of net.minecraft.entity.player.InventoryPlayer in project ConvenientAdditions by Necr0.
the class ContainerTransmutationTome method onContainerClosed.
@Override
public void onContainerClosed(EntityPlayer playerIn) {
if (player.getEntityWorld().isRemote)
return;
InventoryPlayer inventoryplayer = playerIn.inventory;
if (!inventoryplayer.getItemStack().isEmpty()) {
playerIn.dropItem(inventoryplayer.getItemStack(), false);
inventoryplayer.setItemStack(ItemStack.EMPTY);
}
if (!handler.getStackInSlot(0).isEmpty()) {
playerIn.dropItem(handler.getStackInSlot(0), false);
handler.setStackInSlot(0, ItemStack.EMPTY);
}
if (!handler.getStackInSlot(1).isEmpty()) {
playerIn.dropItem(handler.getStackInSlot(1), false);
handler.setStackInSlot(1, ItemStack.EMPTY);
}
if (!out.getStackInSlot(0).isEmpty()) {
playerIn.dropItem(out.getStackInSlot(0), false);
out.setStackInSlot(0, ItemStack.EMPTY);
}
}
use of net.minecraft.entity.player.InventoryPlayer in project ConvenientAdditions by Necr0.
the class CAGuiContainer method drawScreen.
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
super.drawScreen(mouseX, mouseY, partialTicks);
drawDrawables(partialTicks, mouseX, mouseY);
drawTooltips(partialTicks, mouseX, mouseY);
//render tooltip again above widgets
try {
InventoryPlayer inventoryplayer = this.mc.player.inventory;
Field f = GuiContainer.class.getDeclaredField("theSlot");
f.setAccessible(true);
Slot theSlot = (Slot) f.get(this);
if (inventoryplayer.getItemStack().isEmpty() && theSlot != null && theSlot.getHasStack()) {
ItemStack itemstack1 = theSlot.getStack();
this.renderToolTip(itemstack1, mouseX, mouseY);
}
} catch (Exception e) {
}
}
use of net.minecraft.entity.player.InventoryPlayer in project ConvenientAdditions by Necr0.
the class CAContainer method slotClick.
@Override
public ItemStack slotClick(int index, int button, ClickType mode, EntityPlayer player) {
InventoryPlayer inventoryplayer = player.inventory;
ItemStack held = inventoryplayer.getItemStack();
if (index >= 0) {
Slot s = getSlot(index);
if (s instanceof IFakeSlot) {
return ((IFakeSlot) s).slotClick(this, button, mode, player);
}
}
return super.slotClick(index, button, mode, player);
}
use of net.minecraft.entity.player.InventoryPlayer in project Galacticraft by micdoodle8.
the class NEIServerUtils method cycleCreativeInv.
public static void cycleCreativeInv(EntityPlayerMP player, int steps) {
InventoryPlayer inventory = player.inventory;
// top down [row][col]
ItemStack[][] slots = new ItemStack[10][9];
PlayerSave playerSave = NEIServerConfig.forPlayer(player.getName());
// get
System.arraycopy(inventory.mainInventory, 0, slots[9], 0, 9);
for (int row = 0; row < 3; row++) {
System.arraycopy(inventory.mainInventory, (row + 1) * 9, slots[row + 6], 0, 9);
}
for (int row = 0; row < 6; row++) {
System.arraycopy(playerSave.creativeInv, row * 9, slots[row], 0, 9);
}
ItemStack[][] newslots = new ItemStack[10][];
// put back
for (int row = 0; row < 10; row++) {
newslots[(row + steps + 10) % 10] = slots[row];
}
System.arraycopy(newslots[9], 0, inventory.mainInventory, 0, 9);
for (int row = 0; row < 3; row++) {
System.arraycopy(newslots[row + 6], 0, inventory.mainInventory, (row + 1) * 9, 9);
}
for (int row = 0; row < 6; row++) {
System.arraycopy(newslots[row], 0, playerSave.creativeInv, row * 9, 9);
}
playerSave.setDirty();
}
use of net.minecraft.entity.player.InventoryPlayer in project BuildCraft by BuildCraft.
the class ContainerBC_Neptune method transferStackInSlot.
@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
ItemStack itemstack = ItemStack.EMPTY;
Slot slot = this.inventorySlots.get(index);
Slot firstSlot = this.inventorySlots.get(0);
int playerInventorySize = 36;
boolean playerInventoryFirst = firstSlot.inventory instanceof InventoryPlayer;
if (slot != null && slot.getHasStack()) {
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (inventorySlots.size() == playerInventorySize)
return ItemStack.EMPTY;
if (playerInventoryFirst) {
if (index < playerInventorySize) {
if (!this.mergeItemStack(itemstack1, playerInventorySize, this.inventorySlots.size(), false)) {
return ItemStack.EMPTY;
}
} else if (!this.mergeItemStack(itemstack1, 0, playerInventorySize, true)) {
return ItemStack.EMPTY;
}
} else {
if (index < this.inventorySlots.size() - playerInventorySize) {
if (!this.mergeItemStack(itemstack1, this.inventorySlots.size() - playerInventorySize, this.inventorySlots.size(), false)) {
return ItemStack.EMPTY;
}
} else if (!this.mergeItemStack(itemstack1, 0, this.inventorySlots.size() - playerInventorySize, true)) {
return ItemStack.EMPTY;
}
}
if (itemstack1.isEmpty()) {
slot.putStack(ItemStack.EMPTY);
} else {
slot.onSlotChanged();
}
}
return itemstack;
}
Aggregations