Killawulf_Gaming

Dead Or Alive Broken Code

Jul 15th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 19.23 KB | None | 0 0
  1. #Main Leaf Assignment Class
  2.  
  3. package com.doa.biomes.features;
  4.  
  5. import java.util.List;
  6.  
  7. import cpw.mods.fml.relauncher.Side;
  8. import cpw.mods.fml.relauncher.SideOnly;
  9. import net.minecraft.block.BlockLeaves;
  10. import net.minecraft.client.renderer.texture.IIconRegister;
  11. import net.minecraft.creativetab.CreativeTabs;
  12. import net.minecraft.init.Items;
  13. import net.minecraft.item.Item;
  14. import net.minecraft.item.ItemStack;
  15. import net.minecraft.util.IIcon;
  16. import net.minecraft.world.ColorizerFoliage;
  17. import net.minecraft.world.World;
  18.  
  19. public class DOALeaves extends DOALeaf{
  20.    
  21.     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"}};
  22.     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"};
  23.    
  24.     protected void func_150124_c(World world, int par1, int par2, int par3, int par4, int par5)
  25.     {
  26.         if ((par4 & 3) == 0 && world.rand.nextInt(par5) == 0)
  27.         {
  28.             this.dropBlockAsItem(world, par1, par2, par3, new ItemStack(Items.apple, 1, 0));
  29.         }
  30.     }
  31.  
  32.     protected int func_150123_b(int par1)
  33.     {
  34.         int j = super.func_150123_b(par1);
  35.  
  36.         if ((par1 & 3) == 3)
  37.         {
  38.             j = 40;
  39.         }
  40.  
  41.         return j;
  42.     }
  43.  
  44.     /**
  45.      * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
  46.      */
  47.     @SideOnly(Side.CLIENT)
  48.     public void getSubBlocks(Item item, CreativeTabs tabs, List list)
  49.     {
  50.         list.add(new ItemStack(item, 1, 0));
  51.         list.add(new ItemStack(item, 1, 1));
  52.         list.add(new ItemStack(item, 1, 2));
  53.         list.add(new ItemStack(item, 1, 3));
  54.         list.add(new ItemStack(item, 1, 4));
  55.         list.add(new ItemStack(item, 1, 5));
  56.         list.add(new ItemStack(item, 1, 6));
  57.         list.add(new ItemStack(item, 1, 7));
  58.         list.add(new ItemStack(item, 1, 8));
  59.         list.add(new ItemStack(item, 1, 9));
  60.         list.add(new ItemStack(item, 1, 10));
  61.         list.add(new ItemStack(item, 1, 11));
  62.         list.add(new ItemStack(item, 1, 12));
  63.         list.add(new ItemStack(item, 1, 13));
  64.         list.add(new ItemStack(item, 1, 14));
  65.         list.add(new ItemStack(item, 1, 15));
  66.         list.add(new ItemStack(item, 1, 16));
  67.         list.add(new ItemStack(item, 1, 17));
  68.         list.add(new ItemStack(item, 1, 18));
  69.         list.add(new ItemStack(item, 1, 19));
  70.     }
  71.  
  72.     @SideOnly(Side.CLIENT)
  73.     public void registerBlockIcons(IIconRegister iconregister)
  74.     {
  75.         for (int i = 0; i < leaftypes.length; ++i)
  76.         {
  77.             this.field_150129_M[i] = new IIcon[leaftypes[i].length];
  78.  
  79.             for (int j = 0; j < leaftypes[i].length; ++j)
  80.             {
  81.                 this.field_150129_M[i][j] = iconregister.registerIcon("doa:" + leaftypes[i][j]);
  82.             }
  83.         }
  84.     }
  85.  
  86.     public String[] func_150125_e()
  87.     {
  88.         return leaves;
  89.     }
  90.    
  91.     @SideOnly(Side.CLIENT)
  92.     public IIcon getIcon(int side, int meta)
  93.     {
  94.         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]));
  95.     }
  96. }
  97.  
  98.  
  99.  
  100.  
  101. #Edited Version of The Block Leaf Class to remove Biome Colours
  102.  
  103. package com.doa.biomes.features;
  104.  
  105. import java.util.ArrayList;
  106. import java.util.Random;
  107.  
  108. import net.minecraft.block.Block;
  109. import net.minecraft.block.BlockLeavesBase;
  110. import net.minecraft.block.material.Material;
  111. import net.minecraft.entity.player.EntityPlayer;
  112. import net.minecraft.init.Blocks;
  113. import net.minecraft.item.Item;
  114. import net.minecraft.item.ItemStack;
  115. import net.minecraft.util.IIcon;
  116. import net.minecraft.world.ColorizerFoliage;
  117. import net.minecraft.world.IBlockAccess;
  118. import net.minecraft.world.World;
  119. import net.minecraftforge.common.IShearable;
  120.  
  121. import com.doa.main.DOACreativeTabs;
  122.  
  123. import cpw.mods.fml.relauncher.Side;
  124. import cpw.mods.fml.relauncher.SideOnly;
  125.  
  126. public abstract class DOALeaf extends BlockLeavesBase implements IShearable
  127. {
  128.     int[] field_150128_a;
  129.     @SideOnly(Side.CLIENT)
  130.     protected int field_150127_b;
  131.     protected IIcon[][] field_150129_M = new IIcon[2][];
  132.     private static final String __OBFID = "CL_00000263";
  133.  
  134.     public DOALeaf()
  135.     {
  136.         super(Material.leaves, false);
  137.         this.setTickRandomly(true);
  138.         this.setCreativeTab(DOACreativeTabs.tabDOABlocks);
  139.         this.setHardness(0.2F);
  140.         this.setLightOpacity(1);
  141.         this.setStepSound(soundTypeGrass);
  142.     }
  143.  
  144.     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_)
  145.     {
  146.         byte b0 = 1;
  147.         int i1 = b0 + 1;
  148.  
  149.         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))
  150.         {
  151.             for (int j1 = -b0; j1 <= b0; ++j1)
  152.             {
  153.                 for (int k1 = -b0; k1 <= b0; ++k1)
  154.                 {
  155.                     for (int l1 = -b0; l1 <= b0; ++l1)
  156.                     {
  157.                         Block block = p_149749_1_.getBlock(p_149749_2_ + j1, p_149749_3_ + k1, p_149749_4_ + l1);
  158.                         if (block.isLeaves(p_149749_1_, p_149749_2_ + j1, p_149749_3_ + k1, p_149749_4_ + l1))
  159.                         {
  160.                             block.beginLeavesDecay(p_149749_1_, p_149749_2_ + j1, p_149749_3_ + k1, p_149749_4_ + l1);
  161.                         }
  162.                     }
  163.                 }
  164.             }
  165.         }
  166.     }
  167.  
  168.     /**
  169.      * Ticks the block if it's been scheduled
  170.      */
  171.     public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_)
  172.     {
  173.         if (!p_149674_1_.isRemote)
  174.         {
  175.             int l = p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_);
  176.  
  177.             if ((l & 8) != 0 && (l & 4) == 0)
  178.             {
  179.                 byte b0 = 4;
  180.                 int i1 = b0 + 1;
  181.                 byte b1 = 32;
  182.                 int j1 = b1 * b1;
  183.                 int k1 = b1 / 2;
  184.  
  185.                 if (this.field_150128_a == null)
  186.                 {
  187.                     this.field_150128_a = new int[b1 * b1 * b1];
  188.                 }
  189.  
  190.                 int l1;
  191.  
  192.                 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))
  193.                 {
  194.                     int i2;
  195.                     int j2;
  196.  
  197.                     for (l1 = -b0; l1 <= b0; ++l1)
  198.                     {
  199.                         for (i2 = -b0; i2 <= b0; ++i2)
  200.                         {
  201.                             for (j2 = -b0; j2 <= b0; ++j2)
  202.                             {
  203.                                 Block block = p_149674_1_.getBlock(p_149674_2_ + l1, p_149674_3_ + i2, p_149674_4_ + j2);
  204.  
  205.                                 if (!block.canSustainLeaves(p_149674_1_, p_149674_2_ + l1, p_149674_3_ + i2, p_149674_4_ + j2))
  206.                                 {
  207.                                     if (block.isLeaves(p_149674_1_, p_149674_2_ + l1, p_149674_3_ + i2, p_149674_4_ + j2))
  208.                                     {
  209.                                         this.field_150128_a[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -2;
  210.                                     }
  211.                                     else
  212.                                     {
  213.                                         this.field_150128_a[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -1;
  214.                                     }
  215.                                 }
  216.                                 else
  217.                                 {
  218.                                     this.field_150128_a[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = 0;
  219.                                 }
  220.                             }
  221.                         }
  222.                     }
  223.  
  224.                     for (l1 = 1; l1 <= 4; ++l1)
  225.                     {
  226.                         for (i2 = -b0; i2 <= b0; ++i2)
  227.                         {
  228.                             for (j2 = -b0; j2 <= b0; ++j2)
  229.                             {
  230.                                 for (int k2 = -b0; k2 <= b0; ++k2)
  231.                                 {
  232.                                     if (this.field_150128_a[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1] == l1 - 1)
  233.                                     {
  234.                                         if (this.field_150128_a[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2)
  235.                                         {
  236.                                             this.field_150128_a[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1;
  237.                                         }
  238.  
  239.                                         if (this.field_150128_a[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2)
  240.                                         {
  241.                                             this.field_150128_a[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1;
  242.                                         }
  243.  
  244.                                         if (this.field_150128_a[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] == -2)
  245.                                         {
  246.                                             this.field_150128_a[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] = l1;
  247.                                         }
  248.  
  249.                                         if (this.field_150128_a[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] == -2)
  250.                                         {
  251.                                             this.field_150128_a[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] = l1;
  252.                                         }
  253.  
  254.                                         if (this.field_150128_a[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] == -2)
  255.                                         {
  256.                                             this.field_150128_a[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] = l1;
  257.                                         }
  258.  
  259.                                         if (this.field_150128_a[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] == -2)
  260.                                         {
  261.                                             this.field_150128_a[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] = l1;
  262.                                         }
  263.                                     }
  264.                                 }
  265.                             }
  266.                         }
  267.                     }
  268.                 }
  269.  
  270.                 l1 = this.field_150128_a[k1 * j1 + k1 * b1 + k1];
  271.  
  272.                 if (l1 >= 0)
  273.                 {
  274.                     p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, l & -9, 4);
  275.                 }
  276.                 else
  277.                 {
  278.                     this.removeLeaves(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_);
  279.                 }
  280.             }
  281.         }
  282.     }
  283.  
  284.     /**
  285.      * A randomly called display update to be able to add particles or other items for display
  286.      */
  287.     @SideOnly(Side.CLIENT)
  288.     public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_)
  289.     {
  290.         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)
  291.         {
  292.             double d0 = (double)((float)p_149734_2_ + p_149734_5_.nextFloat());
  293.             double d1 = (double)p_149734_3_ - 0.05D;
  294.             double d2 = (double)((float)p_149734_4_ + p_149734_5_.nextFloat());
  295.             p_149734_1_.spawnParticle("dripWater", d0, d1, d2, 0.0D, 0.0D, 0.0D);
  296.         }
  297.     }
  298.  
  299.     private void removeLeaves(World p_150126_1_, int p_150126_2_, int p_150126_3_, int p_150126_4_)
  300.     {
  301.         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);
  302.         p_150126_1_.setBlockToAir(p_150126_2_, p_150126_3_, p_150126_4_);
  303.     }
  304.  
  305.     /**
  306.      * Returns the quantity of items to drop on block destruction.
  307.      */
  308.     public int quantityDropped(Random p_149745_1_)
  309.     {
  310.         return p_149745_1_.nextInt(20) == 0 ? 1 : 0;
  311.     }
  312.  
  313.     public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
  314.     {
  315.         return Item.getItemFromBlock(Blocks.sapling);
  316.     }
  317.  
  318.     /**
  319.      * Drops the block items with a specified chance of dropping the specified items
  320.      */
  321.     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_)
  322.     {
  323.         super.dropBlockAsItemWithChance(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, 1.0f, p_149690_7_);
  324.     }
  325.  
  326.     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_) {}
  327.  
  328.     protected int func_150123_b(int p_150123_1_)
  329.     {
  330.         return 20;
  331.     }
  332.  
  333.     /**
  334.      * Called when the player destroys a block with an item that can harvest it. (i, j, k) are the coordinates of the
  335.      * block and l is the block's subtype/damage.
  336.      */
  337.     public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int block)
  338.     {
  339.         {
  340.             super.harvestBlock(world, player, x, y, z, block);
  341.         }
  342.     }
  343.  
  344.     /**
  345.      * Determines the damage on the item the block drops. Used in cloth and wood.
  346.      */
  347.     public int damageDropped(int meta)
  348.     {
  349.         return meta & 3;
  350.     }
  351.  
  352.     /**
  353.      * Is this block (a) opaque and (b) a full 1m cube?  This determines whether or not to render the shared face of two
  354.      * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
  355.      */
  356.     public boolean isOpaqueCube()
  357.     {
  358.         return false;
  359.     }
  360.  
  361.     /**
  362.      * Gets the block's texture. Args: side, meta
  363.      */
  364.     @SideOnly(Side.CLIENT)
  365.     public abstract IIcon getIcon(int side, int meta);
  366.  
  367.     /**
  368.      * Pass true to draw this block using fancy graphics, or false for fast graphics.
  369.      */
  370.     @SideOnly(Side.CLIENT)
  371.     public void setGraphicsLevel(boolean bool1)
  372.     {
  373.         this.field_150121_P = bool1;
  374.         this.field_150127_b = bool1 ? 0 : 1;
  375.     }
  376.  
  377.     /**
  378.      * Returns an item stack containing a single instance of the current block type. 'i' is the block's subtype/damage
  379.      * and is ignored for blocks which do not support subtypes. Blocks which cannot be harvested should return null.
  380.      */
  381.     protected ItemStack createStackedBlock(int block)
  382.     {
  383.         return new ItemStack(Item.getItemFromBlock(this), 1, block & 3);
  384.     }
  385.  
  386.     public abstract String[] func_150125_e();
  387.  
  388.  
  389.     @Override
  390.     public boolean isShearable(ItemStack item, IBlockAccess world, int x, int y, int z)
  391.     {
  392.         return true;
  393.     }
  394.  
  395.     @Override
  396.     public ArrayList<ItemStack> onSheared(ItemStack item, IBlockAccess world, int x, int y, int z, int fortune)
  397.     {
  398.         ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
  399.         ret.add(new ItemStack(this, 1, world.getBlockMetadata(x, y, z) & 3));
  400.         return ret;
  401.     }
  402.  
  403.     @Override
  404.     public void beginLeavesDecay(World world, int x, int y, int z)
  405.     {
  406.  
  407.         int i2 = world.getBlockMetadata(x, y, z);
  408.  
  409.         if ((i2 & 8) == 0)
  410.         {
  411.             world.setBlockMetadataWithNotify(x, y, z, i2 | 8, 4);
  412.         }
  413.         world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) | 8, 4);
  414.     }
  415.  
  416.     @Override
  417.     public boolean isLeaves(IBlockAccess world, int x, int y, int z)
  418.     {
  419.         return true;
  420.     }
  421.  
  422.  
  423.     @Override
  424.     public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune)
  425.     {
  426.         ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
  427.         int chance = this.func_150123_b(metadata);
  428.  
  429.         if (fortune > 0)
  430.         {
  431.             chance -= 2 << fortune;
  432.             if (chance < 10) chance = 10;
  433.         }
  434.  
  435.         if (world.rand.nextInt(chance) == 0)
  436.             ret.add(new ItemStack(this.getItemDropped(metadata, world.rand, fortune), 1, this.damageDropped(metadata)));
  437.  
  438.         chance = 200;
  439.         if (fortune > 0)
  440.         {
  441.             chance -= 10 << fortune;
  442.             if (chance < 40) chance = 40;
  443.         }
  444.  
  445.         this.captureDrops(true);
  446.         this.func_150124_c(world, x, y, z, metadata, chance); // Dammet mojang
  447.         ret.addAll(this.captureDrops(false));
  448.         return ret;
  449.     }
  450. }
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463. #Leaf Block Item Class
  464. package com.doa.item;
  465.  
  466. import net.minecraft.block.Block;
  467. import net.minecraft.item.ItemBlock;
  468. import net.minecraft.item.ItemStack;
  469.  
  470. public class ItemLeafBlocks extends ItemBlock{
  471.    
  472.     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"};
  473.  
  474.     public ItemLeafBlocks(Block block) {
  475.         super(block);
  476.         this.setHasSubtypes(true);
  477.     }
  478.    
  479.     public String getUnlocalizedName(ItemStack itemstack){
  480.         int i = itemstack.getItemDamage();
  481.         if(i < 0 || i >= leaves.length){
  482.             i = 0;
  483.         }
  484.        
  485.         return super.getUnlocalizedName() + "." + leaves[i];
  486.     }
  487.    
  488.     public int getMetadata(int meta){
  489.         return meta;
  490.     }
  491. }
Add Comment
Please, Sign In to add comment