Advertisement
MrCyberdragon

Untitled

Nov 29th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. package com.mrcyberdragon.lightthenight.tileentities;
  2.  
  3. import com.mrcyberdragon.lightthenight.init.ModBlocks;
  4. import net.minecraft.init.Blocks;
  5. import net.minecraft.tileentity.TileEntity;
  6. import net.minecraft.util.ITickable;
  7. import net.minecraft.util.math.BlockPos;
  8. import net.minecraft.world.World;
  9.  
  10. import java.util.Random;
  11.  
  12. public class TileEntityMudBlock extends TileEntity implements ITickable {
  13.  
  14. @Override
  15. public void update() {
  16. World worldIn = getWorld();
  17. Random random = new Random();
  18. BlockPos pos = this.getPos();
  19. if (worldIn.getWorldTime() > 13000) {
  20. 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)) {
  21. if (worldIn.getBlockState(new BlockPos(pos.getX(), pos.getY() + 3, pos.getZ())).getBlock() == Blocks.AIR) {
  22. if(random.nextInt(100)==1)worldIn.setBlockState(new BlockPos(pos.getX(), pos.getY() + 3, pos.getZ()), ModBlocks.WISP_FLAME.getDefaultState());
  23. }
  24. } else {
  25. if (worldIn.getBlockState(new BlockPos(pos.getX(), pos.getY() + 3, pos.getZ())).getBlock() == ModBlocks.WISP_FLAME) {
  26. worldIn.setBlockToAir(new BlockPos(pos.getX(), pos.getY() + 3, pos.getZ()));
  27. }
  28. }
  29. } else {
  30. if (worldIn.getBlockState(new BlockPos(pos.getX(), pos.getY() + 3, pos.getZ())).getBlock() == ModBlocks.WISP_FLAME) {
  31. worldIn.setBlockToAir(new BlockPos(pos.getX(), pos.getY() + 3, pos.getZ()));
  32. }
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement