Jump to content

java.lang.NullPointerException: Unexpected error, Game Crash Creating Double slab by stacking single slabs


oRaiderzo

Recommended Posts

Hi,

 

I have been trying to create a custom Slab and have been able to get to the point where my slabs can be placed as half blocks (on both the top and bottom of a block) but the Game crashes when ever i stack them.

 

Any help figuring this out would be appreciated (I am a beginner to modding/Java but i do understand most of the basics) the Original code has come from HarryTechRevs (i was following his youtube tutorials and could find a slab one so i just modified the code he posted on github) https://github.com/HarryTechRevs/Minecraft-Modding-1.12

 

Error from Crash Report

Spoiler

---- Minecraft Crash Report ----
// Daisy, daisy...

Time: 12/9/18 4:03 PM
Description: Unexpected error

java.lang.NullPointerException: Unexpected error
    at net.minecraft.item.ItemSlab.makeState(ItemSlab.java:152)
    at net.minecraft.item.ItemSlab.tryPlace(ItemSlab.java:133)
    at net.minecraft.item.ItemSlab.onItemUse(ItemSlab.java:92)
    at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:201)
    at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:499)
    at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1693)
    at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2380)
    at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2146)
    at net.minecraft.client.Minecraft.runTick(Minecraft.java:1934)
    at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1187)
    at net.minecraft.client.Minecraft.run(Minecraft.java:441)
    at net.minecraft.client.main.Main.main(Main.java:118)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    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(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
    at GradleStart.main(GradleStart.java:25)


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

-- Head --
Thread: Client thread
Stacktrace:
    at net.minecraft.item.ItemSlab.makeState(ItemSlab.java:152)
    at net.minecraft.item.ItemSlab.tryPlace(ItemSlab.java:133)
    at net.minecraft.item.ItemSlab.onItemUse(ItemSlab.java:92)
    at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:201)
    at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:499)
    at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1693)
    at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2380)
    at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2146)

-- Affected level --
Details:
    Level name: MpServer
    All players: 1 total; [EntityPlayerSP['Player250'/142, l='MpServer', x=272.47, y=4.00, z=-98.67]]
    Chunk stats: MultiplayerChunkCache: 620, 620
    Level seed: 0
    Level generator: ID 01 - flat, ver 0. Features enabled: false
    Level generator options: 
    Level spawn location: World: (269,4,-111), Chunk: (at 13,0,1 in 16,-7; contains blocks 256,0,-112 to 271,255,-97), Region: (0,-1; contains chunks 0,-32 to 31,-1, blocks 0,0,-512 to 511,255,-1)
    Level time: 144552 game time, 1150 day time
    Level dimension: 0
    Level storage version: 0x00000 - Unknown?
    Level weather: Rain time: 0 (now: true), thunder time: 0 (now: false)
    Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false
    Forced entities: 65 total; [EntitySheep['Sheep'/32, l='MpServer', x=205.21, y=4.00, z=-131.45], EntitySheep['Sheep'/33, l='MpServer', x=207.23, y=4.00, z=-105.47], EntityHorse['Horse'/34, l='MpServer', x=205.08, y=4.00, z=-67.89], EntityHorse['Horse'/35, l='MpServer', x=202.24, y=4.00, z=-59.83], EntitySheep['Sheep'/36, l='MpServer', x=211.21, y=4.00, z=-100.17], EntityDonkey['Donkey'/37, l='MpServer', x=233.14, y=4.00, z=-171.97], EntityDonkey['Donkey'/38, l='MpServer', x=227.18, y=4.00, z=-173.49], EntitySheep['Sheep'/39, l='MpServer', x=232.71, y=4.00, z=-98.70], EntitySheep['Sheep'/40, l='MpServer', x=233.32, y=4.00, z=-49.82], EntityHorse['Horse'/41, l='MpServer', x=237.85, y=4.00, z=-49.76], EntityHorse['Horse'/42, l='MpServer', x=239.86, y=4.00, z=-33.84], EntityPig['Pig'/44, l='MpServer', x=234.62, y=4.00, z=-23.22], EntitySheep['Sheep'/48, l='MpServer', x=244.15, y=4.00, z=-145.78], EntityDonkey['Donkey'/49, l='MpServer', x=254.96, y=4.00, z=-136.47], EntityDonkey['Donkey'/50, l='MpServer', x=240.10, y=4.00, z=-116.48], EntityHorse['Horse'/51, l='MpServer', x=240.13, y=4.00, z=-75.83], EntityItemFrame['entity.ItemFrame.name'/53, l='MpServer', x=259.03, y=6.50, z=-112.50], EntityItemFrame['entity.ItemFrame.name'/54, l='MpServer', x=259.03, y=6.50, z=-113.50], EntityItemFrame['entity.ItemFrame.name'/55, l='MpServer', x=259.03, y=6.50, z=-114.50], EntityItemFrame['entity.ItemFrame.name'/56, l='MpServer', x=259.03, y=5.50, z=-112.50], EntityItemFrame['entity.ItemFrame.name'/57, l='MpServer', x=259.03, y=5.50, z=-113.50], EntityItemFrame['entity.ItemFrame.name'/58, l='MpServer', x=259.03, y=5.50, z=-114.50], EntityItemFrame['entity.ItemFrame.name'/59, l='MpServer', x=259.03, y=4.50, z=-113.50], EntityItemFrame['entity.ItemFrame.name'/60, l='MpServer', x=259.03, y=4.50, z=-112.50], EntityItemFrame['entity.ItemFrame.name'/61, l='MpServer', x=259.03, y=4.50, z=-114.50], EntityItemFrame['entity.ItemFrame.name'/62, l='MpServer', x=259.03, y=6.50, z=-115.50], EntityItemFrame['entity.ItemFrame.name'/63, l='MpServer', x=259.03, y=5.50, z=-115.50], EntityItemFrame['entity.ItemFrame.name'/64, l='MpServer', x=259.03, y=4.50, z=-115.50], EntityItemFrame['entity.ItemFrame.name'/65, l='MpServer', x=259.03, y=5.50, z=-103.50], EntityItemFrame['entity.ItemFrame.name'/66, l='MpServer', x=259.03, y=5.50, z=-107.50], EntityItemFrame['entity.ItemFrame.name'/67, l='MpServer', x=259.03, y=5.50, z=-109.50], EntityItemFrame['entity.ItemFrame.name'/68, l='MpServer', x=259.03, y=5.50, z=-106.50], EntityItemFrame['entity.ItemFrame.name'/69, l='MpServer', x=259.03, y=5.50, z=-108.50], EntityItemFrame['entity.ItemFrame.name'/70, l='MpServer', x=259.03, y=5.50, z=-110.50], EntityItemFrame['entity.ItemFrame.name'/71, l='MpServer', x=259.03, y=6.50, z=-106.50], EntityItemFrame['entity.ItemFrame.name'/72, l='MpServer', x=259.03, y=6.50, z=-107.50], EntityItemFrame['entity.ItemFrame.name'/73, l='MpServer', x=259.03, y=6.50, z=-108.50], EntityItemFrame['entity.ItemFrame.name'/74, l='MpServer', x=259.03, y=6.50, z=-109.50], EntityItemFrame['entity.ItemFrame.name'/75, l='MpServer', x=259.03, y=6.50, z=-110.50], EntityItemFrame['entity.ItemFrame.name'/76, l='MpServer', x=259.03, y=4.50, z=-110.50], EntityItemFrame['entity.ItemFrame.name'/77, l='MpServer', x=259.03, y=4.50, z=-109.50], EntityItemFrame['entity.ItemFrame.name'/78, l='MpServer', x=259.03, y=4.50, z=-108.50], EntityItemFrame['entity.ItemFrame.name'/79, l='MpServer', x=259.03, y=4.50, z=-107.50], EntityItemFrame['entity.ItemFrame.name'/80, l='MpServer', x=259.03, y=4.50, z=-106.50], EntityItemFrame['entity.ItemFrame.name'/81, l='MpServer', x=259.03, y=6.50, z=-103.50], EntityItemFrame['entity.ItemFrame.name'/82, l='MpServer', x=259.03, y=4.50, z=-103.50], EntityItemFrame['entity.ItemFrame.name'/83, l='MpServer', x=259.03, y=6.50, z=-104.50], EntityItemFrame['entity.ItemFrame.name'/84, l='MpServer', x=259.03, y=5.50, z=-104.50], EntityItemFrame['entity.ItemFrame.name'/85, l='MpServer', x=259.03, y=4.50, z=-104.50], EntityItemFrame['entity.ItemFrame.name'/86, l='MpServer', x=259.03, y=5.50, z=-100.50], EntityItemFrame['entity.ItemFrame.name'/87, l='MpServer', x=259.03, y=5.50, z=-99.50], EntityItemFrame['entity.ItemFrame.name'/88, l='MpServer', x=259.03, y=6.50, z=-99.50], EntityItemFrame['entity.ItemFrame.name'/89, l='MpServer', x=259.03, y=6.50, z=-100.50], EntityItemFrame['entity.ItemFrame.name'/90, l='MpServer', x=259.03, y=4.50, z=-100.50], EntityItemFrame['entity.ItemFrame.name'/91, l='MpServer', x=259.03, y=4.50, z=-99.50], EntityHorse['Horse'/99, l='MpServer', x=272.07, y=4.00, z=-49.98], EntitySheep['Sheep'/100, l='MpServer', x=277.64, y=4.00, z=-37.80], EntityPig['Pig'/105, l='MpServer', x=302.78, y=4.00, z=-57.74], EntityHorse['Horse'/106, l='MpServer', x=290.04, y=4.00, z=-34.14], EntityPlayerSP['Player250'/142, l='MpServer', x=272.47, y=4.00, z=-98.67], EntitySheep['Sheep'/114, l='MpServer', x=313.17, y=4.00, z=-116.73], EntityPig['Pig'/115, l='MpServer', x=309.25, y=4.00, z=-32.39], EntityChicken['Chicken'/120, l='MpServer', x=335.11, y=4.00, z=-72.45], EntityItem['item.item.egg'/121, l='MpServer', x=328.37, y=4.00, z=-73.06], EntitySheep['Sheep'/123, l='MpServer', x=345.68, y=4.00, z=-88.78]]
    Retry entities: 0 total; []
    Server brand: fml,forge
    Server type: Integrated singleplayer server
Stacktrace:
    at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:461)
    at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2888)
    at net.minecraft.client.Minecraft.run(Minecraft.java:470)
    at net.minecraft.client.main.Main.main(Main.java:118)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    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(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
    at GradleStart.main(GradleStart.java:25)

-- System Details --
Details:
    Minecraft Version: 1.12.2
    Operating System: Windows 10 (amd64) version 10.0
    Java Version: 1.8.0_192, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 358077760 bytes (341 MB) / 775946240 bytes (740 MB) up to 1900019712 bytes (1812 MB)
    JVM Flags: 0 total; 
    IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
    FML: MCP 9.42 Powered by Forge 14.23.5.2775 5 mods loaded, 5 mods active
    States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored

    | State     | ID        | Version      | Source                           | Signature |
    |:--------- |:--------- |:------------ |:-------------------------------- |:--------- |
    | UCHIJAAAA | minecraft | 1.12.2       | minecraft.jar                    | None      |
    | UCHIJAAAA | mcp       | 9.42         | minecraft.jar                    | None      |
    | UCHIJAAAA | FML       | 8.0.99.99    | forgeSrc-1.12.2-14.23.5.2775.jar | None      |
    | UCHIJAAAA | forge     | 14.23.5.2775 | forgeSrc-1.12.2-14.23.5.2775.jar | None      |
    | UCHIJAAAA | rtm       | 0.1          | bin                              | None      |

    Loaded coremods (and transformers): 
    GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.6.0 NVIDIA 416.34' Renderer: 'GeForce GTX 1050 Ti/PCIe/SSE2'
    Launched Version: 1.12.2
    LWJGL: 2.9.4
    OpenGL: GeForce GTX 1050 Ti/PCIe/SSE2 GL version 4.6.0 NVIDIA 416.34, NVIDIA Corporation
    GL Caps: Using GL 1.3 multitexturing.
Using GL 1.3 texture combiners.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Shaders are available because OpenGL 2.1 is supported.
VBOs are available because OpenGL 1.5 is supported.

    Using VBOs: Yes
    Is Modded: Definitely; Client brand changed to 'fml,forge'
    Type: Client (map_client.txt)
    Resource Packs: 
    Current Language: English (US)
    Profiler Position: N/A (disabled)
    CPU: 8x AMD Ryzen 5 1500X Quad-Core Processor 

 

My Basic SlabBlock Class

Spoiler

package com.raider.raiderztweaks.blocks;

import java.util.Random;

import com.raider.raiderztweaks.Main;
import com.raider.raiderztweaks.blocks.Blockinit;
import net.minecraft.block.Block;
import net.minecraft.block.BlockSlab;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public abstract class SlabBlocks extends BlockSlab
{
	Block half;
	public static final PropertyEnum<Variant> VARIANT = PropertyEnum.<Variant>create("variant", Variant.class);
	
	public SlabBlocks(String name, Material materialIn, BlockSlab half) 
	{
		super(materialIn);
		setUnlocalizedName(name);
		setRegistryName(name);
		setCreativeTab(Main.RaiderzTweeksTab);
		this.useNeighborBrightness = !this.isDouble();
		
		IBlockState state = this.blockState.getBaseState().withProperty(VARIANT, Variant.DEFAULT);
		if(!this.isDouble()) state = state.withProperty(HALF, EnumBlockHalf.BOTTOM);
		setDefaultState(state);
		
		this.half = half;
		
		Blockinit.BLOCKS.add(this);
	}

	@Override
	public Item getItemDropped(IBlockState state, Random rand, int fortune)
	{
		return Item.getItemFromBlock(half);
	}
	
	@Override
	public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state) 
	{
		return new ItemStack(half);
	}
	
	@Override
	public IBlockState getStateFromMeta(int meta) 
	{
		IBlockState state = this.blockState.getBaseState().withProperty(VARIANT, Variant.DEFAULT);
		if(!this.isDouble()) state = state.withProperty(HALF, ((meta&8) != 0) ? EnumBlockHalf.TOP : EnumBlockHalf.BOTTOM);
		return state;
	}
	
	@Override
	public int getMetaFromState(IBlockState state) 
	{
		int meta = 0;
		if(!this.isDouble() && state.getValue(HALF) == EnumBlockHalf.TOP) meta |= 8;
		return meta;
	}
	
	@Override
	protected BlockStateContainer createBlockState() 
	{
		if(!this.isDouble()) return new BlockStateContainer(this, new IProperty[] {VARIANT,HALF});
		else return new BlockStateContainer(this, new IProperty[] {VARIANT});
	}
	
	@Override
	public String getUnlocalizedName(int meta) 
	{
		return super.getUnlocalizedName();
	}
	
	@Override
	public IProperty<?> getVariantProperty()
	{
		return VARIANT;
	}
	
	@Override
	public Comparable<?> getTypeForItem(ItemStack stack) 
	{
		return Variant.DEFAULT;
	}
	
	public static enum Variant implements IStringSerializable
	{
		DEFAULT;
		
		@Override
		public String getName()
		{
			return "default";
		}
	}
}

 

 

MY HalfSlab Class

Spoiler

package com.raider.raiderztweaks.blocks;

import com.raider.raiderztweaks.Main;
import com.raider.raiderztweaks.items.Iteminit;
import com.raider.raiderztweaks.util.IHasModel;

import net.minecraft.block.BlockSlab;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
import net.minecraft.item.ItemSlab;

public class SlabBlocksHalf extends SlabBlocks implements IHasModel
{
	public SlabBlocksHalf(String name, Material materialIn, BlockSlab half, BlockSlab doubleSlab)
	{
		super(name, materialIn, half);
		
		Iteminit.ITEMS.add(new ItemSlab(this, this, doubleSlab).setRegistryName(name));
	}
	
	@Override
	public boolean isDouble() 
	{
		return false;
	}

	@Override
	public void registerModels() 
	{
		Main.proxy.registerItemRenderer(Item.getItemFromBlock(this), 0);
	}
}

 

My double slab class

Spoiler

package com.raider.raiderztweaks.blocks;

import net.minecraft.block.BlockSlab;
import net.minecraft.block.material.Material;

public class SlabBlocksDouble extends SlabBlocks
{
	public SlabBlocksDouble(String name, Material materialIn, BlockSlab half) 
	{
		super(name, materialIn, half);
	}

	@Override
	public boolean isDouble() 
	{	
		return true;
	}
}

	

 

my blockinit class

Spoiler

package com.raider.raiderztweaks.blocks;

import java.util.ArrayList;
import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.block.BlockSlab;
import net.minecraft.block.material.Material;

public class Blockinit
{
	public static final List <Block> BLOCKS = new ArrayList <Block>();
	
	//Basic Blocks
	public static final Block MARBLE = new RockBlocks("marble", Material.ROCK);
	public static final Block MARBLE_TILE = new RockBlocks("marble_tile", Material.ROCK);
	public static final Block MARBLE_BRICKS = new RockBlocks("marble_bricks", Material.ROCK);
	public static final Block SLATE = new RockBlocks("slate", Material.ROCK);
	public static final Block ORE_COPPER = new RockBlocks("ore_copper", Material.ROCK);
	public static final Block ORE_TIN = new RockBlocks("ore_tin", Material.ROCK);
	public static final Block BLOCK_COPPER = new MetalBlocks("block_copper", Material.IRON);
	public static final Block BLOCK_TIN = new MetalBlocks("block_tin", Material.IRON);
	public static final Block BLOCK_BRONZE = new MetalBlocks("block_bronze", Material.IRON);
	
	//Slabs
	public static final BlockSlab MARBLE_SLAB = new SlabBlocksHalf("marble_slab", Material.ROCK, Blockinit.MARBLE_SLAB, Blockinit.MARBLE_SLAB_DOUBLE);
	public static final BlockSlab MARBLE_SLAB_DOUBLE = new SlabBlocksDouble("marble_slab_double", Material.ROCK, Blockinit.MARBLE_SLAB);
	//Stairs
	public static final Block MARBLE_STAIRS = new StairBlocks("marble_stairs", MARBLE.getDefaultState());
	//Walls
	
	//Crops
	public static final Block SEED_TEST = new Seed_Test("seed_test");
	
	//test
	public static final Block BLOCK_MODEL = new ModelBlocks("block_model");
	
}

 

 

please let me know if more info is required

 

Many thanks

Edited by oRaiderzo
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.