Skip to content
20 changes: 11 additions & 9 deletions src/main/java/com/jelly/farmhelperv2/config/FarmHelperConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,16 @@ public class FarmHelperConfig extends Config {
"S Shape - Pumpkin/Melon Melongkingde", // 2
"S Shape - Pumpkin/Melon Default Plot", // 3
"S Shape - Sugar Cane", // 4
"S Shape - Cactus", // 5
"S Shape - Cactus SunTzu Black Cat", // 6
"S Shape - Cocoa Beans", // 7
"S Shape - Cocoa Beans (With Trapdoors)", // 8
"S Shape - Cocoa Beans (Left/Right)", // 9
"S Shape - Mushroom (45°)", // 10
"S Shape - Mushroom (30° with rotations)", // 11
"S Shape - Mushroom SDS", // 12
"Circle - Crops (Wheat, Carrot, Potato, NW)" // 13
"S Shape - Sugar Cane Melonkingde", // 5
"S Shape - Cactus", // 6
"S Shape - Cactus SunTzu Black Cat", // 7
"S Shape - Cocoa Beans", // 8
"S Shape - Cocoa Beans (With Trapdoors)", // 9
"S Shape - Cocoa Beans (Left/Right)", // 10
"S Shape - Mushroom (45°)", // 11
"S Shape - Mushroom (30° with rotations)", // 12
"S Shape - Mushroom SDS", // 13
"Circle - Crops (Wheat, Carrot, Potato, NW)" // 14
}, size = 2
)
public static int macroType = 0;
Expand Down Expand Up @@ -2400,6 +2401,7 @@ public enum MacroEnum {
S_PUMPKIN_MELON_MELONGKINGDE,
S_PUMPKIN_MELON_DEFAULT_PLOT,
S_SUGAR_CANE,
S_SUGAR_CANE_MELONKINGDE,
S_CACTUS,
S_CACTUS_SUNTZU,
S_COCOA_BEANS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ public <T extends AbstractMacro> T getMacro() {
return Macros.S_SHAPE_MELON_PUMPKIN_DEFAULT_MACRO.getMacro();
case S_SUGAR_CANE:
return Macros.S_SHAPE_SUGARCANE_MACRO.getMacro();
case S_SUGAR_CANE_MELONKINGDE:
return Macros.S_SHAPE_SUGARCANE_MELONKINGDE_MACRO.getMacro();
case S_COCOA_BEANS:
case S_COCOA_BEANS_TRAPDOORS:
return Macros.S_SHAPE_COCOA_BEAN_MACRO.getMacro();
Expand Down Expand Up @@ -535,6 +537,7 @@ public enum Macros {
S_SHAPE_MUSHROOM_MACRO(SShapeMushroomMacro.class),
S_SHAPE_COCOA_BEAN_MACRO(SShapeCocoaBeanMacro.class),
S_SHAPE_SUGARCANE_MACRO(SShapeSugarcaneMacro.class),
S_SHAPE_SUGARCANE_MELONKINGDE_MACRO(SShapeSugarcaneMelonkingdeMacro.class),
S_SHAPE_VERTICAL_CROP_MACRO(SShapeVerticalCropMacro.class),
S_SHAPE_MELON_PUMPKIN_DEFAULT_MACRO(SShapeMelonPumpkinDefaultMacro.class),
S_SHAPE_MUSHROOM_SDS(SShapeMushroomSDSMacro.class),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
package com.jelly.farmhelperv2.macro.impl;

import com.jelly.farmhelperv2.config.FarmHelperConfig;
import com.jelly.farmhelperv2.handler.MacroHandler;
import com.jelly.farmhelperv2.macro.AbstractMacro;
import com.jelly.farmhelperv2.util.AngleUtils;
import com.jelly.farmhelperv2.util.BlockUtils;
import com.jelly.farmhelperv2.util.KeyBindUtils;
import com.jelly.farmhelperv2.util.LogUtils;
import com.jelly.farmhelperv2.util.helper.Rotation;
import com.jelly.farmhelperv2.util.helper.RotationConfiguration;
import net.minecraft.block.BlockDirt;
import net.minecraft.block.BlockReed;
import net.minecraft.block.BlockTrapDoor;

import java.util.Optional;

public class SShapeSugarcaneMelonkingdeMacro extends AbstractMacro {

public double rowStartX = 0;
public double rowStartZ = 0;

@Override
public void updateState() {
if (currentState == null)
changeState(State.NONE);
switch (currentState) {
case W: {
if (hasWall(0, 1, getYaw() - 45f) &&
hasWall(0, 1, getYaw() + 45f)) {

changeState(State.A);
}
break;
}
case A: {
if (hasWall(0, 1, getYaw() - 45f) &&
hasWall(0, -1, getYaw() + 45f)) {

changeState(State.W);
}
break;
}
case NONE: {
changeState(calculateDirection());
break;
}
default: {
LogUtils.sendDebug("This shouldn't happen, but it did...");
changeState(State.NONE);
}
}
}

@Override
public void invokeState() {
if (currentState == null) return;
switch (currentState) {
case NONE:
break;
case A:
KeyBindUtils.holdThese(
mc.gameSettings.keyBindLeft,
mc.gameSettings.keyBindAttack
);
break;
case D:
KeyBindUtils.holdThese(
mc.gameSettings.keyBindRight,
mc.gameSettings.keyBindAttack
);
break;
case S:
KeyBindUtils.holdThese(
mc.gameSettings.keyBindBack,
mc.gameSettings.keyBindAttack
);
break;
case W:
KeyBindUtils.holdThese(
mc.gameSettings.keyBindForward,
mc.gameSettings.keyBindAttack
);
break;
case DROPPING:
if (mc.thePlayer.onGround && Math.abs(getLayerY() - mc.thePlayer.getPosition().getY()) <= 1.5) {
LogUtils.sendDebug("Dropping done, but didn't drop high enough to rotate!");
setLayerY(mc.thePlayer.getPosition().getY());
changeState(State.NONE);
}
break;
}
}

@Override
public void actionAfterTeleport() {
setLayerY(mc.thePlayer.getPosition().getY());
rowStartX = mc.thePlayer.posX;
rowStartZ = mc.thePlayer.posZ;
}

@Override
public void onEnable() {
super.onEnable();
if (!isPitchSet()) {
setPitch((float) (Math.random() * 1) - 0.5f); // -0.5 to 0.5
}
if (!isYawSet()) {
setYaw(AngleUtils.getClosestDiagonal());
setClosest90Deg(Optional.of(AngleUtils.getClosest(getYaw())));
}
rowStartX = mc.thePlayer.posX;
rowStartZ = mc.thePlayer.posZ;
if (MacroHandler.getInstance().isTeleporting()) return;
setRestoredState(false);
if (FarmHelperConfig.dontFixAfterWarping && Math.abs(getYaw() - AngleUtils.get360RotationYaw()) < 0.1) return;
getRotation().easeTo(
new RotationConfiguration(
new Rotation(getYaw(), getPitch()),
FarmHelperConfig.getRandomRotationTime(), null
).easeOutBack(!MacroHandler.getInstance().isResume())
);
}

@Override
public State calculateDirection() {
if (mc.theWorld.getBlockState(BlockUtils.getRelativeBlockPos(-1, 1, 0, getYaw() - 45f)).getBlock() instanceof BlockReed) {
return State.A;
}
return State.W;
}

boolean hasWall(int rightOffset, int frontOffset, float yaw) {
return mc.theWorld.getBlockState(BlockUtils.getRelativeBlockPos(rightOffset, 0, frontOffset, yaw)).getBlock() instanceof BlockTrapDoor || mc.theWorld.getBlockState(BlockUtils.getRelativeBlockPos(rightOffset, 0, frontOffset, yaw)).getBlock() instanceof BlockDirt;
}

}
2 changes: 1 addition & 1 deletion src/main/java/com/jelly/farmhelperv2/util/PlayerUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static FarmHelperConfig.CropEnum getFarmingCrop() {
if (MacroHandler.getInstance().getCurrentMacro().isPresent()) {
yaw = MacroHandler.getInstance().getCurrentMacro().get().getClosest90Deg().orElse(AngleUtils.getClosest());
} else {
if (FarmHelperConfig.getMacro() == FarmHelperConfig.MacroEnum.S_MUSHROOM || FarmHelperConfig.getMacro() == FarmHelperConfig.MacroEnum.S_SUGAR_CANE) {
if (FarmHelperConfig.getMacro() == FarmHelperConfig.MacroEnum.S_MUSHROOM || FarmHelperConfig.getMacro() == FarmHelperConfig.MacroEnum.S_SUGAR_CANE || FarmHelperConfig.getMacro() == FarmHelperConfig.MacroEnum.S_SUGAR_CANE_MELONKINGDE) {
yaw = AngleUtils.getClosestDiagonal();
} else {
yaw = AngleUtils.getClosest();
Expand Down