Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[1.7.10] open my custom hud/gui after clicking my custom block[SOLVED]

Featured Replies

Posted

I got this code in my custom block's class file:

 

package com.tominocz.PAYDAY2;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.audio.SoundHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;

public class LobbyBlock extends Block{

SoundHandler sh;

public LobbyBlock(Material rock) {
	super(rock);
	this.setBlockName("LobbyBlock");
	this.setBlockTextureName(Main.MODID + ":" + "0");
	this.setCreativeTab(Main.PAYDAY2Tab);
	this.setLightLevel(1F);
	this.setLightOpacity(2555);
}

@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
    {
     if (world.isRemote)
        {
            return true;
        }
        else
        {
            //HERE I WANT THE CODE FOR OPENING MY CUSTOM GUI/HUD
    	    System.out.println("clicked");
            return false;
        }
    }
}

 

And I got this in the main class:

 

package com.tominocz.PAYDAY2;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;

@Mod(modid = Main.MODID, version = Main.VERSION)
public class Main
{

    public static final String MODID = "PAYDAY2";
    public static final String NAME = "PAYDAY 2 RELOADED";
    public static final String VERSION = "0.01";
    
    public static CreativeTabs PAYDAY2Tab = new PAYDAY2Tab(MODID);
    public static Block LobbyBlock = new LobbyBlock(Material.rock);
    public static Item Logo = new PAYDAY2Logo();
    
    @EventHandler
    public void preInit(FMLPreInitializationEvent event)
    {
    	GameRegistry.registerBlock(LobbyBlock, "LobbyBlock");
    	GameRegistry.registerItem(Logo, "Logo");
    }
    
    @EventHandler
    public void Init(FMLInitializationEvent event)
    {

    }
    
    @EventHandler
    public void postInit(FMLPostInitializationEvent event)
    {

    }
}

 

Now I need the code to open my custom gui/hud like when opening a chest or a crafting table..

but I also want to add buttons in there..

 

Is it possible? :/

  • Author

Ok, thanks for information. I just hope I can make it :/. Because the block is the main thing.. without it.. you can't do anything in the mod :D.

  • Author

Well, I haven't found any tutorial about GUI so far. Everything was a different video...

If you know, where I could find one, tell me please.

  • Author

It works! Now it opens a gui with a text! But now there's an only problem.. it's not compatible with a server.. Do you know how to do that please? :D

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.