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.
179 lines
5.3 KiB
Java
179 lines
5.3 KiB
Java
package net.minecraft.block;
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
import java.util.Random;
|
|
import net.minecraft.block.material.Material;
|
|
import net.minecraft.init.Blocks;
|
|
import net.minecraft.init.Items;
|
|
import net.minecraft.item.Item;
|
|
import net.minecraft.util.AxisAlignedBB;
|
|
import net.minecraft.world.IBlockAccess;
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraftforge.common.EnumPlantType;
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
|
import net.minecraftforge.common.IPlantable;
|
|
|
|
public class BlockReed extends Block implements IPlantable
|
|
{
|
|
private static final String __OBFID = "CL_00000300";
|
|
|
|
protected BlockReed()
|
|
{
|
|
super(Material.plants);
|
|
float f = 0.375F;
|
|
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 1.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 (worldIn.getBlock(x, y - 1, z) == Blocks.reeds || this.func_150170_e(worldIn, x, y, z))
|
|
{
|
|
if (worldIn.isAirBlock(x, y + 1, z))
|
|
{
|
|
int l;
|
|
|
|
for (l = 1; worldIn.getBlock(x, y - l, z) == this; ++l)
|
|
{
|
|
;
|
|
}
|
|
|
|
if (l < 3)
|
|
{
|
|
int i1 = worldIn.getBlockMetadata(x, y, z);
|
|
|
|
if (i1 == 15)
|
|
{
|
|
worldIn.setBlock(x, y + 1, z, this);
|
|
worldIn.setBlockMetadataWithNotify(x, y, z, 0, 4);
|
|
}
|
|
else
|
|
{
|
|
worldIn.setBlockMetadataWithNotify(x, y, z, i1 + 1, 4);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 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)
|
|
{
|
|
Block block = worldIn.getBlock(x, y - 1, z);
|
|
return block.canSustainPlant(worldIn, x, y - 1, z, ForgeDirection.UP, this);
|
|
}
|
|
|
|
/**
|
|
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
|
|
* their own) Args: x, y, z, neighbor Block
|
|
*/
|
|
public void onNeighborBlockChange(World worldIn, int x, int y, int z, Block neighbor)
|
|
{
|
|
this.func_150170_e(worldIn, x, y, z);
|
|
}
|
|
|
|
protected final boolean func_150170_e(World p_150170_1_, int p_150170_2_, int p_150170_3_, int p_150170_4_)
|
|
{
|
|
if (!this.canBlockStay(p_150170_1_, p_150170_2_, p_150170_3_, p_150170_4_))
|
|
{
|
|
this.dropBlockAsItem(p_150170_1_, p_150170_2_, p_150170_3_, p_150170_4_, p_150170_1_.getBlockMetadata(p_150170_2_, p_150170_3_, p_150170_4_), 0);
|
|
p_150170_1_.setBlockToAir(p_150170_2_, p_150170_3_, p_150170_4_);
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 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)
|
|
{
|
|
return this.canPlaceBlockAt(worldIn, x, y, z);
|
|
}
|
|
|
|
/**
|
|
* Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
|
|
* cleared to be reused)
|
|
*/
|
|
public AxisAlignedBB getCollisionBoundingBoxFromPool(World worldIn, int x, int y, int z)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
public Item getItemDropped(int meta, Random random, int fortune)
|
|
{
|
|
return Items.reeds;
|
|
}
|
|
|
|
/**
|
|
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
|
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
|
*/
|
|
public boolean isOpaqueCube()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
|
|
*/
|
|
public boolean renderAsNormalBlock()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* The type of render function that is called for this block
|
|
*/
|
|
public int getRenderType()
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
/**
|
|
* Gets an item for the block being called on. Args: world, x, y, z
|
|
*/
|
|
@SideOnly(Side.CLIENT)
|
|
public Item getItem(World worldIn, int x, int y, int z)
|
|
{
|
|
return Items.reeds;
|
|
}
|
|
|
|
/**
|
|
* Returns a integer with hex for 0xrrggbb with this color multiplied against the blocks color. Note only called
|
|
* when first determining what to render.
|
|
*/
|
|
@SideOnly(Side.CLIENT)
|
|
public int colorMultiplier(IBlockAccess worldIn, int x, int y, int z)
|
|
{
|
|
return worldIn.getBiomeGenForCoords(x, z).getBiomeGrassColor(x, y, z);
|
|
}
|
|
|
|
@Override
|
|
public EnumPlantType getPlantType(IBlockAccess world, int x, int y, int z)
|
|
{
|
|
return EnumPlantType.Beach;
|
|
}
|
|
|
|
@Override
|
|
public Block getPlant(IBlockAccess world, int x, int y, int z)
|
|
{
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public int getPlantMetadata(IBlockAccess world, int x, int y, int z)
|
|
{
|
|
return world.getBlockMetadata(x, y, z);
|
|
}
|
|
} |