Jump to content

Recommended Posts

Posted

Hello,

as the title says I am currently using 

world.getEntitiesWithinAABB

but it doesnt seem to get all Entities in the BB. So I printed my BB and checked all the corners nothing was wrong here.

In my code I harm all the Entitys instanceof EntityLivingBase with Generic damage. But not all Entities are harmed. Is this because I am damaging

them to fast or is it because not all Entities are getted by this Method because the printed List doesnt seem to be the full List of Entities in the BB.

I also tried to synchronize the part were I am getting the List no luck.

Posted
2 hours ago, Pingubro said:

not all Entities are harmed

Set a breakpoint and step through your code in the debugger. Then you'll see what's happening (and probably why).

  • Like 1

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

I went through my code step by step and cant find the issue.

When I throw items in each corner it only gets one. But when they are centered it gets all 

Items and it also damages the Entities.

Posted
 public static AxisAlignedBB getWorkingArea(BlockPos pos, EnumFacing face){
        int x = pos.getX();
        int y = pos.getY();
        int z = pos.getZ();
        BlockPos cornerFront;
        BlockPos cornerBack;
        switch (face) {
            case NORTH:
                cornerFront = new BlockPos(x - 2, y, z - 5);
                cornerBack = new BlockPos(x + 2, y + 2, z - 1);
                break;
            case SOUTH:
                cornerFront = new BlockPos(x + 2, y, z + 5);
                cornerBack = new BlockPos(x - 2, y + 2, z + 1);
                break;
            case WEST:
                cornerFront = new BlockPos(x - 5, y, z + 2);
                cornerBack = new BlockPos(x - 1, y + 2, z - 2);
                break;
            case EAST:
                cornerFront = new BlockPos(x + 5, y, z - 2);
                cornerBack = new BlockPos(x + 1, y + 2, z + 2);
                break;
            default:
                cornerFront = new BlockPos(x, y, z);
                cornerBack = new BlockPos(x, y + 2, z);
                break;
        }

        return new AxisAlignedBB(cornerFront, cornerBack);
    }

Only return a BB for a 5x2x5 Quad. 
I also tried spamming Zombies in a 3x3 area. Not all Zombies are dammaged the max i saw was about 8 or so.

Posted (edited)

Ohh sorry 

It is supposed to get a 5x5 Area and 2 high BB in front of my block. It takes the facing and the coordinates to calculate the BB.

It basically determines the coordinates of the two corners and puts them together

Edited by Pingubro
Posted

It is still not damaging all Entities in my room for testing purposes.

Thanks for updating my method it is much clearer now.

 

Can there be to much Entities for the Method?

Posted

I debbuged and I still dont know what is going on sadly.

I even copied the getEntitiesWithinAABB method to debug it when it only gets called by my class.

 

Is there a way to disable MobMovement to place an entity on everyblock?

Posted

Turn off the mob's AI.

You can use the /summon command and give the datatag {NoAI:1}

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Your AABB is not big enough. You're missing the fact that your block exists at (x,y,z) and has a SIZE of (1,1,1)

  • Like 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
/**
     * Thanks to @diesieben07
     * @param pos
     * @param face
     * @return
     */
    public static AxisAlignedBB getWorkingArea(BlockPos pos, EnumFacing face, int radius) {
        int divide;
        if(radius % 2 != 0){
            divide = (radius - 1)/2;
        }else{
            divide = radius / 2;
        }
        EnumFacing right = face.rotateY();
        BlockPos rightNear = pos.offset(face).offset(right, divide);
        BlockPos leftFar = pos.offset(face, radius).offset(right, -divide).up(2);
        return new AxisAlignedBB(rightNear, leftFar);
    }

I thought about this but which parameter should I expand? And even if I find the rigth one will it fix all the shapes?

Posted

so expanding everything by one every area is cleared but it seems like the mob list is filled with entities that stand in a one smaller radius then the BB is.

But nevermind it is working kind of. So thank you all

Posted (edited)

That's because your "center" is not in the middle of a block, but on one corner.

Radius 2 = 4x4 area centered on a corner (range [0-2, 0+2] => 4). Which is exactly what you got.

If you want "radius 2" to be a 5x5 area centered on a block, then you need to expand by one in the positive X and positive Z directions (range [0-2, 0+2+1] => 5):

5x5.png

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted (edited)
public static AxisAlignedBB getWorkingArea(BlockPos pos, EnumFacing face, int radius) {
        int divide = radius/2;

        EnumFacing right = face.rotateY();
        BlockPos rightNear = pos.offset(right, divide + 1);
        BlockPos leftFar = pos.offset(face, radius + 1).offset(right, -divide).up(2);

        return new AxisAlignedBB(rightNear, leftFar);
    }

I tried this now but it is still not working.

It looks like this -> 

Two of the rest are on the east side two on the south side

Edited by Pingubro
Posted (edited)

That's because your +1is on the wrong side. You need to add it to the positive X and positive Z directions. NOT to left or right sides

 

Your killzone IS 5x5, but it is offset from where you want it (it includes the fence on the fat side from where it didn't kill the shulkers).

Edited by Draco18s
  • Like 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

So the corner points need to look like this:

I have tested this again with shulkers but i wanted to be sure about this. I tested this by replacing the Fences with Shulkers and placed them in the middle the fence Shulkers didnt get moved but the ones inside.

The new Method after you guys helped me: https://github.com/hnsdieter/FluxedThings2/blob/master/src/main/java/pingubro/fluxedthings/util/FluxedUtil.java#L36-L47

P.S. in my local file I mentioned Draco18s aswell.

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.