Java 类net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent 实例源码

项目:Factorization    文件:MiscClientProxy.java   
@SubscribeEvent
public void patchupTheStupidSecretButton(InitGuiEvent.Post event) {
    if (!(event.gui instanceof GuiOptions)) return;

    for (Object obj : event.buttonList) {
        if (obj instanceof GuiButton) {
            GuiButton button = (GuiButton) obj;
            if (button.id == 8675309) {
                button.displayString = "Shaders; press F4 to reset";
                button.xPosition = 0;
                button.yPosition = 0;
                return;
            }
        }
    }
}
项目:OverpoweredInventory    文件:EventHandler.java   
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onGuiPostInit(InitGuiEvent.Post event) {
  Gui gui = event.getGui();
  if (gui == null) { return; } // probably doesnt ever happen
  if (ModConfig.showGuiButton && gui instanceof net.minecraft.client.gui.inventory.GuiInventory) {
    // omg thanks so much to this guy
    // http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/mods-discussion/1390983-making-guis-scale-to-screen-width-height
    ScaledResolution res = new ScaledResolution(Minecraft.getMinecraft());
    int screenWidth = res.getScaledWidth();
    int screenHeight = res.getScaledHeight();
    int button_id = 256;
    int x, y;
    //align t top right
    x = screenWidth / 2 + Const.VWIDTH / 2 - GuiButtonOpenInventory.width - 1;
    y = screenHeight / 2 - Const.VHEIGHT / 2 - GuiButtonOpenInventory.height + 1;
    boolean hasPotions = Minecraft.getMinecraft().player.getActivePotionEffects().size() > 0;
    if (hasPotions) {
      x += 60;
    }
    //this is the tab button
    event.getButtonList().add(new GuiButtonOpenInventory(button_id++, x, y));
  }
}
项目:Skills    文件:GuiManager.java   
@SuppressWarnings("unchecked")
    @SideOnly(Side.CLIENT)
    @SubscribeEvent
    public void onGuiPostInit(InitGuiEvent.Post event)
    {
//      Blocks.enchanting_table.s
//      if(event.gui instanceof EnchantingInterruptor)
//      {
//          ((EnchantingInterruptor)event.gui).redoButtons = true;
//      } else if(event.gui instanceof GuiContainer)
//      {
//          GuiContainer gui = (GuiContainer)event.gui;
//          Container container = gui.inventorySlots;
//          
//          event.buttonList.add(new InvoScrollBar(256, 0, 0, 1, 1, "", container, gui));
//          
//          if(event.gui instanceof GuiInventory)
//          {
//              final ScaledResolution scaledresolution = new ScaledResolution(event.gui.mc, event.gui.mc.displayWidth, event.gui.mc.displayHeight);
//                int i = scaledresolution.getScaledWidth();
//                int j = scaledresolution.getScaledHeight();
//              event.buttonList.add(new GuiButtonUnlockSlot(event.buttonList.size(), i/2 - 50, j - 40, 100, 20, event.gui.mc.thePlayer));
//          }
//      }
    }
项目:blockbuster    文件:MainMenuHandler.java   
@SubscribeEvent
public void onGuiInit(InitGuiEvent event)
{
    if (event.getGui() instanceof GuiMainMenu)
    {
        event.getButtonList().add(this.openModelEditor);
    }
}
项目:In-Game-Account-Switcher    文件:ClientEvents.java   
@SubscribeEvent
public void guiEvent(InitGuiEvent.Post event){
    GuiScreen gui = event.getGui();
    if(gui instanceof GuiMainMenu){
        event.getButtonList().add(new GuiButtonWithImage(20, gui.width / 2 + 104, (gui.height / 4 + 48) + 72 + 12, 20, 20, ""));
    }
}
项目:ShadyMod    文件:ShadyMod.java   
@SuppressWarnings("unchecked")
@SubscribeEvent
public void onGuiInit(InitGuiEvent event)
{
    if(event.gui instanceof GuiOptions)
    {
        int x = event.gui.width / 2 + 5 + 150 + 5;
        int y = event.gui.height / 6 + 48 - 6;
        event.buttonList.add(new GuiIconButton(0x42, x, y, new ResourceLocation(MODID, "textures/gui/palette.png")));
    }
}
项目:Cyclic    文件:GuiTerrariaButtonsModule.java   
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onGuiPostInit(InitGuiEvent.Post event) {
  if (enableTerrariaButtons) {
    addButtonsToGui(event);
  }
}
项目:IngameAccountSwitcher    文件:ForgeEvents.java   
@SubscribeEvent
public void guiEvent(InitGuiEvent.Post event){
    GuiScreen gui = event.gui;
    if(gui instanceof GuiMainMenu){
        event.buttonList.add(new GuiButtonWithImage(20, gui.width / 2 + 104, (gui.height / 4 + 48) + 72 + 12, 20, 20, ""));
    }
}
项目:Cauldron    文件:GuiScreen.java   
public void setWorldAndResolution(Minecraft p_146280_1_, int p_146280_2_, int p_146280_3_)
{
    this.mc = p_146280_1_;
    this.fontRendererObj = p_146280_1_.fontRenderer;
    this.width = p_146280_2_;
    this.height = p_146280_3_;
    if (!MinecraftForge.EVENT_BUS.post(new InitGuiEvent.Pre(this, this.buttonList)))
    {
        this.buttonList.clear();
        this.initGui();
    }
    MinecraftForge.EVENT_BUS.post(new InitGuiEvent.Post(this, this.buttonList));
}
项目:Cauldron    文件:GuiScreen.java   
public void setWorldAndResolution(Minecraft p_146280_1_, int p_146280_2_, int p_146280_3_)
{
    this.mc = p_146280_1_;
    this.fontRendererObj = p_146280_1_.fontRenderer;
    this.width = p_146280_2_;
    this.height = p_146280_3_;
    if (!MinecraftForge.EVENT_BUS.post(new InitGuiEvent.Pre(this, this.buttonList)))
    {
        this.buttonList.clear();
        this.initGui();
    }
    MinecraftForge.EVENT_BUS.post(new InitGuiEvent.Post(this, this.buttonList));
}
项目:betterAnvil-forge    文件:EventHandlerBA.java   
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void addButtons(InitGuiEvent.Post e) {
    if (e.gui instanceof GuiRepair) {
        final List<GuiButton> list = new ArrayList<GuiButton>();
        //TODO Add buttons.



        e.buttonList.addAll(list);
    }
}
项目:ServerObserver    文件:Compat.java   
@Override
public List<GuiButton> getButtonList(final InitGuiEvent e) {
    return e.getButtonList();
}
项目:ServerObserver    文件:CoreHandler.java   
@SubscribeEvent
public void open(final InitGuiEvent.Post e) {
    this.guiHandler.open(e);
}
项目:ServerObserver    文件:Compat.java   
@Override
public List<GuiButton> getButtonList(final InitGuiEvent e) {
    return e.getButtonList();
}
项目:ServerObserver    文件:CoreHandler.java   
@SubscribeEvent
public void open(final InitGuiEvent.Post e) {
    this.guiHandler.open(e);
}
项目:ServerObserver    文件:Compat.java   
@Override
public List<GuiButton> getButtonList(final InitGuiEvent e) {
    return e.getButtonList();
}
项目:ServerObserver    文件:CoreHandler.java   
@SubscribeEvent
public void open(final InitGuiEvent.Post e) {
    this.guiHandler.open(e);
}
项目:ServerObserver    文件:Compat.java   
@Override
public List<GuiButton> getButtonList(final InitGuiEvent e) {
    return e.buttonList;
}
项目:ServerObserver    文件:CoreHandler.java   
@SubscribeEvent
public void open(final InitGuiEvent.Post e) {
    this.guiHandler.open(e);
}
项目:ServerObserver    文件:Compat.java   
@Override
public List<GuiButton> getButtonList(final InitGuiEvent e) {
    return e.getButtonList();
}
项目:ServerObserver    文件:CoreHandler.java   
@SubscribeEvent
public void open(final InitGuiEvent.Post e) {
    this.guiHandler.open(e);
}
项目:ServerObserver    文件:Compat.java   
@Override
@SuppressWarnings("unchecked")
public List<GuiButton> getButtonList(final InitGuiEvent e) {
    return e.buttonList;
}
项目:ServerObserver    文件:CoreHandler.java   
@SubscribeEvent
public void open(final InitGuiEvent.Post e) {
    this.guiHandler.open(e);
}
项目:VisibleArmorSlots    文件:EventDelegatorGuiOverlay.java   
/**
 * Called when the GUI is displayed and when the window resizes.
 */
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onInitGuiEvent(InitGuiEvent.Post event)
{
    // Only process if the world is loaded
    if (Minecraft.getMinecraft().world == null) { return; }
    final GuiScreen gui = event.getGui();

    // NOTE: even if the gui overlay is not visible, it still get the basic config to avoid crashes and leaks
    if (gui != null) {
        /*
        LogHelper.trace("EventDelegatorGuiOverlay.onInitGuiEvent.Post() - %s", gui);
        LogHelper.trace("    is GuiContainer: %s, is GuiInventory: %s", (gui instanceof GuiContainer), (gui instanceof GuiInventory));
        if (gui instanceof GuiContainer) {
            LogHelper.trace("    guiLeft: %d, guiTop: %d, xSize: %d, ySize: %d, inventory: %s", ((GuiContainer) gui).getGuiLeft(), ((GuiContainer) gui).getGuiTop(),
                    ((GuiContainer) gui).getXSize(), ((GuiContainer) gui).getYSize(), ((GuiContainer) gui).inventorySlots);
            if (((GuiContainer) gui).inventorySlots != null) {
                LogHelper.trace("    inventory size: %s", ((GuiContainer) gui).inventorySlots.inventorySlots.size());
            }
        }
        */

        this.getGuiOverlay().setWorldAndResolution(gui.width, gui.height);
        this.getGuiOverlay().setExternalGuiPosition(gui);
    }
    if (!this.shouldDisplayGuiOverlay(gui)) { return; }


    final InfoGuiOverlayDisplayParams displayParams = getDisplayParamsForGui(gui);

    this.getGuiOverlay().guiLeft = displayParams.getGuiLeft();
    this.getGuiOverlay().guiTop = displayParams.getGuiTop();
    this.getGuiOverlay().refreshExtraSlotsInfo(gui.mc.player.inventory);

    // Reposition the overlay if the potion effects are taking space
    if (this.getGuiOverlay().isPotionShiftActive()) {
        if (ModConfig.extraSlotsSide().equals(ModConfig.POSITION_LEFT)) {
            this.getGuiOverlay().guiLeft += ModConfig.POTION_SHIFT_MARGIN_LEFT;
        } else if (ModConfig.extraSlotsSide().equals(ModConfig.POSITION_RIGHT)) {
            this.getGuiOverlay().guiLeft += ModConfig.POTION_SHIFT_MARGIN_RIGHT;
        }

        // Resets the state since the overlay class is shared among all containers.
        this.getGuiOverlay().setPotionShiftState(false);
    }
}
项目:Factorization    文件:MiscClientProxy.java   
@SubscribeEvent
public void customSplash(InitGuiEvent.Pre event) {
    if (!(event.gui instanceof GuiMainMenu)) return;
    int hash = event.gui.hashCode();
    if (hash == last_hash) return;
    last_hash = hash;
    GuiMainMenu menu = (GuiMainMenu) event.gui;
    ReservoirSampler<String> sampler = new ReservoirSampler<String>(1, new Random());
    sampler.give(menu.splashText);
    sampler.preGive(359); // NORELEASE: Verify this number each MC version, including minor versions. (Or we could just count it. Hmm.)
    // Err, should that be <number of lines> - 1? Or maybe even -2 for the hashCode thing?
    sampler.give(""); // !!!! The secret EMPTY splash text! :O
    HashSet<String> alreadySeen = new HashSet<String>();
    int dupes = 0;
    try {
        @SuppressWarnings("unchecked")
        List<IResource> resources = mc.getResourceManager().getAllResources(new ResourceLocation("minecraft:texts/extra_splashes.txt"));
        for (IResource res : resources) {
            InputStream is = null;
            try {
                is = res.getInputStream();
                if (is == null) continue;
                BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(is, Charsets.UTF_8));
                String s;

                while ((s = bufferedreader.readLine()) != null) {
                    s = s.trim();
                    if (s.isEmpty()) continue;
                    if (s.hashCode() == 125780783) continue; // Probably "This message will never appear on the splash screen, isn't that weird?".hashCode()
                    if (s.startsWith("#")) continue;
                    if (!alreadySeen.add(s)) {
                        dupes++;
                        continue;
                    }
                    sampler.give(s);
                }
            } finally {
                FzUtil.closeNoisily("Closing " + res, is);
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    if (dupes > 0) {
        Core.logWarning("Extra splashes had duplicated lines: " + dupes);
    }
    if (sampler.size() < 1) return;
    menu.splashText = sampler.getSamples().get(0);
}
项目:Cyclic    文件:GuiTerrariaButtonsModule.java   
@SideOnly(Side.CLIENT)
public void addButtonsToGui(InitGuiEvent.Post event) {
  GuiScreen gui = event.getGui();
  if (gui == null) {
    return;
  } // probably doesn't ever happen
  // all containers by default but with a blacklist in config
  if (gui instanceof GuiContainer &&
      !(gui instanceof GuiInventory) &&
      !(gui instanceof GuiPlayerExtended) &&
      !(gui instanceof GuiPlayerExtWorkbench)) {
    String self = gui.getClass().getName();
    // &&  blacklistGuis.contains(self) ==
    boolean isInBlacklist = false;
    for (String s : blacklistGuis) {
      if (s.equalsIgnoreCase(self)) {
        isInBlacklist = true;
        break;
      }
    }
    if (isInBlacklist) {
      return;
    }
    //" =>NOT in blacklist, ADD THE BUTTONS NOW :: "+position);
    int button_id = 256;
    // config for different locations - left right bottom top
    int x = 0, y = 0, yDelta = 24, xDelta = 0;
    // not GuiContainerCreative
    GuiContainer guiInv = (GuiContainer) gui;
    // align to different area depending on config
    if (position.equalsIgnoreCase(posLeft)) {
      x = padding;
      y = padding;
      // we are moving top to bottom, so
      xDelta = 0;
      yDelta = Const.btnHeight + padding;
    }
    else if (position.equalsIgnoreCase(posRight)) {
      x = Minecraft.getMinecraft().displayWidth / 2 - BTNWIDTH - padding;
      y = padding;
      // we are moving top to bottom, so
      xDelta = 0;
      yDelta = Const.btnHeight + padding;
    }
    else if (position.equalsIgnoreCase(posBottom)) {
      // test bottom
      x = padding;
      y = Minecraft.getMinecraft().displayHeight / 2 - padding - Const.btnHeight;
      xDelta = BTNWIDTH + padding;
      yDelta = 0;
    }
    else if (position.equalsIgnoreCase(posAlign) || true) {
      //                x = gui.height;
      //                y = gui.width;
      int guiLeft = ReflectionHelper.getPrivateValue(GuiContainer.class, guiInv, "i", "field_147003_i", "guiLeft");
      int guiTop = ReflectionHelper.getPrivateValue(GuiContainer.class, guiInv, "r", "field_147009_r", "guiTop");
      x = guiLeft;
      y = guiTop;
      // we are moving top to bottom, so
      xDelta = 0;
      yDelta = Const.btnHeight + padding;
    }
    event.getButtonList().add(new ButtonTerrariaLootAll(button_id++, x, y));
    x += xDelta;
    y += yDelta;
    event.getButtonList().add(new ButtonTerrariaDepositAll(button_id++, x, y));
    x += xDelta;
    y += yDelta;
    event.getButtonList().add(new ButtonTerrariaQuickStack(button_id++, x, y));
    x += xDelta;
    y += yDelta;
    event.getButtonList().add(new ButtonTerrariaRestock(button_id++, x, y));
  }
}
项目:IngameAccountSwitcher    文件:ForgeEvents.java   
@SubscribeEvent
public void preGui(InitGuiEvent.Pre event){
    if(event.gui instanceof GuiMainMenu){
        Config.save();
    }
}
项目:ServerObserver    文件:ICompat.java   
List<GuiButton> getButtonList(InitGuiEvent e);