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

@ -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().
super.onEnable();
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);
}
}