Posted September 23, 20232 yr I have years of experience programming, even have a degree in computer science, but the whole gradle thing is quite new to me. My objective is to create a "moon-like" gravity. Slow falling, bigger jumps, etc. I have never done anything with forge prior to this, so I did lots of reading of the documentation and have a decent general understanding of things. I am able to do things such as, @SubscribeEvent public void onJump(LivingEvent.LivingJumpEvent event) { if(event.getEntity() instanceof Player) { Player player = (Player) event.getEntity(); player.setHealth(player.getHealth() - 1); } } Reading the docs I see a player#setMotion I would like to do this - which should be possible based on docs player.setMotion(player.getMotion().x, player.getMotion().y * MOON_GRAVITY_FACTOR, player.getMotion().z); but this method, and some other classes and methods do not appear to exist. At first I thought it was a version related issue, but that was proven untrue when I went back all the way to 1.17.1 and the issues persisted. This project is on 1.20.2 and the only thing I did in the project was changing the mod id and versions. Nothing to do with mappings or anything of the sort. Is there changes that I am unaware of? or is there an issue with my project setup? It is currently a default project straight from the website. I really am entirely confused, I am sure it is something simple. I tried my hardest to find the answer prior to asking.
September 24, 20232 yr Author It wasnt mappings issue, I was reading fabric and not forge. Fabric has PlayerEntity while forge has Player. Through a mixin I was able to change the player's velocity so that there is a sort of slow-motion type movement. Only issue is that jumping seems to be handled separately. Changing that velocity only makes the jump lower, not slower. Unsure how to increase the duration in which a jump happens. @Mixin(LivingEntity.class) public abstract class ExampleMixin extends Entity { public ExampleMixin(EntityType<?> type, World world) { super(type, world); } @Inject(method = "tickMovement", at = @At("HEAD")) private void onTickMovement(CallbackInfo ci) { // Access the player entity LivingEntity entity = (LivingEntity)(Object)this; // Modify player's acceleration by applying a force in the opposite direction double slowdownFactor = 0.75; // Adjust as needed entity.setVelocity(entity.getVelocity().multiply(1, slowdownFactor, 1)); } } Edited September 24, 20232 yr by Saday
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.