Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

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


ImNotJahan
 Share

Recommended Posts

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

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
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.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.