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 was wondering if anyone had an idea on how to make the screen shake.

I have a custom entity and I want to make the screen shake when it walks as it's a giant.

I think I will handle this inside of the playStepSound() method, however I have no clue on how to perform this shake effect.

Does anyone have an idea please ?

Forge has events for changing the camera angles and field of view.

See ViewportEvent and its subclasses.

So you can rotate the screen and zoom in/out.

 

But to move the position of the camera, you need to move the player's eye position (or the eye position of the entity the player is spectating).

To do that you have to either physically move the player or do something that changes their dimensions. e.g. changing the player's net.minecraft.world.entity.Pose, like sneaking

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

  • Author

Alright, I will take a look at these classes, I think I will find what I want, thanks for your help !!

  • Author

Ok so now I am running into an issue.

I made the following code to basically affect every player which is in a certain box around the mob.

However, the players are ok, but the setDeltaMouvement() method doesn't make something at all.

I also tried player.jumpFromGound(), it doesn't work either.

Am I missing something ??

@Override protected void playStepSound(BlockPos pPos, BlockState pState) {
		int affectedRadius = 8;
		List<Player> players = this.level.getEntitiesOfClass(Player.class, new AABB(
		  this.getBlockX() + affectedRadius,
		  this.getBlockY() + affectedRadius,
		  this.getBlockZ() + affectedRadius,
		  this.getBlockX() - affectedRadius,
		  this.getBlockY() - affectedRadius,
		  this.getBlockZ() - affectedRadius));
		
		if (!players.isEmpty()) {
			players.forEach(player -> {
				Alcamod.LOGGER.info("Affecting " + player.getName());
				player.setDeltaMovement(player.getDeltaMovement().with(Direction.Axis.Y, 0.4D));
			});
		}
		
		this.playSound(AlcaSoundEvents.CRYSTAL_GOLEM_STEP.get(), 1.0F, 0.6F);
	}

 

Most entity movement calculations (which I believe is where the method you are using is called from?) happens on the server.

But player movement is usually calculated on the client. The "deltaMovement" isn't even sent by the client to the server for players so it is not very useful on the server.

 

There is a ClientBoundSetEntityMotionPacket you can send from the server to the client to update the value.

You can see it being used in for example Player.attack() when it updates the deltaMovement for a ServerPlayer.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

  • Author

Indeed, it explains it all.

I looked at its use in Player.attack() and I got it working, just sending the new packet after setting the deltaMouvement fixed the issue.

It was kind of simple in the end, but I would not have got it without you, thanks xD !

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.