Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[SOLVED] Bounding Box not stopping players from walking into large 3d Object

Featured Replies

Posted

I'm developing my Apocalypse mod, as many people know, and I'm having issus with setting up a bounding box around one of our map objects:

 

D8vF0FN.jpg

 

I've created a rediculous 8x8 bound box on the block class file:

 

BlockBuilding_Shop1.class:

public class BlockBuilding_Shop1 extends BlockContainer

{

    public BlockBuilding_Shop1()

    {

        super(Material.wood);

        this.setBlockBounds(0.0F, 0.0F, 0.0F, 8.0F, 6.0F, 8.0F);

    }

 

    public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack itemstack){

        int rotation = MathHelper.floor_double((double)(entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;

        if (rotation == 0) {

 

            world.setBlockMetadataWithNotify(x, y, z, 2, 2);

        }

        if (rotation == 1) {

            world.setBlockMetadataWithNotify(x, y, z, 5, 2);

        }

        if (rotation == 2) {

            world.setBlockMetadataWithNotify(x, y, z, 3, 2);

        }

        if (rotation == 3) {

            world.setBlockMetadataWithNotify(x, y, z, 4, 2);

        }

    }

 

    public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){

        int meta = world.getBlockMetadata(x, y, z);

        if(meta==2)

            this.setBlockBounds(0.0F, 0.0F, 0.0F, 8.0F, 6.0F, 8.0F);

        if(meta==5)

            this.setBlockBounds(0.0F, 0.0F, 0.0F, 8.0F, 6.0F, 8.0F);

        if(meta==3)

            this.setBlockBounds(0.0F, 0.0F, 0.0F, 8.0F, 6.0F, 8.0F);

        if(meta==4)

            this.setBlockBounds(0.0F, 0.0F, 0.0F, 8.0F, 6.0F, 8.0F);

    }

 

    @Override

    public TileEntity createNewTileEntity(World world, int var1)

    {

        return new EntityBuilding_Shop1();

    }

 

    @Override

    public int getRenderType()

    {

        return -1;

    }

 

    @Override

    public boolean isOpaqueCube()

    {

        return false;

    }

 

    public boolean renderAsNormalBlock()

    {

        return false;

    }

 

 

}

 

WvMWSnT.png

 

Anyone know why players can still enter through the sides/walls of the building apart from one 1x1 block area?

 

Thanks, Forge Community!

 

 

You can sorta cheat with bounding boxes, but only in the +Y direction (see: fences), but in general you can't get larger than 1x1x1

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.

It doesn't work because how would the AI know that that block (which is set to air) is covered by the bounding box from that block waaaay over there?

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.