inventive uses of attributes
This commit is contained in:
parent
6cd03fab06
commit
507ed6b7e5
7 changed files with 87 additions and 28 deletions
|
@ -3,7 +3,6 @@ package me.kawaiizenbo.moonlight.command.commands;
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
|
|
||||||
import me.kawaiizenbo.moonlight.command.Command;
|
import me.kawaiizenbo.moonlight.command.Command;
|
||||||
import me.kawaiizenbo.moonlight.command.CommandManager;
|
|
||||||
import me.kawaiizenbo.moonlight.util.ChatUtils;
|
import me.kawaiizenbo.moonlight.util.ChatUtils;
|
||||||
import me.kawaiizenbo.moonlight.util.ColorUtils;
|
import me.kawaiizenbo.moonlight.util.ColorUtils;
|
||||||
import net.minecraft.command.CommandSource;
|
import net.minecraft.command.CommandSource;
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package me.kawaiizenbo.moonlight.mixin;
|
||||||
|
|
||||||
|
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.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
import me.kawaiizenbo.moonlight.module.ModuleManager;
|
||||||
|
import net.minecraft.block.PowderSnowBlock;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
|
||||||
|
@Mixin(PowderSnowBlock.class)
|
||||||
|
public class PowderSnowBlockMixin
|
||||||
|
{
|
||||||
|
|
||||||
|
@Inject(at = @At("HEAD"), method = "canWalkOnPowderSnow", cancellable = true)
|
||||||
|
private static void canWalkOnPowderSnow(Entity entity, CallbackInfoReturnable<Boolean> cir)
|
||||||
|
{
|
||||||
|
if (ModuleManager.INSTANCE.getModuleByName("Anti Powder Snow").enabled) cir.setReturnValue(true);
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,7 +21,9 @@ public class ModuleManager
|
||||||
new ModulesList(),
|
new ModulesList(),
|
||||||
new ChatSpammer(),
|
new ChatSpammer(),
|
||||||
new Rotation(),
|
new Rotation(),
|
||||||
new AutoJump()
|
new AutoJump(),
|
||||||
|
new Reach(),
|
||||||
|
new AntiPowderSnow()
|
||||||
/*new Timer()*/
|
/*new Timer()*/
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package me.kawaiizenbo.moonlight.module.modules;
|
||||||
|
|
||||||
|
import me.kawaiizenbo.moonlight.module.Category;
|
||||||
|
import me.kawaiizenbo.moonlight.module.Module;
|
||||||
|
|
||||||
|
public class AntiPowderSnow extends Module
|
||||||
|
{
|
||||||
|
public AntiPowderSnow()
|
||||||
|
{
|
||||||
|
super("Anti Powder Snow", "Allows the player to walk on powder snow.", Category.PLAYER);
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,19 +2,43 @@ package me.kawaiizenbo.moonlight.module.modules;
|
||||||
|
|
||||||
import me.kawaiizenbo.moonlight.module.Category;
|
import me.kawaiizenbo.moonlight.module.Category;
|
||||||
import me.kawaiizenbo.moonlight.module.Module;
|
import me.kawaiizenbo.moonlight.module.Module;
|
||||||
|
import me.kawaiizenbo.moonlight.module.settings.DoubleSetting;
|
||||||
|
import net.minecraft.entity.attribute.EntityAttributes;
|
||||||
|
|
||||||
public class Reach extends Module
|
public class Reach extends Module
|
||||||
{
|
{
|
||||||
|
DoubleSetting blockRange = new DoubleSetting("Block Range", 4.5, 1, 10, 1);
|
||||||
|
DoubleSetting entityRange = new DoubleSetting("Entity Range", 3.0, 1, 10, 1);
|
||||||
|
double oldBe = 4.5;
|
||||||
|
double oldEe = 3.0;
|
||||||
|
|
||||||
public Reach()
|
public Reach()
|
||||||
{
|
{
|
||||||
super("Reach", "Extends player reach.", Category.PLAYER);
|
super("Reach", "Extends player interaction distance.", Category.MOVEMENT);
|
||||||
|
settings.add(blockRange);
|
||||||
|
settings.add(entityRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable()
|
public void onEnable()
|
||||||
{
|
{
|
||||||
super.onEnable();
|
super.onEnable();
|
||||||
// this will be completed in 1.20.5, as a new attribute will be added to make this trivial.
|
oldBe = mc.player.getAttributeInstance(EntityAttributes.PLAYER_BLOCK_INTERACTION_RANGE).getBaseValue();
|
||||||
// mc.player.getAbilities().
|
oldEe = mc.player.getAttributeInstance(EntityAttributes.PLAYER_ENTITY_INTERACTION_RANGE).getBaseValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tick()
|
||||||
|
{
|
||||||
|
mc.player.getAttributeInstance(EntityAttributes.PLAYER_BLOCK_INTERACTION_RANGE).setBaseValue(blockRange.value);
|
||||||
|
mc.player.getAttributeInstance(EntityAttributes.PLAYER_ENTITY_INTERACTION_RANGE).setBaseValue(entityRange.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable()
|
||||||
|
{
|
||||||
|
super.onDisable();
|
||||||
|
mc.player.getAttributeInstance(EntityAttributes.PLAYER_BLOCK_INTERACTION_RANGE).setBaseValue(oldBe);
|
||||||
|
mc.player.getAttributeInstance(EntityAttributes.PLAYER_ENTITY_INTERACTION_RANGE).setBaseValue(oldEe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,38 +5,38 @@ import me.kawaiizenbo.moonlight.module.Module;
|
||||||
import me.kawaiizenbo.moonlight.module.settings.DoubleSetting;
|
import me.kawaiizenbo.moonlight.module.settings.DoubleSetting;
|
||||||
import me.kawaiizenbo.moonlight.util.MathUtils;
|
import me.kawaiizenbo.moonlight.util.MathUtils;
|
||||||
import net.minecraft.entity.MovementType;
|
import net.minecraft.entity.MovementType;
|
||||||
|
import net.minecraft.entity.attribute.EntityAttributes;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
public class Speed extends Module
|
public class Speed extends Module
|
||||||
{
|
{
|
||||||
float oldSpeed;
|
double old = 0.1;
|
||||||
|
|
||||||
DoubleSetting speed = new DoubleSetting("Speed", 2, 0.1, 10, 1);
|
DoubleSetting speed = new DoubleSetting("Speed", 1.4, 0.1, 10, 1);
|
||||||
public Speed()
|
public Speed()
|
||||||
{
|
{
|
||||||
super("Speed", "Allows you to move faster. (Deprecated)", Category.MOVEMENT);
|
super("Speed", "Allows you to move faster.", Category.MOVEMENT);
|
||||||
settings.add(speed);
|
settings.add(speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMotion(MovementType type, Vec3d movement)
|
public void onEnable()
|
||||||
{
|
{
|
||||||
// this is a little janky but it works, will find a better solution later
|
super.onEnable();
|
||||||
if (mc.player.forwardSpeed == 0 && mc.player.sidewaysSpeed == 0 && mc.player.isOnGround())
|
old = mc.player.getAttributeInstance(EntityAttributes.GENERIC_MOVEMENT_SPEED).getBaseValue();
|
||||||
{
|
}
|
||||||
mc.player.setVelocity(0, 0, 0);
|
|
||||||
}
|
@Override
|
||||||
Vec3d move = new Vec3d(mc.player.getX() - mc.player.prevX, 0, mc.player.getZ() - mc.player.prevZ).multiply(20);
|
public void tick()
|
||||||
double mps = Math.abs(MathUtils.length2D(move));
|
{
|
||||||
double normal = mc.player.isSprinting() ? 5.61 : 4.31;
|
mc.player.getAttributeInstance(EntityAttributes.GENERIC_MOVEMENT_SPEED).setBaseValue(speed.value/10d);
|
||||||
if (mps > normal * speed.value)
|
}
|
||||||
{
|
|
||||||
return;
|
@Override
|
||||||
}
|
public void onDisable()
|
||||||
if (mc.player.isOnGround())
|
{
|
||||||
{
|
super.onDisable();
|
||||||
mc.player.setVelocity(mc.player.getVelocity().x * speed.value, 0, mc.player.getVelocity().z * speed.value);
|
mc.player.getAttributeInstance(EntityAttributes.GENERIC_MOVEMENT_SPEED).setBaseValue(old);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,8 @@
|
||||||
"KeyboardMixin",
|
"KeyboardMixin",
|
||||||
"SimpleOptionMixin",
|
"SimpleOptionMixin",
|
||||||
"MinecraftClientMixin",
|
"MinecraftClientMixin",
|
||||||
"ClientPlayerEntityMixin"
|
"ClientPlayerEntityMixin",
|
||||||
|
"PowderSnowBlockMixin"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
|
|
Loading…
Add table
Reference in a new issue