diff options
author | Draknyte1 <Draknyte1@hotmail.com> | 2017-05-27 15:41:04 +1000 |
---|---|---|
committer | Draknyte1 <Draknyte1@hotmail.com> | 2017-05-27 15:41:04 +1000 |
commit | b20fad29ca4e6ad5de25080e212ab5257692afa5 (patch) | |
tree | a83c378cac103dac82a32b0508212109b5ac0d04 /src/Java/gtPlusPlus/xmod/bop/blocks/base/LeavesBase.java | |
parent | 0c3d983f6bfa7ada1c85a6176f599a3ea4bb8d2a (diff) | |
download | GT5-Unofficial-b20fad29ca4e6ad5de25080e212ab5257692afa5.tar.gz GT5-Unofficial-b20fad29ca4e6ad5de25080e212ab5257692afa5.tar.bz2 GT5-Unofficial-b20fad29ca4e6ad5de25080e212ab5257692afa5.zip |
+ Added some modular base tree (Log/Leaf/Sapling) classes.
+ Added BoP Rainforest Trees (Still need a bit of work).
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/bop/blocks/base/LeavesBase.java')
-rw-r--r-- | src/Java/gtPlusPlus/xmod/bop/blocks/base/LeavesBase.java | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/xmod/bop/blocks/base/LeavesBase.java b/src/Java/gtPlusPlus/xmod/bop/blocks/base/LeavesBase.java new file mode 100644 index 0000000000..d82e2d52b0 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/bop/blocks/base/LeavesBase.java @@ -0,0 +1,100 @@ +package gtPlusPlus.xmod.bop.blocks.base; + +import java.util.List; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.ItemUtils; +import net.minecraft.block.BlockLeaves; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.*; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class LeavesBase extends BlockLeaves { + + protected IIcon[][] leafTextures = new IIcon[2][]; + protected String[][] leafType = new String[][] {{}, {}}; + protected String[] treeType = new String[] {}; + protected ItemStack[] bonusDrops; + + @SuppressWarnings("deprecation") + public LeavesBase(String blockNameLocalized, String blockNameUnlocalized, ItemStack[] bonusDrops){ + this.bonusDrops = bonusDrops; + String blockName = "block"+Utils.sanitizeString(blockNameLocalized)+"Leaves"; + GameRegistry.registerBlock(this, ItemBlock.class, blockName); + this.setBlockName(blockName); + ItemUtils.addItemToOreDictionary(ItemUtils.getSimpleStack(this), "treeLeaves"); + this.setCreativeTab(AddToCreativeTab.tabBOP); + LanguageRegistry.addName(this, blockNameLocalized+" Leaves"); + } + + private final void setVanillaVariable(Object toSet, Object value){ + toSet = value; + } + + + @Override//Drops when Leaf is broken + protected void func_150124_c(World world, int x, int y, int z, int meta, int randomChance){ + if (this.treeType.length == this.bonusDrops.length){ + for (int i = 0; i < this.treeType.length; ++i){ + if (this.bonusDrops[i] != null && world.rand.nextInt(randomChance) == 0){ + this.dropBlockAsItem(world, x, y, z, ItemUtils.getSimpleStack(this.bonusDrops[i], 1)); + } + } + } + else { + Utils.LOG_INFO("Unable to drop anything, Leaf Type array and Loot array are different sizes."); + } + } + + /** + * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) + */ + @SuppressWarnings("unchecked") + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item item, CreativeTabs tab, @SuppressWarnings("rawtypes") List metaList){ + for (int i = 0; i < this.treeType.length; ++i){ + metaList.add(new ItemStack(item, 1, i)); + } + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int metaID){ + return (metaID & 3) == 1 ? this.leafTextures[this.field_150127_b][1] : this.leafTextures[this.field_150127_b][0]; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iIcon){ + for (int i = 0; i < leafType.length; ++i){ + this.leafTextures[i] = new IIcon[leafType[i].length]; + for (int j = 0; j < leafType[i].length; ++j){ + this.leafTextures[i][j] = iIcon.registerIcon(CORE.MODID + ":" + "trees/" + "leaves/" + "leaves_" + leafType[i][j]); + } + } + setVanillaVariable(this.field_150129_M, this.leafTextures); + } + + @Override + public String[] func_150125_e() + { + return treeType; + } +}
\ No newline at end of file |