New bamboo rendering

This commit is contained in:
Adubbz 2013-09-24 17:53:43 +10:00
parent 1c8115ebc8
commit 67b15ddfee
7 changed files with 156 additions and 8 deletions

View file

@ -4,8 +4,8 @@
<property name="mod.majorversion" value="1" /> <property name="mod.majorversion" value="1" />
<property name="mod.minecraftversion" value="1" /> <property name="mod.minecraftversion" value="1" />
<property name="mod.bugfixversion" value="0" /> <property name="mod.tweakversion" value="1" />
<property name="mod.version" value="${mod.majorversion}.${mod.minecraftversion}.${mod.bugfixversion}" /> <property name="mod.version" value="${mod.majorversion}.${mod.minecraftversion}.${mod.tweakversion}" />
<condition property="mod.build" value="${env.BUILD_NUMBER}" else="0"> <condition property="mod.build" value="${env.BUILD_NUMBER}" else="0">
<isset property="env.BUILD_NUMBER" /> <isset property="env.BUILD_NUMBER" />
</condition> </condition>

View file

@ -8,6 +8,7 @@ import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.entity.RenderSnowball; import net.minecraft.client.renderer.entity.RenderSnowball;
import biomesoplenty.api.Items; import biomesoplenty.api.Items;
import biomesoplenty.blocks.renderers.AltarRenderer; import biomesoplenty.blocks.renderers.AltarRenderer;
import biomesoplenty.blocks.renderers.BambooRenderer;
import biomesoplenty.blocks.renderers.FoliageRenderer; import biomesoplenty.blocks.renderers.FoliageRenderer;
import biomesoplenty.blocks.renderers.GraveRenderer; import biomesoplenty.blocks.renderers.GraveRenderer;
import biomesoplenty.blocks.renderers.PlantsRenderer; import biomesoplenty.blocks.renderers.PlantsRenderer;
@ -43,6 +44,7 @@ public class ClientProxy extends CommonProxy {
RenderUtils.puddleModel = RenderingRegistry.getNextAvailableRenderId(); RenderUtils.puddleModel = RenderingRegistry.getNextAvailableRenderId();
RenderUtils.bonesModel = RenderingRegistry.getNextAvailableRenderId(); RenderUtils.bonesModel = RenderingRegistry.getNextAvailableRenderId();
RenderUtils.graveModel = RenderingRegistry.getNextAvailableRenderId(); RenderUtils.graveModel = RenderingRegistry.getNextAvailableRenderId();
RenderUtils.bambooModel = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerEntityRenderingHandler(EntityMudball.class, new RenderSnowball(Items.mudball.get(), 0)); RenderingRegistry.registerEntityRenderingHandler(EntityMudball.class, new RenderSnowball(Items.mudball.get(), 0));
RenderingRegistry.registerEntityRenderingHandler(EntityDart.class, new RenderDart()); RenderingRegistry.registerEntityRenderingHandler(EntityDart.class, new RenderDart());
@ -58,6 +60,7 @@ public class ClientProxy extends CommonProxy {
RenderingRegistry.registerBlockHandler(new AltarRenderer()); RenderingRegistry.registerBlockHandler(new AltarRenderer());
RenderingRegistry.registerBlockHandler(new PuddleRender()); RenderingRegistry.registerBlockHandler(new PuddleRender());
RenderingRegistry.registerBlockHandler(new GraveRenderer()); RenderingRegistry.registerBlockHandler(new GraveRenderer());
RenderingRegistry.registerBlockHandler(new BambooRenderer());
} }
@Override @Override

View file

@ -1,29 +1,45 @@
package biomesoplenty.blocks; package biomesoplenty.blocks;
import java.util.List;
import java.util.Random; import java.util.Random;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import biomesoplenty.BiomesOPlenty; import biomesoplenty.BiomesOPlenty;
import biomesoplenty.blocks.renderers.RenderUtils;
public class BlockBamboo extends Block public class BlockBamboo extends Block
{ {
private Icon bambooTop;
public BlockBamboo(int par1) public BlockBamboo(int par1)
{ {
super(par1, Material.plants); super(par1, Material.plants);
float var3 = 0.15F;
setBurnProperties(blockID, 5, 5); setBurnProperties(blockID, 5, 5);
this.setBlockBounds(0.5F - var3, 0.0F, 0.5F - var3, 0.5F + var3, 1.0F, 0.5F + var3);
this.setTickRandomly(true); this.setTickRandomly(true);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty); this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
} }
@Override @Override
public void registerIcons(IconRegister par1IconRegister) public void registerIcons(IconRegister iconRegister)
{ {
blockIcon = par1IconRegister.registerIcon("biomesoplenty:bamboo"); blockIcon = iconRegister.registerIcon("biomesoplenty:bamboo");
bambooTop = iconRegister.registerIcon("biomesoplenty:bambootop");
}
@Override
public Icon getIcon(int side, int meta)
{
if (side > 1)
return blockIcon;
else
return bambooTop;
} }
@Override @Override
@ -55,6 +71,29 @@ public class BlockBamboo extends Block
} }
} }
@Override
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z)
{
float pixel = 0.0625F;
return AxisAlignedBB.getAABBPool().getAABB((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
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB axisAlignedBB, List list, Entity entity)
{
float pixel = 0.0625F;
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);
this.setBlockBoundsForItemRender();
}
@Override
public void setBlockBoundsForItemRender()
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
@Override @Override
public boolean canBeReplacedByLeaves(World world, int x, int y, int z) public boolean canBeReplacedByLeaves(World world, int x, int y, int z)
{ {
@ -112,7 +151,7 @@ public class BlockBamboo extends Block
@Override @Override
public int getRenderType() public int getRenderType()
{ {
return 1; return RenderUtils.bambooModel;
} }
@Override @Override

View file

@ -0,0 +1,105 @@
package biomesoplenty.blocks.renderers;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.world.IBlockAccess;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
public class BambooRenderer implements ISimpleBlockRenderingHandler
{
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
{
}
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
{
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
int l = block.colorMultiplier(world, x, y, z);
float f = (float)(l >> 16 & 255) / 255.0F;
float f1 = (float)(l >> 8 & 255) / 255.0F;
float f2 = (float)(l & 255) / 255.0F;
if (EntityRenderer.anaglyphEnable)
{
float f3 = (f * 30.0F + f1 * 59.0F + f2 * 11.0F) / 100.0F;
float f4 = (f * 30.0F + f1 * 70.0F) / 100.0F;
float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F;
f = f3;
f1 = f4;
f2 = f5;
}
Tessellator tessellator = Tessellator.instance;
boolean flag = false;
float f3 = 0.5F;
float f4 = 1.0F;
float f5 = 0.8F;
float f6 = 0.6F;
float r = f3 * f;
float f8 = f4 * f;
float f9 = f5 * f;
float f10 = f6 * f;
float g = f3 * f1;
float f12 = f4 * f1;
float f13 = f5 * f1;
float f14 = f6 * f1;
float b = f3 * f2;
float f16 = f4 * f2;
float f17 = f5 * f2;
float f18 = f6 * f2;
float pixel = 0.0625F;
int m = block.getMixedBrightnessForBlock(world, x, y, z);
if (renderer.renderAllFaces || block.shouldSideBeRendered(world, x, y - 1, z, 0))
{
tessellator.setBrightness(renderer.renderMinY > 0.0D ? m : block.getMixedBrightnessForBlock(world, x, y - 1, z));
tessellator.setColorOpaque_F(r, g, b);
renderer.renderFaceYNeg(block, (double)x, (double)y, (double)z, renderer.getBlockIcon(block, world, x, y, z, 0));
}
if (renderer.renderAllFaces || block.shouldSideBeRendered(world, x, y + 1, z, 1))
{
tessellator.setBrightness(renderer.renderMaxY < 1.0D ? m : block.getMixedBrightnessForBlock(world, x, y + 1, z));
tessellator.setColorOpaque_F(f8, f12, f16);
renderer.renderFaceYPos(block, (double)x, (double)y, (double)z, renderer.getBlockIcon(block, world, x, y, z, 1));
}
tessellator.setBrightness(m);
tessellator.setColorOpaque_F(f9, f13, f17);
tessellator.addTranslation(0.0F, 0.0F, pixel);
renderer.renderFaceZNeg(block, (double)x, (double)y, (double)z + (pixel * 4), renderer.getBlockIcon(block, world, x, y, z, 2));
tessellator.addTranslation(0.0F, 0.0F, -pixel);
tessellator.addTranslation(0.0F, 0.0F, -pixel);
renderer.renderFaceZPos(block, (double)x, (double)y, (double)z - (pixel * 4), renderer.getBlockIcon(block, world, x, y, z, 3));
tessellator.addTranslation(0.0F, 0.0F, pixel);
tessellator.setColorOpaque_F(f10, f14, f18);
tessellator.addTranslation(pixel, 0.0F, 0.0F);
renderer.renderFaceXNeg(block, (double)x + (pixel * 4), (double)y, (double)z, renderer.getBlockIcon(block, world, x, y, z, 4));
tessellator.addTranslation(-pixel, 0.0F, 0.0F);
tessellator.addTranslation(-pixel, 0.0F, 0.0F);
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;
}
@Override
public boolean shouldRender3DInInventory()
{
return false;
}
@Override
public int getRenderId()
{
return RenderUtils.bambooModel;
}
}

View file

@ -19,6 +19,7 @@ public class RenderUtils
public static int puddleModel = -1; public static int puddleModel = -1;
public static int bonesModel = -1; public static int bonesModel = -1;
public static int graveModel = -1; public static int graveModel = -1;
public static int bambooModel = -1;
public static void renderStandardInvBlock(RenderBlocks renderblocks, Block block, int meta) public static void renderStandardInvBlock(RenderBlocks renderblocks, Block block, int meta)
{ {

View file

@ -142,7 +142,7 @@ public class BOPBlocks
Blocks.hardIce = Optional.of(new BlockBOPGeneric(BOPConfigurationIDs.hardIceID, Material.rock, BlockType.HARD_ICE)); Blocks.hardIce = Optional.of(new BlockBOPGeneric(BOPConfigurationIDs.hardIceID, Material.rock, BlockType.HARD_ICE));
Blocks.leavesFruit = Optional.of((new BlockBOPAppleLeaves(BOPConfigurationIDs.leavesFruitID)).setUnlocalizedName("bop.leavesFruit")); Blocks.leavesFruit = Optional.of((new BlockBOPAppleLeaves(BOPConfigurationIDs.leavesFruitID)).setUnlocalizedName("bop.leavesFruit"));
Blocks.leavesFruit2 = Optional.of((new BlockBOPPersimmonLeaves(BOPConfigurationIDs.leavesFruit2ID)).setUnlocalizedName("bop.leavesFruit2")); Blocks.leavesFruit2 = Optional.of((new BlockBOPPersimmonLeaves(BOPConfigurationIDs.leavesFruit2ID)).setUnlocalizedName("bop.leavesFruit2"));
Blocks.bamboo = Optional.of(new BlockBamboo(BOPConfigurationIDs.bambooID).setHardness(0.0F).setStepSound(Block.soundGrassFootstep).setUnlocalizedName("bop.bamboo")); Blocks.bamboo = Optional.of(new BlockBamboo(BOPConfigurationIDs.bambooID).setHardness(0.2F).setStepSound(Block.soundWoodFootstep).setUnlocalizedName("bop.bamboo"));
Blocks.mudBrick = Optional.of(new BlockBOPGeneric(BOPConfigurationIDs.mudBrickBlockID, Material.rock, BlockType.MUD_BRICK)); Blocks.mudBrick = Optional.of(new BlockBOPGeneric(BOPConfigurationIDs.mudBrickBlockID, Material.rock, BlockType.MUD_BRICK));
Blocks.mudBricksStairs = Optional.of((new BlockBOPStairs(BOPConfigurationIDs.mudBrickStairsID, Blocks.redRock.get(), Category.MUD_BRICKS)).setHardness(1.0F).setUnlocalizedName("bop.mudBricksStairs")); Blocks.mudBricksStairs = Optional.of((new BlockBOPStairs(BOPConfigurationIDs.mudBrickStairsID, Blocks.redRock.get(), Category.MUD_BRICKS)).setHardness(1.0F).setUnlocalizedName("bop.mudBricksStairs"));
Blocks.stoneDoubleSlab = Optional.of((BlockHalfSlab)(new BlockBOPSlab(BOPConfigurationIDs.stoneDoubleSlabID, true, Material.rock, SlabCategory.STONE)).setUnlocalizedName("bop.stoneDoubleSlab")); Blocks.stoneDoubleSlab = Optional.of((BlockHalfSlab)(new BlockBOPSlab(BOPConfigurationIDs.stoneDoubleSlabID, true, Material.rock, SlabCategory.STONE)).setUnlocalizedName("bop.stoneDoubleSlab"));

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 B