From ab6e3c904b6833d8142d4cdc553a0fb877b088aa Mon Sep 17 00:00:00 2001 From: zeroeightsix Date: Wed, 3 Oct 2018 15:05:26 +0200 Subject: [PATCH] Implement TpsSync --- .../mixin/client/MixinPlayerControllerMP.java | 25 +++++++++++++++++++ src/main/resources/mixins.kami.json | 3 ++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/main/java/me/zeroeightsix/kami/mixin/client/MixinPlayerControllerMP.java diff --git a/src/main/java/me/zeroeightsix/kami/mixin/client/MixinPlayerControllerMP.java b/src/main/java/me/zeroeightsix/kami/mixin/client/MixinPlayerControllerMP.java new file mode 100644 index 000000000..e0b406f7c --- /dev/null +++ b/src/main/java/me/zeroeightsix/kami/mixin/client/MixinPlayerControllerMP.java @@ -0,0 +1,25 @@ +package me.zeroeightsix.kami.mixin.client; + +import me.zeroeightsix.kami.module.modules.player.TpsSync; +import me.zeroeightsix.kami.util.LagCompensator; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.multiplayer.PlayerControllerMP; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +/** + * Created by 086 on 3/10/2018. + */ +@Mixin(PlayerControllerMP.class) +public class MixinPlayerControllerMP { + + @Redirect(method = "onPlayerDamageBlock", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/state/IBlockState;getPlayerRelativeBlockHardness(Lnet/minecraft/entity/player/EntityPlayer;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)F")) + float getPlayerRelativeBlockHardness(IBlockState state, EntityPlayer player, World worldIn, BlockPos pos) { + return state.getPlayerRelativeBlockHardness(player, worldIn, pos) * (TpsSync.isSync() ? (LagCompensator.INSTANCE.getTickRate() / 20f) : 1); + } + +} diff --git a/src/main/resources/mixins.kami.json b/src/main/resources/mixins.kami.json index 37ea9a0fe..5e45c68ec 100644 --- a/src/main/resources/mixins.kami.json +++ b/src/main/resources/mixins.kami.json @@ -20,6 +20,7 @@ "MixinGuiPlayerTabOverlay", "MixinC00Handshake", "MixinNetHandlerPlayClient", - "MixinRenderLiving" + "MixinRenderLiving", + "MixinPlayerControllerMP" ] }