Jump to content

Recommended Posts

Posted

Hi there!

I have recently decided to try and make a mod for 1.7.2.

When upgrading, there is an error in my class with using itemID, which no longer exists appaerently.

Minecraft crashes when I try to craft with the chisel.

 

Main Class:

package com.obsidiancraft.core;

import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;

import com.obsidiancraft.block.blockObsidianBrick;
import com.obsidiancraft.item.itemDiamondChisel;

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.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;

@Mod(modid = CoreMod.modid, name = CoreMod.name, version = CoreMod.version)
public class CoreMod {
@Instance
public static CoreMod instance;

    public static final String modid = "extendedobsidian";
    public static final String name = "Extended Obsidian";
    public static final String version = "1.0";
    
    //Creative Tab
    public static CreativeTabs ExtendedObsidianTab = new CreativeTabs("ExtendedObsidian") {
    	public Item getTabIconItem() {
    		return Item.getItemFromBlock(blockObsidianBrick);
    		}
    	};
    
    //Blocks
    public static Block blockObsidianBrick;
    
    //Items
    public static Item itemDiamondChisel;
    	
    @EventHandler
    public void preInit(FMLPreInitializationEvent event) {
    	
    	blockObsidianBrick = new blockObsidianBrick().setBlockName("blockObsidianBrick");
    	GameRegistry.registerBlock(blockObsidianBrick, blockObsidianBrick.getUnlocalizedName().substring(5));
    	
    	itemDiamondChisel = new itemDiamondChisel().setUnlocalizedName("itemDiamondChisel").setTextureName(CoreMod.modid + ":" + "itemDiamondChisel");
    	GameRegistry.registerItem(itemDiamondChisel, "itemDiamondChisel");
    	
    }
    
    @EventHandler
    public void Init(FMLInitializationEvent event) {

    //Recipes
    	//shaped
    	GameRegistry.addShapedRecipe(new ItemStack(itemDiamondChisel), new Object[]{"XC", 'X', Items.diamond, 'C', new ItemStack(Items.stick, 1, OreDictionary.WILDCARD_VALUE)});
    	//shapeless
    	GameRegistry.addShapelessRecipe(new ItemStack(blockObsidianBrick), new Object[]{itemDiamondChisel, Blocks.stonebrick, Blocks.obsidian});
    	//smelting
    }
    
    @EventHandler
    public void postInit(FMLPostInitializationEvent event) {
    }
}

 

Item Class:

package com.obsidiancraft.item;

import java.util.List;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

import com.obsidiancraft.core.CoreMod;

public class itemDiamondChisel extends Item {

private ItemStack emptyItem = null;
private static int maxDamage;

    public itemDiamondChisel() {

        setMaxDamage(64);
        this.setMaxStackSize(1);
        this.setNoRepair();
        this.setCreativeTab(CoreMod.ExtendedObsidianTab);
    }
    
    @Override
    public boolean hasContainerItem() {
    return true;
    }
    
    public void setEmptyItem(ItemStack ei) {
    this.emptyItem = ei;
    }
    
    public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack) {
    return false;
    }
    
public ItemStack getContainerItemStack(ItemStack stack) {
	stack.setItemDamage(stack.getItemDamage() + 1);	
	return stack;
}

    public static ItemStack copyStack(ItemStack stack, int n) {
    return new ItemStack(stack.itemID, n, stack.getItemDamage());
    }

    @SuppressWarnings("unchecked")
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean i) {
    	list.add("\u00A77" + (stack.getMaxDamage() - stack.getItemDamage()) + " Uses left");
    }
}

 

Crashlog:

---- Minecraft Crash Report ----
// Surprise! Haha. Well, this is awkward.

Time: 2014-05-01 23:43
Description: Updating screen events

java.lang.NullPointerException: Updating screen events
at net.minecraft.item.ItemStack.isItemStackDamageable(ItemStack.java:194)
at net.minecraft.inventory.SlotCrafting.onPickupFromSlot(SlotCrafting.java:124)
at net.minecraft.inventory.Container.slotClick(SourceFile:238)
at net.minecraft.client.multiplayer.PlayerControllerMP.windowClick(PlayerControllerMP.java:419)
at net.minecraft.client.gui.inventory.GuiContainer.handleMouseClick(GuiContainer.java:638)
at net.minecraft.client.gui.inventory.GuiContainer.mouseClicked(GuiContainer.java:392)
at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:289)
at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:256)
at net.minecraft.client.Minecraft.runTick(Minecraft.java:1579)
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 net.minecraft.item.ItemStack.isItemStackDamageable(ItemStack.java:194)
at net.minecraft.inventory.SlotCrafting.onPickupFromSlot(SlotCrafting.java:124)
at net.minecraft.inventory.Container.slotClick(SourceFile:238)
at net.minecraft.client.multiplayer.PlayerControllerMP.windowClick(PlayerControllerMP.java:419)
at net.minecraft.client.gui.inventory.GuiContainer.handleMouseClick(GuiContainer.java:638)
at net.minecraft.client.gui.inventory.GuiContainer.mouseClicked(GuiContainer.java:392)
at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:289)
at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:256)

-- Affected screen --
Details:
Screen name: net.minecraft.client.gui.inventory.GuiCrafting

-- Affected level --
Details:
Level name: MpServer
All players: 1 total; [EntityClientPlayerMP['Player153'/182, l='MpServer', x=786,82, y=5,62, z=-52,55]]
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: (780,4,-66), Chunk: (at 12,0,14 in 48,-5; contains blocks 768,0,-80 to 783,255,-65), Region: (1,-1; contains chunks 32,-32 to 63,-1, blocks 512,0,-512 to 1023,255,-1)
Level time: 10274 game time, 10274 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: 41 total; [EntityCow['Cow'/68, l='MpServer', x=776,31, y=4,00, z=-21,38], EntitySheep['Sheep'/69, l='MpServer', x=771,63, y=4,00, z=-19,81], EntitySheep['Sheep'/70, l='MpServer', x=777,63, y=4,00, z=-15,94], EntityCow['Cow'/71, l='MpServer', x=781,84, y=4,00, z=-15,78], EntityPig['Pig'/67, l='MpServer', x=773,22, y=4,00, z=-17,09], EntityVillager['Villager'/76, l='MpServer', x=776,34, y=5,00, z=20,69], EntityChicken['Chicken'/129, l='MpServer', x=839,63, y=4,00, z=-37,41], EntityVillager['Villager'/77, l='MpServer', x=775,31, y=5,00, z=20,00], EntityPig['Pig'/128, l='MpServer', x=832,09, y=4,00, z=-126,94], EntityChicken['Chicken'/131, l='MpServer', x=845,94, y=4,00, z=-31,38], EntityVillager['Villager'/79, l='MpServer', x=770,50, y=5,00, z=20,69], EntityChicken['Chicken'/130, l='MpServer', x=833,63, y=4,00, z=-26,44], EntityChicken['Chicken'/133, l='MpServer', x=840,91, y=4,00, z=-24,88], EntitySheep['Sheep'/72, l='MpServer', x=785,09, y=4,00, z=-16,97], EntityCow['Cow'/132, l='MpServer', x=840,72, y=4,00, z=-30,44], EntityCow['Cow'/134, l='MpServer', x=836,34, y=4,00, z=-31,78], EntityVillager['Villager'/80, l='MpServer', x=775,66, y=4,00, z=24,66], EntityPig['Pig'/89, l='MpServer', x=795,97, y=4,00, z=-11,84], EntityCow['Cow'/91, l='MpServer', x=789,97, y=4,00, z=-10,88], EntityChicken['Chicken'/150, l='MpServer', x=848,56, y=4,00, z=-7,59], EntityPig['Pig'/90, l='MpServer', x=784,25, y=4,00, z=-2,09], EntityCow['Cow'/151, l='MpServer', x=849,81, y=4,00, z=-13,78], EntityPig['Pig'/103, l='MpServer', x=811,91, y=4,00, z=-114,72], EntityCow['Cow'/38, l='MpServer', x=719,03, y=4,00, z=13,13], EntityChicken['Chicken'/39, l='MpServer', x=715,47, y=4,00, z=26,53], EntitySheep['Sheep'/36, l='MpServer', x=705,97, y=4,00, z=10,91], EntitySheep['Sheep'/42, l='MpServer', x=733,19, y=4,00, z=25,16], EntityChicken['Chicken'/110, l='MpServer', x=815,53, y=4,00, z=-34,44], EntityChicken['Chicken'/111, l='MpServer', x=820,44, y=4,00, z=-11,66], EntityPig['Pig'/108, l='MpServer', x=820,84, y=4,00, z=-127,50], EntityPig['Pig'/109, l='MpServer', x=817,44, y=4,00, z=-125,19], EntityPig['Pig'/106, l='MpServer', x=818,13, y=4,00, z=-130,88], EntityPig['Pig'/107, l='MpServer', x=829,19, y=4,00, z=-118,06], EntityClientPlayerMP['Player153'/182, l='MpServer', x=786,82, y=5,62, z=-52,55], EntityPig['Pig'/104, l='MpServer', x=802,81, y=4,00, z=-124,91], EntityPig['Pig'/105, l='MpServer', x=807,09, y=4,00, z=-119,72], EntitySheep['Sheep'/49, l='MpServer', x=746,22, y=4,00, z=-37,31], EntityChicken['Chicken'/113, l='MpServer', x=827,63, y=4,00, z=-10,59], EntityCow['Cow'/112, l='MpServer', x=824,06, y=4,00, z=-3,97], EntityPig['Pig'/127, l='MpServer', x=839,88, y=4,00, z=-118,91], EntityCow['Cow'/58, l='MpServer', x=752,13, y=4,00, z=-26,03]]
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:857)
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 7 (amd64) version 6.1
Java Version: 1.7.0_51, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 920859856 bytes (878 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
AABB Pool Size: 10006 (560336 bytes; 0 MB) allocated, 2 (112 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP v9.03 FML v7.2.165.1065 Minecraft Forge 10.12.1.1065 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.165.1065} [Forge Mod Loader] (forgeBin-1.7.2-10.12.1.1065.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Forge{10.12.1.1065} [Minecraft Forge] (forgeBin-1.7.2-10.12.1.1065.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
extendedobsidian{1.0} [Extended Obsidian] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Launched Version: 1.6
LWJGL: 2.9.0
OpenGL: AMD Radeon HD 7570 GL version 4.2.11476 Compatibility Profile Context, ATI Technologies Inc.
Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Packs: []
Current Language: ~~ERROR~~ NullPointerException: null
Profiler Position: N/A (disabled)
Vec3 Pool Size: 167 (9352 bytes; 0 MB) allocated, 21 (1176 bytes; 0 MB) used
Anisotropic Filtering: Off (1)

Posted

You don't use IDs for neither block nor items at all!

The way of doing things now is to use the instances directly, e.g.

// new ItemStack
new ItemStack(MyItems.anItemInstance, 1)

//compare if a stack has item
stack.getItem() == MyItems.anItemInstance

 

If you need to compare a block with an ItemStack, use

stack.getItem() == Item.getItemFromBlock(MyBlocks.aBlockInstance)

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

You don't use IDs for neither block nor items at all!

The way of doing things now is to use the instances directly, e.g.

// new ItemStack
new ItemStack(MyItems.anItemInstance, 1)

//compare if a stack has item
stack.getItem() == MyItems.anItemInstance

 

If you need to compare a block with an ItemStack, use

stack.getItem() == Item.getItemFromBlock(MyBlocks.aBlockInstance)

 

Hi! Thank you for the response.

I don't really under stand where to put the "compare if a stack has item."

And by "MyItems" I assumed it was where the items were registered and all that?

And the "anItemInstance" would for my case be the "itemDiamondChisel"?

 

Well, this is what I've tried:

 

Item class:

package com.obsidiancraft.item;

import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

import com.obsidiancraft.core.CoreMod;

public class itemDiamondChisel extends Item {

private ItemStack emptyItem = null;
private static int maxDamage;

    public itemDiamondChisel() {

        setMaxDamage(63);
        this.setMaxStackSize(1);
        this.setNoRepair();
        this.setCreativeTab(CoreMod.ExtendedObsidianTab);
    }
    
    @Override
    public boolean hasContainerItem() {
    return true;
    }
    
    public void setEmptyItem(ItemStack ei) {
    	if(ei.getItemDamage()<1) {
    	   this.emptyItem = ei;	
    	}
    }
    
    public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack) {
    return false;
    }

    public static ItemStack copyStack(ItemStack stack) {
    return new ItemStack(CoreMod.itemDiamondChisel, 1);
    }

public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean i) {
    	list.add("\u00A77" + (stack.getMaxDamage() - stack.getItemDamage() +1) + " Uses left");
    }
}

 

Main Class:

package com.obsidiancraft.core;

import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.oredict.OreDictionary;

import com.obsidiancraft.block.blockObsidianBrick;
import com.obsidiancraft.item.BasicItem;
import com.obsidiancraft.item.GlowingItem;
import com.obsidiancraft.item.itemDiamondChisel;

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.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;

@Mod(modid = CoreMod.modid, name = CoreMod.name, version = CoreMod.version)
public class CoreMod {
@Instance
public static CoreMod instance;

    public static final String modid = "extendedobsidian";
    public static final String name = "Extended Obsidian";
    public static final String version = "1.0";
    
    //Creative Tab
    public static CreativeTabs ExtendedObsidianTab = new CreativeTabs("ExtendedObsidian") {
    	public Item getTabIconItem() {
    		return Item.getItemFromBlock(blockObsidianBrick);
    		}
    	};
    
    //Tool material
    	
    public static ToolMaterial toolMaterialOT1;
    	
    //Armor material
    	
    public static ArmorMaterial armorMaterialOT1;
    	
    //Blocks
    public static Block blockObsidianBrick;
    
    //Items
    public static Item itemDiamondChisel;
    public static Item itemObsidianIngot;
    public static Item itemObsidianFlake;
    public static Item itemObsidianIngotInfused;
    
    //Tools
    
    public static Item toolOPickaxeT1;
    public static Item toolOShovelT1;
    public static Item toolOAxeT1;
    public static Item toolOSwordT1;
    public static Item toolOHoeT1;
    
    //Armors
    
    public static Item armorOHelmT1;
    public static Item armorOBodyT1;
    public static Item armorOLegsT1;
    public static Item armorOBootsT1;
    	
    @EventHandler
    public void preInit(FMLPreInitializationEvent event) {
    	
    	//Blocks
    	blockObsidianBrick = new blockObsidianBrick().setBlockName("blockObsidianBrick");
    	GameRegistry.registerBlock(blockObsidianBrick, blockObsidianBrick.getUnlocalizedName().substring(5));
    	
    	//Items
    	itemDiamondChisel = new itemDiamondChisel().setUnlocalizedName("itemDiamondChisel").setTextureName(CoreMod.modid + ":" + "itemDiamondChisel");
    	GameRegistry.registerItem(itemDiamondChisel, "itemDiamondChisel");
    	
    	itemObsidianIngot = new BasicItem().setUnlocalizedName("itemObsidianIngot").setTextureName(CoreMod.modid + ":" + "itemObsidianIngot");
    	GameRegistry.registerItem(itemObsidianIngot, "itemObsidianIngot");
    	
    	itemObsidianFlake = new BasicItem().setUnlocalizedName("itemObsidianFlake").setTextureName(CoreMod.modid + ":" + "itemObsidianFlake");
    	GameRegistry.registerItem(itemObsidianFlake, "itemObsidianFlake");
    	
    	itemObsidianIngotInfused = new GlowingItem().setUnlocalizedName("itemObsidianIngotInfused").setTextureName(CoreMod.modid + ":" + "itemObsidianIngot");
    	GameRegistry.registerItem(itemObsidianIngotInfused, "itemObsidianIngotInfused");
    	
    	//Tools
    	
    	toolOPickaxeT1 = new BasicItem().setUnlocalizedName("toolOPickaxeT1").setTextureName(CoreMod.modid + ":" + "toolOPickaxeT1");
    	toolOShovelT1 = new BasicItem().setUnlocalizedName("toolOShovelT1").setTextureName(CoreMod.modid + ":" + "toolOShovelT1");
    	toolOAxeT1 = new BasicItem().setUnlocalizedName("toolOAxeT1").setTextureName(CoreMod.modid + ":" + "toolOAxeT1");
    	toolOSwordT1 = new BasicItem().setUnlocalizedName("toolOSwordT1").setTextureName(CoreMod.modid + ":" + "toolOSwordT1");
    	toolOHoeT1 = new BasicItem().setUnlocalizedName("toolOHoeT1").setTextureName(CoreMod.modid + ":" + "toolOHoeT1");
    	
    	//Armors
    	
    	
    	
    	//EnumTools
    	
    	toolMaterialOT1 = EnumHelper.addToolMaterial("Obsidian Tools Tier 1", 3, 2753, 10.5F, 8.5F, 25);
    	
    	//EnumArmors
    	
    	armorMaterialOT1 = EnumHelper.addArmorMaterial("", 1350, new int[]{5, 6, 2, 5}, 25);
    	
    }
    
    @EventHandler
    public void Init(FMLInitializationEvent event) {

    //Recipes
    	//shaped
    	GameRegistry.addShapedRecipe(new ItemStack(itemDiamondChisel), new Object[]{"XC", 'X', Items.diamond, 'C', new ItemStack(Items.stick, 1, OreDictionary.WILDCARD_VALUE)});
    	GameRegistry.addShapedRecipe(new ItemStack(itemObsidianIngot), new Object[]{"#X#", "XXX", "#X#", 'X', itemObsidianFlake});
    	//shapeless
    	GameRegistry.addShapelessRecipe(new ItemStack(blockObsidianBrick), new Object[]{new ItemStack(itemDiamondChisel, 1, OreDictionary.WILDCARD_VALUE), Blocks.stonebrick, Blocks.obsidian});
    	GameRegistry.addShapelessRecipe(new ItemStack(itemObsidianFlake, 2), new Object[]{new ItemStack(itemDiamondChisel, 1, OreDictionary.WILDCARD_VALUE), Blocks.obsidian});
    	//smelting
    }
    
    @EventHandler
    public void postInit(FMLPostInitializationEvent event) {
    }
}

Posted

The "compare if a stack has item" is just an example, if you wanna compare if an itemstack contains a specific item.

MyItems is the class where you save your item / block instances. I personally have them in a seperate class outside of the @Mod annotated class for cleaner coding, but you can do it your way.

Yes, it would be itemDiamondChisel then.

 

The code you posted seems good, are there any problems with it?

 

However, you may consider removing the substring(5) from this line:

GameRegistry.registerBlock(blockObsidianBrick, blockObsidianBrick.getUnlocalizedName().substring(5));

 

since it's unnecessary and can cause problems (you register your block with the name "block", due to the substring, and if an other mod does the same, or you add another block with the unlocalized name "blockAnotherOne" (which, again, results in "block"), it will cause problems)

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

The "compare if a stack has item" is just an example, if you wanna compare if an itemstack contains a specific item.

MyItems is the class where you save your item / block instances. I personally have them in a seperate class outside of the @Mod annotated class for cleaner coding, but you can do it your way.

Yes, it would be itemDiamondChisel then.

 

The code you posted seems good, are there any problems with it?

 

However, you may consider removing the substring(5) from this line:

GameRegistry.registerBlock(blockObsidianBrick, blockObsidianBrick.getUnlocalizedName().substring(5));

 

since it's unnecessary and can cause problems (you register your block with the name "block", due to the substring, and if an other mod does the same, or you add another block with the unlocalized name "blockAnotherOne" (which, again, results in "block"), it will cause problems)

 

Yes there is a problem, it just crashes when I try to use it in crafting recipes.

 

Crashlog:

---- Minecraft Crash Report ----
// On the bright side, I bought you a teddy bear!

Time: 2014-05-02 15:08
Description: Updating screen events

java.lang.NullPointerException: Updating screen events
at net.minecraft.item.ItemStack.isItemStackDamageable(ItemStack.java:194)
at net.minecraft.inventory.SlotCrafting.onPickupFromSlot(SlotCrafting.java:124)
at net.minecraft.inventory.Container.slotClick(SourceFile:238)
at net.minecraft.client.multiplayer.PlayerControllerMP.windowClick(PlayerControllerMP.java:419)
at net.minecraft.client.gui.inventory.GuiContainer.handleMouseClick(GuiContainer.java:638)
at net.minecraft.client.gui.inventory.GuiContainer.mouseClicked(GuiContainer.java:392)
at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:289)
at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:256)
at net.minecraft.client.Minecraft.runTick(Minecraft.java:1579)
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 net.minecraft.item.ItemStack.isItemStackDamageable(ItemStack.java:194)
at net.minecraft.inventory.SlotCrafting.onPickupFromSlot(SlotCrafting.java:124)
at net.minecraft.inventory.Container.slotClick(SourceFile:238)
at net.minecraft.client.multiplayer.PlayerControllerMP.windowClick(PlayerControllerMP.java:419)
at net.minecraft.client.gui.inventory.GuiContainer.handleMouseClick(GuiContainer.java:638)
at net.minecraft.client.gui.inventory.GuiContainer.mouseClicked(GuiContainer.java:392)
at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:289)
at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:256)

-- Affected screen --
Details:
Screen name: net.minecraft.client.gui.inventory.GuiCrafting

-- Affected level --
Details:
Level name: MpServer
All players: 1 total; [EntityClientPlayerMP['lliinnkk10'/170, l='MpServer', x=786,52, y=5,62, z=-54,36]]
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: (780,4,-66), Chunk: (at 12,0,14 in 48,-5; contains blocks 768,0,-80 to 783,255,-65), Region: (1,-1; contains chunks 32,-32 to 63,-1, blocks 512,0,-512 to 1023,255,-1)
Level time: 27725 game time, 27725 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: 39 total; [EntityChicken['Chicken'/140, l='MpServer', x=851,47, y=4,00, z=-47,38], EntityCow['Cow'/76, l='MpServer', x=771,03, y=4,00, z=-7,94], EntityChicken['Chicken'/128, l='MpServer', x=836,47, y=4,00, z=24,38], EntityVillager['Villager'/78, l='MpServer', x=769,69, y=5,00, z=21,28], EntityPig['Pig'/72, l='MpServer', x=772,69, y=4,00, z=-24,88], EntityClientPlayerMP['lliinnkk10'/170, l='MpServer', x=786,52, y=5,62, z=-54,36], EntityCow['Cow'/73, l='MpServer', x=781,94, y=4,00, z=-17,97], EntityCow['Cow'/74, l='MpServer', x=786,22, y=4,00, z=-22,81], EntitySheep['Sheep'/75, l='MpServer', x=776,41, y=4,00, z=-4,16], EntityPig['Pig'/85, l='MpServer', x=798,31, y=4,00, z=-130,03], EntityChicken['Chicken'/92, l='MpServer', x=813,59, y=4,00, z=21,47], EntityPig['Pig'/89, l='MpServer', x=809,31, y=4,00, z=-130,84], EntityPig['Pig'/88, l='MpServer', x=793,22, y=4,00, z=-12,06], EntityBat['Bat'/91, l='MpServer', x=801,38, y=12,88, z=13,56], EntityChicken['Chicken'/102, l='MpServer', x=828,09, y=4,00, z=-8,78], EntityChicken['Chicken'/103, l='MpServer', x=825,47, y=4,00, z=-15,53], EntityChicken['Chicken'/100, l='MpServer', x=823,63, y=4,00, z=-11,41], EntityChicken['Chicken'/101, l='MpServer', x=818,56, y=4,00, z=-9,63], EntityPig['Pig'/98, l='MpServer', x=820,16, y=4,00, z=-133,97], EntityChicken['Chicken'/99, l='MpServer', x=822,44, y=4,00, z=-36,59], EntityPig['Pig'/96, l='MpServer', x=827,59, y=4,00, z=-120,16], EntityChicken['Chicken'/36, l='MpServer', x=717,47, y=4,00, z=15,59], EntityPig['Pig'/97, l='MpServer', x=823,09, y=4,00, z=-128,53], EntitySheep['Sheep'/40, l='MpServer', x=731,66, y=4,00, z=-72,81], EntityCow['Cow'/104, l='MpServer', x=820,28, y=4,00, z=-5,69], EntityCow['Cow'/105, l='MpServer', x=817,50, y=4,00, z=24,72], EntityCow['Cow'/51, l='MpServer', x=736,25, y=4,00, z=13,63], EntityCow['Cow'/50, l='MpServer', x=750,97, y=4,00, z=-30,13], EntitySheep['Sheep'/49, l='MpServer', x=749,06, y=4,00, z=-23,03], EntitySheep['Sheep'/52, l='MpServer', x=746,84, y=4,00, z=17,06], EntityCow['Cow'/127, l='MpServer', x=833,50, y=4,00, z=-4,25], EntitySheep['Sheep'/59, l='MpServer', x=756,13, y=4,00, z=-22,53], EntityChicken['Chicken'/126, l='MpServer', x=838,59, y=4,00, z=-31,34], EntityCow['Cow'/125, l='MpServer', x=839,22, y=4,00, z=-16,78], EntityChicken['Chicken'/124, l='MpServer', x=832,53, y=4,00, z=-21,66], EntityCow['Cow'/123, l='MpServer', x=843,84, y=4,00, z=-32,63], EntityPig['Pig'/122, l='MpServer', x=834,84, y=4,00, z=-132,13], EntityVillager['Villager'/61, l='MpServer', x=761,50, y=4,00, z=22,25], EntityPig['Pig'/60, l='MpServer', x=753,09, y=4,00, z=-23,81]]
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:857)
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 7 (amd64) version 6.1
Java Version: 1.7.0_51, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 765152248 bytes (729 MB) / 1004011520 bytes (957 MB) up to 2077753344 bytes (1981 MB)
JVM Flags: 3 total; -Xincgc -Xmx2048M -Xms1024M
AABB Pool Size: 18006 (1008336 bytes; 0 MB) allocated, 2 (112 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP v9.03 FML v7.2.165.1065 Minecraft Forge 10.12.1.1065 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.165.1065} [Forge Mod Loader] (forgeBin-1.7.2-10.12.1.1065.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Forge{10.12.1.1065} [Minecraft Forge] (forgeBin-1.7.2-10.12.1.1065.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
extendedobsidian{1.0} [Extended Obsidian] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Launched Version: 1.6
LWJGL: 2.9.0
OpenGL: AMD Radeon HD 7570 GL version 4.2.11476 Compatibility Profile Context, ATI Technologies Inc.
Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Packs: []
Current Language: ~~ERROR~~ NullPointerException: null
Profiler Position: N/A (disabled)
Vec3 Pool Size: 136 (7616 bytes; 0 MB) allocated, 21 (1176 bytes; 0 MB) used
Anisotropic Filtering: Off (1)

 

Item Class:

package com.obsidiancraft.item;

import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

import com.obsidiancraft.core.CoreMod;

public class itemDiamondChisel extends Item {

private ItemStack emptyItem = null;
private static int maxDamage;

    public itemDiamondChisel() {

        setMaxDamage(63);
        this.setMaxStackSize(1);
        this.setNoRepair();
        this.setCreativeTab(CoreMod.ExtendedObsidianTab);
    }
    
    @Override
    public boolean hasContainerItem() {
    return true;
    }
    
    public void setEmptyItem(ItemStack ei) {
    	if(ei.getItemDamage()<1) {
    	   this.emptyItem = ei;	
    	}
    }
    
    public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack) {
    return false;
    }

    public static ItemStack copyStack(ItemStack stack) {
    return new ItemStack(CoreMod.itemDiamondChisel, 1);
    }

public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean i) {
    	list.add("\u00A77" + (stack.getMaxDamage() - stack.getItemDamage() +1) + " Uses left");
    }
}

 

Main Class:

package com.obsidiancraft.core;

import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;

import com.obsidiancraft.block.blockObsidianBrick;
import com.obsidiancraft.item.BasicItem;
import com.obsidiancraft.item.GlowingItem;
import com.obsidiancraft.item.itemDiamondChisel;

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.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;

@Mod(modid = CoreMod.modid, name = CoreMod.name, version = CoreMod.version)
public class CoreMod {
@Instance
public static CoreMod instance;

    public static final String modid = "extendedobsidian";
    public static final String name = "Extended Obsidian";
    public static final String version = "1.0";
    
    //Creative Tab
    public static CreativeTabs ExtendedObsidianTab = new CreativeTabs("ExtendedObsidian") {
    	public Item getTabIconItem() {
    		return Item.getItemFromBlock(blockObsidianBrick);
    		}
    	};
    
    //Tool material
    	
    public static ToolMaterial toolMaterialOT1;
    	
    //Armor material
    	
    public static ArmorMaterial armorMaterialOT1;
    	
    //Blocks
    public static Block blockObsidianBrick;
    
    //Items
    public static Item itemDiamondChisel;
    public static Item itemObsidianIngot;
    public static Item itemObsidianFlake;
    public static Item itemObsidianIngotInfused;
    
    //Tools
    
    public static Item toolOPickaxeT1;
    public static Item toolOShovelT1;
    public static Item toolOAxeT1;
    public static Item toolOSwordT1;
    public static Item toolOHoeT1;
    
    //Armors
    
    public static Item armorOHelmT1;
    public static Item armorOBodyT1;
    public static Item armorOLegsT1;
    public static Item armorOBootsT1;
    	
    @EventHandler
    public void preInit(FMLPreInitializationEvent event) {
    	
    	//Blocks
    	blockObsidianBrick = new blockObsidianBrick().setBlockName("blockObsidianBrick");
    	GameRegistry.registerBlock(blockObsidianBrick, blockObsidianBrick.getUnlocalizedName());
    	
    	//Items
    	itemDiamondChisel = new itemDiamondChisel().setUnlocalizedName("itemDiamondChisel").setTextureName(CoreMod.modid + ":" + "itemDiamondChisel");
    	GameRegistry.registerItem(itemDiamondChisel, "itemDiamondChisel");
    	
    	itemObsidianIngot = new BasicItem().setUnlocalizedName("itemObsidianIngot").setTextureName(CoreMod.modid + ":" + "itemObsidianIngot");
    	GameRegistry.registerItem(itemObsidianIngot, "itemObsidianIngot");
    	
    	itemObsidianFlake = new BasicItem().setUnlocalizedName("itemObsidianFlake").setTextureName(CoreMod.modid + ":" + "itemObsidianFlake");
    	GameRegistry.registerItem(itemObsidianFlake, "itemObsidianFlake");
    	
    	itemObsidianIngotInfused = new GlowingItem().setUnlocalizedName("itemObsidianIngotInfused").setTextureName(CoreMod.modid + ":" + "itemObsidianIngot");
    	GameRegistry.registerItem(itemObsidianIngotInfused, "itemObsidianIngotInfused");
    	
    	//Tools

    	
    	
    	//Armors
    	
    	
    	
    	//EnumTools
    	


    	//EnumArmors
    	
    	
    	
    }
    
    @EventHandler
    public void Init(FMLInitializationEvent event) {

    //Recipes
    	//shaped
    	GameRegistry.addShapedRecipe(new ItemStack(itemDiamondChisel), new Object[]{"XC", 'X', Items.diamond, 'C', new ItemStack(Items.stick, 1, OreDictionary.WILDCARD_VALUE)});
    	GameRegistry.addShapedRecipe(new ItemStack(itemObsidianIngot), new Object[]{"#X#", "XXX", "#X#", 'X', itemObsidianFlake});
    	//shapeless
    	GameRegistry.addShapelessRecipe(new ItemStack(blockObsidianBrick), new Object[]{new ItemStack(itemDiamondChisel, 1, OreDictionary.WILDCARD_VALUE), Blocks.stonebrick, Blocks.obsidian});
    	GameRegistry.addShapelessRecipe(new ItemStack(itemObsidianFlake, 2), new Object[]{new ItemStack(itemDiamondChisel, 1, OreDictionary.WILDCARD_VALUE), Blocks.obsidian});
    	GameRegistry.addShapelessRecipe(new ItemStack(Blocks.obsidian), new Object[]{Items.lava_bucket, Items.lava_bucket, Items.water_bucket, Items.water_bucket});
    	//smelting
    }
    
    @EventHandler
    public void postInit(FMLPostInitializationEvent event) {
    }
}

Posted

You don't call the super constructor in your items constructor... maybe that's the problem.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

You don't call the super constructor in your items constructor... maybe that's the problem.

 

Nope, still crashes..

I really appriceate the help though.

 

Item class:

package com.obsidiancraft.item;

import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

import com.obsidiancraft.core.CoreMod;

public class itemDiamondChisel extends Item {

private ItemStack emptyItem = null;
private static int maxDamage;

    public itemDiamondChisel() {

    	super();
        setMaxDamage(511);
        this.setMaxStackSize(1);
        this.setNoRepair();
        this.setCreativeTab(CoreMod.ExtendedObsidianTab);
    }
    
    @Override
    public boolean hasContainerItem() {
    return true;
    }
    
    public void setEmptyItem(ItemStack ei) {
    	if(ei.getItemDamage()<1) {
    	   this.emptyItem = ei;	
    	}
    }
    
    public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack) {
    return false;
    }

    public static ItemStack copyStack(ItemStack stack) {
    return new ItemStack(CoreMod.itemDiamondChisel, 1);
    }

public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean i) {
    	list.add("\u00A77" + (stack.getMaxDamage() - stack.getItemDamage() +1) + " Uses left");
    }
}

 

Crashlog:

---- Minecraft Crash Report ----
// Hi. I'm Minecraft, and I'm a crashaholic.

Time: 2014-05-02 15:38
Description: Updating screen events

java.lang.NullPointerException: Updating screen events
at net.minecraft.item.ItemStack.isItemStackDamageable(ItemStack.java:194)
at net.minecraft.inventory.SlotCrafting.onPickupFromSlot(SlotCrafting.java:124)
at net.minecraft.inventory.Container.slotClick(SourceFile:238)
at net.minecraft.client.multiplayer.PlayerControllerMP.windowClick(PlayerControllerMP.java:419)
at net.minecraft.client.gui.inventory.GuiContainer.handleMouseClick(GuiContainer.java:638)
at net.minecraft.client.gui.inventory.GuiContainer.mouseClicked(GuiContainer.java:392)
at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:289)
at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:256)
at net.minecraft.client.Minecraft.runTick(Minecraft.java:1579)
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 net.minecraft.item.ItemStack.isItemStackDamageable(ItemStack.java:194)
at net.minecraft.inventory.SlotCrafting.onPickupFromSlot(SlotCrafting.java:124)
at net.minecraft.inventory.Container.slotClick(SourceFile:238)
at net.minecraft.client.multiplayer.PlayerControllerMP.windowClick(PlayerControllerMP.java:419)
at net.minecraft.client.gui.inventory.GuiContainer.handleMouseClick(GuiContainer.java:638)
at net.minecraft.client.gui.inventory.GuiContainer.mouseClicked(GuiContainer.java:392)
at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:289)
at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:256)

-- Affected screen --
Details:
Screen name: net.minecraft.client.gui.inventory.GuiCrafting

-- Affected level --
Details:
Level name: MpServer
All players: 1 total; [EntityClientPlayerMP['lliinnkk10'/168, l='MpServer', x=786,52, y=5,62, z=-54,36]]
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: (780,4,-66), Chunk: (at 12,0,14 in 48,-5; contains blocks 768,0,-80 to 783,255,-65), Region: (1,-1; contains chunks 32,-32 to 63,-1, blocks 512,0,-512 to 1023,255,-1)
Level time: 30690 game time, 30690 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: 40 total; [EntityChicken['Chicken'/139, l='MpServer', x=851,47, y=4,00, z=-47,38], EntityCow['Cow'/76, l='MpServer', x=771,03, y=4,00, z=-7,94], EntityVillager['Villager'/78, l='MpServer', x=769,69, y=5,00, z=21,28], EntityCow['Cow'/73, l='MpServer', x=781,41, y=4,00, z=-16,75], EntityCow['Cow'/74, l='MpServer', x=782,59, y=4,00, z=-14,31], EntitySheep['Sheep'/75, l='MpServer', x=776,41, y=4,00, z=-4,16], EntityPig['Pig'/85, l='MpServer', x=798,31, y=4,00, z=-130,03], EntityPig['Pig'/87, l='MpServer', x=793,22, y=4,00, z=-12,06], EntityPig['Pig'/93, l='MpServer', x=820,16, y=4,00, z=-133,97], EntityPig['Pig'/95, l='MpServer', x=834,09, y=4,00, z=-122,09], EntityPig['Pig'/94, l='MpServer', x=827,53, y=4,00, z=-116,25], EntityPig['Pig'/88, l='MpServer', x=809,31, y=4,00, z=-130,84], EntityPig['Pig'/90, l='MpServer', x=800,09, y=4,00, z=-132,75], EntityChicken['Chicken'/102, l='MpServer', x=827,56, y=4,00, z=15,56], EntityChicken['Chicken'/103, l='MpServer', x=814,53, y=4,00, z=2,59], EntityChicken['Chicken'/100, l='MpServer', x=826,47, y=4,00, z=-8,59], EntityClientPlayerMP['lliinnkk10'/168, l='MpServer', x=786,52, y=5,62, z=-54,36], EntityCow['Cow'/101, l='MpServer', x=823,69, y=4,00, z=-0,81], EntityChicken['Chicken'/98, l='MpServer', x=816,53, y=4,00, z=-15,44], EntityChicken['Chicken'/99, l='MpServer', x=824,63, y=4,00, z=-1,59], EntityChicken['Chicken'/36, l='MpServer', x=717,47, y=4,00, z=15,59], EntityChicken['Chicken'/96, l='MpServer', x=822,44, y=4,00, z=-36,59], EntityChicken['Chicken'/97, l='MpServer', x=823,63, y=4,00, z=-11,41], EntityCow['Cow'/42, l='MpServer', x=733,94, y=4,00, z=16,84], EntitySheep['Sheep'/40, l='MpServer', x=731,66, y=4,00, z=-72,81], EntityCow['Cow'/41, l='MpServer', x=737,34, y=4,00, z=20,28], EntityCow['Cow'/104, l='MpServer', x=818,78, y=4,00, z=27,94], EntityChicken['Chicken'/105, l='MpServer', x=816,41, y=4,00, z=25,59], EntitySheep['Sheep'/51, l='MpServer', x=750,97, y=4,00, z=-17,03], EntitySheep['Sheep'/50, l='MpServer', x=749,06, y=4,00, z=-23,03], EntityCow['Cow'/49, l='MpServer', x=738,72, y=4,00, z=-40,78], EntitySheep['Sheep'/52, l='MpServer', x=746,84, y=4,00, z=17,06], EntityCow['Cow'/125, l='MpServer', x=833,50, y=4,00, z=-4,25], EntityChicken['Chicken'/124, l='MpServer', x=838,59, y=4,00, z=-31,34], EntityVillager['Villager'/63, l='MpServer', x=761,50, y=4,00, z=22,25], EntityCow['Cow'/123, l='MpServer', x=839,22, y=4,00, z=-16,78], EntityChicken['Chicken'/122, l='MpServer', x=832,53, y=4,00, z=-21,66], EntityPig['Pig'/62, l='MpServer', x=758,91, y=4,00, z=-28,06], EntityCow['Cow'/121, l='MpServer', x=843,84, y=4,00, z=-32,63], EntityPig['Pig'/61, l='MpServer', x=753,09, y=4,00, z=-23,81]]
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:857)
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 7 (amd64) version 6.1
Java Version: 1.7.0_51, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 831514512 bytes (792 MB) / 1004011520 bytes (957 MB) up to 2077753344 bytes (1981 MB)
JVM Flags: 3 total; -Xincgc -Xmx2048M -Xms1024M
AABB Pool Size: 18006 (1008336 bytes; 0 MB) allocated, 2 (112 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP v9.03 FML v7.2.165.1065 Minecraft Forge 10.12.1.1065 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.165.1065} [Forge Mod Loader] (forgeBin-1.7.2-10.12.1.1065.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Forge{10.12.1.1065} [Minecraft Forge] (forgeBin-1.7.2-10.12.1.1065.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
extendedobsidian{1.0} [Extended Obsidian] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Launched Version: 1.6
LWJGL: 2.9.0
OpenGL: AMD Radeon HD 7570 GL version 4.2.11476 Compatibility Profile Context, ATI Technologies Inc.
Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Packs: []
Current Language: ~~ERROR~~ NullPointerException: null
Profiler Position: N/A (disabled)
Vec3 Pool Size: 806 (45136 bytes; 0 MB) allocated, 21 (1176 bytes; 0 MB) used
Anisotropic Filtering: Off (1)

Posted

GameRegistry.addShapedRecipe(new ItemStack(itemObsidianIngot), new Object[]{"#X#", "XXX", "#X#", 'X', itemObsidianFlake});

That recipe is incomplete. You are defining only one component.

 

Also, you should use capital as first letters for classes names.

Posted

GameRegistry.addShapedRecipe(new ItemStack(itemObsidianIngot), new Object[]{"#X#", "XXX", "#X#", 'X', itemObsidianFlake});

That recipe is incomplete. You are defining only one component.

 

Also, you should use capital as first letters for classes names.

 

The first one: This shouldn't be a problem. Missing components are handled exactly the same as a space -> Missing character = empty slot

what I do see is you override hasContainerItem and don't override getContainerItem and return an ItemStack there -> resulting in a NullPointerException.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

GameRegistry.addShapedRecipe(new ItemStack(itemObsidianIngot), new Object[]{"#X#", "XXX", "#X#", 'X', itemObsidianFlake});

That recipe is incomplete. You are defining only one component.

 

Also, you should use capital as first letters for classes names.

 

The first one: This shouldn't be a problem. Missing components are handled exactly the same as a space -> Missing character = empty slot

what I do see is you override hasContainerItem and don't override getContainerItem and return an ItemStack there -> resulting in a NullPointerException.

 

I have tried a few different things but non seems to be working:/

I think I have done what you said, I also tried not to override anything and I added "this.isDamageable();" in the constructor.

It still crashes whenever I try and craft with it...

 

Item Class:

package com.obsidiancraft.item;

import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

import com.obsidiancraft.core.CoreMod;

public class itemDiamondChisel extends Item {

private ItemStack emptyItem = null;
private static int maxDamage;

    public itemDiamondChisel() {

    	super();
        setMaxDamage(511);
        this.setMaxStackSize(1);
        this.setNoRepair();
        this.setCreativeTab(CoreMod.ExtendedObsidianTab);
        this.isDamageable();
    }
    
    @Override
    public boolean hasContainerItem() {
    return true;
    }
    
    public void setEmptyItem(ItemStack ei) {
    	if(ei.getItemDamage()<1) {
    	   this.emptyItem = ei;	
    	}
    }
    
    @Override
    public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack) {
    return false;
    }

    public static ItemStack copyStack(ItemStack stack) {
    return new ItemStack(CoreMod.itemDiamondChisel, 1);
    }

public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean i) {
    	list.add("\u00A77" + (stack.getMaxDamage() - stack.getItemDamage() +1) + " Uses left");
    }
}

Posted

Yet you still override hasContainerItem and return true without overriding getContainerItem and return a valid ItemStack.

Either return false in hasContainerItem, or don't override it (remove the method) or override getContainerItem and return a valid ItemStack.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

Yet you still override hasContainerItem and return true without overriding getContainerItem and return a valid ItemStack.

Either return false in hasContainerItem, or don't override it (remove the method) or override getContainerItem and return a valid ItemStack.

 

Yeah, this is really confusing...

I tried everything you said, at one point it crashed with the same crashlog and one time I got it to work but it removed itemDiamondChisel on first craft.

 

Item Class:

package com.obsidiancraft.item;

import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

import com.obsidiancraft.core.CoreMod;

public class itemDiamondChisel extends Item {

private ItemStack emptyItem = null;
private static int maxDamage;

    public itemDiamondChisel() {

    	super();
        setMaxDamage(511);
        this.setMaxStackSize(1);
        this.setNoRepair();
        this.setCreativeTab(CoreMod.ExtendedObsidianTab);
        this.isDamageable();
    }
    /*
    @Override
    public boolean hasContainerItem() {
    return true;
    }
    */
    public void setEmptyItem(ItemStack ei) {
    	if(ei.getItemDamage()<1) {
    	   this.emptyItem = ei;	
    	}
    }
    
    public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack) {
    return false;
    }

    public static ItemStack copyStack(ItemStack stack) {
    return new ItemStack(CoreMod.itemDiamondChisel, 1);
    }

public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean i) {
    	list.add("\u00A77" + (stack.getMaxDamage() - stack.getItemDamage() +1) + " Uses left");
    }
}

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.