[Unanswered] [1.5_01] Giving a block a GUI help?
5 posters
Page 1 of 1
[Unanswered] [1.5_01] Giving a block a GUI help?
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
BlockMagicBox
EDIT: HERE'S THE ERROR MESSAGE FROM ECLIPSE
The last part I copied and pasted from BlockDispenser.
I don't think is is correct at all, but help would be appreciated
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
ringingraptor- Crafter
- Posts : 22
Join date : 2011-04-23
Re: [Unanswered] [1.5_01] Giving a block a GUI help?
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 )
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
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 )
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- Iron Miner
- Posts : 52
Join date : 2011-04-22
Age : 27
Re: [Unanswered] [1.5_01] Giving a block a GUI help?
It only crashes when I right click on the block.
ringingraptor- Crafter
- Posts : 22
Join date : 2011-04-23
Re: [Unanswered] [1.5_01] Giving a block a GUI help?
try this
I deleted this part
- 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- Iron Miner
- Posts : 52
Join date : 2011-04-22
Age : 27
Re: [Unanswered] [1.5_01] Giving a block a GUI help?
I get an error on
(tileentitydispenser);
(tileentitydispenser);
ringingraptor- Crafter
- Posts : 22
Join date : 2011-04-23
Re: [Unanswered] [1.5_01] Giving a block a GUI help?
just so you know guis are complicated
Methuselah96- ZidMC Coder
- Posts : 159
Join date : 2011-04-22
Age : 28
Location : Philadelphia, Pennsylvania, United States
Re: [Unanswered] [1.5_01] Giving a block a GUI help?
ah i tried to make new blocks show dispenser gui but they just dont work, still wonder why
Will.Ez- Iron Miner
- Posts : 52
Join date : 2011-04-22
Age : 27
Re: [Unanswered] [1.5_01] Giving a block a GUI help?
Add this:
- Code:
protected TileEntity getBlockEntity()
{
return new TileEntityFurnace();
}
Flafla2- Recruit
- Posts : 1
Join date : 2011-08-14
Similar topics
» [Unanswered?] changing icon of a block? [1.5_01] [2.11]
» [Unanswered] Block wont show up ingame [1.5_01]
» [UNANSWERED] Torch-Like Block Doesn't Render Right While Held
» [Unanswered]Change block state depend on neighbor blocks
» [Unanswered] Emeralds basic question(s): Block idDrop issue and tool use lockup.
» [Unanswered] Block wont show up ingame [1.5_01]
» [UNANSWERED] Torch-Like Block Doesn't Render Right While Held
» [Unanswered]Change block state depend on neighbor blocks
» [Unanswered] Emeralds basic question(s): Block idDrop issue and tool use lockup.
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|