Jump to content

[1.8] Crash with my corn. Need help!


SteveKunG

Recommended Posts

When I create new corn in my mod. That's not work. :(

 

Here is my code.

package stevekung.mods.moreplanets.planets.fronos.blocks;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable;
import net.minecraft.world.World;
import stevekung.mods.moreplanets.common.blocks.BlockFlowerMP;

public class BlockGlassGemCorn1 extends BlockFlowerMP
{
public static PropertyEnum STAGE = PropertyEnum.create("stage", BlockType.class);

public BlockGlassGemCorn1(String name)
{
	super();
	float f = 0.4F;
	this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.8F, 0.5F + f);
	this.setHardness(0.2F);
	this.setDefaultState(this.getDefaultState().withProperty(STAGE, BlockType.state_bottom1));
	this.setUnlocalizedName(name);
}

@Override
public boolean removedByPlayer(World world, BlockPos pos, EntityPlayer player, boolean canHarvest)
{
	//IBlockState state = world.getBlockState(pos);

	/*if (world.getBlockState(pos.up()).getBlock() != FronosBlocks.glass_gem_corn2 || world.getBlockState(pos.up(2)).getBlock() != FronosBlocks.glass_gem_corn3)
	{
		world.setBlockToAir(pos);

		if (!player.capabilities.isCreativeMode)
		{
			this.dropBlockAsItem(world, pos, state, 0);
		}
	}
	else if (world.getBlockState(pos.up()).getBlock() == FronosBlocks.glass_gem_corn2 || world.getBlockState(pos.up(2)).getBlock() == FronosBlocks.glass_gem_corn3)
	{
		if (!player.capabilities.isCreativeMode)
		{
			this.dropBlockAsItem(world, pos, state, 0);
		}

		if (world.getBlockState(pos.up()).getBlock() == FronosBlocks.glass_gem_corn2 && world.getBlockMetadata(x, y + 1, z) == 3)
		{
			this.dropBlockAsItem(world, pos.up(), state, 0);
			this.dropBlockAsItem(world, pos.up(), state, 0);

			if (world.rand.nextInt( == 0)
			{
				this.dropBlockAsItem(world, pos.up(), state, 0);
				this.dropBlockAsItem(world, pos.up(), state, 0);
			}
		}
		this.dropBlockAsItem(world, pos.up(), state, 0);
		this.dropBlockAsItem(world, pos.up(2), state, 0);
		world.setBlockToAir(pos.up(2));
		world.setBlockToAir(pos.up());
		world.setBlockToAir(pos);
	}*/
	return false;
}

@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand)
{
	if (world.isDaytime() || world.getLightFromNeighbors(pos.up()) >= 9)
	{
		if (state == state.withProperty(STAGE, BlockType.state_bottom1))
		{
			if (!World.doesBlockHaveSolidTopSurface(world, pos.up()))
			{
				if (rand.nextInt(5) == 0)
				{
					world.setBlockState(pos.up(), state.withProperty(STAGE, BlockType.state_middle1), 3);
					world.setBlockState(pos, state.withProperty(STAGE, BlockType.state_bottom2), 3);
				}
			}
		}
		if (state == state.withProperty(STAGE, BlockType.state_middle1))
		{
			if (!World.doesBlockHaveSolidTopSurface(world, pos.up()))
			{
				if (rand.nextInt(5) == 0)
				{
					world.setBlockState(pos, state.withProperty(STAGE, BlockType.state_middle2), 3);
					world.setBlockState(pos.up(), state.withProperty(STAGE, BlockType.state_top1), 3);
				}
			}
		}
		if (state == state.withProperty(STAGE, BlockType.state_middle2))
		{
			if (rand.nextInt(5) == 0)
			{
				world.setBlockState(pos, state.withProperty(STAGE, BlockType.state_middle3), 3);
			}
		}
	}
	super.updateTick(world, pos, state, rand);
}

/*@Override
@SideOnly(Side.CLIENT)
public ItemStack getPickBlock(MovingObjectPosition moving, World world, BlockPos pos)
{
	return new ItemStack(FronosItems.glass_gem_corn);
}*/

@Override
public CreativeTabs getCreativeTabToDisplayOn()
{
	return null;
}

/*@Override
public Item getItemDropped(IBlockState state, Random random, int fortune)
{
	return FronosItems.glass_gem_corn;
}*/

@Override
public boolean canBlockStay(World world, BlockPos pos, IBlockState state)
{
	Block block = world.getBlockState(pos.down()).getBlock();

	if (state == state.withProperty(STAGE, BlockType.state_middle1) || state == state.withProperty(STAGE, BlockType.state_middle2) || state == state.withProperty(STAGE, BlockType.state_middle3))
	{
		return world.getBlockState(pos.down()) == world.getBlockState(pos.down()).withProperty(STAGE, BlockType.state_bottom2);
	}
	if (state == state.withProperty(STAGE, BlockType.state_top1))
	{
		return world.getBlockState(pos.down()) == world.getBlockState(pos.down()).withProperty(STAGE, BlockType.state_middle1) || world.getBlockState(pos.down()) == world.getBlockState(pos.down()).withProperty(STAGE, BlockType.state_middle2) || world.getBlockState(pos.down()) == world.getBlockState(pos.down()).withProperty(STAGE, BlockType.state_middle3);
	}
	return block == FronosBlocks.fronos_farmland;
}

@Override
public boolean canPlaceBlockOnSide(World world, BlockPos pos, EnumFacing side)
{
	return this.canBlockStay(world, pos, world.getBlockState(pos));
}

/*@Override
public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state, Block block)
{
	super.onNeighborBlockChange(world, pos, state, block);
	this.canBlockStay(world, pos, state);
	Block getBlock = world.getBlock(x, y + 1, z);
	int meta = world.getBlockMetadata(x, y, z);

	if (meta == 1 && getBlock != FronosBlocks.glass_gem_corn2)
	{
		if (world.getBlock(x, y + 1, z) != FronosBlocks.glass_gem_corn2)
		{
			world.setBlockMetadataWithNotify(x, y, z, 0, 2);
		}
	}
	if (meta == 0 || meta == 1 || meta == 2)
	{
		this.checkBlockCoordValid(world, x, y, z);
	}
}*/

protected void checkBlockCoordValid(World world, BlockPos pos)
{
	for (int i = 1; world.getBlockState(pos.add(pos.getX(), pos.getY() + i, pos.getZ())) == this; i++)
	{
		if (!this.canBlockStay(world, pos.add(pos.getX(), pos.getY() + i, pos.getZ()), world.getBlockState(pos)))
		{
			this.dropBlockAsItem(world, pos.add(pos.getX(), pos.getY() + i, pos.getZ()), world.getBlockState(pos), 0);
		}
	}
}

@Override
public int damageDropped(IBlockState state)
{
	return 0;
}

@Override
public int quantityDropped(IBlockState state, int fortune, Random rand)
{
	return 1;
}

@Override
public boolean isReplaceable(World world, BlockPos pos)
{
	return false;
}

@Override
protected BlockState createBlockState()
{
	return new BlockState(this, new IProperty[] { STAGE });
}

@Override
public IBlockState getStateFromMeta(int meta)
{
	return this.getDefaultState().withProperty(STAGE, BlockType.values()[meta]);
}

@Override
public int getMetaFromState(IBlockState state)
{
	return ((BlockType)state.getValue(STAGE)).ordinal();
}

public static enum BlockType implements IStringSerializable
{
	state_bottom1,
	state_bottom2,
	state_middle1,
	state_middle2,
	state_middle3,
	state_top1;

	@Override
	public String toString()
	{
		return this.getName();
	}

	@Override
	public String getName()
	{
		return this.name();
	}
}
}


BlockFlowerMP

package stevekung.mods.moreplanets.common.blocks;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.BlockBush;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import stevekung.mods.moreplanets.core.MorePlanetCore;

public abstract class BlockFlowerMP extends BlockBush
{
public BlockFlowerMP()
{
	super(Material.plants);
	this.setStepSound(soundTypeGrass);
	this.setTickRandomly(true);
}

public BlockFlowerMP(Material material)
{
	super(material);
}

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

@Override
@SideOnly(Side.CLIENT)
public Block.EnumOffsetType getOffsetType()
{
	return Block.EnumOffsetType.XZ;
}

@Override
public boolean canPlaceBlockAt(World world, BlockPos pos)
{
	return super.canPlaceBlockAt(world, pos) && this.canBlockStay(world, pos, this.getDefaultState());
}

@Override
public abstract boolean isReplaceable(World world, BlockPos pos);

@Override
public boolean canReplace(World world, BlockPos pos, EnumFacing side, ItemStack stack)
{
	return super.canPlaceBlockOnSide(world, pos, side) && this.canBlockStay(world, pos, this.getStateFromMeta(stack.getMetadata()));
}

@Override
public abstract boolean canBlockStay(World world, BlockPos pos, IBlockState state);

@Override
public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state, Block neighborBlock)
{
	super.onNeighborBlockChange(world, pos, state, neighborBlock);
	this.checkAndDropBlock(world, pos, state);
}

@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand)
{
	this.checkAndDropBlock(world, pos, state);
}

@Override
protected void checkAndDropBlock(World world, BlockPos pos, IBlockState state)
{
	if (!this.canBlockStay(world, pos, state))
	{
		this.dropBlockAsItem(world, pos, state, 0);
		world.setBlockState(pos, Blocks.air.getDefaultState(), 3);
	}
}

@Override
public AxisAlignedBB getCollisionBoundingBox(World world, BlockPos pos, IBlockState state)
{
	return null;
}

@Override
public boolean isOpaqueCube()
{
	return false;
}

@Override
public boolean isFullCube()
{
	return false;
}

@Override
public CreativeTabs getCreativeTabToDisplayOn()
{
	return MorePlanetCore.mpBlocksTab;
}
}

 

Crash report

 

 

 

---- Minecraft Crash Report ----

// You should try our sister game, Minceraft!

 

Time: 7/3/2558, 0:16 น.

Description: Exception while updating neighbours

 

java.lang.IllegalArgumentException: Cannot set property PropertyEnum{name=variant, clazz=class stevekung.mods.moreplanets.planets.fronos.blocks.BlockGlassGemCorn1$BlockType, values=[state_bottom1, state_bottom2, state_middle1, state_middle2, state_middle3, state_top1]} as it does not exist in BlockState{block=minecraft:flowing_water, properties=[level]}

at net.minecraft.block.state.BlockState$StateImplementation.withProperty(BlockState.java:182)

at stevekung.mods.moreplanets.planets.fronos.blocks.BlockGlassGemCorn1.canBlockStay(BlockGlassGemCorn1.java:137)

at stevekung.mods.moreplanets.common.blocks.BlockFlowerMP.checkAndDropBlock(BlockFlowerMP.java:83)

at net.minecraft.block.BlockBush.onNeighborBlockChange(BlockBush.java:52)

at stevekung.mods.moreplanets.common.blocks.BlockFlowerMP.onNeighborBlockChange(BlockFlowerMP.java:70)

at net.minecraft.world.World.notifyBlockOfStateChange(World.java:500)

at net.minecraft.world.World.notifyNeighborsOfStateChange(World.java:454)

at net.minecraft.world.World.notifyNeighborsRespectDebug(World.java:410)

at net.minecraft.world.World.markAndNotifyBlock(World.java:357)

at net.minecraft.world.World.setBlockState(World.java:339)

at net.minecraft.block.BlockDynamicLiquid.tryFlowInto(BlockDynamicLiquid.java:180)

at net.minecraft.block.BlockDynamicLiquid.updateTick(BlockDynamicLiquid.java:159)

at net.minecraft.block.Block.randomTick(Block.java:528)

at net.minecraft.world.WorldServer.updateBlocks(WorldServer.java:467)

at net.minecraft.world.WorldServer.tick(WorldServer.java:228)

at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:763)

at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:669)

at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:171)

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:540)

at java.lang.Thread.run(Unknown Source)

 

 

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

---------------------------------------------------------------------------------------

 

-- Head --

Stacktrace:

at net.minecraft.block.state.BlockState$StateImplementation.withProperty(BlockState.java:182)

at stevekung.mods.moreplanets.planets.fronos.blocks.BlockGlassGemCorn1.canBlockStay(BlockGlassGemCorn1.java:137)

at stevekung.mods.moreplanets.common.blocks.BlockFlowerMP.checkAndDropBlock(BlockFlowerMP.java:83)

at net.minecraft.block.BlockBush.onNeighborBlockChange(BlockBush.java:52)

at stevekung.mods.moreplanets.common.blocks.BlockFlowerMP.onNeighborBlockChange(BlockFlowerMP.java:70)

 

-- Block being updated --

Details:

Source block type: ID #521 (tile.glass_gem_corn1 // stevekung.mods.moreplanets.planets.fronos.blocks.BlockGlassGemCorn1)

Block: moreplanets:glass_gem_corn1[variant=state_middle3]

Block location: World: (-328,57,-190), Chunk: (at 8,3,2 in -21,-12; contains blocks -336,0,-192 to -321,255,-177), Region: (-1,-1; contains chunks -32,-32 to -1,-1, blocks -512,0,-512 to -1,255,-1)

Stacktrace:

at net.minecraft.world.World.notifyBlockOfStateChange(World.java:500)

at net.minecraft.world.World.notifyNeighborsOfStateChange(World.java:454)

at net.minecraft.world.World.notifyNeighborsRespectDebug(World.java:410)

at net.minecraft.world.World.markAndNotifyBlock(World.java:357)

at net.minecraft.world.World.setBlockState(World.java:339)

at net.minecraft.block.BlockDynamicLiquid.tryFlowInto(BlockDynamicLiquid.java:180)

at net.minecraft.block.BlockDynamicLiquid.updateTick(BlockDynamicLiquid.java:159)

at net.minecraft.block.Block.randomTick(Block.java:528)

at net.minecraft.world.WorldServer.updateBlocks(WorldServer.java:467)

at net.minecraft.world.WorldServer.tick(WorldServer.java:228)

 

-- Affected level --

Details:

Level name: New World

All players: 1 total; [EntityPlayerMP['Player946'/0, l='New World', x=-327.50, y=56.00, z=-186.71]]

Chunk stats: ServerChunkCache: 363 Drop: 0

Level seed: -6999197709684721328

Level generator: ID 01 - flat, ver 0. Features enabled: true

Level generator options: 3;minecraft:bedrock,3*minecraft:stone,52*minecraft:sandstone;2;

Level spawn location: -268.00,56.00,-219.00 - World: (-268,56,-219), Chunk: (at 4,3,5 in -17,-14; contains blocks -272,0,-224 to -257,255,-209), Region: (-1,-1; contains chunks -32,-32 to -1,-1, blocks -512,0,-512 to -1,255,-1)

Level time: 2653622 game time, 6000 day time

Level dimension: 0

Level storage version: 0x04ABD - Anvil

Level weather: Rain time: 1 (now: false), thunder time: 1 (now: false)

Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true

Stacktrace:

at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:763)

at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:669)

at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:171)

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:540)

at java.lang.Thread.run(Unknown Source)

 

-- System Details --

Details:

Minecraft Version: 1.8

Operating System: Windows 7 (x86) version 6.1

Java Version: 1.7.0_71, Oracle Corporation

Java VM Version: Java HotSpot Client VM (mixed mode), Oracle Corporation

Memory: 771717128 bytes (735 MB) / 1060372480 bytes (1011 MB) up to 1060372480 bytes (1011 MB)

JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M

IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0

FML: MCP v9.10 FML v8.0.37.1334 Minecraft Forge 11.14.1.1334 5 mods loaded, 5 mods active

mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

FML{8.0.37.1334} [Forge Mod Loader] (forgeSrc-1.8-11.14.1.1334.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

Forge{11.14.1.1334} [Minecraft Forge] (forgeSrc-1.8-11.14.1.1334.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

SteveIceBucket{1.0.3} [steve's Ice Bucket] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

MorePlanets{2.0.0} [More Planets] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

Loaded coremods (and transformers):

Profiler Position: N/A (disabled)

Player Count: 1 / 8; [EntityPlayerMP['Player946'/0, l='New World', x=-327.50, y=56.00, z=-186.71]]

Type: Integrated Server (map_client.txt)

Is Modded: Definitely; Client brand changed to 'fml,forge'

 

 

 

I can't click spoiler because my connection is slowy. -.-

 

Link to comment
Share on other sites

Hi.

 

If the code and spoiler buttons don't work, you can type them

 

[co de ]

code here

[/co de]

 

(remove the spaces)

 

This part of the error message

BlockState{block=minecraft:flowing_water, properties=[level]}

from

java.lang.IllegalArgumentException: Cannot set property PropertyEnum{name=variant, clazz=class stevekung.mods.moreplanets.planets.fronos.blocks.BlockGlassGemCorn1$BlockType, values=[state_bottom1, state_bottom2, state_middle1, state_middle2, state_middle3, state_top1]} as it does not exist in BlockState{block=minecraft:flowing_water, properties=[level]}

  at net.minecraft.block.state.BlockState$StateImplementation.withProperty(BlockState.java:182)

  at stevekung.mods.moreplanets.planets.fronos.blocks.BlockGlassGemCorn1.canBlockStay(BlockGlassGemCorn1.java:137)

 

shows that your BlockGlassGemCorn1.canBlockStay is assuming that a block can be cast to type BlockGlassGemCorn, but it's actually a vanilla water block.  So when you try to set the block state of the water block, it doesn't like it.

 

-TGG

 

 

 

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.