Jump to content

Recommended Posts

Posted

I Keep getting an error on my block

when it is activated

 

MainClass:

 

package com.CraigTheMailman.MinecraftExpansion;

 

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.creativetab.CreativeTabs;

 

import com.CraigTheMailman.MinecraftExpansion.blocks.WorkSurface;

import com.CraigTheMailman.MinecraftExpansion.lib.ProxyCommon;

import com.CraigTheMailman.MinecraftExpansion.lib.Refrences;

import com.CraigTheMailman.MinecraftExpansion.tab.tabK;

 

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.Mod.EventHandler;

import cpw.mods.fml.common.Mod.Instance;

import cpw.mods.fml.common.SidedProxy;

import cpw.mods.fml.common.event.FMLInitializationEvent;

import cpw.mods.fml.common.registry.GameRegistry;

import cpw.mods.fml.common.registry.LanguageRegistry;

 

@Mod(modid = Refrences.modid, version = Refrences.version)

public class MinecraftExpansion {

 

@SidedProxy(clientSide = Refrences.Client,

serverSide = Refrences.Common)

public static ProxyCommon proxy;

 

@Instance

public static MinecraftExpansion instance;

 

//Blocks

public static Block blockWorkSurface;

public static final int guiIDCustom1 = 1;

 

public static CreativeTabs tabK = new tabK(CreativeTabs.getNextID(), "tabK");

 

@EventHandler

public void init(FMLInitializationEvent event)

{

blockWorkSurface = new WorkSurface(Material.wood);

 

GameRegistry.registerBlock(blockWorkSurface, "CM1");

 

LanguageRegistry.addName(blockWorkSurface, "Metalwork Cooler");

}

 

@EventHandler

public void load(FMLInitializationEvent event)

{

proxy.registerRenderInformation();

}

 

}

 

 

 

Block Class:

 

package com.CraigTheMailman.MinecraftExpansion.blocks;

 

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.client.renderer.texture.IIconRegister;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.util.IIcon;

import net.minecraft.world.World;

import com.CraigTheMailman.MinecraftExpansion.MinecraftExpansion;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

public class WorkSurface extends Block {

 

@SideOnly(Side.CLIENT)

private IIcon workSurfaceTop;

 

public WorkSurface(Material wood) {

super(Material.wood);

 

this.setHardness(3.5F);

this.setResistance(5.0F);

this.setCreativeTab(MinecraftExpansion.tabK);

}

 

@SideOnly(Side.CLIENT)

public IIcon getIcon (int side, int metadata) {

return side == 1 ? this.workSurfaceTop : this.blockIcon;

}

 

@SideOnly(Side.CLIENT)

public void registerBlockIcons (IIconRegister iconRegister) {

this.blockIcon = iconRegister.registerIcon("MCExpansion:CustomMech1_Side");

this.workSurfaceTop = iconRegister.registerIcon("MCExpansion:CustomMech1_Top");

}

 

public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {

 

if (!player.isSneaking()) {

player.openGui(MinecraftExpansion.instance, MinecraftExpansion.guiIDCustom1, world, x, y, z);

return true;

}else{

return false;

}

}

 

 

}

 

 

And, of course last, but not least!

CRASH REPORT:

 

---- Minecraft Crash Report ----

// Uh... Did I do that?

 

Time: 5/23/14 1:28 AM

Description: Unexpected error

 

java.lang.NullPointerException: Unexpected error

at cpw.mods.fml.common.network.NetworkRegistry.getLocalGuiContainer(NetworkRegistry.java:263)

at cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:93)

at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2208)

at com.CraigTheMailman.MinecraftExpansion.blocks.WorkSurface.onBlockActivated(WorkSurface.java:40)

at net.minecraft.client.multiplayer.PlayerControllerMP.onPlayerRightClick(PlayerControllerMP.java:326)

at net.minecraft.client.Minecraft.func_147121_ag(Minecraft.java:1399)

at net.minecraft.client.Minecraft.runTick(Minecraft.java:1903)

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:916)

at net.minecraft.client.Minecraft.run(Minecraft.java:835)

at net.minecraft.client.main.Main.main(SourceFile:103)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

 

 

A detailed walkthrough of the error, its code path and all known details is as follows:

---------------------------------------------------------------------------------------

 

-- Head --

Stacktrace:

at cpw.mods.fml.common.network.NetworkRegistry.getLocalGuiContainer(NetworkRegistry.java:263)

at cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:93)

at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2208)

at com.CraigTheMailman.MinecraftExpansion.blocks.WorkSurface.onBlockActivated(WorkSurface.java:40)

at net.minecraft.client.multiplayer.PlayerControllerMP.onPlayerRightClick(PlayerControllerMP.java:326)

at net.minecraft.client.Minecraft.func_147121_ag(Minecraft.java:1399)

 

-- Affected level --

Details:

Level name: MpServer

All players: 1 total; [EntityClientPlayerMP['Player706'/65, l='MpServer', x=20.74, y=5.62, z=2568.08]]

Chunk stats: MultiplayerChunkCache: 225, 225

Level seed: 0

Level generator: ID 01 - flat, ver 0. Features enabled: false

Level generator options:

Level spawn location: World: (26,4,2562), Chunk: (at 10,0,2 in 1,160; contains blocks 16,0,2560 to 31,255,2575), Region: (0,5; contains chunks 0,160 to 31,191, blocks 0,0,2560 to 511,255,3071)

Level time: 717 game time, 717 day time

Level dimension: 0

Level storage version: 0x00000 - Unknown?

Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)

Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false

Forced entities: 50 total; [EntitySlime['Slime'/3, l='MpServer', x=-59.63, y=4.00, z=2547.47], EntitySlime['Slime'/4, l='MpServer', x=-50.63, y=4.99, z=2569.21], EntitySlime['Slime'/5, l='MpServer', x=-60.04, y=4.00, z=2571.21], EntitySlime['Slime'/6, l='MpServer', x=-51.66, y=4.00, z=2566.03], EntitySlime['Slime'/7, l='MpServer', x=-53.28, y=5.06, z=2588.62], EntitySlime['Slime'/11785, l='MpServer', x=-28.80, y=4.00, z=2576.20], EntitySlime['Slime'/11, l='MpServer', x=-39.16, y=4.00, z=2507.31], EntitySlime['Slime'/12, l='MpServer', x=-35.56, y=4.00, z=2545.88], EntitySlime['Slime'/15, l='MpServer', x=-23.11, y=4.39, z=2492.87], EntitySlime['Slime'/17, l='MpServer', x=-27.76, y=5.06, z=2611.14], EntitySlime['Slime'/18, l='MpServer', x=-9.75, y=4.00, z=2525.00], EntitySlime['Slime'/19, l='MpServer', x=12.03, y=4.00, z=2580.94], EntitySlime['Slime'/20, l='MpServer', x=3.36, y=4.00, z=2603.38], EntitySlime['Slime'/21, l='MpServer', x=16.06, y=4.00, z=2619.09], EntitySlime['Slime'/23, l='MpServer', x=13.55, y=4.33, z=2641.81], EntityVillager['Villager'/24, l='MpServer', x=46.22, y=6.00, z=2615.50], EntityVillager['Villager'/25, l='MpServer', x=37.59, y=5.00, z=2637.88], EntityVillager['Villager'/26, l='MpServer', x=38.69, y=5.00, z=2637.44], EntitySlime['Slime'/27, l='MpServer', x=46.22, y=4.00, z=2649.02], EntitySlime['Slime'/29, l='MpServer', x=47.28, y=4.99, z=2556.92], EntityVillager['Villager'/30, l='MpServer', x=57.66, y=4.00, z=2599.69], EntityVillager['Villager'/31, l='MpServer', x=50.84, y=4.00, z=2613.50], EntityVillager['Villager'/32, l='MpServer', x=51.78, y=4.00, z=2616.88], EntityVillager['Villager'/33, l='MpServer', x=62.38, y=5.00, z=2631.63], EntityVillager['Villager'/34, l='MpServer', x=62.28, y=5.00, z=2633.50], EntityVillager['Villager'/35, l='MpServer', x=50.16, y=4.00, z=2626.59], EntitySlime['Slime'/36, l='MpServer', x=56.44, y=4.00, z=2645.38], EntitySlime['Slime'/38, l='MpServer', x=73.82, y=4.33, z=2492.37], EntityVillager['Villager'/39, l='MpServer', x=71.50, y=6.00, z=2596.22], EntityClientPlayerMP['Player706'/65, l='MpServer', x=20.74, y=5.62, z=2568.08], EntityVillager['Villager'/40, l='MpServer', x=70.84, y=4.00, z=2600.41], EntitySlime['Slime'/41, l='MpServer', x=76.31, y=4.00, z=2596.34], EntityVillager['Villager'/42, l='MpServer', x=76.75, y=5.00, z=2613.56], EntityVillager['Villager'/43, l='MpServer', x=77.50, y=5.00, z=2608.50], EntityVillager['Villager'/44, l='MpServer', x=79.50, y=5.00, z=2616.50], EntityVillager['Villager'/45, l='MpServer', x=66.49, y=5.00, z=2616.21], EntityVillager['Villager'/46, l='MpServer', x=73.78, y=4.00, z=2612.34], EntityVillager['Villager'/47, l='MpServer', x=71.88, y=4.00, z=2616.38], EntityVillager['Villager'/48, l='MpServer', x=77.41, y=4.00, z=2632.66], EntityVillager['Villager'/49, l='MpServer', x=74.56, y=4.00, z=2631.66], EntityVillager['Villager'/50, l='MpServer', x=64.63, y=4.00, z=2628.59], EntitySlime['Slime'/53, l='MpServer', x=91.54, y=4.57, z=2512.29], EntityVillager['Villager'/54, l='MpServer', x=80.50, y=5.00, z=2616.50], EntitySlime['Slime'/2615, l='MpServer', x=72.17, y=4.62, z=2528.23], EntityVillager['Villager'/55, l='MpServer', x=84.72, y=4.00, z=2613.22], EntitySkeleton['Skeleton'/56, l='MpServer', x=86.50, y=9.00, z=2610.50], EntityVillager['Villager'/57, l='MpServer', x=82.63, y=4.00, z=2625.44], EntityVillager['Villager'/58, l='MpServer', x=80.75, y=4.00, z=2627.44], EntitySlime['Slime'/59, l='MpServer', x=96.33, y=4.39, z=2513.28], EntitySlime['Slime'/5204, l='MpServer', x=90.18, y=4.00, z=2579.04]]

Retry entities: 0 total; []

Server brand: fml,forge

Server type: Integrated singleplayer server

Stacktrace:

at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:368)

at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2382)

at net.minecraft.client.Minecraft.run(Minecraft.java:864)

at net.minecraft.client.main.Main.main(SourceFile:103)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

 

-- System Details --

Details:

Minecraft Version: 1.7.2

Operating System: Windows Vista (amd64) version 6.0

Java Version: 1.8.0_05, Oracle Corporation

Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation

Memory: 922878464 bytes (880 MB) / 1056309248 bytes (1007 MB) up to 1056309248 bytes (1007 MB)

JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M

AABB Pool Size: 20006 (1120336 bytes; 1 MB) allocated, 2 (112 bytes; 0 MB) used

IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0

FML: MCP v9.03 FML v7.2.196.1085 Minecraft Forge 10.12.1.1085 4 mods loaded, 4 mods active

mcp{9.03} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

FML{7.2.196.1085} [Forge Mod Loader] (forgeBin-1.7.2-10.12.1.1085.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

Forge{10.12.1.1085} [Minecraft Forge] (forgeBin-1.7.2-10.12.1.1085.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

Minecraft Expansion{1.0} [Minecraft Expansion] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

Launched Version: 1.6

LWJGL: 2.9.0

OpenGL: Mobile Intel® 4 Series Express Chipset Family GL version 2.1.0 - Build 8.15.10.2302, Intel

Is Modded: Definitely; Client brand changed to 'fml,forge'

Type: Client (map_client.txt)

Resource Packs: []

Current Language: English (US)

Profiler Position: N/A (disabled)

Vec3 Pool Size: 1228 (68768 bytes; 0 MB) allocated, 21 (1176 bytes; 0 MB) used

Anisotropic Filtering: Off (1)

 

Posted

Try this:

 

package com.CraigTheMailman.MinecraftExpansion.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import com.CraigTheMailman.MinecraftExpansion.MinecraftExpansion;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class WorkSurface extends Block {

   @SideOnly(Side.CLIENT)
   private IIcon workSurfaceTop;

   public WorkSurface(Material wood) {
      super(Material.wood);

      this.setHardness(3.5F);
      this.setResistance(5.0F);
      this.setCreativeTab(MinecraftExpansion.tabK);
   }

   @SideOnly(Side.CLIENT)
   public IIcon getIcon (int side, int metadata) {
      return side == 1 ? this.workSurfaceTop : this.blockIcon;
   }

   @SideOnly(Side.CLIENT)
   public void registerBlockIcons (IIconRegister iconRegister) {
      this.blockIcon = iconRegister.registerIcon("MCExpansion:CustomMech1_Side");
      this.workSurfaceTop = iconRegister.registerIcon("MCExpansion:CustomMech1_Top");
   }

   public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {

      if(!player.isSneaking() && !world.isRemote) {
         FMLNetworkHandler.openGui(player, MinecraftExpansion.instance, MinecraftExpansion.guiIDCustom1, world, x, y, z);
      }
      return true;
   }


}

Posted

@diesieben07:

 

GUI HANDLER:

 

package com.CraigTheMailman.MinecraftExpansion.gui;

 

import org.lwjgl.opengl.GL11;

 

import net.minecraft.client.Minecraft;

import net.minecraft.client.gui.inventory.GuiContainer;

import net.minecraft.entity.player.InventoryPlayer;

import net.minecraft.util.ResourceLocation;

import net.minecraft.util.StatCollector;

import net.minecraft.world.World;

 

public class GuiWorkSurface extends GuiContainer {

 

private ResourceLocation texture = new ResourceLocation("mcexpansion:textures/gui/WorkSurface.png");

 

public GuiWorkSurface(InventoryPlayer invPlayer, World world, int x, int y, int z) {

super(new com.CraigTheMailman.MinecraftExpansion.container.ContainerWorkSurface(invPlayer, world, x, y, z));

 

this.xSize = 176;

this.ySize = 188;

 

}

 

 

public void onGuiClosed() {

super.onGuiClosed();

}

 

protected void drawGuiContainerForegroundLayer(int i, int j) {

 

this.fontRendererObj.drawString(StatCollector.translateToLocal("Work Surface"), 100, 5, 0xFFFFFF);

 

}

 

@Override

protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) {

 

GL11.glColor4f(1F, 1F, 1F, 1F);

 

Minecraft.getMinecraft().getTextureManager().bindTexture(texture);

 

drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);

 

}

 

}

 

 

 

Sorry, kinda knew i forgot something...

Posted

A gui handler is a class implementing IGuiHandler. If you implement it correctly, you need to add two methods. Add those. In that method, check if the ID is the same as the ID specified in, in your case MinecraftExpansion.guiIDCustom1, and if that that, return a new gui in the client method, and a container in the server method.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

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



×
×
  • Create New...

Important Information

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