Search in sources :

Example 16 with Slot

use of net.minecraft.screen.slot.Slot in project Rug by RubixDev.

the class PeekCommand method showEnderChest.

public static void showEnderChest(ServerPlayerEntity executingPlayer, ServerPlayerEntity targetPlayer) {
    EnderChestInventory targetEnderChest = targetPlayer.getEnderChestInventory();
    PlayerDataGui invScreen = new PlayerDataGui(ScreenHandlerType.GENERIC_9X3, executingPlayer, targetPlayer);
    invScreen.setTitle(Text.of("EnderChest of " + targetPlayer.getDisplayName().asString()));
    for (int slot = 0; slot < targetEnderChest.size(); slot++) {
        invScreen.setSlotRedirect(slot, new Slot(targetEnderChest, slot, 0, 0));
    }
    invScreen.open();
}
Also used : PlayerDataGui(de.rubixdev.rug.gui.PlayerDataGui) EnderChestInventory(net.minecraft.inventory.EnderChestInventory) Slot(net.minecraft.screen.slot.Slot)

Example 17 with Slot

use of net.minecraft.screen.slot.Slot in project WK by witches-kitchen.

the class ScreenHandlerBuilder method playerSetup.

public ScreenHandlerBuilder playerSetup(int posX, int posY) {
    final int i = this.parent.slots.size();
    for (int j = 0; j < 3; ++j) {
        for (int k = 0; k < 9; ++k) {
            this.parent.addSlot(new Slot(this.playerInventory, k + j * 9 + 9, posX + k * 18, posY + j * 18));
        }
    }
    posY += 58;
    for (int x = 0; x < 9; x++) {
        this.parent.addSlot(new Slot(this.playerInventory, x, posX + x * 18, posY));
    }
    final int j = this.parent.slots.size() - 1;
    this.parent.addPlayerRange(Range.between(i, j));
    this.start = this.parent.slots.size();
    return this;
}
Also used : WKOutputSlot(cf.witcheskitchen.client.gui.screen.handler.slot.WKOutputSlot) WKSlot(cf.witcheskitchen.client.gui.screen.handler.slot.WKSlot) Slot(net.minecraft.screen.slot.Slot)

Example 18 with Slot

use of net.minecraft.screen.slot.Slot in project WK by witches-kitchen.

the class WKScreenHandler method transferSlot.

@Override
public ItemStack transferSlot(final PlayerEntity player, final int index) {
    ItemStack originalStack = ItemStack.EMPTY;
    final Slot slot = this.getSlot(index);
    if (slot != null && slot.hasStack()) {
        final ItemStack stackInSlot = slot.getStack();
        originalStack = stackInSlot.copy();
        boolean shifted = false;
        for (final Range<Integer> range : this.playerRanges) {
            if (range.contains(index)) {
                if (this.transferToBlockEntity(stackInSlot)) {
                    shifted = true;
                }
                break;
            }
        }
        if (!shifted) {
            for (final Range<Integer> range : this.blockEntityRanges) {
                if (range.contains(index)) {
                    if (this.transferToPlayer(stackInSlot)) {
                        shifted = true;
                    }
                    break;
                }
            }
        }
        slot.onQuickTransfer(stackInSlot, originalStack);
        if (stackInSlot.getCount() <= 0) {
            slot.setStack(ItemStack.EMPTY);
        } else {
            slot.markDirty();
        }
        if (stackInSlot.getCount() == originalStack.getCount()) {
            return ItemStack.EMPTY;
        }
        slot.onTakeItem(player, stackInSlot);
    }
    return originalStack;
}
Also used : Slot(net.minecraft.screen.slot.Slot) ItemStack(net.minecraft.item.ItemStack)

Example 19 with Slot

use of net.minecraft.screen.slot.Slot in project Skyblocker by LifeIsAParadox.

the class ContainerSolverManager method onDraw.

public void onDraw(MatrixStack matrices, List<Slot> slots) {
    if (currentSolver == null)
        return;
    if (highlights == null)
        highlights = currentSolver.getColors(groups, slotMap(slots));
    RenderSystem.disableDepthTest();
    RenderSystem.colorMask(true, true, true, false);
    for (ColorHighlight highlight : highlights) {
        Slot slot = slots.get(highlight.slot());
        int color = highlight.color();
        fillGradient(matrices, slot.x, slot.y, slot.x + 16, slot.y + 16, color, color);
    }
    RenderSystem.colorMask(true, true, true, true);
    RenderSystem.enableDepthTest();
}
Also used : Slot(net.minecraft.screen.slot.Slot)

Example 20 with Slot

use of net.minecraft.screen.slot.Slot in project BleachHack by BleachDrinker420.

the class Peek method drawScreen.

@BleachSubscribe
public void drawScreen(EventRenderTooltip event) {
    if (!(event.getScreen() instanceof HandledScreen)) {
        return;
    }
    Slot slot = ((HandledScreen<?>) event.getScreen()).focusedSlot;
    if (slot == null)
        return;
    if (slot.x != slotX || slot.y != slotY) {
        pageCount = 0;
        pages = null;
        slotX = slot.x;
        slotY = slot.y;
    }
    event.getMatrix().push();
    event.getMatrix().translate(0, 0, 400);
    if (getSetting(0).asToggle().getState()) {
        List<TooltipComponent> components = drawShulkerToolTip(event.getMatrix(), slot, event.getMouseX(), event.getMouseY());
        if (components != null) {
            if (components.isEmpty()) {
                event.setCancelled(true);
            } else {
                event.setComponents(components);
            }
        }
    }
    if (getSetting(1).asToggle().getState())
        drawBookToolTip(event.getMatrix(), slot, event.getMouseX(), event.getMouseY());
    if (getSetting(2).asToggle().getState())
        drawMapToolTip(event.getMatrix(), slot, event.getMouseX(), event.getMouseY());
    event.getMatrix().pop();
}
Also used : HandledScreen(net.minecraft.client.gui.screen.ingame.HandledScreen) Slot(net.minecraft.screen.slot.Slot) TooltipComponent(net.minecraft.client.gui.tooltip.TooltipComponent) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

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