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.

Featured Replies

Either a: use the onRandomTick (sp?) method in the block, take the passed in corrdinates, and pull an entity list from the world for an AABB near the block.

 

or b:  use a tile entity for the block, and do the same thing from an update tick from the tile entity.

 

brief questions get brief answers.

  • Author

I'm sorry if i was a little brief in my first post but i didn't know how to explain it any further.

now what i want to do is send of a redstone signal if a entity is in front of the block.

just like tripwire but you dont have to layout a line of tripwire.

 

i hope this was a little less brief in your opinnion but i dont know how to explain it any further.

 

and can you explain a little bit more about the AABB function to detect entity's?

 

i already found this function in the pressure plate class:

public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity){

}

 

bu i dont know how to extend the collision box of the block.

Haven't used this code in a a few MC versions, but you want to overwrite you're block's getCollisionBoundingBoxFromPool method like so:

    /**
     * Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
     * cleared to be reused)
     */
    @Override
    public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
    {
        return AxisAlignedBB.getAABBPool().addOrModifyAABBInPool(minX, minY, minZ, maxX, maxY, maxZ));
    }

With minX, minY, minZ, maxX, maxY, maxZ defining the area you want the collision hitbox to be. (A standard block would have 0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F I think, and a BlockCactus's collision BB would be slightly bigger than a standard block.)

 

Then override the onEntityCollided method, and put a log statement in there to test if your bounding box is right, like so:

    /**
     * Triggered whenever an entity collides with this block (enters into the block). Args: world, x, y, z, entity
     */
    public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
    {
        System.out.println("Collision detected!");
    }

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.