Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
recode spin
Browse files Browse the repository at this point in the history
add silent mode to norotate
fix invmanager
  • Loading branch information
xia-mc committed Jul 8, 2024
1 parent 97d13b6 commit 28a410f
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 39 deletions.
Binary file modified logo/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified logo/logo.psd
Binary file not shown.
64 changes: 34 additions & 30 deletions src/main/java/keystrokesmod/module/impl/fun/Spin.java
Original file line number Diff line number Diff line change
@@ -1,45 +1,49 @@
package keystrokesmod.module.impl.fun;

import keystrokesmod.event.RotationEvent;
import keystrokesmod.module.Module;
import keystrokesmod.module.setting.impl.DescriptionSetting;
import keystrokesmod.module.setting.impl.ButtonSetting;
import keystrokesmod.module.setting.impl.SliderSetting;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import org.jetbrains.annotations.NotNull;


public class Spin extends Module {
public SliderSetting a;
public SliderSetting b;
private float yaw;

public Spin() {
super("Spin", category.fun, 0);
this.registerSetting(a = new SliderSetting("Rotation", 360.0D, 30.0D, 360.0D, 1.0D));
this.registerSetting(b = new SliderSetting("Speed", 25.0D, 1.0D, 60.0D, 1.0D));
}
private final SliderSetting speed = new SliderSetting("Speed", 30, 10, 45, 5);
private final ButtonSetting constantPitch = new ButtonSetting("Constant pitch", true);
private final SliderSetting pitch = new SliderSetting("Pitch", 90, -90, 90, 5, constantPitch::isToggled);

public void onEnable() {
this.yaw = mc.thePlayer.rotationYaw;
}
private Float lastYaw = null;
private Float lastPitch = null;

public Spin() {
super("Spin", category.fun);
this.registerSetting(speed, constantPitch, pitch);
}

public void onDisable() {
this.yaw = 0.0F;
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onRotation(@NotNull RotationEvent event) {
if (lastYaw == null) {
lastPitch = event.getPitch();
}
event.setYaw(lastYaw = lastYaw + (float) speed.getInput());

public void onUpdate() {
double left = (double) this.yaw + a.getInput() - (double) mc.thePlayer.rotationYaw;
EntityPlayerSP var10000;
if (left < b.getInput()) {
var10000 = mc.thePlayer;
var10000.rotationYaw = (float) ((double) var10000.rotationYaw + left);
this.disable();
} else {
var10000 = mc.thePlayer;
var10000.rotationYaw = (float) ((double) var10000.rotationYaw + b.getInput());
if ((double) mc.thePlayer.rotationYaw >= (double) this.yaw + a.getInput()) {
this.disable();
}
}

if (constantPitch.isToggled()) {
event.setPitch((float) pitch.getInput());
} else {
if (lastPitch == null) {
lastPitch = event.getPitch();
}
event.setPitch(lastPitch = lastPitch + (float) speed.getInput());
}
}

@Override
public void onDisable() {
lastYaw = null;
lastPitch = null;
}
}

12 changes: 10 additions & 2 deletions src/main/java/keystrokesmod/module/impl/other/RotationHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ public static float getMovementYaw(Entity entity) {
return entity.rotationYaw;
}

public static void setRotationYaw(float rotationYaw) {
RotationHandler.rotationYaw = rotationYaw;
}

public static void setRotationPitch(float rotationPitch) {
RotationHandler.rotationYaw = rotationPitch;
}

public static float getRotationYaw() {
if (rotationYaw != null)
return rotationYaw;
Expand All @@ -64,7 +72,7 @@ public static float getRotationPitch() {
*/
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPreMotion(MoveInputEvent event) {
if (isSet) {
if (isSet && mc.thePlayer.openContainer == null) {
switch ((int) smoothBack.getInput()) {
case 0:
rotationYaw = mc.thePlayer.rotationYaw;
Expand All @@ -83,7 +91,7 @@ public void onPreMotion(MoveInputEvent event) {
RotationEvent rotationEvent = new RotationEvent(getRotationYaw(), getRotationPitch());
MinecraftForge.EVENT_BUS.post(rotationEvent);
isSet = rotationEvent.isSet() || rotationYaw != null || rotationPitch != null;
if (isSet) {
if (isSet && mc.thePlayer.openContainer == null) {
rotationYaw = rotationEvent.getYaw();
rotationPitch = rotationEvent.getPitch();
}
Expand Down
23 changes: 17 additions & 6 deletions src/main/java/keystrokesmod/module/impl/player/NoRotate.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

import keystrokesmod.event.ReceivePacketEvent;
import keystrokesmod.module.Module;
import keystrokesmod.module.impl.other.RotationHandler;
import keystrokesmod.module.setting.impl.ModeSetting;
import keystrokesmod.utility.Reflection;
import keystrokesmod.utility.Utils;
import net.minecraft.network.play.server.S08PacketPlayerPosLook;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

public class NoRotate extends Module {
private final ModeSetting mode = new ModeSetting("Mode", new String[]{"Cancel", "Silent"}, 0);

public NoRotate() {
super("NoRotate", category.player);
}
Expand All @@ -19,12 +23,19 @@ public void onReceivePacket(ReceivePacketEvent event) { // from croat
}
if (event.getPacket() instanceof S08PacketPlayerPosLook) {
S08PacketPlayerPosLook packet = (S08PacketPlayerPosLook) event.getPacket();
try {
Reflection.S08PacketPlayerPosLookYaw.set(packet, mc.thePlayer.rotationYaw);
Reflection.S08PacketPlayerPosLookPitch.set(packet, mc.thePlayer.rotationPitch);
} catch (Exception e) {
e.printStackTrace();
Utils.sendModuleMessage(this, "&cFailed to modify S08PacketPlayerPosLookPitch. Relaunch your game.");
switch ((int) mode.getInput()) {
case 1:
RotationHandler.setRotationYaw(packet.getYaw());
RotationHandler.setRotationPitch(packet.getPitch());
case 0:
try {
Reflection.S08PacketPlayerPosLookYaw.set(packet, mc.thePlayer.rotationYaw);
Reflection.S08PacketPlayerPosLookPitch.set(packet, mc.thePlayer.rotationPitch);
} catch (Exception e) {
e.printStackTrace();
Utils.sendModuleMessage(this, "&cFailed to modify S08PacketPlayerPosLookPitch. Relaunch your game.");
}
break;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/keystrokesmod/utility/ContainerUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ public static int getBestFood(int desiredSlot) {
final ItemStack stack = getItemStack(i);
if (stack != null && stack.getItem() instanceof ItemFood) {
float thisFoodLevel = ((ItemFood) stack.getItem()).getSaturationModifier(stack);
if (thisFoodLevel > foodLevel) {
if (thisFoodLevel > foodLevel + 1) {
foodLevel = thisFoodLevel;
slot = i;
}
Expand Down

0 comments on commit 28a410f

Please sign in to comment.