Skip to content

Commit

Permalink
fix autotrophyfish 'NaN' pitch value + setyawcommand for farming
Browse files Browse the repository at this point in the history
  • Loading branch information
StarZebra committed Feb 19, 2023
1 parent be71fe3 commit aa675bc
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/main/java/nexus/Nexus.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent;
import nexus.commands.DrillToggleCommand;
import nexus.commands.SetYawCommand;
import nexus.features.AutoTrophyFish;
import nexus.features.StopFuelUpdateDrill;
import org.lwjgl.input.Keyboard;
Expand All @@ -22,7 +23,7 @@
public class Nexus {

public static Minecraft mc = Minecraft.getMinecraft();
public static boolean devMode = false;
public static boolean devMode = true;
public static HashMap<String, KeyBinding> keyBindings = new HashMap<>();
public static boolean nameChangeToggle = true;

Expand All @@ -32,6 +33,7 @@ public class Nexus {
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event){
ClientCommandHandler.instance.registerCommand(new DrillToggleCommand());
ClientCommandHandler.instance.registerCommand(new SetYawCommand());
}

@Mod.EventHandler
Expand Down
38 changes: 38 additions & 0 deletions src/main/java/nexus/commands/SetYawCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package nexus.commands;

import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.util.ChatComponentText;
import nexus.Nexus;

public class SetYawCommand extends CommandBase{
@Override
public String getCommandName() {
return "setyaw";
}

@Override
public String getCommandUsage(ICommandSender sender) {
return "/" + getCommandName();
}

@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
if(args.length > 0){
String argYaw = args[0];
if(argYaw.matches("[a-z]+")) return;

Nexus.mc.thePlayer.rotationYaw = Float.parseFloat(argYaw);
Nexus.mc.thePlayer.addChatMessage(new ChatComponentText(Nexus.prefix + "Set yaw to " + argYaw));

}
}

@Override
public int getRequiredPermissionLevel(){
return 0;
}
}


2 changes: 1 addition & 1 deletion src/main/java/nexus/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static Pair<Float, Float> blockPosToYawPitch(BlockPos blockPos, Vec3 play
double diffY = blockPos.getY() - (playerPos.yCoord +Nexus.mc.thePlayer.getEyeHeight()) + 0.5;
double diffZ = blockPos.getZ() - playerPos.zCoord + 0.5;
float yaw = (float) Math.toDegrees(Math.atan2(diffZ, diffX)) - 90.0f;
float dist = (float) Math.sqrt(diffY*diffX+diffZ*diffZ);
float dist = (float) Math.sqrt(diffX*diffX+diffZ*diffZ);
float pitch = (float) (-(Math.toDegrees(Math.atan2(diffY, dist))));
return new Pair<>(Nexus.mc.thePlayer.rotationYaw + wrapAngleTo180(yaw-Nexus.mc.thePlayer.rotationYaw),
Nexus.mc.thePlayer.rotationPitch + wrapAngleTo180(pitch-Nexus.mc.thePlayer.rotationPitch));
Expand Down

0 comments on commit aa675bc

Please sign in to comment.