Jump to content

Recommended Posts

Posted

You open the vanilla GUI, which checks to see if the player is using a vanilla workbench, and immediately closes the gui if they are not.

 

You need to open your custom GUI using a GuiHandler and player.openGui(...) which includes passing your mod ID.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Never mind. I put it in the workbench class.

 

    public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int par6, float par7, float par8, float par9)

    {

    entityplayer.openGui(Mod.Instance, par6, world, x, y, z);

 

    }

 

I don't know what to put in "mod.instance" and in "par6" though. Can you help me with that as well? :)

Posted

Your 'Main' class should have an 'instance' field, e.g.:

@Mod(modid = ModInfo.ID, name = ModInfo.NAME, version = ModInfo.VERSION)
public class Main
{
@Mod.Instance(ModInfo.ID)
public static Main instance;

It doesn't have to be named 'Main', it could be 'YourMod' or whatever, but it is your main class that contains all of the critical mod components.

 

As for 'par6', that is the ID of the GUI screen you wish to open. For my mods, I create a constant for each GUI that I can reference, e.g. MyGuiHandler.GUI_SCREEN_ONE might be 1, and GUI_SCREEN_TWO would be 2, etc. That way your IGuiHandler has some way to determine which Gui and Container to class to return.

Posted

I've tried so much and I have done everything you said but I still can't get it to work. It's giving some errors now. Here are my files now:

 

moriumWorkbench.java:

http://pastebin.com/1zb2Dkn7

 

GuiHandler.java:

http://pastebin.com/dA0gm4se

 

ContainerModTileEntity.java:

http://pastebin.com/DZ3fY7ab

 

ContainerMoriumWorkbench.java:

http://pastebin.com/y0p6pJYW

 

GuiCrafting.java:

http://pastebin.com/yAznNezz

 

The errors that are given:

GuiHandler.java:line 17 (BlockPos)

GuiHandler.java:line 26 (line 26 completely)

 

 

If you want to know anything else, let me know! I hope somebody can help me because I've been trying for a long time and I have no idea how to finally get my custom workbench!

 

Thanks

 

Posted

The errors that are given:

GuiHandler.java:line 17 (BlockPos)

GuiHandler.java:line 26 (line 26 completely)

 

You've gone all bonkers with the file.  The first problem is that BlockPos does not exist in 1.7.10, but you're trying to use it.

This is what the class should look like.

 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Thanks for helping but I really have no idea what to do to be honest.

 

This is what I changed my GuiHandler.java to:

package com.tristanvo.mod.gui;

 

import com.tristanvo.mod.blocks.moriumWorkbench;

 

import cpw.mods.fml.common.network.IGuiHandler;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.world.World;

 

public class GuiHandler implements IGuiHandler {

 

@Override

    public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {

if(id == 0) {

TileEntity tileEntity = world.getTileEntity(x, y, z);

if(tileEntity instanceof moriumWorkbench){

return new ContainerModTileEntity(player.inventory, (moriumWorkbench) tileEntity);

}

}

return null;

    }

 

    @Override

    public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {

    if(id == 0) {

TileEntity tileEntity = world.getTileEntity(x, y, z);

if(tileEntity instanceof moriumWorkbench){

return new GuiCrafting(player.inventory, (moriumWorkbench) tileEntity);

}

    }

return null;

    }

}

 

And this gives an error as well right now:

entityplayer.openGui(mod.instance, GuiHandler.???, world, x, y, z);

Posted

You removed the public static field

tile_entity_gui

. You still need that, or can replace it with a 0 (but doing so violates the advice given upthead, but to follow it you'd need to check

id == tile_entity_gui

instead of

id == 0

).

 

((Also, tile_entity_gui is a terrible name))

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

@Override

    public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {

if(id == 0) {

TileEntity tileEntity = world.getTileEntity(x, y, z);

if(tileEntity instanceof ContainerModTileEntity){

return new ContainerMoriumWorkbench(player.inventory, (ContainerModTileEntity) tileEntity);

}

}

return null;

    }

 

    @Override

    public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {

    if(id == 0) {

TileEntity tileEntity = world.getTileEntity(x, y, z);

if(tileEntity instanceof ContainerModTileEntity){

return new GuiCrafting(player.inventory, (ContainerModTileEntity) tileEntity);

}

    }

return null;

    }

}

 

I don't know what to put in "ContainerModTileEntity, ContainerMoriumWorkbench, GuiCrafting" because those all give an error while I do have these classes in my mod package!

Posted

You should be passing the TileEntity itself.

The reason this isn't working is because your block doesn't HAVE a tile entity and the Container/GuiContainer are expecting an object of type

moriumWorkbench

(which, by the way, you should capitalize and prepend with "Block",

BlockMoriumWorkbench

)

 

You don't have a TileEntity to pass, so the

TileEntity tileEntity = world.getTileEntity(x, y, z);

is going to return null anyway and fail the instanceof check.  If you want to do this with just the block, you're going to have some trouble.

 

In fact, I already see some problems in your other classes.  ContainerModTileEntity has this line:

 

        for(int y = 0; y < 3; ++y)
        {
            for(int x = 0; x < 3; ++x)
            {
                this.addSlotToContainer(new Slot(inventory, x + y * 9 + 9, 8 + x * 18, 84 + y * 18));
            }
        }

 

That's supposed to be adding a 3x3 grid for the crafting, but the inventory you told the slot that it is a part of is the player's inventory!

 

Then there's this:

 

    public boolean canInteractWith(EntityPlayer player) {
        return ((IInventory) this.te).isUseableByPlayer(player);
    }

 

te

in this context is a

moriumWorkbench

, which as established above is a Block which does not extend IInventory! This line will throw a null pointer exception when run, as will likely your

transferStackInSlot

method; I'm not entirely sure what'll happen.

 

Long story short, you've followed a tutorial for how to add a gui interface for a TileEntity and have even named your classes with "TileEntity" even though you do not have one.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Thanks, I already fixed the problems in all the classes except for the GuiHandler.java. How do I create a tile entity inside my block class then? I really still don't get it although I'm very thankful for you help!

Posted

implement ITileEntityProvider and override its methods.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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...

×   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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I need to know what mod is doing this crash, i mean the mod xenon is doing the crash but i want to know who mod is incompatible with xenon, but please i need to know a solution if i need to replace xenon, i cant use optifine anymore and all the other mods i tried(sodium, lithium, vulkan, etc) doesn't work, it crash the game.
    • I have been trying to solve a consistent crashing issue on my brother's computer where it will crash during the "Scanning Mod Candidates" phase of the loading process that starts when you click the play button on the Minecraft launcher. The issue seems to stem from a missing library that it mentions in the log file I provide below. I might I'm missing the bigger issue here for a smaller one but hopefully someone can find what I'm missing. Here's all of the stuff that I've been able to figure out so far: 1. It has nothing to do with mods, the crash happened with a real modpack, and even when I made a custom modpack and launched it without putting ANY mods into it (That is where the log file comes from by the way). 2. I have tried to find this class like a file in the Minecraft folders, but I've had no luck finding it (I don't think it works like that, but since I really don't understand how it works, I just figured I'd try). 3. I haven't seen anyone else have this issue before. 4. I know that my modpack (with mods) does work since I've run it on my computer, and it works fantastic. For some reason my brother's computer can't seem to run anything through curseforge. 5. This is for Minecraft version 1.20.1, Minecraft launcher version 3.4.50-2.1.3, forge 47.3.0, and curseforge app version 1.256.0.21056 6. My brother is using a Dell laptop from 6 years ago running Windows 10 (If you think more info on this would help, please ask as I do have it. I'm just choosing not to put it here for now). 7. I have reinstalled the curseforge app and installed Minecraft version 1.20.1. I have not reinstalled Minecraft or forge 47.3.0 but I didn't know if that would help. 8. I had an error code of 1 Please let me know if there is anything else that I am missing that you would like me to add to this post/add in a comment! Lastly, many thanks in advance to whoever can help! ------------- LOG FILE (latest.log) ------------- (from /Users/<NAME OF USER>/cursforge/minecraft/Instances/<THE NAME OF MY EMPTY MODPACK>/logs/latest.log) (This was made after running an empty modpack with same versions for all apps) ("[REDACTED]" is not the actual text from the log, it is me replacing text I figured wouldn't be necessary for fixing and would hurt my privacy) https://pastebin.com/hxXvGGEK ------------- DEBUG.LOG (I realized that I should have put this here first after I had done all of the work on putting latest.log in) -------------------- (again, "[REDACTED]" is not the actual text from the log, it is me replacing text I figured wouldn't be necessary for fixing and would hurt my privacy) https://pastebin.com/Fmh8GHYs
    • Pastebin... https://pastebin.com/Y3iZ85L5   Brand new profile, does not point to a mod as far as I can tell, my fatal message just has something about mixins. Don't know much about reading logs like this, but am genuinely stuck, please help. Java updated, pc restarted.
    • I was playing minecraft, forge 47.3.0 and 1.20.1, but when i tried to play minecraft now only crashes, i need help please. here is the crash report: https://securelogger.net/files/e6640a4f-9ed0-4acc-8d06-2e500c77aaaf.txt
  • Topics

×
×
  • Create New...

Important Information

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