use of net.minecraft.entity.player.InventoryPlayer in project ConvenientAdditions by Necr0.
the class SlotFakeWithAmount method slotClick.
@Override
public ItemStack slotClick(Container container, int button, ClickType mode, EntityPlayer player) {
int adder = 0;
InventoryPlayer inventoryplayer = player.inventory;
ItemStack held = inventoryplayer.getItemStack();
if (mode == ClickType.THROW) {
if (button == 0)
slotAdd(-1);
else
slotAdd(-64);
} else if (mode == ClickType.SWAP) {
return ItemStack.EMPTY;
} else if ((mode == ClickType.PICKUP || mode == ClickType.PICKUP_ALL) && (button == 0 || button == 1)) {
ItemStack stack = getStack();
if (!stack.isEmpty() && isItemValid(held)) {
if (button == 0) {
adder = held.getCount();
} else if (button == 1) {
adder = 1;
}
slotAdd(adder);
} else if (!held.isEmpty()) {
this.putStack(held.copy());
} else if (!stack.isEmpty() && held.isEmpty()) {
adder = button == 0 ? 1 : -1;
slotAdd(adder);
}
} else if ((mode == ClickType.QUICK_MOVE) && (button == 0 || button == 1)) {
adder = button == 0 ? 8 : -8;
slotAdd(adder);
}
container.detectAndSendChanges();
return ItemStack.EMPTY;
}
use of net.minecraft.entity.player.InventoryPlayer in project Charset by CharsetMC.
the class ContainerPocketTable method addSlotToContainer.
@Override
protected Slot addSlotToContainer(Slot slot) {
if (slot.inventory instanceof InventoryPlayer) {
if (slot.isHere(slot.inventory, heldPos)) {
slot = new SlotBlocked(slot.inventory, slot.getSlotIndex(), slot.xPos, slot.yPos);
}
if (slot.getSlotIndex() >= 9 && (slot.getSlotIndex() % 9) >= 6) {
slot = new Slot(slot.inventory, slot.getSlotIndex(), slot.xPos, slot.yPos) {
@Override
public void onSlotChanged() {
super.onSlotChanged();
updateCraft();
}
};
craftingSlots.add(slot);
} else {
nonCraftingInventorySlots.add(slot);
if (slot.getSlotIndex() < 9) {
hotbarSlots.add(slot);
} else {
mainInvSlots.add(slot);
}
if (slot.getSlotIndex() < 9 && slot.getHasStack() && slot.getStack().getItem() == CharsetCraftingPocket.pocketTable) {
slot = new Slot(slot.inventory, slot.getSlotIndex(), slot.xPos, slot.yPos) {
@Override
public boolean canTakeStack(EntityPlayer playerIn) {
return false;
}
};
}
}
}
return super.addSlotToContainer(slot);
}
use of net.minecraft.entity.player.InventoryPlayer in project ForestryMC by ForestryMC.
the class SlotUtil method slotClickPhantom.
public static ItemStack slotClickPhantom(SlotForestry slot, int mouseButton, ClickType clickTypeIn, EntityPlayer player) {
ItemStack stack = ItemStack.EMPTY;
ItemStack stackSlot = slot.getStack();
if (!stackSlot.isEmpty()) {
stack = stackSlot.copy();
}
if (mouseButton == 2) {
fillPhantomSlot(slot, ItemStack.EMPTY, mouseButton);
} else if (mouseButton == 0 || mouseButton == 1) {
InventoryPlayer playerInv = player.inventory;
ItemStack stackHeld = playerInv.getItemStack();
if (stackSlot.isEmpty()) {
if (!stackHeld.isEmpty() && slot.isItemValid(stackHeld)) {
fillPhantomSlot(slot, stackHeld, mouseButton);
}
} else if (stackHeld.isEmpty()) {
adjustPhantomSlot(slot, mouseButton, clickTypeIn);
} else if (slot.isItemValid(stackHeld)) {
if (ItemStackUtil.isIdenticalItem(stackSlot, stackHeld)) {
adjustPhantomSlot(slot, mouseButton, clickTypeIn);
} else {
fillPhantomSlot(slot, stackHeld, mouseButton);
}
}
} else if (mouseButton == 5) {
InventoryPlayer playerInv = player.inventory;
ItemStack stackHeld = playerInv.getItemStack();
if (!slot.getHasStack()) {
fillPhantomSlot(slot, stackHeld, mouseButton);
}
}
return stack;
}
use of net.minecraft.entity.player.InventoryPlayer in project ForestryMC by ForestryMC.
the class GuiForestry method drawGuiContainerForegroundLayer.
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
ledgerManager.drawTooltips(mouseX, mouseY);
InventoryPlayer playerInv = mc.player.inventory;
if (playerInv.getItemStack().isEmpty()) {
GuiUtil.drawToolTips(this, widgetManager.getWidgets(), mouseX, mouseY);
GuiUtil.drawToolTips(this, buttonList, mouseX, mouseY);
GuiUtil.drawToolTips(this, inventorySlots.inventorySlots, mouseX, mouseY);
}
}
use of net.minecraft.entity.player.InventoryPlayer in project minecolonies by Minecolonies.
the class WindowBuildTool method onOpened.
/**
* Called when the window is opened.
* Sets up the buttons for either hut mode or decoration mode.
*/
@Override
public void onOpened() {
if (Settings.instance.isStaticSchematicMode()) {
sections.add(Structures.SCHEMATICS_PREFIX);
setStructureName(staticSchematicName);
} else {
Structures.loadScannedStyleMaps();
sections.clear();
final InventoryPlayer inventory = this.mc.player.inventory;
final List<String> allSections = Structures.getSections();
for (final String section : allSections) {
if (section.equals(Structures.SCHEMATICS_PREFIX) || section.equals(Structures.SCHEMATICS_SCAN) || inventoryHasHut(inventory, section)) {
sections.add(section);
}
}
if (Minecraft.getMinecraft().player.capabilities.isCreativeMode) {
findPaneOfTypeByID(BUTTON_PASTE, Button.class).setVisible(true);
findPaneOfTypeByID(BUTTON_PASTE_NICE, Button.class).setVisible(true);
} else {
findPaneOfTypeByID(BUTTON_PASTE, Button.class).setVisible(false);
findPaneOfTypeByID(BUTTON_PASTE_NICE, Button.class).setVisible(false);
}
setStructureName(Settings.instance.getStructureName());
}
}
Aggregations