diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/co/fantabos/bscv/BoSCoVicino.java | 4 | ||||
-rw-r--r-- | src/main/java/co/fantabos/bscv/modules/FastInteract.java | 46 | ||||
-rw-r--r-- | src/main/java/co/fantabos/bscv/modules/hud/EntityList.java | 58 |
3 files changed, 108 insertions, 0 deletions
diff --git a/src/main/java/co/fantabos/bscv/BoSCoVicino.java b/src/main/java/co/fantabos/bscv/BoSCoVicino.java index 1808c99..23c1d48 100644 --- a/src/main/java/co/fantabos/bscv/BoSCoVicino.java +++ b/src/main/java/co/fantabos/bscv/BoSCoVicino.java @@ -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(); diff --git a/src/main/java/co/fantabos/bscv/modules/FastInteract.java b/src/main/java/co/fantabos/bscv/modules/FastInteract.java new file mode 100644 index 0000000..f9d9d29 --- /dev/null +++ b/src/main/java/co/fantabos/bscv/modules/FastInteract.java @@ -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(); + } + } +} diff --git a/src/main/java/co/fantabos/bscv/modules/hud/EntityList.java b/src/main/java/co/fantabos/bscv/modules/hud/EntityList.java new file mode 100644 index 0000000..ee013b7 --- /dev/null +++ b/src/main/java/co/fantabos/bscv/modules/hud/EntityList.java @@ -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; + } + } +} |