Advertisement
Guest User

BlockDenseWaterFluid.class

a guest
Dec 11th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. package com.mystic.dimensionatlantis.blocks.fluids;
  2.  
  3.  
  4. import net.minecraft.block.Block;
  5. import net.minecraft.block.material.MapColor;
  6. import net.minecraft.block.material.Material;
  7. import net.minecraft.block.state.BlockFaceShape;
  8. import net.minecraft.block.state.IBlockState;
  9. import net.minecraft.init.Blocks;
  10. import net.minecraft.util.EnumFacing;
  11. import net.minecraft.util.math.AxisAlignedBB;
  12. import net.minecraft.util.math.BlockPos;
  13. import net.minecraft.world.IBlockAccess;
  14. import net.minecraft.world.World;
  15. import net.minecraftforge.fluids.BlockFluidClassic;
  16. import net.minecraftforge.fluids.Fluid;
  17.  
  18. public class BlockDenseWaterFluid extends BlockFluidClassic
  19. {
  20. public BlockDenseWaterFluid(Fluid fluid)
  21. {
  22. super(fluid, Material.WATER);
  23. this.setLightOpacity(3);
  24. this.setHardness(100.0F);
  25. }
  26.  
  27. @Override
  28. public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
  29. {
  30. return FULL_BLOCK_AABB;
  31. }
  32.  
  33. @Override
  34. public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos)
  35. {
  36. return NULL_AABB;
  37. }
  38.  
  39. @Override
  40. public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
  41. {
  42. super.onBlockAdded(worldIn, pos, state);
  43. this.checkForMixing(worldIn, pos, state);
  44. }
  45.  
  46. @Override
  47. public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos neighborPos)
  48. {
  49. super.neighborChanged(state, worldIn, pos, blockIn, neighborPos);
  50. this.checkForMixing(worldIn, pos, state);
  51. }
  52.  
  53. public boolean checkForMixing(World worldIn, BlockPos pos, IBlockState state)
  54. {
  55. boolean flag = false;
  56.  
  57. for (EnumFacing enumfacing : EnumFacing.values())
  58. {
  59. if (enumfacing != EnumFacing.DOWN && (worldIn.getBlockState(pos.offset(enumfacing)).getMaterial().isLiquid() == true))
  60. {
  61. if (worldIn.getBlockState(pos.offset(enumfacing)).getBlock() != this.getBlockState().getBlock())
  62. {
  63. flag = true;
  64. break;
  65. }
  66. }
  67. }
  68.  
  69. if (flag)
  70. {
  71. Integer integer = state.getValue(LEVEL);
  72.  
  73. if (integer.intValue() == 0)
  74. {
  75. worldIn.setBlockState(pos, Blocks.STONE.getDefaultState());
  76. return true;
  77. }
  78.  
  79. if (integer.intValue() <= 4)
  80. {
  81. worldIn.setBlockState(pos, Blocks.STONE.getDefaultState());
  82. return true;
  83. }
  84. }
  85.  
  86. return false;
  87. }
  88.  
  89. @Override
  90. public MapColor getMapColor(IBlockState state, IBlockAccess world, BlockPos pos)
  91. {
  92. return MapColor.BLUE;
  93. }
  94.  
  95. @Override
  96. public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing facing)
  97. {
  98. return BlockFaceShape.UNDEFINED;
  99. }
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement