Started slowly working on compressing blocks to use less IDs.

This commit is contained in:
Amnet 2013-04-13 17:07:23 +02:00
parent 72bfd8af9d
commit cd8dac3c8c
18 changed files with 496 additions and 1 deletions

View file

@ -5,6 +5,7 @@ import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import tdwp_ftw.biomesop.mod_BiomesOPlenty;
@Deprecated
public class BlockAcaciaPlank extends Block
{
public static final String[] woodType = new String[] {"acacia"};

View file

@ -0,0 +1,61 @@
package tdwp_ftw.biomesop.blocks;
import java.util.List;
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.item.ItemStack;
import net.minecraft.util.Icon;
import tdwp_ftw.biomesop.mod_BiomesOPlenty;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockBOPPlank extends Block
{
private static final String[] woodTypes = new String[] {"acacia", "cherry", "dark", "fir", "holy", "magic", "mangrove", "palm", "redwood", "willow"};
@SideOnly(Side.CLIENT)
private Icon[] textures;
public BlockBOPPlank(int blockID)
{
super(blockID, Material.wood);
setBurnProperties(this.blockID, 5, 20);
setHardness(2.0F);
this.setCreativeTab(mod_BiomesOPlenty.tabBiomesOPlenty);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
textures = new Icon[woodTypes.length];
for (int i = 0; i < woodTypes.length; ++i)
textures[i] = iconRegister.registerIcon("BiomesOPlenty:"+woodTypes[i]+"plank");
}
@Override
@SideOnly(Side.CLIENT)
public Icon getBlockTextureFromSideAndMetadata(int side, int meta)
{
if (meta < 0 || meta >= textures.length)
meta = 0;
return textures[meta];
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) {
for (int i = 0; i < woodTypes.length; ++i)
list.add(new ItemStack(blockID, 1, i));
}
@Override
public int damageDropped(int meta)
{
return meta;
}
}

View file

@ -0,0 +1,74 @@
package tdwp_ftw.biomesop.blocks;
import java.util.List;
import net.minecraft.block.BlockHalfSlab;
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 tdwp_ftw.biomesop.mod_BiomesOPlenty;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockBOPSlab extends BlockHalfSlab
{
private static final String[] woodTypes = new String[] {"acacia", "cherry", "dark", "fir", "holy", "magic", "mangrove", "palm", "redwood", "willow"};
@SideOnly(Side.CLIENT)
private Icon[] textures;
public BlockBOPSlab(int par1, boolean par2)
{
super(par1, par2, Material.wood);
setBurnProperties(this.blockID, 5, 20);
this.setCreativeTab(mod_BiomesOPlenty.tabBiomesOPlenty);
useNeighborBrightness[blockID] = true;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
textures = new Icon[woodTypes.length];
for (int i = 0; i < woodTypes.length; ++i)
textures[i] = iconRegister.registerIcon("BiomesOPlenty:"+woodTypes[i]+"plank");
}
@Override
@SideOnly(Side.CLIENT)
public Icon getBlockTextureFromSideAndMetadata(int side, int meta)
{
if (meta < 0 || meta >= textures.length)
meta = 0;
return textures[meta];
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) {
for (int i = 0; i < woodTypes.length; ++i)
list.add(new ItemStack(blockID, 1, i));
}
@Override
public String getFullSlabName(int meta)
{
if (meta < 0 || meta >= textures.length)
meta = 0;
return (new StringBuilder()).append(woodTypes[meta]).append("Slab").toString();
}
@Override
public int damageDropped(int meta)
{
return meta;
}
protected ItemStack createStackedBlock(int par1)
{
return new ItemStack(this.blockID, 2, par1);
}
}

View file

@ -0,0 +1,61 @@
package tdwp_ftw.biomesop.blocks;
import java.util.List;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import tdwp_ftw.biomesop.mod_BiomesOPlenty;
import net.minecraft.block.Block;
import net.minecraft.block.BlockStairs;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
public class BlockBOPStairs extends BlockStairs
{
private static final String[] woodTypes = new String[] {"acacia", "cherry", "dark", "fir", "holy", "magic", "mangrove", "palm", "redwood", "willow"};
@SideOnly(Side.CLIENT)
private Icon[] textures;
public BlockBOPStairs(int blockID, Block model)
{
super(blockID, model, 0);
setBurnProperties(this.blockID, 5, 20);
this.setLightOpacity(0);
this.setCreativeTab(mod_BiomesOPlenty.tabBiomesOPlenty);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
textures = new Icon[woodTypes.length];
for (int i = 0; i < woodTypes.length; ++i)
textures[i] = iconRegister.registerIcon("BiomesOPlenty:"+woodTypes[i]+"plank");
}
@Override
@SideOnly(Side.CLIENT)
public Icon getBlockTextureFromSideAndMetadata(int side, int meta)
{
if (meta < 0 || meta >= textures.length)
meta = 0;
return textures[meta];
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) {
for (int i = 0; i < woodTypes.length; ++i)
list.add(new ItemStack(blockID, 1, i));
}
@Override
public int damageDropped(int meta)
{
return meta;
}
}

View file

@ -5,6 +5,7 @@ import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import tdwp_ftw.biomesop.mod_BiomesOPlenty;
@Deprecated
public class BlockCherryPlank extends Block
{
/** The type of tree this block came from. */

View file

@ -5,6 +5,7 @@ import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import tdwp_ftw.biomesop.mod_BiomesOPlenty;
@Deprecated
public class BlockDarkPlank extends Block
{
/** The type of tree this block came from. */

View file

@ -5,6 +5,7 @@ import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import tdwp_ftw.biomesop.mod_BiomesOPlenty;
@Deprecated
public class BlockFirPlank extends Block
{
/** The type of tree this block came from. */

View file

@ -0,0 +1,177 @@
package tdwp_ftw.biomesop.blocks;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFlower;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.world.ColorizerFoliage;
import net.minecraft.world.ColorizerGrass;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.IShearable;
import tdwp_ftw.biomesop.configuration.BOPBlocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockFoliage extends BlockFlower implements IShearable
{
private static final String[] foliageTypes = new String[] {"shortgrass", "mediumgrass", "highgrassbottom", "highgrasstop"};
@SideOnly(Side.CLIENT)
private Icon[] textures = {null, null, null, null};
private final int metadata;
public BlockFoliage(int blockID, int index)
{
super(blockID, Material.vine);
float f = 0.4F;
BlockFoliage.setBurnProperties(this.blockID, 60, 100);
metadata = index;
if (metadata == 3)
this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F);
else
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.8F, 0.5F + f);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
for (int i = 0; i < textures.length; ++i)
textures[i] = iconRegister.registerIcon("BiomesOPlenty:"+foliageTypes[i]);
}
@Override
@SideOnly(Side.CLIENT)
public Icon getBlockTextureFromSideAndMetadata(int side, int meta)
{
if (meta >= textures.length)
{
meta = 0;
}
return textures[meta];
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(int blockID, CreativeTabs par2CreativeTabs, List list)
{
list.add(new ItemStack(blockID, 1, 0));
list.add(new ItemStack(blockID, 1, 1));
list.add(new ItemStack(blockID, 1, 2));
list.add(new ItemStack(blockID, 1, 3));
}
@Override
public boolean canPlaceBlockAt(World world, int x, int y, int z)
{
return super.canPlaceBlockAt(world, x, y, z) && this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y - 1, z));
}
@Override
protected boolean canThisPlantGrowOnThisBlockID(int blockID)
{
if (metadata == 3)
return blockID == BOPBlocks.highGrassBottom.blockID;
else
return blockID == Block.grass.blockID || blockID == Block.dirt.blockID || blockID == Block.tilledField.blockID;
}
@Override
public boolean canBlockStay(World world, int x, int y, int z)
{
return (world.getFullBlockLightValue(x, y, z) >= 8 || world.canBlockSeeTheSky(x, y, z)) && this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y - 1, z));
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, int neighborID)
{
super.onNeighborBlockChange(world, x, y, z, neighborID);
this.checkFlowerChange(world, x, y, z);
}
@Override
@SideOnly(Side.CLIENT)
public int getBlockColor()
{
double var1 = 0.5D;
double var3 = 1.0D;
return ColorizerGrass.getGrassColor(var1, var3);
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderColor(int par1)
{
return par1 == 0 ? 16777215 : ColorizerFoliage.getFoliageColorBasic();
}
@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
int var5 = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
return var5 == 0 ? 16777215 : par1IBlockAccess.getBiomeGenForCoords(par2, par4).getBiomeGrassColor();
}
@Override
public int getDamageValue(World world, int x, int y, int z)
{
return world.getBlockMetadata(x, y, z);
}
@Override
public int idDropped(int par1, Random par2Random, int par3)
{
return -1;
}
@Override
public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta)
{
super.harvestBlock(world, player, x, y, z, meta);
}
@Override
public int idPicked(World par1World, int par2, int par3, int par4)
{
// TODO
return -1;
// return BOPItems.shortGrassItem.itemID;
}
@Override
public boolean isBlockReplaceable(World world, int x, int y, int z)
{
return true;
}
@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)));
return ret;
}
@Override
public boolean isBlockFoliage(World world, int x, int y, int z)
{
return true;
}
}

View file

@ -2,6 +2,8 @@ package tdwp_ftw.biomesop.blocks;
import java.util.Random;
import tdwp_ftw.biomesop.configuration.BOPBlocks;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFlower;
import net.minecraft.block.material.Material;
@ -18,7 +20,7 @@ public class BlockHighGrassBottom extends BlockFlower
super(par1, Material.vine);
float var3 = 0.4F;
this.setBurnProperties(this.blockID, 60, 100);
this.setBlockBounds(0.5F - var3, 0.0F, 0.5F - var3, 0.5F + var3, 0.8F, 0.5F + var3);
this.setBlockBounds(0.5F - var3, 0.0F, 0.5F - var3, 0.5F + var3, 1.8F, 0.5F + var3);
}
@Override
@ -100,4 +102,11 @@ public class BlockHighGrassBottom extends BlockFlower
{
return true;
}
public int onBlockPlaced(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9)
{
par1World.setBlock(par2, par3, par4, BOPBlocks.highGrassBottom.blockID, 2, par9);
par1World.setBlock(par2, par3 + 1, par4, BOPBlocks.highGrassTop.blockID, 2, par9);
return par9;
}
}

View file

@ -5,6 +5,7 @@ import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import tdwp_ftw.biomesop.mod_BiomesOPlenty;
@Deprecated
public class BlockHolyPlank extends Block
{
/** The type of tree this block came from. */

View file

@ -5,6 +5,7 @@ import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import tdwp_ftw.biomesop.mod_BiomesOPlenty;
@Deprecated
public class BlockMagicPlank extends Block
{
/** The type of tree this block came from. */

View file

@ -5,6 +5,7 @@ import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import tdwp_ftw.biomesop.mod_BiomesOPlenty;
@Deprecated
public class BlockMangrovePlank extends Block
{
/** The type of tree this block came from. */

View file

@ -5,6 +5,7 @@ import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import tdwp_ftw.biomesop.mod_BiomesOPlenty;
@Deprecated
public class BlockPalmPlank extends Block
{
/** The type of tree this block came from. */

View file

@ -5,6 +5,7 @@ import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import tdwp_ftw.biomesop.mod_BiomesOPlenty;
@Deprecated
public class BlockRedwoodPlank extends Block
{
/** The type of tree this block came from. */

View file

@ -5,6 +5,7 @@ import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import tdwp_ftw.biomesop.mod_BiomesOPlenty;
@Deprecated
public class BlockWillowPlank extends Block
{
/** The type of tree this block came from. */

View file

@ -7,6 +7,7 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.oredict.OreDictionary;
import tdwp_ftw.biomesop.blocks.*;
import tdwp_ftw.biomesop.items.ItemBOPPlank;
import tdwp_ftw.biomesop.items.ItemBOPSlab;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
@ -187,6 +188,11 @@ public class BOPBlocks {
public static BlockHalfSlab holySingleSlab;
public static Block holyStairs;
public static Block planks;
public static Block stairs;
public static BlockHalfSlab singleSlab;
public static BlockHalfSlab doubleSlab;
public static void init()
{
// Block declaration
@ -362,6 +368,67 @@ public class BOPBlocks {
holyDoubleSlab = (BlockHalfSlab)(new BlockHolySlab(BOPConfiguration.holyDoubleSlabID, true)).setHardness(2.0F).setResistance(5.0F).setStepSound(Block.soundWoodFootstep).setUnlocalizedName("holySlab");
holySingleSlab = (BlockHalfSlab)(new BlockHolySlab(BOPConfiguration.holySingleSlabID, false)).setHardness(2.0F).setResistance(5.0F).setStepSound(Block.soundWoodFootstep).setUnlocalizedName("holySlab");
holyStairs = (new BlockHolyStairs(BOPConfiguration.holyStairsID, holyPlank)).setUnlocalizedName("holyStairs");
/*
// Planks condensed into one block
planks = (new BlockBOPPlank(2000)).setResistance(5.0F).setStepSound(Block.soundWoodFootstep).setUnlocalizedName("planks");
GameRegistry.registerBlock(planks, ItemBOPPlank.class, "planks");
LanguageRegistry.addName(new ItemStack(planks,1,0), "Acacia Wood Planks");
LanguageRegistry.addName(new ItemStack(planks,1,1), "Cherry Wood Planks");
LanguageRegistry.addName(new ItemStack(planks,1,2), "Dark Wood Planks");
LanguageRegistry.addName(new ItemStack(planks,1,3), "Fir Wood Planks");
LanguageRegistry.addName(new ItemStack(planks,1,4), "Holy Wood Planks");
LanguageRegistry.addName(new ItemStack(planks,1,5), "Magic Wood Planks");
LanguageRegistry.addName(new ItemStack(planks,1,6), "Mangrove Wood Planks");
LanguageRegistry.addName(new ItemStack(planks,1,7), "Palm Wood Planks");
LanguageRegistry.addName(new ItemStack(planks,1,8), "Redwood Wood Planks");
LanguageRegistry.addName(new ItemStack(planks,1,9), "Willow Wood Planks");
doubleSlab = (BlockHalfSlab)(new BlockBOPSlab(2003, true)).setHardness(2.0F).setResistance(5.0F).setStepSound(Block.soundWoodFootstep).setUnlocalizedName("slab");
singleSlab = (BlockHalfSlab)(new BlockBOPSlab(2002, false)).setHardness(2.0F).setResistance(5.0F).setStepSound(Block.soundWoodFootstep).setUnlocalizedName("slab");
ItemBOPSlab.setSlabs(singleSlab, doubleSlab);
// Slabs condensed - almost working, need to divide
GameRegistry.registerBlock(doubleSlab, ItemBOPSlab.class, "doubleSlab");
GameRegistry.registerBlock(singleSlab, ItemBOPSlab.class, "singleSlab");
LanguageRegistry.addName(new ItemStack(doubleSlab,1,0), "Acacia Wood Slab");
LanguageRegistry.addName(new ItemStack(doubleSlab,1,1), "Cherry Wood Slab");
LanguageRegistry.addName(new ItemStack(doubleSlab,1,2), "Dark Wood Slab");
LanguageRegistry.addName(new ItemStack(doubleSlab,1,3), "Fir Wood Slab");
LanguageRegistry.addName(new ItemStack(doubleSlab,1,4), "Holy Wood Slab");
LanguageRegistry.addName(new ItemStack(doubleSlab,1,5), "Magic Wood Slab");
LanguageRegistry.addName(new ItemStack(doubleSlab,1,6), "Mangrove Wood Slab");
LanguageRegistry.addName(new ItemStack(doubleSlab,1,7), "Palm Wood Slab");
LanguageRegistry.addName(new ItemStack(doubleSlab,1,8), "Redwood Wood Slab");
LanguageRegistry.addName(new ItemStack(doubleSlab,1,9), "Willow Wood Slab");
LanguageRegistry.addName(new ItemStack(singleSlab,1,0), "Acacia Wood Slab");
LanguageRegistry.addName(new ItemStack(singleSlab,1,1), "Cherry Wood Slab");
LanguageRegistry.addName(new ItemStack(singleSlab,1,2), "Dark Wood Slab");
LanguageRegistry.addName(new ItemStack(singleSlab,1,3), "Fir Wood Slab");
LanguageRegistry.addName(new ItemStack(singleSlab,1,4), "Holy Wood Slab");
LanguageRegistry.addName(new ItemStack(singleSlab,1,5), "Magic Wood Slab");
LanguageRegistry.addName(new ItemStack(singleSlab,1,6), "Mangrove Wood Slab");
LanguageRegistry.addName(new ItemStack(singleSlab,1,7), "Palm Wood Slab");
LanguageRegistry.addName(new ItemStack(singleSlab,1,8), "Redwood Wood Slab");
LanguageRegistry.addName(new ItemStack(singleSlab,1,9), "Willow Wood Slab");
/*Stairs condensed into one block - NOT WORKING
stairs = (new BlockBOPStairs(2001, planks)).setUnlocalizedName("stairs");
GameRegistry.registerBlock(stairs, ItemBOPPlank.class, "stairs");
LanguageRegistry.addName(new ItemStack(stairs,1,0), "Acacia Wood Stairs");
LanguageRegistry.addName(new ItemStack(stairs,1,1), "Cherry Wood Stairs");
LanguageRegistry.addName(new ItemStack(stairs,1,2), "Dark Wood Stairs");
LanguageRegistry.addName(new ItemStack(stairs,1,3), "Fir Wood Stairs");
LanguageRegistry.addName(new ItemStack(stairs,1,4), "Holy Wood Stairs");
LanguageRegistry.addName(new ItemStack(stairs,1,5), "Magic Wood Stairs");
LanguageRegistry.addName(new ItemStack(stairs,1,6), "Mangrove Wood Stairs");
LanguageRegistry.addName(new ItemStack(stairs,1,7), "Palm Wood Stairs");
LanguageRegistry.addName(new ItemStack(stairs,1,8), "Redwood Wood Stairs");
LanguageRegistry.addName(new ItemStack(stairs,1,9), "Willow Wood Stairs");
*/
// Add block registration
GameRegistry.registerBlock(mud, "mud");

View file

@ -0,0 +1,28 @@
package tdwp_ftw.biomesop.items;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
public class ItemBOPPlank extends ItemBlock
{
private static final String[] woodTypes = new String[] {"acacia", "cherry", "dark", "fir", "holy", "magic", "mangrove", "palm", "redwood", "willow"};
public ItemBOPPlank(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(woodTypes[itemStack.getItemDamage()]).append("Planks").toString();
}
}

View file

@ -8,6 +8,7 @@ import com.google.common.base.Optional;
public class ItemBOPSlab extends ItemSlab
{
private static final String[] woodTypes = new String[] {"acacia", "cherry", "dark", "fir", "holy", "magic", "mangrove", "palm", "redwood", "willow"};
private static Optional<BlockHalfSlab> singleSlab = Optional.absent();
private static Optional<BlockHalfSlab> doubleSlab = Optional.absent();
@ -20,9 +21,16 @@ public class ItemBOPSlab extends ItemSlab
public ItemBOPSlab(int id) {
super(id, singleSlab.get(), doubleSlab.get(), id == doubleSlab.get().blockID);
}
@Override
public int getMetadata(int meta)
{
return meta;
}
@Override
public String getUnlocalizedName(ItemStack itemStack) {
return itemStack.getItem().getUnlocalizedName();
// return (new StringBuilder()).append(woodTypes[itemStack.getItemDamage()]).append("Slab").toString();
}
}