feat: added FastInteract and EntityList

This commit is contained in:
əlemi 2023-01-30 03:35:23 +01:00
parent a38a214a5e
commit 23cc6afc8f
No known key found for this signature in database
GPG key ID: BBCBFE5D7244634E
3 changed files with 108 additions and 0 deletions

View file

@ -65,8 +65,12 @@ public class BoSCoVicino {
builder.pop();
BoSCoVicino.mods.add(new VanillaFlight(builder, this.dispatcher));
builder.pop();
BoSCoVicino.mods.add(new FastInteract(builder, this.dispatcher));
builder.pop();
BoSCoVicino.mods.add(new Coordinates(builder, this.dispatcher));
builder.pop();
BoSCoVicino.mods.add(new EntityList(builder, this.dispatcher));
builder.pop();
BoSCoVicino.mods.add(new ActiveModules(builder, this.dispatcher));
builder.pop();

View file

@ -0,0 +1,46 @@
package co.fantabos.bscv.modules;
import static co.fantabos.bscv.BoSCoVicino.log;
import java.lang.reflect.Field;
import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.command.CommandSource;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import co.fantabos.bscv.Module;
import co.fantabos.bscv.BoSCoVicino;
public class FastInteract extends Module {
Field delayField;
public FastInteract(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
super("FastInteract", Group.CORE, builder, dispatcher);
}
@Override
protected void onEnabled() {
try {
delayField = BoSCoVicino.minecraft.getClass().getDeclaredField("field_71467_ac");
delayField.setAccessible(true);
} catch (NoSuchFieldException e) {
log("! failed accessing delay field");
this.disable();
}
}
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
if (BoSCoVicino.minecraft == null) return;
try {
this.delayField.set(BoSCoVicino.minecraft, 0);
} catch (IllegalAccessException e) {
log("! failed accessing delay field");
this.disable();
}
}
}

View file

@ -0,0 +1,58 @@
package co.fantabos.bscv.modules.hud;
import static co.fantabos.bscv.tools.Text.TextBuilder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import com.mojang.brigadier.CommandDispatcher;
import co.fantabos.bscv.BoSCoVicino;
import net.minecraft.command.CommandSource;
import net.minecraft.entity.Entity;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.eventbus.api.SubscribeEvent;
public class EntityList extends HudModule {
public EntityList(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
super("EntityList", builder, dispatcher);
}
@SubscribeEvent
public void onRenderOverlay(RenderGameOverlayEvent event) {
if (event.getType() != ElementType.TEXT) return;
List<String> entities = new ArrayList<>();
for (Entity e : BoSCoVicino.minecraft.level.entitiesForRendering()) {
// TODO do some filtering here?
entities.add(e.getName().getString());
}
List<String> uniques = new ArrayList<>();
for (String s : entities.stream().distinct().collect(Collectors.toList())) {
int num = Collections.frequency(entities, s);
if (num > 1) {
uniques.add(String.format("%s (%d)", s, num));
} else {
uniques.add(s);
}
}
int offset = 0;
for (String u : uniques) {
TextBuilder()
.txt(String.format("%s <", u))
.anchor(this.anchor.get())
.x(this.x.get())
.y(this.y.get() + offset)
.scale(this.scale.get())
.render(event.getMatrixStack(), event.getWindow());
offset += BoSCoVicino.minecraft.font.lineHeight;
}
}
}