Add Speed Mine, Timer, tweaks to Flight & NoFall

main
Charlotte Som 2022-03-13 01:50:20 +00:00
parent 008b70c02c
commit 15323b2e4d
12 changed files with 167 additions and 15 deletions

View File

@ -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));
}
}

View File

@ -1,6 +1,7 @@
package codes.som.hibiscus.mixins;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.RenderTickCounter;
import net.minecraft.client.util.Session;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
@ -11,4 +12,7 @@ public interface MixinExtMinecraftClient {
@Accessor
@Mutable
void setSession(Session session);
@Accessor
RenderTickCounter getRenderTickCounter();
}

View File

@ -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();
}

View File

@ -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();
}
}

View File

@ -7,6 +7,7 @@ fun allCommandClasses(): Array<() -> Command> = arrayOf(
::Reload,
::Vclip,
::Gamma,
::Timer,
)
class CommandRegistry : CommandManager() {

View 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
}
}
}

View File

@ -3,9 +3,14 @@ package codes.som.hibiscus.events
import codes.som.hibiscus.api.event.Cancellable
import codes.som.hibiscus.api.event.Event
import net.minecraft.entity.MovementType
import net.minecraft.util.math.BlockPos
object PlayerPreTickEvent : Event
object PlayerTickEvent : Event
class SendChatEvent(val message: String) : Cancellable(), Event
data class MovePlayerEvent(var x: Double, var y: Double, var z: Double, val movementType: MovementType) : 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

View File

@ -10,6 +10,7 @@ import codes.som.hibiscus.features.overlay.Overlay
import codes.som.hibiscus.features.player.NoFallDamage
import codes.som.hibiscus.features.player.NoSprintingPacket
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.Fullbright
import codes.som.hibiscus.features.visual.NoFog
@ -31,6 +32,7 @@ fun FEATURE_CONSTRUCTORS(): Array<() -> Feature> = arrayOf(
::Nuker,
::Fullbright,
::NoFog,
::SpeedMine,
)
class FeaturesRegistry : Resettable {

View File

@ -71,7 +71,7 @@ class Flight : Feature("Flight", FeatureCategory.MOVEMENT) {
calcMoveVec(getMoveInputVecFromPlayerInput(player.input), player.yaw)
.normalize()
.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 {
Vec3d.ZERO
}
@ -102,25 +102,28 @@ class Flight : Feature("Flight", FeatureCategory.MOVEMENT) {
}
on(cond = { vanillaKickBypass }) { event: NetworkMovingEvent ->
flyKickCounter++
val playerNotColliding = world.getBlockCollisions(
null, player.boundingBox
.offset(0.0, lockY - player.y, 0.0)
.expand(0.0625)
.stretch(0.0, -0.55, 0.0)
).all(VoxelShape::isEmpty)
if (flyKickCounter >= 16) {
if (flyKickCounter == 16)
lockY = event.y - 0.0625
if (playerNotColliding) {
flyKickCounter++
val playerNotColliding = world.getBlockCollisions(
null, player.boundingBox
.offset(0.0, lockY - player.y, 0.0)
.expand(0.0625)
.stretch(0.0, -0.55, 0.0)
).all(VoxelShape::isEmpty)
if (flyKickCounter >= 16) {
if (flyKickCounter == 16)
lockY = event.y - 0.0625
if (playerNotColliding)
event.y = lockY
}
}
if (flyKickCounter >= 24)
if (flyKickCounter >= 24)
flyKickCounter = 0
} else {
flyKickCounter = 0
}
}
}

View File

@ -6,7 +6,7 @@ import codes.som.hibiscus.events.NetworkMovingEvent
class NoFallDamage : Feature("No Fall Damage", FeatureCategory.PLAYER) {
init {
on<NetworkMovingEvent> { it.onGround = false }
on<NetworkMovingEvent> { it.onGround = true }
}
override fun createFeatureCommand() =

View File

@ -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
}
}

View File

@ -9,16 +9,19 @@
"MixinBackgroundRenderer",
"MixinClientConnection",
"MixinClientPlayerEntity",
"MixinClientPlayerInteractionManager",
"MixinClientPlayNetworkHandler",
"MixinDebugHud",
"MixinExtClientPlayerEntity",
"MixinExtEntity",
"MixinExtMinecraftClient",
"MixinExtPlayerInteractEntityC2SPacket",
"MixinExtRenderTickCounter",
"MixinExtUpdatePlayerAbilitiesC2SPacket",
"MixinGameRenderer",
"MixinKeyboard",
"MixinMinecraftClient",
"MixinPlayerEntity",
"MixinRenderSectionManager",
"MixinWorldRenderer",
"netmoving.MixinClientPlayerEntity",