net.minecraft.client.options.KeyBinding Java Examples
The following examples show how to use
net.minecraft.client.options.KeyBinding.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SneakHack.java From Wurst7 with GNU General Public License v3.0 | 6 votes |
@Override public void onDisable() { EVENTS.remove(PreMotionListener.class, this); EVENTS.remove(PostMotionListener.class, this); switch(mode.getSelected()) { case LEGIT: IKeyBinding sneakKey = (IKeyBinding)MC.options.keySneak; ((KeyBinding)sneakKey).setPressed(sneakKey.isActallyPressed()); break; case PACKET: sendSneakPacket(Mode.RELEASE_SHIFT_KEY); break; } }
Example #2
Source File: SneakHack.java From Wurst7 with GNU General Public License v3.0 | 6 votes |
@Override public void onPreMotion() { KeyBinding sneakKey = MC.options.keySneak; switch(mode.getSelected()) { case LEGIT: sneakKey.setPressed(true); break; case PACKET: sneakKey.setPressed(((IKeyBinding)sneakKey).isActallyPressed()); sendSneakPacket(Mode.PRESS_SHIFT_KEY); sendSneakPacket(Mode.RELEASE_SHIFT_KEY); break; } }
Example #3
Source File: FreecamHack.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
@Override public void onEnable() { EVENTS.add(UpdateListener.class, this); EVENTS.add(PacketOutputListener.class, this); EVENTS.add(IsPlayerInWaterListener.class, this); EVENTS.add(PlayerMoveListener.class, this); EVENTS.add(CameraTransformViewBobbingListener.class, this); EVENTS.add(IsNormalCubeListener.class, this); EVENTS.add(SetOpaqueCubeListener.class, this); EVENTS.add(RenderListener.class, this); fakePlayer = new FakePlayerEntity(); GameOptions gs = MC.options; KeyBinding[] bindings = {gs.keyForward, gs.keyBack, gs.keyLeft, gs.keyRight, gs.keyJump, gs.keySneak}; for(KeyBinding binding : bindings) binding.setPressed(((IKeyBinding)binding).isActallyPressed()); playerBox = GL11.glGenLists(1); GL11.glNewList(playerBox, GL11.GL_COMPILE); Box bb = new Box(-0.5, 0, -0.5, 0.5, 1, 0.5); RenderUtils.drawOutlinedBox(bb); GL11.glEndList(); }
Example #4
Source File: MineLittlePony.java From MineLittlePony with MIT License | 5 votes |
private void onTick(MinecraftClient client) { boolean inGame = client.world != null && client.player != null && client.currentScreen == null; boolean mainMenu = client.currentScreen instanceof TitleScreen; if (!inGame && mainMenu) { KeyBinding.updatePressedStates(); } if ((mainMenu || inGame) && keyBinding.isPressed()) { client.openScreen(new GuiPonySettings(client.currentScreen)); } }
Example #5
Source File: AddedKeybinds.java From patchwork-api with GNU Lesser General Public License v2.1 | 5 votes |
public static KeyBinding[] addRegisteredKeys(KeyBinding[] keysAll) { List<KeyBinding> newKeysAll = new ArrayList<>(); for (KeyBinding binding : keysAll) { newKeysAll.add(binding); } newKeysAll.addAll(registeredKeys); return newKeysAll.toArray(new KeyBinding[0]); }
Example #6
Source File: ZoomManagerScreen.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
@Override public void setKey(String key) { WurstClient.INSTANCE.getZoomKey() .setBoundKey(InputUtil.fromTranslationKey(key)); client.options.write(); KeyBinding.updateKeysByCode(); keyButton.setMessage(new LiteralText("Zoom Key: " + key)); }
Example #7
Source File: PathProcessor.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
public static final void lockControls() { // disable keys for(KeyBinding key : CONTROLS) key.setPressed(false); // disable sprinting WurstClient.MC.player.setSprinting(false); }
Example #8
Source File: MileyCyrusHack.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
@Override public void onDisable() { EVENTS.remove(UpdateListener.class, this); KeyBinding sneak = MC.options.keySneak; sneak.setPressed(((IKeyBinding)sneak).isActallyPressed()); }
Example #9
Source File: TunnellerHack.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
@Override public void onUpdate() { HackList hax = WURST.getHax(); Hack[] incompatibleHax = {hax.autoToolHack, hax.autoWalkHack, hax.blinkHack, hax.flightHack, hax.nukerHack, // TODO: // hax.nukerLegitHack, // hax.speedNukerHack, hax.sneakHack}; for(Hack hack : incompatibleHax) hack.setEnabled(false); if(hax.freecamHack.isEnabled()) return; GameOptions gs = MC.options; KeyBinding[] bindings = {gs.keyForward, gs.keyBack, gs.keyLeft, gs.keyRight, gs.keyJump, gs.keySneak}; for(KeyBinding binding : bindings) binding.setPressed(false); for(Task task : tasks) { if(!task.canRun()) continue; task.run(); break; } }
Example #10
Source File: AutoWalkHack.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
@Override public void onDisable() { EVENTS.remove(UpdateListener.class, this); KeyBinding forwardKey = MC.options.keyForward; forwardKey.setPressed(((IKeyBinding)forwardKey).isActallyPressed()); }
Example #11
Source File: PathProcessor.java From Wurst7 with GNU General Public License v3.0 | 4 votes |
public static final void releaseControls() { // reset keys for(KeyBinding key : CONTROLS) key.setPressed(((IKeyBinding)key).isActallyPressed()); }
Example #12
Source File: TunnellerHack.java From Wurst7 with GNU General Public License v3.0 | 4 votes |
@Override public void run() { BlockPos player = new BlockPos(MC.player.getPos()); KeyBinding forward = MC.options.keyForward; Vec3d diffVec = Vec3d.of(player.subtract(start)); Vec3d dirVec = Vec3d.of(direction.getVector()); double dotProduct = diffVec.dotProduct(dirVec); BlockPos pos1 = start.offset(direction, (int)dotProduct); if(!player.equals(pos1)) { WURST.getRotationFaker() .faceVectorClientIgnorePitch(toVec3d(pos1)); forward.setPressed(true); return; } BlockPos pos2 = start.offset(direction, Math.max(0, length - 10)); if(!player.equals(pos2)) { WURST.getRotationFaker() .faceVectorClientIgnorePitch(toVec3d(pos2)); forward.setPressed(true); MC.player.setSprinting(true); return; } BlockPos pos3 = start.offset(direction, length + 1); WURST.getRotationFaker().faceVectorClientIgnorePitch(toVec3d(pos3)); forward.setPressed(false); MC.player.setSprinting(false); if(disableTimer > 0) { disableTimer--; return; } setEnabled(false); }
Example #13
Source File: AddedKeybinds.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
public static void registerKeyBinding(KeyBinding key) { registeredKeys.add(key); }
Example #14
Source File: BlockParty.java From bleachhack-1.14 with GNU General Public License v3.0 | 4 votes |
@Subscribe public void onTick(EventTick event) { Item item = mc.player.inventory.getMainHandStack().getItem(); Block block = Block.getBlockFromItem(item); if (block == Blocks.AIR) return; if (mc.world.getBlockState(mc.player.getBlockPos().add(0, -1, 0)).getBlock() == block || mc.world.getBlockState(mc.player.getBlockPos().add(0, -2, 0)).getBlock() == block) { mc.player.setVelocity(0, mc.player.getVelocity().y, 0); KeyBinding.setKeyPressed(mc.options.keyForward.getDefaultKeyCode(), false); return; } List<BlockPos> poses = new ArrayList<>(); for (int x = -50; x < 50; x++) { for (int y = -2; y < 1; y++) { for (int z = -50; z < 50; z++) { if (mc.world.getBlockState(mc.player.getBlockPos().add(x, y, z)).getBlock() == block && mc.world.getBlockState(mc.player.getBlockPos().add(x, y+1, z)).getBlock() == Blocks.AIR) poses.add(mc.player.getBlockPos().add(x, y, z)); } } } if (poses.isEmpty()) return; poses.sort((a,b) -> Double.compare(a.getSquaredDistance(mc.player.getBlockPos()), b.getSquaredDistance(mc.player.getBlockPos()))); double diffX = poses.get(0).getX() + 0.5 - mc.player.x; double diffZ = poses.get(0).getZ() + 0.5 - mc.player.z; float yaw = (float)Math.toDegrees(Math.atan2(diffZ, diffX)) - 90F; mc.player.yaw += MathHelper.wrapDegrees(yaw - mc.player.yaw); KeyBinding.setKeyPressed(mc.options.keyForward.getDefaultKeyCode(), true); if (mc.player.getBlockPos().getSquaredDistance(poses.get(0)) < (mc.player.isSprinting() ? 25 : 8) && Math.abs(mc.player.getVelocity().x) + Math.abs(mc.player.getVelocity().z) > 0.15 && mc.player.verticalCollision) { mc.player.jump(); mc.player.verticalCollision = false; //mc.player.setPosition(mc.player.x, mc.player.y + 0.02, mc.player.z); } if (getSettings().get(1).toToggle().state && mc.player.fallDistance < 0.25) { if (jumping && mc.player.y >= mc.player.prevY + 0.399994D) { mc.player.setVelocity(mc.player.getVelocity().x, -0.9, mc.player.getVelocity().z); mc.player.y = mc.player.prevY; jumping = false; } if (mc.player.forwardSpeed != 0.0F && !mc.player.horizontalCollision) { if (mc.player.verticalCollision) { mc.player.setVelocity(mc.player.getVelocity().x * Math.min(1.3, 0.85 + mc.player.getBlockPos().getSquaredDistance(poses.get(0)) / 300), mc.player.getVelocity().y, mc.player.getVelocity().z * Math.min(1.3, 0.85 + mc.player.getBlockPos().getSquaredDistance(poses.get(0)) / 300)); jumping = true; mc.player.jump(); } if (jumping && mc.player.y >= mc.player.prevY + 0.399994D) { mc.player.setVelocity(mc.player.getVelocity().x, -100, mc.player.getVelocity().z); jumping = false; } } } }
Example #15
Source File: BlockParty.java From bleachhack-1.14 with GNU General Public License v3.0 | 4 votes |
@Subscribe public void onTick(EventTick event) { Item item = mc.player.inventory.getMainHandStack().getItem(); Block block = Block.getBlockFromItem(item); if (block == Blocks.AIR) return; if (mc.world.getBlockState(mc.player.getBlockPos().add(0, -1, 0)).getBlock() == block || mc.world.getBlockState(mc.player.getBlockPos().add(0, -2, 0)).getBlock() == block) { mc.player.setVelocity(0, mc.player.getVelocity().y, 0); KeyBinding.setKeyPressed(mc.options.keyForward.getDefaultKey(), false); return; } List<BlockPos> poses = new ArrayList<>(); for (int x = -50; x < 50; x++) { for (int y = -2; y < 1; y++) { for (int z = -50; z < 50; z++) { if (mc.world.getBlockState(mc.player.getBlockPos().add(x, y, z)).getBlock() == block && mc.world.getBlockState(mc.player.getBlockPos().add(x, y+1, z)).getBlock() == Blocks.AIR) poses.add(mc.player.getBlockPos().add(x, y, z)); } } } if (poses.isEmpty()) return; poses.sort((a,b) -> Double.compare(a.getSquaredDistance(mc.player.getBlockPos()), b.getSquaredDistance(mc.player.getBlockPos()))); double diffX = poses.get(0).getX() + 0.5 - mc.player.getX(); double diffZ = poses.get(0).getZ() + 0.5 - mc.player.getZ(); float yaw = (float)Math.toDegrees(Math.atan2(diffZ, diffX)) - 90F; mc.player.yaw += MathHelper.wrapDegrees(yaw - mc.player.yaw); KeyBinding.setKeyPressed(mc.options.keyForward.getDefaultKey(), true); if (mc.player.getBlockPos().getSquaredDistance(poses.get(0)) < (mc.player.isSprinting() ? 25 : 8) && Math.abs(mc.player.getVelocity().x) + Math.abs(mc.player.getVelocity().z) > 0.15 && mc.player.verticalCollision) { mc.player.jump(); mc.player.verticalCollision = false; //mc.player.setPosition(mc.player.getX(), mc.player.y + 0.02, mc.player.getZ()); } if (getSettings().get(1).toToggle().state && mc.player.fallDistance < 0.25) { if (jumping && mc.player.getY() >= mc.player.prevY + 0.399994D) { mc.player.setVelocity(mc.player.getVelocity().x, -0.9, mc.player.getVelocity().z); mc.player.setPos(mc.player.getX(), mc.player.prevY, mc.player.getZ()); jumping = false; } if (mc.player.forwardSpeed != 0.0F && !mc.player.horizontalCollision) { if (mc.player.verticalCollision) { mc.player.setVelocity(mc.player.getVelocity().x * Math.min(1.3, 0.85 + mc.player.getBlockPos().getSquaredDistance(poses.get(0)) / 300), mc.player.getVelocity().y, mc.player.getVelocity().z * Math.min(1.3, 0.85 + mc.player.getBlockPos().getSquaredDistance(poses.get(0)) / 300)); jumping = true; mc.player.jump(); } if (jumping && mc.player.getY() >= mc.player.prevY + 0.399994D) { mc.player.setVelocity(mc.player.getVelocity().x, -100, mc.player.getVelocity().z); jumping = false; } } } }
Example #16
Source File: BlockParty.java From bleachhack-1.14 with GNU General Public License v3.0 | 4 votes |
@Subscribe public void onTick(EventTick event) { Item item = mc.player.inventory.getMainHandStack().getItem(); Block block = Block.getBlockFromItem(item); if (block == Blocks.AIR) return; if (mc.world.getBlockState(mc.player.getBlockPos().add(0, -1, 0)).getBlock() == block || mc.world.getBlockState(mc.player.getBlockPos().add(0, -2, 0)).getBlock() == block) { mc.player.setVelocity(0, mc.player.getVelocity().y, 0); KeyBinding.setKeyPressed(mc.options.keyForward.getDefaultKeyCode(), false); return; } List<BlockPos> poses = new ArrayList<>(); for (int x = -50; x < 50; x++) { for (int y = -2; y < 1; y++) { for (int z = -50; z < 50; z++) { if (mc.world.getBlockState(mc.player.getBlockPos().add(x, y, z)).getBlock() == block && mc.world.getBlockState(mc.player.getBlockPos().add(x, y+1, z)).getBlock() == Blocks.AIR) poses.add(mc.player.getBlockPos().add(x, y, z)); } } } if (poses.isEmpty()) return; poses.sort((a,b) -> Double.compare(a.getSquaredDistance(mc.player.getBlockPos()), b.getSquaredDistance(mc.player.getBlockPos()))); double diffX = poses.get(0).getX() + 0.5 - mc.player.getX(); double diffZ = poses.get(0).getZ() + 0.5 - mc.player.getZ(); float yaw = (float)Math.toDegrees(Math.atan2(diffZ, diffX)) - 90F; mc.player.yaw += MathHelper.wrapDegrees(yaw - mc.player.yaw); KeyBinding.setKeyPressed(mc.options.keyForward.getDefaultKeyCode(), true); if (mc.player.getBlockPos().getSquaredDistance(poses.get(0)) < (mc.player.isSprinting() ? 25 : 8) && Math.abs(mc.player.getVelocity().x) + Math.abs(mc.player.getVelocity().z) > 0.15 && mc.player.verticalCollision) { mc.player.jump(); mc.player.verticalCollision = false; //mc.player.setPosition(mc.player.getX(), mc.player.y + 0.02, mc.player.getZ()); } if (getSettings().get(1).toToggle().state && mc.player.fallDistance < 0.25) { if (jumping && mc.player.getY() >= mc.player.prevY + 0.399994D) { mc.player.setVelocity(mc.player.getVelocity().x, -0.9, mc.player.getVelocity().z); mc.player.setPos(mc.player.getX(), mc.player.prevY, mc.player.getZ()); jumping = false; } if (mc.player.forwardSpeed != 0.0F && !mc.player.horizontalCollision) { if (mc.player.verticalCollision) { mc.player.setVelocity(mc.player.getVelocity().x * Math.min(1.3, 0.85 + mc.player.getBlockPos().getSquaredDistance(poses.get(0)) / 300), mc.player.getVelocity().y, mc.player.getVelocity().z * Math.min(1.3, 0.85 + mc.player.getBlockPos().getSquaredDistance(poses.get(0)) / 300)); jumping = true; mc.player.jump(); } if (jumping && mc.player.getY() >= mc.player.prevY + 0.399994D) { mc.player.setVelocity(mc.player.getVelocity().x, -100, mc.player.getVelocity().z); jumping = false; } } } }
Example #17
Source File: ClientRegistry.java From patchwork-api with GNU Lesser General Public License v2.1 | 2 votes |
/** * Registers a {@link KeyBinding}. * Call this during {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent}. * This method is safe to call during parallel mod loading. */ public static synchronized void registerKeyBinding(KeyBinding key) { KeyBindingRegistry.INSTANCE.addCategory(key.getCategory()); AddedKeybinds.registerKeyBinding(key); }