GenericWood: add slabs
This commit is contained in:
parent
e32c4228aa
commit
d8288f071f
3 changed files with 79 additions and 11 deletions
|
@ -12,7 +12,6 @@ import cpw.mods.fml.common.registry.LanguageRegistry;
|
|||
import net.universe_factory.minecraft.test.blocks.*;
|
||||
import net.universe_factory.minecraft.test.generic.GenericWood;
|
||||
|
||||
|
||||
@Mod(modid = Test.MODID, version = Test.VERSION)
|
||||
public class Test {
|
||||
public static final String MODID = "neoraider_test";
|
||||
|
@ -27,7 +26,8 @@ public class Test {
|
|||
@Override
|
||||
public int getMinTreeHeight() {
|
||||
return 4;
|
||||
}});
|
||||
}
|
||||
});
|
||||
|
||||
@Instance(value = MODID)
|
||||
public static Test instance;
|
||||
|
|
|
@ -10,11 +10,13 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.block.BlockLeaves;
|
||||
import net.minecraft.block.BlockLog;
|
||||
import net.minecraft.block.BlockSapling;
|
||||
import net.minecraft.block.BlockSlab;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemSlab;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -31,6 +33,8 @@ public class GenericWood {
|
|||
public final Block log;
|
||||
public final BlockLeaves leaves;
|
||||
public final BlockSapling sapling;
|
||||
public final BlockSlab slab;
|
||||
public final BlockSlab double_slab;
|
||||
|
||||
public GenericWood(Info info) {
|
||||
this.info = info;
|
||||
|
@ -39,15 +43,24 @@ public class GenericWood {
|
|||
log = new Log();
|
||||
leaves = new Leaves();
|
||||
sapling = new Sapling();
|
||||
slab = new Slab(false);
|
||||
double_slab = new Slab(true);
|
||||
}
|
||||
|
||||
public void register() {
|
||||
GameRegistry.registerBlock(planks, "blockWood" + info.getName());
|
||||
GameRegistry.registerBlock(log, "blockLog" + info.getName());
|
||||
GameRegistry.registerBlock(leaves, "blockLeaves" + info.getName());
|
||||
GameRegistry.registerBlock(sapling, "blockSapling" + info.getName());
|
||||
GameRegistry.registerBlock(planks, "wood_" + info.getName().toLowerCase());
|
||||
GameRegistry.registerBlock(log, "log_" + info.getName().toLowerCase());
|
||||
GameRegistry.registerBlock(leaves, "leaves_" + info.getName().toLowerCase());
|
||||
GameRegistry.registerBlock(sapling, "sapling_" + info.getName().toLowerCase());
|
||||
|
||||
GameRegistry.registerBlock(slab, null, "wooden_slab_" + info.getName().toLowerCase());
|
||||
GameRegistry.registerItem(new ItemSlab(slab, slab, double_slab, false), "wooden_slab_" + info.getName().toLowerCase());
|
||||
|
||||
GameRegistry.registerBlock(double_slab, null, "double_wooden_slab_" + info.getName().toLowerCase());
|
||||
GameRegistry.registerItem(new ItemSlab(double_slab, slab, double_slab, true), "double_wooden_slab_" + info.getName().toLowerCase());
|
||||
|
||||
GameRegistry.addRecipe(new ItemStack(planks, 4, 0), "#", '#', log);
|
||||
GameRegistry.addRecipe(new ItemStack(slab, 6, 0), "###", '#', planks);
|
||||
}
|
||||
|
||||
private class Planks extends Block {
|
||||
|
@ -171,18 +184,72 @@ public class GenericWood {
|
|||
public void func_149878_d(World world, int x, int y, int z, Random random) {
|
||||
if (!TerrainGen.saplingGrowTree(world, random, x, y, z))
|
||||
return;
|
||||
|
||||
|
||||
WorldGenerator generator = new WorldGenGenericTrees(true, GenericWood.this);
|
||||
|
||||
|
||||
world.setBlock(x, y, z, Blocks.air, 0, 4);
|
||||
|
||||
|
||||
if (!generator.generate(world, random, x, y, z))
|
||||
world.setBlock(x, y, z, this, 0, 4);
|
||||
world.setBlock(x, y, z, this, 0, 4);
|
||||
}
|
||||
}
|
||||
|
||||
private class Slab extends BlockSlab {
|
||||
public Slab(boolean doubleSlab) {
|
||||
super(doubleSlab, Material.wood);
|
||||
|
||||
setCreativeTab(CreativeTabs.tabBlock);
|
||||
|
||||
setHardness(2.0f);
|
||||
setResistance(5.0f);
|
||||
setStepSound(soundTypeWood);
|
||||
setBlockName("woodSlab" + info.getName());
|
||||
|
||||
setLightOpacity(doubleSlab ? 255 : 0);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return planks.getIcon(side, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int p_149650_1_, Random random, int p_149650_3_) {
|
||||
return Item.getItemFromBlock(slab);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack createStackedBlock(int meta) {
|
||||
return new ItemStack(Item.getItemFromBlock(slab), 2, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String func_150002_b(int p_150002_1_) {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) {
|
||||
if (!field_150004_a)
|
||||
super.getSubBlocks(item, creativeTabs, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Item getItem(World world, int x, int y, int z) {
|
||||
return Item.getItemFromBlock(slab);
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class Info {
|
||||
public abstract String getName();
|
||||
|
||||
public abstract int getMinTreeHeight();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
tile.woodCherry.name=Cherry Tree Wood Planks
|
||||
tile.logCherry.name=Cherry Tree Wood
|
||||
tile.leavesCherry.name=Cherry Tree Leaves
|
||||
tile.saplingCherry.name=Cherry Tree Sapling
|
||||
tile.saplingCherry.name=Cherry Tree Sapling
|
||||
tile.woodSlabCherry.name=Cherry Tree Wood Slab
|
Reference in a new issue