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.

[1.16.5] Chest lid openness is always zero when grabbed, despite changing

Featured Replies

Posted

I'm implementing the IChestLid interface, and doing everything basically the same as in the vanilla chest and in the iron chests mod, yet still whenever it gets the openness value in the tile entity renderer it's always 0. 

This is where I get the openness value:

Spoiler
float f1 = iCallbackWrapper.apply(TabulatedChest.getLid(tileEntity)).get(partialTicks);

 

And everywhere I set the value of the lid angle

Spoiler
@Override
    public void tick()
    {
        int i = this.worldPosition.getX();
        int j = this.worldPosition.getY();
        int k = this.worldPosition.getZ();
        ++this.ticksSinceSync;
        this.numPlayersUsing = getNumberOfPlayersUsing(this.level, this, this.ticksSinceSync, i, j, k, this.numPlayersUsing);
        this.prevLidAngle = this.lidAngle;
        float f = 0.1F;

        if (this.numPlayersUsing > 0 && this.lidAngle == 0.0F)
        {
            this.playSound(SoundEvents.CHEST_OPEN);
        }

        if (this.numPlayersUsing == 0 && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F)
        {
            float f1 = this.lidAngle;
            if (this.numPlayersUsing > 0)
            {
                this.lidAngle += 0.1F;
            }
            else
            {
                this.lidAngle -= 0.1F;
            }

            if (this.lidAngle > 1.0F)
            {
                this.lidAngle = 1.0F;
            }

            float f2 = 0.5F;
            if (this.lidAngle < 0.5F && f1 >= 0.5F)
            {
                this.playSound(SoundEvents.CHEST_CLOSE);
            }

            if (this.lidAngle < 0.0F)
            {
                this.lidAngle = 0.0F;
            }
        }
    }

 

And lastly where I get the value:

Spoiler
@Override
  public float getOpenNess(float time)
{
  return MathHelper.lerp(time, prevLidAngle, lidAngle);
}
@OnlyIn(Dist.CLIENT)
    public static TileEntityMerger.ICallback<TabulatedTile, Float2FloatFunction> getLid(final IChestLid lid)
    {
        return new TileEntityMerger.ICallback<TabulatedTile, Float2FloatFunction>()
        {
            @Override
            public Float2FloatFunction acceptDouble(TabulatedTile firstTile, TabulatedTile secondTile)
            {
                return (p_226921_2_) -> Math.max(firstTile.getOpenNess(p_226921_2_), secondTile.getOpenNess(p_226921_2_));
            }

            @Override
            public Float2FloatFunction acceptSingle(TabulatedTile p_225538_1_)
            {
                return p_225538_1_::getOpenNess;
            }

            @Override
            public Float2FloatFunction acceptNone()
            {
                return lid::getOpenNess;
            }
        };
    }

 

Any help's appreciated

  • Author

Fixed it, just had to override the triggerEvent method in the blocks class so it'd happen in the tile entity, so that the lid data would be synced between the client and server

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.