Jump to content

Recommended Posts

Posted

I seem to have an issue when right clicking on the ground with custom sugar cane item.

 

Crashlog:

Spoiler

[07:22:34] [Client thread/FATAL]: Unreported exception thrown!
java.lang.NullPointerException
    at net.minecraft.world.World.mayPlace(World.java:3358) ~[World.class:?]
    at net.minecraft.item.ItemBlockSpecial.onItemUse(ItemBlockSpecial.java:45) ~[ItemBlockSpecial.class:?]
    at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:180) ~[ItemStack.class:?]
    at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:486) ~[PlayerControllerMP.class:?]
    at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1606) ~[Minecraft.class:?]
    at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2276) ~[Minecraft.class:?]
    at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2053) ~[Minecraft.class:?]
    at net.minecraft.client.Minecraft.runTick(Minecraft.java:1841) ~[Minecraft.class:?]
    at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1119) ~[Minecraft.class:?]
    at net.minecraft.client.Minecraft.run(Minecraft.java:407) [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/:?]
[07:22:34] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:600]: ---- Minecraft Crash Report ----
// Shall we play a game?

Time: 5/14/17 7:22 AM
Description: Unexpected error

java.lang.NullPointerException: Unexpected error
    at net.minecraft.world.World.mayPlace(World.java:3358)
    at net.minecraft.item.ItemBlockSpecial.onItemUse(ItemBlockSpecial.java:45)
    at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:180)
    at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:486)
    at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1606)
    at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2276)
    at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2053)
    at net.minecraft.client.Minecraft.runTick(Minecraft.java:1841)
    at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1119)
    at net.minecraft.client.Minecraft.run(Minecraft.java:407)
    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:
---------------------------------------------------------------------------------------

-- Head --
Thread: Client thread
Stacktrace:
    at net.minecraft.world.World.mayPlace(World.java:3358)
    at net.minecraft.item.ItemBlockSpecial.onItemUse(ItemBlockSpecial.java:45)
    at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:180)
    at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:486)
    at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1606)
    at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2276)
    at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2053)

-- Affected level --
Details:
    Level name: MpServer
    All players: 1 total; [EntityPlayerSP['Player219'/258, l='MpServer', x=-22.90, y=33.09, z=35.02]]
    Chunk stats: MultiplayerChunkCache: 625, 625
    Level seed: 0
    Level generator: ID 00 - default, ver 1. Features enabled: false
    Level generator options:
    Level spawn location: World: (-16,64,317), Chunk: (at 0,4,13 in -1,19; contains blocks -16,0,304 to -1,255,319), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
    Level time: 80063 game time, 13918 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: 48 total; [EntityPigZombie['Zombie Pigman'/259, l='MpServer', x=-29.28, y=36.00, z=46.50], EntityPigZombie['Zombie Pigman'/260, l='MpServer', x=-19.10, y=35.00, z=46.44], EntityPigZombie['Zombie Pigman'/261, l='MpServer', x=-16.55, y=34.00, z=45.77], EntityPigZombie['Zombie Pigman'/262, l='MpServer', x=-29.50, y=90.00, z=46.50], EntityPigZombie['Zombie Pigman'/263, l='MpServer', x=-14.51, y=101.00, z=39.25], EntityPigZombie['Zombie Pigman'/269, l='MpServer', x=-103.44, y=13.00, z=-9.65], EntityPigZombie['Zombie Pigman'/272, l='MpServer', x=-68.50, y=84.00, z=-19.50], EntityPigZombie['Zombie Pigman'/273, l='MpServer', x=-64.50, y=18.00, z=2.50], EntityPigZombie['Zombie Pigman'/274, l='MpServer', x=-67.50, y=85.00, z=8.50], EntityPigZombie['Zombie Pigman'/275, l='MpServer', x=-67.50, y=85.00, z=9.50], EntityPigZombie['Zombie Pigman'/276, l='MpServer', x=-68.45, y=85.00, z=5.20], EntityPigZombie['Zombie Pigman'/277, l='MpServer', x=-69.50, y=85.00, z=8.50], EntityPlayerSP['Player219'/258, l='MpServer', x=-22.90, y=33.09, z=35.02], EntityPigZombie['Zombie Pigman'/287, l='MpServer', x=50.50, y=37.00, z=109.50], EntityPigZombie['Zombie Pigman'/288, l='MpServer', x=56.41, y=39.00, z=97.77], EntityPigZombie['Zombie Pigman'/292, l='MpServer', x=49.24, y=92.00, z=-4.50], EntityEnderman['Enderman'/293, l='MpServer', x=-2.52, y=93.00, z=67.61], EntityEnderman['Enderman'/294, l='MpServer', x=-11.50, y=92.00, z=69.50], EntityPigZombie['Zombie Pigman'/295, l='MpServer', x=-34.50, y=111.00, z=99.50], EntityPigZombie['Zombie Pigman'/301, l='MpServer', x=-13.50, y=103.00, z=-28.50], EntityPigZombie['Zombie Pigman'/302, l='MpServer', x=-27.43, y=89.00, z=104.26], EntityPigZombie['Zombie Pigman'/303, l='MpServer', x=-52.41, y=55.00, z=-5.66], EntityPigZombie['Zombie Pigman'/304, l='MpServer', x=-36.26, y=33.00, z=63.47], EntityPigZombie['Zombie Pigman'/305, l='MpServer', x=-33.80, y=35.00, z=58.59], EntityPigZombie['Zombie Pigman'/306, l='MpServer', x=-33.59, y=89.00, z=54.26], EntityPigZombie['Zombie Pigman'/307, l='MpServer', x=18.50, y=13.00, z=-10.50], EntityPigZombie['Zombie Pigman'/308, l='MpServer', x=-15.50, y=100.00, z=28.50], EntityPigZombie['Zombie Pigman'/309, l='MpServer', x=-64.50, y=83.00, z=103.50], EntityPigZombie['Zombie Pigman'/310, l='MpServer', x=8.81, y=7.00, z=-13.50], EntityPigZombie['Zombie Pigman'/311, l='MpServer', x=12.51, y=19.00, z=-12.19], EntityChicken['Chicken'/312, l='MpServer', x=15.36, y=99.00, z=-11.50], EntityPigZombie['Zombie Pigman'/313, l='MpServer', x=24.60, y=100.00, z=-12.18], EntityPigZombie['Zombie Pigman'/314, l='MpServer', x=25.50, y=70.00, z=-17.50], EntityPigZombie['Zombie Pigman'/315, l='MpServer', x=-15.65, y=100.00, z=38.70], EntityPigZombie['Zombie Pigman'/316, l='MpServer', x=-23.50, y=90.00, z=16.50], EntityPigZombie['Zombie Pigman'/318, l='MpServer', x=-69.50, y=85.00, z=113.50], EntityPigZombie['Zombie Pigman'/319, l='MpServer', x=30.50, y=69.00, z=26.50], EntityPigZombie['Zombie Pigman'/321, l='MpServer', x=33.50, y=35.00, z=80.50], EntityPigZombie['Zombie Pigman'/322, l='MpServer', x=40.19, y=37.00, z=92.50], EntityPigZombie['Zombie Pigman'/323, l='MpServer', x=33.50, y=35.00, z=82.50], EntityPigZombie['Zombie Pigman'/324, l='MpServer', x=34.50, y=78.00, z=92.76], EntityPigZombie['Zombie Pigman'/325, l='MpServer', x=43.50, y=37.00, z=109.50], EntityPigZombie['Zombie Pigman'/331, l='MpServer', x=2.50, y=107.00, z=87.50], EntityPigZombie['Zombie Pigman'/332, l='MpServer', x=39.50, y=34.00, z=68.50], EntityPigZombie['Zombie Pigman'/333, l='MpServer', x=39.50, y=34.00, z=69.50], EntityPigZombie['Zombie Pigman'/334, l='MpServer', x=45.22, y=38.00, z=72.50], EntityPigZombie['Zombie Pigman'/335, l='MpServer', x=33.50, y=35.00, z=79.50], EntityPigZombie['Zombie Pigman'/336, l='MpServer', x=20.76, y=79.00, z=89.50]]
    Retry entities: 0 total; []
    Server brand: fml,forge
    Server type: Integrated singleplayer server
Stacktrace:
    at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:456)
    at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2774)
    at net.minecraft.client.Minecraft.run(Minecraft.java:436)
    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)

 

The code in my item class for the sugar cane

Spoiler

        netherReed = new ItemBlockSpecial(MoShizBlocks.netherReed).setUnlocalizedName("nether/netherReed").setRegistryName("nether/netherReed").setCreativeTab(MoShizMain.tabTest);

 

And my Nether Reed block class

Spoiler

package com.ProfitOrange.moshiz.blocks.nether;

import java.util.Random;
import javax.annotation.Nullable;

import com.ProfitOrange.moshiz.MoShizMain;
import com.ProfitOrange.moshiz.init.MoShizBlocks;
import com.ProfitOrange.moshiz.init.MoShizItems;

import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
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.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
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.common.EnumPlantType;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class NetherReed extends Block implements IPlantable
{
    public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 15);
    protected static final AxisAlignedBB REED_AABB = new AxisAlignedBB(0.125D, 0.0D, 0.125D, 0.875D, 1.0D, 0.875D);

    public NetherReed(String name)
    {
        super(Material.PLANTS);
        this.setUnlocalizedName(name);
        this.setRegistryName(name);
        this.setDefaultState(this.blockState.getBaseState().withProperty(AGE, Integer.valueOf(0)));
        this.setTickRandomly(true);
        this.blockSoundType = SoundType.PLANT;
        this.setCreativeTab(MoShizMain.tabGems);
        
    }

    public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
    {
        return REED_AABB;
    }

    public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
    {
        if (worldIn.getBlockState(pos.down()).getBlock() == MoShizBlocks.netherReed || this.checkForDrop(worldIn, pos, state))
        {
            if (worldIn.isAirBlock(pos.up()))
            {
                int i;

                for (i = 1; worldIn.getBlockState(pos.down(i)).getBlock() == this; ++i)
                {
                    ;
                }

                if (i < 3)
                {
                    int j = ((Integer)state.getValue(AGE)).intValue();

                    if(net.minecraftforge.common.ForgeHooks.onCropsGrowPre(worldIn, pos, state, true))
                    {
                    if (j == 15)
                    {
                        worldIn.setBlockState(pos.up(), this.getDefaultState());
                        worldIn.setBlockState(pos, state.withProperty(AGE, Integer.valueOf(0)), 4);
                    }
                    else
                    {
                        worldIn.setBlockState(pos, state.withProperty(AGE, Integer.valueOf(j + 1)), 4);
                    }
                    net.minecraftforge.common.ForgeHooks.onCropsGrowPost(worldIn, pos, state, worldIn.getBlockState(pos));
                    }
                }
            }
        }
    }

    
    /*
    
    
    */
    public boolean canSustainPlants(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, IPlantable plantable)
    {
    	boolean isBeach = this == MoShizBlocks.netherSand || this == net.minecraft.init.Blocks.SOUL_SAND || this == net.minecraft.init.Blocks.NETHERRACK;
    	boolean hasWater = (world.getBlockState(pos.east()).getMaterial() == Material.LAVA ||
                        world.getBlockState(pos.west()).getMaterial() == Material.LAVA ||
                        world.getBlockState(pos.north()).getMaterial() == Material.LAVA ||
                        world.getBlockState(pos.south()).getMaterial() == Material.LAVA);
    	return isBeach && hasWater;
    }
    
    public boolean canPlaceBlockAt(World world, BlockPos pos)
    {
        IBlockState state = world.getBlockState(pos.down());
        Block block = state.getBlock();
        if (this.canSustainPlants(state, world, pos.down(), EnumFacing.UP, this)) 
        {
        	return true;
        }

        if (block == this)
        {
            return true;
        }
        else if (block != MoShizBlocks.netherSand && block != Blocks.SOUL_SAND && block != Blocks.NETHERRACK)
        {
            return false;
        }
        else
        {
            BlockPos blockpos = pos.down();

            for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
            {
                IBlockState iblockstate = world.getBlockState(blockpos.offset(enumfacing));

                if (iblockstate.getMaterial() == Material.LAVA)
                {
                    return true;
                }
            }

            return false;
        }
    }

    /**
     * Called when a neighboring block was changed and marks that this state should perform any checks during a neighbor
     * change. Cases may include when redstone power is updated, cactus blocks popping off due to a neighboring solid
     * block, etc.
     */
    public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos)
    {
        this.checkForDrop(worldIn, pos, state);
    }

    protected final boolean checkForDrop(World worldIn, BlockPos pos, IBlockState state)
    {
        if (this.canBlockStay(worldIn, pos))
        {
            return true;
        }
        else
        {
            this.dropBlockAsItem(worldIn, pos, state, 0);
            worldIn.setBlockToAir(pos);
            return false;
        }
    }

    public boolean canBlockStay(World worldIn, BlockPos pos)
    {
        return this.canPlaceBlockAt(worldIn, pos);
    }

    @Nullable
    public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos)
    {
        return NULL_AABB;
    }

    /**
     * Get the Item that this Block should drop when harvested.
     */
    public Item getItemDropped(IBlockState state, Random rand, int fortune)
    {
        return MoShizItems.netherReed;
    }

    /**
     * Used to determine ambient occlusion and culling when rebuilding chunks for render
     */
    public boolean isOpaqueCube(IBlockState state)
    {
        return false;
    }

    public boolean isFullCube(IBlockState state)
    {
        return false;
    }

    public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state)
    {
        return new ItemStack(MoShizItems.netherReed);
    }

    /**
     * Convert the given metadata into a BlockState for this Block
     */
    public IBlockState getStateFromMeta(int meta)
    {
        return this.getDefaultState().withProperty(AGE, Integer.valueOf(meta));
    }

    @SideOnly(Side.CLIENT)
    public BlockRenderLayer getBlockLayer()
    {
        return BlockRenderLayer.CUTOUT;
    }

    /**
     * Convert the BlockState into the correct metadata value
     */
    public int getMetaFromState(IBlockState state)
    {
        return ((Integer)state.getValue(AGE)).intValue();
    }
    
    
    /*
    @Override
    public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos)
    {
        return MoShizPlantType.NetherBeach;
    }
    */
    
    
    
    @Override
    public IBlockState getPlant(IBlockAccess world, BlockPos pos)
    {
        return this.getDefaultState();
    }

    protected BlockStateContainer createBlockState()
    {
        return new BlockStateContainer(this, new IProperty[] {AGE});
    }

	@Override
	public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos)
	{
		return net.minecraftforge.common.EnumPlantType.Nether;
	}
    
    
}

 

I have the Nether Reed block to place and render correctly when using the block version of it, but the issue causes the game to crash as soon as I try placing the nether reed item.

Posted

$100 says you create and register your item before you create and register your block.

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.

  • 2 weeks later...

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.