Jump to content

[1.16] PlayerEvent affecting all entities?


jstN0body

Recommended Posts

    @SubscribeEvent
    public void onSizeChange(PlayerEvent.Size event) {
        if (!(event.getEntity() instanceof PlayerEntity)) return;
        EntitySize newSize;
        switch (event.getPose()) {
            case CROUCHING:
                newSize = EntitySize.fixed(0.6f * SizeMod.sizePercentage, 1.5f * SizeMod.sizePercentage);
                break;

            case SWIMMING:
            case FALL_FLYING:
                newSize = EntitySize.fixed(0.6f * SizeMod.sizePercentage, 0.6f * SizeMod.sizePercentage);
                break;

            case SLEEPING:
                newSize = EntitySize.fixed(0.2f * SizeMod.sizePercentage, 0.2f * SizeMod.sizePercentage);
                break;

            case DYING:
                newSize = EntitySize.fixed(0.01f, 0.01f);
                break;

            default:
                newSize = EntitySize.fixed(0.6f * SizeMod.sizePercentage, 1.8f * SizeMod.sizePercentage);
        }
        event.setNewSize(newSize);
        event.setNewEyeHeight(newSize.height * 0.9f);
    }

I can't seem to figure out what's going wrong with my code. It seems like it should only affect players but any mob that spawns has its hitbox changed as well as any item that's dropped. Does anyone happen to know what's going on here?

Link to comment
Share on other sites

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.