Search in sources :

Example 6 with Slot

use of net.minecraft.screen.slot.Slot in project isometric-renders by gliscowo.

the class HandledScreenMixin method renderInventory.

@Inject(method = "keyPressed", at = @At("HEAD"), cancellable = true)
public void renderInventory(int keyCode, int scanCode, int modifiers, CallbackInfoReturnable<Boolean> cir) {
    if (keyCode == GLFW.GLFW_KEY_F12) {
        if (Screen.hasControlDown()) {
            client.openScreen(new BatchIsometricBlockRenderScreen(IsometricRenderHelper.extractBlocks(handler.slots.stream().map(Slot::getStack).collect(Collectors.toList())), "inventory"));
            cir.cancel();
        } else if (Screen.hasAltDown()) {
            client.openScreen(new BatchIsometricItemRenderScreen(handler.slots.stream().map(Slot::getStack).iterator(), "inventory"));
            cir.cancel();
        } else if (Screen.hasShiftDown()) {
            IsometricRenderHelper.renderItemAtlas("inventory", handler.slots.stream().map(Slot::getStack).filter(itemStack -> !itemStack.isEmpty()).collect(Collectors.toList()), true);
            cir.cancel();
        }
    }
}
Also used : BatchIsometricItemRenderScreen(com.glisco.isometricrenders.client.gui.BatchIsometricItemRenderScreen) BatchIsometricBlockRenderScreen(com.glisco.isometricrenders.client.gui.BatchIsometricBlockRenderScreen) Slot(net.minecraft.screen.slot.Slot) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 7 with Slot

use of net.minecraft.screen.slot.Slot in project Client by MatHax.

the class InventorySorter method generateActions.

private void generateActions() {
    // Find all slots and sort them
    List<MySlot> slots = new ArrayList<>();
    for (Slot slot : screen.getScreenHandler().slots) {
        if (getInvPart(slot) == originInvPart)
            slots.add(new MySlot(((ISlot) slot).getId(), slot.getStack()));
    }
    slots.sort(Comparator.comparingInt(value -> value.id));
    // Generate actions
    generateStackingActions(slots);
    generateSortingActions(slots);
}
Also used : PeekScreen(mathax.client.utils.render.PeekScreen) PlayerInventory(net.minecraft.entity.player.PlayerInventory) Pair(net.minecraft.util.Pair) ISlot(mathax.client.mixininterface.ISlot) SimpleInventory(net.minecraft.inventory.SimpleInventory) Slot(net.minecraft.screen.slot.Slot) Registry(net.minecraft.util.registry.Registry) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) List(java.util.List) GenericContainerScreen(net.minecraft.client.gui.screen.ingame.GenericContainerScreen) CreativeInventoryScreen(net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen) Comparator(java.util.Comparator) HandledScreen(net.minecraft.client.gui.screen.ingame.HandledScreen) ArrayList(java.util.ArrayList) ISlot(mathax.client.mixininterface.ISlot) Slot(net.minecraft.screen.slot.Slot)

Example 8 with Slot

use of net.minecraft.screen.slot.Slot in project CopperEquipment by Redy1aye.

the class DrayerScreenHandler method transferSlot.

@Override
public ItemStack transferSlot(PlayerEntity player, int invSlot) {
    ItemStack newStack = ItemStack.EMPTY;
    Slot slot = this.slots.get(invSlot);
    if (slot != null && slot.hasStack()) {
        ItemStack originalStack = slot.getStack();
        newStack = originalStack.copy();
        if (invSlot < this.inventory.size()) {
            if (!this.insertItem(originalStack, this.inventory.size(), this.slots.size(), true)) {
                return ItemStack.EMPTY;
            }
        } else if (!this.insertItem(originalStack, 0, this.inventory.size(), false)) {
            return ItemStack.EMPTY;
        }
        if (originalStack.isEmpty()) {
            slot.setStack(ItemStack.EMPTY);
        } else {
            slot.markDirty();
        }
    }
    return newStack;
}
Also used : Slot(net.minecraft.screen.slot.Slot) ItemStack(net.minecraft.item.ItemStack)

Example 9 with Slot

use of net.minecraft.screen.slot.Slot in project LittleMaidReBirth-Fabric by SistrScarlet.

the class LittleMaidScreenHandler method transferSlot.

// 18 + 2 + 4 = 24、24 + 4 * 9 = 60
// 0~17メイドインベントリ、18~19メインサブ、20~23防具、24~59プレイヤーインベントリ
@Override
public ItemStack transferSlot(PlayerEntity player, int invSlot) {
    ItemStack newStack = ItemStack.EMPTY;
    Slot slot = this.slots.get(invSlot);
    if (slot == null || !slot.hasStack()) {
        return newStack;
    }
    ItemStack originalStack = slot.getStack();
    newStack = originalStack.copy();
    if (invSlot < 18) {
        // メイド->プレイヤー
        if (!this.insertItem(originalStack, 24, 60, false)) {
            return ItemStack.EMPTY;
        }
    } else if (invSlot < 24) {
        // ハンド、防具->メイド
        if (!this.insertItem(originalStack, 0, 18, true)) {
            return ItemStack.EMPTY;
        }
    } else {
        // プレイヤー->メイド
        if (!this.insertItem(originalStack, 0, 18, false)) {
            return ItemStack.EMPTY;
        }
    }
    if (originalStack.isEmpty()) {
        slot.setStack(ItemStack.EMPTY);
    } else {
        slot.markDirty();
    }
    return newStack;
}
Also used : EquipmentSlot(net.minecraft.entity.EquipmentSlot) Slot(net.minecraft.screen.slot.Slot) ItemStack(net.minecraft.item.ItemStack)

Example 10 with Slot

use of net.minecraft.screen.slot.Slot in project SinoCate by EverlastSino.

the class StoneMillScreenHandler method transferSlot.

@Override
public ItemStack transferSlot(PlayerEntity player, int invSlot) {
    ItemStack newStack = ItemStack.EMPTY;
    Slot slot = this.slots.get(invSlot);
    if (slot.hasStack()) {
        ItemStack originalStack = slot.getStack();
        newStack = originalStack.copy();
        if (invSlot < this.inventory.size()) {
            if (!this.insertItem(originalStack, this.inventory.size(), this.slots.size(), true)) {
                return ItemStack.EMPTY;
            }
        } else if (!this.insertItem(originalStack, 0, this.inventory.size(), false)) {
            return ItemStack.EMPTY;
        }
        if (originalStack.isEmpty()) {
            slot.setStack(ItemStack.EMPTY);
        } else {
            slot.markDirty();
        }
    }
    return newStack;
}
Also used : Slot(net.minecraft.screen.slot.Slot) ItemStack(net.minecraft.item.ItemStack)

Aggregations

Slot (net.minecraft.screen.slot.Slot)24 ItemStack (net.minecraft.item.ItemStack)14 EquipmentSlot (net.minecraft.entity.EquipmentSlot)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 ArmorStandPreset (eu.pb4.armorstandeditor.config.ArmorStandPreset)2 ConfigManager (eu.pb4.armorstandeditor.config.ConfigManager)2 ArmorStandData (eu.pb4.armorstandeditor.helpers.ArmorStandData)2 ArmorStandInventory (eu.pb4.armorstandeditor.helpers.ArmorStandInventory)2 ItemFrameInventory (eu.pb4.armorstandeditor.helpers.ItemFrameInventory)2 SPEInterface (eu.pb4.armorstandeditor.helpers.SPEInterface)2 ArmorStandEntityAccessor (eu.pb4.armorstandeditor.mixin.ArmorStandEntityAccessor)2 ItemFrameEntityAccessor (eu.pb4.armorstandeditor.mixin.ItemFrameEntityAccessor)2 ClickType (eu.pb4.sgui.api.ClickType)2 GuiElement (eu.pb4.sgui.api.elements.GuiElement)2 GuiElementBuilder (eu.pb4.sgui.api.elements.GuiElementBuilder)2 GuiElementInterface (eu.pb4.sgui.api.elements.GuiElementInterface)2 AnvilInputGui (eu.pb4.sgui.api.gui.AnvilInputGui)2 SimpleGui (eu.pb4.sgui.api.gui.SimpleGui)2 Collection (java.util.Collection)2