diff --git a/src/main/java/me/zeroeightsix/kami/mixin/client/MixinBlockSoulSand.java b/src/main/java/me/zeroeightsix/kami/mixin/client/MixinBlockSoulSand.java index 0cd6e4eb..d1ad6ec8 100644 --- a/src/main/java/me/zeroeightsix/kami/mixin/client/MixinBlockSoulSand.java +++ b/src/main/java/me/zeroeightsix/kami/mixin/client/MixinBlockSoulSand.java @@ -1,6 +1,7 @@ package me.zeroeightsix.kami.mixin.client; import me.zeroeightsix.kami.module.ModuleManager; +import me.zeroeightsix.kami.module.modules.movement.NoSlowDown; import net.minecraft.block.BlockSoulSand; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; @@ -20,7 +21,7 @@ public class MixinBlockSoulSand { @Inject(method = "onEntityCollision", at = @At("HEAD"), cancellable = true) public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn, CallbackInfo info) { // If noslowdown is on, just don't do anything else in this method (slow the player) - if (ModuleManager.isModuleEnabled("NoSlowDown")) info.cancel(); + if (ModuleManager.isModuleEnabled("NoSlowDown") && ((NoSlowDown) ModuleManager.getModuleByName("NoSlowDown")).soulSand.getValue()) info.cancel(); } } diff --git a/src/main/java/me/zeroeightsix/kami/mixin/client/MixinBlockWeb.java b/src/main/java/me/zeroeightsix/kami/mixin/client/MixinBlockWeb.java new file mode 100644 index 00000000..b197262a --- /dev/null +++ b/src/main/java/me/zeroeightsix/kami/mixin/client/MixinBlockWeb.java @@ -0,0 +1,28 @@ +package me.zeroeightsix.kami.mixin.client; + +import me.zeroeightsix.kami.module.ModuleManager; +import me.zeroeightsix.kami.module.modules.movement.NoSlowDown; +import net.minecraft.block.BlockWeb; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.Entity; +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.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +/** + * @see MixinBlockSoulSand + * @author 086 + */ +@Mixin(BlockWeb.class) +public class MixinBlockWeb { + + @Inject(method = "onEntityCollision", at = @At("HEAD"), cancellable = true) + public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn, CallbackInfo info) { + // If noslowdown is on, just don't do anything else in this method (slow the player) + if (ModuleManager.isModuleEnabled("NoSlowDown") && ((NoSlowDown) ModuleManager.getModuleByName("NoSlowDown")).cobweb.getValue()) info.cancel(); + } + +} diff --git a/src/main/java/me/zeroeightsix/kami/module/modules/movement/NoSlowDown.java b/src/main/java/me/zeroeightsix/kami/module/modules/movement/NoSlowDown.java index 37d8b300..8aac742c 100644 --- a/src/main/java/me/zeroeightsix/kami/module/modules/movement/NoSlowDown.java +++ b/src/main/java/me/zeroeightsix/kami/module/modules/movement/NoSlowDown.java @@ -3,28 +3,58 @@ package me.zeroeightsix.kami.module.modules.movement; import me.zero.alpine.listener.EventHandler; import me.zero.alpine.listener.Listener; import me.zeroeightsix.kami.module.Module; +import me.zeroeightsix.kami.setting.Setting; +import me.zeroeightsix.kami.setting.Settings; +import net.minecraft.init.Blocks; +import net.minecraft.item.*; import net.minecraftforge.client.event.InputUpdateEvent; /** * Created by 086 on 15/12/2017. + * Updated by S-B99 on 21/03/20 + * @see me.zeroeightsix.kami.mixin.client.MixinBlockSoulSand + * @see net.minecraft.client.entity.EntityPlayerSP .onLivingUpdate() */ @Module.Info(name = "NoSlowDown", category = Module.Category.MOVEMENT, description = "Prevents being slowed down when using an item or going through cobwebs") public class NoSlowDown extends Module { + public Setting soulSand = register(Settings.b("Soul Sand", true)); + public Setting cobweb = register(Settings.b("Cobweb", true)); + private Setting slime = register(Settings.b("Slime", true)); + private Setting allItems = register(Settings.b("All Items", false)); + private Setting food = register(Settings.booleanBuilder().withName("Food").withValue(true).withVisibility(v -> !allItems.getValue()).build()); + private Setting bow = register(Settings.booleanBuilder().withName("Bows").withValue(true).withVisibility(v -> !allItems.getValue()).build()); + private Setting potion = register(Settings.booleanBuilder().withName("Potions").withValue(true).withVisibility(v -> !allItems.getValue()).build()); + private Setting shield = register(Settings.booleanBuilder().withName("Shield").withValue(true).withVisibility(v -> !allItems.getValue()).build()); @EventHandler private Listener eventListener = new Listener<>(event -> { - // - // InputUpdateEvent is called just before the player is slowed down @see EntityPlayerSP.onLivingUpdate) - // We'll abuse this fact, and multiply moveStrafe and moveForward by 5 to nullify the *0.2f hardcoded by mojang. - // + /* + * InputUpdateEvent is called just before the player is slowed down @see EntityPlayerSP.onLivingUpdate) + * We'll abuse this fact, and multiply moveStrafe and moveForward by 5 to nullify the *0.2f hardcoded by mojang. + */ // Check if the player should be slowed down or not - if (mc.player.isHandActive() && !mc.player.isRiding()) { + if (passItemCheck(mc.player.getActiveItemStack().getItem()) && mc.player.isHandActive() && !mc.player.isRiding()) { event.getMovementInput().moveStrafe *= 5; event.getMovementInput().moveForward *= 5; } }); - // Check MixinBlockSoulSand for soulsand slowdown nullification + @Override + public void onUpdate() { + if (slime.getValue()) Blocks.SLIME_BLOCK.slipperiness = 0.4945f; // normal block speed 0.4945 + else Blocks.SLIME_BLOCK.slipperiness = 0.8f; + } + @Override + public void onDisable() { Blocks.SLIME_BLOCK.slipperiness = 0.8f; } + + private boolean passItemCheck(Item item) { + if (allItems.getValue()) return true; + if (food.getValue() && item instanceof ItemFood) return true; + if (bow.getValue() && item instanceof ItemBow) return true; + if (potion.getValue() && item instanceof ItemPotion) return true; + if (shield.getValue() && item instanceof ItemShield) return true; + return false; + } } diff --git a/src/main/resources/mixins.kami.json b/src/main/resources/mixins.kami.json index 7222d0ad..373bb85f 100644 --- a/src/main/resources/mixins.kami.json +++ b/src/main/resources/mixins.kami.json @@ -7,6 +7,7 @@ "MixinAbstractClientPlayer", "MixinBlockLiquid", "MixinBlockSoulSand", + "MixinBlockWeb", "MixinC00Handshake", "MixinChunkCache", "MixinEntity",