Skip to content

Commit

Permalink
added Cart Bomb module
Browse files Browse the repository at this point in the history
  • Loading branch information
Mjaucher committed Apr 16, 2022
1 parent 04eef50 commit ae81fe9
Show file tree
Hide file tree
Showing 7 changed files with 217 additions and 26 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ __Credits:__ https://en.wikipedia.org/wiki/Trollface

### Needed mods:
Meteor Client - https://meteorclient.com/

Fabric Language Kotlin - https://www.curseforge.com/minecraft/mc-mods/fabric-language-kotlin

### Features:
__Auto Kit__ Takes _Kit_ after your death.

__Auto Login__ Enters password after logging in to server.

__Changer__ Changes in-game parameters (EXP Bar, Weather, Fov, FPS limit, and more)
__Cart Bomb__ Automatically puts _Mine Cart_ with TNT under enemy feet.

__Changer__ _Changes_ in-game parameters (EXP Bar, Weather, Fov, FPS limit, and more)

__Fake Kick__ Automatic disconnect with _Fake_ reason

Expand All @@ -29,7 +31,7 @@ __Credits:__ https://en.wikipedia.org/wiki/Trollface

__No Interact__ Disable _Interaction_ with interactive blocks.

__NoSwing__ Removes all hand _Swings_.
__No Swing__ Removes all hand _Swings_.

__Prefix__ Custom Meteor Client _Prefix_ with more customizations.

Expand Down
7 changes: 5 additions & 2 deletions src/main/java/me/meowcher/silivia/mixins/Minecraft.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@

@Mixin (value = MinecraftClient.class, priority = Integer.MAX_VALUE) public abstract class Minecraft
{
@Redirect (method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;isBreakingBlock()Z"))
@Redirect (method = "doItemUse", at = @At(value = "INVOKE",
target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;isBreakingBlock()Z"))
public boolean doItemUse(ClientPlayerInteractionManager CPIManager)
{
return MeteorClient.EVENT_BUS.post(BreakingBlock.Companion.hook(CPIManager.isBreakingBlock())).getBoo();
}
@Redirect (method = "handleBlockBreaking", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isUsingItem()Z"))

@Redirect (method = "handleBlockBreaking", at = @At(value = "INVOKE",
target = "Lnet/minecraft/client/network/ClientPlayerEntity;isUsingItem()Z"))
public boolean handleBlockBreaking(ClientPlayerEntity CPEntity)
{
return MeteorClient.EVENT_BUS.post(UsingItem.Companion.hook(CPEntity.isUsingItem())).getLean();
Expand Down
15 changes: 8 additions & 7 deletions src/main/kotlin/me/meowcher/silivia/core/Implements.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ class Implements
{
companion object
{
private fun modsInitialize(vararg Features : Module?)
{
for (modules in Features)
{
Modules.get().add(modules)
}
}
fun modsInitialize()
{
modsInitialize(
Expand All @@ -24,12 +17,20 @@ class Implements
AutoLogin(),
MultiTask(),
TickShift(),
CartBomb(),
FakeKick(),
NoSwing(),
Changer(),
AutoKit(),
Prefix(),
)
}
private fun modsInitialize(vararg Features : Module?)
{
for (modules in Features)
{
Modules.get().add(modules)
}
}
}
}
151 changes: 151 additions & 0 deletions src/main/kotlin/me/meowcher/silivia/impl/CartBomb.kt
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
}
}
29 changes: 24 additions & 5 deletions src/main/kotlin/me/meowcher/silivia/utils/player/UInteract.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package me.meowcher.silivia.utils.player

import me.meowcher.silivia.core.Global
import me.meowcher.silivia.utils.world.UBlock
import net.minecraft.item.Item
import net.minecraft.entity.Entity
import net.minecraft.network.Packet
import net.minecraft.network.packet.c2s.play.*
import net.minecraft.util.Hand
Expand All @@ -19,9 +18,9 @@ class UInteract
{
network?.sendPacket(Packet)
}
fun doSwingHand()
fun doSwingHand(Hand : Hand)
{
player?.swingHand(Hand.MAIN_HAND)
player?.swingHand(Hand)
}
fun doUse()
{
Expand All @@ -35,10 +34,30 @@ class UInteract
{
doPacketSend(PlayerActionC2SPacket(PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, destroyPosition, Direction.UP))
}
fun doInteractBlock(Position : BlockPos, Direction : Direction, Hand : Hand)
fun doUseItemOnBlock(Position : BlockPos, Direction : Direction, Hand : Hand)
{
val result = BlockHitResult(Vec3d.of(Position), Direction, Position, false)
network?.sendPacket(PlayerInteractBlockC2SPacket(Hand, result))
doSwingHand(Hand)
}
fun doAttack(Entity : Entity, Hand : Hand) {
doPacketSend(PlayerInteractEntityC2SPacket.attack(Entity, player!!.isSneaking))
doSwingHand(Hand)
/*
private fun doAttackMineCart()
{
for (mineCart in world!!.entities)
{
if (player!!.distanceTo(mineCart) < attackRange.get())
{
if (mineCart is MinecartEntity)
{
UInteract.doAttack(mineCart, Hand.MAIN_HAND)
}
}
}
}
*/
}
}
}
19 changes: 13 additions & 6 deletions src/main/kotlin/me/meowcher/silivia/utils/player/UInventory.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package me.meowcher.silivia.utils.player

import me.meowcher.silivia.core.Global
import net.minecraft.inventory.Inventory
import net.minecraft.item.Item
import net.minecraft.item.Items
import net.minecraft.network.packet.c2s.play.*
import net.minecraft.screen.slot.SlotActionType

Expand All @@ -17,17 +19,22 @@ class UInventory
{
inventory?.selectedSlot = slotNumber
}
fun getCurrentSlot() : Int?
fun getCurrentSlot() : Int
{
return inventory?.selectedSlot
return inventory!!.selectedSlot
}
fun getItemSlot(Item : Item?, Inventory : Boolean) : Int
fun getItem(Slot : Int) : Item?
{
val inv = if (Inventory) player!!.inventory.size() else 9
for (i in 0..inv) if (inventory?.getStack(i)?.item?.equals(Item) == true) return i
return if (Slot == -1) Items.AIR
else inventory?.getStack(Slot)?.item
}
fun getItemSlot(Item : Item, Inventory : Boolean) : Int
{
val slots = if (Inventory) inventory?.size() else 8
for (i in 0..slots!!) if (inventory?.getStack(i)?.item?.equals(Item) == true) return i
return -1
}
fun doSlotMovement(Item : Item?, moveSlot : Int)
fun doSlotMovement(Item : Item, moveSlot : Int)
{
val oldSlot = getItemSlot(Item, true)
interaction?.clickSlot(0, oldSlot, 0, SlotActionType.PICKUP, player)
Expand Down
14 changes: 11 additions & 3 deletions src/main/kotlin/me/meowcher/silivia/utils/world/UEntity.kt
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
}
}
}

0 comments on commit ae81fe9

Please sign in to comment.