Nothing Happens When Calling a Method

Discussion in 'Plugin Development' started by Jeff.Halbert, Jan 15, 2013.

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

    Jeff.Halbert

    I created a method that will gather the (x,z) locations for all locations in the same biome I am standing in. y location never changes. But when I call the method, nothing happens. Nothing at all. Here is a link to the method...

    http://pastebin.com/embed_iframe.php?i=T6aXBJB2

    I'm not getting any errors from console. Any Ideas?
     
  2. Offline

    camyono

    Hey,

    it's nice that you are trying to do like this. But just for your information:

    When i get it right you are trying to get all blocks around you which are in a specific radius to check whether they are in the same biome as the location is?

    Then it would be alot easier you will use the Point class ( http://docs.oracle.com/javase/1.4.2/docs/api/java/awt/Point.html ) and Rectangle class ( http://docs.oracle.com/javase/1.4.2/docs/api/java/awt/Rectangle.html )
    You can create a list of all points around you in this specific radius and trying to get the type of biome.

    Simple and short example:

    Code:java
    1.  
    2. // Your area to check
    3. Rectangle rectangle = new Rectangle((int)loc.getX()-rad, (int)loc.getZ()-rad, rad*2, rad*2);
    4.  
    5. // Lists of points
    6. List<Point> biomePoints = new ArrayList<Point>();
    7.  
    8. // Check until max z
    9. for ( int z = 0; z <= rectangle.getMaxY(); z++ ) {
    10.  
    11. // Check until max x
    12. for ( int x = 0; x <= rectangle.getMaxX(); x++ ) {
    13.  
    14. // Check whether its your biome
    15. Location actLoc = new Location(loc.getWorld(),x,0,z);
    16. if ( actLoc.getBlock().getBiome() == biome ) {
    17.  
    18. // Save the point
    19. biomePoints.add(new Point(x, z));
    20.  
    21. }
    22.  
    23. }
    24.  
    25. }
    26.  
     
  3. Offline

    Jeff.Halbert

    that would definitely been WAY more easier... the only issue is, I would be over lapping in every loop iteration... but still, way easier. Thanks man.

    But still, it doesn't explain why there is no result at all... still so lost....
     
  4. Offline

    camyono

    First of all you are welcome. Could you explain what you are mean with overlapping?

    Edit: Here is the fix if you mean that ( i think that should work ):

    Code:java
    1.  
    2. // Check until max z
    3. for (int z = (int) rectangle.getMinY(); z <= rectangle.getMaxY(); z++) {
    4.  
    5. // Check until max x
    6. for (int x = (int) rectangle.getMinX(); x <= rectangle.getMaxX(); x++) {
    7.  


    You could try to debug. Insert in every iteration loop a logger#info or out#println. This is what actually is also used in the professional programming and it will help you to go through the steps of your programm and understand whats going on there.
     
  5. Offline

    Jeff.Halbert

    yeah... i'm going to have to do that.... just so i can see where i'm going wrong.
     
  6. Offline

    camyono

    Tell me if get stuck on that.
     
Thread Status:
Not open for further replies.

Share This Page