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

Hello,
I created a custom entity which shoots snowballs at the player and other mobs. Now I want it to look at the target while doing so --> rotating its head to it/at least rotate its body in the targets direction
I tried to use this.lookAt(enitity) which doesnt seem to work.

Spawning Particles doesnt work either :(

public void tick() {
			this.attackTimer++;
			LivingEntity targetentity = this.snowmanCannon.getTarget();
			this.snowmanCannon.setAttacking(true);
			Level level = this.snowmanCannon.level;
			this.snowmanCannon.getLookControl().setLookAt(targetentity);
			
			if(!this.snowmanCannon.hasLineOfSight(targetentity)) {
				
			} else if (this.attackTimer == 1) {
				this.snowmanCannon.setAttacking(true);
				Vec3 pos1 = this.snowmanCannon.getEyePosition().add(0,-0.5,0);
				Vec3 pos2 = targetentity.getEyePosition();
				Vec3 dir = pos2.subtract(this.snowmanCannon.getEyePosition());
				SnowmanCannonProjectile snowball = new SnowmanCannonProjectile(level, pos1.x, pos1.y, pos1.z);
			    snowball.shoot(dir.x, dir.y, dir.z, 4.5F, 0.1F);
			    this.snowmanCannon.playSound(SoundEvents.SNOW_GOLEM_SHOOT, 1.0F, 1.0F);
			    
			    level.addAlwaysVisibleParticle(ParticleTypes.EXPLOSION, pos1.x, pos1.y, pos1.z, 1d, 1d, 1d);
				
			    level.addFreshEntity(snowball);
			} if (this.attackTimer == 3) {
				this.snowmanCannon.setAttacking(false);
				this.attackTimer = 0;
			}
		} 

Thank you for any help

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.