GenericWood: make abstract
This commit is contained in:
parent
fcc093da13
commit
0c500046d4
3 changed files with 32 additions and 43 deletions
|
@ -25,7 +25,7 @@ public class Test {
|
||||||
public static Test instance;
|
public static Test instance;
|
||||||
|
|
||||||
public static final Item cherries = new ItemFood(2, 0.2f, false).setTextureName(MODID + ":cherries").setUnlocalizedName("cherries");
|
public static final Item cherries = new ItemFood(2, 0.2f, false).setTextureName(MODID + ":cherries").setUnlocalizedName("cherries");
|
||||||
public static final GenericWood cherryTree = new GenericWood(new GenericWood.Info() {
|
public static final GenericWood cherryTree = new GenericWood() {
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "Cherry";
|
return "Cherry";
|
||||||
|
@ -54,7 +54,7 @@ public class Test {
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void preInit(FMLInitializationEvent event) {
|
public void preInit(FMLInitializationEvent event) {
|
||||||
|
|
|
@ -29,9 +29,7 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
public class GenericWood {
|
public abstract class GenericWood {
|
||||||
public final Info info;
|
|
||||||
|
|
||||||
public final Block planks;
|
public final Block planks;
|
||||||
public final Block log;
|
public final Block log;
|
||||||
public final BlockLeaves leaves;
|
public final BlockLeaves leaves;
|
||||||
|
@ -40,9 +38,7 @@ public class GenericWood {
|
||||||
public final BlockSlab double_slab;
|
public final BlockSlab double_slab;
|
||||||
public final BlockStairs stairs;
|
public final BlockStairs stairs;
|
||||||
|
|
||||||
public GenericWood(Info info) {
|
protected GenericWood() {
|
||||||
this.info = info;
|
|
||||||
|
|
||||||
planks = new Planks();
|
planks = new Planks();
|
||||||
log = new Log();
|
log = new Log();
|
||||||
leaves = new Leaves();
|
leaves = new Leaves();
|
||||||
|
@ -53,18 +49,18 @@ public class GenericWood {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void register() {
|
public void register() {
|
||||||
GameRegistry.registerBlock(planks, "wood_" + info.getName().toLowerCase());
|
GameRegistry.registerBlock(planks, "wood_" + getName().toLowerCase());
|
||||||
GameRegistry.registerBlock(log, "log_" + info.getName().toLowerCase());
|
GameRegistry.registerBlock(log, "log_" + getName().toLowerCase());
|
||||||
GameRegistry.registerBlock(leaves, "leaves_" + info.getName().toLowerCase());
|
GameRegistry.registerBlock(leaves, "leaves_" + getName().toLowerCase());
|
||||||
GameRegistry.registerBlock(sapling, "sapling_" + info.getName().toLowerCase());
|
GameRegistry.registerBlock(sapling, "sapling_" + getName().toLowerCase());
|
||||||
|
|
||||||
GameRegistry.registerBlock(slab, null, "wooden_slab_" + info.getName().toLowerCase());
|
GameRegistry.registerBlock(slab, null, "wooden_slab_" + getName().toLowerCase());
|
||||||
GameRegistry.registerItem(new ItemSlab(slab, slab, double_slab, false), "wooden_slab_" + info.getName().toLowerCase());
|
GameRegistry.registerItem(new ItemSlab(slab, slab, double_slab, false), "wooden_slab_" + getName().toLowerCase());
|
||||||
|
|
||||||
GameRegistry.registerBlock(double_slab, null, "double_wooden_slab_" + info.getName().toLowerCase());
|
GameRegistry.registerBlock(double_slab, null, "double_wooden_slab_" + getName().toLowerCase());
|
||||||
GameRegistry.registerItem(new ItemSlab(double_slab, slab, double_slab, true), "double_wooden_slab_" + info.getName().toLowerCase());
|
GameRegistry.registerItem(new ItemSlab(double_slab, slab, double_slab, true), "double_wooden_slab_" + getName().toLowerCase());
|
||||||
|
|
||||||
GameRegistry.registerBlock(stairs, "stairs_wood_" + info.getName().toLowerCase());
|
GameRegistry.registerBlock(stairs, "stairs_wood_" + getName().toLowerCase());
|
||||||
|
|
||||||
GameRegistry.addRecipe(new ItemStack(planks, 4), "#", '#', log);
|
GameRegistry.addRecipe(new ItemStack(planks, 4), "#", '#', log);
|
||||||
GameRegistry.addRecipe(new ItemStack(slab, 6), "###", '#', planks);
|
GameRegistry.addRecipe(new ItemStack(slab, 6), "###", '#', planks);
|
||||||
|
@ -89,11 +85,11 @@ public class GenericWood {
|
||||||
setHardness(2.0f);
|
setHardness(2.0f);
|
||||||
setResistance(5.0f);
|
setResistance(5.0f);
|
||||||
setStepSound(Block.soundTypeWood);
|
setStepSound(Block.soundTypeWood);
|
||||||
setBlockName("wood" + info.getName());
|
setBlockName("wood" + getName());
|
||||||
setCreativeTab(CreativeTabs.tabBlock);
|
setCreativeTab(CreativeTabs.tabBlock);
|
||||||
setHarvestLevel("axe", 0);
|
setHarvestLevel("axe", 0);
|
||||||
|
|
||||||
setBlockTextureName(Test.MODID + ":planks_" + info.getName().toLowerCase());
|
setBlockTextureName(Test.MODID + ":planks_" + getName().toLowerCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +98,7 @@ public class GenericWood {
|
||||||
private IIcon topIcon;
|
private IIcon topIcon;
|
||||||
|
|
||||||
public Log() {
|
public Log() {
|
||||||
setBlockName("log" + info.getName());
|
setBlockName("log" + getName());
|
||||||
setHarvestLevel("axe", 0);
|
setHarvestLevel("axe", 0);
|
||||||
|
|
||||||
setBlockTextureName(Test.MODID + ":log");
|
setBlockTextureName(Test.MODID + ":log");
|
||||||
|
@ -111,8 +107,8 @@ public class GenericWood {
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||||
sideIcon = iconRegister.registerIcon(this.getTextureName() + "_" + info.getName().toLowerCase());
|
sideIcon = iconRegister.registerIcon(this.getTextureName() + "_" + getName().toLowerCase());
|
||||||
topIcon = iconRegister.registerIcon(this.getTextureName() + "_" + info.getName().toLowerCase() + "_top");
|
topIcon = iconRegister.registerIcon(this.getTextureName() + "_" + getName().toLowerCase() + "_top");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -129,12 +125,12 @@ public class GenericWood {
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Leaves extends BlockLeaves {
|
private class Leaves extends BlockLeaves {
|
||||||
private String[] nameArray = new String[] { info.getName() };
|
private String[] nameArray = new String[] { getName() };
|
||||||
private IIcon icon;
|
private IIcon icon;
|
||||||
private IIcon iconOpaque;
|
private IIcon iconOpaque;
|
||||||
|
|
||||||
public Leaves() {
|
public Leaves() {
|
||||||
setBlockName("leaves" + info.getName());
|
setBlockName("leaves" + getName());
|
||||||
|
|
||||||
setBlockTextureName(Test.MODID + ":leaves");
|
setBlockTextureName(Test.MODID + ":leaves");
|
||||||
|
|
||||||
|
@ -144,8 +140,8 @@ public class GenericWood {
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||||
icon = iconRegister.registerIcon(this.getTextureName() + "_" + info.getName().toLowerCase());
|
icon = iconRegister.registerIcon(this.getTextureName() + "_" + getName().toLowerCase());
|
||||||
iconOpaque = iconRegister.registerIcon(this.getTextureName() + "_" + info.getName().toLowerCase() + "_opaque");
|
iconOpaque = iconRegister.registerIcon(this.getTextureName() + "_" + getName().toLowerCase() + "_opaque");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -226,7 +222,7 @@ public class GenericWood {
|
||||||
this.dropBlockAsItem(world, x, y, z, new ItemStack(item, 1, this.damageDropped(meta)));
|
this.dropBlockAsItem(world, x, y, z, new ItemStack(item, 1, this.damageDropped(meta)));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ItemStack drop : info.getDrops(world, x, y, z, meta, fortune))
|
for (ItemStack drop : GenericWood.this.getDrops(world, x, y, z, meta, fortune))
|
||||||
this.dropBlockAsItem(world, x, y, z, drop);
|
this.dropBlockAsItem(world, x, y, z, drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -234,12 +230,12 @@ public class GenericWood {
|
||||||
|
|
||||||
private class Sapling extends BlockSapling {
|
private class Sapling extends BlockSapling {
|
||||||
public Sapling() {
|
public Sapling() {
|
||||||
setBlockName("sapling" + info.getName());
|
setBlockName("sapling" + getName());
|
||||||
|
|
||||||
setHardness(0.0f);
|
setHardness(0.0f);
|
||||||
setStepSound(soundTypeGrass);
|
setStepSound(soundTypeGrass);
|
||||||
|
|
||||||
setBlockTextureName(Test.MODID + ":sapling_" + info.getName().toLowerCase());
|
setBlockTextureName(Test.MODID + ":sapling_" + getName().toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -284,7 +280,7 @@ public class GenericWood {
|
||||||
setHardness(2.0f);
|
setHardness(2.0f);
|
||||||
setResistance(5.0f);
|
setResistance(5.0f);
|
||||||
setStepSound(soundTypeWood);
|
setStepSound(soundTypeWood);
|
||||||
setBlockName("woodSlab" + info.getName());
|
setBlockName("woodSlab" + getName());
|
||||||
|
|
||||||
setLightOpacity(doubleSlab ? 255 : 0);
|
setLightOpacity(doubleSlab ? 255 : 0);
|
||||||
}
|
}
|
||||||
|
@ -332,18 +328,16 @@ public class GenericWood {
|
||||||
public Stairs() {
|
public Stairs() {
|
||||||
super(planks, 0);
|
super(planks, 0);
|
||||||
|
|
||||||
setBlockName("stairsWood" + info.getName());
|
setBlockName("stairsWood" + getName());
|
||||||
setLightOpacity(0);
|
setLightOpacity(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class Info {
|
public abstract String getName();
|
||||||
public abstract String getName();
|
|
||||||
|
|
||||||
public abstract int getMinTreeHeight();
|
public abstract int getMinTreeHeight();
|
||||||
|
|
||||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int meta, int fortune) {
|
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int meta, int fortune) {
|
||||||
return new ArrayList<ItemStack>();
|
return new ArrayList<ItemStack>();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,13 +3,8 @@ package net.universe_factory.minecraft.test.generic;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockSapling;
|
|
||||||
import net.minecraft.init.Blocks;
|
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.gen.feature.WorldGenAbstractTree;
|
import net.minecraft.world.gen.feature.WorldGenAbstractTree;
|
||||||
import net.minecraft.world.gen.feature.WorldGenerator;
|
|
||||||
import net.minecraftforge.common.IPlantable;
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
public class WorldGenGenericTrees extends WorldGenAbstractTree {
|
public class WorldGenGenericTrees extends WorldGenAbstractTree {
|
||||||
|
@ -23,7 +18,7 @@ public class WorldGenGenericTrees extends WorldGenAbstractTree {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean generate(World world, Random random, int x, int y, int z) {
|
public boolean generate(World world, Random random, int x, int y, int z) {
|
||||||
int height = random.nextInt(3) + genericWood.info.getMinTreeHeight();
|
int height = random.nextInt(3) + genericWood.getMinTreeHeight();
|
||||||
boolean flag = true;
|
boolean flag = true;
|
||||||
|
|
||||||
if (y >= 1 && y + height + 1 <= 256) {
|
if (y >= 1 && y + height + 1 <= 256) {
|
||||||
|
|
Reference in a new issue