Skip to content

Commit 14fd87e

Browse files
committed
smooth lock yaw
2 parents 0d7d65d + a135c7d commit 14fd87e

39 files changed

+763
-222
lines changed

src/main/java/com/jelly/farmhelper/FarmHelper.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
import com.jelly.farmhelper.features.Antistuck;
55
import com.jelly.farmhelper.features.Failsafe;
66
import com.jelly.farmhelper.gui.MenuGUI;
7+
import com.jelly.farmhelper.gui.Render;
78
import com.jelly.farmhelper.macros.MacroHandler;
89
import com.jelly.farmhelper.utils.KeyBindUtils;
9-
import com.jelly.farmhelper.utils.LogUtils;
1010
import com.jelly.farmhelper.world.GameState;
1111
import net.minecraft.client.Minecraft;
1212
import net.minecraftforge.common.MinecraftForge;
@@ -27,19 +27,21 @@ public class FarmHelper {
2727
public static int tickCount = 0;
2828
public static boolean openedGUI = false;
2929
private static final Minecraft mc = Minecraft.getMinecraft();
30-
public static GameState gameState = new GameState();
30+
public static GameState gameState;
3131

3232
@Mod.EventHandler
3333
public void init(FMLInitializationEvent event) {
3434
// ClientCommandHandler.instance.registerCommand((ICommand)new CheetoCommand());
3535
Display.setTitle(FarmHelper.NAME + " v" + FarmHelper.VERSION + " | GIGACHADS ONLY");
3636
FarmHelperConfig.init();
3737
KeyBindUtils.setup();
38-
MinecraftForge.EVENT_BUS.register(new FarmHelper());
38+
MinecraftForge.EVENT_BUS.register(this);
39+
MinecraftForge.EVENT_BUS.register(new Render());
3940
MinecraftForge.EVENT_BUS.register(new MenuGUI());
4041
MinecraftForge.EVENT_BUS.register(new Failsafe());
4142
MinecraftForge.EVENT_BUS.register(new Antistuck());
4243
MinecraftForge.EVENT_BUS.register(new MacroHandler());
44+
gameState = new GameState();
4345

4446
}
4547
@SubscribeEvent
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.jelly.farmhelper.datastructures;
2+
3+
public class Pair<K, V> {
4+
private K key;
5+
private V value;
6+
7+
public Pair(K key, V value) {
8+
this.key = key;
9+
this.value = value;
10+
}
11+
12+
public K getKey() {
13+
return key;
14+
}
15+
16+
public void setKey(K key) {
17+
this.key = key;
18+
}
19+
20+
public V getValue() {
21+
return value;
22+
}
23+
24+
public void setValue(V value) {
25+
this.value = value;
26+
}
27+
28+
@Override
29+
public String toString() {
30+
return "Pair{" +
31+
"key=" + key +
32+
", value=" + value +
33+
'}';
34+
}
35+
}

src/main/java/com/jelly/farmhelper/features/Antistuck.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.jelly.farmhelper.FarmHelper;
44
import com.jelly.farmhelper.macros.MacroHandler;
55
import com.jelly.farmhelper.utils.Clock;
6+
import com.jelly.farmhelper.utils.LogUtils;
67
import net.minecraft.client.Minecraft;
78
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
89
import net.minecraftforge.fml.common.gameevent.TickEvent;
@@ -16,9 +17,13 @@ public class Antistuck {
1617

1718
@SubscribeEvent
1819
public final void tick(TickEvent.ClientTickEvent event) {
19-
if (!MacroHandler.on || event.phase == TickEvent.Phase.END || mc.thePlayer == null || mc.theWorld == null) return;
20+
if (MacroHandler.currentMacro == null || !MacroHandler.currentMacro.enabled || event.phase == TickEvent.Phase.END || mc.thePlayer == null || mc.theWorld == null) return;
2021
if (cooldown.passed()) {
2122
stuck = Math.abs(mc.thePlayer.posX - lastX) < 1 && Math.abs(mc.thePlayer.posZ - lastZ) < 1;
23+
if (stuck) {
24+
LogUtils.webhookLog("Stuck, trying to fix");
25+
LogUtils.debugLog("Stuck, trying to fix");
26+
}
2227
lastX = mc.thePlayer.posX;
2328
lastZ = mc.thePlayer.posZ;
2429
cooldown.schedule(3000);

src/main/java/com/jelly/farmhelper/features/Failsafe.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.jelly.farmhelper.FarmHelper;
44
import com.jelly.farmhelper.config.interfaces.JacobConfig;
5+
import com.jelly.farmhelper.config.interfaces.MiscConfig;
56
import com.jelly.farmhelper.macros.MacroHandler;
67
import com.jelly.farmhelper.utils.Clock;
78
import com.jelly.farmhelper.utils.LogUtils;
@@ -45,13 +46,15 @@ public final void tick(TickEvent.ClientTickEvent event) {
4546
return;
4647
case LIMBO:
4748
if (cooldown.passed()) {
49+
LogUtils.webhookLog("Not at island - teleporting back");
4850
mc.thePlayer.sendChatMessage("/lobby");
4951
cooldown.schedule(5000);
5052
teleporting = true;
5153
}
5254
return;
5355
case LOBBY:
5456
if (cooldown.passed() && jacobWait.passed()) {
57+
LogUtils.webhookLog("Not at island - teleporting back");
5558
mc.thePlayer.sendChatMessage("/skyblock");
5659
cooldown.schedule(5000);
5760
teleporting = true;
@@ -60,13 +63,14 @@ public final void tick(TickEvent.ClientTickEvent event) {
6063
case HUB:
6164
LogUtils.debugLog("Detected Hub");
6265
if (cooldown.passed() && jacobWait.passed()) {
66+
LogUtils.webhookLog("Not at island - teleporting back");
6367
mc.thePlayer.sendChatMessage("/is");
6468
cooldown.schedule(5000);
6569
teleporting = true;
6670
}
6771
return;
6872
case ISLAND:
69-
if (jacobExceeded()) {
73+
if (JacobConfig.jacobFailsafe && jacobExceeded()) {
7074
jacobWait.schedule(getJacobRemaining());
7175
mc.thePlayer.sendChatMessage("/lobby");
7276
} else {
@@ -101,8 +105,8 @@ public static long getJacobRemaining() {
101105
String cleanedLine = ScoreboardUtils.cleanSB(line);
102106
Matcher matcher = pattern.matcher(cleanedLine);
103107
if (matcher.find()) {
104-
LogUtils.scriptLog("Jacob remaining time: " + matcher.group(1) + "m" + matcher.group(2) + "s");
105-
// LogUtils.webhookLog("Reached jacob threshold - Resuming in " + matcher.group(1) + "m" + matcher.group(2) + "s");
108+
LogUtils.debugLog("Jacob remaining time: " + matcher.group(1) + "m" + matcher.group(2) + "s");
109+
LogUtils.webhookLog("Jacob score exceeded - - Resuming in " + matcher.group(1) + "m" + matcher.group(2) + "s");
106110
return TimeUnit.MINUTES.toMillis(Long.parseLong(matcher.group(1))) + TimeUnit.SECONDS.toMillis(Long.parseLong(matcher.group(2)));
107111
}
108112
}

src/main/java/com/jelly/farmhelper/features/Resync.java

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,25 @@ public class Resync {
3030
public static void update(BlockPos lastBrokenPos) {
3131
Resync.lastBrokenPos = lastBrokenPos;
3232
if (checkTimer.passed()) {
33-
System.out.println("resync update recieved - " + lastBrokenPos + ", " + mc.theWorld.getBlockState(lastBrokenPos));
3433
cachedPos = lastBrokenPos;
3534
Timer t = new Timer();
3635
t.schedule(
37-
new TimerTask() {
38-
@Override
39-
public void run() {
40-
if (cachedPos != null && mc.theWorld.getBlockState(cachedPos) != null) {
41-
// LogUtils.debugLog("Rechecked - " + mc.theWorld.getBlockState(cachedPos).getValue(BlockCrops.AGE));
42-
if (FarmConfig.cropType == CropEnum.NETHERWART && mc.theWorld.getBlockState(cachedPos).getValue(BlockNetherWart.AGE) > 2) {
43-
mc.thePlayer.sendChatMessage("/hub");
44-
} else if(FarmConfig.cropType == CropEnum.SUGARCANE && mc.theWorld.getBlockState(cachedPos).getBlock().equals(Blocks.reeds)){
45-
mc.thePlayer.sendChatMessage("/hub");
46-
} else if (mc.theWorld.getBlockState(cachedPos).getValue(BlockCrops.AGE) > 4) {
47-
mc.thePlayer.sendChatMessage("/hub");
48-
}
49-
}
50-
t.cancel();
51-
}
52-
},
53-
4000
36+
new TimerTask() {
37+
@Override
38+
public void run() {
39+
if (cachedPos != null && mc.theWorld.getBlockState(cachedPos) != null) {
40+
if (FarmConfig.cropType == CropEnum.NETHERWART && mc.theWorld.getBlockState(cachedPos).getValue(BlockNetherWart.AGE) > 2 ||
41+
FarmConfig.cropType == CropEnum.SUGARCANE && mc.theWorld.getBlockState(cachedPos).getBlock().equals(Blocks.reeds) ||
42+
mc.theWorld.getBlockState(cachedPos).getValue(BlockCrops.AGE) > 4) {
43+
LogUtils.debugLog("Desync detected");
44+
LogUtils.webhookLog("Desync detected");
45+
mc.thePlayer.sendChatMessage("/hub");
46+
}
47+
}
48+
t.cancel();
49+
}
50+
},
51+
4000
5452
);
5553
checkTimer.schedule(5000);
5654
}

src/main/java/com/jelly/farmhelper/gui/ProfitGUI.java

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,17 @@ public ProfitGUI(Window window) {
7373
.setColor(new Color(249, 249, 249))
7474
.setChildOf(topBar);
7575

76-
stats.add(new Stat("https://i.ibb.co/HrWKbsw/profit.png").bind(ProfitUtils.profit).setChildOf(this));
77-
stats.add(new Stat("https://i.ibb.co/BP29c8v/profithr.png").bind(ProfitUtils.profitHr).setChildOf(this));
78-
stats.add(new Stat("https://i.ibb.co/8dv1fR0/mnw.png").bind(ProfitUtils.cropCount).setChildOf(this));
79-
stats.add(new Stat("https://static.wikia.nocookie.net/hypixel-skyblock/images/7/70/Enchanted_Carrot.png").bind(ProfitUtils.cropCount).setChildOf(this));
80-
stats.add(new Stat("https://static.wikia.nocookie.net/hypixel-skyblock/images/8/82/Enchanted_Baked_Potato.png").bind(ProfitUtils.cropCount).setChildOf(this));
81-
stats.add(new Stat("https://static.wikia.nocookie.net/hypixel-skyblock/images/7/7c/Enchanted_Hay_Bale").bind(ProfitUtils.cropCount).setChildOf(this));
82-
stats.add(new Stat("https://static.wikia.nocookie.net/hypixel-skyblock/images/e/e5/Enchanted_Red_Mushroom.png").bind(ProfitUtils.redMushroomCount).setChildOf(this));
83-
stats.add(new Stat("https://static.wikia.nocookie.net/hypixel-skyblock/images/6/6a/Enchanted_Brown_Mushroom.png").bind(ProfitUtils.brownMushroomCount).setChildOf(this));
84-
stats.add(new Stat("https://i.ibb.co/0YCYCnX/newton-nether-warts-hoe-tier-2.png").bind(ProfitUtils.counter).setChildOf(this));
85-
stats.add(new Stat("https://i.ibb.co/t3L9FHw/runtime.png").bind(ProfitUtils.runtime).setChildOf(this));
76+
stats.add(new Stat("profit.png").bind(ProfitUtils.profit).setChildOf(this));
77+
stats.add(new Stat("profithr.png").bind(ProfitUtils.profitHr).setChildOf(this));
78+
stats.add(new Stat("mnw.png").bind(ProfitUtils.cropCount).setChildOf(this));
79+
stats.add(new Stat("ecarrot.png").bind(ProfitUtils.cropCount).setChildOf(this));
80+
stats.add(new Stat("epotato.png").bind(ProfitUtils.cropCount).setChildOf(this));
81+
stats.add(new Stat("ehaybale.png").bind(ProfitUtils.cropCount).setChildOf(this));
82+
stats.add(new Stat("ecane.png").bind(ProfitUtils.brownMushroomCount).setChildOf(this));
83+
stats.add(new Stat("eredmushroom.png").bind(ProfitUtils.redMushroomCount).setChildOf(this));
84+
stats.add(new Stat("ebrownmushroom.png").bind(ProfitUtils.brownMushroomCount).setChildOf(this));
85+
stats.add(new Stat("hoe.png").bind(ProfitUtils.counter).setChildOf(this));
86+
stats.add(new Stat("clock_00.png").bind(ProfitUtils.runtime).setChildOf(this));
8687
}
8788
}
8889

@@ -94,16 +95,14 @@ public Stat(String iconURL) {
9495
.setWidth(new RelativeConstraint(1f))
9596
.setColor(new Color(36, 37, 39, 85));
9697

97-
try {
98-
UIImage.ofURL(new URL(iconURL))
99-
.setX(new PixelConstraint(5))
100-
.setY(new CenterConstraint())
101-
.setHeight(new PixelConstraint(15))
102-
.setWidth(new PixelConstraint(15))
103-
.setChildOf(this);
104-
} catch (MalformedURLException e) {
105-
e.printStackTrace();
106-
}
98+
String path = "/assets/farmhelper/textures/gui/";
99+
100+
UIImage.ofResource(path + iconURL)
101+
.setX(new PixelConstraint(5))
102+
.setY(new CenterConstraint())
103+
.setHeight(new PixelConstraint(15))
104+
.setWidth(new PixelConstraint(15))
105+
.setChildOf(this);
107106

108107
displayString = new UIText("").setTextScale(new PixelConstraint(0.9f))
109108
.setColor(new Color(249, 249, 249))
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package com.jelly.farmhelper.gui;
2+
3+
import com.jelly.farmhelper.FarmHelper;
4+
import com.jelly.farmhelper.config.interfaces.FarmConfig;
5+
import com.jelly.farmhelper.config.interfaces.ProfitCalculatorConfig;
6+
import com.jelly.farmhelper.world.GameState;
7+
import gg.essential.elementa.UIComponent;
8+
import gg.essential.elementa.components.Window;
9+
import net.minecraft.client.Minecraft;
10+
import net.minecraftforge.client.event.RenderGameOverlayEvent;
11+
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
12+
import net.minecraftforge.fml.relauncher.Side;
13+
import net.minecraftforge.fml.relauncher.SideOnly;
14+
15+
public class Render {
16+
private final Minecraft mc = Minecraft.getMinecraft();
17+
private final Window window;
18+
private final ProfitGUI profitGUI;
19+
public Render() {
20+
window = new Window();
21+
profitGUI = new ProfitGUI(window);
22+
}
23+
24+
@SideOnly(Side.CLIENT)
25+
@SubscribeEvent
26+
public void render(RenderGameOverlayEvent event) {
27+
if (mc.theWorld != null && mc.thePlayer != null && ProfitCalculatorConfig.profitCalculator && event.type == RenderGameOverlayEvent.ElementType.TEXT) {
28+
profitGUI.stats.forEach(UIComponent::hide);
29+
if (ProfitCalculatorConfig.runtime) profitGUI.stats.get(10).unhide(true);
30+
if (ProfitCalculatorConfig.counter) profitGUI.stats.get(9).unhide(true);
31+
if (ProfitCalculatorConfig.mushroomCount) {
32+
profitGUI.stats.get(8).unhide(true);
33+
profitGUI.stats.get(7).unhide(true);
34+
}
35+
if (ProfitCalculatorConfig.itemCount) {
36+
switch (FarmConfig.cropType) {
37+
case NETHERWART:
38+
profitGUI.stats.get(2).unhide(true);
39+
break;
40+
case CARROT:
41+
profitGUI.stats.get(3).unhide(true);
42+
break;
43+
case POTATO:
44+
profitGUI.stats.get(4).unhide(true);
45+
break;
46+
case WHEAT:
47+
profitGUI.stats.get(5).unhide(true);
48+
break;
49+
case SUGARCANE:
50+
profitGUI.stats.get(6).unhide(true);
51+
break;
52+
}
53+
}
54+
if (ProfitCalculatorConfig.profitHour) profitGUI.stats.get(1).unhide(true);
55+
if (ProfitCalculatorConfig.totalProfit) profitGUI.stats.get(0).unhide(true);
56+
57+
//UGraphics.enableAlpha();
58+
window.draw();
59+
window.drawFloatingComponents();
60+
//UGraphics.disableAlpha();
61+
}
62+
}
63+
}

src/main/java/com/jelly/farmhelper/gui/menus/FarmMenu.java

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ public FarmMenu() {
2727
.setChildOf(this);
2828

2929

30-
cropList.add(new ImageBox(new PixelConstraint(10), new PixelConstraint(10), "https://static.wikia.nocookie.net/minecraft/images/6/63/Carrot_Updated.png", cropList, 0L, "cropType").setChildOf(selector));
31-
cropList.add(new ImageBox(new SiblingConstraint(10), new PixelConstraint(10), "https://static.wikia.nocookie.net/minecraft_gamepedia/images/c/c0/Nether_Wart_%28item%29_JE1.png", cropList, 1L, "cropType").setChildOf(selector));
32-
cropList.add(new ImageBox(new PixelConstraint(10), new SiblingConstraint(10), "https://static.wikia.nocookie.net/minecraft_gamepedia/images/c/c1/Potato_JE3_BE2.png", cropList, 2L, "cropType").setChildOf(selector));
33-
cropList.add( new ImageBox(new SiblingConstraint(10), new CramSiblingConstraint(10), "https://static.wikia.nocookie.net/minecraft_gamepedia/images/7/75/Wheat_JE2_BE2.png", cropList, 3L, "cropType").setChildOf(selector));
34-
cropList.add( new ImageBox(new PixelConstraint(80), new SiblingConstraint(10), "https://static.wikia.nocookie.net/hypixel-skyblock/images/6/67/Sugar_Cane.png/revision/latest?cb=20210615232455", cropList, 4L, "cropType").setChildOf(selector));
30+
cropList.add(new ImageBox(new PixelConstraint(10), new PixelConstraint(10), 60f, "carrot.png", cropList, 0L, "cropType").setChildOf(selector));
31+
cropList.add(new ImageBox(new SiblingConstraint(10), new PixelConstraint(10), 60f, "netherwart.png", cropList, 1L, "cropType").setChildOf(selector));
32+
cropList.add(new ImageBox(new PixelConstraint(10), new SiblingConstraint(10), 60f, "potato.png", cropList, 2L, "cropType").setChildOf(selector));
33+
cropList.add(new ImageBox(new SiblingConstraint(10), new CramSiblingConstraint(10), 60f, "wheat.png", cropList, 3L, "cropType").setChildOf(selector));
34+
cropList.add(new ImageBox(new PixelConstraint(10), new SiblingConstraint(10), 130f, "cane.png", cropList, 4L, "cropType").setChildOf(selector));
3535

36-
farmList.add(new ImageBox(new PixelConstraint(10), new CramSiblingConstraint(10), "https://i.ibb.co/6nFDfRt/layered.png", farmList, 0L, "farmType").setChildOf(selector));
37-
farmList.add(new ImageBox(new SiblingConstraint(10), new CramSiblingConstraint(10), "https://i.ibb.co/hLG9g3X/vertical.png", farmList, 1L, "farmType").setChildOf(selector));
36+
farmList.add(new ImageBox(new PixelConstraint(10), new CramSiblingConstraint(10), 60f, "layered.png", farmList, 0L, "farmType").setChildOf(selector));
37+
farmList.add(new ImageBox(new PixelConstraint(80), new CramSiblingConstraint(10), 60f, "vertical.png", farmList, 1L, "farmType").setChildOf(selector));
3838

3939
new UIText("Layered")
4040
.setX(new CenterConstraint())
@@ -55,15 +55,15 @@ class ImageBox extends UIBlock {
5555
private Color fillColor;
5656
private ArrayList<UIComponent> components;
5757
private String configName;
58-
public ImageBox(XConstraint x, YConstraint y, String ImageURL, ArrayList<UIComponent> components, Long value, String configName) {
58+
public ImageBox(XConstraint x, YConstraint y, float width ,String ImageURL, ArrayList<UIComponent> components, Long value, String configName) {
5959
// Check if already marked
6060
selected = (long) FarmHelperConfig.get(configName) == value;
6161
this.components = components;
6262
this.configName = configName;
6363
fillColor = selected ? new Color(175, 36, 36) : new Color(30, 31, 32);
6464
this.setX(x)
6565
.setY(y)
66-
.setWidth(new PixelConstraint(60))
66+
.setWidth(new PixelConstraint(width))
6767
.setHeight(new PixelConstraint(60))
6868
.setColor(fillColor)
6969
.onMouseClick((component, uiClickEvent) -> {
@@ -79,19 +79,17 @@ public ImageBox(XConstraint x, YConstraint y, String ImageURL, ArrayList<UICompo
7979
.setX(new CenterConstraint())
8080
.setY(new CenterConstraint())
8181
.setHeight(new RelativeConstraint(0.95f))
82-
.setWidth(new RelativeConstraint(0.95f))
82+
.setWidth(new PixelConstraint(width - 3))
8383
.setChildOf(this);
8484

85-
try {
86-
UIImage.ofURL(new URL(ImageURL))
87-
.setX(new CenterConstraint())
88-
.setY(new CenterConstraint())
89-
.setHeight(new RelativeConstraint(0.5f))
90-
.setWidth(new RelativeConstraint(0.5f))
91-
.setChildOf(this);
92-
} catch (MalformedURLException e) {
93-
e.printStackTrace();
94-
}
85+
String path = "/assets/farmhelper/textures/gui/";
86+
87+
UIImage.ofResource(path + ImageURL)
88+
.setX(new CenterConstraint())
89+
.setY(new CenterConstraint())
90+
.setHeight(new RelativeConstraint(0.5f))
91+
.setWidth(new AspectConstraint())
92+
.setChildOf(this);
9593
}
9694

9795

0 commit comments

Comments
 (0)