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.

[1.14.4] How would I go about checking if a living entity is above my custom block

Featured Replies

Posted

I'm currently trying to make a block that gradually increases the players y position (levitation) but only while the player is above block. I've looked into onEntityWalk but is only called if the player is directly on the block. I've looked into how soul sand does it with bubble columns but I'd rather not replace all air blocks above the block and instead just use livingEntity.getMotion(). I'm not sure what method I should use so that there are continuous checks to see if a living entity is above the block.

 

Any help is appreciated thanks.

7 hours ago, iGuess19 said:

Any help is appreciated thanks.

You'd have to subscribe to the LivingUpdateEvent and check all blocks beneath the entity.

Use the suggestion below me it's more efficient.

Edited by Animefan8888

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Or your could create a tile entity that pushes living entities above it every tick.

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

  • Author

Hey guys, just wanted to give a bit of an update as well as say that I appreciate both of your help.

 

I spent the last couple of days messing with the LivingUpdateEvent to no avail. I was having issues making it so that the player would continue to levitate even if it was more than one block above the levitation block.

 

I saw DavidM's reply and I spent a few hours today messing around with tile entities and just generally trying to get familiar with what I may need and I got it to work! I have a quick question about tile entities and performance though. Since I started playing MC I have always heard that tile entities are lag machines after a certain point. Since my tile entity relies on "tick updates" (may not be proper term) should I be worried about performance? I plan to implement a block for each potion effect so I could see users potentially using many these blocks to make, say, healing rooms with a bunch of regen blocks, or long highways with speed blocks, etc.

 

I also have another question, I'm not sure If I should make a separate post for this but how would I go about stopping the effect once it reaches a non air block above? That way it won't work through ceilings in builds. Right now I'm using a for loop to check from one above the tile entities y position up until world height but that seems disastrous. Is there some kind of ray I could use to check if it hits a solid block? Sorry if these questions seem simple I'm still getting used to the forge api and minecrafts internals.

 

Also, thanks again to both of you. I now have a working block as well as knowing about forge events that may be useful later on.

Edited by iGuess19

I can't figure out how to quote on mobile so this post may be a formatting mess.

 

Tile entities do create a bigger performance impact than regular blocks, but not significant enough to worry about. Yes, ticking the TEs every tick will lag a bit if you have tenth of thousands of it, but a roomful probably won't cause problems.

 

As for checking for blocks above the block, your way of using a for loop to check should be the best way. Ray tracing is way more expensive than a for loop.

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

5 hours ago, DavidM said:

I can't figure out how to quote on mobile so this post may be a formatting mess.

It's a bit of a pain, but you should just be able to highlight and hopefully the "Quote Selection" box will come up.

5 hours ago, iGuess19 said:

Right now I'm using a for loop to check from one above the tile entities y position up until world height but that seems disastrous.

I would probably just give the block an arbitrary range maybe make it increase-able. And only for loop for that range until I find a solid block. Otherwise you just have to go until you reach a solid block. Then I would take that range I have found (the y height of the solid block) and use World#getEntitiesInAABB (Or whatever it is called now).

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

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.