Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I am trying to Generate a flower like block. right now it extends Blockbush. i seem to be having trouble with this line

 

          if (worldIn.isAirBlock(blockpos) && (!worldIn.provider.getHasNoSky() || blockpos.getY() < 255) && this.getBlock.canBlockStay(worldIn, blockpos, this.state))

 

this part makes my game crash this.getBlock.canBlockStay(worldIn, blockpos, this.state)

 

http://pastebin.com/ZpERMRM6

 

http://pastebin.com/X1TpkUcM

 

 

I have this and this works fine:

public WorldGenerator BUSH= new WorldGenBush((BlockBush) BlockClass.BLOCK);

@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
	switch (world.provider.getDimension()) {
	case -1:
		break;
	case 0:
		runGenerator(BUSH, world, random, chunkX, chunkZ, 7, 50, 120);
		break;
	case 1:
		break;
	}
}

private void runGenerator(WorldGenerator generator, World world, Random random, int chunk_X, int chunk_Z, int chancesToSpawn, int minHeight, int maxHeight){
	if (minHeight < 0 || maxHeight > 256 || minHeight > maxHeight){
		throw new IllegalArgumentException("Illegal Height Arguments for WorldGenerator");
	}
	int heightDiff = maxHeight - minHeight + 1;
	for (int i = 0; i < chancesToSpawn; i++); {
		int x = chunk_X * 16 + random.nextInt(16);
		int y = minHeight  + random.nextInt(heightDiff);
		int z = chunk_Z * 16 + random.nextInt(16);
		generator.generate(world, random, new BlockPos(x, y, z));
	}
}

}

  • Author

Encountered an unexpected exception

java.lang.NullPointerException

at net.minecraft.block.BlockBush.canBlockStay(BlockBush.java:80) ~[blockBush.class:?]

at com.mightydanp.eot.api.common.world.gen.feature.IWorldGenTwigs.generate(IWorldGenTwigs.java:31) ~[iWorldGenTwigs.class:?]

at com.mightydanp.eot.api.common.world.gen.IWorldGen.spawnTwigs(IWorldGen.java:57) ~[iWorldGen.class:?]

at com.mightydanp.eot.common.world.gen.WorldGen.generateSurface(WorldGen.java:51) ~[WorldGen.class:?]

at com.mightydanp.eot.api.common.world.gen.IWorldGen.generate(IWorldGen.java:28) ~[iWorldGen.class:?]

 

http://pastebin.com/A5Fiq6uA

 

http://pastebin.com/36390A3G

 

spawnTwigs(ModBlocks.twigs, world, random, chunkX, chunkZ, 7);

You never assign a value to IWorldGenTwigs#state, so it is null and Java throws an NPE when it is referenced.

 

While not the cause of the problem IWorldGenTwigs should be called WorldGenTwigs, as it is a class, not an interface.

  • Author

i have tried to set the blocks state with this.getBlock.getDefaultState() and this.getBlock.canBlockStay(worldIn, blockpos, this.getBlock.getStateFromMeta(0)

 

neither of them work and it gives the same exact crash

  • Author

if (worldIn.isAirBlock(blockpos) && (!worldIn.provider.getHasNoSky() || blockpos.getY() < 255) && this.getBlock.canBlockStay(worldIn, blockpos,this.getBlock.getDefaultState() ))

  • Author

at com.mightydanp.eot.api.common.world.gen.feature.IWorldGenTwigs.generate(IWorldGenTwigs.java:23) ~[iWorldGenTwigs.class:?]

at com.mightydanp.eot.api.common.world.gen.IWorldGen.spawnTwigs(IWorldGen.java:57) ~[iWorldGen.class:?]

at com.mightydanp.eot.common.world.gen.WorldGen.generateSurface(WorldGen.java:51) ~[WorldGen.class:?]

at com.mightydanp.eot.api.common.world.gen.IWorldGen.generate(IWorldGen.java:28) ~[iWorldGen.class:?]

at net.minecraftforge.fml.common.registry.GameRegistry.generateWorld(GameRegistry.java:120) ~[GameRegistry.class:?]

at net.minecraft.world.chunk.Chunk.populateChunk(Chunk.java:1070) ~[Chunk.class:?]

at net.minecraft.world.chunk.Chunk.populateChunk(Chunk.java:1033) ~[Chunk.class:?]

at...

 

Dude, seriously. The first line is the most important one: it tells us/you what the error is.  The second line is the second most important: it tells us/you where the error is.  We need both.

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.

  • Author

In my Console in eclipse i get this

 

at com.mightydanp.eot.common.block.BlockTwigs.canBlockStay(BlockTwigs.java:50) ~[blockTwigs.class:?]

at com.mightydanp.eot.api.common.world.gen.feature.IWorldGenTwigs.generate(IWorldGenTwigs.java:23) ~[iWorldGenTwigs.class:?]

at com.mightydanp.eot.api.common.world.gen.IWorldGen.spawnTwigs(IWorldGen.java:57) ~[iWorldGen.class:?]

at com.mightydanp.eot.common.world.gen.WorldGen.generateSurface(WorldGen.java:51) ~[WorldGen.class:?]

at com.mightydanp.eot.api.common.world.gen.IWorldGen.generate(IWorldGen.java:28) ~[iWorldGen.class:?]

at net.minecraftforge.fml.common.registry.GameRegistry.generateWorld(GameRegistry.java:120) ~[GameRegistry.class:?]

at net.minecraft.world.chunk.Chunk.populateChunk(Chunk.java:1070) ~[Chunk.class:?]

at net.minecraft.world.chunk.Chunk.populateChunk(Chunk.java:1033) ~[Chunk.class:?]

at net.minecraft.world.gen.ChunkProviderServer.provideChunk(ChunkProviderServer.java:160) ~[ChunkProviderServer.class:?]

at net.minecraft.world.World.getChunkFromChunkCoords(World.java:349) ~[World.class:?]

 

  • Author

i removed && this.twig.canBlockStay(worldIn, blockpos, this.state and it still game me the same errors i showed you above

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.