I need to more of how to work with multi-blocks, to make structure that "incubates" an egg when a netherrack is place under an obsidian, under an egg (the egg is a block). I want to make this structure for a mod about breeding dragons. If there are any better alternatives to multiblocks or some good sources for tutorials, let me know in the comments below.
You're usually not going to find a tutorial that is that specific. What you're asking is very simple. The egg block just need to check whether it is under the blocks you need to incubate it. For a block to have complex logic it usually makes sense to make it.a tile entity.
So just make your egg block have a tile entity that checks for the required blocks above it and increments the incubation timer.
You don't necessarily need a tile entity; for example, here is the updateTick() method for cactus (from the source for 1.6.4):
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
if (par1World.isAirBlock(par2, par3 + 1, par4))
{
int var6;
for (var6 = 1; par1World.getBlockId(par2, par3 - var6, par4) == this.blockID; ++var6)
{
;
}
if (var6 < 3)
{
int var7 = par1World.getBlockMetadata(par2, par3, par4);
if (var7 == 15)
{
par1World.setBlock(par2, par3 + 1, par4, this.blockID);
par1World.setBlockMetadataWithNotify(par2, par3, par4, 0, 4);
this.onNeighborBlockChange(par1World, par2, par3 + 1, par4, this.blockID);
}
else
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, var7 + 1, 4);
}
}
}
}
First it checks to see if the block above is an air block, then it counts the number of cactus blocks below and if there are less than 3 it either grows a new block if its data value is 15 (a total of 16 stages since it starts at 0 and does not grow until the next tick after it reaches 15) or increments it by one; since a block receives a block update once every 68.27 seconds on average it takes about 18 minutes to grow a new block (this can easily be extended by adding a random chance to advance to the next stage; e.g. random.nextFloat() < 0.3F will increase the average time to about an hour; reducing the time requires reducing the number of stages; e.g. 8 stages (0-7) will give half the time).
The main advantage of a tile entity is that the time can be more predictable or even exact (I'd assume you'd want some randomness though) since you don't need to rely on random block updates and you can store additional data (e.g. type of dragon and texture) without requiring an entire new block for each type or limiting the number of types/growth stages (e.g. 4 stages and 4 types, or 2 bits for each, as there are only 16 data values / 4 bits to work with) but it increases code complexity (multiple blocks would not necessarily be more complex since you could reuse the same class with a different dragon type passed into its constructor; as seen above it refers to "this.blockID" instead of a specific block's ID (or just "this" in 1.7+ as they no longer use numerical IDs) so you could easily use this vanilla code for your own cactus blocks).
Yeah, I was going to mention that random tick block could be used, but I'm predicting that the person will want other complicated behavior from the egg block -- like a hatching process and such, maybe with animated model -- so figured might as well get them to bite the bullet and do a tile entity. Plant growth and such works because there isn't a lot of different states to keep track of, but if you wanted to track information like who "laid" the egg then probably tile entity makes more sense.
I need to more of how to work with multi-blocks, to make structure that "incubates" an egg when a netherrack is place under an obsidian, under an egg (the egg is a block). I want to make this structure for a mod about breeding dragons. If there are any better alternatives to multiblocks or some good sources for tutorials, let me know in the comments below.
You're usually not going to find a tutorial that is that specific. What you're asking is very simple. The egg block just need to check whether it is under the blocks you need to incubate it. For a block to have complex logic it usually makes sense to make it.a tile entity.
So just make your egg block have a tile entity that checks for the required blocks above it and increments the incubation timer.
You don't necessarily need a tile entity; for example, here is the updateTick() method for cactus (from the source for 1.6.4):
First it checks to see if the block above is an air block, then it counts the number of cactus blocks below and if there are less than 3 it either grows a new block if its data value is 15 (a total of 16 stages since it starts at 0 and does not grow until the next tick after it reaches 15) or increments it by one; since a block receives a block update once every 68.27 seconds on average it takes about 18 minutes to grow a new block (this can easily be extended by adding a random chance to advance to the next stage; e.g. random.nextFloat() < 0.3F will increase the average time to about an hour; reducing the time requires reducing the number of stages; e.g. 8 stages (0-7) will give half the time).
The main advantage of a tile entity is that the time can be more predictable or even exact (I'd assume you'd want some randomness though) since you don't need to rely on random block updates and you can store additional data (e.g. type of dragon and texture) without requiring an entire new block for each type or limiting the number of types/growth stages (e.g. 4 stages and 4 types, or 2 bits for each, as there are only 16 data values / 4 bits to work with) but it increases code complexity (multiple blocks would not necessarily be more complex since you could reuse the same class with a different dragon type passed into its constructor; as seen above it refers to "this.blockID" instead of a specific block's ID (or just "this" in 1.7+ as they no longer use numerical IDs) so you could easily use this vanilla code for your own cactus blocks).
TheMasterCaver's First World - possibly the most caved-out world in Minecraft history - includes world download.
TheMasterCaver's World - my own version of Minecraft largely based on my views of how the game should have evolved since 1.6.4.
Why do I still play in 1.6.4?
Yeah, I was going to mention that random tick block could be used, but I'm predicting that the person will want other complicated behavior from the egg block -- like a hatching process and such, maybe with animated model -- so figured might as well get them to bite the bullet and do a tile entity. Plant growth and such works because there isn't a lot of different states to keep track of, but if you wanted to track information like who "laid" the egg then probably tile entity makes more sense.
Sorry for the late reply, ill go with a TE.