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

Is it possible to create custom projectiles, like the arrow, except they are not affected by gravity (or at least not affected as much as arrows are)? I also would like to change their expiration time (the time before they disappear) so I can create projectiles that wouldn't travel forever.

 

This is all for a gem staff 'magic' weapon thing I'm planning; they'll shoot balls of 'energy' or something.

Yes. Extend EntityThrowable and override #getGravityVelocity to return 0.01F or some such - I don't recommend negating gravity entirely, however, or going much below that threshold unless you plan to limit the flight time in some way; otherwise your projectiles can travel forever.

 

As for the time on the ground, you could spawn it as an EntityItem with a custom lifespan, or do the much more difficult but cooler effect of figuring out how to place your projectile in an immobile state at the point of impact and render it correctly on that side of the block hit, in which case you have complete control over when the projectile entity despawns.

  • Author

Ah, alright. What I meant by 'time until they disappear' was that they should disappear when they hit a block, or after a certain time in the air. Since these are 'magic' weapons, you wouldn't be able to collect the projectile ball anyway.

Where do you register your projectile entity? It should be done during pre-init:

// increment the index for each entity you register
int modEntityIndex = 0;

// last 3 parameters are tracking range, tracking frequency, and whether to send tracking updates or not
// check the vanilla EntityList (I think) to find a similar entity class and use the same values
// in this case, throwable entities all use '64, 10, true' so I recommend you do the same
EntityRegistry.registerModEntity(YourEntityClass.class, "Your Entity", ++modEntityIndex, this, 64, 10, true);

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.