use of net.minecraft.entity.player.InventoryPlayer in project Binnie by ForestryMC.
the class CustomSlot method onSlotClick.
public void onSlotClick(final ContainerCraftGUI container, final int dragType, final ClickType modifier, final EntityPlayer player) {
InventoryPlayer inventory = player.inventory;
ItemStack stack = inventory.getItemStack();
ItemStack slotStack = getStack().copy();
// TODO modifier==mouseButton2?
if (stack.isEmpty() || modifier == ClickType.PICKUP_ALL) {
this.putStack(ItemStack.EMPTY);
} else {
stack = stack.copy();
stack.setCount(1);
this.putStack(stack);
}
}
use of net.minecraft.entity.player.InventoryPlayer in project Binnie by ForestryMC.
the class ComponentDesignerRecipe method receiveGuiNBTOnServer.
@Override
public void receiveGuiNBTOnServer(final EntityPlayer player, final String name, final NBTTagCompound nbt) {
if (name.equals("recipe")) {
final InventoryPlayer playerInv = player.inventory;
final ItemStack recipe = this.doRecipe(false);
if (!recipe.isEmpty()) {
if (playerInv.getItemStack().isEmpty()) {
playerInv.setItemStack(this.doRecipe(true));
} else if (playerInv.getItemStack().isItemEqual(recipe) && ItemStack.areItemStackTagsEqual(playerInv.getItemStack(), recipe)) {
final int fit = recipe.getMaxStackSize() - (recipe.getCount() + playerInv.getItemStack().getCount());
if (fit >= 0) {
this.doRecipe(true);
recipe.grow(playerInv.getItemStack().getCount());
playerInv.setItemStack(recipe);
}
}
player.openContainer.detectAndSendChanges();
if (player instanceof EntityPlayerMP) {
((EntityPlayerMP) player).updateHeldItem();
}
}
} else if (name.equals("design")) {
setDesign(Design.getDesignManager().getDesign(nbt.getInteger("d")));
}
}
use of net.minecraft.entity.player.InventoryPlayer in project BuildCraft by BuildCraft.
the class BuildCraftContainer method slotClickPhantom.
// @Override
// public ItemStack slotClick(int slotNum, int mouseButton, ClickType clickType, EntityPlayer player) {
// Slot slot = slotNum < 0 ? null : (Slot) this.inventorySlots.get(slotNum);
// if (slot instanceof IPhantomSlot) {
// return slotClickPhantom(slot, mouseButton, clickType, player);
// }
// return super.slotClick(slotNum, mouseButton, clickType, player);
// }
private ItemStack slotClickPhantom(Slot slot, int mouseButton, ClickType clickType, EntityPlayer player) {
ItemStack stack = null;
if (mouseButton == 2) {
if (((IPhantomSlot) slot).canAdjustCount()) {
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)) {
fillPhantomSlot(slot, stackHeld, mouseButton, clickType);
}
} else if (stackHeld == null) {
adjustPhantomSlot(slot, mouseButton, clickType);
slot.onPickupFromSlot(player, playerInv.getItemStack());
} else if (slot.isItemValid(stackHeld)) {
if (StackUtil.canMerge(stackSlot, stackHeld)) {
adjustPhantomSlot(slot, mouseButton, clickType);
} else {
fillPhantomSlot(slot, stackHeld, mouseButton, clickType);
}
}
}
return stack;
}
use of net.minecraft.entity.player.InventoryPlayer in project BuildCraft by BuildCraft.
the class GuiBuildCraft method drawScreen.
/**
* Draws the screen and all the components in it.
*/
@Override
public void drawScreen(int mouseX, int mouseY, float par3) {
super.drawScreen(mouseX, mouseY, par3);
int left = this.guiLeft;
int top = this.guiTop;
GlStateManager.disableDepth();
GL11.glPushMatrix();
GL11.glTranslatef(left, top, 0.0F);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
RenderHelper.disableStandardItemLighting();
InventoryPlayer playerInv = this.mc.thePlayer.inventory;
if (playerInv.getItemStack() == null) {
drawToolTips(container.getWidgets(), mouseX - left, mouseY - top, left, top);
drawToolTips(buttonList, mouseX, mouseY, 0, 0);
drawToolTips(inventorySlots.inventorySlots, mouseX, mouseY, 0, 0);
}
GL11.glPopMatrix();
GlStateManager.enableDepth();
}
use of net.minecraft.entity.player.InventoryPlayer in project BuildCraft by BuildCraft.
the class FluidTankWidget method handleTankClick.
/**
* Attempts to interact the currently held item (in the gui) with this tank. This will either attempt to fill or
* drain the tank depending on what type of item is currently held.
*/
private void handleTankClick() {
InventoryPlayer inv = container.getPlayer().inventory;
ItemStack heldStack = inv.getItemStack();
if (heldStack == null || heldStack.getItem() == null)
return;
Item heldItem = heldStack.getItem();
if (FluidContainerRegistry.isEmptyContainer(heldStack)) {
int capacity = FluidContainerRegistry.getContainerCapacity(tank.drain(1, false), heldStack);
FluidStack potential = tank.drain(capacity, false);
if (potential == null)
return;
ItemStack filled = FluidContainerRegistry.fillFluidContainer(potential, heldStack);
if (filled == null)
return;
if (FluidContainerRegistry.getContainerCapacity(filled) != capacity)
return;
tank.drain(capacity, true);
inv.setItemStack(filled);
if (inv.player instanceof EntityPlayerMP) {
((EntityPlayerMP) inv.player).updateHeldItem();
}
} else if (FluidContainerRegistry.isFilledContainer(heldStack)) {
FluidStack contained = FluidContainerRegistry.getFluidForFilledItem(heldStack);
if (tank.fill(contained, false) != contained.amount)
return;
ItemStack drained = FluidContainerRegistry.drainFluidContainer(heldStack);
if (drained == null)
return;
tank.fill(contained, true);
inv.setItemStack(drained);
if (inv.player instanceof EntityPlayerMP) {
((EntityPlayerMP) inv.player).updateHeldItem();
}
} else if (heldItem instanceof IFluidContainerItem) {
IFluidContainerItem container = (IFluidContainerItem) heldItem;
FluidStack held = container.getFluid(heldStack);
}
}
Aggregations