From d9b3519b65a1e6f78d49c22dd979473698ded61f Mon Sep 17 00:00:00 2001 From: Adubbz Date: Thu, 23 May 2013 06:08:28 +1000 Subject: [PATCH] Started on Bone Segments, currently the metdata isn't playing nicely for some reason :/ --- src/minecraft/biomesoplenty/ClientProxy.java | 44 ++++- src/minecraft/biomesoplenty/CommonProxy.java | 10 +- src/minecraft/biomesoplenty/api/Blocks.java | 13 +- .../biomesoplenty/blocks/BlockBones.java | 162 ++++++++++++++++++ .../blocks/renderers/SmallBlockRenderer.java | 66 +++++++ .../configuration/BOPBlocks.java | 9 + .../configuration/BOPConfiguration.java | 4 + 7 files changed, 296 insertions(+), 12 deletions(-) create mode 100644 src/minecraft/biomesoplenty/blocks/BlockBones.java create mode 100644 src/minecraft/biomesoplenty/blocks/renderers/SmallBlockRenderer.java diff --git a/src/minecraft/biomesoplenty/ClientProxy.java b/src/minecraft/biomesoplenty/ClientProxy.java index f7bf50864..e7f46eee1 100644 --- a/src/minecraft/biomesoplenty/ClientProxy.java +++ b/src/minecraft/biomesoplenty/ClientProxy.java @@ -1,19 +1,23 @@ package biomesoplenty; +import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelSlime; import net.minecraft.client.particle.EntityBreakingFX; import net.minecraft.client.particle.EntityFX; -import net.minecraft.client.renderer.entity.RenderSlime; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.RenderSnowball; + +import org.lwjgl.opengl.GL11; + import biomesoplenty.api.Items; import biomesoplenty.blocks.renderers.FoliageRenderer; import biomesoplenty.blocks.renderers.PlantsRenderer; +import biomesoplenty.blocks.renderers.SmallBlockRenderer; import biomesoplenty.items.projectiles.EntityDart; import biomesoplenty.items.projectiles.EntityMudball; -import biomesoplenty.items.projectiles.EntityPoisonDart; import biomesoplenty.items.projectiles.RenderDart; -import biomesoplenty.items.projectiles.RenderPoisonDart; import biomesoplenty.mobs.EntityGlob; import biomesoplenty.mobs.RenderGlob; import biomesoplenty.particles.EntityDandelionFX; @@ -34,6 +38,7 @@ public class ClientProxy extends CommonProxy { RenderingRegistry.registerBlockHandler(new FoliageRenderer()); RenderingRegistry.registerBlockHandler(new PlantsRenderer()); + RenderingRegistry.registerBlockHandler(new SmallBlockRenderer()); } @Override @@ -56,4 +61,37 @@ public class ClientProxy extends CommonProxy { { return RenderingRegistry.addNewArmourRendererPrefix(armor); } + + @Override + public void renderStandardInvBlock(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); + } + } \ No newline at end of file diff --git a/src/minecraft/biomesoplenty/CommonProxy.java b/src/minecraft/biomesoplenty/CommonProxy.java index 2d8bc5886..1a12124ea 100644 --- a/src/minecraft/biomesoplenty/CommonProxy.java +++ b/src/minecraft/biomesoplenty/CommonProxy.java @@ -1,9 +1,7 @@ package biomesoplenty; -import biomesoplenty.api.Items; -import net.minecraft.client.particle.EntityBreakingFX; -import net.minecraft.client.particle.EntityFX; -import net.minecraft.world.World; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; public class CommonProxy { public static String ARMOR_MUD1_PNG = "/mods/BiomesOPlenty/textures/armor/mud_1.png"; @@ -24,4 +22,8 @@ public class CommonProxy { public void spawnParticle(String string, double x, double y, double z) { } + + public void renderStandardInvBlock(RenderBlocks renderblocks, Block block, int meta) + { + } } \ No newline at end of file diff --git a/src/minecraft/biomesoplenty/api/Blocks.java b/src/minecraft/biomesoplenty/api/Blocks.java index c36d44695..eb1d6b717 100644 --- a/src/minecraft/biomesoplenty/api/Blocks.java +++ b/src/minecraft/biomesoplenty/api/Blocks.java @@ -46,8 +46,8 @@ public class Blocks public static Optional redCobbleStairs = Optional.absent(); public static Optional redBricksStairs = Optional.absent(); public static Optional mudBricksStairs = Optional.absent(); - public static Optional holyCobbleStairs = Optional.absent(); - public static Optional holyBricksStairs = Optional.absent(); + public static Optional holyCobbleStairs = Optional.absent(); + public static Optional holyBricksStairs = Optional.absent(); // Slabs public static Optional woodenSingleSlab1 = Optional.absent(); @@ -70,13 +70,16 @@ public class Blocks public static Optional saplings = Optional.absent(); public static Optional colorizedSaplings = Optional.absent(); public static Optional willow = Optional.absent(); - public static Optional ivy = Optional.absent(); + public static Optional ivy = Optional.absent(); public static Optional treeMoss = Optional.absent(); public static Optional moss = Optional.absent(); public static Optional petals = Optional.absent(); public static Optional bamboo = Optional.absent(); - public static Optional cloud = Optional.absent(); - + public static Optional cloud = Optional.absent(); + + //Nether + public static Optional bones = Optional.absent(); + // public static Optional amethystBlock = Optional.absent(); public static Optional amethystOre = Optional.absent(); // public static Optional bambooThatching = Optional.absent(); diff --git a/src/minecraft/biomesoplenty/blocks/BlockBones.java b/src/minecraft/biomesoplenty/blocks/BlockBones.java new file mode 100644 index 000000000..ae5b3daf1 --- /dev/null +++ b/src/minecraft/biomesoplenty/blocks/BlockBones.java @@ -0,0 +1,162 @@ +package biomesoplenty.blocks; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Icon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import biomesoplenty.BiomesOPlenty; +import biomesoplenty.api.Blocks; +import biomesoplenty.blocks.renderers.SmallBlockRenderer; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class BlockBones extends Block { + private static final String[] boneTypes = new String[] {"bones_small", "bones_medium", "bones_large"}; + private Icon[] textures; + + public BlockBones(int blockID) + { + super(blockID, Material.rock); + setHardness(3.0F); + setResistance(5.0F); + this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty); + } + + @Override + public void registerIcons(IconRegister iconRegister) + { + textures = new Icon[boneTypes.length]; + + for (int i = 0; i < boneTypes.length; ++i) + textures[i] = iconRegister.registerIcon("BiomesOPlenty:"+boneTypes[i]); + } + + @Override + public Icon getIcon(int side, int meta) + { + if (meta < 0 || meta >= textures.length) + meta = 0; + + return textures[meta]; + } + + /*@Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) + { + int meta = world.getBlockMetadata(x, y, z); + + if (meta == 0) + { + return AxisAlignedBB.getBoundingBox((double) x + 0.25D, y, (double) z + 0.25D, (double) x + 0.75D, (double) y + 0.5D, (double) z + 0.75D); + } + if (meta == 1) + { + return AxisAlignedBB.getBoundingBox((double) x + 0.125D, y, (double) z + 0.125D, (double) x + 0.875D, (double) y + 0.75D, (double) z + 0.875D); + } + else + { + return AxisAlignedBB.getBoundingBox(x, y, z, (double) x + 1.0D, (double) y + 1.0D, (double) z + 1.0D); + } + } + + @Override + public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) + { + int meta = world.getBlockMetadata(x, y, z); + + if (meta == 0) + { + return AxisAlignedBB.getBoundingBox((double) x + 0.25D, y, (double) z + 0.25D, (double) x + 0.75D, (double) y + 0.5D, (double) z + 0.75D); + } + else if (meta == 1) + { + return AxisAlignedBB.getBoundingBox((double) x + 0.125D, y, (double) z + 0.125D, (double) x + 0.875D, (double) y + 0.75D, (double) z + 0.875D); + } + else + { + return AxisAlignedBB.getBoundingBox(x, y, z, (double) x + 1.0D, (double) y + 1.0D, (double) z + 1.0D); + } + } + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess iblockaccess, int x, int y, int z) + { + int meta = iblockaccess.getBlockMetadata(x, y, z); + + float minX; + float minY = 0F; + float minZ; + float maxX; + float maxY; + float maxZ; + + if (meta == 0) + { + minX = minZ = 0.25F; + maxX = maxZ = 0.75F; + maxY = 0.5F; + } + else if (meta == 1) + { + minX = minZ = 0.125F; + maxX = maxZ = 0.875F; + maxY = 0.75F; + } + else + { + minX = minZ = 0.0F; + maxX = maxZ = 1.0F; + maxY = 1.0F; + } + setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ); + }*/ + + @Override + public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) + { + for (int i = 0; i < boneTypes.length; ++i) + list.add(new ItemStack(blockID, 1, i)); + }/* + + @Override + public boolean isOpaqueCube() + { + return false; + } + + @Override + public boolean renderAsNormalBlock() + { + return false; + } + + @Override + public int getRenderType() + { + return SmallBlockRenderer.bonesModel; + } + + @Override + public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l) + { + return true; + }*/ + + @Override + public int damageDropped(int meta) + { + return meta; + } +} diff --git a/src/minecraft/biomesoplenty/blocks/renderers/SmallBlockRenderer.java b/src/minecraft/biomesoplenty/blocks/renderers/SmallBlockRenderer.java new file mode 100644 index 000000000..3461f9e5c --- /dev/null +++ b/src/minecraft/biomesoplenty/blocks/renderers/SmallBlockRenderer.java @@ -0,0 +1,66 @@ +package biomesoplenty.blocks.renderers; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.world.IBlockAccess; + +import org.lwjgl.opengl.GL11; + +import biomesoplenty.BiomesOPlenty; + +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; + +public class SmallBlockRenderer implements ISimpleBlockRenderingHandler +{ + public static int bonesModel = RenderingRegistry.getNextAvailableRenderId(); + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) + { + if (modelId == bonesModel) + { + int meta = world.getBlockMetadata(x, y, z); + if (meta == 0) + { + renderer.setRenderBounds(0.25F, 0.0F, 0.25F, 0.75F, 0.5F, 0.75F); + renderer.renderStandardBlock(block, x, y, z); + } + else if (meta == 1) + { + renderer.setRenderBounds(0.125F, 0.0F, 0.125F, 0.875F, 0.75F, 0.875F); + renderer.renderStandardBlock(block, x, y, z); + } + else + { + renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + renderer.renderStandardBlock(block, x, y, z); + } + } + return true; + } + + @Override + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) + { + if (modelID == bonesModel) + { + Tessellator tessellator = Tessellator.instance; + renderer.setRenderBounds(0.25F, 0.0F, 0.25F, 0.75F, 0.5F, 0.75F); + BiomesOPlenty.proxy.renderStandardInvBlock(renderer, block, metadata); + } + } + + @Override + public boolean shouldRender3DInInventory() + { + return true; + } + + @Override + public int getRenderId() + { + return bonesModel; + } +} diff --git a/src/minecraft/biomesoplenty/configuration/BOPBlocks.java b/src/minecraft/biomesoplenty/configuration/BOPBlocks.java index 2c88635cf..12ca6fed4 100644 --- a/src/minecraft/biomesoplenty/configuration/BOPBlocks.java +++ b/src/minecraft/biomesoplenty/configuration/BOPBlocks.java @@ -32,6 +32,7 @@ import biomesoplenty.blocks.BlockBOPSlab.SlabCategory; import biomesoplenty.blocks.BlockBOPStairs; import biomesoplenty.blocks.BlockBOPStairs.Category; import biomesoplenty.blocks.BlockBamboo; +import biomesoplenty.blocks.BlockBones; import biomesoplenty.blocks.BlockCloud; import biomesoplenty.blocks.BlockIvy; import biomesoplenty.blocks.BlockMoss; @@ -148,6 +149,8 @@ public class BOPBlocks { // Blocks.quicksand = Optional.of((new BlockQuicksand(BOPConfiguration.quicksandID)).setHardness(0.3F).setStepSound(Block.soundSandFootstep).setUnlocalizedName("quicksand")); // Blocks.grass = Optional.of(new BlockBOPGrass(3000).setUnlocalizedName("holyGrass")); Blocks.cloud = Optional.of((new BlockCloud(BOPConfiguration.cloudID)).setHardness(0.1F).setLightOpacity(3).setStepSound(Block.soundClothFootstep).setUnlocalizedName("cloud")); + + Blocks.bones = Optional.of((new BlockBones(BOPConfiguration.bonesID)).setStepSound(Block.soundStoneFootstep).setUnlocalizedName("bones")); Blocks.planks = Optional.of((new BlockBOPPlank(BOPConfiguration.planksID)).setResistance(5.0F).setStepSound(Block.soundWoodFootstep).setUnlocalizedName("planks")); @@ -219,6 +222,8 @@ public class BOPBlocks { // GameRegistry.registerBlock(Blocks.quicksand.get(), "quicksand"); // GameRegistry.registerBlock(Blocks.amethyst.get(), ItemBOPAmethyst.class, "amethystOre1"); GameRegistry.registerBlock(Blocks.cloud.get(), "cloud"); + + GameRegistry.registerBlock(Blocks.bones.get(), "bones"); ItemBOPSlab.setSlabs(Blocks.stoneSingleSlab.get(), Blocks.stoneDoubleSlab.get()); GameRegistry.registerBlock(Blocks.stoneDoubleSlab.get(), ItemBOPSlab.class, "stoneDoubleSlab"); @@ -369,6 +374,10 @@ public class BOPBlocks { LanguageRegistry.addName(Blocks.cloud.get(), "Cloud Block"); LanguageRegistry.addName(new ItemStack(Blocks.mud.get(), 1, 1), "Quicksand"); LanguageRegistry.addName(new ItemStack(Blocks.saplings.get(),1,2), "Bamboo Sapling"); + + LanguageRegistry.addName(new ItemStack(Blocks.bones.get(), 1, 0), "Small Bone Segment"); + LanguageRegistry.addName(new ItemStack(Blocks.bones.get(), 1, 1), "Medium Bone Segment"); + LanguageRegistry.addName(new ItemStack(Blocks.bones.get(), 1, 2), "Large Bone Segment"); LanguageRegistry.addName(new ItemStack(Blocks.planks.get(), 1, 0), "Acacia Wood Planks"); LanguageRegistry.addName(new ItemStack(Blocks.planks.get(), 1, 1), "Cherry Wood Planks"); diff --git a/src/minecraft/biomesoplenty/configuration/BOPConfiguration.java b/src/minecraft/biomesoplenty/configuration/BOPConfiguration.java index ab481eae9..989c83111 100644 --- a/src/minecraft/biomesoplenty/configuration/BOPConfiguration.java +++ b/src/minecraft/biomesoplenty/configuration/BOPConfiguration.java @@ -182,6 +182,8 @@ public class BOPConfiguration { public static int crystalID; public static int cloudID; + + public static int bonesID; //Item IDs public static int shroomPowderID; @@ -680,6 +682,8 @@ public class BOPConfiguration { holyBrickStairsID = config.getBlock("Skystone Brick Stairs ID", 1966, null).getInt(); mushroomsID = config.getBlock("Mushroom ID", 1967, null).getInt(); + + bonesID = config.getBlock("Bones ID", 1968, null).getInt(); // Get Item ID's shroomPowderID = config.getItem("Shroom Powder ID", 21001, null).getInt();