O
O
OneDeus2022-03-23 18:25:49
Java
OneDeus, 2022-03-23 18:25:49

How to implement step by step keystroke?

Can you please tell me how to make a phased keystroke?
So that if Ctrl is pressed, if at number 1 would work, when ctrl is pressed again, if at number 2 would work

@Override
    public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) {
        if (!world.isClient()) {
            if (entity instanceof PlayerEntity) {
                PlayerEntity player = (PlayerEntity) entity;
                ItemStack helmet = player.getInventory().getArmorStack(3);
                if (Screen.hasControlDown()) { <------ 1
                    player.addStatusEffect(new StatusEffectInstance(StatusEffects.NIGHT_VISION, (int) Float.POSITIVE_INFINITY,1));
                    player.sendMessage(new TranslatableText("tooltip.nevada.horror.on"), true);
                }

                if (Screen.hasControlDown() || helmet.isEmpty() || !((((ArmorItem)helmet.getItem()).getMaterial() == ArmorMaterials.COSMETICAL))) { <------ 2  
                    player.removeStatusEffect(StatusEffects.NIGHT_VISION);
                    player.sendMessage(new TranslatableText("tooltip.nevada.horror.off"), true);
                }
            }
        }
        super.inventoryTick(stack, world, entity, slot, selected);
    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question