diff options
78 files changed, 613 insertions, 700 deletions
diff --git a/build.gradle b/build.gradle index b266c3c2..1790be3e 100644 --- a/build.gradle +++ b/build.gradle @@ -16,32 +16,14 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -buildscript { - ext.kotlin_version = "1.5.0-RC" - - repositories { - gradlePluginPortal() - mavenCentral() - maven { url "https://jitpack.io" } - maven { - name = "sonatype" - url = "https://oss.sonatype.org/content/repositories/snapshots" - } - maven { url "https://maven.minecraftforge.net/" } - } - - dependencies { - classpath "com.github.jengelman.gradle.plugins:shadow:6.1.0" - classpath "com.github.Skytils:ForgeGradle:FG_2.1-SNAPSHOT" - classpath "com.github.Skytils:mixingradle:d75e32e743" - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } +plugins { + id "net.minecraftforge.gradle.forge" version "8f14deb" + id "com.github.johnrengelman.shadow" version "6.1.0" + id "org.jetbrains.kotlin.jvm" version "1.5.0" + id "org.spongepowered.mixin" version "d75e32e743" } -apply plugin: "kotlin" -apply plugin: "com.github.johnrengelman.shadow" -apply plugin: "net.minecraftforge.gradle.forge" -apply plugin: "org.spongepowered.mixin" +ext.kotlin_version = "1.5.0-RC" version = "1.0-pre2" group = "skytils.skytilsmod" @@ -65,6 +47,7 @@ minecraft { runDir = "run" mappings = "stable_22" makeObfSourceJar = false + gitVersion = false clientJvmArgs += "-Dfml.coreMods.load=skytils.skytilsmod.tweaker.FMLLoadingPlugin" clientRunArgs += "--mixin mixins.skytils.json" } @@ -76,26 +59,6 @@ repositories { } dependencies { - // you may put jars on which you depend on in ./libs - // or you may define them like so.. - //compile "some.group:artifact:version:classifier" - //compile "some.group:artifact:version" - - // real examples - //compile "com.mod-buildcraft:buildcraft:6.0.8:dev" // adds buildcraft to the dev env - //compile "com.googlecode.efficient-java-matrix-library:ejml:0.24" // adds ejml to the dev env - - // the "provided" configuration is for optional dependencies that exist at compile-time but might not at runtime. - //provided "com.mod-buildcraft:buildcraft:6.0.8:dev" - - // the deobf configurations: "deobfCompile" and "deobfProvided" are the same as the normal compile and provided, - // except that these dependencies get remapped to your current MCP mappings - //deobfCompile "com.mod-buildcraft:buildcraft:6.0.8:dev" - //deobfProvided "com.mod-buildcraft:buildcraft:6.0.8:dev" - - // for more info... - // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html - // http://www.gradle.org/docs/current/userguide/dependency_management.html implementation("org.spongepowered:mixin:0.7.11-SNAPSHOT") { transitive = false exclude module: "guava" @@ -119,9 +82,6 @@ dependencies { } jar { - - duplicatesStrategy = DuplicatesStrategy.EXCLUDE - manifest.attributes( "Main-Class": "SkytilsInstallerFrame", "FMLCorePlugin": "skytils.skytilsmod.tweaker.FMLLoadingPlugin", @@ -196,7 +156,7 @@ reobf { sourceSets { main { - //ext.refMap = "mixins.skytils.refmap.json" + ext.refMap = "mixins.skytils.refmap.json" } } diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 00000000..b8792e2f --- /dev/null +++ b/settings.gradle @@ -0,0 +1,26 @@ +pluginManagement { + repositories { + gradlePluginPortal() + mavenCentral() + maven { + name = "sonatype" + url = "https://oss.sonatype.org/content/repositories/snapshots" + } + maven { url "https://maven.minecraftforge.net/" } + maven { url "https://jitpack.io" } + } + resolutionStrategy { + eachPlugin { + switch (requested.id.id) { + case "net.minecraftforge.gradle.forge": + useModule("com.github.Skytils:ForgeGradle:${requested.version}") + break + case "org.spongepowered.mixin": + useModule("com.github.Skytils:mixingradle:${requested.version}") + break + } + } + } +} + +rootProject.name = "SkytilsMod"
\ No newline at end of file diff --git a/src/main/java/skytils/skytilsmod/mixins/MixinMinecraft.java b/src/main/java/skytils/skytilsmod/mixins/MixinMinecraft.java index f259ba1f..091b3110 100644 --- a/src/main/java/skytils/skytilsmod/mixins/MixinMinecraft.java +++ b/src/main/java/skytils/skytilsmod/mixins/MixinMinecraft.java @@ -107,14 +107,17 @@ public abstract class MixinMinecraft { File file = new File(new File(mcDataDir, "config"), "vigilance.toml"); if (!file.exists()) { try { - HttpGet request = new HttpGet(new URL(Skytils.config.dataURL + "files/vigilance.toml").toURI()); + HttpGet request = new HttpGet(new URL(Skytils.config.getDataURL() + "files/vigilance.toml").toURI()); request.setProtocolVersion(HttpVersion.HTTP_1_1); HttpResponse response = APIUtil.INSTANCE.getClient().execute(request); if (response.getStatusLine().getStatusCode() == 200) { - file.createNewFile(); - response.getEntity().writeTo(new FileOutputStream(file)); + if (file.createNewFile()) { + response.getEntity().writeTo(new FileOutputStream(file)); + } else { + throw new IllegalStateException("Failed to create file"); + } } - } catch (URISyntaxException | IOException e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/src/main/kotlin/skytils/skytilsmod/Skytils.kt b/src/main/kotlin/skytils/skytilsmod/Skytils.kt index 69432904..d9b75f6a 100644 --- a/src/main/kotlin/skytils/skytilsmod/Skytils.kt +++ b/src/main/kotlin/skytils/skytilsmod/Skytils.kt @@ -104,14 +104,13 @@ class Skytils { @JvmField val mc: Minecraft = Minecraft.getMinecraft() - @JvmField - val config = Config() + lateinit var config: Config @JvmField val modDir = File(File(mc.mcDataDir, "config"), "skytils") @JvmStatic - lateinit var GUIMANAGER: GuiManager + lateinit var guiManager: GuiManager var ticks = 0 @JvmField @@ -152,17 +151,18 @@ class Skytils { } if (!modDir.exists()) modDir.mkdirs() File(modDir, "trackers").mkdirs() - GUIMANAGER = GuiManager() + guiManager = GuiManager() jarFile = event.sourceFile } @Mod.EventHandler fun init(event: FMLInitializationEvent) { + config = Config() config.preload() MinecraftForge.EVENT_BUS.register(this) MinecraftForge.EVENT_BUS.register(ChatListener()) - MinecraftForge.EVENT_BUS.register(GUIMANAGER) + MinecraftForge.EVENT_BUS.register(guiManager) MinecraftForge.EVENT_BUS.register(MayorInfo()) MinecraftForge.EVENT_BUS.register(SBInfo) MinecraftForge.EVENT_BUS.register(SoundQueue) @@ -301,17 +301,17 @@ class Skytils { @SubscribeEvent fun onGuiInitPost(event: GuiScreenEvent.InitGuiEvent.Post) { if (config.configButtonOnPause && event.gui is GuiIngameMenu) { - var x = event.gui.width - 105 - var x2 = x + 100 + val x = event.gui.width - 105 + val x2 = x + 100 var y = event.gui.height - 22 var y2 = y + 20 val sorted = Lists.newArrayList(event.buttonList) sorted.sortWith { a, b -> b.yPosition + b.height - a.yPosition + a.height } for (button in sorted) { - var otherX = button.xPosition - var otherX2 = button.xPosition + button.width - var otherY = button.yPosition - var otherY2 = button.yPosition + button.height + val otherX = button.xPosition + val otherX2 = button.xPosition + button.width + val otherY = button.yPosition + val otherY2 = button.yPosition + button.height if (otherX2 > x && otherX < x2 && otherY2 > y && otherY < y2) { y = otherY - 20 - 2 y2 = y + 20 diff --git a/src/main/kotlin/skytils/skytilsmod/commands/ArmorColorCommand.kt b/src/main/kotlin/skytils/skytilsmod/commands/ArmorColorCommand.kt index ae1bff7a..c2bbd376 100644 --- a/src/main/kotlin/skytils/skytilsmod/commands/ArmorColorCommand.kt +++ b/src/main/kotlin/skytils/skytilsmod/commands/ArmorColorCommand.kt @@ -19,7 +19,10 @@ package skytils.skytilsmod.commands import com.google.common.collect.Lists import net.minecraft.client.entity.EntityPlayerSP -import net.minecraft.command.* +import net.minecraft.command.CommandBase +import net.minecraft.command.ICommandSender +import net.minecraft.command.SyntaxErrorException +import net.minecraft.command.WrongUsageException import net.minecraft.item.ItemArmor import net.minecraft.util.BlockPos import net.minecraft.util.ChatComponentText @@ -28,7 +31,6 @@ import skytils.skytilsmod.features.impl.handlers.ArmorColor import skytils.skytilsmod.utils.ItemUtil import skytils.skytilsmod.utils.Utils import skytils.skytilsmod.utils.graphics.colors.CustomColor -import java.util.* object ArmorColorCommand : CommandBase() { override fun getCommandName(): String { @@ -51,7 +53,7 @@ object ArmorColorCommand : CommandBase() { return emptyList() } - @Throws(CommandException::class) + override fun processCommand(sender: ICommandSender, args: Array<String>) { val player = sender as EntityPlayerSP if (args.isEmpty()) { diff --git a/src/main/kotlin/skytils/skytilsmod/commands/BlockAbilityCommand.kt b/src/main/kotlin/skytils/skytilsmod/commands/BlockAbilityCommand.kt index ef72f5ca..bb5eb08c 100644 --- a/src/main/kotlin/skytils/skytilsmod/commands/BlockAbilityCommand.kt +++ b/src/main/kotlin/skytils/skytilsmod/commands/BlockAbilityCommand.kt @@ -19,14 +19,12 @@ package skytils.skytilsmod.commands import net.minecraft.client.entity.EntityPlayerSP import net.minecraft.command.CommandBase -import net.minecraft.command.CommandException import net.minecraft.command.ICommandSender import net.minecraft.util.BlockPos import net.minecraft.util.ChatComponentText import skytils.skytilsmod.core.PersistentSave import skytils.skytilsmod.features.impl.handlers.BlockAbility import skytils.skytilsmod.utils.ItemUtil -import java.util.* object BlockAbilityCommand : CommandBase() { override fun getCommandName(): String { @@ -49,7 +47,7 @@ object BlockAbilityCommand : CommandBase() { return emptyList() } - @Throws(CommandException::class) + override fun processCommand(sender: ICommandSender, args: Array<String>) { val player = sender as EntityPlayerSP if (args.isEmpty()) { diff --git a/src/main/kotlin/skytils/skytilsmod/commands/GlintCustomizeCommand.kt b/src/main/kotlin/skytils/skytilsmod/commands/GlintCustomizeCommand.kt index 3df1a7d8..ff6f411c 100644 --- a/src/main/kotlin/skytils/skytilsmod/commands/GlintCustomizeCommand.kt +++ b/src/main/kotlin/skytils/skytilsmod/commands/GlintCustomizeCommand.kt @@ -18,7 +18,10 @@ package skytils.skytilsmod.commands import net.minecraft.client.entity.EntityPlayerSP -import net.minecraft.command.* +import net.minecraft.command.CommandBase +import net.minecraft.command.ICommandSender +import net.minecraft.command.SyntaxErrorException +import net.minecraft.command.Wron |
