Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. package mreyeballs29.issactncore.block;
  2.  
  3. import java.util.Random;
  4.  
  5. import mreyeballs29.issactncore.init.I29CBlocks;
  6.  
  7. import net.minecraft.block.Block;
  8.  
  9. import net.minecraft.block.BlockFalling;
  10.  
  11. import net.minecraft.block.SoundType;
  12.  
  13. import net.minecraft.block.material.Material;
  14.  
  15. import net.minecraft.block.state.IBlockState;
  16.  
  17. import net.minecraft.init.Items;
  18.  
  19. import net.minecraft.item.Item;
  20.  
  21. import net.minecraft.util.EnumFacing;
  22.  
  23. import net.minecraft.util.math.BlockPos;
  24.  
  25. import net.minecraft.world.World;
  26.  
  27. public class BlockPlainConcretePowder extends BlockFalling {
  28.  
  29. private Item item;
  30.  
  31. public BlockPlainConcretePowder(Item concretePowder) {
  32.  
  33. item = concretePowder;
  34.  
  35. setSoundType(SoundType.SAND);
  36.  
  37. }
  38.  
  39.  
  40.  
  41. @Override
  42.  
  43. public Item getItemDropped(IBlockState state, Random rand, int fortune) {
  44.  
  45. return item != null ? item.delegate.get() : Items.AIR;
  46.  
  47. }
  48.  
  49.  
  50.  
  51. /**
  52.  
  53. * @param state
  54.  
  55. */
  56.  
  57. protected boolean tryTouchWater(World worldIn, BlockPos pos, IBlockState state)
  58.  
  59. {
  60.  
  61. boolean flag = false;
  62.  
  63. for (EnumFacing enumfacing : EnumFacing.values())
  64.  
  65. {
  66.  
  67. if (enumfacing != EnumFacing.DOWN)
  68.  
  69. {
  70.  
  71. BlockPos blockpos = pos.offset(enumfacing);
  72.  
  73. if (worldIn.getBlockState(blockpos).getMaterial() == Material.WATER)
  74.  
  75. {
  76.  
  77. flag = true;
  78.  
  79. break;
  80.  
  81. }
  82.  
  83. }
  84.  
  85. }
  86.  
  87. if (flag)
  88.  
  89. {
  90.  
  91. worldIn.setBlockState(pos, I29CBlocks.CONCRETE.getDefaultState(), 3);
  92.  
  93. }
  94.  
  95. return flag;
  96.  
  97. }
  98.  
  99.  
  100.  
  101. public void onEndFalling(World worldIn, BlockPos pos, IBlockState p_176502_3_, IBlockState p_176502_4_)
  102.  
  103. {
  104.  
  105. if (p_176502_4_.getMaterial().isLiquid())
  106.  
  107. {
  108.  
  109. worldIn.setBlockState(pos, I29CBlocks.CONCRETE.getDefaultState(), 3);
  110.  
  111. }
  112.  
  113. }
  114.  
  115.  
  116.  
  117. public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
  118.  
  119. {
  120.  
  121. if (!this.tryTouchWater(worldIn, pos, state))
  122.  
  123. {
  124.  
  125. super.onBlockAdded(worldIn, pos, state);
  126.  
  127. }
  128.  
  129. }
  130.  
  131.  
  132.  
  133. public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos)
  134.  
  135. {
  136.  
  137. if (!this.tryTouchWater(worldIn, pos, state))
  138.  
  139. {
  140.  
  141. super.neighborChanged(state, worldIn, pos, blockIn, fromPos);
  142.  
  143. }
  144.  
  145. }
  146.  
  147.  
  148.  
  149. @Override
  150.  
  151. public int getDustColor(IBlockState state) {
  152.  
  153. return 0xCDC9B2;
  154.  
  155. }
  156.  
  157. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement