Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I'm trying to figure out how to disable the player movement keys when the left and right mouse buttons are being held down at the same time. When the player releases the mouse keys the movement keys will work again.

 

I have been reading the tutorials provided on the website explaining how mouse and keyboard input works.

http://greyminecraftcoder.blogspot.com.au/2013/10/user-input.html

 

I am looking for tips on how to apply this information to a mod. I'm not entirely sure where to start.

 

Thanks in advance to anyone who is able to help me out.

  • Author

Hey thanks for the reply guys.

TheGreyGhost, I have read the thread you linked me and I figured I will get confused keys working first and then I will use that as a base to get my mod to work.

I am however having a few problems.

 

 

(In 1.7.10)

I have re-created your three classes ConfusedMovementInput, ClientTickHandler, (my main modding class)

 

- ConfusedMovementInput doesn't seem to have any errors

 

- ClientTickHandler has the following errors:

  -> It's telling me I need to create the interface "ITickHandler"

  -> It's telling me I need to create an interface or Class called "TickType"

 

- (main modding class called Shinobi) doesn't seem to have any errors

 

Here is the code:

package net.shinobi.mod;

import net.shinobi.mod.keyboard.ConfusedMovementInput;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;

@Mod(modid = Shinobi.MODID, version = Shinobi.VERSION)
public class Shinobi
{
    public static final String MODID = "Shinobi";
    public static final String VERSION = "Alpha 1.0";

    public static net.shinobi.mod.Shinobi instance;
    
    public static ConfusedMovementInput confusedMovementInput;
}

package net.shinobi.mod.keyboard;

import net.minecraft.util.MovementInput;

public class ConfusedMovementInput extends MovementInput
{
  public ConfusedMovementInput(MovementInput interceptedMovementInput)
  {
    underlyingMovementInput = interceptedMovementInput;
  }

  @Override
  public void updatePlayerMoveState() {
    underlyingMovementInput.updatePlayerMoveState();

    this.jump = underlyingMovementInput.jump;
    this.sneak = underlyingMovementInput.sneak;

    if (!confused) {
      this.moveStrafe = underlyingMovementInput.moveStrafe;
      this.moveForward = underlyingMovementInput.moveForward;
    } else {
      this.moveStrafe = -underlyingMovementInput.moveStrafe;           //swap left and right
      this.moveForward = underlyingMovementInput.moveForward;
    }
  }

  public void setConfusion(boolean newConfused) {
    confused = newConfused;
  }

  protected MovementInput underlyingMovementInput;
  private boolean confused = false;
}

package net.shinobi.mod.keyboard;

import java.util.EnumSet;

import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.item.ItemStack;
import net.shinobi.mod.Shinobi;

public class ClientTickHandler implements ITickHandler {

  public EnumSet<TickType> ticks()
  {
    return EnumSet.of(TickType.CLIENT);
  }

  public void tickStart(EnumSet<TickType> type, Object... tickData)
  {
    if (!type.contains(TickType.CLIENT)) return;

    EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
    if (player != null) {
      if (player.movementInput instanceof ConfusedMovementInput) {
      } else {
        Shinobi.confusedMovementInput = new ConfusedMovementInput(player.movementInput);
        player.movementInput = Shinobi.confusedMovementInput;
      }

      ItemStack heldItem = player.getHeldItem();
      if (heldItem != null) {
    	  Shinobi.confusedMovementInput.setConfusion(true);
      } else {
    	  Shinobi.confusedMovementInput.setConfusion(false);
      }
    }



  }

  public void tickEnd(EnumSet<TickType> type, Object... tickData)
  {
    }

  

  public String getLabel()
  {
    return "ClientTickHandler";
  }

}

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.