Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class BlockLogic {
- @SubscribeEvent
- public void checkBreak(BreakEvent event) {
- //Part A
- event.getPlayer().sendMessage(new TextComponentString(TextFormatting.BOLD + event.getState().toString()));
- //Part B
- BlockPos position = event.getPos();
- if (position.getX() < 0) {
- event.getPlayer().sendMessage(new TextComponentString(TextFormatting.RED + event.getState().toString()));
- }
- else if (position.getX() > 50) {
- event.getPlayer().sendMessage(new TextComponentString(TextFormatting.BLUE + event.getState().toString()));
- }
- else {
- event.getPlayer().sendMessage(new TextComponentString(TextFormatting.GREEN + event.getState().toString()));
- }
- //Part C
- if (event.getState().equals(Blocks.GRASS.getDefaultState())) {
- event.getPlayer().sendMessage(new TextComponentString(TextFormatting.GREEN + event.getState().toString()));
- }
- else if (event.getState().equals(Blocks.DIRT.getDefaultState())) {
- event.getPlayer().sendMessage(new TextComponentString(TextFormatting.RED + event.getState().toString()));
- }
- //Part D
- int duration = 90;
- PotionEffect effect = new PotionEffect(Potion.getPotionById(10), duration * 20, 1); // Arguments: Potion, duration, amplitude (power)
- event.getPlayer().addPotionEffect(effect);
- //Part E
- int duration = 90;
- if (event.getState().equals(Blocks.SAND.getDefaultState())) {
- event.getPlayer().sendMessage(new TextComponentString("A sand block was broken releasing its regenerative powers!"));
- // The duration is multiplied by twenty to convert from ticks into seconds (20 ticks per second)
- PotionEffect effect = new PotionEffect(Potion.getPotionById(10), duration * 20, 1); // Arguments: Potion, duration, amplitude (power)
- event.getPlayer().addPotionEffect(effect);
- }
- //Part F
- PotionEffect effect1 = new PotionEffect(Potion.getPotionById(3), 90 * 20, 3);
- PotionEffect effect2 = new PotionEffect(Potion.getPotionById(7), 10, 1);
- PotionEffect effect3 = new PotionEffect(Potion.getPotionById(14), 30 * 20, 2);
- if (event.getState().equals(Blocks.SAND.getDefaultState())) {
- event.getPlayer().sendMessage(new TextComponentString(TextFormatting.YELLOW + "A sand block was broken..."));
- event.getPlayer().addPotionEffect(effect1);
- }
- else if (event.getState().equals(Blocks.GRASS.getDefaultState())) {
- event.getPlayer().sendMessage(new TextComponentString(TextFormatting.GREEN + "A grass block was broken..."));
- event.getPlayer().addPotionEffect(effect2);
- }
- else if (!event.getState().equals(Blocks.DIRT.getDefaultState())) {
- event.getPlayer().sendMessage(new TextComponentString(TextFormatting.YELLOW + "Something other than dirt was broken..."));
- event.getPlayer().addPotionEffect(effect3);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement