Advertisement
MrCyberdragon

Untitled

Nov 13th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.94 KB | None | 0 0
  1. package com.mrcyberdragon.lightthenight.blocks;
  2.  
  3. import com.mrcyberdragon.lightthenight.Main;
  4. import com.mrcyberdragon.lightthenight.init.ModBlocks;
  5. import com.mrcyberdragon.lightthenight.init.ModItems;
  6. import com.mrcyberdragon.lightthenight.util.IHasModel;
  7. import net.minecraft.block.Block;
  8. import net.minecraft.block.SoundType;
  9. import net.minecraft.block.material.Material;
  10. import net.minecraft.block.state.IBlockState;
  11. import net.minecraft.client.resources.I18n;
  12. import net.minecraft.client.util.ITooltipFlag;
  13. import net.minecraft.creativetab.CreativeTabs;
  14. import net.minecraft.init.Blocks;
  15. import net.minecraft.item.Item;
  16. import net.minecraft.item.ItemBlock;
  17. import net.minecraft.item.ItemStack;
  18. import net.minecraft.util.EnumParticleTypes;
  19. import net.minecraft.util.math.BlockPos;
  20. import net.minecraft.world.World;
  21. import net.minecraftforge.fml.relauncher.Side;
  22. import net.minecraftforge.fml.relauncher.SideOnly;
  23.  
  24. import javax.annotation.Nullable;
  25. import java.util.List;
  26. import java.util.Random;
  27.  
  28. public class BlockSwampMud extends Block implements IHasModel {
  29.  
  30. public BlockSwampMud(String name, Material material){
  31. super(material);
  32. setUnlocalizedName(name);
  33. setRegistryName(name);
  34. setCreativeTab(CreativeTabs.DECORATIONS);
  35. this.setSoundType(SoundType.GROUND);
  36. this.setTickRandomly(true);
  37.  
  38. ModBlocks.BLOCKS.add(this);
  39. ModItems.ITEMS.add(new ItemBlock(this).setRegistryName(this.getRegistryName()));
  40. }
  41.  
  42. @Override
  43. public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> list, ITooltipFlag flagIn)
  44. {
  45. list.add(I18n.format("Bubbles under water and produces colored flames at night"));
  46. }
  47.  
  48. @Override
  49. public int tickRate(World worldIn) {
  50. return 0;
  51. }
  52.  
  53. public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
  54. super.updateTick(worldIn, pos, state, rand);
  55. if (worldIn.getWorldTime() > 13000) {
  56. if (worldIn.getBlockState(new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ())).getBlock() == Blocks.WATER && (worldIn.getBlockState(new BlockPos(pos.getX(), pos.getY() + 2, pos.getZ())).getBlock() == Blocks.AIR||worldIn.getBlockState(new BlockPos(pos.getX(), pos.getY() + 2, pos.getZ())).getBlock() == Blocks.WATER)) {
  57. if (worldIn.getBlockState(new BlockPos(pos.getX(), pos.getY() + 3, pos.getZ())).getBlock() == Blocks.AIR) {
  58. worldIn.setBlockState(new BlockPos(pos.getX(), pos.getY() + 3, pos.getZ()), ModBlocks.WISP_FLAME.getDefaultState());
  59. }
  60. } else {
  61. if (worldIn.getBlockState(new BlockPos(pos.getX(), pos.getY() + 3, pos.getZ())).getBlock() == ModBlocks.WISP_FLAME) {
  62. worldIn.setBlockToAir(new BlockPos(pos.getX(), pos.getY() + 3, pos.getZ()));
  63. }
  64. }
  65. } else {
  66. if (worldIn.getBlockState(new BlockPos(pos.getX(), pos.getY() + 3, pos.getZ())).getBlock() == ModBlocks.WISP_FLAME) {
  67. worldIn.setBlockToAir(new BlockPos(pos.getX(), pos.getY() + 3, pos.getZ()));
  68. }
  69. }
  70. }
  71.  
  72. @Override
  73. public void registerModels() {
  74. Main.proxy.registerItemRenderer(Item.getItemFromBlock(this), 0, "inventory");
  75. }
  76.  
  77. @SideOnly(Side.CLIENT)
  78. public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand){
  79. if(worldIn.getBlockState(new BlockPos(pos.getX(), pos.getY()+1, pos.getZ())).getBlock()==Blocks.WATER){
  80. double e0 = rand.nextInt(10)/10.0D;
  81. double e1 = rand.nextInt(10)/10.0D;
  82. double e2 = rand.nextInt(5)/10.0D;
  83. double d0 = (double)pos.getX() + e0;
  84. double d1 = (double)pos.getY() + 1;
  85. double d2 = (double)pos.getZ() + e1;
  86. double d3 = e2;
  87. worldIn.spawnParticle(EnumParticleTypes.WATER_BUBBLE, d0, d1, d2, 0, d3, 0);
  88. }
  89. }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement