Add helper functions for paged block classes BOPLeaves BOPLog BOPSapling
This commit is contained in:
parent
bd33408d07
commit
fc05c996c3
6 changed files with 99 additions and 9 deletions
|
@ -22,9 +22,7 @@ import biomesoplenty.api.block.BOPWoodEnums.AllWoods;
|
|||
import biomesoplenty.common.block.BlockBOPFlower2;
|
||||
import biomesoplenty.common.block.BlockBOPFlower2.FlowerType;
|
||||
import biomesoplenty.common.block.BlockBOPLeaves;
|
||||
import biomesoplenty.common.block.BlockBOPLeaves3;
|
||||
import biomesoplenty.common.block.BlockBOPLog;
|
||||
import biomesoplenty.common.block.BlockBOPLog3;
|
||||
import biomesoplenty.common.block.BlockBOPPlant;
|
||||
import biomesoplenty.common.block.BlockGem;
|
||||
import biomesoplenty.common.block.BlockGem.GemType;
|
||||
|
@ -49,7 +47,7 @@ public class BiomeGenLavenderFields extends BOPBiome
|
|||
this.addGenerator("lavender", GeneratorStage.FLOWERS, new GeneratorFlora(999, BOPBlocks.flower2.getDefaultState().withProperty(BlockBOPFlower2.VARIANT, FlowerType.LAVENDER)));
|
||||
|
||||
GeneratorWeighted treeGenerator = new GeneratorWeighted(1);
|
||||
treeGenerator.add(3, new GeneratorBasicTree(1, false, 4, 7, BOPBlocks.log_3.getDefaultState().withProperty(BlockBOPLog.getVariantProperty(BlockBOPLog3.PAGENUM), AllWoods.JACARANDA), BOPBlocks.leaves_3.getDefaultState().withProperty(BlockBOPLeaves.getVariantProperty(BlockBOPLeaves3.PAGENUM), AllTrees.JACARANDA)));
|
||||
treeGenerator.add(3, new GeneratorBasicTree(1, false, 4, 7, BlockBOPLog.getVariantState(AllWoods.JACARANDA), BlockBOPLeaves.getVariantState(AllTrees.JACARANDA)));
|
||||
treeGenerator.add(1, new GeneratorBigTree(1, false, Blocks.log.getDefaultState(), Blocks.leaves.getDefaultState()));
|
||||
this.addGenerator("trees", GeneratorStage.TREE, treeGenerator);
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ import biomesoplenty.common.block.BlockBOPFlower2;
|
|||
import biomesoplenty.common.block.BlockBOPFlower2.FlowerType;
|
||||
import biomesoplenty.common.block.BlockBOPGrass;
|
||||
import biomesoplenty.common.block.BlockBOPLeaves;
|
||||
import biomesoplenty.common.block.BlockBOPLeaves2;
|
||||
import biomesoplenty.common.block.BlockBOPGrass.BOPGrassType;
|
||||
import biomesoplenty.common.config.MiscConfigurationHandler;
|
||||
import biomesoplenty.common.world.feature.GeneratorFlora;
|
||||
|
@ -40,8 +39,7 @@ public class BiomeGenOriginValley extends BOPBiome
|
|||
|
||||
this.topBlock = BOPBlocks.grass.getDefaultState().withProperty(BlockBOPGrass.VARIANT, BOPGrassType.ORIGIN);
|
||||
|
||||
GeneratorBasicTree treeGenerator = new GeneratorBasicTree(4, false, 5, 8, Blocks.log.getDefaultState(),
|
||||
BOPBlocks.leaves_2.getDefaultState().withProperty(BlockBOPLeaves.getVariantProperty(BlockBOPLeaves2.PAGENUM), AllTrees.ORIGIN));
|
||||
GeneratorBasicTree treeGenerator = new GeneratorBasicTree(4, false, 5, 8, Blocks.log.getDefaultState(), BlockBOPLeaves.getVariantState(AllTrees.ORIGIN));
|
||||
this.addGenerator("trees", GeneratorStage.TREE, treeGenerator);
|
||||
|
||||
GeneratorWeighted flowerGenerator = new GeneratorWeighted(4);
|
||||
|
|
|
@ -8,7 +8,9 @@
|
|||
|
||||
package biomesoplenty.common.block;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import biomesoplenty.api.block.BOPBlocks;
|
||||
|
@ -66,7 +68,33 @@ public abstract class BlockBOPLeaves extends BlockLeaves implements IBOPBlock
|
|||
{
|
||||
int i = Math.max(0, Math.min(meta + (this.getPageNum() * VARIANTS_PER_PAGE), AllTrees.values().length));
|
||||
return AllTrees.values()[i];
|
||||
}
|
||||
}
|
||||
|
||||
// store reference to each created instance, indexed by page num, so that later we can look up the right BlockFoliage instance for a particular variant
|
||||
private static Map<Integer, BlockBOPLeaves> instances = new HashMap<Integer, BlockBOPLeaves>();
|
||||
// get the BlockBOPLeaves instance for the given variant
|
||||
public static BlockBOPLeaves getVariantBlock(AllTrees tree)
|
||||
{
|
||||
int pageNum = tree.ordinal() / VARIANTS_PER_PAGE;
|
||||
BlockBOPLeaves block = instances.get(pageNum);
|
||||
if (block == null) {throw new IllegalArgumentException("No BlockBOPLeaves instance created yet for page "+pageNum);}
|
||||
return block;
|
||||
}
|
||||
// get the default block state for the given variant
|
||||
public static IBlockState getVariantState(AllTrees tree)
|
||||
{
|
||||
BlockBOPLeaves block = getVariantBlock(tree);
|
||||
return block.getDefaultState().withProperty(block.getMyVariantProperty() , tree);
|
||||
}
|
||||
// get the item representation of the given variant
|
||||
public static ItemStack getVariantItem(AllTrees tree, int howMany)
|
||||
{
|
||||
return new ItemStack(getVariantBlock(tree), howMany, getVariantBlock(tree).getMetaFromState(getVariantState(tree)));
|
||||
}
|
||||
public static ItemStack getVariantItem(AllTrees tree)
|
||||
{
|
||||
return getVariantItem(tree, 1);
|
||||
}
|
||||
|
||||
// add properties - note CHECK_DECAY and DECAYABLE are both inherited from BlockLeaves
|
||||
@Override
|
||||
|
@ -98,6 +126,8 @@ public abstract class BlockBOPLeaves extends BlockLeaves implements IBOPBlock
|
|||
public BlockBOPLeaves()
|
||||
{
|
||||
super();
|
||||
// save a reference to this instance so that later we can look up the right BlockFoliage instance for a particular variant
|
||||
instances.put(this.getPageNum(), this);
|
||||
this.setDefaultState(this.blockState.getBaseState().withProperty(CHECK_DECAY, Boolean.valueOf(true)).withProperty(DECAYABLE, Boolean.valueOf(true)));
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
|
||||
package biomesoplenty.common.block;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import biomesoplenty.api.block.BOPWoodEnums.AllWoods;
|
||||
import biomesoplenty.api.block.BOPWoodEnums;
|
||||
import biomesoplenty.api.block.IBOPBlock;
|
||||
|
@ -18,6 +21,7 @@ import net.minecraft.block.properties.PropertyEnum;
|
|||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public abstract class BlockBOPLog extends BlockLog implements IBOPBlock
|
||||
{
|
||||
|
@ -48,7 +52,34 @@ public abstract class BlockBOPLog extends BlockLog implements IBOPBlock
|
|||
{
|
||||
int i = Math.max(0, Math.min(meta + (this.getPageNum() * VARIANTS_PER_PAGE), AllWoods.values().length));
|
||||
return AllWoods.values()[i];
|
||||
}
|
||||
}
|
||||
|
||||
// store reference to each created instance, indexed by page num, so that later we can look up the right BlockBOPLog instance for a particular variant
|
||||
private static Map<Integer, BlockBOPLog> instances = new HashMap<Integer, BlockBOPLog>();
|
||||
// get the BlockFoliage instance for the given variant
|
||||
public static BlockBOPLog getVariantBlock(AllWoods wood)
|
||||
{
|
||||
int pageNum = wood.ordinal() / VARIANTS_PER_PAGE;
|
||||
BlockBOPLog block = instances.get(pageNum);
|
||||
if (block == null) {throw new IllegalArgumentException("No BlockBOPLog instance created yet for page "+pageNum);}
|
||||
return block;
|
||||
}
|
||||
// get the default block state for the given variant
|
||||
public static IBlockState getVariantState(AllWoods wood)
|
||||
{
|
||||
BlockBOPLog block = getVariantBlock(wood);
|
||||
return block.getDefaultState().withProperty(block.getMyVariantProperty() , wood);
|
||||
}
|
||||
// get the item representation of the given variant
|
||||
public static ItemStack getVariantItem(AllWoods wood, int howMany)
|
||||
{
|
||||
return new ItemStack(getVariantBlock(wood), howMany, getVariantBlock(wood).getMetaFromState(getVariantState(wood)));
|
||||
}
|
||||
public static ItemStack getVariantItem(AllWoods wood)
|
||||
{
|
||||
return getVariantItem(wood, 1);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { LOG_AXIS, getMyVariantProperty() });}
|
||||
|
@ -80,6 +111,8 @@ public abstract class BlockBOPLog extends BlockLog implements IBOPBlock
|
|||
public BlockBOPLog()
|
||||
{
|
||||
super();
|
||||
// save a reference to this instance so that later we can look up the right BlockBOPLog instance for a particular variant
|
||||
instances.put(this.getPageNum(), this);
|
||||
this.setDefaultState(this.blockState.getBaseState().withProperty(LOG_AXIS, BlockLog.EnumAxis.Y));
|
||||
this.setHarvestLevel("axe", 0);
|
||||
}
|
||||
|
|
|
@ -86,9 +86,9 @@ public abstract class BlockBOPPlant extends BlockDecoration implements IShearabl
|
|||
int i = Math.max(0, Math.min(meta + (this.getPageNum() * VARIANTS_PER_PAGE), AllPlants.values().length));
|
||||
return AllPlants.values()[i];
|
||||
}
|
||||
|
||||
// store reference to each created instance, indexed by page num, so that later we can look up the right BlockFoliage instance for a particular variant
|
||||
private static Map<Integer, BlockBOPPlant> instances = new HashMap<Integer, BlockBOPPlant>();
|
||||
|
||||
// get the BlockFoliage instance for the given variant
|
||||
public static BlockBOPPlant getVariantBlock(AllPlants plant)
|
||||
{
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
package biomesoplenty.common.block;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import biomesoplenty.api.block.BOPBlocks;
|
||||
|
@ -21,6 +23,7 @@ import net.minecraft.block.properties.PropertyInteger;
|
|||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.feature.WorldGenAbstractTree;
|
||||
|
@ -59,6 +62,32 @@ public abstract class BlockBOPSapling extends BlockDecoration implements IGrowab
|
|||
int i = Math.max(0, Math.min(meta + (this.getPageNum() * VARIANTS_PER_PAGE), AllTrees.values().length));
|
||||
return AllTrees.values()[i];
|
||||
}
|
||||
|
||||
// store reference to each created instance, indexed by page num, so that later we can look up the right BlockFoliage instance for a particular variant
|
||||
private static Map<Integer, BlockBOPSapling> instances = new HashMap<Integer, BlockBOPSapling>();
|
||||
// get the BlockBOPLeaves instance for the given variant
|
||||
public static BlockBOPSapling getVariantBlock(AllTrees tree)
|
||||
{
|
||||
int pageNum = tree.ordinal() / VARIANTS_PER_PAGE;
|
||||
BlockBOPSapling block = instances.get(pageNum);
|
||||
if (block == null) {throw new IllegalArgumentException("No BlockBOPLeaves instance created yet for page "+pageNum);}
|
||||
return block;
|
||||
}
|
||||
// get the default block state for the given variant
|
||||
public static IBlockState getVariantState(AllTrees tree)
|
||||
{
|
||||
BlockBOPSapling block = getVariantBlock(tree);
|
||||
return block.getDefaultState().withProperty(block.getMyVariantProperty() , tree);
|
||||
}
|
||||
// get the item representation of the given variant
|
||||
public static ItemStack getVariantItem(AllTrees tree, int howMany)
|
||||
{
|
||||
return new ItemStack(getVariantBlock(tree), howMany, getVariantBlock(tree).getMetaFromState(getVariantState(tree)));
|
||||
}
|
||||
public static ItemStack getVariantItem(AllTrees tree)
|
||||
{
|
||||
return getVariantItem(tree, 1);
|
||||
}
|
||||
|
||||
|
||||
// add properties
|
||||
|
@ -82,6 +111,8 @@ public abstract class BlockBOPSapling extends BlockDecoration implements IGrowab
|
|||
public BlockBOPSapling()
|
||||
{
|
||||
super();
|
||||
// save a reference to this instance so that later we can look up the right BlockBOPSapling instance for a particular variant
|
||||
instances.put(this.getPageNum(), this);
|
||||
this.setStepSound(Block.soundTypeGrass);
|
||||
this.setBlockBoundsByRadiusAndHeight(0.4F, 0.8F);
|
||||
this.setDefaultState(this.blockState.getBaseState().withProperty(STAGE, Integer.valueOf(0)));
|
||||
|
|
Loading…
Reference in a new issue