Block Drop Glass = rip hair out...

Discussion in 'Plugin Development' started by AskCharlie, Jul 23, 2011.

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

    AskCharlie

    I have been playing minecraft for quite some time and now I am interested in the basics of plugin development. I have gone through many tutorials and read the commands on the Bukkit Docs. I have experience with JavaScripting, but this simple block break/drop event is setting my mind a craze.

    I am wondering if someone could help me with a basic break 1 block get 1 block @override for the blocklistener.

    I have read through many different source codes from other plugin creators who were willing to share their source and each one of them do something different, with locating a file and making a list of what blocks change into what.

    I just need a simple, break glass, get glass to work for me. I have started on the code which may be completely barbaric but if anyone wants to see what i've done so far and where I am stuck, i will gladly send it to them.

    I'm not asking anyone to just write it out for me, but explain it to me so I can learn and adapt it to work on more simple ideas to get my foot in the door.


    I realized right after I posted this, there is someone who made a GlassReturn plugin already and that helped me understand what I was doing wrong by reviewing his source-code.
     
  2. Offline

    s1mpl3x

    havn't tested it but it should work. if you want if for glass only just add a if where you check the block type againt glass

    Code:
        public void onBlockBreak(BlockBreakEvent event) {
            Block b = event.getBlock();
            BlockState bs = b.getState();
    
            b.setType(Material.AIR);
            b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(bs.getType(), 1, bs.getRawData(), bs.getRawData()));
            event.setCancelled(true);
        }
     
    iPhysX likes this.
  3. Offline

    Daniel Heppner

    Javascript is a COMPLETELY different language from Java. Which do you know, Java or Javascript?
     
    zhuowei likes this.
  4. Offline

    AskCharlie

    thanks for the information. I just figured out what my problem was. I didn't register the event of block_break inside the main <plugin>.java or set any kind of priority. Once I did the it loaded right up and glass started to flow.

    I am going to try your quick code now just to see what happens, because i'm curious on learning different ways to do things. Right now my code is like 10 lines and yours seems a lot more compact.
     
  5. Offline

    iPhysX

    If you don't know much java or you have come from javascript, go to youtube and search thenewboston Java tutorials, he will help you get some basic knowledge which is definately required if you want to start on some plugins :)
    Goodluck
     
  6. Offline

    AskCharlie

    I'm sorry if I misspoke there. I call it javascript because its scripting in java. I don't know how else to say it. In my brain they would be the same thing, but I guess someone whose been working with code longer would know differently.

    sorry.
     
  7. Offline

    iPhysX

    Don't apologise lol. We all have our own way of saying things, I say programming, some people say coding :p
    it's all good bro
     
  8. Offline

    AskCharlie

    thanks for the information, I am actually already subscribed to his channel and have gone through all his videos, I guess I just said the wrong thing.

    yeah i call it coding while you mentioned you call it programming. I guess you could say I'm a code vulture because I do best when I can pick clean someone else's code and figure out exactly how it works and what makes it tick. Then I can go back and start writing my own because the functions make sense to me.

    Spending hours on tutorials just give me a headache and I'm sitting there with a confused expression on my face wondering what I do next. If I can get my hands on a code, study it for a while, i can usually break it apart, put it back together and it works, even tweak a few things here and there to fit what I'm searching for.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 17, 2016
    iPhysX likes this.
  9. Offline

    iPhysX

    @AskCharlie Well if you need any help just let me know i'm sure i can whip up some help :)
    Goodluck
     
  10. Offline

    loganwm

    You should be able to pick it up relatively quickly. I've been writing code for the better part of the past 6 years, and I always learned best by simply "doing." Especially with C. I've spent hours mastering C/C++'s memory operations simply by trying every possible scenario [even those that would fail] just to see how they would fail or succeed and why. Fortunately, you won't have to worry about anything low-level like that with Java, and this forum should be able to help you get acclimated since a substantial number of the developers here have started programming with Java as their first language and have already gotten pretty good in a short timeframe.
     
  11. Offline

    Daniel Heppner

    Sorry if I was harsh. I tend to do that. :p
     
Thread Status:
Not open for further replies.

Share This Page