Compressing Leaves

This commit is contained in:
Amnet 2013-04-14 02:23:46 +02:00
parent 2c931fa8f4
commit b942946df1
24 changed files with 334 additions and 3 deletions

View file

@ -19,6 +19,7 @@ import tdwp_ftw.biomesop.configuration.BOPBlocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@Deprecated
public class BlockAcaciaLeaves extends BlockLeavesBase implements IShearable
{
/**

View file

@ -18,6 +18,7 @@ import tdwp_ftw.biomesop.configuration.BOPBlocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@Deprecated
public class BlockAutumnLeaves extends BlockLeavesBase implements IShearable
{
/**

View file

@ -0,0 +1,132 @@
package tdwp_ftw.biomesop.blocks;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import tdwp_ftw.biomesop.mod_BiomesOPlenty;
import tdwp_ftw.biomesop.configuration.BOPBlocks;
import net.minecraft.block.BlockLeavesBase;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.world.ColorizerFoliage;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.IShearable;
public class BlockBOPColorizedLeaves extends BlockLeavesBase implements IShearable
{
private static final String[] leaves = new String[] {"acacia", "mangrove", "palm", "redwood", "willow"};
@SideOnly(Side.CLIENT)
private Icon[][] textures;
public BlockBOPColorizedLeaves(int blockID)
{
super(blockID, Material.leaves, false);
setBurnProperties(this.blockID, 30, 60);
this.setTickRandomly(true);
this.setCreativeTab(mod_BiomesOPlenty.tabBiomesOPlenty);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
textures = new Icon[2][leaves.length];
for (int i = 0; i < leaves.length; ++i)
{
textures[0][i] = iconRegister.registerIcon("BiomesOPlenty:" + leaves[i] + "leaves1");
textures[1][i] = iconRegister.registerIcon("BiomesOPlenty:" + leaves[i] + "leaves2");
}
}
@Override
@SideOnly(Side.CLIENT)
public int getBlockColor()
{
double temperature = 0.5D;
double humidity = 1.0D;
return ColorizerFoliage.getFoliageColor(temperature, humidity);
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderColor(int par1)
{
// TODO
return (par1 & 3) == 1 ? ColorizerFoliage.getFoliageColorPine() : ((par1 & 3) == 2 ? ColorizerFoliage.getFoliageColorBirch() : ColorizerFoliage.getFoliageColorBasic());
}
@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
int var6 = 0;
int var7 = 0;
int var8 = 0;
for (int var9 = -1; var9 <= 1; ++var9)
{
for (int var10 = -1; var10 <= 1; ++var10)
{
int var11 = par1IBlockAccess.getBiomeGenForCoords(par2 + var10, par4 + var9).getBiomeFoliageColor();
var6 += (var11 & 16711680) >> 16;
var7 += (var11 & 65280) >> 8;
var8 += var11 & 255;
}
}
return (var6 / 9 & 255) << 16 | (var7 / 9 & 255) << 8 | var8 / 9 & 255;
}
@Override
@SideOnly(Side.CLIENT)
public Icon getBlockTextureFromSideAndMetadata(int side, int meta)
{
if (meta < 0 || meta >= textures[0].length)
meta = 0;
return textures[(!isOpaqueCube() ? 0 : 1)][meta];
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) {
for (int i = 0; i < textures[0].length; ++i)
list.add(new ItemStack(blockID, 1, i));
}
@Override
public int idDropped(int par1, Random par2Random, int par3)
{
return BOPBlocks.yellowSapling.blockID;
}
@Override
public int damageDropped(int meta)
{
return meta & textures[0].length;
}
@Override
public boolean isShearable(ItemStack item, World world, int x, int y, int z)
{
return true;
}
@Override
public ArrayList<ItemStack> onSheared(ItemStack item, World world, int x, int y, int z, int fortune)
{
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
ret.add(new ItemStack(this, 1, world.getBlockMetadata(x, y, z) & 3));
return ret;
}
}

View file

@ -8,6 +8,7 @@ import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
import tdwp_ftw.biomesop.mod_BiomesOPlenty;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -33,6 +34,7 @@ public class BlockBOPFlower extends BlockFlower
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
textures = new Icon[plants.length];

View file

@ -0,0 +1,91 @@
package tdwp_ftw.biomesop.blocks;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import tdwp_ftw.biomesop.mod_BiomesOPlenty;
import tdwp_ftw.biomesop.configuration.BOPBlocks;
import net.minecraft.block.BlockLeavesBase;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
import net.minecraftforge.common.IShearable;
public class BlockBOPLeaves extends BlockLeavesBase implements IShearable
{
private static final String[] leaves = new String[] {"autumn", "bamboo", "blue", "dark", "dead", "fir", "holy", "orange", "origin", "pink", "red", "white"};
@SideOnly(Side.CLIENT)
private Icon[][] textures;
public BlockBOPLeaves(int blockID)
{
super(blockID, Material.leaves, false);
setBurnProperties(this.blockID, 30, 60);
this.setTickRandomly(true);
this.setCreativeTab(mod_BiomesOPlenty.tabBiomesOPlenty);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
textures = new Icon[2][leaves.length];
for (int i = 0; i < leaves.length; ++i)
{
textures[0][i] = iconRegister.registerIcon("BiomesOPlenty:" + leaves[i] + "leaves1");
textures[1][i] = iconRegister.registerIcon("BiomesOPlenty:" + leaves[i] + "leaves2");
}
}
@Override
@SideOnly(Side.CLIENT)
public Icon getBlockTextureFromSideAndMetadata(int side, int meta)
{
if (meta < 0 || meta >= textures[0].length)
meta = 0;
return textures[(!isOpaqueCube() ? 0 : 1)][meta];
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) {
for (int i = 0; i < textures[0].length; ++i)
list.add(new ItemStack(blockID, 1, i));
}
@Override
public int idDropped(int par1, Random par2Random, int par3)
{
return BOPBlocks.yellowSapling.blockID;
}
@Override
public int damageDropped(int meta)
{
return meta & textures[0].length;
}
@Override
public boolean isShearable(ItemStack item, World world, int x, int y, int z)
{
return true;
}
@Override
public ArrayList<ItemStack> onSheared(ItemStack item, World world, int x, int y, int z, int fortune)
{
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
ret.add(new ItemStack(this, 1, world.getBlockMetadata(x, y, z) & 3));
return ret;
}
}

View file

@ -18,6 +18,7 @@ import tdwp_ftw.biomesop.configuration.BOPBlocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@Deprecated
public class BlockBambooLeaves extends BlockLeavesBase implements IShearable
{
/**

View file

@ -18,6 +18,7 @@ import tdwp_ftw.biomesop.configuration.BOPBlocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@Deprecated
public class BlockBlueLeaves extends BlockLeavesBase implements IShearable
{
/**

View file

@ -18,6 +18,7 @@ import tdwp_ftw.biomesop.configuration.BOPBlocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@Deprecated
public class BlockDarkLeaves extends BlockLeavesBase implements IShearable
{
/**

View file

@ -18,6 +18,7 @@ import tdwp_ftw.biomesop.configuration.BOPBlocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@Deprecated
public class BlockDeadLeaves extends BlockLeavesBase implements IShearable
{
/**

View file

@ -18,6 +18,7 @@ import tdwp_ftw.biomesop.configuration.BOPBlocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@Deprecated
public class BlockFirLeaves extends BlockLeavesBase implements IShearable
{
/**

View file

@ -18,6 +18,7 @@ import tdwp_ftw.biomesop.configuration.BOPBlocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@Deprecated
public class BlockHolyLeaves extends BlockLeavesBase implements IShearable
{
/**

View file

@ -19,6 +19,7 @@ import tdwp_ftw.biomesop.configuration.BOPBlocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@Deprecated
public class BlockMangroveLeaves extends BlockLeavesBase implements IShearable
{
/**

View file

@ -19,6 +19,7 @@ import tdwp_ftw.biomesop.configuration.BOPBlocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@Deprecated
public class BlockOrangeLeaves extends BlockLeavesBase implements IShearable
{
/**

View file

@ -18,6 +18,7 @@ import tdwp_ftw.biomesop.configuration.BOPBlocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@Deprecated
public class BlockOriginLeaves extends BlockLeavesBase implements IShearable
{
/**

View file

@ -19,6 +19,7 @@ import tdwp_ftw.biomesop.configuration.BOPBlocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@Deprecated
public class BlockPalmLeaves extends BlockLeavesBase implements IShearable
{
/**

View file

@ -18,6 +18,7 @@ import tdwp_ftw.biomesop.configuration.BOPBlocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@Deprecated
public class BlockPinkLeaves extends BlockLeavesBase implements IShearable
{
/**

View file

@ -18,6 +18,7 @@ import tdwp_ftw.biomesop.configuration.BOPBlocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@Deprecated
public class BlockRedLeaves extends BlockLeavesBase implements IShearable
{
/**

View file

@ -19,6 +19,7 @@ import tdwp_ftw.biomesop.configuration.BOPBlocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@Deprecated
public class BlockRedwoodLeaves extends BlockLeavesBase implements IShearable
{
/**

View file

@ -18,6 +18,7 @@ import tdwp_ftw.biomesop.configuration.BOPBlocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@Deprecated
public class BlockWhiteLeaves extends BlockLeavesBase implements IShearable
{
/**

View file

@ -19,6 +19,7 @@ import tdwp_ftw.biomesop.configuration.BOPBlocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@Deprecated
public class BlockWillowLeaves extends BlockLeavesBase implements IShearable
{
/**

View file

@ -10,6 +10,8 @@ import tdwp_ftw.biomesop.blocks.*;
import tdwp_ftw.biomesop.items.ItemBOPFlower;
import tdwp_ftw.biomesop.items.ItemBOPPlank;
import tdwp_ftw.biomesop.items.ItemBOPSlab;
import tdwp_ftw.biomesop.items.ItemBOPLeaves;
import tdwp_ftw.biomesop.items.ItemBOPColorizedLeaves;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
@ -194,7 +196,9 @@ public class BOPBlocks {
// public static Block stairs;
// public static BlockHalfSlab singleSlab;
// public static BlockHalfSlab doubleSlab;
// public static Block flowers;
public static Block flowers;
public static Block leaves;
public static Block leavesColorized;
public static void init()
{
@ -433,8 +437,8 @@ public class BOPBlocks {
LanguageRegistry.addName(new ItemStack(stairs,1,9), "Willow Wood Stairs");
// Flowers - mostly working, missing glow on Glowflower
flowers = (new BlockBOPFlower(2000)).setHardness(0.0F).setStepSound(Block.soundGrassFootstep).setUnlocalizedName("flowers");
GameRegistry.registerBlock(flowers, ItemBOPFlower.class, "plants");
flowers = (new BlockBOPFlower(2002)).setHardness(0.0F).setStepSound(Block.soundGrassFootstep).setUnlocalizedName("flowers");
GameRegistry.registerBlock(flowers, ItemBOPFlower.class, "flowers");
LanguageRegistry.addName(new ItemStack(flowers,1,0), "Swampflower");
LanguageRegistry.addName(new ItemStack(flowers,1,1), "Deathbloom");
@ -445,8 +449,36 @@ public class BOPBlocks {
LanguageRegistry.addName(new ItemStack(flowers,1,6), "Wildflower");
LanguageRegistry.addName(new ItemStack(flowers,1,7), "Violet");
LanguageRegistry.addName(new ItemStack(flowers,1,8), "Anemone");
// Leaves - Almost working, will have to fix drops
leaves = (new BlockBOPLeaves(2000)).setHardness(0.2F).setLightOpacity(1).setStepSound(Block.soundGrassFootstep).setUnlocalizedName("leaves");
GameRegistry.registerBlock(leaves, ItemBOPLeaves.class, "leaves");
LanguageRegistry.addName(new ItemStack(leaves,1,0), "Autumn Leaves");
LanguageRegistry.addName(new ItemStack(leaves,1,1), "Bamboo Leaves");
LanguageRegistry.addName(new ItemStack(leaves,1,2), "Magic Leaves");
LanguageRegistry.addName(new ItemStack(leaves,1,3), "Dark Leaves");
LanguageRegistry.addName(new ItemStack(leaves,1,4), "Dying Leaves");
LanguageRegistry.addName(new ItemStack(leaves,1,5), "Fir Leaves");
LanguageRegistry.addName(new ItemStack(leaves,1,6), "Holy Leaves");
LanguageRegistry.addName(new ItemStack(leaves,1,7), "Autumn Leaves");
LanguageRegistry.addName(new ItemStack(leaves,1,8), "Origin Leaves");
LanguageRegistry.addName(new ItemStack(leaves,1,9), "Cherry Leaves");
LanguageRegistry.addName(new ItemStack(leaves,1,10), "Maple Leaves");
LanguageRegistry.addName(new ItemStack(leaves,1,11), "Cherry Leaves");
leavesColorized = (new BlockBOPColorizedLeaves(2001)).setHardness(0.2F).setLightOpacity(1).setStepSound(Block.soundGrassFootstep).setUnlocalizedName("leavesColorized");
GameRegistry.registerBlock(leavesColorized, ItemBOPColorizedLeaves.class, "leavesColorized");
LanguageRegistry.addName(new ItemStack(leavesColorized,1,0), "Acacia Leaves");
LanguageRegistry.addName(new ItemStack(leavesColorized,1,1), "Mangrove Leaves");
LanguageRegistry.addName(new ItemStack(leavesColorized,1,2), "Palm Leaves");
LanguageRegistry.addName(new ItemStack(leavesColorized,1,3), "Redwood Leaves");
LanguageRegistry.addName(new ItemStack(leavesColorized,1,4), "Willow Leaves");
*/
// Add block registration
GameRegistry.registerBlock(mud, "mud");
GameRegistry.registerBlock(driedDirt, "driedDirt");

View file

@ -0,0 +1,28 @@
package tdwp_ftw.biomesop.items;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
public class ItemBOPColorizedLeaves extends ItemBlock
{
private static final String[] leaves = new String[] {"acacia", "mangrove", "palm", "redwood", "willow"};
public ItemBOPColorizedLeaves(int par1)
{
super(par1);
setMaxDamage(0);
setHasSubtypes(true);
}
@Override
public int getMetadata(int meta)
{
return meta;
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
return (new StringBuilder()).append(leaves[itemStack.getItemDamage()]).append("Planks").toString();
}
}

View file

@ -28,6 +28,7 @@ public class ItemBOPFlower extends ItemBlock
return (new StringBuilder()).append(plants[itemStack.getItemDamage()]).toString();
}
@Override
public Icon getIconFromDamage(int meta)
{
return Block.blocksList[this.itemID].getBlockTextureFromSideAndMetadata(0, meta);

View file

@ -0,0 +1,28 @@
package tdwp_ftw.biomesop.items;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
public class ItemBOPLeaves extends ItemBlock
{
private static final String[] leaves = new String[] {"autumn", "bamboo", "blue", "dark", "dead", "fir", "holy", "orange", "origin", "pink", "red", "white"};
public ItemBOPLeaves(int par1)
{
super(par1);
setMaxDamage(0);
setHasSubtypes(true);
}
@Override
public int getMetadata(int meta)
{
return meta;
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
return (new StringBuilder()).append(leaves[itemStack.getItemDamage()]).append("Planks").toString();
}
}