Advertisement
Guest User

Blood Light

a guest
Nov 15th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.00 KB | None | 0 0
  1. package WayofTime.bloodmagic.block;
  2.  
  3. import java.util.List;
  4. import java.util.Random;
  5.  
  6. import net.minecraft.block.Block;
  7. import net.minecraft.block.material.Material;
  8. import net.minecraft.block.state.IBlockState;
  9. import net.minecraft.client.Minecraft;
  10. import net.minecraft.client.entity.EntityPlayerSP;
  11. import net.minecraft.client.particle.ParticleManager;
  12. import net.minecraft.entity.Entity;
  13. import net.minecraft.util.BlockRenderLayer;
  14. import net.minecraft.util.EnumParticleTypes;
  15. import net.minecraft.util.math.AxisAlignedBB;
  16. import net.minecraft.util.math.BlockPos;
  17. import net.minecraft.world.IBlockAccess;
  18. import net.minecraft.world.World;
  19. import net.minecraftforge.fml.relauncher.Side;
  20. import net.minecraftforge.fml.relauncher.SideOnly;
  21. import WayofTime.bloodmagic.api.Constants;
  22. import WayofTime.bloodmagic.registry.ModItems;
  23.  
  24. public class BlockBloodLight extends Block
  25. {
  26. protected static final AxisAlignedBB AABB = new AxisAlignedBB(0.4, 0.4, 0.4, 0.6, 0.6, 0.6);
  27.  
  28. public BlockBloodLight()
  29. {
  30. super(Material.CLOTH);
  31.  
  32. setUnlocalizedName(Constants.Mod.MODID + ".bloodLight");
  33. }
  34.  
  35. @Override
  36. public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity)
  37. {
  38.  
  39. }
  40.  
  41. @Override
  42. public boolean isReplaceable(IBlockAccess world, BlockPos pos)
  43. {
  44. return true;
  45. }
  46.  
  47. @Override
  48. @SideOnly(Side.CLIENT)
  49. public BlockRenderLayer getBlockLayer()
  50. {
  51. return BlockRenderLayer.CUTOUT;
  52. }
  53.  
  54. @Override
  55. public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos)
  56. {
  57. return false;
  58. }
  59.  
  60. @Override
  61. public boolean isOpaqueCube(IBlockState state)
  62. {
  63. return false;
  64. }
  65.  
  66. @Override
  67. public boolean isFullCube(IBlockState state)
  68. {
  69. return false;
  70. }
  71.  
  72. @Override
  73. public boolean causesSuffocation()
  74. {
  75. return false;
  76. }
  77.  
  78. @Override
  79. public int getLightValue(IBlockState state)
  80. {
  81. return 15;
  82. }
  83.  
  84. @Override
  85. @SideOnly(Side.CLIENT)
  86. public boolean addDestroyEffects(World world, BlockPos pos, ParticleManager particleManager)
  87. {
  88. if (world.getBlockState(pos).getBlock() == this)
  89. {
  90. Random random = new Random();
  91. particleManager.spawnEffectParticle(EnumParticleTypes.REDSTONE.getParticleID(), pos.getX() + 0.5D + random.nextGaussian() / 8, pos.getY() + 0.5D, pos.getZ() + 0.5D + random.nextGaussian() / 8, 0, 0, 0);
  92. }
  93. return true;
  94. }
  95.  
  96. @Override
  97. @SideOnly(Side.CLIENT)
  98. public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand)
  99. {
  100. EntityPlayerSP playerSP = Minecraft.getMinecraft().player;
  101.  
  102. if (rand.nextInt(3) != 0)
  103. {
  104. world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5D + rand.nextGaussian() / 8, pos.getY() + 0.5D, pos.getZ() + 0.5D + rand.nextGaussian() / 8, 0, 0, 0, 0);
  105. if (playerSP.getActiveItemStack() != null && playerSP.getActiveItemStack().getItem() == ModItems.SIGIL_BLOOD_LIGHT)
  106. {
  107. world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5D + rand.nextGaussian() / 8, pos.getY() + 0.5D, pos.getZ() + 0.5D + rand.nextGaussian() / 8, 0, 0, 0, 0);
  108. world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5D + rand.nextGaussian() / 8, pos.getY() + 0.5D, pos.getZ() + 0.5D + rand.nextGaussian() / 8, 0, 0, 0, 0);
  109. world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5D + rand.nextGaussian() / 8, pos.getY() + 0.5D, pos.getZ() + 0.5D + rand.nextGaussian() / 8, 0, 0, 0, 0);
  110. }
  111. }
  112. }
  113.  
  114. @Override
  115. public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
  116. {
  117. return AABB;
  118. }
  119.  
  120. @Override
  121. public int quantityDropped(Random par1Random)
  122. {
  123. return 0;
  124. }
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement