Add Ghost, Anti-Ghost
parent
e6ae1efcbc
commit
a4e2c33cdf
|
@ -0,0 +1,22 @@
|
|||
package codes.som.hibiscus.mixins;
|
||||
|
||||
import codes.som.hibiscus.HibiscusMod;
|
||||
import codes.som.hibiscus.events.ReceivePacketEvent;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.listener.PacketListener;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(ClientConnection.class)
|
||||
public abstract class MixinClientConnection {
|
||||
@Inject(method = "handlePacket", at = @At("HEAD"), cancellable = true)
|
||||
private static <T extends PacketListener> void onHandlePacket(Packet<T> packet, PacketListener listener, CallbackInfo ci) {
|
||||
var event = new ReceivePacketEvent(packet);
|
||||
HibiscusMod.bus().fire(event);
|
||||
if (event.isCancelled())
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package codes.som.hibiscus.mixins;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(Entity.class)
|
||||
public interface MixinExtEntity {
|
||||
@Invoker("setFlag")
|
||||
void callSetFlag(int flag, boolean set);
|
||||
|
||||
@Accessor
|
||||
void setRemovalReason(Entity.RemovalReason reason);
|
||||
}
|
|
@ -2,6 +2,7 @@ package codes.som.hibiscus.api.feature
|
|||
|
||||
enum class FeatureCategory(val humanName: String) {
|
||||
COMBAT("Combat"),
|
||||
EXPLOITS("Exploits"),
|
||||
PLAYER("Player"),
|
||||
MOVEMENT("Movement"),
|
||||
OVERLAY("Overlay"),
|
||||
|
|
|
@ -5,6 +5,8 @@ import codes.som.hibiscus.api.event.Event
|
|||
import net.minecraft.network.Packet
|
||||
|
||||
data class SendPacketEvent(var packet: Packet<*>) : Cancellable(), Event
|
||||
data class ReceivePacketEvent(var packet: Packet<*>) : Cancellable(), Event
|
||||
|
||||
class NetworkMovingEvent(
|
||||
var x: Double,
|
||||
var y: Double,
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
package codes.som.hibiscus.features
|
||||
|
|
@ -2,9 +2,11 @@ package codes.som.hibiscus.features
|
|||
|
||||
import codes.som.hibiscus.api.feature.Feature
|
||||
import codes.som.hibiscus.features.combat.Criticals
|
||||
import codes.som.hibiscus.features.exploits.AntiGhost
|
||||
import codes.som.hibiscus.features.movement.Flight
|
||||
import codes.som.hibiscus.features.movement.Speed
|
||||
import codes.som.hibiscus.features.overlay.Overlay
|
||||
import codes.som.hibiscus.features.exploits.Ghost
|
||||
import codes.som.hibiscus.features.player.NoFallDamage
|
||||
|
||||
val ALL_FEATURES: Array<() -> Feature> = arrayOf(
|
||||
|
@ -13,6 +15,8 @@ val ALL_FEATURES: Array<() -> Feature> = arrayOf(
|
|||
::Overlay,
|
||||
::Speed,
|
||||
::Criticals,
|
||||
::Ghost,
|
||||
::AntiGhost,
|
||||
)
|
||||
|
||||
class FeaturesRegistry {
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package codes.som.hibiscus.features.exploits
|
||||
|
||||
import codes.som.hibiscus.api.feature.Feature
|
||||
import codes.som.hibiscus.api.feature.FeatureCategory
|
||||
import codes.som.hibiscus.events.PlayerTickEvent
|
||||
import codes.som.hibiscus.mc
|
||||
import codes.som.hibiscus.mixins.MixinExtEntity
|
||||
import codes.som.hibiscus.util.ext.requireExtension
|
||||
import codes.som.hibiscus.world
|
||||
|
||||
class AntiGhost : Feature("Anti Ghost", FeatureCategory.EXPLOITS) {
|
||||
init {
|
||||
on { _: PlayerTickEvent ->
|
||||
|
||||
for (player in world.players) {
|
||||
if (player == mc.player)
|
||||
continue
|
||||
|
||||
if (player.health <= 0) {
|
||||
player.deathTime = -1
|
||||
|
||||
requireExtension<MixinExtEntity>(player)
|
||||
player.setRemovalReason(null)
|
||||
|
||||
player.hurtTime = Int.MAX_VALUE
|
||||
|
||||
player.prevHeadYaw = player.prevYaw
|
||||
player.headYaw = player.yaw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package codes.som.hibiscus.features.exploits
|
||||
|
||||
import codes.som.hibiscus.api.feature.Feature
|
||||
import codes.som.hibiscus.api.feature.FeatureCategory
|
||||
import codes.som.hibiscus.events.PlayerTickEvent
|
||||
import codes.som.hibiscus.events.ReceivePacketEvent
|
||||
import codes.som.hibiscus.mc
|
||||
import codes.som.hibiscus.mixins.MixinExtEntity
|
||||
import codes.som.hibiscus.player
|
||||
import net.minecraft.client.gui.screen.DeathScreen
|
||||
import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket
|
||||
import net.minecraft.network.packet.s2c.play.HealthUpdateS2CPacket
|
||||
import net.minecraft.network.packet.s2c.play.PlayerRespawnS2CPacket
|
||||
|
||||
class Ghost : Feature("Ghost", FeatureCategory.EXPLOITS) {
|
||||
var dead = false
|
||||
|
||||
init {
|
||||
on { _: PlayerTickEvent ->
|
||||
if (player.health <= 0) {
|
||||
dead = true
|
||||
player.health = Float.MIN_VALUE
|
||||
}
|
||||
|
||||
if (dead) {
|
||||
player.hurtTime = 0
|
||||
player.knockbackVelocity = 0f
|
||||
player.hungerManager.foodLevel = 20
|
||||
player.hungerManager.saturationLevel = 1000F
|
||||
(player as MixinExtEntity).callSetFlag(0, false)
|
||||
}
|
||||
|
||||
if (mc.currentScreen is DeathScreen) {
|
||||
dead = true
|
||||
mc.setScreen(null)
|
||||
}
|
||||
}
|
||||
|
||||
on { event: ReceivePacketEvent ->
|
||||
val (packet) = event
|
||||
|
||||
if (packet is HealthUpdateS2CPacket) {
|
||||
if (packet.health <= 0) {
|
||||
event.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
if (packet is GameJoinS2CPacket || packet is PlayerRespawnS2CPacket) {
|
||||
dead = false
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Render 0 health on the status bar when dead
|
||||
}
|
||||
|
||||
override fun createFeatureCommand() = super.createFeatureCommand().apply {
|
||||
branch("respawn") {
|
||||
player.requestRespawn()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,9 +6,11 @@
|
|||
"defaultRequire": 1
|
||||
},
|
||||
"mixins": [
|
||||
"MixinClientConnection",
|
||||
"MixinClientPlayerEntity",
|
||||
"MixinClientPlayNetworkHandler",
|
||||
"MixinExtClientPlayerEntity",
|
||||
"MixinExtEntity",
|
||||
"MixinExtPlayerInteractEntityC2SPacket",
|
||||
"MixinExtPlayerMoveC2SPacket",
|
||||
"MixinExtUpdatePlayerAbilitiesC2SPacket",
|
||||
|
|
Loading…
Reference in New Issue