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.20.1] Creating a custom blockentity from interaction with vanilla block

Featured Replies

Posted

Hi all, I have a pretty basic question here that I'll try to lay out as concisely as possible:

I am currently working on this: On right clicking a banner with a name tag, the banner will generate an invisible radius around it, and the player will be alerted everytime they cross in and out of this radius under a generic message "Leaving/entering name tag's territory". I have already created an event to handle the right clicking on a banner block with a name tag, my current issue is finding the best way to spawn a custom block entity (if this is the appropriate method to implement this) into the world which can act as the centre point for this radius (being the banner) from wherein I can implement all of the code logic.

I just need to be pointed in the right direction on how the best way to spawn this entity/blockentity. I have already tried to make a custom banner entity, or to override the vanilla banner block + entity, but I cannot see that as being the best way to go about this. If anyone has any suggestions on how to proceed, it would be greatly appreciated. Thanks.
 

  • 2 weeks later...

In my mod, i tried to make a special block that "hurt" any living things that is around.
I used an entity block to do so. That entityBlock, every X tick, check if there is any living around.  If there is one, the block "hit" the entity.

You can make a ticking blockEntity linked to your banner that checks every "X" ticks if a player is around. If he detects someone as player,  you can "tag" him  like " he is in" and when he leaves , untag him (with a chat message each tagging/untagging for example). 

I think that's a good way to do it.

  • Author

Hi, thanks for the reply!

That seems like the best way to do it, my question is, how would you go about "linking"a block entity to a vanilla object in that way? I see for your example if you had a custom block you would have no issue in using your own CustomBlockBlockEntity associated with the custom block, however for me, banners already have a block entity, so unless I want to completely overwrite this vanilla BlockEntity, I am not sure on how to override or add methods to the BannerBlockEntity. Any suggestions?

Thanks again!

My not create your own BannerType Block  ?
Like that you can do whatever you want with it :)
And you can also take some code from the vanilla banner so make things work the same as a regular banner... except you had your custom things in addition .

 

  • 5 months later...

Hey can you send me pls the event interaction with the banner ?

and if possible can u tell me if i can do it with a custom Item and a custom block.

 

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.