ZidMC
Would you like to react to this message? Create an account in a few clicks or log in to continue.

[Unanswered] [1.5_01] Giving a block a GUI help?

5 posters

Go down

[Unanswered] [1.5_01] Giving a block a GUI help? Empty [Unanswered] [1.5_01] Giving a block a GUI help?

Post by ringingraptor Tue Apr 26, 2011 7:41 pm

So I'm trying to give a block the GUI of a dispenser. I really have no idea how to do it, but I whipped up some code real quick.
I can craft the block and everything, but when I try to open/right-click

mod_MagicBox
Code:
package net.minecraft.src;

public class mod_MagicBox extends BaseMod
{

   public static final Block MagicBox = new BlockMagicBox(200, 0).setHardness(1.5F).setResistance(1.0F).setBlockName("MagicBox");
   
   public mod_MagicBox()
   {
   ModLoader.RegisterBlock(MagicBox);
   
     ModLoader.AddName(MagicBox, "Magic Box");
    
     ModLoader.AddRecipe(new ItemStack(MagicBox, 1), new Object[] {
          "XXX", "XZX", "XXX", Character.valueOf('X'), Block.cobblestone, Character.valueOf('Z'), Item.redstone
  });
   }

BlockMagicBox
Code:
package net.minecraft.src;

public class BlockMagicBox extends Block
{

    protected BlockMagicBox(int i, int j)
    {
        super(i, j, Material.rock);
    }




public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer)
{
    if(world.multiplayerWorld)
    {
        return true;
    } else
    {
        TileEntityDispenser tileentitydispenser = (TileEntityDispenser)world.getBlockTileEntity(i, j, k);
        entityplayer.displayGUIDispenser(tileentitydispenser);
        return true;
    }
}}

EDIT: HERE'S THE ERROR MESSAGE FROM ECLIPSE
Code:
16 achievements
146 recipes
ModLoader Beta 1.5_01 Initializing...
Mod Loaded: net.minecraft.src.mod_MagicBox 1.4_01
Done.
WARNING: Found unknown Windows version: Windows 7
Attempting to use default windows plug-in.
Loading: net.java.games.input.DirectAndRawInputEnvironmentPlugin
Failed to initialize device 2.4GHz Cordless Desktop because of: java.io.IOException: Failed to acquire device (8007001e)

Starting up SoundSystem...
Initializing LWJGL OpenAL
    (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)
OpenAL initialized.

java.lang.NullPointerException
   at net.minecraft.src.ContainerDispenser.isUsableByPlayer(ContainerDispenser.java:40)
   at net.minecraft.src.EntityPlayer.onUpdate(EntityPlayer.java:66)
   at net.minecraft.src.World.updateEntityWithOptionalForce(World.java:1350)
   at net.minecraft.src.World.updateEntity(World.java:1326)
   at net.minecraft.src.World.func_633_c(World.java:1300)
   at net.minecraft.client.Minecraft.runTick(Minecraft.java:1125)
   at net.minecraft.client.Minecraft.run(Minecraft.java:451)
   at java.lang.Thread.run(Unknown Source)
Stopping!

SoundSystem shutting down...

The last part I copied and pasted from BlockDispenser.
I don't think is is correct at all, but help would be appreciated Smile


ringingraptor
Crafter

Posts : 22
Join date : 2011-04-23

Back to top Go down

[Unanswered] [1.5_01] Giving a block a GUI help? Empty Re: [Unanswered] [1.5_01] Giving a block a GUI help?

Post by Will.Ez Wed Apr 27, 2011 9:05 am

what happens when you open/right click?
I had a fast check through TileEntityDispenser.java and well, you know, it has many more functions, like taking a random item out of 9 item slots and read, write something to NBT something(which i dont understand) and those functions i think wont work if you dont have something particular(sorry i dont know either Razz)
Can any1 give a good solution and
btw, how to make your own GUI like the craft table which you can have the output slot and user-defined input slots
Will.Ez
Will.Ez
Iron Miner

Posts : 52
Join date : 2011-04-22
Age : 27

Back to top Go down

[Unanswered] [1.5_01] Giving a block a GUI help? Empty Re: [Unanswered] [1.5_01] Giving a block a GUI help?

Post by ringingraptor Wed Apr 27, 2011 3:57 pm

It only crashes when I right click on the block.

ringingraptor
Crafter

Posts : 22
Join date : 2011-04-23

Back to top Go down

[Unanswered] [1.5_01] Giving a block a GUI help? Empty Re: [Unanswered] [1.5_01] Giving a block a GUI help?

Post by Will.Ez Thu Apr 28, 2011 12:12 am

try this
Code:
package net.minecraft.src;

public class BlockMagicBox extends Block
{

    protected BlockMagicBox(int i, int j)
    {
        super(i, j, Material.rock);
    }




public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer)
{
    if(world.multiplayerWorld)
    {
        return true;
    } else
    {
        entityplayer.displayGUIDispenser(tileentitydispenser);
        return true;
    }
}}

I deleted this part
Code:
TileEntityDispenser tileentitydispenser = (TileEntityDispenser)world.getBlockTileEntity(i, j, k);
Will.Ez
Will.Ez
Iron Miner

Posts : 52
Join date : 2011-04-22
Age : 27

Back to top Go down

[Unanswered] [1.5_01] Giving a block a GUI help? Empty Re: [Unanswered] [1.5_01] Giving a block a GUI help?

Post by ringingraptor Thu Apr 28, 2011 4:12 pm

I get an error on

(tileentitydispenser);

ringingraptor
Crafter

Posts : 22
Join date : 2011-04-23

Back to top Go down

[Unanswered] [1.5_01] Giving a block a GUI help? Empty Re: [Unanswered] [1.5_01] Giving a block a GUI help?

Post by Yelik Thu Apr 28, 2011 4:12 pm

Maybe if you tried chest?

Yelik
ZidMC Coder
ZidMC Coder

Posts : 26
Join date : 2011-04-22

http://mrizen.com

Back to top Go down

[Unanswered] [1.5_01] Giving a block a GUI help? Empty Re: [Unanswered] [1.5_01] Giving a block a GUI help?

Post by Methuselah96 Thu Apr 28, 2011 4:40 pm

just so you know guis are complicated
Methuselah96
Methuselah96
ZidMC Coder
ZidMC Coder

Posts : 159
Join date : 2011-04-22
Age : 28
Location : Philadelphia, Pennsylvania, United States

Back to top Go down

[Unanswered] [1.5_01] Giving a block a GUI help? Empty Re: [Unanswered] [1.5_01] Giving a block a GUI help?

Post by Will.Ez Fri Apr 29, 2011 5:37 am

ah i tried to make new blocks show dispenser gui but they just dont work, still wonder why
Will.Ez
Will.Ez
Iron Miner

Posts : 52
Join date : 2011-04-22
Age : 27

Back to top Go down

[Unanswered] [1.5_01] Giving a block a GUI help? Empty Re: [Unanswered] [1.5_01] Giving a block a GUI help?

Post by Flafla2 Sun Aug 14, 2011 12:33 pm

Add this:
Code:
protected TileEntity getBlockEntity()
    {
        return new TileEntityFurnace();
    }

Flafla2
Recruit

Posts : 1
Join date : 2011-08-14

Back to top Go down

[Unanswered] [1.5_01] Giving a block a GUI help? Empty Re: [Unanswered] [1.5_01] Giving a block a GUI help?

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum