Jump to content

Custom Container Error


gmod622

Recommended Posts

Hey all!

 

So I'm making a crate as a test to create a tileentity/container:

 

So starting it, I get this crash:

 

 

2016-11-14 00:31:40,836 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
2016-11-14 00:31:40,838 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
[00:31:40] [main/INFO] [GradleStart]: Extra: []
[00:31:40] [main/INFO] [GradleStart]: Running with arguments: [--userProperties, {}, --assetsDir, C:/Users/Blake/.gradle/caches/minecraft/assets, --assetIndex, 1.10, --accessToken{REDACTED}, --version, 1.10.2, --tweakClass, net.minecraftforge.fml.common.launcher.FMLTweaker, --tweakClass, net.minecraftforge.gradle.tweakers.CoremodTweaker]
[00:31:40] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
[00:31:40] [main/INFO] [LaunchWrapper]: Using primary tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
[00:31:40] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.CoremodTweaker
[00:31:40] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLTweaker
[00:31:41] [main/INFO] [FML]: Forge Mod Loader version 12.18.2.2125 for Minecraft 1.10.2 loading
[00:31:41] [main/INFO] [FML]: Java is Java HotSpot(TM) 64-Bit Server VM, version 1.8.0_101, running on Windows 10:amd64:10.0, installed at C:\Program Files\Java\jre1.8.0_101
[00:31:41] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation
[00:31:41] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.CoremodTweaker
[00:31:41] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.fml.relauncher.FMLCorePlugin
[00:31:41] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.classloading.FMLForgePlugin
[00:31:41] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[00:31:41] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLDeobfTweaker
[00:31:41] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.AccessTransformerTweaker
[00:31:41] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[00:31:41] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[00:31:41] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper
[00:31:41] [main/ERROR] [FML]: The binary patch set is missing. Either you are in a development environment, or things are not going to work!
[00:31:42] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing
[00:31:42] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper
[00:31:42] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLDeobfTweaker
[00:31:43] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.AccessTransformerTweaker
[00:31:43] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.TerminalTweaker
[00:31:43] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.TerminalTweaker
[00:31:43] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main}
2016-11-14 00:31:44,292 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
2016-11-14 00:31:44,337 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
2016-11-14 00:31:44,339 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
[00:31:44] [Client thread/INFO]: Setting user: Player531
[00:31:50] [Client thread/WARN]: Skipping bad option: lastServer:
[00:31:50] [Client thread/INFO]: LWJGL Version: 2.9.4
[00:31:52] [Client thread/INFO] [sTDOUT]: [net.minecraftforge.fml.client.SplashProgress:start:221]: ---- Minecraft Crash Report ----
// This is a token for 1 free hug. Redeem at your nearest Mojangsta: [~~HUG~~]

Time: 11/14/16 12:31 AM
Description: Loading screen debug info

This is just a prompt for computer specs to be printed. THIS IS NOT A ERROR


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

-- System Details --
Details:
Minecraft Version: 1.10.2
Operating System: Windows 10 (amd64) version 10.0
Java Version: 1.8.0_101, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 832113544 bytes (793 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: 
Loaded coremods (and transformers): 
GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 375.70' Renderer: 'GeForce GTX 960/PCIe/SSE2'
[00:31:52] [Client thread/INFO] [FML]: MinecraftForge v12.18.2.2125 Initialized
[00:31:52] [Client thread/INFO] [FML]: Replaced 231 ore recipes
[00:31:53] [Client thread/INFO] [FML]: Found 0 mods from the command line. Injecting into mod discoverer
[00:31:53] [Client thread/INFO] [FML]: Searching F:\Minecraft Workspace\1.10.x\Plentiful Misc v2\run\mods for mods
[00:31:54] [Client thread/INFO] [FML]: Forge Mod Loader has identified 4 mods to load
[00:31:55] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, plentifulmisc] at CLIENT
[00:31:55] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, plentifulmisc] at SERVER
[00:31:55] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:Plentiful Misc
[00:31:56] [Client thread/INFO] [FML]: Processing ObjectHolder annotations
[00:31:56] [Client thread/INFO] [FML]: Found 423 ObjectHolder annotations
[00:31:56] [Client thread/INFO] [FML]: Identifying ItemStackHolder annotations
[00:31:56] [Client thread/INFO] [FML]: Found 0 ItemStackHolder annotations
[00:31:56] [Client thread/INFO] [FML]: Applying holder lookups
[00:31:56] [Client thread/INFO] [FML]: Holder lookups applied
[00:31:56] [Client thread/INFO] [FML]: Applying holder lookups
[00:31:56] [Client thread/INFO] [FML]: Holder lookups applied
[00:31:56] [Client thread/INFO] [FML]: Applying holder lookups
[00:31:56] [Client thread/INFO] [FML]: Holder lookups applied
[00:31:56] [Client thread/INFO] [FML]: Configured a dormant chunk cache size of 0
[00:31:56] [Forge Version Check/INFO] [ForgeVersionCheck]: [Forge] Starting version check at http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json
[00:31:56] [Client thread/INFO] [FML]: Applying holder lookups
[00:31:56] [Client thread/INFO] [FML]: Holder lookups applied
[00:31:56] [Client thread/INFO] [FML]: Injecting itemstacks
[00:31:56] [Client thread/INFO] [FML]: Itemstack injection complete
[00:31:56] [Client thread/ERROR] [FML]: Fatal errors were detected during the transition from PREINITIALIZATION to INITIALIZATION. Loading cannot continue
[00:31:56] [Client thread/ERROR] [FML]: 
States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
UCH	mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) 
UCH	FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.10.2-12.18.2.2125.jar) 
UCH	Forge{12.18.2.2125} [Minecraft Forge] (forgeSrc-1.10.2-12.18.2.2125.jar) 
UCE	plentifulmisc{0.0.1} [Plentiful Misc] (bin) 
[00:31:56] [Client thread/ERROR] [FML]: The following problems were captured during this phase
[00:31:56] [Client thread/ERROR] [FML]: Caught exception from Plentiful Misc (plentifulmisc)
java.lang.NullPointerException
at net.minecraftforge.client.model.ModelLoader.setCustomModelResourceLocation(ModelLoader.java:1095) ~[forgeSrc-1.10.2-12.18.2.2125.jar:?]
at com.lambda.PlentifulMisc.client.ClientProxy.crateRegistration(ClientProxy.java:23) ~[bin/:?]
at com.lambda.PlentifulMisc.main.PlentifulMisc.preInit(PlentifulMisc.java:39) ~[bin/:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_101]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_101]
at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:602) ~[forgeSrc-1.10.2-12.18.2.2125.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_101]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_101]
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?]
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?]
at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:243) ~[forgeSrc-1.10.2-12.18.2.2125.jar:?]
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:221) ~[forgeSrc-1.10.2-12.18.2.2125.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_101]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_101]
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?]
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?]
at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:145) [LoadController.class:?]
at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:614) [Loader.class:?]
at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:257) [FMLClientHandler.class:?]
at net.minecraft.client.Minecraft.startGame(Minecraft.java:477) [Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:386) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_101]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_101]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_101]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_101]
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
at GradleStart.main(GradleStart.java:26) [start/:?]
[00:31:56] [Forge Version Check/INFO] [ForgeVersionCheck]: [Forge] Found status: AHEAD Target: null
[00:31:56] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:649]: ---- Minecraft Crash Report ----
// My bad.

Time: 11/14/16 12:31 AM
Description: There was a severe problem during mod loading that has caused the game to fail

net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Plentiful Misc (plentifulmisc)
Caused by: java.lang.NullPointerException
at net.minecraftforge.client.model.ModelLoader.setCustomModelResourceLocation(ModelLoader.java:1095)
at com.lambda.PlentifulMisc.client.ClientProxy.crateRegistration(ClientProxy.java:23)
at com.lambda.PlentifulMisc.main.PlentifulMisc.preInit(PlentifulMisc.java:39)
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.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:602)
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 com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:243)
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:221)
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 com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:145)
at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:614)
at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:257)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:477)
at net.minecraft.client.Minecraft.run(Minecraft.java:386)
at net.minecraft.client.main.Main.main(Main.java:118)
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:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
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.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
at GradleStart.main(GradleStart.java:26)


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

-- System Details --
Details:
Minecraft Version: 1.10.2
Operating System: Windows 10 (amd64) version 10.0
Java Version: 1.8.0_101, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 631669600 bytes (602 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP 9.32 Powered by Forge 12.18.2.2125 4 mods loaded, 4 mods active
States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
UCH	mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) 
UCH	FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.10.2-12.18.2.2125.jar) 
UCH	Forge{12.18.2.2125} [Minecraft Forge] (forgeSrc-1.10.2-12.18.2.2125.jar) 
UCE	plentifulmisc{0.0.1} [Plentiful Misc] (bin) 
Loaded coremods (and transformers): 
GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 375.70' Renderer: 'GeForce GTX 960/PCIe/SSE2'
[00:31:56] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:649]: #@!@# Game crashed! Crash report saved to: #@!@# F:\Minecraft Workspace\1.10.x\Plentiful Misc v2\run\.\crash-reports\crash-2016-11-14_00.31.56-client.txt
Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release

 

 

 

This is where its crashing in my ClientProxy:

@SideOnly(Side.CLIENT)
public void crateRegistration() {
	ModelResourceLocation itemModelResourceLocation = new ModelResourceLocation("plentifulmisc:crate", "inventory");
	final int DEFAULT_ITEM_SUBTYPE = 0;
	ModelLoader.setCustomModelResourceLocation(CommonProxy.itemBlockInventoryBasic, DEFAULT_ITEM_SUBTYPE, itemModelResourceLocation); //HERE
}

 

Here is my the rest of my ClientProxy:

 

 

package com.lambda.PlentifulMisc.client;

import com.lambda.PlentifulMisc.info.Reference;
import com.lambda.PlentifulMisc.main.CommonProxy;


import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class ClientProxy extends CommonProxy {
@Override
public void registerItemRenderer(Item item, int meta, String id) {
	ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(Reference.MOD_ID + ":" + id, "inventory"));
}

@SideOnly(Side.CLIENT)
public void crateRegistration() {
	ModelResourceLocation itemModelResourceLocation = new ModelResourceLocation("plentifulmisc:crate", "inventory");
	final int DEFAULT_ITEM_SUBTYPE = 0;
ModelLoader.setCustomModelResourceLocation(CommonProxy.itemBlockInventoryBasic, DEFAULT_ITEM_SUBTYPE, itemModelResourceLocation);
}
}

 

 

 

Here is my CommonProxy:

 

 

package com.lambda.PlentifulMisc.main;

import com.lambda.PlentifulMisc.block.BlockCrate;
import com.lambda.PlentifulMisc.block.ModBlocks;
import com.lambda.PlentifulMisc.block.tileentity.TileEntityCrate;
import com.lambda.PlentifulMisc.client.gui.GuiHandler;
import com.lambda.PlentifulMisc.client.gui.GuiHandlerRegistry;
import com.lambda.PlentifulMisc.item.ModItems;
import com.lambda.PlentifulMisc.tab.PMCreativeTab;

import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;

public abstract  class CommonProxy {

public static Block blockInventoryBasic;  // this holds the unique instance of your block
public static ItemBlock itemBlockInventoryBasic; // and the corresponding item form that block

public void registerItemRenderer(Item item, int meta, String id){

}

public void crateRegistration() {
	blockInventoryBasic = (BlockCrate)(new BlockCrate().setRegistryName("crate"));
	blockInventoryBasic.setUnlocalizedName("crate");
	GameRegistry.register(blockInventoryBasic);

	itemBlockInventoryBasic = new ItemBlock(blockInventoryBasic);
	itemBlockInventoryBasic.setRegistryName(blockInventoryBasic.getRegistryName());
	GameRegistry.register(itemBlockInventoryBasic);

	GameRegistry.registerTileEntity(TileEntityCrate.class, "tile_crate");

	NetworkRegistry.INSTANCE.registerGuiHandler(PlentifulMisc.instance, GuiHandlerRegistry.getInstance());
	GuiHandlerRegistry.getInstance().registerGuiHandler(new GuiHandler(), GuiHandler.getGuiID());
}
}

 

 

 

My main:

 

 

 

package com.lambda.PlentifulMisc.main;

import com.lambda.PlentifulMisc.block.ModBlocks;
import com.lambda.PlentifulMisc.client.gui.GuiHandlerRegistry;
import com.lambda.PlentifulMisc.info.Reference;
import com.lambda.PlentifulMisc.item.ModItems;
import com.lambda.PlentifulMisc.main.crafting.ModRecipes;
import com.lambda.PlentifulMisc.tab.PMCreativeTab;

import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;

@Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.MOD_VERSION)
public class PlentifulMisc {

@Instance(Reference.MOD_ID)
public static PlentifulMisc instance;
@SidedProxy(clientSide = "com.lambda.PlentifulMisc.client.ClientProxy", serverSide = "com.lambda.PlentifulMisc.main.CommonProxy")
public static CommonProxy proxy;

public PMCreativeTab creativeTab;

@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
	creativeTab = new PMCreativeTab();

	ModBlocks.load(event);
	ModItems.load(event);
	ModRecipes.load(event);

	proxy.crateRegistration();


}

@Mod.EventHandler
public void init(FMLInitializationEvent event) {
}

@Mod.EventHandler
public void postInit(FMLPostInitializationEvent event) {
}

}

 

 

 

My GUI / GUI Handler / GUI Register

 

 

 

package com.lambda.PlentifulMisc.client.gui;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import java.awt.*;

import com.lambda.PlentifulMisc.block.container.ContainerCrate;
import com.lambda.PlentifulMisc.block.tileentity.TileEntityCrate;

/**
* User: brandon3055
* Date: 06/01/2015
*
* GuiInventoryBasic is a simple gui that does nothing but draw a background image and a line of text on the screen
* everything else is handled by the vanilla container code
*/
@SideOnly(Side.CLIENT)
public class GuiCrate extends GuiContainer {

// This is the resource location for the background image for the GUI
private static final ResourceLocation texture = new ResourceLocation("plentifulmisc", "textures/gui/crateGUI.png");
private TileEntityCrate tileEntityInventoryBasic;

public GuiCrate(InventoryPlayer invPlayer, TileEntityCrate tile) {
	super(new ContainerCrate(invPlayer, tile));
	tileEntityInventoryBasic = tile;
	// Set the width and height of the gui.  Should match the size of the texture!
	xSize = 176;
	ySize = 133;
}

// draw the background for the GUI - rendered first
@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int x, int y) {
	// Bind the image texture of our custom container
	Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
	// Draw the image
	GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
	drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
}

// draw the foreground for the GUI - rendered after the slots, but before the dragged items and tooltips
// renders relative to the top left corner of the background
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
	final int LABEL_XPOS = 5;
	final int LABEL_YPOS = 5;
	fontRendererObj.drawString(tileEntityInventoryBasic.getDisplayName().getUnformattedText(), LABEL_XPOS, LABEL_YPOS, Color.darkGray.getRGB());
}
}

 

 

 

 

 

package com.lambda.PlentifulMisc.client.gui;

import com.lambda.PlentifulMisc.block.container.ContainerCrate;
import com.lambda.PlentifulMisc.block.tileentity.TileEntityCrate;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.network.IGuiHandler;

/**
* User: brandon3055
* Date: 06/01/2015
*
* This class is used to get the client and server gui elements when a player opens a gui. There can only be one registered
*   IGuiHandler instance handler per mod.
*/
public class GuiHandler implements IGuiHandler {
private static final int GUIID_MBE_30 = 30;
public static int getGuiID() {return GUIID_MBE_30;}

// Gets the server side element for the given gui id- this should return a container
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
	if (ID != getGuiID()) {
		System.err.println("Invalid ID: expected " + getGuiID() + ", received " + ID);
	}

	BlockPos xyz = new BlockPos(x, y, z);
	TileEntity tileEntity = world.getTileEntity(xyz);
	if (tileEntity instanceof TileEntityCrate) {
		TileEntityCrate tileEntityInventoryBasic = (TileEntityCrate) tileEntity;
		return new ContainerCrate(player.inventory, tileEntityInventoryBasic);
	}
	return null;
}

// Gets the client side element for the given gui id- this should return a gui
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
	if (ID != getGuiID()) {
		System.err.println("Invalid ID: expected " + getGuiID() + ", received " + ID);
	}

	BlockPos xyz = new BlockPos(x, y, z);
	TileEntity tileEntity = world.getTileEntity(xyz);
	if (tileEntity instanceof TileEntityCrate) {
		TileEntityCrate tileEntityInventoryBasic = (TileEntityCrate) tileEntity;
		return new GuiCrate(player.inventory, tileEntityInventoryBasic);
	}
	return null;
}
}

 

 

 

 

 

package com.lambda.PlentifulMisc.client.gui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.network.IGuiHandler;

import java.util.HashMap;

public class GuiHandlerRegistry implements IGuiHandler {

public void registerGuiHandler(IGuiHandler handler, int guiID)
{
	registeredHandlers.put(guiID, handler);
}

public static GuiHandlerRegistry getInstance() {return guiHandlerRegistry;}

private HashMap<Integer, IGuiHandler> registeredHandlers = new HashMap<Integer, IGuiHandler>();
private static GuiHandlerRegistry guiHandlerRegistry = new GuiHandlerRegistry();

// Gets the server side element for the given gui id- this should return a container
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
	IGuiHandler handler = registeredHandlers.get(ID);
	if (handler != null) {
		return handler.getServerGuiElement(ID, player, world, x, y, z);
	} else {
		return null;
	}
}

// Gets the client side element for the given gui id- this should return a gui
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
	IGuiHandler handler = registeredHandlers.get(ID);
	if (handler != null) {
		return handler.getClientGuiElement(ID, player, world, x, y, z);
	} else {
		return null;
	}
}

}

 

 

 

Tile Entity:

 

 

package com.lambda.PlentifulMisc.block.tileentity;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;

import java.util.Arrays;

/**
* User: brandon3055
* Date: 06/01/2015
*
* This is a simple tile entity implementing IInventory that can store 9 item stacks
*/
public class TileEntityCrate extends TileEntity implements IInventory {
// Create and initialize the items variable that will store store the items
final int NUMBER_OF_SLOTS = 9;
private ItemStack[] itemStacks = new ItemStack[NUMBER_OF_SLOTS];

/* The following are some IInventory methods you are required to override */

// Gets the number of slots in the inventory
@Override
public int getSizeInventory() {
	return itemStacks.length;
}

// Gets the stack in the given slot
@Override
public ItemStack getStackInSlot(int slotIndex) {
	return itemStacks[slotIndex];
}

/**
 * Removes some of the units from itemstack in the given slot, and returns as a separate itemstack
	 * @param slotIndex the slot number to remove the items from
 * @param count the number of units to remove
 * @return a new itemstack containing the units removed from the slot
 */
@Override
public ItemStack decrStackSize(int slotIndex, int count) {
	ItemStack itemStackInSlot = getStackInSlot(slotIndex);
	if (itemStackInSlot == null) return null;

	ItemStack itemStackRemoved;
	if (itemStackInSlot.stackSize <= count) {
		itemStackRemoved = itemStackInSlot;
		setInventorySlotContents(slotIndex, null);
	} else {
		itemStackRemoved = itemStackInSlot.splitStack(count);
		if (itemStackInSlot.stackSize == 0) {
			setInventorySlotContents(slotIndex, null);
		}
	}
  markDirty();
	return itemStackRemoved;
}

// overwrites the stack in the given slotIndex with the given stack
@Override
public void setInventorySlotContents(int slotIndex, ItemStack itemstack) {
	itemStacks[slotIndex] = itemstack;
	if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) {
		itemstack.stackSize = getInventoryStackLimit();
	}
	markDirty();
}

// This is the maximum number if items allowed in each slot
// This only affects things such as hoppers trying to insert items you need to use the container to enforce this for players
// inserting items via the gui
@Override
public int getInventoryStackLimit() {
	return 64;
}

// Return true if the given player is able to use this block. In this case it checks that
// 1) the world tileentity hasn't been replaced in the meantime, and
// 2) the player isn't too far away from the centre of the block
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
	if (this.worldObj.getTileEntity(this.pos) != this) return false;
	final double X_CENTRE_OFFSET = 0.5;
	final double Y_CENTRE_OFFSET = 0.5;
	final double Z_CENTRE_OFFSET = 0.5;
	final double MAXIMUM_DISTANCE_SQ = 8.0 * 8.0;
	return player.getDistanceSq(pos.getX() + X_CENTRE_OFFSET, pos.getY() + Y_CENTRE_OFFSET, pos.getZ() + Z_CENTRE_OFFSET) < MAXIMUM_DISTANCE_SQ;
}

// Return true if the given stack is allowed to go in the given slot.  In this case, we can insert anything.
// This only affects things such as hoppers trying to insert items you need to use the container to enforce this for players
// inserting items via the gui
@Override
public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) {
	return true;
}

// This is where you save any data that you don't want to lose when the tile entity unloads
// In this case, it saves the itemstacks stored in the container
@Override
public NBTTagCompound writeToNBT(NBTTagCompound parentNBTTagCompound)
{
	super.writeToNBT(parentNBTTagCompound); // The super call is required to save and load the tileEntity's location

	// to use an analogy with Java, this code generates an array of hashmaps
	// The itemStack in each slot is converted to an NBTTagCompound, which is effectively a hashmap of key->value pairs such
	//   as slot=1, id=2353, count=1, etc
	// Each of these NBTTagCompound are then inserted into NBTTagList, which is similar to an array.
	NBTTagList dataForAllSlots = new NBTTagList();
	for (int i = 0; i < this.itemStacks.length; ++i) {
		if (this.itemStacks[i] != null)	{
			NBTTagCompound dataForThisSlot = new NBTTagCompound();
			dataForThisSlot.setByte("Slot", (byte) i);
			this.itemStacks[i].writeToNBT(dataForThisSlot);
			dataForAllSlots.appendTag(dataForThisSlot);
		}
	}
	// the array of hashmaps is then inserted into the parent hashmap for the container
	parentNBTTagCompound.setTag("Items", dataForAllSlots);
	// return the NBT Tag Compound
	return parentNBTTagCompound;
}

// This is where you load the data that you saved in writeToNBT
@Override
public void readFromNBT(NBTTagCompound parentNBTTagCompound)
{
	super.readFromNBT(parentNBTTagCompound); // The super call is required to save and load the tiles location
	final byte NBT_TYPE_COMPOUND = 10;       // See NBTBase.createNewByType() for a listing
	NBTTagList dataForAllSlots = parentNBTTagCompound.getTagList("Items", NBT_TYPE_COMPOUND);

	Arrays.fill(itemStacks, null);           // set all slots to empty
	for (int i = 0; i < dataForAllSlots.tagCount(); ++i) {
		NBTTagCompound dataForOneSlot = dataForAllSlots.getCompoundTagAt(i);
		int slotIndex = dataForOneSlot.getByte("Slot") & 255;

		if (slotIndex >= 0 && slotIndex < this.itemStacks.length) {
			this.itemStacks[slotIndex] = ItemStack.loadItemStackFromNBT(dataForOneSlot);
		}
	}
}

// set all slots to empty
@Override
public void clear() {
	Arrays.fill(itemStacks, null);
}

// will add a key for this container to the lang file so we can name it in the GUI
@Override
public String getName() {
	return "container.mbe30_inventory_basic.name";
}

@Override
public boolean hasCustomName() {
	return false;
}

// standard code to look up what the human-readable name is
@Override
public ITextComponent getDisplayName() {
	return this.hasCustomName() ? new TextComponentString(this.getName()) : new TextComponentTranslation(this.getName());
}

// -----------------------------------------------------------------------------------------------------------
// The following methods are not needed for this example but are part of IInventory so they must be implemented

/**
 * This method removes the entire contents of the given slot and returns it.
 * Used by containers such as crafting tables which return any items in their slots when you close the GUI
 * @param slotIndex
 * @return
 */
@Override
public ItemStack removeStackFromSlot(int slotIndex) {
	ItemStack itemStack = getStackInSlot(slotIndex);
	if (itemStack != null) setInventorySlotContents(slotIndex, null);
	return itemStack;
}

@Override
public void openInventory(EntityPlayer player) {}

@Override
public void closeInventory(EntityPlayer player) {}

@Override
public int getField(int id) {
	return 0;
}

@Override
public void setField(int id, int value) {}

@Override
public int getFieldCount() {
	return 0;
}
}

 

 

 

Container

 

 

package com.lambda.PlentifulMisc.block.container;

import com.lambda.PlentifulMisc.block.tileentity.TileEntityCrate;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;

public class ContainerCrate extends Container {

// Stores a reference to the tile entity instance for later use
private TileEntityCrate tileEntityInventoryBasic;

// must assign a slot number to each of the slots used by the GUI.
// For this container, we can see both the tile inventory's slots as well as the player inventory slots and the hotbar.
// Each time we add a Slot to the container, it automatically increases the slotIndex, which means
//  0 - 8 = hotbar slots (which will map to the InventoryPlayer slot numbers 0 - 
//  9 - 35 = player inventory slots (which map to the InventoryPlayer slot numbers 9 - 35)
//  36 - 44 = TileInventory slots, which map to our TileEntity slot numbers 0 - 

private final int HOTBAR_SLOT_COUNT = 9;
private final int PLAYER_INVENTORY_ROW_COUNT = 3;
private final int PLAYER_INVENTORY_COLUMN_COUNT = 9;
private final int PLAYER_INVENTORY_SLOT_COUNT = PLAYER_INVENTORY_COLUMN_COUNT * PLAYER_INVENTORY_ROW_COUNT;
private final int VANILLA_SLOT_COUNT = HOTBAR_SLOT_COUNT + PLAYER_INVENTORY_SLOT_COUNT;

private final int VANILLA_FIRST_SLOT_INDEX = 0;
private final int TE_INVENTORY_FIRST_SLOT_INDEX = VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT;
private final int TE_INVENTORY_SLOT_COUNT = 9;

public ContainerCrate(InventoryPlayer invPlayer, TileEntityCrate tileEntityInventoryBasic) {
	this.tileEntityInventoryBasic = tileEntityInventoryBasic;

	final int SLOT_X_SPACING = 18;
    final int SLOT_Y_SPACING = 18;
	final int HOTBAR_XPOS = 8;
	final int HOTBAR_YPOS = 109;
	// Add the players hotbar to the gui - the [xpos, ypos] location of each item
	for (int x = 0; x < HOTBAR_SLOT_COUNT; x++) {
		int slotNumber = x;
		addSlotToContainer(new Slot(invPlayer, slotNumber, HOTBAR_XPOS + SLOT_X_SPACING * x, HOTBAR_YPOS));
	}

	final int PLAYER_INVENTORY_XPOS = 8;
	final int PLAYER_INVENTORY_YPOS = 51;
	// Add the rest of the players inventory to the gui
	for (int y = 0; y < PLAYER_INVENTORY_ROW_COUNT; y++) {
		for (int x = 0; x < PLAYER_INVENTORY_COLUMN_COUNT; x++) {
			int slotNumber = HOTBAR_SLOT_COUNT + y * PLAYER_INVENTORY_COLUMN_COUNT + x;
			int xpos = PLAYER_INVENTORY_XPOS + x * SLOT_X_SPACING;
			int ypos = PLAYER_INVENTORY_YPOS + y * SLOT_Y_SPACING;
			addSlotToContainer(new Slot(invPlayer, slotNumber,  xpos, ypos));
		}
	}

	if (TE_INVENTORY_SLOT_COUNT != tileEntityInventoryBasic.getSizeInventory()) {
		System.err.println("Mismatched slot count in ContainerBasic(" + TE_INVENTORY_SLOT_COUNT
											  + ") and TileInventory (" + tileEntityInventoryBasic.getSizeInventory()+")");
	}
	final int TILE_INVENTORY_XPOS = 8;
	final int TILE_INVENTORY_YPOS = 20;
	// Add the tile inventory container to the gui
	for (int x = 0; x < TE_INVENTORY_SLOT_COUNT; x++) {
		int slotNumber = x;
		addSlotToContainer(new Slot(tileEntityInventoryBasic, slotNumber, TILE_INVENTORY_XPOS + SLOT_X_SPACING * x, TILE_INVENTORY_YPOS));
	}
}

// Vanilla calls this method every tick to make sure the player is still able to access the inventory, and if not closes the gui
@Override
public boolean canInteractWith(EntityPlayer player)
{
	return tileEntityInventoryBasic.isUseableByPlayer(player);
}

// This is where you specify what happens when a player shift clicks a slot in the gui
//  (when you shift click a slot in the TileEntity Inventory, it moves it to the first available position in the hotbar and/or
//    player inventory.  When you you shift-click a hotbar or player inventory item, it moves it to the first available
//    position in the TileEntity inventory)
// At the very least you must override this and return null or the game will crash when the player shift clicks a slot
// returns null if the source slot is empty, or if none of the the source slot items could be moved
//   otherwise, returns a copy of the source stack
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int sourceSlotIndex)
{
	Slot sourceSlot = (Slot)inventorySlots.get(sourceSlotIndex);
	if (sourceSlot == null || !sourceSlot.getHasStack()) return null;
	ItemStack sourceStack = sourceSlot.getStack();
	ItemStack copyOfSourceStack = sourceStack.copy();

	// Check if the slot clicked is one of the vanilla container slots
	if (sourceSlotIndex >= VANILLA_FIRST_SLOT_INDEX && sourceSlotIndex < VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT) {
		// This is a vanilla container slot so merge the stack into the tile inventory
		if (!mergeItemStack(sourceStack, TE_INVENTORY_FIRST_SLOT_INDEX, TE_INVENTORY_FIRST_SLOT_INDEX + TE_INVENTORY_SLOT_COUNT, false)){
			return null;
		}
	} else if (sourceSlotIndex >= TE_INVENTORY_FIRST_SLOT_INDEX && sourceSlotIndex < TE_INVENTORY_FIRST_SLOT_INDEX + TE_INVENTORY_SLOT_COUNT) {
		// This is a TE slot so merge the stack into the players inventory
		if (!mergeItemStack(sourceStack, VANILLA_FIRST_SLOT_INDEX, VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT, false)) {
			return null;
		}
	} else {
		System.err.print("Invalid slotIndex:" + sourceSlotIndex);
		return null;
	}

	// If stack size == 0 (the entire stack was moved) set slot contents to null
	if (sourceStack.stackSize == 0) {
		sourceSlot.putStack(null);
	} else {
		sourceSlot.onSlotChanged();
	}

	sourceSlot.onPickupFromSlot(player, sourceStack);
	return copyOfSourceStack;
}

// pass the close container message to the tileEntityInventory (not strictly needed for this example)
//  see ContainerChest and TileEntityChest
@Override
public void onContainerClosed(EntityPlayer playerIn)
{
	super.onContainerClosed(playerIn);
	this.tileEntityInventoryBasic.closeInventory(playerIn);
}
}

 

 

 

lastly my block file

 

 

 

package com.lambda.PlentifulMisc.block;
import com.lambda.PlentifulMisc.block.tileentity.TileEntityCrate;
import com.lambda.PlentifulMisc.client.gui.GuiHandler;
import com.lambda.PlentifulMisc.main.PlentifulMisc;

import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

/**
* User: brandon3055
* Date: 06/01/2015
*
* BlockInventoryBasic is a simple inventory capable of storing 9 item stacks. The block itself doesn't do much more
* then any regular block except create a tile entity when placed, open a gui when right clicked and drop tne
* inventory's contents when harvested. The actual storage is handled by the tile entity.
*/

//Note that in 1.10.*, extending BlockContainer can cause rendering problems if you don't extend getRenderType()
// If you don't want to extend BlockContainer, make sure to add the tile entity manually,
//   using hasTileEntity() and createTileEntity().  See BlockContainer for a couple of other important methods you may
//  need to implement.

public class BlockCrate extends BlockContainer
{   
public BlockCrate()
{
	super(Material.ROCK);
	this.setCreativeTab(PlentifulMisc.instance.creativeTab);     // the block will appear on the Blocks tab.
}

  /**
   * Create the Tile Entity for this block.
   * If your block doesn't extend BlockContainer, use createTileEntity(World worldIn, IBlockState state) instead
   * @param worldIn
   * @param meta
   * @return
   */

  @Override
  public TileEntity createNewTileEntity(World worldIn, int meta) {
    return new TileEntityCrate();
  }

  // not needed if your block implements ITileEntityProvider (in this case implemented by BlockContainer), but it
  //  doesn't hurt to include it anyway...
@Override
public boolean hasTileEntity(IBlockState state)
{
	return true;
}

// Called when the block is right clicked
// In this block it is used to open the blocks gui when right clicked by a player
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
	// Uses the gui handler registered to your mod to open the gui for the given gui id
	// open on the server side only  (not sure why you shouldn't open client side too... vanilla doesn't, so we better not either)
	if (worldIn.isRemote) return true;

	playerIn.openGui(PlentifulMisc.instance, GuiHandler.getGuiID(), worldIn, pos.getX(), pos.getY(), pos.getZ());
	return true;
}

// This is where you can do something when the block is broken. In this case drop the inventory's contents
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {

	IInventory inventory = worldIn.getTileEntity(pos) instanceof IInventory ? (IInventory)worldIn.getTileEntity(pos) : null;

	if (inventory != null){
		// For each slot in the inventory
		for (int i = 0; i < inventory.getSizeInventory(); i++){
			// If the slot is not empty
			if (inventory.getStackInSlot(i) != null)
			{
				// Create a new entity item with the item stack in the slot
				EntityItem item = new EntityItem(worldIn, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, inventory.getStackInSlot(i));

				// Apply some random motion to the item
				float multiplier = 0.1f;
				float motionX = worldIn.rand.nextFloat() - 0.5f;
				float motionY = worldIn.rand.nextFloat() - 0.5f;
				float motionZ = worldIn.rand.nextFloat() - 0.5f;

				item.motionX = motionX * multiplier;
				item.motionY = motionY * multiplier;
				item.motionZ = motionZ * multiplier;

				// Spawn the item in the world
				worldIn.spawnEntityInWorld(item);
			}
		}

		// Clear the inventory so nothing else (such as another mod) can do anything with the items
		inventory.clear();
	}

	// Super MUST be called last because it removes the tile entity
	super.breakBlock(worldIn, pos, state);
}

//---------------------------------------------------------

// the block is smaller than a full cube, specify dimensions here
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
	return new AxisAlignedBB(1/16.0F, 0, 1/16.0F, 15/16.0F, 8/16.0F, 15/16.0F);
}

// the block will render in the SOLID layer.  See http://greyminecraftcoder.blogspot.co.at/2014/12/block-rendering-18.html for more information.
@SideOnly(Side.CLIENT)
public BlockRenderLayer getBlockLayer()
{
	return BlockRenderLayer.SOLID;
}

// used by the renderer to control lighting and visibility of other blocks.
// set to false because this block doesn't fill the entire 1x1x1 space
@Override
public boolean isOpaqueCube(IBlockState state)
{
	return false;
}

// used by the renderer to control lighting and visibility of other blocks, also by
// (eg) wall or fence to control whether the fence joins itself to this block
// set to false because this block doesn't fill the entire 1x1x1 space
@Override
public boolean isFullCube(IBlockState state)
{
	return false;
}

  // render using a BakedModel (mbe30_inventory_basic.json --> mbe30_inventory_basic_model.json)
  // required because the default (super method) is INVISIBLE for BlockContainers.
  @Override
  public EnumBlockRenderType getRenderType(IBlockState iBlockState) {
    return EnumBlockRenderType.MODEL;
  }


}

 

 

 

Lastly my registration (modblocks):

 

 

 

package com.lambda.PlentifulMisc.block;

import com.lambda.PlentifulMisc.item.IItemModelProvider;

import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class ModBlocks {

public static CropRockcress CROP_ROCKCRESS;
public static BlockXianiteOre ORE_XIANITE;
public static BlockFertileDirt FERTILEDIRT;
public static BlockFertileDirt TILLED_FERTILEDIRT;
public static BlockCrate CRATE;

public static void load(FMLPreInitializationEvent event) 
{
	CROP_ROCKCRESS = register(new CropRockcress(), null);
	FERTILEDIRT = new BlockFertileDirt(false);
	TILLED_FERTILEDIRT = new BlockFertileDirt(true);

	CRATE = new BlockCrate();

	ORE_XIANITE = new BlockXianiteOre();

}

private static <T extends Block> T register(T block, ItemBlock itemBlock) {
	GameRegistry.register(block);
	if(itemBlock != null) {
	GameRegistry.register(itemBlock);
	}
	if (block instanceof IItemModelProvider) {
		((IItemModelProvider)block).registerItemModel(itemBlock);
	}

	return block;
}

private static <T extends Block> T register(T block) {
	ItemBlock itemBlock = new ItemBlock(block);
	itemBlock.setRegistryName(block.getRegistryName());
	return register(block, itemBlock);
}
}

 

 

Not new to java >> New to modding.

Link to comment
Share on other sites

crateRegistration() in your client proxy doesn't call super() so your block is never created.

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.

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