inventive uses of attributes

This commit is contained in:
kawaiizenbo 2024-06-15 20:10:59 -07:00
parent 6cd03fab06
commit 507ed6b7e5
7 changed files with 87 additions and 28 deletions

View file

@ -3,7 +3,6 @@ package me.kawaiizenbo.moonlight.command.commands;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import me.kawaiizenbo.moonlight.command.Command;
import me.kawaiizenbo.moonlight.command.CommandManager;
import me.kawaiizenbo.moonlight.util.ChatUtils;
import me.kawaiizenbo.moonlight.util.ColorUtils;
import net.minecraft.command.CommandSource;

View file

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

View file

@ -21,7 +21,9 @@ public class ModuleManager
new ModulesList(),
new ChatSpammer(),
new Rotation(),
new AutoJump()
new AutoJump(),
new Reach(),
new AntiPowderSnow()
/*new Timer()*/
);
}

View file

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

View file

@ -2,19 +2,43 @@ package me.kawaiizenbo.moonlight.module.modules;
import me.kawaiizenbo.moonlight.module.Category;
import me.kawaiizenbo.moonlight.module.Module;
import me.kawaiizenbo.moonlight.module.settings.DoubleSetting;
import net.minecraft.entity.attribute.EntityAttributes;
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()
{
super("Reach", "Extends player reach.", Category.PLAYER);
super("Reach", "Extends player interaction distance.", Category.MOVEMENT);
settings.add(blockRange);
settings.add(entityRange);
}
@Override
public void onEnable()
{
super.onEnable();
// this will be completed in 1.20.5, as a new attribute will be added to make this trivial.
// mc.player.getAbilities().
oldBe = mc.player.getAttributeInstance(EntityAttributes.PLAYER_BLOCK_INTERACTION_RANGE).getBaseValue();
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);
}
}

View file

@ -5,38 +5,38 @@ import me.kawaiizenbo.moonlight.module.Module;
import me.kawaiizenbo.moonlight.module.settings.DoubleSetting;
import me.kawaiizenbo.moonlight.util.MathUtils;
import net.minecraft.entity.MovementType;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.util.math.Vec3d;
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()
{
super("Speed", "Allows you to move faster. (Deprecated)", Category.MOVEMENT);
super("Speed", "Allows you to move faster.", Category.MOVEMENT);
settings.add(speed);
}
@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
if (mc.player.forwardSpeed == 0 && mc.player.sidewaysSpeed == 0 && mc.player.isOnGround())
{
mc.player.setVelocity(0, 0, 0);
super.onEnable();
old = mc.player.getAttributeInstance(EntityAttributes.GENERIC_MOVEMENT_SPEED).getBaseValue();
}
Vec3d move = new Vec3d(mc.player.getX() - mc.player.prevX, 0, mc.player.getZ() - mc.player.prevZ).multiply(20);
double mps = Math.abs(MathUtils.length2D(move));
double normal = mc.player.isSprinting() ? 5.61 : 4.31;
if (mps > normal * speed.value)
@Override
public void tick()
{
return;
mc.player.getAttributeInstance(EntityAttributes.GENERIC_MOVEMENT_SPEED).setBaseValue(speed.value/10d);
}
if (mc.player.isOnGround())
@Override
public void onDisable()
{
mc.player.setVelocity(mc.player.getVelocity().x * speed.value, 0, mc.player.getVelocity().z * speed.value);
}
super.onDisable();
mc.player.getAttributeInstance(EntityAttributes.GENERIC_MOVEMENT_SPEED).setBaseValue(old);
}
}

View file

@ -13,7 +13,8 @@
"KeyboardMixin",
"SimpleOptionMixin",
"MinecraftClientMixin",
"ClientPlayerEntityMixin"
"ClientPlayerEntityMixin",
"PowderSnowBlockMixin"
],
"injectors": {
"defaultRequire": 1