Skip to content
This repository has been archived by the owner on Jul 20, 2024. It is now read-only.

Commit

Permalink
First pathfinder
Browse files Browse the repository at this point in the history
  • Loading branch information
Osama committed Apr 9, 2024
1 parent 13585aa commit a98cbf1
Show file tree
Hide file tree
Showing 33 changed files with 1,411 additions and 155 deletions.
124 changes: 64 additions & 60 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,96 +1,100 @@
plugins {
kotlin("jvm") version "1.9.0"
id("cc.polyfrost.loom") version "0.10.0.5"
id("dev.architectury.architectury-pack200") version "0.1.3"
id("com.github.johnrengelman.shadow") version "8.1.1"
id("net.kyori.blossom") version "1.3.1"
kotlin("jvm") version "1.9.0"
id("cc.polyfrost.loom") version "0.10.0.5"
id("dev.architectury.architectury-pack200") version "0.1.3"
id("com.github.johnrengelman.shadow") version "8.1.1"
id("net.kyori.blossom") version "1.3.1"
}

group = "dev.macrohq"
version = "1.0.0"

repositories {
maven("https://repo.polyfrost.cc/releases")
maven("https://repo.spongepowered.org/repository/maven-public")
maven("https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1")
maven("https://repo.polyfrost.cc/releases")
maven("https://repo.spongepowered.org/repository/maven-public")
maven("https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1")
}

val embed: Configuration by configurations.creating
configurations.implementation.get().extendsFrom(embed)

dependencies {
minecraft("com.mojang:minecraft:1.8.9")
mappings("de.oceanlabs.mcp:mcp_stable:22-1.8.9")
forge("net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9")
compileOnly("cc.polyfrost:oneconfig-1.8.9-forge:0.2.0-alpha+")
embed("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-beta+")
compileOnly("org.spongepowered:mixin:0.8.5-SNAPSHOT")
annotationProcessor("org.spongepowered:mixin:0.8.5-SNAPSHOT:processor")
modRuntimeOnly("me.djtheredstoner:DevAuth-forge-legacy:1.1.2")
embed("com.squareup.okhttp3:okhttp:3.14.9")
minecraft("com.mojang:minecraft:1.8.9")
mappings("de.oceanlabs.mcp:mcp_stable:22-1.8.9")
forge("net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9")
compileOnly("cc.polyfrost:oneconfig-1.8.9-forge:0.2.0-alpha+")
embed("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-beta+")
compileOnly("org.spongepowered:mixin:0.8.5-SNAPSHOT")
annotationProcessor("org.spongepowered:mixin:0.8.5-SNAPSHOT:processor")
modRuntimeOnly("me.djtheredstoner:DevAuth-forge-legacy:1.1.2")
embed("com.squareup.okhttp3:okhttp:3.14.9")
implementation("it.unimi.dsi:fastutil:8.2.1")
}

blossom {
replaceToken("%%VERSION%%", version)
replaceToken("%%VERSION%%", version)
}

loom {
runConfigs {
named("client") {
ideConfigGenerated(true)
}
runConfigs {
named("client") {
ideConfigGenerated(true)
}
}

launchConfigs {
getByName("client") {
arg("--tweakClass", "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker")
property("devauth.enabled", "false")
}
launchConfigs {
getByName("client") {
arg("--tweakClass", "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker")
property("devauth.enabled", "false")
}
}

forge {
pack200Provider.set(dev.architectury.pack200.java.Pack200Adapter())
mixinConfig("mixins.swiftslayer.json")
}
forge {
pack200Provider.set(dev.architectury.pack200.java.Pack200Adapter())
mixinConfig("mixins.swiftslayer.json")
}
}

tasks {
jar {
manifest.attributes(
mapOf(
"ModSide" to "CLIENT",
"TweakOrder" to "0",
"ForceLoadAsMod" to true,
"TweakClass" to "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker",
"MixinConfigs" to "mixins.swiftslayer.json"
)
)
dependsOn(shadowJar)
}
jar {
manifest.attributes(
mapOf(
"ModSide" to "CLIENT",
"TweakOrder" to "0",
"ForceLoadAsMod" to true,
"TweakClass" to "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker",
"MixinConfigs" to "mixins.swiftslayer.json"
)
)
dependsOn(shadowJar)
}

remapJar {
input.set(shadowJar.get().archiveFile)
archiveClassifier.set("")
}
remapJar {
input.set(shadowJar.get().archiveFile)
archiveClassifier.set("")
}

shadowJar {
isEnableRelocation = true
relocationPrefix = "dev.macrohq.swiftslayer.relocate"
relocate("cc.polyfrost", "cc.polyfrost") // this is so oneconfig doesn't get relocated, causing the tweaker to not be found
configurations = listOf(embed)
}
shadowJar {
isEnableRelocation = true
relocationPrefix = "dev.macrohq.swiftslayer.relocate"
relocate(
"cc.polyfrost",
"cc.polyfrost"
) // this is so oneconfig doesn't get relocated, causing the tweaker to not be found
configurations = listOf(embed)
}

processResources {
inputs.property("version", version)
filesMatching(listOf("mcmod.info")) {
expand(mapOf("version" to version))
}
processResources {
inputs.property("version", version)
filesMatching(listOf("mcmod.info")) {
expand(mapOf("version" to version))
}
}
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

java.toolchain.languageVersion = JavaLanguageVersion.of(8)
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package dev.macrohq.swiftslayer.mixin.world;

import dev.macrohq.swiftslayer.util.accessor.IChunkProviderClient;
import net.minecraft.client.multiplayer.ChunkProviderClient;
import net.minecraft.util.LongHashMap;
import net.minecraft.world.chunk.Chunk;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

import java.util.List;

@Mixin(ChunkProviderClient.class)
public class MixinChunkProviderClient implements IChunkProviderClient {

@Shadow
private LongHashMap<Chunk> chunkMapping;

@Shadow
private List<Chunk> chunkListing;

@Override
public LongHashMap<Chunk> chunkMapping() {
return this.chunkMapping;
}

@Override
public List<Chunk> chunkListing() {
return this.chunkListing;
}
}
113 changes: 62 additions & 51 deletions src/main/kotlin/dev/macrohq/swiftslayer/SwiftSlayer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@ import dev.macrohq.swiftslayer.command.PathfindTest
import dev.macrohq.swiftslayer.command.SwiftSlayerCommand
import dev.macrohq.swiftslayer.command.TestCommand
import dev.macrohq.swiftslayer.config.SwiftSlayerConfig
import dev.macrohq.swiftslayer.event.GameEventHandler
import dev.macrohq.swiftslayer.feature.*
import dev.macrohq.swiftslayer.macro.EndermanBossKiller
import dev.macrohq.swiftslayer.macro.GenericBossKiller
import dev.macrohq.swiftslayer.macro.MacroManager
import dev.macrohq.swiftslayer.macro.MobKiller
import dev.macrohq.swiftslayer.macro.Revenant
import dev.macrohq.swiftslayer.pathfinder.helper.BlockStateAccessor
import dev.macrohq.swiftslayer.pathfinder.helper.player.IPlayerContext
import dev.macrohq.swiftslayer.pathfinder.helper.player.PlayerContext
import dev.macrohq.swiftslayer.pathfinding.PathExecutor
import dev.macrohq.swiftslayer.util.KeyBindUtil
import dev.macrohq.swiftslayer.util.RenderUtil
import dev.macrohq.swiftslayer.util.RotationUtil
import net.minecraft.client.Minecraft
import net.minecraft.util.BlockPos
import net.minecraftforge.client.event.RenderWorldLastEvent
import net.minecraftforge.common.MinecraftForge
Expand All @@ -38,62 +43,68 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

@Mod(modid = "swiftslayer", name = "SwiftSlayer", version = "%%VERSION%%")
class SwiftSlayer {
companion object {
@Mod.Instance("swiftslayer")
lateinit var instance: SwiftSlayer private set
}
companion object {
@Mod.Instance("swiftslayer")
lateinit var instance: SwiftSlayer private set
}

lateinit var pathExecutor: PathExecutor private set
lateinit var config: SwiftSlayerConfig private set
lateinit var mobKiller: MobKiller private set
lateinit var endermanBossKiller: EndermanBossKiller private set
lateinit var autoBatphone: AutoBatphone private set
lateinit var macroManager: MacroManager private set
lateinit var genericBossKiller: GenericBossKiller private set
lateinit var revenant: Revenant private set
lateinit var tracker: Tracker private set
var removeLater: BlockPos? = null
lateinit var pathExecutor: PathExecutor private set
lateinit var config: SwiftSlayerConfig private set
lateinit var mobKiller: MobKiller private set
lateinit var endermanBossKiller: EndermanBossKiller private set
lateinit var autoBatphone: AutoBatphone private set
lateinit var macroManager: MacroManager private set
lateinit var genericBossKiller: GenericBossKiller private set
lateinit var revenant: Revenant private set
lateinit var tracker: Tracker private set
var removeLater: BlockPos? = null

@Mod.EventHandler
fun init(event: FMLInitializationEvent) {
config = SwiftSlayerConfig()
pathExecutor = PathExecutor()
mobKiller = MobKiller()
endermanBossKiller = EndermanBossKiller()
autoBatphone = AutoBatphone()
macroManager = MacroManager()
genericBossKiller = GenericBossKiller()
revenant = Revenant()
tracker = Tracker()
MinecraftForge.EVENT_BUS.register(this)
MinecraftForge.EVENT_BUS.register(pathExecutor)
MinecraftForge.EVENT_BUS.register(mobKiller)
MinecraftForge.EVENT_BUS.register(autoBatphone)
MinecraftForge.EVENT_BUS.register(macroManager)
MinecraftForge.EVENT_BUS.register(genericBossKiller)
MinecraftForge.EVENT_BUS.register(Failsafe())
MinecraftForge.EVENT_BUS.register(revenant)
MinecraftForge.EVENT_BUS.register(tracker)
MinecraftForge.EVENT_BUS.register(SupportItem())
CommandManager.register(PathfindTest())
CommandManager.register(SwiftSlayerCommand())
@Mod.EventHandler
fun init(event: FMLInitializationEvent) {
config = SwiftSlayerConfig()
pathExecutor = PathExecutor()
mobKiller = MobKiller()
endermanBossKiller = EndermanBossKiller()
autoBatphone = AutoBatphone()
macroManager = MacroManager()
genericBossKiller = GenericBossKiller()
revenant = Revenant()
tracker = Tracker()
MinecraftForge.EVENT_BUS.register(this)
MinecraftForge.EVENT_BUS.register(pathExecutor)
MinecraftForge.EVENT_BUS.register(mobKiller)
MinecraftForge.EVENT_BUS.register(autoBatphone)
MinecraftForge.EVENT_BUS.register(macroManager)
MinecraftForge.EVENT_BUS.register(genericBossKiller)
MinecraftForge.EVENT_BUS.register(Failsafe())
MinecraftForge.EVENT_BUS.register(revenant)
MinecraftForge.EVENT_BUS.register(tracker)
MinecraftForge.EVENT_BUS.register(SupportItem())
CommandManager.register(PathfindTest())
CommandManager.register(SwiftSlayerCommand())

val cmd = TestCommand()
CommandManager.register(cmd)
MinecraftForge.EVENT_BUS.register(cmd)
val cmd = TestCommand()
CommandManager.register(cmd)
MinecraftForge.EVENT_BUS.register(cmd)

// New Structure
FeatureManager.getInstance().loadFeatures().forEach(MinecraftForge.EVENT_BUS::register)
// New Structure
FeatureManager.getInstance().loadFeatures().forEach(MinecraftForge.EVENT_BUS::register)
MinecraftForge.EVENT_BUS.register(GameEventHandler(this))

}
}

fun isTrackerInitialized() = ::tracker.isInitialized
fun isTrackerInitialized() = ::tracker.isInitialized

@SubscribeEvent
fun onRenderWorldLast(event: RenderWorldLastEvent) {
// this is here because im not sure if objects can have events cuz they are kinda static
RotationUtil.onRenderWorldLast()
RenderUtil.onRenderWorldLast(event)
KeyBindUtil.onRenderWorldLast()
}
@SubscribeEvent
fun onRenderWorldLast(event: RenderWorldLastEvent) {
// this is here because im not sure if objects can have events cuz they are kinda static
RotationUtil.onRenderWorldLast()
RenderUtil.onRenderWorldLast(event)
KeyBindUtil.onRenderWorldLast()
}

// Hellow
val mc: Minecraft = Minecraft.getMinecraft()
val playerContext: IPlayerContext = PlayerContext(this, mc)
var bsa: BlockStateAccessor? = null
}
Loading

0 comments on commit a98cbf1

Please sign in to comment.