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

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. 

2021-03-18_15_13_46.png.a641ed14073055c53603d6e56609eec3.png2021-03-18_15_13_29.png.fb2c90ec0044395518bac8561ab4acc2.png

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 by Skyriis

  • 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!

  • 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?

  • 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?

 

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.