Search in sources :

Example 6 with GenericContainerScreenHandler

use of net.minecraft.screen.GenericContainerScreenHandler in project BleachHack by BleachDrinker420.

the class AutoSteal method onOpenScreen.

@BleachSubscribe
public void onOpenScreen(EventOpenScreen event) {
    currentSyncId = -1;
    if (mc.player != null) {
        if (event.getScreen() instanceof HandledScreen) {
            ScreenHandler handler = ((HandledScreen<?>) event.getScreen()).getScreenHandler();
            if (handler instanceof GenericContainerScreenHandler) {
                currentSyncId = handler.syncId;
                lastOpen = currentTime;
                if (getSetting(0).asMode().getMode() >= 1) {
                    event.setCancelled(true);
                }
            } else {
                currentItems = null;
                mc.player.networkHandler.sendPacket(new CloseHandledScreenC2SPacket(currentSyncId));
            }
        } else {
            currentItems = null;
            mc.player.networkHandler.sendPacket(new CloseHandledScreenC2SPacket(currentSyncId));
        }
    }
}
Also used : HandledScreen(net.minecraft.client.gui.screen.ingame.HandledScreen) GenericContainerScreenHandler(net.minecraft.screen.GenericContainerScreenHandler) ScreenHandler(net.minecraft.screen.ScreenHandler) GenericContainerScreenHandler(net.minecraft.screen.GenericContainerScreenHandler) CloseHandledScreenC2SPacket(net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

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