Jump to content

When can you use Minecraft.getMinecraf();


Minecraft_idk_

Recommended Posts

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);
		}
	}
}

 

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.