-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
217 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
package me.meowcher.silivia.impl | ||
|
||
import me.meowcher.silivia.core.Global | ||
import me.meowcher.silivia.core.Initializer | ||
import me.meowcher.silivia.utils.chat.UMessages | ||
import me.meowcher.silivia.utils.player.UInteract | ||
import me.meowcher.silivia.utils.player.UInventory | ||
import me.meowcher.silivia.utils.world.UBlock | ||
import me.meowcher.silivia.utils.world.UEntity | ||
import meteordevelopment.meteorclient.events.game.GameLeftEvent | ||
import meteordevelopment.meteorclient.events.world.TickEvent.Post | ||
import meteordevelopment.meteorclient.settings.BoolSetting | ||
import meteordevelopment.meteorclient.settings.IntSetting | ||
import meteordevelopment.meteorclient.systems.modules.Module | ||
import meteordevelopment.orbit.EventHandler | ||
import net.minecraft.block.Block | ||
import net.minecraft.item.Item | ||
import net.minecraft.item.Items | ||
import net.minecraft.util.Hand | ||
import net.minecraft.util.math.BlockPos | ||
import net.minecraft.util.math.Direction | ||
|
||
class CartBomb : Global, Module(Initializer.Category, "cart-bomb", "Automatically puts Mine Cart with TNT under enemy feet.") | ||
{ | ||
private val group = settings.defaultGroup | ||
private var targetRange = group.add(IntSetting.Builder().name("target-range").defaultValue(4).sliderRange(1, 6).build()) | ||
private var placementDelay = group.add(IntSetting.Builder().name("placement-delay").defaultValue(5).sliderRange(0, 20).build()) | ||
private var antiSelfDMG = group.add(BoolSetting.Builder().name("anti-self-dmg").defaultValue(true).build()) | ||
private var ignoreFriends = group.add(BoolSetting.Builder().name("ignore-friends").defaultValue(true).build()) | ||
private var onlySurrounded = group.add(BoolSetting.Builder().name("only-surrounded").description("Module is activated when target is surrounded.").defaultValue(true).build()) | ||
private var debugs = group.add(BoolSetting.Builder().name("debugs").defaultValue(false).build()) | ||
|
||
private var shutdownGroup = settings.createGroup("Shutdown Settings") | ||
private var foundResultShutdown = shutdownGroup.add(BoolSetting.Builder().name("found-result-shutdown").defaultValue(true).build()) | ||
private var worldLeftShutdown = shutdownGroup.add(BoolSetting.Builder().name("world-left-shutdown").defaultValue(true).build()) | ||
private var lowHealthStop = shutdownGroup.add(BoolSetting.Builder().name("low-health-stop").defaultValue(true).build()) | ||
private var lowHealthToggle = shutdownGroup.add(BoolSetting.Builder().name("low-health-turn-off").defaultValue(true).visible{lowHealthStop.get()}.build()) | ||
private var lowHealthCount = shutdownGroup.add(IntSetting.Builder().name("minimal-health").defaultValue(5).sliderRange(1, 36).visible{lowHealthStop.get()}.build()) | ||
|
||
private var doMineCartPlace = false | ||
|
||
private var ticks = 0 | ||
private var bugTicks = 0 | ||
private var carts = 0 | ||
|
||
override fun onActivate() | ||
{ | ||
doSetDefault() | ||
} | ||
|
||
override fun onDeactivate() | ||
{ | ||
doSetDefault() | ||
} | ||
|
||
private fun getRailSlot() : Int | ||
{ | ||
var itemSlot = -1 | ||
for (i in 0..8) | ||
{ | ||
if (isRailItem(UInventory.getItem(i)!!)) | ||
{ | ||
itemSlot = i | ||
break | ||
} | ||
} | ||
return itemSlot | ||
} | ||
|
||
@EventHandler private fun onGameLeftEvent(Event : GameLeftEvent) | ||
{ | ||
if (worldLeftShutdown.get()) toggle() | ||
} | ||
|
||
@EventHandler private fun onTickPostEvent(Event : Post) | ||
{ | ||
val target = UEntity.getTarget(targetRange.get(), ignoreFriends.get()) ?: return | ||
val targetPos = BlockPos(target.blockPos) | ||
|
||
val isRailBlock = UBlock.getBlock(targetPos) === Block.getBlockFromItem(UInventory.getItem(getRailSlot())) | ||
|
||
val getCartSlot = UInventory.getItemSlot(Items.TNT_MINECART, false) | ||
val slot = if (doMineCartPlace) getCartSlot else getRailSlot() | ||
|
||
val notSurrounded = onlySurrounded.get() && !UEntity.isSurrounded(target) | ||
val isBurrowed = !UBlock.isAir(targetPos) && !isRailBlock | ||
val antiSelf = antiSelfDMG.get() && (targetPos == player!!.blockPos) | ||
val lowHPStop = lowHealthStop.get() && player!!.health <= lowHealthCount.get().toFloat() | ||
|
||
if (notSurrounded) doSendDebug("Target is not surrounded!") | ||
if (isBurrowed) doSendDebug("Target is burrowed, placement is impossible!") | ||
if (antiSelf || isBurrowed || notSurrounded) return | ||
|
||
if (lowHPStop) | ||
{ | ||
doSendDebug("You have minimum allowable amount of health, work is stopped!") | ||
|
||
if (lowHealthToggle.get()) toggle() | ||
else return | ||
} | ||
|
||
if (slot < 0 || slot > 9) | ||
{ | ||
val wrongFoundText = | ||
if (doMineCartPlace) "TNT Cart is not in your hot bar!" | ||
else "Rails is not in your hot bar!" | ||
|
||
doSendDebug(wrongFoundText) | ||
|
||
if (foundResultShutdown.get()) toggle() | ||
else return | ||
} | ||
|
||
if (ticks == placementDelay.get()) UInventory.doSelectSlot(slot) | ||
|
||
if (ticks >= (placementDelay.get() + 1)) | ||
{ | ||
if (isRailBlock == doMineCartPlace && UBlock.isAir(targetPos) == !doMineCartPlace) | ||
{ | ||
if (UInventory.getCurrentSlot() == slot) | ||
{ | ||
UInteract.doUseItemOnBlock(targetPos, Direction.UP, Hand.MAIN_HAND) | ||
doMineCartPlace = slot != getCartSlot | ||
ticks = 0 | ||
} | ||
} | ||
} | ||
|
||
ticks++ | ||
} | ||
|
||
private fun isRailItem(Item : Item) : Boolean | ||
{ | ||
return Item === Items.RAIL || Item === Items.POWERED_RAIL || | ||
Item === Items.ACTIVATOR_RAIL || Item === Items.ACTIVATOR_RAIL | ||
} | ||
|
||
private fun doSendDebug(Text : String) | ||
{ | ||
if (debugs.get()) UMessages.doFakeSend(Text) | ||
else println(Text) | ||
} | ||
|
||
private fun doSetDefault() | ||
{ | ||
doMineCartPlace = false | ||
ticks = 0 | ||
bugTicks = 0 | ||
carts = 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 11 additions & 3 deletions
14
src/main/kotlin/me/meowcher/silivia/utils/world/UEntity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,33 @@ | ||
package me.meowcher.silivia.utils.world | ||
|
||
import me.meowcher.silivia.core.Global | ||
import meteordevelopment.meteorclient.systems.friends.Friends | ||
import net.minecraft.entity.player.PlayerEntity | ||
|
||
|
||
class UEntity | ||
{ | ||
companion object : Global | ||
{ | ||
fun getTarget(Range : Int) : PlayerEntity? | ||
fun getTarget(Range : Int, ignoreFriends : Boolean) : PlayerEntity? | ||
{ | ||
for (target in world!!.entities) | ||
{ | ||
if (player!!.distanceTo(target) <= Range) | ||
if (player!!.distanceTo(target) <= Range && target is PlayerEntity && target != player) | ||
{ | ||
if (target is PlayerEntity && target !== player) | ||
if (Friends.get().isFriend(target) != ignoreFriends) | ||
{ | ||
return target | ||
} | ||
} | ||
} | ||
return null | ||
} | ||
|
||
fun isSurrounded(entity : PlayerEntity) : Boolean { | ||
val blockPos = entity.blockPos | ||
return world?.getBlockState(blockPos.add(0, 0, 1))?.isAir == false && world?.getBlockState(blockPos.add(0, 0, -1))?.isAir == false && | ||
world?.getBlockState(blockPos.add(1, 0, 0))?.isAir == false && world?.getBlockState(blockPos.add(-1, 0, 0))?.isAir == false | ||
} | ||
} | ||
} |