forked from RepoMirrors/kami-blue
close #579 and add cobwebs to noslow
This commit is contained in:
parent
ba0111fa13
commit
f8345b7d2f
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
|
@ -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<Boolean> soulSand = register(Settings.b("Soul Sand", true));
|
||||
public Setting<Boolean> cobweb = register(Settings.b("Cobweb", true));
|
||||
private Setting<Boolean> slime = register(Settings.b("Slime", true));
|
||||
private Setting<Boolean> allItems = register(Settings.b("All Items", false));
|
||||
private Setting<Boolean> food = register(Settings.booleanBuilder().withName("Food").withValue(true).withVisibility(v -> !allItems.getValue()).build());
|
||||
private Setting<Boolean> bow = register(Settings.booleanBuilder().withName("Bows").withValue(true).withVisibility(v -> !allItems.getValue()).build());
|
||||
private Setting<Boolean> potion = register(Settings.booleanBuilder().withName("Potions").withValue(true).withVisibility(v -> !allItems.getValue()).build());
|
||||
private Setting<Boolean> shield = register(Settings.booleanBuilder().withName("Shield").withValue(true).withVisibility(v -> !allItems.getValue()).build());
|
||||
|
||||
@EventHandler
|
||||
private Listener<InputUpdateEvent> 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
"MixinAbstractClientPlayer",
|
||||
"MixinBlockLiquid",
|
||||
"MixinBlockSoulSand",
|
||||
"MixinBlockWeb",
|
||||
"MixinC00Handshake",
|
||||
"MixinChunkCache",
|
||||
"MixinEntity",
|
||||
|
|
Loading…
Reference in New Issue