Advertisement
SpazzMods

BlockShinySapling.java

Jul 19th, 2016
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.23 KB | None | 0 0
  1.  
  2. import net.minecraft.block.Block;
  3. import net.minecraft.block.BlockLeaves;
  4. import net.minecraft.block.BlockOldLeaf;
  5. import net.minecraft.block.BlockOldLog;
  6. import net.minecraft.block.BlockPlanks;
  7. import net.minecraft.block.BlockSapling;
  8. import net.minecraft.block.IGrowable;
  9. import net.minecraft.block.material.Material;
  10. import net.minecraft.block.properties.PropertyEnum;
  11. import net.minecraft.block.properties.PropertyInteger;
  12. import net.minecraft.block.state.IBlockState;
  13. import net.minecraft.init.Blocks;
  14. import net.minecraft.util.math.BlockPos;
  15. import net.minecraft.world.World;
  16. import net.minecraft.world.gen.feature.WorldGenBigTree;
  17. import net.minecraft.world.gen.feature.WorldGenBirchTree;
  18. import net.minecraft.world.gen.feature.WorldGenCanopyTree;
  19. import net.minecraft.world.gen.feature.WorldGenMegaJungle;
  20. import net.minecraft.world.gen.feature.WorldGenMegaPineTree;
  21. import net.minecraft.world.gen.feature.WorldGenSavannaTree;
  22. import net.minecraft.world.gen.feature.WorldGenTaiga2;
  23. import net.minecraft.world.gen.feature.WorldGenTrees;
  24. import net.minecraft.world.gen.feature.WorldGenerator;
  25.  
  26. public class BlockShinySapling extends BlockSapling {
  27.  
  28. public static final PropertyEnum<BlockPlanks.EnumType> TYPE = PropertyEnum.<BlockPlanks.EnumType>create("type", BlockPlanks.EnumType.class);
  29. public static final PropertyInteger STAGE = PropertyInteger.create("stage", 0, 1);
  30.  
  31.  
  32. public BlockShinySapling() {
  33. setUnlocalizedName(Reference.GloriousBlocks.SHINY_SAPPLING.getUnlocalizedName());
  34. setRegistryName(Reference.GloriousBlocks.SHINY_SAPPLING.getRegistryName());
  35.  
  36. }
  37.  
  38. @Override
  39. public void generateTree(World worldIn, BlockPos pos, IBlockState state, Random rand) {
  40. if (!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(worldIn, rand, pos))
  41. return;
  42. WorldGenerator worldgenerator = (WorldGenerator) (rand.nextInt(10) == 0 ? new WorldGenBigTree(true)
  43. : new WorldGenTrees(true));
  44. int i = 0;
  45. int j = 0;
  46. boolean flag = false;
  47.  
  48. switch ((BlockPlanks.EnumType) state.getValue(TYPE)) {
  49. case SPRUCE:
  50. label114:
  51.  
  52. for (i = 0; i >= -1; --i) {
  53. for (j = 0; j >= -1; --j) {
  54. if (this.IsTwoByTwoOfType(worldIn, pos, i, j, BlockPlanks.EnumType.SPRUCE)) {
  55. worldgenerator = new WorldGenMegaPineTree(false, rand.nextBoolean());
  56. flag = true;
  57. break label114;
  58. }
  59. }
  60. }
  61.  
  62. if (!flag) {
  63. i = 0;
  64. j = 0;
  65. worldgenerator = new WorldGenTaiga2(true);
  66. }
  67.  
  68. break;
  69. case BIRCH:
  70. worldgenerator = new WorldGenBirchTree(true, false);
  71. break;
  72. case JUNGLE:
  73. IBlockState iblockstate = Blocks.LOG.getDefaultState().withProperty(BlockOldLog.VARIANT,
  74. BlockPlanks.EnumType.JUNGLE);
  75. IBlockState iblockstate1 = Blocks.LEAVES.getDefaultState()
  76. .withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.JUNGLE)
  77. .withProperty(BlockLeaves.CHECK_DECAY, Boolean.valueOf(false));
  78. label269:
  79.  
  80. for (i = 0; i >= -1; --i) {
  81. for (j = 0; j >= -1; --j) {
  82. if (this.IsTwoByTwoOfType(worldIn, pos, i, j, BlockPlanks.EnumType.JUNGLE)) {
  83. worldgenerator = new WorldGenMegaJungle(true, 10, 20, iblockstate, iblockstate1);
  84. flag = true;
  85. break label269;
  86. }
  87. }
  88. }
  89.  
  90. if (!flag) {
  91. i = 0;
  92. j = 0;
  93. worldgenerator = new WorldGenTrees(true, 4 + rand.nextInt(7), iblockstate, iblockstate1, false);
  94. }
  95.  
  96. break;
  97. case ACACIA:
  98. worldgenerator = new WorldGenSavannaTree(true);
  99. break;
  100. case DARK_OAK:
  101. label390:
  102.  
  103. for (i = 0; i >= -1; --i) {
  104. for (j = 0; j >= -1; --j) {
  105. if (this.IsTwoByTwoOfType(worldIn, pos, i, j, BlockPlanks.EnumType.DARK_OAK)) {
  106. worldgenerator = new WorldGenCanopyTree(true);
  107. flag = true;
  108. break label390;
  109. }
  110. }
  111. }
  112.  
  113. if (!flag) {
  114. return;
  115. }
  116.  
  117. case OAK:
  118. }
  119. }
  120.  
  121. private boolean IsTwoByTwoOfType(World worldIn, BlockPos pos, int p_181624_3_, int p_181624_4_,
  122. BlockPlanks.EnumType type) {
  123. return this.isTypeAt(worldIn, pos.add(p_181624_3_, 0, p_181624_4_), type)
  124. && this.isTypeAt(worldIn, pos.add(p_181624_3_ + 1, 0, p_181624_4_), type)
  125. && this.isTypeAt(worldIn, pos.add(p_181624_3_, 0, p_181624_4_ + 1), type)
  126. && this.isTypeAt(worldIn, pos.add(p_181624_3_ + 1, 0, p_181624_4_ + 1), type);
  127. }
  128.  
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement