Letting pickaxes mine any block

Discussion in 'Plugin Development' started by Hex_27, Jan 9, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    1Rogue

    No, it's an issue with your old code. Do you not understand how to retrieve data from a Map? It's outlined in the tutorial: Maps exist like a PO box. You put your value in a PO box, and the PO box number is your "key". In order to get your item back, you need the "key" in order to retrieve the "value". Insertion uses
    Code:
    .put(key, value)
    whereas retrieval is
    Code:
    .get(key)
     
  2. Offline

    Hex_27

    @1Rogue I know how to use a hashmap. I just don't understand what you're DOING with it that needs me to put the value in. And I did test it. If I'm an op, it would work, but if I wasn't an op, it wouldn't work.
     
  3. Offline

    1Rogue

    You map a material, such as DIAMOND_ORE, to the list of itemstacks that diamond ore should drop when you break it. Moving on to your BlockBreakEvent, when a block is broken, you see if you've defined custom drops in your map. If you have, drop those. Otherwise you just drop the normal drops.
     
  4. Offline

    Hex_27

    @1Rogue Ok.. its time for me to explain everything of what I'm doing. In my coded gamemode, only a few blocks can be broken. And wood pickaxes are the default free tools. Heck, its supposed to break the ore even if I punch with a FIST. So nothing else can be destroyed, and thus only those blocks would drop something.
     
  5. Offline

    1Rogue

    So then just have two different methods in your listener for the event, since they do different things:

    Code:java
    1. @EventHandler
    2. public void stopBreaking(BlockBreakEvent event) {
    3. //...
    4. }
    5.  
    6. @EventHandler
    7. public void handlePickaxes(BlockBreakEvent event) {
    8. //...
    9. }
     
  6. Offline

    Hex_27

    @1Rogue my methods are much more complicated, cos there are stuff like "spell corrode" block protection, bla bla bla... so I can't just do that
     
  7. Offline

    mythbusterma

    @Hex_27

    Pretty sure you can just do that?
     
  8. Offline

    1Rogue

    Right, so have one method that focuses on your "spell" corrode and such, and then another that would focus on things like which blocks can be broken. Or however you want to divide up the work. Methods exist for a reason, you don't need everything in one single block of code.
     
  9. Offline

    Hex_27

    @1Rogue this is confusing. Now players can break blocks with wood pickaxe. This is giving me a headache...

    What do you refer to by "that"?

    <Edit by mrCookieSlime: Merged posts. Please don't double post. There is an Edit Button right next to the Date.>
     
    Last edited by a moderator: Jan 11, 2015
Thread Status:
Not open for further replies.

Share This Page