Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Main Leaf Assignment Class
- package com.doa.biomes.features;
- import java.util.List;
- import cpw.mods.fml.relauncher.Side;
- import cpw.mods.fml.relauncher.SideOnly;
- import net.minecraft.block.BlockLeaves;
- import net.minecraft.client.renderer.texture.IIconRegister;
- import net.minecraft.creativetab.CreativeTabs;
- import net.minecraft.init.Items;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.util.IIcon;
- import net.minecraft.world.ColorizerFoliage;
- import net.minecraft.world.World;
- public class DOALeaves extends DOALeaf{
- public static final String[][] leaftypes = new String[][] {{"leaves_magic", "leaves_shimmer", "leaves_glow", "leaves_chime", "leaves_live", "leaves_float", "leaves_love", "leaves_mystical", "leaves_angle", "leaves_sun", "leaves_chaos", "leaves_silent", "leaves_rot", "leaves_dead", "leaves_devil", "leaves_doom", "leaves_snake", "leaves_mold", "leaves_flame", "leaves_reaper"}, {"leaves_magic_opaque", "leaves_shimmer_opaque", "leaves_glow_opaque", "leaves_chime_opaque", "leaves_live_opaque", "leaves_float_opaque", "leaves_love_opaque", "leaves_mystical_opaque", "leaves_angle_opaque", "leaves_sun_opaque", "leaves_chaos_opaque", "leaves_silent_opaque", "leaves_rot_opaque", "leaves_dead_opaque", "leaves_devil_opaque", "leaves_doom_opaque", "leaves_snake_opaque", "leaves_mold_opaque", "leaves_flame_opaque", "leaves_reaper_opaque"}};
- public static final String[] leaves = new String[]{"magic", "shimmer", "glow", "chime", "live", "float", "love", "mystical", "angle", "sun", "chaos", "silent", "rot", "dead", "devil", "doom", "snake", "mold", "flame", "reaper"};
- protected void func_150124_c(World world, int par1, int par2, int par3, int par4, int par5)
- {
- if ((par4 & 3) == 0 && world.rand.nextInt(par5) == 0)
- {
- this.dropBlockAsItem(world, par1, par2, par3, new ItemStack(Items.apple, 1, 0));
- }
- }
- protected int func_150123_b(int par1)
- {
- int j = super.func_150123_b(par1);
- if ((par1 & 3) == 3)
- {
- j = 40;
- }
- return j;
- }
- /**
- * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
- */
- @SideOnly(Side.CLIENT)
- public void getSubBlocks(Item item, CreativeTabs tabs, List list)
- {
- list.add(new ItemStack(item, 1, 0));
- list.add(new ItemStack(item, 1, 1));
- list.add(new ItemStack(item, 1, 2));
- list.add(new ItemStack(item, 1, 3));
- list.add(new ItemStack(item, 1, 4));
- list.add(new ItemStack(item, 1, 5));
- list.add(new ItemStack(item, 1, 6));
- list.add(new ItemStack(item, 1, 7));
- list.add(new ItemStack(item, 1, 8));
- list.add(new ItemStack(item, 1, 9));
- list.add(new ItemStack(item, 1, 10));
- list.add(new ItemStack(item, 1, 11));
- list.add(new ItemStack(item, 1, 12));
- list.add(new ItemStack(item, 1, 13));
- list.add(new ItemStack(item, 1, 14));
- list.add(new ItemStack(item, 1, 15));
- list.add(new ItemStack(item, 1, 16));
- list.add(new ItemStack(item, 1, 17));
- list.add(new ItemStack(item, 1, 18));
- list.add(new ItemStack(item, 1, 19));
- }
- @SideOnly(Side.CLIENT)
- public void registerBlockIcons(IIconRegister iconregister)
- {
- for (int i = 0; i < leaftypes.length; ++i)
- {
- this.field_150129_M[i] = new IIcon[leaftypes[i].length];
- for (int j = 0; j < leaftypes[i].length; ++j)
- {
- this.field_150129_M[i][j] = iconregister.registerIcon("doa:" + leaftypes[i][j]);
- }
- }
- }
- public String[] func_150125_e()
- {
- return leaves;
- }
- @SideOnly(Side.CLIENT)
- public IIcon getIcon(int side, int meta)
- {
- return (meta & 3) == 1 ? this.field_150129_M[this.field_150127_b][1] : ((meta & 3) == 2 ? this.field_150129_M[this.field_150127_b][2] : ((meta & 3) == 3 ? this.field_150129_M[this.field_150127_b][3] : (meta & 3) == 4 ? this.field_150129_M[this.field_150127_b][4]: (meta & 3) == 5 ? this.field_150129_M[this.field_150127_b][5]: (meta & 3) == 6 ? this.field_150129_M[this.field_150127_b][6] : (meta & 3) == 7 ? this.field_150129_M[this.field_150127_b][7] : (meta & 3) == 8 ? this.field_150129_M[this.field_150127_b][8] : (meta & 3) == 9 ? this.field_150129_M[this.field_150127_b][9] : (meta & 3) == 10 ? this.field_150129_M[this.field_150127_b][10] : (meta & 3) == 11 ? this.field_150129_M[this.field_150127_b][11] : (meta & 3) == 12 ? this.field_150129_M[this.field_150127_b][12] : (meta & 3) == 13 ? this.field_150129_M[this.field_150127_b][13] : (meta & 3) == 14 ? this.field_150129_M[this.field_150127_b][14] : (meta & 3) == 15 ? this.field_150129_M[this.field_150127_b][15] : (meta & 3) == 16 ? this.field_150129_M[this.field_150127_b][16] : (meta & 3) == 17 ? this.field_150129_M[this.field_150127_b][17] : (meta & 3) == 18 ? this.field_150129_M[this.field_150127_b][18] : (meta & 3) == 19 ? this.field_150129_M[this.field_150127_b][19] : this.field_150129_M[this.field_150127_b][0]));
- }
- }
- #Edited Version of The Block Leaf Class to remove Biome Colours
- package com.doa.biomes.features;
- import java.util.ArrayList;
- import java.util.Random;
- import net.minecraft.block.Block;
- import net.minecraft.block.BlockLeavesBase;
- import net.minecraft.block.material.Material;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.init.Blocks;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.util.IIcon;
- import net.minecraft.world.ColorizerFoliage;
- import net.minecraft.world.IBlockAccess;
- import net.minecraft.world.World;
- import net.minecraftforge.common.IShearable;
- import com.doa.main.DOACreativeTabs;
- import cpw.mods.fml.relauncher.Side;
- import cpw.mods.fml.relauncher.SideOnly;
- public abstract class DOALeaf extends BlockLeavesBase implements IShearable
- {
- int[] field_150128_a;
- @SideOnly(Side.CLIENT)
- protected int field_150127_b;
- protected IIcon[][] field_150129_M = new IIcon[2][];
- private static final String __OBFID = "CL_00000263";
- public DOALeaf()
- {
- super(Material.leaves, false);
- this.setTickRandomly(true);
- this.setCreativeTab(DOACreativeTabs.tabDOABlocks);
- this.setHardness(0.2F);
- this.setLightOpacity(1);
- this.setStepSound(soundTypeGrass);
- }
- public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_)
- {
- byte b0 = 1;
- int i1 = b0 + 1;
- if (p_149749_1_.checkChunksExist(p_149749_2_ - i1, p_149749_3_ - i1, p_149749_4_ - i1, p_149749_2_ + i1, p_149749_3_ + i1, p_149749_4_ + i1))
- {
- for (int j1 = -b0; j1 <= b0; ++j1)
- {
- for (int k1 = -b0; k1 <= b0; ++k1)
- {
- for (int l1 = -b0; l1 <= b0; ++l1)
- {
- Block block = p_149749_1_.getBlock(p_149749_2_ + j1, p_149749_3_ + k1, p_149749_4_ + l1);
- if (block.isLeaves(p_149749_1_, p_149749_2_ + j1, p_149749_3_ + k1, p_149749_4_ + l1))
- {
- block.beginLeavesDecay(p_149749_1_, p_149749_2_ + j1, p_149749_3_ + k1, p_149749_4_ + l1);
- }
- }
- }
- }
- }
- }
- /**
- * Ticks the block if it's been scheduled
- */
- public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_)
- {
- if (!p_149674_1_.isRemote)
- {
- int l = p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_);
- if ((l & 8) != 0 && (l & 4) == 0)
- {
- byte b0 = 4;
- int i1 = b0 + 1;
- byte b1 = 32;
- int j1 = b1 * b1;
- int k1 = b1 / 2;
- if (this.field_150128_a == null)
- {
- this.field_150128_a = new int[b1 * b1 * b1];
- }
- int l1;
- if (p_149674_1_.checkChunksExist(p_149674_2_ - i1, p_149674_3_ - i1, p_149674_4_ - i1, p_149674_2_ + i1, p_149674_3_ + i1, p_149674_4_ + i1))
- {
- int i2;
- int j2;
- for (l1 = -b0; l1 <= b0; ++l1)
- {
- for (i2 = -b0; i2 <= b0; ++i2)
- {
- for (j2 = -b0; j2 <= b0; ++j2)
- {
- Block block = p_149674_1_.getBlock(p_149674_2_ + l1, p_149674_3_ + i2, p_149674_4_ + j2);
- if (!block.canSustainLeaves(p_149674_1_, p_149674_2_ + l1, p_149674_3_ + i2, p_149674_4_ + j2))
- {
- if (block.isLeaves(p_149674_1_, p_149674_2_ + l1, p_149674_3_ + i2, p_149674_4_ + j2))
- {
- this.field_150128_a[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -2;
- }
- else
- {
- this.field_150128_a[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -1;
- }
- }
- else
- {
- this.field_150128_a[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = 0;
- }
- }
- }
- }
- for (l1 = 1; l1 <= 4; ++l1)
- {
- for (i2 = -b0; i2 <= b0; ++i2)
- {
- for (j2 = -b0; j2 <= b0; ++j2)
- {
- for (int k2 = -b0; k2 <= b0; ++k2)
- {
- if (this.field_150128_a[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1] == l1 - 1)
- {
- if (this.field_150128_a[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2)
- {
- this.field_150128_a[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1;
- }
- if (this.field_150128_a[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2)
- {
- this.field_150128_a[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1;
- }
- if (this.field_150128_a[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] == -2)
- {
- this.field_150128_a[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] = l1;
- }
- if (this.field_150128_a[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] == -2)
- {
- this.field_150128_a[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] = l1;
- }
- if (this.field_150128_a[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] == -2)
- {
- this.field_150128_a[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] = l1;
- }
- if (this.field_150128_a[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] == -2)
- {
- this.field_150128_a[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] = l1;
- }
- }
- }
- }
- }
- }
- }
- l1 = this.field_150128_a[k1 * j1 + k1 * b1 + k1];
- if (l1 >= 0)
- {
- p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, l & -9, 4);
- }
- else
- {
- this.removeLeaves(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_);
- }
- }
- }
- }
- /**
- * A randomly called display update to be able to add particles or other items for display
- */
- @SideOnly(Side.CLIENT)
- public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_)
- {
- if (p_149734_1_.canLightningStrikeAt(p_149734_2_, p_149734_3_ + 1, p_149734_4_) && !World.doesBlockHaveSolidTopSurface(p_149734_1_, p_149734_2_, p_149734_3_ - 1, p_149734_4_) && p_149734_5_.nextInt(15) == 1)
- {
- double d0 = (double)((float)p_149734_2_ + p_149734_5_.nextFloat());
- double d1 = (double)p_149734_3_ - 0.05D;
- double d2 = (double)((float)p_149734_4_ + p_149734_5_.nextFloat());
- p_149734_1_.spawnParticle("dripWater", d0, d1, d2, 0.0D, 0.0D, 0.0D);
- }
- }
- private void removeLeaves(World p_150126_1_, int p_150126_2_, int p_150126_3_, int p_150126_4_)
- {
- this.dropBlockAsItem(p_150126_1_, p_150126_2_, p_150126_3_, p_150126_4_, p_150126_1_.getBlockMetadata(p_150126_2_, p_150126_3_, p_150126_4_), 0);
- p_150126_1_.setBlockToAir(p_150126_2_, p_150126_3_, p_150126_4_);
- }
- /**
- * Returns the quantity of items to drop on block destruction.
- */
- public int quantityDropped(Random p_149745_1_)
- {
- return p_149745_1_.nextInt(20) == 0 ? 1 : 0;
- }
- public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
- {
- return Item.getItemFromBlock(Blocks.sapling);
- }
- /**
- * Drops the block items with a specified chance of dropping the specified items
- */
- public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_)
- {
- super.dropBlockAsItemWithChance(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, 1.0f, p_149690_7_);
- }
- protected void func_150124_c(World p_150124_1_, int p_150124_2_, int p_150124_3_, int p_150124_4_, int p_150124_5_, int p_150124_6_) {}
- protected int func_150123_b(int p_150123_1_)
- {
- return 20;
- }
- /**
- * Called when the player destroys a block with an item that can harvest it. (i, j, k) are the coordinates of the
- * block and l is the block's subtype/damage.
- */
- public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int block)
- {
- {
- super.harvestBlock(world, player, x, y, z, block);
- }
- }
- /**
- * Determines the damage on the item the block drops. Used in cloth and wood.
- */
- public int damageDropped(int meta)
- {
- return meta & 3;
- }
- /**
- * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
- * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
- */
- public boolean isOpaqueCube()
- {
- return false;
- }
- /**
- * Gets the block's texture. Args: side, meta
- */
- @SideOnly(Side.CLIENT)
- public abstract IIcon getIcon(int side, int meta);
- /**
- * Pass true to draw this block using fancy graphics, or false for fast graphics.
- */
- @SideOnly(Side.CLIENT)
- public void setGraphicsLevel(boolean bool1)
- {
- this.field_150121_P = bool1;
- this.field_150127_b = bool1 ? 0 : 1;
- }
- /**
- * Returns an item stack containing a single instance of the current block type. 'i' is the block's subtype/damage
- * and is ignored for blocks which do not support subtypes. Blocks which cannot be harvested should return null.
- */
- protected ItemStack createStackedBlock(int block)
- {
- return new ItemStack(Item.getItemFromBlock(this), 1, block & 3);
- }
- public abstract String[] func_150125_e();
- @Override
- public boolean isShearable(ItemStack item, IBlockAccess world, int x, int y, int z)
- {
- return true;
- }
- @Override
- public ArrayList<ItemStack> onSheared(ItemStack item, IBlockAccess 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) & 3));
- return ret;
- }
- @Override
- public void beginLeavesDecay(World world, int x, int y, int z)
- {
- int i2 = world.getBlockMetadata(x, y, z);
- if ((i2 & 8) == 0)
- {
- world.setBlockMetadataWithNotify(x, y, z, i2 | 8, 4);
- }
- world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) | 8, 4);
- }
- @Override
- public boolean isLeaves(IBlockAccess world, int x, int y, int z)
- {
- return true;
- }
- @Override
- public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune)
- {
- ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
- int chance = this.func_150123_b(metadata);
- if (fortune > 0)
- {
- chance -= 2 << fortune;
- if (chance < 10) chance = 10;
- }
- if (world.rand.nextInt(chance) == 0)
- ret.add(new ItemStack(this.getItemDropped(metadata, world.rand, fortune), 1, this.damageDropped(metadata)));
- chance = 200;
- if (fortune > 0)
- {
- chance -= 10 << fortune;
- if (chance < 40) chance = 40;
- }
- this.captureDrops(true);
- this.func_150124_c(world, x, y, z, metadata, chance); // Dammet mojang
- ret.addAll(this.captureDrops(false));
- return ret;
- }
- }
- #Leaf Block Item Class
- package com.doa.item;
- import net.minecraft.block.Block;
- import net.minecraft.item.ItemBlock;
- import net.minecraft.item.ItemStack;
- public class ItemLeafBlocks extends ItemBlock{
- public static final String[] leaves = new String[]{"magic", "shimmer", "glow", "chime", "live", "float", "love", "mystical", "angle", "sun", "chaos", "silent", "rot", "dead", "devil", "doom", "snake", "mold", "flame", "reaper"};
- public ItemLeafBlocks(Block block) {
- super(block);
- this.setHasSubtypes(true);
- }
- public String getUnlocalizedName(ItemStack itemstack){
- int i = itemstack.getItemDamage();
- if(i < 0 || i >= leaves.length){
- i = 0;
- }
- return super.getUnlocalizedName() + "." + leaves[i];
- }
- public int getMetadata(int meta){
- return meta;
- }
- }
Add Comment
Please, Sign In to add comment