Posted July 8, 20214 yr I don't understand when you can use it or how you can, I made a "PlayerTickEvent" and I want to use "gameSettings" to see if the player pressed any keys to change the "event.player.abilities.setWalkSpeed". But I need to use .getMinecraft() to get the gameSettings. It says "The method getMinecraft() is undefined for the type Minecraft". package com.opl.mod.client.event; import net.minecraft.client.Minecraft; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; @EventBusSubscriber(modid="oplmodid", bus = Bus.FORGE, value = Dist.CLIENT) public class ClientEvents { private static final Minecraft mc = Minecraft.getMinecraft(); @SubscribeEvent public static void onBlockBreak(final TickEvent.PlayerTickEvent event) { if (mc.gameSettings.keyBindAttack.isKeyDown()) { event.player.abilities.setWalkSpeed(3f); } else { event.player.abilities.setWalkSpeed(1f); } } }
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.