Skip to content

Commit

Permalink
Fix compatibility with future freecam
Browse files Browse the repository at this point in the history
  • Loading branch information
babbaj committed Apr 2, 2020
1 parent 933b06e commit ab9b007
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
13 changes: 9 additions & 4 deletions src/main/java/com/matt/forgehax/Helper.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
import com.matt.forgehax.util.FileManager;
import com.matt.forgehax.util.command.CommandGlobal;
import com.matt.forgehax.util.mod.loader.ModManager;
import java.util.Optional;
import java.util.Scanner;
import javax.annotation.Nullable;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.multiplayer.PlayerControllerMP;
Expand All @@ -24,6 +21,10 @@
import net.minecraftforge.fml.client.FMLClientHandler;
import org.apache.logging.log4j.Logger;

import javax.annotation.Nullable;
import java.util.Optional;
import java.util.Scanner;

/**
* Created on 4/25/2017 by fr1kin
*/
Expand All @@ -48,7 +49,11 @@ public static FileManager getFileManager() {
public static Logger getLog() {
return LOGGER;
}


public static Entity getRenderEntity() {
return MC.getRenderViewEntity();
}

public static EntityPlayerSP getLocalPlayer() {
return MC.player;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/matt/forgehax/mods/CompassMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private double getX(double rad) {

private double getY(double rad) {
final double epicPitch = MathHelper
.clamp(Helper.getLocalPlayer().rotationPitch + 30f, -90f, 90f);
.clamp(Helper.getRenderEntity().rotationPitch + 30f, -90f, 90f);
final double pitchRadians = Math.toRadians(epicPitch); // player pitch
return Math.cos(rad) * Math.sin(pitchRadians) * (scale.getAsDouble() * 10);
}
Expand All @@ -71,7 +71,7 @@ private double getY(double rad) {
private static double getPosOnCompass(Direction dir) {
double yaw =
Math.toRadians(
MathHelper.wrapDegrees(Helper.getLocalPlayer().rotationYaw)); // player yaw
MathHelper.wrapDegrees(Helper.getRenderEntity().rotationYaw)); // player yaw
int index = dir.ordinal();
return yaw + (index * HALF_PI);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.matt.forgehax.mods.services;

import static com.matt.forgehax.Helper.getLocalPlayer;

import com.matt.forgehax.events.Render2DEvent;
import com.matt.forgehax.events.RenderEvent;
import com.matt.forgehax.util.entity.EntityUtils;
Expand All @@ -17,6 +15,8 @@
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import org.lwjgl.opengl.GL11;

import static com.matt.forgehax.Helper.getRenderEntity;

/**
* Created on 6/14/2017 by fr1kin
*/
Expand All @@ -41,7 +41,7 @@ public void onRenderWorld(RenderWorldLastEvent event) {

GlStateManager.glLineWidth(1.f);

Vec3d renderPos = EntityUtils.getInterpolatedPos(getLocalPlayer(), event.getPartialTicks());
Vec3d renderPos = EntityUtils.getInterpolatedPos(getRenderEntity(), event.getPartialTicks());

RenderEvent e = new RenderEvent(TESSELLATOR, renderPos, event.getPartialTicks());
e.resetTranslation();
Expand Down

0 comments on commit ab9b007

Please sign in to comment.