Advertisement
Guest User

LoopsAndLogic

a guest
Jul 23rd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. public class BlockLogic {
  2. @SubscribeEvent
  3. public void checkBreak(BreakEvent event) {
  4.  
  5. //Part A
  6. event.getPlayer().sendMessage(new TextComponentString(TextFormatting.BOLD + event.getState().toString()));
  7.  
  8. //Part B
  9. BlockPos position = event.getPos();
  10. if (position.getX() < 0) {
  11. event.getPlayer().sendMessage(new TextComponentString(TextFormatting.RED + event.getState().toString()));
  12. }
  13. else if (position.getX() > 50) {
  14. event.getPlayer().sendMessage(new TextComponentString(TextFormatting.BLUE + event.getState().toString()));
  15. }
  16. else {
  17. event.getPlayer().sendMessage(new TextComponentString(TextFormatting.GREEN + event.getState().toString()));
  18. }
  19.  
  20. //Part C
  21. if (event.getState().equals(Blocks.GRASS.getDefaultState())) {
  22. event.getPlayer().sendMessage(new TextComponentString(TextFormatting.GREEN + event.getState().toString()));
  23. }
  24. else if (event.getState().equals(Blocks.DIRT.getDefaultState())) {
  25. event.getPlayer().sendMessage(new TextComponentString(TextFormatting.RED + event.getState().toString()));
  26. }
  27.  
  28. //Part D
  29. int duration = 90;
  30. PotionEffect effect = new PotionEffect(Potion.getPotionById(10), duration * 20, 1); // Arguments: Potion, duration, amplitude (power)
  31. event.getPlayer().addPotionEffect(effect);
  32.  
  33. //Part E
  34. int duration = 90;
  35. if (event.getState().equals(Blocks.SAND.getDefaultState())) {
  36. event.getPlayer().sendMessage(new TextComponentString("A sand block was broken releasing its regenerative powers!"));
  37. // The duration is multiplied by twenty to convert from ticks into seconds (20 ticks per second)
  38. PotionEffect effect = new PotionEffect(Potion.getPotionById(10), duration * 20, 1); // Arguments: Potion, duration, amplitude (power)
  39. event.getPlayer().addPotionEffect(effect);
  40. }
  41.  
  42. //Part F
  43. PotionEffect effect1 = new PotionEffect(Potion.getPotionById(3), 90 * 20, 3);
  44. PotionEffect effect2 = new PotionEffect(Potion.getPotionById(7), 10, 1);
  45. PotionEffect effect3 = new PotionEffect(Potion.getPotionById(14), 30 * 20, 2);
  46. if (event.getState().equals(Blocks.SAND.getDefaultState())) {
  47. event.getPlayer().sendMessage(new TextComponentString(TextFormatting.YELLOW + "A sand block was broken..."));
  48. event.getPlayer().addPotionEffect(effect1);
  49. }
  50. else if (event.getState().equals(Blocks.GRASS.getDefaultState())) {
  51. event.getPlayer().sendMessage(new TextComponentString(TextFormatting.GREEN + "A grass block was broken..."));
  52. event.getPlayer().addPotionEffect(effect2);
  53. }
  54. else if (!event.getState().equals(Blocks.DIRT.getDefaultState())) {
  55. event.getPlayer().sendMessage(new TextComponentString(TextFormatting.YELLOW + "Something other than dirt was broken..."));
  56. event.getPlayer().addPotionEffect(effect3);
  57. }
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement