Jump to content

  • Curse Sites
Become a Premium Member! Help
Latest News Article

Generate a structure when a block with specified position = air


  • Please log in to reply
9 replies to this topic

#1

poiuytrezay
  • Minecraft: Shade_Terror

Posted 12 April 2012 - 10:46 AM

Hi,
As i say in the title, I would like to generate a structure when blocks at certain position are destroyed, equal air. I tried some things,but it was a failure,so I shall return to the forum...
Here 's my code :
( As you can see, I've tried to add an update on the block who need to be destroyed for spawn structure )
public void generateSurface(World world, Random rand, int i, int j)
{
	for(int k = 0; k < 1; k++)
	{
		int RandPosX = i + rand.nextInt(16);
		int RandPosY = rand.nextInt(128);
		int RandPosZ = j + rand.nextInt(16);
		(new WorldGenEternalFrostDungeon()).generate(world, rand, RandPosX, RandPosY, RandPosZ);
		world.markBlockNeedsUpdate(RandPosX + -24, RandPosY + 1, RandPosZ + 14);
		world.markBlockNeedsUpdate(RandPosX + -24, RandPosY + 1, RandPosZ + 14);
		int l = world.getBlockId(RandPosX + -24, RandPosY + 1, RandPosZ + 14);
		int m = world.getBlockId(RandPosX + -20, RandPosY + 1, RandPosZ + 14);
		if (l == 0 && m == 0)
		{
			(new WorldGenEternalFrostDungeon2()).generate(world, rand, RandPosX, RandPosY, RandPosZ);
		 }
	}
}

Posted Image

Register or log in to remove.

#2

poiuytrezay
  • Minecraft: Shade_Terror

Posted 12 April 2012 - 07:21 PM

Some help ? Please >.<
Posted Image

#3

poiuytrezay
  • Minecraft: Shade_Terror

Posted 14 April 2012 - 11:04 AM

No one know this ? >.<
Posted Image

#4

TheJmax04
  • Location: Zorgotron
  • Minecraft: J3TS

Posted 14 April 2012 - 11:49 AM

maybe theres a problem with adding a negative to another field, i wouldnt know though, im a noob... just try
				world.markBlockNeedsUpdate(RandPosX - 24, RandPosY + 1, RandPosZ + 14);
				world.markBlockNeedsUpdate(RandPosX - 20, RandPosY + 1, RandPosZ + 14);
				int l = world.getBlockId(RandPosX - 24, RandPosY + 1, RandPosZ + 14);
				int m = world.getBlockId(RandPosX - 20, RandPosY + 1, RandPosZ + 14);

Posted Image

#5

Beardedcow

Posted 14 April 2012 - 12:11 PM

I think you are calling this in the wrong place. generate surface happens when you first generate a chunk and then is never called again, I don't think. so you need to set it up with a block its self, I would think, I not really completely sure having never done this before.

#6

poiuytrezay
  • Minecraft: Shade_Terror

Posted 17 April 2012 - 08:42 PM

I've find a solution : Use a spawner block on destroy =)
Posted Image

#7

Bakenokawa
  • Location: US
  • Minecraft: tytrin

Posted 18 April 2012 - 12:46 AM

View Postpoiuytrezay, on 17 April 2012 - 08:42 PM, said:

I've find a solution : Use a spawner block on destroy =)

I am intensely curious as this sounds similar to an operation I am trying to perform, although I am no where near as advanced as you are in this case. Would you care to share what exactly you mean by "use a spawner block on destroy"?
[!]Please visit my WIP page!I am working on updating my Floating Islands mod and developing a new one!
Operor non relinquo sapientia , quod is mos servo youlove ; suus quod is mos (Prov. 4:6)

#8

SpeedStar5
  • Location: UK
  • Minecraft: blake5961

Posted 18 April 2012 - 01:02 AM

You could look into using either of these methods to generate it:
	public void onBlockDestroyedByPlayer(World world, int i, int j, int k, int l)
	{
	}
Or:
	public boolean blockActivated(World par1World, int par2, int par3, int i, EntityPlayer entityplayer)
	{
		return false;
	}
Then using your Frost Dungeon generation code in those rather than in generate.
If I have been helpful then +Rep  would be nice :3  That's the button over there -->

#9

poiuytrezay
  • Minecraft: Shade_Terror

Posted 18 April 2012 - 09:27 AM

I've doing this :
	public void onBlockDestroyedByPlayer(World world, int i, int j, int k, int l)
	{
		world.setBlockWithNotify(i, j, k, mod_Freezer.piece2.blockID);  
		(new WorldGenEternalFrostDungeonChest1()).generate(world, rand, i, j, k);
	}

Block piece2 :
public void onBlockDestroyedByPlayer(World world, int i, int j, int k, int l)
{
	(new WorldGenEternalFrostDungeon2()).generate(world, rand, i + 24, j - 1, k - 14);
}

Posted Image

#10

Bakenokawa
  • Location: US
  • Minecraft: tytrin

Posted 19 April 2012 - 01:46 PM

Thank you much! This will certainly help with my mods , if and when I get there.
[!]Please visit my WIP page!I am working on updating my Floating Islands mod and developing a new one!
Operor non relinquo sapientia , quod is mos servo youlove ; suus quod is mos (Prov. 4:6)