File size: 894 Bytes
d46f4a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package net.minecraft.client;

import com.mojang.blaze3d.platform.InputConstants;
import java.util.function.BooleanSupplier;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

@OnlyIn(Dist.CLIENT)
public class ToggleKeyMapping extends KeyMapping {
    private final BooleanSupplier needsToggle;

    public ToggleKeyMapping(String p_92529_, int p_92530_, String p_92531_, BooleanSupplier p_92532_) {
        super(p_92529_, InputConstants.Type.KEYSYM, p_92530_, p_92531_);
        this.needsToggle = p_92532_;
    }

    @Override
    public void setDown(boolean p_92534_) {
        if (this.needsToggle.getAsBoolean()) {
            if (p_92534_) {
                super.setDown(!this.isDown());
            }
        } else {
            super.setDown(p_92534_);
        }
    }

    protected void reset() {
        super.setDown(false);
    }
}