Anyone care to clean this garbage up for me?

Discussion in 'Plugin Development' started by Jnorr44, Nov 15, 2013.

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

    Jnorr44

    I wrote this when I first started programming, and now that I typically look at fairly decent or better code, I can't really understand what the heck I was doing here... Can anyone see if they can figure out how to clean this up and make it readable and make sense?

    Code:
                        if ((to.getTypeId() == 0) && (this.config.nearFix) && ((relative.getX() != b.getX()) || (relative.getY() != b.getY()) || (relative.getZ() != b.getZ()))) {
                            if ((relative.getData() == 0) && (((relative.getTypeId() == 8) && (this.config.enableWater)) || ((relative.getTypeId() == 10) && (this.config.enableWater)))) {
                                event.getToBlock().setTypeId(b.getTypeId());
                                count += 1;
                                event.setCancelled(true);
                                break;
                            }
                        }
    This is contained in a BlockFromToEvent
    BlockFromToEvent event = the event...?
    Block b = block that liquid is flowing from
    Block to = block that liquid is flowing to
    Block relative = block around "b" (North, South, East, or West)
    this.config.enable... are simple booleans, you shouldn't have to worry much about what their values are, because it is confugrable (changes)
    int count = you probably don't need to worry about it
     
  2. Offline

    RealDope

    We're completely missing the context here.. I don't see the declaration of these variables, what event you're using, or what config.nearFix is
     
  3. Offline

    Alshain01

    You want us to interpret code you wrote and failed to document? It's not even complete. What is "relative"?
     
  4. Offline

    Jnorr44

    Ouch, I forgot to put it in context, updating OP now.
     
  5. Offline

    Alshain01

    Well, first of all relative.getLocation() != b.getLocation() would cover most of the first line.
     
  6. Offline

    Jnorr44

    Yeah, pretty much, but it should probably use the .equals() method in location, and go by blockX,Y,Z, since the double values can be different.
     
  7. Offline

    Alshain01

    Yeah, I'm pseudo coding, don't take it literally.
     
Thread Status:
Not open for further replies.

Share This Page