Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.15.2] How do I create a GUI?


TheTank18
 Share

Recommended Posts

Use onBlockActivated() to dectect when the user right-clicks a block

For example in the class which you put your block properties

Spoiler

    @Override
    public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand handIn, BlockRayTraceResult hit) {
		// Code
        return super.onBlockActivated(state, worldIn, pos, playerIn, handIn, hit);
    }

 

 

What GUI? What is it supposed to be, just a simple gui with buttons? Or a container example your inventory.

 

I'm also new, but I help when I know I can

 

 

Edited by Slastic
Link to comment
Share on other sites

3 minutes ago, jakethesnake123 said:

so where would you actually make it open the gui?

 

Override Block#onBlockActivated and open the GUI there.

If your GUI has a server-side container counter-part, use NetworkHooks::openGui on the server side (by checking if World#isRemote is false).

Edited by DavidM

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

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
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Problem with "structure gel", which is not using the forge config system correctly. Make sure the mod is up to date. If it already is, report this to the mod author (including my message above).
    • Time: 12/4/21, 11:45 AM Description: Initializing game java.lang.ExceptionInInitializerError: null     at net.minecraft.world.item.Item.handler$zch000$getDisplayName(Item.java:529) ~[client-1.17.1-20210706.113038-srg.jar%2379!:?] {re:mixin,re:classloading,pl:mixin:A}     at net.minecraft.world.item.Item.m_7626_(Item.java) ~[client-1.17.1-20210706.113038-srg.jar%2379!:?] {re:mixin,re:classloading,pl:mixin:A}     at net.minecraft.world.item.ItemStack.m_41786_(ItemStack.java:584) ~[client-1.17.1-20210706.113038-srg.jar%2379!:?] {re:mixin,xf:fml:forge:itemstack,re:classloading,xf:fml:forge:itemstack}     at net.minecraft.world.item.ItemStack.m_41651_(ItemStack.java:620) ~[client-1.17.1-20210706.113038-srg.jar%2379!:?] {re:mixin,xf:fml:forge:itemstack,re:classloading,xf:fml:forge:itemstack}     at net.minecraft.client.Minecraft.m_91316_(Minecraft.java:695) ~[client-1.17.1-20210706.113038-srg.jar%2379!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.searchtree.ReloadableSearchTree.m_8074_(SourceFile:36) ~[client-1.17.1-20210706.113038-srg.jar%2379!:?] {re:classloading}     at net.minecraft.client.searchtree.ReloadableIdSearchTree.m_8080_(SourceFile:48) ~[client-1.17.1-20210706.113038-srg.jar%2379!:?] {re:classloading}     at net.minecraft.client.Minecraft.lambda$createSearchTrees$10(Minecraft.java:713) ~[client-1.17.1-20210706.113038-srg.jar%2379!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?] {re:mixin}     at net.minecraft.client.Minecraft.m_91271_(Minecraft.java:712) ~[client-1.17.1-20210706.113038-srg.jar%2379!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft.<init>(Minecraft.java:506) ~[client-1.17.1-20210706.113038-srg.jar%2379!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.main.Main.main(Main.java:151) ~[client-1.17.1-20210706.113038-srg.jar%2379!:?] {re:classloading,pl:runtimedistcleaner:A}     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[?:?] {}     at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}     at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?] {}     at net.minecraftforge.fml.loading.targets.CommonClientLaunchHandler.lambda$launchService$0(CommonClientLaunchHandler.java:45) ~[fmlloader-1.17.1-37.0.112.jar%2322!:?] {}     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.Launcher.run(Launcher.java:106) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:90) [bootstraplauncher-0.1.17.jar:?] {} Caused by: java.lang.NullPointerException: Cannot invoke "net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext.getModEventBus()" because the return value of "net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext.get()" is null     at com.legacy.structure_gel.core.SGConfig$Common.<init>(SGConfig.java:49) ~[structure_gel-1.17.1-2.0.1.jar%2374!:2.0.1] {re:classloading}     at net.minecraftforge.common.ForgeConfigSpec$Builder.configure(ForgeConfigSpec.java:618) ~[forge-1.17.1-37.0.112-universal.jar%2383!:?] {re:classloading}     at com.legacy.structure_gel.core.SGConfig.<clinit>(SGConfig.java:25) ~[structure_gel-1.17.1-2.0.1.jar%2374!:2.0.1] {re:mixin,re:classloading}     ... 25 more A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Render thread Stacktrace:     at net.minecraft.world.item.Item.handler$zch000$getDisplayName(Item.java:529) ~[client-1.17.1-20210706.113038-srg.jar%2379!:?] {re:mixin,re:classloading,pl:mixin:A}     at net.minecraft.world.item.Item.m_7626_(Item.java) ~[client-1.17.1-20210706.113038-srg.jar%2379!:?] {re:mixin,re:classloading,pl:mixin:A}     at net.minecraft.world.item.ItemStack.m_41786_(ItemStack.java:584) ~[client-1.17.1-20210706.113038-srg.jar%2379!:?] {re:mixin,xf:fml:forge:itemstack,re:classloading,xf:fml:forge:itemstack}     at net.minecraft.world.item.ItemStack.m_41651_(ItemStack.java:620) ~[client-1.17.1-20210706.113038-srg.jar%2379!:?] {re:mixin,xf:fml:forge:itemstack,re:classloading,xf:fml:forge:itemstack}     at net.minecraft.client.Minecraft.m_91316_(Minecraft.java:695) ~[client-1.17.1-20210706.113038-srg.jar%2379!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.searchtree.ReloadableSearchTree.m_8074_(SourceFile:36) ~[client-1.17.1-20210706.113038-srg.jar%2379!:?] {re:classloading}     at net.minecraft.client.searchtree.ReloadableIdSearchTree.m_8080_(SourceFile:48) ~[client-1.17.1-20210706.113038-srg.jar%2379!:?] {re:classloading}     at net.minecraft.client.Minecraft.lambda$createSearchTrees$10(Minecraft.java:713) ~[client-1.17.1-20210706.113038-srg.jar%2379!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?] {re:mixin}     at net.minecraft.client.Minecraft.m_91271_(Minecraft.java:712) ~[client-1.17.1-20210706.113038-srg.jar%2379!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft.<init>(Minecraft.java:506) ~[client-1.17.1-20210706.113038-srg.jar%2379!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A} -- Initialization -- Details: Stacktrace:     at net.minecraft.client.main.Main.main(Main.java:151) ~[client-1.17.1-20210706.113038-srg.jar%2379!:?] {re:classloading,pl:runtimedistcleaner:A}     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[?:?] {}     at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}     at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?] {}     at net.minecraftforge.fml.loading.targets.CommonClientLaunchHandler.lambda$launchService$0(CommonClientLaunchHandler.java:45) ~[fmlloader-1.17.1-37.0.112.jar%2322!:?] {}     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.Launcher.run(Launcher.java:106) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:90) [bootstraplauncher-0.1.17.jar:?] {}
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.