Jump to content

[1.10.2] Custom crop crash


Egietje

Recommended Posts

When I right-click with my seeds on farm land the game crashes

My plant class:

package com.Egietje.degeweldigemod.blocks;

import java.util.Random;

import com.Egietje.degeweldigemod.init.CheeseItems;

import net.minecraft.block.BlockCrops;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class CheesePlant extends BlockCrops {
@Override
protected Item getSeed() {
	return CheeseItems.CHEESE_SEEDS;
}

@Override
protected Item getCrop() {
	return CheeseItems.CHEESE;
}
}

Block class:

package com.Egietje.degeweldigemod.init;

import com.Egietje.degeweldigemod.DeGeweldigeMod;
import com.Egietje.degeweldigemod.Reference;
import com.Egietje.degeweldigemod.blocks.*;

import net.minecraft.block.Block;
import net.minecraft.block.BlockWorkbench;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class CheeseBlocks {

public static Block CHEESE_BLOCK;
public static Block CHEESE_ORE;
public static Block CHEESE_ORE_NETHER;
public static Block CHEESE_ORE_END;
public static Block QUICK_CHEESE;
public static Block COMPLIMENT_MACHINE;
public static Block BELGIUM_FLAG;
public static Block CHEESE_PLANT;

public CheeseBlocks() {
	init();
	register();
}

public static void init() {
	CHEESE_ORE = new CheeseOre().setCreativeTab(DeGeweldigeMod.tabCheeseStuff).setHardness(2F);
	CHEESE_ORE_NETHER = new CheeseOreNether().setCreativeTab(DeGeweldigeMod.tabCheeseStuff).setHardness(2F);
	CHEESE_ORE_END = new CheeseOreEnd().setCreativeTab(DeGeweldigeMod.tabCheeseStuff).setHardness(2F);
	CHEESE_BLOCK = new Block(Material.ROCK).setCreativeTab(DeGeweldigeMod.tabCheeseStuff).setHardness(3F);
	QUICK_CHEESE = new QuickCheese().setHardness(4F);
	COMPLIMENT_MACHINE = new ComplimentsMachine().setCreativeTab(DeGeweldigeMod.tabCheeseStuff).setHardness(3F);
	BELGIUM_FLAG = new BelgiumFlag().setCreativeTab(DeGeweldigeMod.tabCheeseStuff).setHardness(2F);
	CHEESE_PLANT = new CheesePlant();

	CheeseUtils.setNames(CHEESE_ORE, "cheese_ore");
	CheeseUtils.setNames(CHEESE_ORE_NETHER, "cheese_ore_nether");
	CheeseUtils.setNames(CHEESE_ORE_END, "cheese_ore_end");
	CheeseUtils.setNames(CHEESE_BLOCK, "cheese_block");
	CheeseUtils.setNames(QUICK_CHEESE, "quick_cheese");
	CheeseUtils.setNames(COMPLIMENT_MACHINE, "compliment_machine");
	CheeseUtils.setNames(BELGIUM_FLAG, "belgium_flag");
	CheeseUtils.setNames(CHEESE_PLANT, "cheese_plant");
}	

public void register() {
	this.registerBlock(CHEESE_ORE);
	this.registerBlock(CHEESE_ORE_NETHER);
	this.registerBlock(CHEESE_ORE_END);
	this.registerBlock(CHEESE_BLOCK);
	this.registerBlock(QUICK_CHEESE);
	this.registerBlock(COMPLIMENT_MACHINE);
	this.registerBlock(BELGIUM_FLAG);
	this.registerBlock(CHEESE_PLANT);
}	

private void registerBlock(Block block) {
	GameRegistry.register(block);
	GameRegistry.register(new ItemBlock(block).setUnlocalizedName(block.getUnlocalizedName()).setRegistryName(block.getRegistryName()));
}
}

Item class:

package com.Egietje.degeweldigemod.init;

import com.Egietje.degeweldigemod.DeGeweldigeMod;
import com.Egietje.degeweldigemod.Reference;
import com.Egietje.degeweldigemod.items.*;
import com.Egietje.degeweldigemod.items.tools.*;

import net.minecraft.init.Blocks;
import net.minecraft.init.SoundEvents;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemHoe;
import net.minecraft.item.ItemPickaxe;
import net.minecraft.item.ItemSeeds;
import net.minecraft.item.ItemSpade;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class CheeseItems {
public static ToolMaterial cheese_tool_material;

public static ArmorMaterial cheese_armor_material;

public static Item CHEESE_SWORD;
public static Item CHEESE_PICKAXE;
public static Item CHEESE_AXE;
public static Item CHEESE_SHOVEL;
public static Item CHEESE_HOE;
public static Item CHEESE_FLY_STICK;
public static Item CHEESE_BOW;

public static Item CHEESE_HELMET;
public static Item CHEESE_CHESTPLATE;
public static Item CHEESE_LEGGINGS;
public static Item CHEESE_BOOTS;

public static Item CHEESE;
public static Item CHEESE_COOKED;
public static Item BREAD_CHEESE;
public static Item CHEESE_APPLE;
public static Item CHEESE_BUCKET;
public static Item CHEESE_SEEDS;

public static Item CHEESE_INGOT;
public static Item CHEESE_ARROW;

public CheeseItems() {
	init();
	register();
}

public static void init() {
	cheese_tool_material = EnumHelper.addToolMaterial("cheese_tool_material", 2, 1265, 7.0F, 2.5F, 17);

	cheese_armor_material = EnumHelper.addArmorMaterial("cheese_armor_material", "", 22, new int[] {3, 6, 8, 3}, 17, SoundEvents.BLOCK_SLIME_BREAK, 3);

	CHEESE_HELMET = new CheeseArmor(cheese_armor_material, EntityEquipmentSlot.HEAD).setCreativeTab(DeGeweldigeMod.tabCheeseStuff);
	CHEESE_CHESTPLATE = new CheeseArmor(cheese_armor_material, EntityEquipmentSlot.CHEST).setCreativeTab(DeGeweldigeMod.tabCheeseStuff);
	CHEESE_LEGGINGS = new CheeseArmor(cheese_armor_material, EntityEquipmentSlot.LEGS).setCreativeTab(DeGeweldigeMod.tabCheeseStuff);
	CHEESE_BOOTS = new CheeseArmor(cheese_armor_material, EntityEquipmentSlot.FEET).setCreativeTab(DeGeweldigeMod.tabCheeseStuff);

	CHEESE_SWORD = new CheeseSword(cheese_tool_material).setCreativeTab(DeGeweldigeMod.tabCheeseStuff);
	CHEESE_PICKAXE = new CheesePickaxe(cheese_tool_material).setCreativeTab(DeGeweldigeMod.tabCheeseStuff);
	CHEESE_AXE = new CheeseAxe(cheese_tool_material).setCreativeTab(DeGeweldigeMod.tabCheeseStuff);
	CHEESE_SHOVEL = new CheeseSpade(cheese_tool_material).setCreativeTab(DeGeweldigeMod.tabCheeseStuff);
	CHEESE_HOE = new CheeseHoe(cheese_tool_material).setCreativeTab(DeGeweldigeMod.tabCheeseStuff);
	CHEESE_FLY_STICK = new CheeseFlyStick().setCreativeTab(DeGeweldigeMod.tabCheeseStuff);
	CHEESE_BOW = new CheeseBow().setCreativeTab(DeGeweldigeMod.tabCheeseStuff);

	CHEESE = new ItemFood(4, 0.8F, false).setCreativeTab(DeGeweldigeMod.tabCheeseStuff);
	CHEESE_COOKED = new ItemFood(7, 1.3F, true).setCreativeTab(DeGeweldigeMod.tabCheeseStuff);
	BREAD_CHEESE = new ItemFood(15, 1.7F, true).setCreativeTab(DeGeweldigeMod.tabCheeseStuff);
	CHEESE_APPLE = new CheeseApple().setCreativeTab(DeGeweldigeMod.tabCheeseStuff);
	CHEESE_BUCKET = new CheeseBucket().setCreativeTab(DeGeweldigeMod.tabCheeseStuff);
	CHEESE_SEEDS = new ItemSeeds(CheeseBlocks.CHEESE_PLANT, Blocks.FARMLAND).setCreativeTab(DeGeweldigeMod.tabCheeseStuff);

	CHEESE_INGOT = new Item().setCreativeTab(DeGeweldigeMod.tabCheeseStuff);
	CHEESE_ARROW = new CheeseArrow().setCreativeTab(DeGeweldigeMod.tabCheeseStuff);

	CheeseUtils.setNames(CHEESE, "cheese");
	CheeseUtils.setNames(CHEESE_COOKED, "cheese_cooked");
	CheeseUtils.setNames(BREAD_CHEESE, "bread_cheese");
	CheeseUtils.setNames(CHEESE_APPLE, "cheese_apple");
	CheeseUtils.setNames(CHEESE_BUCKET, "cheese_bucket");
	CheeseUtils.setNames(CHEESE_SEEDS, "cheese_seeds");

	CheeseUtils.setNames(CHEESE_INGOT, "cheese_ingot");
	CheeseUtils.setNames(CHEESE_ARROW, "cheese_arrow");

	CheeseUtils.setNames(CHEESE_SWORD, "cheese_sword");
	CheeseUtils.setNames(CHEESE_PICKAXE, "cheese_pickaxe");
	CheeseUtils.setNames(CHEESE_AXE, "cheese_axe");
	CheeseUtils.setNames(CHEESE_SHOVEL, "cheese_shovel");
	CheeseUtils.setNames(CHEESE_HOE, "cheese_hoe");
	CheeseUtils.setNames(CHEESE_FLY_STICK, "cheese_fly_stick");
	CheeseUtils.setNames(CHEESE_BOW, "cheese_bow");

	CheeseUtils.setNames(CHEESE_HELMET, "cheese_helmet");
	CheeseUtils.setNames(CHEESE_CHESTPLATE, "cheese_chestplate");
	CheeseUtils.setNames(CHEESE_LEGGINGS, "cheese_leggings");
	CheeseUtils.setNames(CHEESE_BOOTS, "cheese_boots");
}	

public static void register() {
	GameRegistry.register(CHEESE_SWORD);
	GameRegistry.register(CHEESE_PICKAXE);
	GameRegistry.register(CHEESE_AXE);
	GameRegistry.register(CHEESE_SHOVEL);
	GameRegistry.register(CHEESE_HOE);
	GameRegistry.register(CHEESE_FLY_STICK);
	GameRegistry.register(CHEESE_BOW);

	GameRegistry.register(CHEESE_HELMET);
	GameRegistry.register(CHEESE_CHESTPLATE);
	GameRegistry.register(CHEESE_LEGGINGS);
	GameRegistry.register(CHEESE_BOOTS);

	GameRegistry.register(CHEESE);
	GameRegistry.register(CHEESE_COOKED);
	GameRegistry.register(BREAD_CHEESE);
	GameRegistry.register(CHEESE_APPLE);
	GameRegistry.register(CHEESE_BUCKET);
	GameRegistry.register(CHEESE_SEEDS);

	GameRegistry.register(CHEESE_INGOT);
	GameRegistry.register(CHEESE_ARROW);
}
}

Eclipse console:

[22:36:51] [server thread/FATAL]: Error executing task
java.util.concurrent.ExecutionException: java.lang.NullPointerException
at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.8.0_77]
at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.8.0_77]
at net.minecraft.util.Util.runTask(Util.java:26) [util.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:742) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) [integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536) [MinecraftServer.class:?]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_77]
Caused by: java.lang.NullPointerException
at net.minecraft.item.ItemSeeds.getPlant(ItemSeeds.java:52) ~[itemSeeds.class:?]
at net.minecraft.block.Block.canSustainPlant(Block.java:1825) ~[block.class:?]
at net.minecraft.item.ItemSeeds.onItemUse(ItemSeeds.java:31) ~[itemSeeds.class:?]
at net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(ForgeHooks.java:746) ~[ForgeHooks.class:?]
at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:158) ~[itemStack.class:?]
at net.minecraft.server.management.PlayerInteractionManager.processRightClickBlock(PlayerInteractionManager.java:509) ~[PlayerInteractionManager.class:?]
at net.minecraft.network.NetHandlerPlayServer.processRightClickBlock(NetHandlerPlayServer.java:706) ~[NetHandlerPlayServer.class:?]
at net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock.processPacket(CPacketPlayerTryUseItemOnBlock.java:68) ~[CPacketPlayerTryUseItemOnBlock.class:?]
at net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock.processPacket(CPacketPlayerTryUseItemOnBlock.java:13) ~[CPacketPlayerTryUseItemOnBlock.class:?]
at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) ~[PacketThreadUtil$1.class:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_77]
at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_77]
at net.minecraft.util.Util.runTask(Util.java:25) ~[util.class:?]
... 5 more

Link to comment
Share on other sites

$100 says you call CheeseItems.init() before calling CheeseBlocks.init()

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

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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