Fixed bamboo on Podzol and Dirt. Closes #300

This commit is contained in:
Adubbz 2014-08-02 16:35:25 +10:00
parent 670b31a773
commit c7cd3b343c
2 changed files with 52 additions and 83 deletions

View file

@ -18,9 +18,6 @@ public class BambooRenderer implements ISimpleBlockRenderingHandler
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
{
//TODO: setBlockBounds
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
//TODO: colorMultiplier
int l = block.colorMultiplier(world, x, y, z);
float f = (float)(l >> 16 & 255) / 255.0F;
@ -56,22 +53,15 @@ public class BambooRenderer implements ISimpleBlockRenderingHandler
float f17 = f5 * f2;
float f18 = f6 * f2;
float pixel = 0.0625F;
//TODO: getMixedBrightnessForBlock()
int m = block.getMixedBrightnessForBlock(world, x, y, z);
//Need to make public: renderAllFaces, renderMinY, renderMaxY
//TODO: renderAllFaces shouldSideBeRendered()
if (renderer.renderAllFaces || block.shouldSideBeRendered(world, x, y - 1, z, 0))
{
//TODO: renderMinY getMixedBrightnessForBlock()
tessellator.setBrightness(renderer.renderMinY > 0.0D ? m : block.getMixedBrightnessForBlock(world, x, y - 1, z));
tessellator.setColorOpaque_F(r, g, b);
//TODO: renderFaceYNeg getBlockIcon()
renderer.renderFaceYNeg(block, (double)x, (double)y, (double)z, renderer.getBlockIcon(block, world, x, y, z, 0));
}
//TODO: renderAllFaces shouldSideBeRendered()
if (renderer.renderAllFaces || block.shouldSideBeRendered(world, x, y + 1, z, 1))
{
//TODO: renderMaxY getMixedBrightnessForBlock()
@ -101,8 +91,6 @@ public class BambooRenderer implements ISimpleBlockRenderingHandler
renderer.renderFaceXPos(block, (double)x - (pixel * 4), (double)y, (double)z, renderer.getBlockIcon(block, world, x, y, z, 5));
tessellator.addTranslation(pixel, 0.0F, 0.0F);
return true;
}

View file

@ -1,45 +1,40 @@
package biomesoplenty.common.blocks;
import java.util.List;
import static net.minecraftforge.common.EnumPlantType.Plains;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.util.ForgeDirection;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.client.render.RenderUtils;
public class BlockBamboo extends Block
public class BlockBamboo extends Block implements IPlantable
{
private IIcon bambooSide;
private IIcon bambooTop;
public BlockBamboo()
{
//TODO: Material.plants
super(Material.plants);
//TODO: this.setHardness
this.setHardness(0.2F);
//TODO setStepSound(Block.soundWoodFootstep)
this.setStepSound(Block.soundTypeWood);
//TODO: setTickRandomly()
this.setTickRandomly(true);
//TODO: this.setCreativeTab()
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
//TODO: registerIcons()
public void registerBlockIcons(IIconRegister iconRegister)
{
bambooSide = iconRegister.registerIcon("biomesoplenty:bamboo");
@ -47,7 +42,6 @@ public class BlockBamboo extends Block
}
@Override
//TODO: getIcon()
public IIcon getIcon(int side, int meta)
{
if (side > 1)
@ -56,16 +50,31 @@ public class BlockBamboo extends Block
return bambooTop;
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
{
return getBoundingBox(world, x, y, z);
}
@Override
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z)
{
return getBoundingBox(world, x, y, z);
}
private AxisAlignedBB getBoundingBox(World world, int x, int y, int z)
{
float pixel = 0.0625F;
return AxisAlignedBB.getBoundingBox(x + pixel * 4, y, z + pixel * 4, x + 1 - pixel * 4, y + 1, z + 1 - pixel * 4);
}
@Override
//TODO: updateTick()
public void updateTick(World world, int x, int y, int z, Random random)
{
//TODO: isAirBlock()
if (world.isAirBlock(x, y + 1, z))
{
int var6;
//TODO: getBlock()
for (var6 = 1; world.getBlock(x, y - var6, z) == this; ++var6)
{
;
@ -77,7 +86,6 @@ public class BlockBamboo extends Block
if (var7 == 15)
{
//TODO: setBlock()
world.setBlock(x, y + 1, z, this, 0, 2);
world.setBlockMetadataWithNotify(x, y, z, 0, 2);
}
@ -90,51 +98,6 @@ public class BlockBamboo extends Block
}
@Override
//TODO: getSelectedBoundingBoxFromPool()
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z)
{
float pixel = 0.0625F;
return AxisAlignedBB.getBoundingBox((double)x + (1.0F - (pixel * 4)), (double)y, (double)z + (1.0F - (pixel * 4)), (double)x + (pixel * 4), (double)y + 1.0F, (double)z + (pixel * 4));
}
@Override
//TODO: addCollisionBoxesToList()
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB axisAlignedBB, List list, Entity entity)
{
float pixel = 0.0625F;
//TODO: setBlockBounds
this.setBlockBounds((pixel * 4), 0.0F, (pixel * 4), 1.0F - (pixel * 4), 1.0F, 1.0F - (pixel * 4));
super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity);
//TODO: setBlockBoundsForItemRender()
this.setBlockBoundsForItemRender();
}
@Override
//TODO: setBlockBoundsForItemRender()
public void setBlockBoundsForItemRender()
{
//TODO: setBlockBounds
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
@Override
//TODO: canPlaceBlockAt
public boolean canPlaceBlockAt(World world, int x, int y, int z)
{
//TODO: getBlock
Block block = world.getBlock(x, y - 1, z);
if (block == this)
return true;
else if (block == Blocks.grass)
return true;
else
return false;
}
@Override
//TODO: onNeighborBlockChange()
public void onNeighborBlockChange(World world, int x, int y, int z, Block neighborBlock)
{
this.checkBlockCoordValid(world, x, y, z);
@ -142,40 +105,40 @@ public class BlockBamboo extends Block
public final void checkBlockCoordValid(World world, int x, int y, int z)
{
//TODO: canBlockStay()
if (!this.canBlockStay(world, x, y, z))
{
//TODO: dropBlockAsItem()
this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
//TODO: setBlockToAir
world.setBlockToAir(x, y, z);
}
}
@Override
public boolean canPlaceBlockAt(World world, int x, int y, int z)
{
return super.canPlaceBlockAt(world, x, y, z) && this.canBlockStay(world, x, y, z);
}
@Override
//TODO: canBlockStay()
public boolean canBlockStay(World world, int x, int y, int z)
{
//TODO: canPlaceBlockAt
return this.canPlaceBlockAt(world, x, y, z);
Block bottomBlock = world.getBlock(x, y - 1, z);
return bottomBlock.canSustainPlant(world, x, y - 1, z, ForgeDirection.UP, this) || bottomBlock == this;
}
@Override
//TODO: isOpaqueCube()
public boolean isOpaqueCube()
{
return false;
}
@Override
//TODO: renderAsNormalBlock()
public boolean renderAsNormalBlock()
{
return false;
}
@Override
//TODO getRenderType()
public int getRenderType()
{
return RenderUtils.bambooModel;
@ -193,4 +156,22 @@ public class BlockBamboo extends Block
return true;
}
@Override
public EnumPlantType getPlantType(IBlockAccess world, int x, int y, int z)
{
return Plains;
}
@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);
}
}