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

Posted

I have looked at a couple of online documentations with the forge hierarchies but I couldn't find an answer.

 

A BlockDoor is a block, so in both states (open and closed) it acts as a block. Does this mean that it technically takes up the whole "cube" and some of it is without collisions, or is it a special sized block. Is there any way to get the block adjacent to the door? I tried to look for location, adjacent, nearby, etc... methods but they don't seem to exist for a door.

 

My next best bet was to implement a pressure plate mechanism, however when I checked the methods none of them seemed to explain the effect that pressure plates have. Any ideas about what those might be?

 

tl;dr I want to be able to detect players on top of/nearby/in blocks. I tried to look online for the appropriate methods, but I couldn't find them. If they exist I apologize for the question. Thanks!

Hi

 

You can get adjacent blocks if you know the [x,y,z] coordinate of your door block. 

The method you're overriding will give you World, call world.getBlock() with the coordinates of the adjacent block.

See also here

http://greyminecraftcoder.blogspot.com.au/2013/07/blocks.html

 

My usual strategy for figuring out how something works is to google it first, check a couple of links, then if nothing promising, just look at the vanilla.

 

For example:

Pressure plate?  search on pressure -> BlockBasePressurePlate looks promising

browse through methods ->

 

    /**
     * Ticks the block if it's been scheduled
     */
   public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)

    /**
     * Triggered whenever an entity collides with this block (enters into the block). Args: world, x, y, z, entity
     */
    public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)

    /**
     * Checks if there are mobs on the plate. If a mob is on the plate and it is off, it turns it on, and vice versa.
     */
    protected void setStateIfMobInteractsWithPlate(World par1World, int par2, int par3, int par4, int par5)

I reckon we've hit paydirt there.

 

It's nearly always possible to get there pretty easily this way.  Just think of the vanilla block / item / text command that does something, search for it in vanilla, spend a bit of time figuring out how the code works, then model your new code on it.

 

-TGG

 

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.