Search in sources :

Example 1 with GenericContainerScreenHandler

use of net.minecraft.screen.GenericContainerScreenHandler in project KahzerxMod by otakucraft.

the class SpoofExtension method spoofInv.

public int spoofInv(ServerCommandSource source, String playerE) throws CommandSyntaxException {
    int invSize = 54;
    int hotBarSize = 9;
    int hotBarStartPos = 27;
    int invStartPos = 9;
    Inventory inventory = new SimpleInventory(invSize);
    ServerPlayerEntity player = source.getPlayer();
    ServerPlayerEntity player2 = source.getServer().getPlayerManager().getPlayer(playerE);
    assert player2 != null;
    for (int i = 0; i < player2.getInventory().main.size(); i++) {
        if (i < hotBarSize) {
            inventory.setStack(i + hotBarStartPos, player2.getInventory().main.get(i));
        } else {
            inventory.setStack(i - invStartPos, player2.getInventory().main.get(i));
        }
    }
    int armorSlotStartPos = 45;
    for (int j = 0; j < player2.getInventory().armor.size(); j++) {
        inventory.setStack(j + armorSlotStartPos, player2.getInventory().armor.get(j));
    }
    int offHandSlotPos = 36;
    inventory.setStack(offHandSlotPos, player2.getInventory().offHand.get(0));
    ScreenHandlerListener listener = new ScreenHandlerListener() {

        @Override
        public void onSlotUpdate(ScreenHandler handler, int slotId, ItemStack stack) {
        // source.getServer().getPlayerManager().saveAllPlayerData();
        }

        @Override
        public void onPropertyUpdate(ScreenHandler handler, int property, int value) {
        }
    };
    player.openHandledScreen(new SimpleNamedScreenHandlerFactory((i, playerInventory, playerEntity) -> {
        GenericContainerScreenHandler invCont = GenericContainerScreenHandler.createGeneric9x6(i, playerInventory, inventory);
        invCont.addListener(listener);
        return invCont;
    }, new LiteralText(String.format("%s stop hax >:(", player.getName().getString()))));
    return 1;
}
Also used : ExtensionSettings(com.kahzerx.kahzerxmod.extensions.ExtensionSettings) LiteralText(net.minecraft.text.LiteralText) ScreenHandler(net.minecraft.screen.ScreenHandler) CommandDispatcher(com.mojang.brigadier.CommandDispatcher) GenericExtension(com.kahzerx.kahzerxmod.extensions.GenericExtension) EnderChestInventory(net.minecraft.inventory.EnderChestInventory) ServerCommandSource(net.minecraft.server.command.ServerCommandSource) ScreenHandlerListener(net.minecraft.screen.ScreenHandlerListener) SimpleNamedScreenHandlerFactory(net.minecraft.screen.SimpleNamedScreenHandlerFactory) Extensions(com.kahzerx.kahzerxmod.Extensions) Inventory(net.minecraft.inventory.Inventory) SimpleInventory(net.minecraft.inventory.SimpleInventory) ItemStack(net.minecraft.item.ItemStack) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException) GenericContainerScreenHandler(net.minecraft.screen.GenericContainerScreenHandler) ScreenHandlerListener(net.minecraft.screen.ScreenHandlerListener) GenericContainerScreenHandler(net.minecraft.screen.GenericContainerScreenHandler) SimpleNamedScreenHandlerFactory(net.minecraft.screen.SimpleNamedScreenHandlerFactory) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) ScreenHandler(net.minecraft.screen.ScreenHandler) GenericContainerScreenHandler(net.minecraft.screen.GenericContainerScreenHandler) ItemStack(net.minecraft.item.ItemStack) EnderChestInventory(net.minecraft.inventory.EnderChestInventory) Inventory(net.minecraft.inventory.Inventory) SimpleInventory(net.minecraft.inventory.SimpleInventory) SimpleInventory(net.minecraft.inventory.SimpleInventory) LiteralText(net.minecraft.text.LiteralText)

Example 2 with GenericContainerScreenHandler

use of net.minecraft.screen.GenericContainerScreenHandler in project Client by MatHax.

the class EChestMemory method onOpenScreenEvent.

@EventHandler
private static void onOpenScreenEvent(OpenScreenEvent event) {
    if (echestOpenedState == 1 && event.screen instanceof GenericContainerScreen) {
        echestOpenedState = 2;
        return;
    }
    if (echestOpenedState == 0)
        return;
    if (!(mc.currentScreen instanceof GenericContainerScreen))
        return;
    GenericContainerScreenHandler container = ((GenericContainerScreen) mc.currentScreen).getScreenHandler();
    if (container == null)
        return;
    Inventory inv = container.getInventory();
    for (int i = 0; i < 27; i++) {
        ITEMS.set(i, inv.getStack(i));
    }
    echestOpenedState = 0;
}
Also used : GenericContainerScreen(net.minecraft.client.gui.screen.ingame.GenericContainerScreen) GenericContainerScreenHandler(net.minecraft.screen.GenericContainerScreenHandler) Inventory(net.minecraft.inventory.Inventory) EventHandler(mathax.client.eventbus.EventHandler)

Example 3 with GenericContainerScreenHandler

use of net.minecraft.screen.GenericContainerScreenHandler in project KiwiClient by TangyKiwi.

the class EChestMemory method onOpenScreenEvent.

@Subscribe
@AllowConcurrentEvents
private static void onOpenScreenEvent(OpenScreenEvent event) {
    if (echestOpenedState == 1 && event.getScreen() instanceof GenericContainerScreen) {
        echestOpenedState = 2;
        return;
    }
    if (echestOpenedState == 0)
        return;
    if (!(Utils.mc.currentScreen instanceof GenericContainerScreen))
        return;
    GenericContainerScreenHandler container = ((GenericContainerScreen) Utils.mc.currentScreen).getScreenHandler();
    if (container == null)
        return;
    Inventory inv = container.getInventory();
    for (int i = 0; i < 27; i++) {
        ITEMS.set(i, inv.getStack(i));
    }
    echestOpenedState = 0;
}
Also used : GenericContainerScreen(net.minecraft.client.gui.screen.ingame.GenericContainerScreen) GenericContainerScreenHandler(net.minecraft.screen.GenericContainerScreenHandler) Inventory(net.minecraft.inventory.Inventory) AllowConcurrentEvents(com.google.common.eventbus.AllowConcurrentEvents) Subscribe(com.google.common.eventbus.Subscribe)

Example 4 with GenericContainerScreenHandler

use of net.minecraft.screen.GenericContainerScreenHandler in project meteor-client by MeteorDevelopment.

the class EChestMemory method onOpenScreenEvent.

@EventHandler
private static void onOpenScreenEvent(OpenScreenEvent event) {
    if (echestOpenedState == 1 && event.screen instanceof GenericContainerScreen) {
        echestOpenedState = 2;
        return;
    }
    if (echestOpenedState == 0)
        return;
    if (!(mc.currentScreen instanceof GenericContainerScreen))
        return;
    GenericContainerScreenHandler container = ((GenericContainerScreen) mc.currentScreen).getScreenHandler();
    if (container == null)
        return;
    Inventory inv = container.getInventory();
    for (int i = 0; i < 27; i++) {
        ITEMS.set(i, inv.getStack(i));
    }
    echestOpenedState = 0;
}
Also used : GenericContainerScreen(net.minecraft.client.gui.screen.ingame.GenericContainerScreen) GenericContainerScreenHandler(net.minecraft.screen.GenericContainerScreenHandler) Inventory(net.minecraft.inventory.Inventory) EventHandler(meteordevelopment.orbit.EventHandler)

Example 5 with GenericContainerScreenHandler

use of net.minecraft.screen.GenericContainerScreenHandler in project EdenClient by HahaOO7.

the class ContainerInfo method onInventoryChange.

private void onInventoryChange(PlayerInventory playerInventory) {
    ScreenHandler sh = playerInventory.player.currentScreenHandler;
    if (!(sh instanceof ShulkerBoxScreenHandler) && !(sh instanceof GenericContainerScreenHandler)) {
        lastInteractedBlock = null;
        return;
    }
    List<ItemStack> items = sh.getStacks();
    items = items.subList(0, items.size() - 36);
    if (items.isEmpty())
        lastInteractedBlock = null;
    else
        onOpenInventory(items);
}
Also used : ShulkerBoxScreenHandler(net.minecraft.screen.ShulkerBoxScreenHandler) GenericContainerScreenHandler(net.minecraft.screen.GenericContainerScreenHandler) ScreenHandler(net.minecraft.screen.ScreenHandler) ShulkerBoxScreenHandler(net.minecraft.screen.ShulkerBoxScreenHandler) GenericContainerScreenHandler(net.minecraft.screen.GenericContainerScreenHandler) ItemStack(net.minecraft.item.ItemStack)

Aggregations

GenericContainerScreenHandler (net.minecraft.screen.GenericContainerScreenHandler)6 Inventory (net.minecraft.inventory.Inventory)4 GenericContainerScreen (net.minecraft.client.gui.screen.ingame.GenericContainerScreen)3 ScreenHandler (net.minecraft.screen.ScreenHandler)3 ItemStack (net.minecraft.item.ItemStack)2 AllowConcurrentEvents (com.google.common.eventbus.AllowConcurrentEvents)1 Subscribe (com.google.common.eventbus.Subscribe)1 Extensions (com.kahzerx.kahzerxmod.Extensions)1 ExtensionSettings (com.kahzerx.kahzerxmod.extensions.ExtensionSettings)1 GenericExtension (com.kahzerx.kahzerxmod.extensions.GenericExtension)1 CommandDispatcher (com.mojang.brigadier.CommandDispatcher)1 CommandSyntaxException (com.mojang.brigadier.exceptions.CommandSyntaxException)1 EventHandler (mathax.client.eventbus.EventHandler)1 EventHandler (meteordevelopment.orbit.EventHandler)1 HandledScreen (net.minecraft.client.gui.screen.ingame.HandledScreen)1 EnderChestInventory (net.minecraft.inventory.EnderChestInventory)1 SimpleInventory (net.minecraft.inventory.SimpleInventory)1 CloseHandledScreenC2SPacket (net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket)1 ScreenHandlerListener (net.minecraft.screen.ScreenHandlerListener)1 ShulkerBoxScreenHandler (net.minecraft.screen.ShulkerBoxScreenHandler)1