Attempted adding puddles, big letdown is the fact that the water isn't transparent

This commit is contained in:
Adubbz G 2013-06-25 18:53:40 +10:00
parent b7eb27fe3c
commit f8dfc61c68
7 changed files with 1902 additions and 2 deletions

View file

@ -17,6 +17,7 @@ import biomesoplenty.api.Items;
import biomesoplenty.blocks.renderers.AltarRenderer;
import biomesoplenty.blocks.renderers.FoliageRenderer;
import biomesoplenty.blocks.renderers.PlantsRenderer;
import biomesoplenty.blocks.renderers.PuddleRender;
import biomesoplenty.blocks.renderers.RenderUtils;
import biomesoplenty.blocks.renderers.SmallBlockRenderer;
import biomesoplenty.entities.EntityGlob;
@ -47,6 +48,7 @@ public class ClientProxy extends CommonProxy {
RenderingRegistry.registerBlockHandler(new PlantsRenderer());
RenderingRegistry.registerBlockHandler(new SmallBlockRenderer());
RenderingRegistry.registerBlockHandler(new AltarRenderer());
RenderingRegistry.registerBlockHandler(new PuddleRender());
//TODO: Remove upon Fluid API being integrated into Forge
FluidRegistry.renderIdFluid = RenderingRegistry.getNextAvailableRenderId();

View file

@ -96,6 +96,7 @@ public class Blocks
public static Optional<? extends Block> promisedPortal = Optional.absent();
public static Optional<? extends Block> glass = Optional.absent();
public static Optional<? extends Block> altar = Optional.absent();
public static Optional<? extends Block> puddle = Optional.absent();
/**
* Populated by Biomes O Plenty with default Biomes O Plenty leaves. Add additional leaves here (E.g. "Blocks.shearBlockIds.put(acaciaLeaves.blockID, 15.0F);")

View file

@ -0,0 +1,114 @@
package biomesoplenty.blocks;
import java.util.Random;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.blocks.renderers.PuddleRender;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.IPlantable;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockPuddle extends Block
{
@SideOnly(Side.CLIENT)
private Icon field_94441_a;
@SideOnly(Side.CLIENT)
private Icon field_94440_b;
public BlockPuddle(int par1)
{
super(par1, Material.ground);
this.setTickRandomly(true);
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.8135F, 1.0F);
this.setLightOpacity(0);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
{
return AxisAlignedBB.getAABBPool().getAABB((double)(par2 + 0), (double)(par3 + 0), (double)(par4 + 0), (double)(par2 + 1), (double)(par3 + 0.8135F), (double)(par4 + 1));
}
public boolean isOpaqueCube()
{
return false;
}
public boolean renderAsNormalBlock()
{
return false;
}
public int onBlockPlaced(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9)
{
par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, 1);
return par9;
}
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
Material material1 = par1World.getBlockMaterial(par2 + 1, par3, par4);
Material material2 = par1World.getBlockMaterial(par2 - 1, par3, par4);
Material material3 = par1World.getBlockMaterial(par2, par3, par4 + 1);
Material material4 = par1World.getBlockMaterial(par2, par3, par4 - 1);
if (!material1.isSolid() || !material2.isSolid() || !material3.isSolid() || !material1.isSolid())
{
par1World.setBlock(par2, par3, par4, Block.dirt.blockID);
}
}
@Override
public int getRenderType()
{
return PuddleRender.puddleID;
}
@SideOnly(Side.CLIENT)
public Icon getIcon(int par1, int par2)
{
return Block.dirt.getBlockTextureFromSide(par1);
}
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
{
super.onNeighborBlockChange(par1World, par2, par3, par4, par5);
Material material = par1World.getBlockMaterial(par2, par3 + 1, par4);
if (material.isSolid())
{
par1World.setBlock(par2, par3, par4, Block.dirt.blockID);
}
par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, 1);
}
public int idDropped(int par1, Random par2Random, int par3)
{
return Block.dirt.idDropped(0, par2Random, par3);
}
@SideOnly(Side.CLIENT)
public int idPicked(World par1World, int par2, int par3, int par4)
{
return Block.dirt.blockID;
}
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister)
{
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,89 @@
package biomesoplenty.blocks.renderers;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.Item;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.liquids.LiquidStack;
import org.lwjgl.opengl.GL11;
import biomesoplenty.BiomesOPlenty;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.client.registry.RenderingRegistry;
public class PuddleRender implements ISimpleBlockRenderingHandler
{
public static int puddleID = RenderingRegistry.getNextAvailableRenderId();
@Override
public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer)
{
if (modelID == puddleID)
{
RenderUtils.renderStandardInvBlock(renderer, block, metadata);
}
}
@Override
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer)
{
if (modelID == puddleID)
{
renderer.renderStandardBlock(block, x, y, z);
//Liquid
renderer.setRenderBounds(0.0, 0.8135, 0.0, 1.0, 0.8880, 1.0);
Block liquidBlock = Block.blocksList[Block.waterStill.blockID];
BlockSkinRenderHelper.renderMetadataBlock(liquidBlock, 0, x, y, z, renderer, world);
}
return true;
}
@Override
public boolean shouldRender3DInInventory()
{
return true;
}
@Override
public int getRenderId()
{
return puddleID;
}
private void renderDoRe (RenderBlocks renderblocks, Block block, int meta)
{
Tessellator tessellator = Tessellator.instance;
GL11.glTranslatef(-0.5F, 0.5F, -0.5F);
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, -1F, 0.0F);
renderblocks.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, meta));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 1.0F, 0.0F);
renderblocks.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, meta));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, -1F);
renderblocks.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, meta));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, 1.0F);
renderblocks.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, meta));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(-1F, 0.0F, 0.0F);
renderblocks.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, meta));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(1.0F, 0.0F, 0.0F);
renderblocks.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, meta));
tessellator.draw();
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
}
}

View file

@ -3,7 +3,6 @@ package biomesoplenty.configuration;
import net.minecraft.block.Block;
import net.minecraft.block.BlockHalfSlab;
import net.minecraft.block.material.Material;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import biomesoplenty.api.Blocks;
import biomesoplenty.blocks.BlockAltar;
@ -42,6 +41,7 @@ import biomesoplenty.blocks.BlockMoss;
import biomesoplenty.blocks.BlockMud;
import biomesoplenty.blocks.BlockOriginGrass;
import biomesoplenty.blocks.BlockPromisedPortal;
import biomesoplenty.blocks.BlockPuddle;
import biomesoplenty.blocks.BlockTreeMoss;
import biomesoplenty.blocks.BlockWillow;
import biomesoplenty.items.ItemBOPAltar;
@ -75,7 +75,6 @@ import biomesoplenty.tileentity.TileEntityAltar;
import com.google.common.base.Optional;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
public class BOPBlocks {
public static void init()
@ -172,6 +171,8 @@ public class BOPBlocks {
Blocks.glass = Optional.of((new BlockBOPGlass(BOPConfiguration.glassID)).setStepSound(Block.soundGlassFootstep).setUnlocalizedName("bop.glass"));
Blocks.altar = Optional.of((new BlockAltar(BOPConfiguration.altarID)).setStepSound(Block.soundStoneFootstep).setUnlocalizedName("bop.altar"));
Blocks.puddle = Optional.of((new BlockPuddle(BOPConfiguration.puddleID)).setStepSound(Block.soundGravelFootstep).setUnlocalizedName("bop.puddle"));
Blocks.planks = Optional.of((new BlockBOPPlank(BOPConfiguration.planksID)).setResistance(5.0F).setStepSound(Block.soundWoodFootstep).setUnlocalizedName("bop.planks"));
@ -252,6 +253,7 @@ public class BOPBlocks {
GameRegistry.registerBlock(Blocks.bones.get(), ItemBOPBones.class, "bop.bones");
GameRegistry.registerBlock(Blocks.glass.get(), ItemBOPGlass.class, "bop.glass");
GameRegistry.registerBlock(Blocks.altar.get(), ItemBOPAltar.class, "bop.altar");
GameRegistry.registerBlock(Blocks.puddle.get(), "bop.puddle");
ItemBOPSlab.setSlabs(Blocks.stoneSingleSlab.get(), Blocks.stoneDoubleSlab.get());
GameRegistry.registerBlock(Blocks.stoneDoubleSlab.get(), ItemBOPSlab.class, "bop.stoneDoubleSlab");

View file

@ -181,6 +181,8 @@ public class BOPConfiguration {
// public static int smolderingGrassID;
// public static int quicksandID;
public static int puddleID;
public static int planksID;
@ -798,6 +800,8 @@ public class BOPConfiguration {
glassID = config.getBlock("Glass ID", 1978, null).getInt();
altarID = config.getBlock("Altar ID", 1979, null).getInt();
puddleID = config.getBlock("Puddle ID", 1980, null).getInt();
// Get Item ID's
shroomPowderID = config.getItem("Shroom Powder ID", 21001, null).getInt();