From 5023b2c41df4cf1de2e7ebd9af6bdbd051fa82bf Mon Sep 17 00:00:00 2001 From: Imeguras Date: Thu, 6 Apr 2023 17:09:09 +0100 Subject: [PATCH 1/2] Added Minecart as an option to autoremount --- .../module/modules/movement/AutoRemount.kt | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/AutoRemount.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/AutoRemount.kt index 54f5093c5..b5d2c2827 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/AutoRemount.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/AutoRemount.kt @@ -7,6 +7,8 @@ import com.lambda.client.util.TimeUnit import com.lambda.client.util.threads.safeListener import net.minecraft.entity.Entity import net.minecraft.entity.item.EntityBoat +import net.minecraft.entity.item.EntityMinecartEmpty + import net.minecraft.entity.passive.* import net.minecraft.util.EnumHand import net.minecraftforge.fml.common.gameevent.TickEvent @@ -17,6 +19,7 @@ object AutoRemount : Module( category = Category.MOVEMENT ) { private val boat by setting("Boats", true) + private val minecart by setting("Minecarts", true) private val horse by setting("Horse", true) private val skeletonHorse by setting("Skeleton Horse", true) private val donkey by setting("Donkey", true) @@ -25,7 +28,7 @@ object AutoRemount : Module( private val llama by setting("Llama", true) private val range by setting("Range", 2.0f, 1.0f..5.0f, 0.5f) private val remountDelay by setting("Remount Delay", 5, 0..10, 1) - + private val remountTimer = TickTimer(TimeUnit.TICKS) init { @@ -50,13 +53,20 @@ object AutoRemount : Module( } private fun isValidEntity(entity: Entity): Boolean { - return boat && entity is EntityBoat - || entity is EntityAnimal && !entity.isChild // FBI moment - && (horse && entity is EntityHorse - || skeletonHorse && entity is EntitySkeletonHorse - || donkey && entity is EntityDonkey - || mule && entity is EntityMule - || pig && entity is EntityPig && entity.saddled - || llama && entity is EntityLlama) + //check if entity is an animal and not a child + var matureAnimalCheck: Boolean = entity is EntityAnimal && !entity.isChild; //FBI moment + when(entity){ + is EntityBoat -> return boat; + is EntityMinecartEmpty -> return minecart; + + is EntityHorse -> return horse && matureAnimalCheck; + is EntitySkeletonHorse -> return skeletonHorse && matureAnimalCheck; + is EntityDonkey -> return donkey && matureAnimalCheck; + is EntityMule -> return mule && matureAnimalCheck; + is EntityPig -> return pig && entity.saddled && matureAnimalCheck; + is EntityLlama -> return llama && matureAnimalCheck; + else -> return false; + + } } } From b32570fc43fe71d79b6ef061be93aadc52c3d37c Mon Sep 17 00:00:00 2001 From: Constructor Date: Sun, 9 Apr 2023 20:44:14 +0200 Subject: [PATCH 2/2] Small refactor no semicolons in kotlin ;) --- .../module/modules/movement/AutoRemount.kt | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/AutoRemount.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/AutoRemount.kt index b5d2c2827..c81a7b73f 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/AutoRemount.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/AutoRemount.kt @@ -15,7 +15,7 @@ import net.minecraftforge.fml.common.gameevent.TickEvent object AutoRemount : Module( name = "AutoRemount", - description = "Automatically remounts your ridable entity", + description = "Automatically remounts your rideable entity", category = Category.MOVEMENT ) { private val boat by setting("Boats", true) @@ -28,7 +28,7 @@ object AutoRemount : Module( private val llama by setting("Llama", true) private val range by setting("Range", 2.0f, 1.0f..5.0f, 0.5f) private val remountDelay by setting("Remount Delay", 5, 0..10, 1) - + private val remountTimer = TickTimer(TimeUnit.TICKS) init { @@ -54,19 +54,17 @@ object AutoRemount : Module( private fun isValidEntity(entity: Entity): Boolean { //check if entity is an animal and not a child - var matureAnimalCheck: Boolean = entity is EntityAnimal && !entity.isChild; //FBI moment - when(entity){ - is EntityBoat -> return boat; - is EntityMinecartEmpty -> return minecart; - - is EntityHorse -> return horse && matureAnimalCheck; - is EntitySkeletonHorse -> return skeletonHorse && matureAnimalCheck; - is EntityDonkey -> return donkey && matureAnimalCheck; - is EntityMule -> return mule && matureAnimalCheck; - is EntityPig -> return pig && entity.saddled && matureAnimalCheck; - is EntityLlama -> return llama && matureAnimalCheck; - else -> return false; - + val matureAnimalCheck: Boolean = entity is EntityAnimal && !entity.isChild //FBI moment + return when (entity) { + is EntityBoat -> boat + is EntityMinecartEmpty -> minecart + is EntityHorse -> horse && matureAnimalCheck + is EntitySkeletonHorse -> skeletonHorse && matureAnimalCheck + is EntityDonkey -> donkey && matureAnimalCheck + is EntityMule -> mule && matureAnimalCheck + is EntityPig -> pig && entity.saddled && matureAnimalCheck + is EntityLlama -> llama && matureAnimalCheck + else -> false } } }