day / night cycle detection

Discussion in 'Spigot Plugin Development' started by aquathickshell, Jun 9, 2015.

  1. How can I replace a mob drop in plugin development?
    I want to replace ghast drops from ghast tears to gold ingots.
     
  2. @aquathickshell In the EntityDeathEvent, clear the drops List and add your own ItemStacks
     
  3. @DarkSeraphim sorry, I don't entirely understand that. I am very much still learning.
     
    • Like Like x 1
  4. Did you first learn JAVA?
    Or did you instantly start with bukkit/spigot API?
    If you started with bukkit/spigot your must likely screwed as you don't know much about Java.
     
    • Agree Agree x 1
  5. Instead of saying hes screwed you could point him in the right direction/tutorials. Everyone has to start somewhere
     
    • Agree Agree x 1
    • Funny Funny x 1
  6. Ok, he should read the entire Java docs, and make random Java programs like a calculator, a guessing game so like you select range of 1-100 in the dialog and then it picks it then you do like 45 and it says 'Higher' or 'Lower' etc.. Make random Java stuff and get a feel for it and make sure you refer back to Java docs when you have an issue with Java then when your comfortable with Java read the spigot docs and do the same thing, random stuff you think you can and cannot do and if you can't figure out how.
     
    • Agree Agree x 2
  7. How does it know that I am changing the ghast's drops?
    I know what I feel that I need to, if there is anything that I don't know I will research it. By that I meant that I am very knew to the mob part of bukkit/spigot.
     
  8. Code (Java):
    @EventHandler
    public void onDeath(EntityDeathEvent e) {
    if (e.getEntityType() == EntityType.GHAST) {
    // check for ghast death
    List<ItemStack> drops = new ArrayList<ItemStack>();
    e.getDrops().clear();
    drops.add(new ItemStack(Material.GOLD_INGOT, 2));
    e.getDrops().addAll(drops);
    // create a list to add our custom drops to, clear the regular
    // drops, add items to the custom drop list, set the final
    // drops as the list
    }
    }
     
  9. @Arman
    You code is working fine for adding multiple new items, however when adding only one you can just add this one instead of a new list with just one item:
    Code (Text):
        @EventHandler
        public void onDeath(EntityDeathEvent e) {
            if (e.getEntityType() == EntityType.GHAST) {
                // check for ghast death
                e.getDrops().clear();
                ItemStack drop = new ItemStack(Material.GOLD_INGOT, 2);
                e.getDrops().add(drop);
            }
        }
     
    • Like Like x 2
  10. Thank you this has helped a lot.
    I would also like to know if there is a way to find if a player has a certain amount of achievements
     
  11. Untested, but something like this

    Code (Text):
    int numberOfAchievements = 0;
    for (Achievement a : Achievement.values()) {
        if (player.hasAchievement(a)) {
            numberOfAchievements++;
        }
    }
    Basically it just enumerates the Achievement enum and checks if the player has got this achievement, if yes increase the counter.
     
    • Like Like x 1
  12. - Sorry if you feel I am asking too much
    Am I able to detect how many day / night cycles have gone by or do I just have to set up a timer that detects when that amount of time has passed?
    I am going to try to turn gamerule doDaylightCycle to false after 2 day / night cycles have passed.
     
  13. If anyone knows any information that could help, I ask that you please reveal.
     
  14. Is there any event witch can check for day light cycle?