FallenMoonNetwork / CanaryMod

Server administration mod and API for Minecraft beta multiplayer server
http://canarymod.net
GNU Lesser General Public License v3.0
20 stars 14 forks source link

HitBlox Addition - getTargetBlockIgnoring (I already coded it for you) #79

Closed BluXDragon closed 11 years ago

BluXDragon commented 11 years ago

I coded for myself a method that obtains a target block from HitBlox while ignoring specified blocks instead of just air. So if ignoredList is {0, 8, 9} the hitblox will not stop at water, for example. 0 is necessary, as I figured one day I might need a hitblox that checks for air.

    public Block getTargetBlockIgnoring(HitBlox hb, int[] ignoredList){
        blockLoop:
        while ((getNextBlock() != null)) {
            for (int i : ignoredList){
                if (getCurBlock().getType() == i){
                    continue blockLoop;
                }
            }
            return getCurBlock();
            }
    return getCurBlock();
    }
WWOL commented 11 years ago

Wouldn't a break do instead of continue blockLoop; ? I don't really know what the labels do 100% so I may be wrong.

WWOL

BluXDragon commented 11 years ago

break on its own would end the "for (int i : ignoredList)" loop, and it would just return the current block. Doing so makes it not work at all if it has more than one value in "ignoredList". "continue blockLoop" continues the while loop instead.

I was very happy when I found out about this labelling :3

WWOL commented 11 years ago

Ah I see, thanks.

WWOL

gregcarlin commented 11 years ago

Are you sure you can't make a pull request? I believe you have to fork the project, edit your version, and then make a pull request from there.