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 want to spawn a wither for one of my mods but I don't know how.

 

@SubscribeEvent

public void WitherMake(BreakEvent event) {

   if(!event.getPlayer().level.isClientSide) {

   WitherBoss wither = new WitherBoss(null, event.getPlayer().level);

   event.getPlayer().level.gameEvent(wither, GameEvent.ENTITY_PLACE, event.getPos());

   }

}

 

This is what im trying now but it dose not work. How would I spawn a wither i this placeholder method?

I looked at the spawn egg code but it is really confusing

  • Author

if(!event.getPlayer().level.isClientSide) {

   WitherBoss wither = new WitherBoss(null, event.getPlayer().level);

   event.getPlayer().level.addFreshEntity(wither);

}

 

I tried this too and it also doesn't work

12 hours ago, Duck478 said:

I tried this too and it also doesn't work

maybe it does? or it doesn't? why did you expect to see result without specifying the location of the new entity?

addFreshEntity should work. alternatively, entityType.spawn() will work too.

  • Author
On 6/20/2023 at 7:04 AM, MFMods said:

why did you expect to see result without specifying the location of the new entity?

I don't know how to do that, how do I specify the location?

Can you give me an example of code to create any entity in minecraft and I can follow that

 

entityType.spawn() has a BlockPos parameter. you can't miss it.

if you want to go with addFreshEntity, set the location (x,y,z) of the entity (there are set methods for it, i think i was setPosRaw). then, after that, call addFreshEntity.

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.