Jump to content

Recommended Posts

Posted

I made a custom cake. When i place it in the world the game crashes.

here is the crash:

 

[14:23:35] [server thread/FATAL]: Error executing task
java.util.concurrent.ExecutionException: java.lang.NullPointerException
at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:1.8.0_73]
at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:1.8.0_73]
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(Thread.java:745) [?:1.8.0_73]
Caused by: java.lang.NullPointerException
at net.minecraft.world.World.canBlockBePlaced(World.java:3382) ~[World.class:?]
at winnetrie.tem.item.ItemCheeseCake.onItemUse(ItemCheeseCake.java:52) ~[itemCheeseCake.class:?]
at net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(ForgeHooks.java:755) ~[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(Executors.java:511) ~[?:1.8.0_73]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_73]
at net.minecraft.util.Util.runTask(Util.java:25) ~[util.class:?]
... 5 more
[14:23:36] [server thread/INFO]: Stopping server
[14:23:36] [server thread/INFO]: Saving players
[14:23:36] [server thread/INFO]: Saving worlds
[14:23:36] [server thread/INFO]: Saving chunks for level 'New World'/Overworld
[14:23:36] [server thread/INFO]: Saving chunks for level 'New World'/Nether
[14:23:36] [server thread/INFO]: Saving chunks for level 'New World'/The End
[14:23:37] [server thread/INFO] [FML]: Unloading dimension 0
[14:23:37] [server thread/INFO] [FML]: Unloading dimension -1
[14:23:37] [server thread/INFO] [FML]: Unloading dimension 1
[14:23:39] [Client thread/FATAL]: Unreported exception thrown!
java.lang.NullPointerException
at net.minecraft.world.World.canBlockBePlaced(World.java:3382) ~[World.class:?]
at winnetrie.tem.item.ItemCheeseCake.onItemUse(ItemCheeseCake.java:52) ~[itemCheeseCake.class:?]
at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:159) ~[itemStack.class:?]
at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:486) ~[PlayerControllerMP.class:?]
at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1603) ~[Minecraft.class:?]
at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2281) ~[Minecraft.class:?]
at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2058) ~[Minecraft.class:?]
at net.minecraft.client.Minecraft.runTick(Minecraft.java:1846) ~[Minecraft.class:?]
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1118) ~[Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:406) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_73]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_73]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_73]
at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_73]
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_73]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_73]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_73]
at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_73]
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
at GradleStart.main(GradleStart.java:26) [start/:?]
[14:23:39] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:649]: ---- Minecraft Crash Report ----
// Oops.

Time: 3-11-16 14:23
Description: Unexpected error

java.lang.NullPointerException: Unexpected error
at net.minecraft.world.World.canBlockBePlaced(World.java:3382)
at winnetrie.tem.item.ItemCheeseCake.onItemUse(ItemCheeseCake.java:52)
at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:159)
at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:486)
at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1603)
at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2281)
at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2058)
at net.minecraft.client.Minecraft.runTick(Minecraft.java:1846)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1118)
at net.minecraft.client.Minecraft.run(Minecraft.java:406)
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:497)
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:497)
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.canBlockBePlaced(World.java:3382)
at winnetrie.tem.item.ItemCheeseCake.onItemUse(ItemCheeseCake.java:52)
at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:159)
at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:486)
at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1603)
at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2281)
at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2058)

-- Affected level --
Details:
Level name: MpServer
All players: 1 total; [EntityPlayerSP['Player680'/298, l='MpServer', x=400,79, y=67,00, z=764,65]]
Chunk stats: MultiplayerChunkCache: 617, 617
Level seed: 0
Level generator: ID 00 - default, ver 1. Features enabled: false
Level generator options: 
Level spawn location: World: (-36,64,256), Chunk: (at 12,4,0 in -3,16; contains blocks -48,0,256 to -33,255,271), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
Level time: 603107 game time, 2230 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: 92 total; [EntityPig['Pig'/640, l='MpServer', x=427,62, y=68,00, z=786,72], EntityPig['Pig'/641, l='MpServer', x=427,67, y=67,00, z=793,50], EntityPig['Pig'/642, l='MpServer', x=427,45, y=66,00, z=801,14], EntityZombie['Zombie'/387, l='MpServer', x=325,50, y=55,00, z=758,83], EntitySkeleton['Skeleton'/388, l='MpServer', x=325,48, y=55,00, z=758,06], EntityPig['Pig'/389, l='MpServer', x=328,75, y=63,00, z=761,52], EntitySkeleton['Skeleton'/391, l='MpServer', x=331,50, y=17,00, z=832,50], EntityPig['Pig'/392, l='MpServer', x=343,70, y=69,00, z=834,81], EntityPig['Pig'/393, l='MpServer', x=332,64, y=70,00, z=807,24], EntityPig['Pig'/394, l='MpServer', x=328,74, y=70,00, z=807,46], EntityPig['Pig'/396, l='MpServer', x=341,24, y=70,00, z=815,35], EntityBat['Bat'/527, l='MpServer', x=445,29, y=19,53, z=714,87], EntityCow['Cow'/528, l='MpServer', x=449,87, y=70,00, z=701,14], EntitySquid['Squid'/529, l='MpServer', x=425,69, y=61,61, z=743,74], EntityEnderman['Enderman'/402, l='MpServer', x=330,73, y=18,00, z=831,52], EntityBat['Bat'/531, l='MpServer', x=438,56, y=19,50, z=721,07], EntityWitch['Witch'/533, l='MpServer', x=434,77, y=35,00, z=723,53], EntitySkeleton['Skeleton'/535, l='MpServer', x=444,50, y=33,00, z=732,50], EntityEnderman['Enderman'/664, l='MpServer', x=459,50, y=34,00, z=804,50], EntitySkeleton['Skeleton'/539, l='MpServer', x=441,71, y=34,00, z=727,50], EntitySpider['Spider'/540, l='MpServer', x=442,50, y=33,00, z=729,50], EntityZombie['Zombie'/670, l='MpServer', x=477,20, y=45,00, z=784,57], EntityBat['Bat'/543, l='MpServer', x=452,66, y=17,74, z=724,09], EntitySkeleton['Skeleton'/544, l='MpServer', x=463,24, y=24,00, z=733,50], EntityCreeper['Creeper'/545, l='MpServer', x=457,50, y=22,00, z=732,50], EntitySkeleton['Skeleton'/546, l='MpServer', x=446,46, y=33,00, z=736,30], EntityCow['Cow'/547, l='MpServer', x=427,19, y=71,00, z=700,87], EntityCow['Cow'/548, l='MpServer', x=425,79, y=71,00, z=699,85], EntityCow['Cow'/553, l='MpServer', x=447,12, y=71,00, z=688,65], EntityCow['Cow'/554, l='MpServer', x=437,21, y=71,00, z=694,59], EntityCreeper['Creeper'/299, l='MpServer', x=403,50, y=18,00, z=761,50], EntityZombie['Zombie'/300, l='MpServer', x=410,16, y=18,00, z=760,50], EntityCow['Cow'/556, l='MpServer', x=460,47, y=71,00, z=685,83], EntityZombie['Zombie'/301, l='MpServer', x=408,50, y=18,00, z=761,50], EntityCreeper['Creeper'/429, l='MpServer', x=415,17, y=34,00, z=687,48], EntityZombie['Zombie'/557, l='MpServer', x=426,80, y=43,00, z=714,44], EntityZombie['Zombie'/302, l='MpServer', x=405,50, y=18,00, z=761,50], EntityCow['Cow'/558, l='MpServer', x=430,70, y=71,00, z=704,16], EntityBat['Bat'/303, l='MpServer', x=414,25, y=43,10, z=765,25], EntitySquid['Squid'/559, l='MpServer', x=425,65, y=62,66, z=718,95], EntityBat['Bat'/304, l='MpServer', x=403,25, y=60,10, z=765,75], EntityZombie['Zombie'/436, l='MpServer', x=342,50, y=54,00, z=743,50], EntityPig['Pig'/437, l='MpServer', x=344,75, y=64,00, z=743,89], EntityPig['Pig'/438, l='MpServer', x=351,38, y=64,00, z=750,21], EntityZombie['Zombie'/566, l='MpServer', x=450,50, y=43,00, z=778,29], EntityBat['Bat'/439, l='MpServer', x=362,79, y=62,05, z=719,65], EntityCreeper['Creeper'/567, l='MpServer', x=456,50, y=39,00, z=783,50], EntityCreeper['Creeper'/568, l='MpServer', x=458,50, y=39,00, z=782,50], EntityPig['Pig'/441, l='MpServer', x=365,44, y=67,00, z=759,01], EntityCreeper['Creeper'/569, l='MpServer', x=471,30, y=25,00, z=758,30], EntityBat['Bat'/570, l='MpServer', x=471,41, y=20,07, z=768,92], EntityCreeper['Creeper'/571, l='MpServer', x=477,50, y=38,00, z=766,50], EntityCreeper['Creeper'/572, l='MpServer', x=430,50, y=46,00, z=809,50], EntitySkeleton['Skeleton'/573, l='MpServer', x=419,66, y=45,00, z=800,50], EntitySkeleton['Skeleton'/574, l='MpServer', x=417,78, y=45,00, z=806,31], EntitySkeleton['Skeleton'/575, l='MpServer', x=416,39, y=45,87, z=804,48], EntityCreeper['Creeper'/576, l='MpServer', x=430,50, y=45,00, z=811,50], EntityBat['Bat'/449, l='MpServer', x=392,20, y=38,10, z=774,60], EntityCreeper['Creeper'/577, l='MpServer', x=429,50, y=45,00, z=811,50], EntityBat['Bat'/450, l='MpServer', x=393,45, y=38,10, z=772,25], EntityCreeper['Creeper'/578, l='MpServer', x=444,74, y=36,07, z=787,55], EntityCreeper['Creeper'/451, l='MpServer', x=411,47, y=43,00, z=769,77], EntityPig['Pig'/579, l='MpServer', x=440,04, y=63,00, z=788,92], EntityCreeper['Creeper'/452, l='MpServer', x=413,16, y=55,00, z=768,48], EntityCreeper['Creeper'/580, l='MpServer', x=433,50, y=45,00, z=806,50], EntityZombie['Zombie'/453, l='MpServer', x=408,51, y=52,00, z=771,45], EntityBat['Bat'/454, l='MpServer', x=377,75, y=61,10, z=752,58], EntitySpider['Spider'/455, l='MpServer', x=396,50, y=32,00, z=751,50], EntityCreeper['Creeper'/456, l='MpServer', x=408,15, y=46,00, z=751,47], EntityZombie['Zombie'/457, l='MpServer', x=385,80, y=34,00, z=766,52], EntityBat['Bat'/460, l='MpServer', x=401,19, y=50,10, z=788,52], EntityZombie['Zombie'/611, l='MpServer', x=477,44, y=19,00, z=724,80], EntityCreeper['Creeper'/612, l='MpServer', x=477,13, y=18,00, z=728,21], EntityCreeper['Creeper'/614, l='MpServer', x=443,50, y=22,00, z=754,50], EntityPlayerSP['Player680'/298, l='MpServer', x=400,79, y=67,00, z=764,65], EntityEnderman['Enderman'/615, l='MpServer', x=436,50, y=23,00, z=756,50], EntityZombie['Zombie'/616, l='MpServer', x=452,50, y=12,00, z=745,50], EntitySkeleton['Skeleton'/617, l='MpServer', x=454,51, y=13,00, z=748,91], EntityCreeper['Creeper'/618, l='MpServer', x=449,11, y=20,00, z=740,50], EntityBat['Bat'/619, l='MpServer', x=429,44, y=22,10, z=773,26], EntityBat['Bat'/620, l='MpServer', x=422,75, y=58,10, z=780,25], EntityBat['Bat'/621, l='MpServer', x=422,75, y=58,10, z=780,25], EntityCreeper['Creeper'/631, l='MpServer', x=478,76, y=15,00, z=754,43], EntityBat['Bat'/632, l='MpServer', x=472,49, y=63,18, z=745,78], EntitySkeleton['Skeleton'/634, l='MpServer', x=456,49, y=14,00, z=756,27], EntityCreeper['Creeper'/635, l='MpServer', x=450,47, y=19,00, z=761,18], EntityPig['Pig'/380, l='MpServer', x=326,05, y=63,00, z=723,86], EntityBat['Bat'/636, l='MpServer', x=416,25, y=57,10, z=787,75], EntityPig['Pig'/381, l='MpServer', x=321,71, y=62,52, z=727,84], EntityCreeper['Creeper'/637, l='MpServer', x=428,50, y=49,00, z=790,50], EntityCreeper['Creeper'/638, l='MpServer', x=427,50, y=49,00, z=790,50], EntityCreeper['Creeper'/639, l='MpServer', x=430,50, y=59,00, z=792,21]]
Retry entities: 0 total; []
Server brand: fml,forge
Server type: Integrated singleplayer server
Stacktrace:
at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:451)
at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2779)
at net.minecraft.client.Minecraft.run(Minecraft.java:435)
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:497)
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:497)
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
at GradleStart.main(GradleStart.java:26)

-- System Details --
Details:
Minecraft Version: 1.10.2
Operating System: Windows 10 (amd64) version 10.0
Java Version: 1.8.0_73, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 300418264 bytes (286 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94
FML: MCP 9.32 Powered by Forge 12.18.2.2099 4 mods loaded, 4 mods active
States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
UCHIJAAAA	mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) 
UCHIJAAAA	FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.10.2-12.18.2.2099.jar) 
UCHIJAAAA	Forge{12.18.2.2099} [Minecraft Forge] (forgeSrc-1.10.2-12.18.2.2099.jar) 
UCHIJAAAA	tem{2.1.0} [Tim's Expansion Mod] (bin) 
Loaded coremods (and transformers): 
GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 372.70' Renderer: 'GeForce GTX 960/PCIe/SSE2'
Launched Version: 1.10.2
LWJGL: 2.9.4
OpenGL: GeForce GTX 960/PCIe/SSE2 GL version 4.5.0 NVIDIA 372.70, 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 FX(tm)-8350 Eight-Core Processor 

 

 

Here is the code for cheeseblock:

 

public class BlockCheeseCake extends Block{

public static final PropertyInteger BITES = PropertyInteger.create("bites", 0, 6);
    protected static final AxisAlignedBB[] CAKE_AABB = new AxisAlignedBB[] {new AxisAlignedBB(0.0625D, 0.0D, 0.0625D, 0.9375D, 0.5D, 0.9375D), new AxisAlignedBB(0.1875D, 0.0D, 0.0625D, 0.9375D, 0.5D, 0.9375D), new AxisAlignedBB(0.3125D, 0.0D, 0.0625D, 0.9375D, 0.5D, 0.9375D), new AxisAlignedBB(0.4375D, 0.0D, 0.0625D, 0.9375D, 0.5D, 0.9375D), new AxisAlignedBB(0.5625D, 0.0D, 0.0625D, 0.9375D, 0.5D, 0.9375D), new AxisAlignedBB(0.6875D, 0.0D, 0.0625D, 0.9375D, 0.5D, 0.9375D), new AxisAlignedBB(0.8125D, 0.0D, 0.0625D, 0.9375D, 0.5D, 0.9375D)};

    public BlockCheeseCake(String unlocalname, String registryname)
    {
        super(Material.CAKE);
        this.setDefaultState(this.blockState.getBaseState().withProperty(BITES, Integer.valueOf(0)));
        this.setTickRandomly(true);
        this.setUnlocalizedName(unlocalname);
        this.setRegistryName(registryname);
        //this.setCreativeTab(Tem.blockstab);
    }

    public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
    {
        return CAKE_AABB[((Integer)state.getValue(BITES)).intValue()];
    }

    @SideOnly(Side.CLIENT)
    public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World worldIn, BlockPos pos)
    {
        return state.getCollisionBoundingBox(worldIn, pos);
    }

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

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

    public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
    {
        this.eatCake(worldIn, pos, state, playerIn);
        return true;
    }

    private void eatCake(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
    {
        if (player.canEat(false))
        {
            player.addStat(StatList.CAKE_SLICES_EATEN);
            player.getFoodStats().addStats(2, 0.1F);
            int i = ((Integer)state.getValue(BITES)).intValue();

            if (i < 6)
            {
                worldIn.setBlockState(pos, state.withProperty(BITES, Integer.valueOf(i + 1)), 3);
            }
            else
            {
                worldIn.setBlockToAir(pos);
            }
        }
    }

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

    public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn)
    {
        if (!this.canBlockStay(worldIn, pos))
        {
            worldIn.setBlockToAir(pos);
        }
    }

    private boolean canBlockStay(World worldIn, BlockPos pos)
    {
        return worldIn.getBlockState(pos.down()).getMaterial().isSolid();
    }

    public int quantityDropped(Random random)
    {
        return 0;
    }

    @Nullable
    public Item getItemDropped(IBlockState state, Random rand, int fortune)
    {
        return null;
    }

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

    public IBlockState getStateFromMeta(int meta)
    {
        return this.getDefaultState().withProperty(BITES, Integer.valueOf(meta));
    }

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

    public int getMetaFromState(IBlockState state)
    {
        return ((Integer)state.getValue(BITES)).intValue();
    }

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

    public int getComparatorInputOverride(IBlockState blockState, World worldIn, BlockPos pos)
    {
        return (7 - ((Integer)blockState.getValue(BITES)).intValue()) * 2;
    }

    public boolean hasComparatorInputOverride(IBlockState state)
    {
        return true;
    }

}

 

 

And here for the item:

 

public class ItemCheeseCake extends Item{

private final Block block;

    public ItemCheeseCake(Block block, String unlocalname, String registryname)
    {
        this.block = block;
        this.setUnlocalizedName(unlocalname);
        this.setRegistryName(registryname);
        this.setMaxStackSize(1);
        setCreativeTab(Tem.itemstab);
    }

    public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);
        Block block = iblockstate.getBlock();

        if (block == Blocks.SNOW_LAYER && ((Integer)iblockstate.getValue(BlockSnow.LAYERS)).intValue() < 1)
        {
            facing = EnumFacing.UP;
        }
        else if (!block.isReplaceable(worldIn, pos))
        {
            pos = pos.offset(facing);
        }

        if (playerIn.canPlayerEdit(pos, facing, stack) && stack.stackSize != 0 && worldIn.canBlockBePlaced(this.block, pos, false, facing, (Entity)null, stack))
        {
            IBlockState iblockstate1 = this.block.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, 0, playerIn);

            if (!worldIn.setBlockState(pos, iblockstate1, 11))
            {
                return EnumActionResult.FAIL;
            }
            else
            {
                iblockstate1 = worldIn.getBlockState(pos);

                if (iblockstate1.getBlock() == this.block)
                {
                    ItemBlock.setTileEntityNBT(worldIn, playerIn, pos, stack);
                    iblockstate1.getBlock().onBlockPlacedBy(worldIn, pos, iblockstate1, playerIn, stack);
                }

                SoundType soundtype = iblockstate1.getBlock().getSoundType(iblockstate1, worldIn, pos, playerIn);
                worldIn.playSound(playerIn, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
                --stack.stackSize;
                return EnumActionResult.SUCCESS;
            }
        }
        else
        {
            return EnumActionResult.FAIL;
        }
    }
}

I can't see what's wrong

Posted

It looks like you passed a

null

Block

to

World#canBlockBePlaced

from

ItemCheeseCake#onItemUse

.

 

Side note: It looks like you've copy-pasted the vanilla cake code. Why not just use/extend the existing classes?

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

It looks like you passed a

null

Block

to

World#canBlockBePlaced

from

ItemCheeseCake#onItemUse

.

 

Side note: It looks like you've copy-pasted the vanilla cake code. Why not just use/extend the existing classes?

Ow yes true, because i register items before blocks and the item needs to know wich block to use.

I'll try the extending way. I was not sure that would work properly.

But the main reason is i hate to do this:

.setfunction1.setfunction2.setfunction3.setfunction4.setfunction5

Posted

Ow yes true, because i register items before blocks and the item needs to know wich block to use.

Block

s should be created and registered before

Item

s.

 

You should be using the new registry events,

RegistryEvent.Register<Block>

will be fired before

RegistryEvent.Register<Item>

.

 

I'll try the extending way. I was not sure that would work properly.

But the main reason is i hate to do this:

.setfunction1.setfunction2.setfunction3.setfunction4.setfunction5

If you don't want to call a bunch of setter methods at the place of instantiation, move them to the constructor.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Where do i find this "new" registryEvent? What forge version is this?

How do i use it?

 

RegistryEvent

and

ModelRegistryEvent

were added in Forge 1.10.2-12.18.1.2092 (this commit).

 

I explain them here.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hi all,  I have the following issue: I'd like to parse some json using gson and rely on the (somewhat new) java record types. This is supported in gson 2.10+. Gson is already a dependency used by minecraft, however it's 2.8.x for 1.19.2 which I'm targeting at the moment. My idea was to include the newer version of the library in my mod and then shadow it so it gets used inside the scope of my mod instead of the older 2.8. This works fine for building the jar: If I decompile my mod.jar, I can see that it's correctly using the shadowed classes. However obviously when using the runClient intellj config, the shadowing doesn't get invoked. Is there any way of invoking shadow when using runClient, or am I on the wrong track and there's a better way of doing this entirely? Thanks in advance!
    • Yep I did upgrade just because it showed me a new version available.  I'll redownload the mod list and make sure anything works.  Thanks!
    • The latest log was taken down by pastebin for some reason. Did you try removing the mods you added? The mods you updated, was there a specific reason you updated, or just because? It's possible the updates introduced incompatibilitie, or even need a newer build of forge. If you didn't need the updates for a specific reason, you could also try downgrading those mods.
    • Please read the FAQ, and post logs as described there. https://forums.minecraftforge.net/topic/125488-rules-and-frequently-asked-questions-faq/
    • I am using forge 1.20.1 (version 47.3.0). My pc has an RTX 4080 super and an i9 14900 KF, I am on the latest Nvidia graphics driver, latest windows 10 software, I have java 23, forge 1.12.2 works and so does all vanilla versions but for some reason no version of forge 1.20.1 works and instead the game just crashes with the error code "-1." I have no mods in my mods fodler, I have deleted my options.txt and forge.cfg files in case my settings were causing a crash and have tried removing my forge version from the installations folder and reinstalling but no matter what I still crash with the same code and my log doesn't tell me anything: 18:34:53.924 game 2025-02-06 18:34:53,914 main WARN Advanced terminal features are not available in this environment 18:34:54.023 game [18:34:54] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher running: args [--username, mrmirchi, --version, 1.20.1-forge-47.3.0, --gameDir, C:\Users\aryam\AppData\Roaming\.minecraft, --assetsDir, C:\Users\aryam\AppData\Roaming\.minecraft\assets, --assetIndex, 5, --uuid, 2db00ea8d678420a8956109a85d90e9d, --accessToken, ????????, --clientId, ZWI3NThkNzMtNmNlZS00MGI5LTgyZTgtYmZkNzcwMTM5MGMx, --xuid, 2535436222989555, --userType, msa, --versionType, release, --quickPlayPath, C:\Users\aryam\AppData\Roaming\.minecraft\quickPlay\java\1738838092785.json, --launchTarget, forgeclient, --fml.forgeVersion, 47.3.0, --fml.mcVersion, 1.20.1, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20230612.114412] 18:34:54.027 game [18:34:54] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher 10.0.9+10.0.9+main.dcd20f30 starting: java version 17.0.8 by Microsoft; OS Windows 10 arch amd64 version 10.0 18:34:54.132 game [18:34:54] [main/INFO] [ne.mi.fm.lo.ImmediateWindowHandler/]: Loading ImmediateWindowProvider fmlearlywindow 18:34:54.191 game [18:34:54] [main/INFO] [EARLYDISPLAY/]: Trying GL version 4.6 18:34:54.303 game [18:34:54] [main/INFO] [EARLYDISPLAY/]: Requested GL version 4.6 got version 4.6 18:34:54.367 monitor Process Monitor Process crashed with exit code -1     screenshot of log: https://drive.google.com/file/d/1WdkH88H865XErvmIqAKjlg7yrmj8EYy7/view?usp=sharing
  • Topics

×
×
  • Create New...

Important Information

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