Jump to content

Recommended Posts

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 ?

Posted

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.

Posted

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);
	}

 

Posted

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.

Posted

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.