Advertisement
MrCyberdragon

Untitled

Mar 9th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. public class BlockWispFlame extends Block implements ITileEntityProvider {
  2.  
  3. Random random = new Random();
  4.  
  5. public static final PropertyInteger COLOR = PropertyInteger.create("color", 0, 4);
  6.  
  7. public BlockWispFlame(String name, Material material){
  8. super(material);
  9. this.setDefaultState(this.blockState.getBaseState().withProperty(COLOR, Integer.valueOf(0)));
  10. float light = random.nextFloat() * (0.7F - 0.4F) + 0.4F;
  11. this.setLightLevel(light);
  12. setUnlocalizedName(name);
  13. setRegistryName(name);
  14. this.setLightOpacity(0);
  15.  
  16. ModBlocks.BLOCKS.add(this);
  17. ModItems.ITEMS.add(new ItemBlock(this).setRegistryName(this.getRegistryName()));
  18. }
  19.  
  20. @Override
  21. protected BlockStateContainer createBlockState(){
  22. return new BlockStateContainer(this, new IProperty[] {COLOR});
  23. }
  24.  
  25. @Override
  26. public int getMetaFromState(IBlockState state){
  27. return state.getValue(COLOR);
  28. }
  29.  
  30. @Override
  31. public IBlockState getStateFromMeta(int meta){
  32. return this.getDefaultState().withProperty(COLOR, meta);
  33. }
  34.  
  35. @Override
  36. public TileEntity createNewTileEntity(World worldIn, int meta) {
  37. return new TileEntityWispFlame();
  38. }
  39.  
  40. @Override
  41. public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos)
  42. {
  43. return null;
  44. }
  45.  
  46. @SideOnly(Side.CLIENT)
  47. public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand){
  48. double height = random.nextFloat() * (0.7F - 0.4F) + 0.4F;
  49. int color = stateIn.getValue(COLOR);
  50. switch(color) {
  51. case 0:
  52. worldIn.spawnParticle(EnumParticleTypes.FLAME, pos.getX() + 0.5D, pos.getY() + height, pos.getZ() + 0.5D, 0, 0, 0);
  53. break;
  54. case 1:
  55. Particles.BLUE_FLAME.spawn(worldIn,pos.getX()+0.5D, pos.getY() + height, pos.getZ()+0.5D, 0, 0, 0);
  56. break;
  57. case 2:
  58. Particles.RED_FLAME.spawn(worldIn,pos.getX()+0.5D, pos.getY() + height, pos.getZ()+0.5D, 0, 0, 0);
  59. break;
  60. case 3:
  61. Particles.GREEN_FLAME.spawn(worldIn,pos.getX()+0.5D, pos.getY() + height, pos.getZ()+0.5D, 0, 0, 0);
  62. break;
  63. case 4:
  64. Particles.PURPLE_FLAME.spawn(worldIn,pos.getX()+0.5D, pos.getY() + height, pos.getZ()+0.5D, 0, 0, 0);
  65. }
  66. }
  67.  
  68. @Override
  69. public boolean isCollidable() {
  70. return false;
  71. }
  72.  
  73. @Override
  74. public boolean isOpaqueCube(IBlockState state) {
  75. return false;
  76. }
  77.  
  78. @Override
  79. public BlockRenderLayer getBlockLayer() {
  80. return BlockRenderLayer.TRANSLUCENT;
  81. }
  82.  
  83. @Override
  84. public boolean isReplaceable(IBlockAccess worldIn, BlockPos pos) {
  85. return true;
  86. }
  87.  
  88. @Override
  89. @SideOnly(Side.CLIENT)
  90. public int getPackedLightmapCoords(IBlockState state, IBlockAccess source, BlockPos pos)
  91. {
  92. return 15728880;
  93. }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement