Posted March 18, 20214 yr Hi, i wrote a mod which can grow and shrink the player but if the player is shrinked they crawl if they are inside a 1 block gap or if they jump inside a 2 block gap. How can i prevent them from doing that? I tried using the EntityEvent.Size and check if the event.getPose is Swimming (since this is the pose the player is using while crawling) but the entity isn't inside water. But it doesn't seems to work. Any ideas? Edited March 18, 20214 yr by Skyriis
March 19, 20214 yr Author @Mixin(Entity.class) public abstract class MixinEntity { @Shadow public abstract EntityType<?> getType(); @Shadow public World level; @Shadow public abstract int getId(); @Inject(method = "getBoundingBoxForPose", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/entity/Entity;getDimensions(Lnet/minecraft/entity/Pose;)Lnet/minecraft/entity/EntitySize;"), cancellable = true) private void getBoundingBoxForPose(Pose pose, CallbackInfoReturnable<AxisAlignedBB> cir) { if (!this.getType().equals(EntityType.PLAYER)) return; Entity entity = level.getEntity(getId()); if (entity == null) return; entity.getCapability(CapabilityHelper.RACE_CAPABILITY).ifPresent(iRaceProvider -> { final AxisAlignedBB axisAlignedBB = iRaceProvider.getRace().getPlayerBoundingBox(entity, pose); cir.setReturnValue(axisAlignedBB); }); } } i've used mixin to fix my problem but since i have no clue what i'm doing here i would be grateful for alternatives!
March 19, 20214 yr Author 4 minutes ago, diesieben07 said: You can use setForcedPose to set the pose. I tried using the setForcePose method within the PlayerTickEvent (set the pose on pre tick event and remove the pose on post tick event) but somehow it's bugging between both poses. I guess the source of my problem is that Entity.getBoundingBoxForPose returns a bounding box for the default EntityType.PLAYER which is not what i need since i'm resizing the player inside of the EntityEvent.Size event. #Entity.class public EntitySize getDimensions(Pose p_213305_1_) { return this.type.getDimensions(); } protected AxisAlignedBB getBoundingBoxForPose(Pose p_213321_1_) { EntitySize entitysize = this.getDimensions(p_213321_1_); float f = entitysize.width / 2.0F; Vector3d vector3d = new Vector3d(this.getX() - (double)f, this.getY(), this.getZ() - (double)f); Vector3d vector3d1 = new Vector3d(this.getX() + (double)f, this.getY() + (double)entitysize.height, this.getZ() + (double)f); return new AxisAlignedBB(vector3d, vector3d1); } getDimensions(Pose) should return the set EntitySize from the EntityEvent.Size event to make it work without mixin. Or am i wrong with that?
March 19, 20214 yr Author So i would have to manage the whole pose control using the player tick events if i want to prevent using mixin. Is that correct?
March 19, 20214 yr Author Do you mean that pull request? https://github.com/MinecraftForge/MinecraftForge/pull/6858
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.