You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
149 lines
4.5 KiB
Java
149 lines
4.5 KiB
Java
package net.minecraft.block;
|
|
|
|
import java.util.Random;
|
|
import net.minecraft.init.Blocks;
|
|
import net.minecraft.world.World;
|
|
import net.minecraft.world.gen.feature.WorldGenBigMushroom;
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
|
|
|
public class BlockMushroom extends BlockBush implements IGrowable
|
|
{
|
|
private static final String __OBFID = "CL_00000272";
|
|
|
|
protected BlockMushroom()
|
|
{
|
|
float f = 0.2F;
|
|
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f);
|
|
this.setTickRandomly(true);
|
|
}
|
|
|
|
/**
|
|
* Ticks the block if it's been scheduled
|
|
*/
|
|
public void updateTick(World worldIn, int x, int y, int z, Random random)
|
|
{
|
|
if (random.nextInt(25) == 0)
|
|
{
|
|
byte b0 = 4;
|
|
int l = 5;
|
|
int i1;
|
|
int j1;
|
|
int k1;
|
|
|
|
for (i1 = x - b0; i1 <= x + b0; ++i1)
|
|
{
|
|
for (j1 = z - b0; j1 <= z + b0; ++j1)
|
|
{
|
|
for (k1 = y - 1; k1 <= y + 1; ++k1)
|
|
{
|
|
if (worldIn.getBlock(i1, k1, j1) == this)
|
|
{
|
|
--l;
|
|
|
|
if (l <= 0)
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
i1 = x + random.nextInt(3) - 1;
|
|
j1 = y + random.nextInt(2) - random.nextInt(2);
|
|
k1 = z + random.nextInt(3) - 1;
|
|
|
|
for (int l1 = 0; l1 < 4; ++l1)
|
|
{
|
|
if (worldIn.isAirBlock(i1, j1, k1) && this.canBlockStay(worldIn, i1, j1, k1))
|
|
{
|
|
x = i1;
|
|
y = j1;
|
|
z = k1;
|
|
}
|
|
|
|
i1 = x + random.nextInt(3) - 1;
|
|
j1 = y + random.nextInt(2) - random.nextInt(2);
|
|
k1 = z + random.nextInt(3) - 1;
|
|
}
|
|
|
|
if (worldIn.isAirBlock(i1, j1, k1) && this.canBlockStay(worldIn, i1, j1, k1))
|
|
{
|
|
worldIn.setBlock(i1, j1, k1, this, 0, 2);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
|
|
*/
|
|
public boolean canPlaceBlockAt(World worldIn, int x, int y, int z)
|
|
{
|
|
return super.canPlaceBlockAt(worldIn, x, y, z) && this.canBlockStay(worldIn, x, y, z);
|
|
}
|
|
|
|
/**
|
|
* is the block grass, dirt or farmland
|
|
*/
|
|
protected boolean canPlaceBlockOn(Block ground)
|
|
{
|
|
return ground.func_149730_j();
|
|
}
|
|
|
|
/**
|
|
* Can this block stay at this position. Similar to canPlaceBlockAt except gets checked often with plants.
|
|
*/
|
|
public boolean canBlockStay(World worldIn, int x, int y, int z)
|
|
{
|
|
if (y >= 0 && y < 256)
|
|
{
|
|
Block block = worldIn.getBlock(x, y - 1, z);
|
|
return block == Blocks.mycelium || block == Blocks.dirt && worldIn.getBlockMetadata(x, y - 1, z) == 2 || worldIn.getFullBlockLightValue(x, y, z) < 13 && block.canSustainPlant(worldIn, x, y - 1, z, ForgeDirection.UP, this);
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public boolean func_149884_c(World p_149884_1_, int p_149884_2_, int p_149884_3_, int p_149884_4_, Random p_149884_5_)
|
|
{
|
|
int l = p_149884_1_.getBlockMetadata(p_149884_2_, p_149884_3_, p_149884_4_);
|
|
p_149884_1_.setBlockToAir(p_149884_2_, p_149884_3_, p_149884_4_);
|
|
WorldGenBigMushroom worldgenbigmushroom = null;
|
|
|
|
if (this == Blocks.brown_mushroom)
|
|
{
|
|
worldgenbigmushroom = new WorldGenBigMushroom(0);
|
|
}
|
|
else if (this == Blocks.red_mushroom)
|
|
{
|
|
worldgenbigmushroom = new WorldGenBigMushroom(1);
|
|
}
|
|
|
|
if (worldgenbigmushroom != null && worldgenbigmushroom.generate(p_149884_1_, p_149884_5_, p_149884_2_, p_149884_3_, p_149884_4_))
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
p_149884_1_.setBlock(p_149884_2_, p_149884_3_, p_149884_4_, this, l, 3);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public boolean func_149851_a(World worldIn, int x, int y, int z, boolean isClient)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public boolean func_149852_a(World worldIn, Random random, int x, int y, int z)
|
|
{
|
|
return (double)random.nextFloat() < 0.4D;
|
|
}
|
|
|
|
public void func_149853_b(World worldIn, Random random, int x, int y, int z)
|
|
{
|
|
this.func_149884_c(worldIn, x, y, z, random);
|
|
}
|
|
} |