Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.chef.mod.crops;
- import java.util.Random;
- import net.minecraft.block.Block;
- import net.minecraft.block.IGrowable;
- import net.minecraft.block.material.Material;
- import net.minecraft.entity.EntityLivingBase;
- import net.minecraft.init.Blocks;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.util.AxisAlignedBB;
- import net.minecraft.world.IBlockAccess;
- import net.minecraft.world.World;
- import net.minecraftforge.common.EnumPlantType;
- import net.minecraftforge.common.IPlantable;
- import com.chef.mod.init.MyBlocks;
- import com.chef.mod.init.MyItems;
- import cpw.mods.fml.relauncher.Side;
- import cpw.mods.fml.relauncher.SideOnly;
- public class BlockNori extends Block {
- float f = 0.375f;
- public BlockNori() {
- super(Material.water);
- this.setStepSound(soundTypeGrass);
- this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 1.0F, 0.5F + f);
- this.setTickRandomly(true);
- }
- @Override
- public boolean canPlaceBlockAt(World worldIn, int x, int y, int z) {
- Block ground = worldIn.getBlock(x, y - 1, z);
- Block above = worldIn.getBlock(x, y + 1, z);
- if (ground == Blocks.gravel || ground == Blocks.dirt || ground == Blocks.sand || ground == MyBlocks.nori) {
- if (above == Blocks.water) {
- return true;
- }
- }
- return false;
- }
- /**
- * Called when a neighboring block changes.
- */
- public void onNeighborBlockChange(World worldIn, int x, int y, int z, Block neighborBlock) {
- this.checkForDrop(worldIn, x, y, z);
- }
- public void breakBlock(World worldIn, int x, int y, int z) {
- worldIn.setBlock(x, y, z, Blocks.water);
- }
- protected final boolean checkForDrop(World worldIn, int x, int y, int z) {
- if (this.canBlockStay(worldIn, x, y, z)) {
- return true;
- } else {
- this.dropBlockAsItem(worldIn, x, y, z, worldIn.getBlockMetadata(x, y, z), 0);
- worldIn.setBlock(x, y, z, Blocks.water);
- return false;
- }
- }
- public boolean canBlockStay(World world, int x, int y, int z) {
- return this.canPlaceBlockAt(world, x, y, z);
- }
- @Override
- public AxisAlignedBB getCollisionBoundingBoxFromPool(World worldIn, int x, int y, int z) {
- return null;
- }
- @Override
- public boolean isOpaqueCube() {
- return false;
- }
- @Override
- public boolean renderAsNormalBlock() {
- return false;
- }
- @Override
- public int getRenderType() {
- return 1;
- }
- @Override
- public void updateTick(World worldIn, int x, int y, int z, Random rand) {
- if (worldIn.getBlock(x, y, z) == MyBlocks.nori) {
- if (worldIn.getBlock(x, y + 2, z) == Blocks.water) {
- int i;
- for (i = 1; worldIn.getBlock(x, y - i, z) == this; ++i) {
- }
- if (i < 5) {
- int level = worldIn.getBlockMetadata(x, y, z);
- if (level == 15) {
- worldIn.setBlock(x, y + 1, z, this);
- worldIn.setBlockMetadataWithNotify(x, y, z, 0, 4);
- } else {
- worldIn.setBlockMetadataWithNotify(x, y, z, level + 1, 4);
- }
- }
- }
- }
- }
- @Override
- @SideOnly(Side.CLIENT)
- public Item getItem(World world, int x, int y, int z) {
- return MyItems.nori_leaf;
- }
- @Override
- public Item getItemDropped(int metadata, Random rand, int fortune) {
- return MyItems.nori_leaf;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment