Skip to content

Commit

Permalink
Merge branch 'beta' into DetektRoundFive
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidArthurCole authored Oct 2, 2024
2 parents 67c14f1 + ab7b326 commit fdcb824
Show file tree
Hide file tree
Showing 26 changed files with 567 additions and 473 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@

import at.hannibal2.skyhanni.config.FeatureToggle;
import at.hannibal2.skyhanni.config.core.config.Position;
import at.hannibal2.skyhanni.features.garden.CropType;
import com.google.gson.annotations.Expose;
import io.github.notenoughupdates.moulconfig.annotations.Accordion;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDraggableList;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorInfoText;
import io.github.notenoughupdates.moulconfig.annotations.ConfigLink;
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;

import java.util.ArrayList;
import java.util.List;

public class FarmingLaneConfig {

@Expose
Expand Down Expand Up @@ -37,4 +42,11 @@ public class FarmingLaneConfig {
@FeatureToggle
public boolean cornerWaypoints = false;

@Expose
@ConfigOption(
name = "Ignored Crops",
desc = "Add the crops you wish to not setup a lane for."
)
@ConfigEditorDraggableList()
public List<CropType> ignoredCrops = new ArrayList<>();
}
51 changes: 50 additions & 1 deletion src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt
Original file line number Diff line number Diff line change
@@ -1,29 +1,44 @@
package at.hannibal2.skyhanni.data

import at.hannibal2.skyhanni.events.EntityMoveEvent
import at.hannibal2.skyhanni.events.IslandChangeEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.LorenzWarpEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.DelayedRun
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.RegexUtils.matches
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.getLorenzVec
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.client.Minecraft
import net.minecraft.entity.Entity
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.Duration.Companion.seconds

@SkyHanniModule
object EntityMovementData {

private val warpingPattern by RepoPattern.pattern(
"data.entity.warping",
"§7(?:Warping|Warping you to your SkyBlock island|Warping using transfer token|Finding player|Sending a visit request)\\.\\.\\."
"§7(?:Warping|Warping you to your SkyBlock island|Warping using transfer token|Finding player|Sending a visit request)\\.\\.\\.",
)

private var nextTeleport: OnNextTeleport? = null

fun onNextTeleport(island: IslandType, action: () -> Unit) {
nextTeleport = OnNextTeleport(island, action)
}

class OnNextTeleport(val island: IslandType, val action: () -> Unit) {
val startTime: SimpleTimeMark = SimpleTimeMark.now()
}

private val entityLocation = mutableMapOf<Entity, LorenzVec>()

fun addToTrack(entity: Entity) {
Expand All @@ -32,6 +47,40 @@ object EntityMovementData {
}
}

@SubscribeEvent
fun onIslandChange(event: IslandChangeEvent) {
val nextData = nextTeleport ?: return
if (nextData.island != event.newIsland) return
val passedSince = nextData.startTime.passedSince()
if (passedSince > 5.seconds) {
nextTeleport = null
return
}

DelayedRun.runDelayed(100.milliseconds) {
nextData.action()
}
nextTeleport = null
}

@SubscribeEvent
fun onPlayerMove(event: EntityMoveEvent) {
if (!LorenzUtils.inSkyBlock || event.entity != Minecraft.getMinecraft().thePlayer) return

val nextData = nextTeleport ?: return

val passedSince = nextData.startTime.passedSince()
if (passedSince > 5.seconds) {
nextTeleport = null
return
}
if (passedSince > 50.milliseconds && nextData.island.isInIsland()) {
nextData.action()
nextTeleport = null
return
}
}

@SubscribeEvent
fun onTick(event: LorenzTickEvent) {
if (!LorenzUtils.inSkyBlock) return
Expand Down
Loading

0 comments on commit fdcb824

Please sign in to comment.