Add Speed Mine, Timer, tweaks to Flight & NoFall
This commit is contained in:
parent
008b70c02c
commit
15323b2e4d
12 changed files with 167 additions and 15 deletions
|
@ -0,0 +1,50 @@
|
||||||
|
package codes.som.hibiscus.mixins;
|
||||||
|
|
||||||
|
import codes.som.hibiscus.Hibiscus;
|
||||||
|
import codes.som.hibiscus.events.PlayerBlockBreakCheckItemEvent;
|
||||||
|
import codes.som.hibiscus.events.PlayerBlockBreakCooldownEvent;
|
||||||
|
import codes.som.hibiscus.events.PlayerBlockBreakProgressEvent;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.client.network.ClientPlayerInteractionManager;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
|
import net.minecraft.world.BlockView;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
@Mixin(ClientPlayerInteractionManager.class)
|
||||||
|
public abstract class MixinClientPlayerInteractionManager {
|
||||||
|
@Shadow
|
||||||
|
private int blockBreakingCooldown;
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
private BlockPos currentBreakingPos;
|
||||||
|
|
||||||
|
@Inject(method = "updateBlockBreakingProgress", at = @At("HEAD"))
|
||||||
|
private void blockBreakingCooldownHook(BlockPos pos, Direction direction, CallbackInfoReturnable<Boolean> cir) {
|
||||||
|
var event = new PlayerBlockBreakCooldownEvent(pos, this.blockBreakingCooldown);
|
||||||
|
Hibiscus.bus().fire(event);
|
||||||
|
this.blockBreakingCooldown = event.getCooldown();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "updateBlockBreakingProgress", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;calcBlockBreakingDelta(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;)F"))
|
||||||
|
private float blockBreakingProgressHook(BlockState instance, PlayerEntity player, BlockView world, BlockPos pos) {
|
||||||
|
float origProgress = instance.calcBlockBreakingDelta(player, world, pos);
|
||||||
|
var event = new PlayerBlockBreakProgressEvent(pos, origProgress);
|
||||||
|
Hibiscus.bus().fire(event);
|
||||||
|
return event.getProgress();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "isCurrentlyBreaking", at = @At("RETURN"), cancellable = true)
|
||||||
|
private void onGetIsCurrentlyBreaking(BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
|
||||||
|
var event = new PlayerBlockBreakCheckItemEvent(pos);
|
||||||
|
Hibiscus.bus().fire(event);
|
||||||
|
if (event.isCancelled())
|
||||||
|
cir.setReturnValue(pos.equals(this.currentBreakingPos));
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package codes.som.hibiscus.mixins;
|
package codes.som.hibiscus.mixins;
|
||||||
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.render.RenderTickCounter;
|
||||||
import net.minecraft.client.util.Session;
|
import net.minecraft.client.util.Session;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Mutable;
|
import org.spongepowered.asm.mixin.Mutable;
|
||||||
|
@ -11,4 +12,7 @@ public interface MixinExtMinecraftClient {
|
||||||
@Accessor
|
@Accessor
|
||||||
@Mutable
|
@Mutable
|
||||||
void setSession(Session session);
|
void setSession(Session session);
|
||||||
|
|
||||||
|
@Accessor
|
||||||
|
RenderTickCounter getRenderTickCounter();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package codes.som.hibiscus.mixins;
|
||||||
|
|
||||||
|
import net.minecraft.client.render.RenderTickCounter;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Mutable;
|
||||||
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
|
|
||||||
|
@Mixin(RenderTickCounter.class)
|
||||||
|
public interface MixinExtRenderTickCounter {
|
||||||
|
@Accessor
|
||||||
|
@Mutable
|
||||||
|
void setTickTime(float tickTime);
|
||||||
|
|
||||||
|
@Accessor
|
||||||
|
float getTickTime();
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package codes.som.hibiscus.mixins;
|
||||||
|
|
||||||
|
import codes.som.hibiscus.Hibiscus;
|
||||||
|
import codes.som.hibiscus.features.player.NoFallDamage;
|
||||||
|
import net.minecraft.client.network.ClientPlayerEntity;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
|
@Mixin(PlayerEntity.class)
|
||||||
|
public abstract class MixinPlayerEntity {
|
||||||
|
@Redirect(method = "getBlockBreakingSpeed", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/player/PlayerEntity;onGround:Z"))
|
||||||
|
private boolean getOnGround(PlayerEntity player) {
|
||||||
|
if (player instanceof ClientPlayerEntity) {
|
||||||
|
try {
|
||||||
|
if (Hibiscus.INSTANCE.getFeatures().getFeature(NoFallDamage.class).getEnabled())
|
||||||
|
return true;
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return player.isOnGround();
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,7 @@ fun allCommandClasses(): Array<() -> Command> = arrayOf(
|
||||||
::Reload,
|
::Reload,
|
||||||
::Vclip,
|
::Vclip,
|
||||||
::Gamma,
|
::Gamma,
|
||||||
|
::Timer,
|
||||||
)
|
)
|
||||||
|
|
||||||
class CommandRegistry : CommandManager() {
|
class CommandRegistry : CommandManager() {
|
||||||
|
|
19
src/main/kotlin/codes/som/hibiscus/commands/Timer.kt
Normal file
19
src/main/kotlin/codes/som/hibiscus/commands/Timer.kt
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
package codes.som.hibiscus.commands
|
||||||
|
|
||||||
|
import codes.som.hibiscus.api.command.Command
|
||||||
|
import codes.som.hibiscus.mc
|
||||||
|
import codes.som.hibiscus.mixins.MixinExtMinecraftClient
|
||||||
|
import codes.som.hibiscus.mixins.MixinExtRenderTickCounter
|
||||||
|
import codes.som.hibiscus.util.ext.requireExtension
|
||||||
|
|
||||||
|
class Timer : Command("timer") {
|
||||||
|
init {
|
||||||
|
branch { n: Float ->
|
||||||
|
val renderTickCounter = (mc as MixinExtMinecraftClient).renderTickCounter
|
||||||
|
requireExtension<MixinExtRenderTickCounter>(renderTickCounter)
|
||||||
|
renderTickCounter.tickTime = 1000F / (20F * n)
|
||||||
|
|
||||||
|
Unit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,9 +3,14 @@ package codes.som.hibiscus.events
|
||||||
import codes.som.hibiscus.api.event.Cancellable
|
import codes.som.hibiscus.api.event.Cancellable
|
||||||
import codes.som.hibiscus.api.event.Event
|
import codes.som.hibiscus.api.event.Event
|
||||||
import net.minecraft.entity.MovementType
|
import net.minecraft.entity.MovementType
|
||||||
|
import net.minecraft.util.math.BlockPos
|
||||||
|
|
||||||
object PlayerPreTickEvent : Event
|
object PlayerPreTickEvent : Event
|
||||||
object PlayerTickEvent : Event
|
object PlayerTickEvent : Event
|
||||||
class SendChatEvent(val message: String) : Cancellable(), Event
|
class SendChatEvent(val message: String) : Cancellable(), Event
|
||||||
data class MovePlayerEvent(var x: Double, var y: Double, var z: Double, val movementType: MovementType) : Event
|
data class MovePlayerEvent(var x: Double, var y: Double, var z: Double, val movementType: MovementType) : Event
|
||||||
object PlayerInputTickEvent : Event
|
object PlayerInputTickEvent : Event
|
||||||
|
|
||||||
|
data class PlayerBlockBreakCooldownEvent(val pos: BlockPos, var cooldown: Int) : Event
|
||||||
|
data class PlayerBlockBreakProgressEvent(val pos: BlockPos, var progress: Float) : Event
|
||||||
|
class PlayerBlockBreakCheckItemEvent(val pos: BlockPos) : Cancellable(), Event
|
||||||
|
|
|
@ -10,6 +10,7 @@ import codes.som.hibiscus.features.overlay.Overlay
|
||||||
import codes.som.hibiscus.features.player.NoFallDamage
|
import codes.som.hibiscus.features.player.NoFallDamage
|
||||||
import codes.som.hibiscus.features.player.NoSprintingPacket
|
import codes.som.hibiscus.features.player.NoSprintingPacket
|
||||||
import codes.som.hibiscus.features.player.Nuker
|
import codes.som.hibiscus.features.player.Nuker
|
||||||
|
import codes.som.hibiscus.features.player.SpeedMine
|
||||||
import codes.som.hibiscus.features.visual.Freecam
|
import codes.som.hibiscus.features.visual.Freecam
|
||||||
import codes.som.hibiscus.features.visual.Fullbright
|
import codes.som.hibiscus.features.visual.Fullbright
|
||||||
import codes.som.hibiscus.features.visual.NoFog
|
import codes.som.hibiscus.features.visual.NoFog
|
||||||
|
@ -31,6 +32,7 @@ fun FEATURE_CONSTRUCTORS(): Array<() -> Feature> = arrayOf(
|
||||||
::Nuker,
|
::Nuker,
|
||||||
::Fullbright,
|
::Fullbright,
|
||||||
::NoFog,
|
::NoFog,
|
||||||
|
::SpeedMine,
|
||||||
)
|
)
|
||||||
|
|
||||||
class FeaturesRegistry : Resettable {
|
class FeaturesRegistry : Resettable {
|
||||||
|
|
|
@ -71,7 +71,7 @@ class Flight : Feature("Flight", FeatureCategory.MOVEMENT) {
|
||||||
calcMoveVec(getMoveInputVecFromPlayerInput(player.input), player.yaw)
|
calcMoveVec(getMoveInputVecFromPlayerInput(player.input), player.yaw)
|
||||||
.normalize()
|
.normalize()
|
||||||
.multiply(speed.toDouble() * (10.0 - 1 / 8))
|
.multiply(speed.toDouble() * (10.0 - 1 / 8))
|
||||||
.multiply(1.0, 0.5, 1.0)
|
.multiply(1.0, if (vanillaKickBypass && flyKickCounter >= 16) 0.0 else 0.5, 1.0)
|
||||||
} else {
|
} else {
|
||||||
Vec3d.ZERO
|
Vec3d.ZERO
|
||||||
}
|
}
|
||||||
|
@ -102,12 +102,6 @@ class Flight : Feature("Flight", FeatureCategory.MOVEMENT) {
|
||||||
}
|
}
|
||||||
|
|
||||||
on(cond = { vanillaKickBypass }) { event: NetworkMovingEvent ->
|
on(cond = { vanillaKickBypass }) { event: NetworkMovingEvent ->
|
||||||
flyKickCounter++
|
|
||||||
|
|
||||||
if (flyKickCounter >= 16) {
|
|
||||||
if (flyKickCounter == 16)
|
|
||||||
lockY = event.y - 0.0625
|
|
||||||
|
|
||||||
val playerNotColliding = world.getBlockCollisions(
|
val playerNotColliding = world.getBlockCollisions(
|
||||||
null, player.boundingBox
|
null, player.boundingBox
|
||||||
.offset(0.0, lockY - player.y, 0.0)
|
.offset(0.0, lockY - player.y, 0.0)
|
||||||
|
@ -115,12 +109,21 @@ class Flight : Feature("Flight", FeatureCategory.MOVEMENT) {
|
||||||
.stretch(0.0, -0.55, 0.0)
|
.stretch(0.0, -0.55, 0.0)
|
||||||
).all(VoxelShape::isEmpty)
|
).all(VoxelShape::isEmpty)
|
||||||
|
|
||||||
if (playerNotColliding)
|
if (playerNotColliding) {
|
||||||
|
flyKickCounter++
|
||||||
|
|
||||||
|
if (flyKickCounter >= 16) {
|
||||||
|
if (flyKickCounter == 16)
|
||||||
|
lockY = event.y - 0.0625
|
||||||
|
|
||||||
event.y = lockY
|
event.y = lockY
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flyKickCounter >= 24)
|
if (flyKickCounter >= 24)
|
||||||
flyKickCounter = 0
|
flyKickCounter = 0
|
||||||
|
} else {
|
||||||
|
flyKickCounter = 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import codes.som.hibiscus.events.NetworkMovingEvent
|
||||||
|
|
||||||
class NoFallDamage : Feature("No Fall Damage", FeatureCategory.PLAYER) {
|
class NoFallDamage : Feature("No Fall Damage", FeatureCategory.PLAYER) {
|
||||||
init {
|
init {
|
||||||
on<NetworkMovingEvent> { it.onGround = false }
|
on<NetworkMovingEvent> { it.onGround = true }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createFeatureCommand() =
|
override fun createFeatureCommand() =
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
package codes.som.hibiscus.features.player
|
||||||
|
|
||||||
|
import codes.som.hibiscus.api.feature.Feature
|
||||||
|
import codes.som.hibiscus.api.feature.FeatureCategory
|
||||||
|
import codes.som.hibiscus.events.PlayerBlockBreakCheckItemEvent
|
||||||
|
import codes.som.hibiscus.events.PlayerBlockBreakCooldownEvent
|
||||||
|
import codes.som.hibiscus.events.PlayerBlockBreakProgressEvent
|
||||||
|
|
||||||
|
class SpeedMine : Feature("Speed Mine", FeatureCategory.PLAYER) {
|
||||||
|
init {
|
||||||
|
on { event: PlayerBlockBreakCooldownEvent ->
|
||||||
|
event.cooldown = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
on { event: PlayerBlockBreakProgressEvent ->
|
||||||
|
if (event.progress >= 0.7F)
|
||||||
|
event.progress = 1.0F
|
||||||
|
}
|
||||||
|
|
||||||
|
on { event: PlayerBlockBreakCheckItemEvent -> event.cancel() }
|
||||||
|
|
||||||
|
enabled = true
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,16 +9,19 @@
|
||||||
"MixinBackgroundRenderer",
|
"MixinBackgroundRenderer",
|
||||||
"MixinClientConnection",
|
"MixinClientConnection",
|
||||||
"MixinClientPlayerEntity",
|
"MixinClientPlayerEntity",
|
||||||
|
"MixinClientPlayerInteractionManager",
|
||||||
"MixinClientPlayNetworkHandler",
|
"MixinClientPlayNetworkHandler",
|
||||||
"MixinDebugHud",
|
"MixinDebugHud",
|
||||||
"MixinExtClientPlayerEntity",
|
"MixinExtClientPlayerEntity",
|
||||||
"MixinExtEntity",
|
"MixinExtEntity",
|
||||||
"MixinExtMinecraftClient",
|
"MixinExtMinecraftClient",
|
||||||
"MixinExtPlayerInteractEntityC2SPacket",
|
"MixinExtPlayerInteractEntityC2SPacket",
|
||||||
|
"MixinExtRenderTickCounter",
|
||||||
"MixinExtUpdatePlayerAbilitiesC2SPacket",
|
"MixinExtUpdatePlayerAbilitiesC2SPacket",
|
||||||
"MixinGameRenderer",
|
"MixinGameRenderer",
|
||||||
"MixinKeyboard",
|
"MixinKeyboard",
|
||||||
"MixinMinecraftClient",
|
"MixinMinecraftClient",
|
||||||
|
"MixinPlayerEntity",
|
||||||
"MixinRenderSectionManager",
|
"MixinRenderSectionManager",
|
||||||
"MixinWorldRenderer",
|
"MixinWorldRenderer",
|
||||||
"netmoving.MixinClientPlayerEntity",
|
"netmoving.MixinClientPlayerEntity",
|
||||||
|
|
Loading…
Reference in a new issue