Compare commits

...

5 commits

36 changed files with 451 additions and 252 deletions

View file

@ -4,10 +4,4 @@ end_of_line = lf
insert_final_newline = true insert_final_newline = true
charset = utf-8 charset = utf-8
indent_style = tab indent_style = tab
indent_size = 4
[*.java]
indent_size = 2 indent_size = 2
[*.gradle]
indent_size = 4

View file

@ -4,13 +4,14 @@ plugins {
alias libs.plugins.forgeGradle alias libs.plugins.forgeGradle
alias libs.plugins.gitVersion alias libs.plugins.gitVersion
alias libs.plugins.checkerFramework alias libs.plugins.checkerFramework
alias libs.plugins.shadow
} }
version = gitVersion() version = gitVersion()
group = 'ftbsc' group = 'ftbsc'
archivesBaseName = 'bscv' archivesBaseName = 'bscv'
def shortVersion = version.split('-')[0].replaceAll(".dirty", "") // necessary when there are no extra commits on tags, and thus no dash def shortVersion = (version as String).split('-')[0].replaceAll(".dirty", "")
project.ext { project.ext {
deployJarDo = getProjectProperty("deployJar.do", "false") deployJarDo = getProjectProperty("deployJar.do", "false")
@ -61,6 +62,9 @@ dependencies {
implementation libs.lillero implementation libs.lillero
implementation libs.lilleroProcessor implementation libs.lilleroProcessor
implementation libs.autoServiceAnnotations implementation libs.autoServiceAnnotations
implementation libs.luaJava
implementation libs.luaJit
runtimeOnly libs.luaNatives.get().toString() + ":natives-desktop" //lol
annotationProcessor libs.lilleroProcessor annotationProcessor libs.lilleroProcessor
annotationProcessor libs.autoService annotationProcessor libs.autoService
} }
@ -69,8 +73,26 @@ compileJava { //mappings for lillero-processor
options.compilerArgs << '-AmappingsFile=https://data.fantabos.co/1.16.5.tsrg' options.compilerArgs << '-AmappingsFile=https://data.fantabos.co/1.16.5.tsrg'
} }
def simpleFileName = "${jar.archiveBaseName.get()}-${shortVersion}.${jar.archiveExtension.get()}"
jar { jar {
archiveFileName = "${jar.archiveBaseName.get()}-${shortVersion}.${jar.archiveExtension.get()}" archiveFileName = simpleFileName
}
shadowJar {
archiveFileName = simpleFileName
relocate('com.badlogicgames.gdx', 'b') { //needed for luajava
include 'com.badlogicgames.gdx.utils.SharedLibraryLoad*'
}
dependencies {
include(
dependency {
it.moduleGroup == 'party.iroiro.luajava'
|| it.moduleGroup == 'com.badlogicgames.gdx'
}
)
}
manifest { manifest {
attributes([ attributes([
"Specification-Title": "bscv", "Specification-Title": "bscv",
@ -84,7 +106,14 @@ jar {
} }
} }
jar.finalizedBy('reobfJar') reobf {
jar {
dependsOn shadowJar
}
shadowJar {
dependsOn jar
}
}
//copy jar from build/libs to the forge mod folder //copy jar from build/libs to the forge mod folder
tasks.register('deployJar', Copy) { tasks.register('deployJar', Copy) {

View file

@ -7,11 +7,14 @@ autoService = "1.0.1"
lillero = "0.4.1" lillero = "0.4.1"
lilleroProcessor = "0.5.2" lilleroProcessor = "0.5.2"
checkerFramework = "0.6.24" checkerFramework = "0.6.24"
shadow = "7.1.2"
luaJava = "3.5.0"
[plugins] [plugins]
forgeGradle = { id = "net.minecraftforge.gradle", version.ref = "forgeGradle" } forgeGradle = { id = "net.minecraftforge.gradle", version.ref = "forgeGradle" }
gitVersion = { id = "com.palantir.git-version", version.ref = "gitVersion" } gitVersion = { id = "com.palantir.git-version", version.ref = "gitVersion" }
checkerFramework = { id = "org.checkerframework", version.ref = "checkerFramework" } checkerFramework = { id = "org.checkerframework", version.ref = "checkerFramework" }
shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadow" }
[libraries] [libraries]
minecraftForge = { group = "net.minecraftforge", name = "forge", version.ref = "forge" } minecraftForge = { group = "net.minecraftforge", name = "forge", version.ref = "forge" }
@ -19,3 +22,6 @@ autoService = { group = "com.google.auto.service", name = "auto-service", versio
autoServiceAnnotations = { group = "com.google.auto.service", name = "auto-service-annotations", version.ref = "autoService" } autoServiceAnnotations = { group = "com.google.auto.service", name = "auto-service-annotations", version.ref = "autoService" }
lillero = { group = "ftbsc", name = "lll", version.ref = "lillero" } lillero = { group = "ftbsc", name = "lll", version.ref = "lillero" }
lilleroProcessor = { group = "ftbsc.lll", name = "processor", version.ref = "lilleroProcessor" } lilleroProcessor = { group = "ftbsc.lll", name = "processor", version.ref = "lilleroProcessor" }
luaJava = { group = "party.iroiro.luajava", name = "luajava", version.ref = "luaJava" }
luaJit = { group = "party.iroiro.luajava", name = "luajit", version.ref = "luaJava" }
luaNatives = { group = "party.iroiro.luajava", name = "luajit-platform", version.ref = "luaJava" }

View file

@ -6,9 +6,7 @@ import com.mojang.brigadier.tree.CommandNode;
import ftbsc.bscv.api.IModule; import ftbsc.bscv.api.IModule;
import ftbsc.bscv.patches.CommandsPatch.CommandsBuiltEvent; import ftbsc.bscv.patches.CommandsPatch.CommandsBuiltEvent;
import ftbsc.bscv.system.Friends; import ftbsc.bscv.system.*;
import ftbsc.bscv.system.ModManager;
import ftbsc.bscv.system.Ruler;
import net.minecraft.client.gui.screen.IngameMenuScreen; import net.minecraft.client.gui.screen.IngameMenuScreen;
import net.minecraft.client.gui.widget.button.Button; import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.command.CommandSource; import net.minecraft.command.CommandSource;
@ -27,49 +25,82 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
@Mod("bscv") @Mod(Boscovicino.MOD_ID)
public class Boscovicino implements ICommons { public class Boscovicino implements ICommons {
public static String MOD_ID = "bscv"; public static final String MOD_ID = "bscv";
public static final Logger LOGGER = LogManager.getLogger(); public static final Logger LOGGER = LogManager.getLogger();
public static ModManager modManager; //todo this should not be static
private final CommandDispatcher<CommandSource> dispatcher = new CommandDispatcher<>(); private final CommandDispatcher<CommandSource> dispatcher = new CommandDispatcher<>();
public static ForgeConfigSpec spec; public final ForgeConfigSpec spec;
private static Friends friends; public final Modules modules;
public static Friends friends() { return Boscovicino.friends; } public final Friends friends;
public final Bindings bindings;
public final Macros macros;
@SuppressWarnings("unused") // it just needs to exist to be used by player @SuppressWarnings({"unused", "FieldCanBeLocal"}) // it just needs to exist to be used by player
private static Ruler ruler; private final Ruler ruler; //TODO remove
public Boscovicino() { public Boscovicino() throws IOException, ReflectiveOperationException {
// add listener
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onSetupComplete); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onSetupComplete);
// initialise config
ForgeConfigSpec.Builder cfg = new ForgeConfigSpec.Builder(); ForgeConfigSpec.Builder cfg = new ForgeConfigSpec.Builder();
CommandDispatcher<CommandSource> dp = this.dispatcher; CommandDispatcher<CommandSource> dp = this.dispatcher;
Boscovicino.modManager = new ModManager(cfg, dp); // load modules
Boscovicino.modManager.load(); this.modules = new Modules(cfg, dp);
this.modules.load();
this.modules.finish();
Boscovicino.modManager.finish(); this.ruler = new Ruler(); //TODO remove
Boscovicino.ruler = new Ruler(); // macros and bindings
ForgeConfigSpec.Builder bindingSpec = new ForgeConfigSpec.Builder();
Boscovicino.spec = cfg.build(); this.bindings = new Bindings(bindingSpec);
this.macros = new Macros(this);
//friends
ForgeConfigSpec.Builder friendSpec = new ForgeConfigSpec.Builder(); ForgeConfigSpec.Builder friendSpec = new ForgeConfigSpec.Builder();
Boscovicino.friends = new Friends(friendSpec, dp); this.friends = new Friends(friendSpec, dp);
// register config handler // register config handlers
ModLoadingContext.get().registerConfig(Type.CLIENT, spec, "bscv.toml"); this.spec = cfg.build();
ModLoadingContext.get().registerConfig(Type.CLIENT, this.spec, "bscv.toml");
ModLoadingContext.get().registerConfig(Type.CLIENT, friendSpec.build(), "friends.toml"); ModLoadingContext.get().registerConfig(Type.CLIENT, friendSpec.build(), "friends.toml");
ModLoadingContext.get().registerConfig(Type.CLIENT, bindingSpec.build(), "bindings.toml");
// Register ourselves for server and other game events we are interested in // register ourselves for server and other game events we are interested in
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
// set the ICommons instance with reflection magic
// should go without saying, but don't access BSCV's members before loading is complete
Field instance = ICommons.class.getDeclaredField("BSCV");
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setInt(instance, instance.getModifiers() & ~Modifier.FINAL); //make non final
instance.set(null, this); //set instance
modifiersField.setInt(instance, instance.getModifiers() & Modifier.FINAL); //make it final again
}
/**
* Fake constructor, only used to set the temporary value of {@link ICommons#BSCV}.
* The sole purpose of this is to make the language server shut up about null pointer exceptions.
* @param ignored dummy parameter to distinguish from real constructor.
*/
Boscovicino(boolean ignored) {
this.modules = null;
this.ruler = null;
this.bindings = null;
this.macros = null;
this.friends = null;
this.spec = null;
} }
public static void log(String message, Object... args) { public static void log(String message, Object... args) {
@ -86,7 +117,7 @@ public class Boscovicino implements ICommons {
private void onSetupComplete(final FMLLoadCompleteEvent event) { private void onSetupComplete(final FMLLoadCompleteEvent event) {
LOGGER.info("Initializing modules"); LOGGER.info("Initializing modules");
for (IModule m : modManager.mods) { for (IModule m : modules.mods) {
if (m.isEnabled()) { if (m.isEnabled()) {
m.enable(); // re-run enable() to register on the event bus and run enabled callbacks m.enable(); // re-run enable() to register on the event bus and run enabled callbacks
} }
@ -102,8 +133,8 @@ public class Boscovicino implements ICommons {
@SubscribeEvent @SubscribeEvent
public void onClientChatEvent(ClientChatEvent event) { public void onClientChatEvent(ClientChatEvent event) {
if (event.getMessage().startsWith("/")) { if (MC.player != null && event.getMessage().startsWith("/")) {
CommandSource source = MC.player.createCommandSourceStack(); // TODO player could be NULL CommandSource source = MC.player.createCommandSourceStack();
try { try {
LOGGER.info(String.format("Running command %s", event.getMessage())); LOGGER.info(String.format("Running command %s", event.getMessage()));
this.dispatcher.execute(event.getMessage().substring(1), source); this.dispatcher.execute(event.getMessage().substring(1), source);
@ -116,14 +147,15 @@ public class Boscovicino implements ICommons {
} }
@SubscribeEvent @SubscribeEvent
// TODO de-jank this, maybe by extending IngameMenuScreen
public void onPauseMenu(InitGuiEvent.Post event) { public void onPauseMenu(InitGuiEvent.Post event) {
if (event.getGui() instanceof IngameMenuScreen) { // TODO de-jank this, maybe by extending IngameMenuScreen if (event.getGui() instanceof IngameMenuScreen) {
IngameMenuScreen screen = (IngameMenuScreen) event.getGui(); IngameMenuScreen screen = (IngameMenuScreen) event.getGui();
screen.buttons.remove(3); screen.buttons.remove(3);
screen.buttons.remove(3); screen.buttons.remove(3);
screen.children.remove(3); screen.children.remove(3);
screen.children.remove(3); screen.children.remove(3);
Button mods_btn = new Button( Button modsBtn = new Button(
screen.width / 2 + 4, screen.width / 2 + 4,
screen.height / 4 + 72 + -16, 98, 20, screen.height / 4 + 72 + -16, 98, 20,
new TranslationTextComponent("fml.menu.mods"), new TranslationTextComponent("fml.menu.mods"),
@ -132,10 +164,10 @@ public class Boscovicino implements ICommons {
} }
); );
// need to add it twice for it to work once... // need to add it twice for it to work once...
screen.buttons.add(3, mods_btn); screen.buttons.add(3, modsBtn);
screen.buttons.add(3, mods_btn); screen.buttons.add(3, modsBtn);
screen.children.add(3, mods_btn); screen.children.add(3, modsBtn);
screen.children.add(3, mods_btn); screen.children.add(3, modsBtn);
} }
} }
} }

View file

@ -3,5 +3,6 @@ package ftbsc.bscv;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
public interface ICommons { public interface ICommons {
public static final Minecraft MC = Minecraft.getInstance(); Minecraft MC = Minecraft.getInstance();
Boscovicino BSCV = new Boscovicino(true); //actually overwritten via reflection with the real instance
} }

View file

@ -6,7 +6,6 @@ import java.util.List;
import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import ftbsc.bscv.Boscovicino;
import ftbsc.bscv.ICommons; import ftbsc.bscv.ICommons;
import ftbsc.bscv.api.ICommand; import ftbsc.bscv.api.ICommand;
import net.minecraft.command.CommandSource; import net.minecraft.command.CommandSource;
@ -19,7 +18,7 @@ public abstract class AbstractCommand implements ICommand, ICommons {
} }
public CommandDispatcher<CommandSource> getDispatcher() { public CommandDispatcher<CommandSource> getDispatcher() {
return Boscovicino.modManager.getDispatcher(); return BSCV.modules.getDispatcher();
} }
public List<LiteralArgumentBuilder<CommandSource>> subcommands() { public List<LiteralArgumentBuilder<CommandSource>> subcommands() {

View file

@ -21,6 +21,8 @@ public class Cursor extends AbstractCommand {
.then( .then(
Commands.literal("info") Commands.literal("info")
.executes(ctx -> { .executes(ctx -> {
if (MC.level == null || MC.hitResult == null)
return 0;
switch (MC.hitResult.getType()) { switch (MC.hitResult.getType()) {
case BLOCK: case BLOCK:
BlockRayTraceResult result = (BlockRayTraceResult) MC.hitResult; BlockRayTraceResult result = (BlockRayTraceResult) MC.hitResult;

View file

@ -24,6 +24,8 @@ public class ItemCommand extends AbstractCommand {
.then( .then(
Commands.literal("damage") Commands.literal("damage")
.executes(ctx -> { .executes(ctx -> {
if(MC.player == null)
return 0;
Slot slot = Inventory.hotbar(MC.player).get(MC.player.inventory.selected); Slot slot = Inventory.hotbar(MC.player).get(MC.player.inventory.selected);
if (!slot.hasItem()) return 0; if (!slot.hasItem()) return 0;
log( log(
@ -49,6 +51,8 @@ public class ItemCommand extends AbstractCommand {
) )
) )
.executes(ctx -> { .executes(ctx -> {
if(MC.player == null)
return 0;
Slot slot = Inventory.hotbar(MC.player).get(MC.player.inventory.selected); Slot slot = Inventory.hotbar(MC.player).get(MC.player.inventory.selected);
if (!slot.hasItem()) return 0; if (!slot.hasItem()) return 0;
log(slot.getItem().toString()); log(slot.getItem().toString());

View file

@ -22,7 +22,7 @@ public class ModCommands extends AbstractCommand {
.then( .then(
Commands.literal("off") Commands.literal("off")
.executes(ctx -> { .executes(ctx -> {
for (IModule mod : Boscovicino.modManager.mods) { for (IModule mod : BSCV.modules.mods) {
if (mod.isEnabled()) { if (mod.isEnabled()) {
mod.disable(); mod.disable();
} }
@ -33,7 +33,7 @@ public class ModCommands extends AbstractCommand {
.then( .then(
Commands.literal("re-enable") // this is to fix some jankyness in event subscriptions Commands.literal("re-enable") // this is to fix some jankyness in event subscriptions
.executes(ctx -> { .executes(ctx -> {
for (IModule mod : Boscovicino.modManager.mods) { for (IModule mod : BSCV.modules.mods) {
if (mod.isEnabled()) { if (mod.isEnabled()) {
mod.disable(); mod.disable();
mod.enable(); mod.enable();
@ -43,8 +43,8 @@ public class ModCommands extends AbstractCommand {
}) })
) )
.executes(ctx -> { .executes(ctx -> {
String mods = Boscovicino.modManager.mods.stream() String mods = BSCV.modules.mods.stream()
.map(x -> x.getName()) .map(ILoadable::getName)
.collect(Collectors.joining(",")); .collect(Collectors.joining(","));
Boscovicino.log("[ %s ]", mods); Boscovicino.log("[ %s ]", mods);
return 1; return 1;

View file

@ -23,6 +23,8 @@ public class Teleport extends AbstractCommand {
.then( .then(
Commands.argument("distance", DoubleArgumentType.doubleArg()) Commands.argument("distance", DoubleArgumentType.doubleArg())
.executes( ctx -> { .executes( ctx -> {
if(MC.player == null)
return 0;
double distance = ctx.getArgument("distance", Double.class); double distance = ctx.getArgument("distance", Double.class);
MC.player.setPos( MC.player.setPos(
MC.player.position().x, MC.player.position().x,
@ -41,6 +43,8 @@ public class Teleport extends AbstractCommand {
.then( .then(
Commands.argument("z", DoubleArgumentType.doubleArg()) Commands.argument("z", DoubleArgumentType.doubleArg())
.executes( ctx -> { .executes( ctx -> {
if(MC.player == null)
return 0;
double x = ctx.getArgument("x", Double.class); double x = ctx.getArgument("x", Double.class);
double y = ctx.getArgument("y", Double.class); double y = ctx.getArgument("y", Double.class);
double z = ctx.getArgument("z", Double.class); double z = ctx.getArgument("z", Double.class);

View file

@ -2,7 +2,6 @@ package ftbsc.bscv.modules;
import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.BoolArgumentType; import com.mojang.brigadier.arguments.BoolArgumentType;
import ftbsc.bscv.Boscovicino;
import ftbsc.bscv.ICommons; import ftbsc.bscv.ICommons;
import ftbsc.bscv.api.IModule; import ftbsc.bscv.api.IModule;
import net.minecraft.command.CommandSource; import net.minecraft.command.CommandSource;
@ -27,12 +26,12 @@ public abstract class AbstractModule implements IModule, ICommons {
@Override @Override
public ForgeConfigSpec.Builder getConfigBuilder() { public ForgeConfigSpec.Builder getConfigBuilder() {
return Boscovicino.modManager.getCfgBuilder(); return BSCV.modules.getCfgBuilder();
} }
@Override @Override
public CommandDispatcher<CommandSource> getDispatcher() { public CommandDispatcher<CommandSource> getDispatcher() {
return Boscovicino.modManager.getDispatcher(); return BSCV.modules.getDispatcher();
} }
public AbstractModule() { public AbstractModule() {

View file

@ -1,6 +1,5 @@
package ftbsc.bscv.modules; package ftbsc.bscv.modules;
import ftbsc.bscv.Boscovicino;
import ftbsc.bscv.tools.Keybind; import ftbsc.bscv.tools.Keybind;
import net.minecraft.client.settings.KeyBinding; import net.minecraft.client.settings.KeyBinding;
import net.minecraft.client.util.InputMappings; import net.minecraft.client.util.InputMappings;
@ -14,7 +13,7 @@ public abstract class QuickModule extends AbstractModule {
public static final int UNBOUND = InputMappings.UNKNOWN.getValue(); public static final int UNBOUND = InputMappings.UNKNOWN.getValue();
private class ToggleHook { private static class ToggleHook {
private final KeyBinding key; private final KeyBinding key;
private final QuickModule mod; private final QuickModule mod;
private boolean debounce; private boolean debounce;

View file

@ -2,7 +2,6 @@ package ftbsc.bscv.modules.defense;
import com.google.auto.service.AutoService; import com.google.auto.service.AutoService;
import ftbsc.bscv.Boscovicino;
import ftbsc.bscv.api.ILoadable; import ftbsc.bscv.api.ILoadable;
import ftbsc.bscv.modules.QuickModule; import ftbsc.bscv.modules.QuickModule;
import ftbsc.bscv.modules.self.AutoTool; import ftbsc.bscv.modules.self.AutoTool;
@ -24,18 +23,13 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
@AutoService(ILoadable.class) @AutoService(ILoadable.class)
public class Aura extends QuickModule { public class Aura extends QuickModule {
private enum LookType { public enum LookType {
NONE, NONE,
PACKET, PACKET,
ONCE, ONCE,
// RESET // RESET
} }
@Override
protected int getDefaultKey() {
return UNBOUND;
}
public final ForgeConfigSpec.ConfigValue<Double> reach; public final ForgeConfigSpec.ConfigValue<Double> reach;
public final ForgeConfigSpec.ConfigValue<Double> strenght; public final ForgeConfigSpec.ConfigValue<Double> strenght;
public final ForgeConfigSpec.ConfigValue<Boolean> tool; public final ForgeConfigSpec.ConfigValue<Boolean> tool;
@ -105,7 +99,7 @@ public class Aura extends QuickModule {
@Override @Override
public void enable() { public void enable() {
super.enable(); super.enable();
this.autotool = (AutoTool) Boscovicino.modManager.get(AutoTool.class); this.autotool = (AutoTool) BSCV.modules.get(AutoTool.class);
} }
private void lookAtHidden(EntityAnchorArgument.Type anchor, Vector3d target) { private void lookAtHidden(EntityAnchorArgument.Type anchor, Vector3d target) {
@ -139,7 +133,7 @@ public class Aura extends QuickModule {
if (!this.neutral.get() && e.getClassification(false).isFriendly()) continue; if (!this.neutral.get() && e.getClassification(false).isFriendly()) continue;
if (e instanceof PlayerEntity) { if (e instanceof PlayerEntity) {
PlayerEntity player = (PlayerEntity) e; PlayerEntity player = (PlayerEntity) e;
if (Boscovicino.friends().isFriend(player.getGameProfile().getId())) { if (BSCV.friends.isFriend(player.getGameProfile().getId())) {
continue; continue;
} }
} }

View file

@ -1,7 +1,6 @@
package ftbsc.bscv.modules.hud; package ftbsc.bscv.modules.hud;
import com.google.auto.service.AutoService; import com.google.auto.service.AutoService;
import ftbsc.bscv.Boscovicino;
import ftbsc.bscv.api.ILoadable; import ftbsc.bscv.api.ILoadable;
import ftbsc.bscv.api.IModule; import ftbsc.bscv.api.IModule;
import ftbsc.bscv.modules.HudModule; import ftbsc.bscv.modules.HudModule;
@ -18,7 +17,7 @@ public class ActiveModules extends HudModule {
if (event.getType() != ElementType.TEXT) return; if (event.getType() != ElementType.TEXT) return;
if (this.shouldHide()) return; if (this.shouldHide()) return;
int offset = 0; int offset = 0;
for (IModule m : Boscovicino.modManager.mods) { for (IModule m : BSCV.modules.mods) {
if (m.isEnabled() && !m.getGroup().equalsIgnoreCase("HUD")) { if (m.isEnabled() && !m.getGroup().equalsIgnoreCase("HUD")) {
TextBuilder() TextBuilder()
.txt(this.affixed(m.getName())) .txt(this.affixed(m.getName()))

View file

@ -26,7 +26,7 @@ public class Coordinates extends HudModule {
@SubscribeEvent @SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) { public void onTick(TickEvent.ClientTickEvent event) {
if (event.phase == Phase.START) return; if (event.phase == Phase.START) return;
if (MC.player == null) return; if (MC.player == null || MC.level == null) return;
this.posX = MC.player.getX(); this.posX = MC.player.getX();
this.posY = MC.player.getY(); this.posY = MC.player.getY();

View file

@ -38,6 +38,7 @@ public class EntityList extends HudModule {
@SubscribeEvent @SubscribeEvent
public void onRenderOverlay(RenderGameOverlayEvent event) { public void onRenderOverlay(RenderGameOverlayEvent event) {
if (event.getType() != ElementType.TEXT) return; if (event.getType() != ElementType.TEXT) return;
if (MC.level == null) return;
if (this.shouldHide()) return; if (this.shouldHide()) return;
List<String> entities = new ArrayList<>(); List<String> entities = new ArrayList<>();
@ -65,7 +66,7 @@ public class EntityList extends HudModule {
.y(this.y.get() + offset) .y(this.y.get() + offset)
.scale(this.scale.get()) .scale(this.scale.get())
.style( .style(
this.search.get().length() > 0 && u.toLowerCase().contains(this.search.get().toLowerCase()) this.search.get().isEmpty() && u.toLowerCase().contains(this.search.get().toLowerCase())
? Style.EMPTY.withBold(true).withColor(Color.fromLegacyFormat(TextFormatting.GOLD)) ? Style.EMPTY.withBold(true).withColor(Color.fromLegacyFormat(TextFormatting.GOLD))
: Style.EMPTY.withColor(Color.fromLegacyFormat(TextFormatting.WHITE)) : Style.EMPTY.withColor(Color.fromLegacyFormat(TextFormatting.WHITE))
) )

View file

@ -1,30 +1,22 @@
package ftbsc.bscv.modules.hud; package ftbsc.bscv.modules.hud;
import com.google.auto.service.AutoService;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import ftbsc.bscv.api.ILoadable;
import ftbsc.bscv.modules.AbstractModule; import ftbsc.bscv.modules.AbstractModule;
import ftbsc.bscv.tools.Inventory; import ftbsc.bscv.tools.Inventory;
import ftbsc.bscv.tools.Setting; import ftbsc.bscv.tools.Setting;
import net.minecraft.client.gui.screen.inventory.ContainerScreen; import net.minecraft.client.gui.screen.inventory.ContainerScreen;
import net.minecraft.inventory.container.Slot; import net.minecraft.inventory.container.Slot;
import net.minecraft.item.EnchantedBookItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT;
import net.minecraftforge.client.event.GuiContainerEvent; import net.minecraftforge.client.event.GuiContainerEvent;
import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.client.gui.GuiUtils; import net.minecraftforge.fml.client.gui.GuiUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import ftbsc.bscv.api.ILoadable;
import com.google.auto.service.AutoService;
@AutoService(ILoadable.class) @AutoService(ILoadable.class)
public class Highlighter extends AbstractModule { public class Highlighter extends AbstractModule {

View file

@ -25,13 +25,13 @@ import static ftbsc.bscv.tools.Text.TextBuilder;
@AutoService(ILoadable.class) @AutoService(ILoadable.class)
public class InfoDisplay extends HudModule { public class InfoDisplay extends HudModule {
private Vector3d last_position = new Vector3d(0.0, 0.0, 0.0); private Vector3d lastPosition = new Vector3d(0.0, 0.0, 0.0);
private double instant_speed = 0.0; private double instantSpeed = 0.0;
private double average_speed = 0.0; private double averageSpeed = 0.0;
private double instant_tps = 0.0; private double instantTps = 0.0;
private int instant_ping = 0; private int instantPing = 0;
private Queue<Double> speed_history = new LinkedList<>(); private final Queue<Double> speedHistory = new LinkedList<>();
private Queue<Long> tps_history = new LinkedList<>(); private final Queue<Long> tpsHistory = new LinkedList<>();
public final ForgeConfigSpec.ConfigValue<Boolean> logo; public final ForgeConfigSpec.ConfigValue<Boolean> logo;
public final ForgeConfigSpec.ConfigValue<Boolean> speed; public final ForgeConfigSpec.ConfigValue<Boolean> speed;
@ -43,16 +43,16 @@ public class InfoDisplay extends HudModule {
// public final ForgeConfigSpec.ConfigValue<Boolean> biome; // public final ForgeConfigSpec.ConfigValue<Boolean> biome;
// public final ForgeConfigSpec.ConfigValue<Boolean> light; // public final ForgeConfigSpec.ConfigValue<Boolean> light;
// public final ForgeConfigSpec.ConfigValue<Boolean> saturation; // public final ForgeConfigSpec.ConfigValue<Boolean> saturation;
// public final ForgeConfigSpec.ConfigValue<Boolean> system_time; // public final ForgeConfigSpec.ConfigValue<Boolean> systemTime;
// public final ForgeConfigSpec.ConfigValue<Boolean> damage_value; // public final ForgeConfigSpec.ConfigValue<Boolean> damageValue;
// public final ForgeConfigSpec.ConfigValue<Boolean> effects_list; // public final ForgeConfigSpec.ConfigValue<Boolean> effectsList;
// public final ForgeConfigSpec.ConfigValue<Boolean> item_quantity; // public final ForgeConfigSpec.ConfigValue<Boolean> itemQuantity;
// public final ForgeConfigSpec.ConfigValue<Boolean> client_chunk_size; // public final ForgeConfigSpec.ConfigValue<Boolean> clientChunkSize;
public final ForgeConfigSpec.ConfigValue<Boolean> hide_effects; public final ForgeConfigSpec.ConfigValue<Boolean> hideEffects;
public final ForgeConfigSpec.ConfigValue<Integer> tps_sample_size; public final ForgeConfigSpec.ConfigValue<Integer> tpsSampleSize;
public final ForgeConfigSpec.ConfigValue<Integer> speed_sample_size; public final ForgeConfigSpec.ConfigValue<Integer> speedSampleSize;
public InfoDisplay() { public InfoDisplay() {
super(); super();
@ -99,20 +99,20 @@ public class InfoDisplay extends HudModule {
.fallback(true) .fallback(true)
.build(this); .build(this);
this.hide_effects = Setting.Bool.builder() this.hideEffects = Setting.Bool.builder()
.name("hide-effects") .name("hide-effects")
.comment("hide effect icons on top right corner") .comment("hide effect icons on top right corner")
.fallback(false) .fallback(false)
.build(this); .build(this);
this.tps_sample_size = Setting.Number.builder() this.tpsSampleSize = Setting.Number.builder()
.min(2) .min(2)
.name("tps-sample-size") .name("tps-sample-size")
.comment("TPS samples to store (1 taken each second)") .comment("TPS samples to store (1 taken each second)")
.fallback(60) .fallback(60)
.build(this); .build(this);
this.speed_sample_size = Setting.Number.builder() this.speedSampleSize = Setting.Number.builder()
.min(2) .min(2)
.name("speed-sample-size") .name("speed-sample-size")
.comment("instant speed samples to store (1 taken each tick)") .comment("instant speed samples to store (1 taken each tick)")
@ -124,59 +124,59 @@ public class InfoDisplay extends HudModule {
public void onTick(TickEvent.ClientTickEvent event) { public void onTick(TickEvent.ClientTickEvent event) {
if (!this.speed.get()) return; if (!this.speed.get()) return;
if (event.phase == Phase.START) return; if (event.phase == Phase.START) return;
if (MC.player != null) { if (MC.player != null && MC.getConnection() != null) {
this.instant_speed = this.last_position.distanceTo(MC.player.position()); this.instantSpeed = this.lastPosition.distanceTo(MC.player.position());
this.last_position = MC.player.position(); this.lastPosition = MC.player.position();
NetworkPlayerInfo info = MC.getConnection().getPlayerInfo( NetworkPlayerInfo info = MC.getConnection().getPlayerInfo(
MC.player.getGameProfile().getId() MC.player.getGameProfile().getId()
); );
if (info != null) { // bungeecord switching makes this null for a second if (info != null) { // bungeecord switching makes this null for a second
this.instant_ping = info.getLatency(); this.instantPing = info.getLatency();
} }
} else { } else {
this.instant_speed = 0.0; this.instantSpeed = 0.0;
this.instant_ping = 0; this.instantPing = 0;
} }
this.speed_history.offer(this.instant_speed); this.speedHistory.offer(this.instantSpeed);
while (this.speed_history.size() >= this.speed_sample_size.get()) { while (this.speedHistory.size() >= this.speedSampleSize.get()) {
this.speed_history.poll(); this.speedHistory.poll();
} }
double buf = 0.0; double buf = 0.0;
for (double v : this.speed_history) { buf += v; } for (double v : this.speedHistory) { buf += v; }
this.average_speed = buf / this.speed_history.size(); this.averageSpeed = buf / this.speedHistory.size();
if (this.last_fps_string != MC.fpsString) { if (this.lastFpsString.equals(MC.fpsString)) {
this.last_fps_string = MC.fpsString; this.lastFpsString = MC.fpsString;
this.curr_fps = this.last_fps_string.split(" ")[0]; this.currFps = this.lastFpsString.split(" ")[0];
} }
} }
@SubscribeEvent @SubscribeEvent
public void onPacket(PacketEvent.Incoming event) { public void onPacket(PacketEvent.Incoming event) {
if (event.packet instanceof SUpdateTimePacket) { if (event.packet instanceof SUpdateTimePacket) {
this.tps_history.offer(System.currentTimeMillis()); this.tpsHistory.offer(System.currentTimeMillis());
while (this.tps_history.size() > this.tps_sample_size.get()) { while (this.tpsHistory.size() > this.tpsSampleSize.get()) {
this.tps_history.poll(); this.tpsHistory.poll();
} }
double positive_time = 0.; double positiveTime = 0.;
double last_time = 0; double lastTime = 0;
for (long t : this.tps_history) { for (long t : this.tpsHistory) {
if (last_time != 0) { if (lastTime != 0) {
double delta = (double) (t - last_time) / 1000.; double delta = (double) (t - lastTime) / 1000.;
positive_time += Math.max(delta, 1.); positiveTime += Math.max(delta, 1.);
} }
last_time = t; lastTime = t;
} }
this.instant_tps = 20 / (positive_time / (this.tps_history.size() - 1)); this.instantTps = 20 / (positiveTime / (this.tpsHistory.size() - 1));
} }
} }
@SubscribeEvent @SubscribeEvent
public void onRenderOverlay(RenderGameOverlayEvent event) { public void onRenderOverlay(RenderGameOverlayEvent event) {
if (event.getType() == ElementType.POTION_ICONS) { if (event.getType() == ElementType.POTION_ICONS) {
if (this.hide_effects.get() && event.isCancelable()) { if (this.hideEffects.get() && event.isCancelable()) {
event.setCanceled(true); event.setCanceled(true);
} }
} }
@ -195,7 +195,7 @@ public class InfoDisplay extends HudModule {
.style(Style.EMPTY.withColor(Color.fromRgb(12542314)).withBold(true)) .style(Style.EMPTY.withColor(Color.fromRgb(12542314)).withBold(true))
.scale(scale * 4.0) .scale(scale * 4.0)
.render(event.getMatrixStack(), event.getWindow()); .render(event.getMatrixStack(), event.getWindow());
offset += MC.font.lineHeight * scale * 4.0; offset += (int) (MC.font.lineHeight * scale * 4.0);
} }
long day = 0; long day = 0;
@ -207,46 +207,46 @@ public class InfoDisplay extends HudModule {
if (this.fps.get()) { if (this.fps.get()) {
TextBuilder() TextBuilder()
.txt(this.affixed("fps: %s", this.curr_fps)) .txt(this.affixed("fps: %s", this.currFps))
.anchor(this.anchor.get()) .anchor(this.anchor.get())
.x(this.x.get()) .x(this.x.get())
.y(this.y.get() + offset) .y(this.y.get() + offset)
.scale(scale) .scale(scale)
.render(event.getMatrixStack(), event.getWindow()); .render(event.getMatrixStack(), event.getWindow());
offset += MC.font.lineHeight * scale; offset += (int) (MC.font.lineHeight * scale);
} }
if (this.ping.get()) { if (this.ping.get()) {
TextBuilder() TextBuilder()
.txt(this.affixed("ping: %d", this.instant_ping)) .txt(this.affixed("ping: %d", this.instantPing))
.anchor(this.anchor.get()) .anchor(this.anchor.get())
.x(this.x.get()) .x(this.x.get())
.y(this.y.get() + offset) .y(this.y.get() + offset)
.scale(scale) .scale(scale)
.render(event.getMatrixStack(), event.getWindow()); .render(event.getMatrixStack(), event.getWindow());
offset += MC.font.lineHeight * scale; offset += (int) (MC.font.lineHeight * scale);
} }
if (this.tps.get()) { if (this.tps.get()) {
TextBuilder() TextBuilder()
.txt(this.affixed("tps: %.1f", this.instant_tps)) .txt(this.affixed("tps: %.1f", this.instantTps))
.anchor(this.anchor.get()) .anchor(this.anchor.get())
.x(this.x.get()) .x(this.x.get())
.y(this.y.get() + offset) .y(this.y.get() + offset)
.scale(scale) .scale(scale)
.render(event.getMatrixStack(), event.getWindow()); .render(event.getMatrixStack(), event.getWindow());
offset += MC.font.lineHeight * scale; offset += (int) (MC.font.lineHeight * scale);
} }
if (this.speed.get()) { if (this.speed.get()) {
TextBuilder() TextBuilder()
.txt(this.affixed("speed: %.1f [%.1f] m/s", this.instant_speed * 20.0, this.average_speed * 20.0)) .txt(this.affixed("speed: %.1f [%.1f] m/s", this.instantSpeed * 20.0, this.averageSpeed * 20.0))
.anchor(this.anchor.get()) .anchor(this.anchor.get())
.x(this.x.get()) .x(this.x.get())
.y(this.y.get() + offset) .y(this.y.get() + offset)
.scale(scale) .scale(scale)
.render(event.getMatrixStack(), event.getWindow()); .render(event.getMatrixStack(), event.getWindow());
offset += MC.font.lineHeight * scale; offset += (int) (MC.font.lineHeight * scale);
} }
if (this.age.get()) { if (this.age.get()) {
@ -257,10 +257,11 @@ public class InfoDisplay extends HudModule {
.y(this.y.get() + offset) .y(this.y.get() + offset)
.scale(scale) .scale(scale)
.render(event.getMatrixStack(), event.getWindow()); .render(event.getMatrixStack(), event.getWindow());
offset += MC.font.lineHeight * scale; offset += (int) (MC.font.lineHeight * scale);
} }
if (this.time.get()) { if (this.time.get()) {
int TPS = 20;
TextBuilder() TextBuilder()
.txt(this.affixed("time: %d/%d (%s)", (time / TPS), this.getNextStep(time) / TPS, this.getTimePhase(time) )) .txt(this.affixed("time: %d/%d (%s)", (time / TPS), this.getNextStep(time) / TPS, this.getTimePhase(time) ))
.anchor(this.anchor.get()) .anchor(this.anchor.get())
@ -268,12 +269,12 @@ public class InfoDisplay extends HudModule {
.y(this.y.get() + offset) .y(this.y.get() + offset)
.scale(scale) .scale(scale)
.render(event.getMatrixStack(), event.getWindow()); .render(event.getMatrixStack(), event.getWindow());
offset += MC.font.lineHeight * scale; offset += (int) (MC.font.lineHeight * scale);
} }
} }
private String last_fps_string; private String lastFpsString;
private String curr_fps = "0"; private String currFps = "0";
// TPS utils // TPS utils
@ -301,5 +302,4 @@ public class InfoDisplay extends HudModule {
return 5500; return 5500;
} }
private final int TPS = 20;
} }

View file

@ -18,6 +18,7 @@ public class PlayerList extends HudModule {
public void onRenderOverlay(RenderGameOverlayEvent event) { public void onRenderOverlay(RenderGameOverlayEvent event) {
if (event.getType() != ElementType.TEXT) return; if (event.getType() != ElementType.TEXT) return;
if (this.shouldHide()) return; if (this.shouldHide()) return;
if (MC.level == null) return;
int offset = 0; int offset = 0;
for (Entity e : MC.level.entitiesForRendering()) { for (Entity e : MC.level.entitiesForRendering()) {

View file

@ -2,7 +2,6 @@ package ftbsc.bscv.modules.motion;
import com.google.auto.service.AutoService; import com.google.auto.service.AutoService;
import ftbsc.bscv.Boscovicino;
import ftbsc.bscv.api.ILoadable; import ftbsc.bscv.api.ILoadable;
import ftbsc.bscv.modules.AbstractModule; import ftbsc.bscv.modules.AbstractModule;
import ftbsc.bscv.patches.BackgroundPatch.RenderBackgroundEvent; import ftbsc.bscv.patches.BackgroundPatch.RenderBackgroundEvent;
@ -30,7 +29,7 @@ public class GuiMove extends AbstractModule {
public final ForgeConfigSpec.ConfigValue<Boolean> background; public final ForgeConfigSpec.ConfigValue<Boolean> background;
private AutoWalk autoWalk_mod; private AutoWalk autoWalkMod;
public GuiMove() { public GuiMove() {
super(); super();
@ -44,7 +43,7 @@ public class GuiMove extends AbstractModule {
@Override @Override
public void enable() { public void enable() {
this.autoWalk_mod = (AutoWalk) Boscovicino.modManager.get(AutoWalk.class); this.autoWalkMod = (AutoWalk) BSCV.modules.get(AutoWalk.class);
super.enable(); super.enable();
} }
@ -72,7 +71,7 @@ public class GuiMove extends AbstractModule {
private void forceMovementTick(MovementInput input) { private void forceMovementTick(MovementInput input) {
// TODO can we patch to make this always happen instead of duplicating code? // TODO can we patch to make this always happen instead of duplicating code?
input.up = this.autoWalk_mod.isEnabled() || this.isKeyDown(MC.options.keyUp); input.up = this.autoWalkMod.isEnabled() || this.isKeyDown(MC.options.keyUp);
input.down = this.isKeyDown(MC.options.keyDown); input.down = this.isKeyDown(MC.options.keyDown);
input.left = this.isKeyDown(MC.options.keyLeft); input.left = this.isKeyDown(MC.options.keyLeft);
input.right = this.isKeyDown(MC.options.keyRight); input.right = this.isKeyDown(MC.options.keyRight);

View file

@ -16,7 +16,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
@AutoService(ILoadable.class) @AutoService(ILoadable.class)
public class VanillaFlight extends QuickModule { public class VanillaFlight extends QuickModule {
private enum AntikickMode { public enum AntiKickMode {
NONE, NONE,
PACKET, PACKET,
FORCED FORCED
@ -27,10 +27,10 @@ public class VanillaFlight extends QuickModule {
public final ForgeConfigSpec.ConfigValue<Boolean> force; public final ForgeConfigSpec.ConfigValue<Boolean> force;
public final ForgeConfigSpec.ConfigValue<Boolean> drift; public final ForgeConfigSpec.ConfigValue<Boolean> drift;
public final ForgeConfigSpec.ConfigValue<Double> speed; public final ForgeConfigSpec.ConfigValue<Double> speed;
public final ForgeConfigSpec.ConfigValue<AntikickMode> antikick; public final ForgeConfigSpec.ConfigValue<AntiKickMode> antikick;
public final ForgeConfigSpec.ConfigValue<Double> antikick_magnitude; public final ForgeConfigSpec.ConfigValue<Double> antikickMagnitude;
public final ForgeConfigSpec.ConfigValue<Integer> antikick_cycle; public final ForgeConfigSpec.ConfigValue<Integer> antikickCycle;
public final ForgeConfigSpec.ConfigValue<Integer> antikick_duration; public final ForgeConfigSpec.ConfigValue<Integer> antikickDuration;
private int tick = 0; private int tick = 0;
@ -56,20 +56,20 @@ public class VanillaFlight extends QuickModule {
.comment("flight speed to set") .comment("flight speed to set")
.build(this); .build(this);
this.antikick = Setting.Switch.builder(AntikickMode.class) this.antikick = Setting.Switch.builder(AntiKickMode.class)
.fallback(AntikickMode.PACKET) .fallback(AntiKickMode.PACKET)
.name("antikick") .name("antikick")
.comment("prevent vanilla flight kick by descending") .comment("prevent vanilla flight kick by descending")
.build(this); .build(this);
this.antikick_magnitude = Setting.Decimal.builder() this.antikickMagnitude = Setting.Decimal.builder()
.min(0.) .min(0.)
.fallback(0.032) .fallback(0.032)
.name("magnitude") .name("magnitude")
.comment("magnitude of antikick push") .comment("magnitude of antikick push")
.build(this); .build(this);
this.antikick_cycle = Setting.Number.builder() this.antikickCycle = Setting.Number.builder()
.min(1) .min(1)
.max(80) .max(80)
.fallback(70) .fallback(70)
@ -77,7 +77,7 @@ public class VanillaFlight extends QuickModule {
.comment("how often to run antikick routine") .comment("how often to run antikick routine")
.build(this); .build(this);
this.antikick_duration = Setting.Number.builder() this.antikickDuration = Setting.Number.builder()
.min(1) .min(1)
.max(80) .max(80)
.fallback(5) .fallback(5)
@ -86,7 +86,7 @@ public class VanillaFlight extends QuickModule {
.build(this); .build(this);
} }
private long last_event = 0; private long lastEvent = 0;
private boolean couldFlyBefore = false; private boolean couldFlyBefore = false;
private float flyingSpeedBefore = 0.05f; private float flyingSpeedBefore = 0.05f;
@ -113,11 +113,11 @@ public class VanillaFlight extends QuickModule {
MC.player.setDeltaMovement(Vector3d.ZERO); MC.player.setDeltaMovement(Vector3d.ZERO);
} }
this.tick = ( this.tick + 1 ) % this.antikick_cycle.get(); this.tick = ( this.tick + 1 ) % this.antikickCycle.get();
Vector3d pos = MC.player.position(); Vector3d pos = MC.player.position();
if (this.tick == 0 && this.antikick.get() == AntikickMode.PACKET) { if (this.tick == 0 && this.antikick.get() == AntiKickMode.PACKET) {
MC.player.setPos(pos.x, pos.y - this.antikick_magnitude.get(), pos.z); MC.player.setPos(pos.x, pos.y - this.antikickMagnitude.get(), pos.z);
} }
} }
@ -126,11 +126,11 @@ public class VanillaFlight extends QuickModule {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
switch (this.antikickState) { switch (this.antikickState) {
case COOLDOWN: case COOLDOWN:
if (now - this.last_event < this.antikick_cycle.get() * MS_PER_TICK) break; if (now - this.lastEvent < this.antikickCycle.get() * MS_PER_TICK) break;
this.last_event = now; this.lastEvent = now;
this.antikickState = AntikickState.ACTIVE; // don't break and also run ACTIVE this.antikickState = AntikickState.ACTIVE; // don't break and also run ACTIVE
case ACTIVE: case ACTIVE:
if (now - this.last_event > this.antikick_duration.get() * MS_PER_TICK) { if (now - this.lastEvent > this.antikickDuration.get() * MS_PER_TICK) {
this.antikickState = AntikickState.COOLDOWN; this.antikickState = AntikickState.COOLDOWN;
break; break;
} }
@ -139,7 +139,7 @@ public class VanillaFlight extends QuickModule {
event.packet instanceof CPlayerPacket.PositionRotationPacket event.packet instanceof CPlayerPacket.PositionRotationPacket
) { ) {
CPlayerPacket packet = (CPlayerPacket) event.packet; CPlayerPacket packet = (CPlayerPacket) event.packet;
packet.y = packet.y - this.antikick_magnitude.get(); packet.y = packet.y - this.antikickMagnitude.get();
} }
} }
} }

View file

@ -59,7 +59,7 @@ public class PacketLogger extends QuickModule {
@SubscribeEvent @SubscribeEvent
public void onPacketOutgoing(PacketEvent.Outgoing event) { public void onPacketOutgoing(PacketEvent.Outgoing event) {
try { try {
this.capture.add(this.packet_to_json(event.packet, this.pretty_time())); // get send time here this.capture.add(this.packetToJson(event.packet, this.prettyTime())); // get send time here
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
Boscovicino.LOGGER.warn("Could not process fields of packet {}", event.packet.toString()); Boscovicino.LOGGER.warn("Could not process fields of packet {}", event.packet.toString());
} }
@ -68,7 +68,7 @@ public class PacketLogger extends QuickModule {
@SubscribeEvent @SubscribeEvent
public void onPacketIncoming(PacketEvent.Incoming event) { public void onPacketIncoming(PacketEvent.Incoming event) {
try { try {
this.capture.add(this.packet_to_json(event.packet, this.pretty_time())); // get recv time here this.capture.add(this.packetToJson(event.packet, this.prettyTime())); // get recv time here
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
Boscovicino.LOGGER.warn("Could not process fields of packet {}", event.packet.toString()); Boscovicino.LOGGER.warn("Could not process fields of packet {}", event.packet.toString());
} }
@ -88,7 +88,7 @@ public class PacketLogger extends QuickModule {
} }
} }
private JsonElement packet_to_json(IPacket<?> packet, double time) throws IllegalAccessException { private JsonElement packetToJson(IPacket<?> packet, double time) throws IllegalAccessException {
Class<?> clazz = packet.getClass(); Class<?> clazz = packet.getClass();
List<String> classNames = new ArrayList<>(); List<String> classNames = new ArrayList<>();
JsonObject fields = new JsonObject(); JsonObject fields = new JsonObject();
@ -97,7 +97,7 @@ public class PacketLogger extends QuickModule {
for (Field field : clazz.getDeclaredFields()) { for (Field field : clazz.getDeclaredFields()) {
if (!Modifier.isStatic(field.getModifiers())) { if (!Modifier.isStatic(field.getModifiers())) {
field.setAccessible(true); field.setAccessible(true);
fields.add(field.getName(), this.format_value(field.get(packet))); // TODO deobfuscate field.getName() fields.add(field.getName(), this.formatValue(field.get(packet))); // TODO deobfuscate field.getName()
} }
} }
clazz = clazz.getSuperclass(); clazz = clazz.getSuperclass();
@ -105,12 +105,12 @@ public class PacketLogger extends QuickModule {
JsonObject json = new JsonObject(); JsonObject json = new JsonObject();
json.addProperty("time", time); json.addProperty("time", time);
json.addProperty("name", this.compose_packet_name(classNames)); json.addProperty("name", this.composePacketName(classNames));
json.add("fields", fields); json.add("fields", fields);
return json; return json;
} }
private JsonElement format_value(Object value) { private JsonElement formatValue(Object value) {
if (value == null) return null; if (value == null) return null;
if (value instanceof ITextComponent) { if (value instanceof ITextComponent) {
ITextComponent component = (ITextComponent) value; ITextComponent component = (ITextComponent) value;
@ -119,7 +119,7 @@ public class PacketLogger extends QuickModule {
return obj; return obj;
} }
if (value.getClass().isArray()) { if (value.getClass().isArray()) {
return this.array_to_string(value); return this.arrayToString(value);
} }
if (value instanceof Number) { if (value instanceof Number) {
return new JsonPrimitive((Number) value); return new JsonPrimitive((Number) value);
@ -135,17 +135,17 @@ public class PacketLogger extends QuickModule {
} }
if (value instanceof Vector3d) { if (value instanceof Vector3d) {
Vector3d vec = (Vector3d) value; Vector3d vec = (Vector3d) value;
return this.array_to_string(new double[] { vec.x(), vec.y(), vec.z() }); return this.arrayToString(new double[] { vec.x(), vec.y(), vec.z() });
} }
if (value instanceof Vector2f) { if (value instanceof Vector2f) {
Vector2f vec = (Vector2f) value; Vector2f vec = (Vector2f) value;
return this.array_to_string(new float[] { vec.x, vec.y }); return this.arrayToString(new float[] { vec.x, vec.y });
} }
// TODO pretty print some very noisy toStrings // TODO pretty print some very noisy toStrings
return new JsonPrimitive(value.toString()); return new JsonPrimitive(value.toString());
} }
private JsonArray array_to_string(Object value) { private JsonArray arrayToString(Object value) {
JsonArray out = new JsonArray(); JsonArray out = new JsonArray();
if (value instanceof byte[]) { if (value instanceof byte[]) {
byte[] arr = (byte[]) value; byte[] arr = (byte[]) value;
@ -192,7 +192,7 @@ public class PacketLogger extends QuickModule {
return out; return out;
} }
private String compose_packet_name(List<String> classNames) { private String composePacketName(List<String> classNames) {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
for (int i = classNames.size() - 1; i >= 0; i--) { for (int i = classNames.size() - 1; i >= 0; i--) {
builder.append(classNames.get(i)); builder.append(classNames.get(i));
@ -201,7 +201,7 @@ public class PacketLogger extends QuickModule {
return builder.toString(); return builder.toString();
} }
private double pretty_time() { private double prettyTime() {
return (double) System.nanoTime() / 1000000000.; return (double) System.nanoTime() / 1000000000.;
} }
} }

View file

@ -49,6 +49,7 @@ public class AntiHunger extends AbstractModule {
this.hover.get() this.hover.get()
&& event.packet instanceof CPlayerPacket && event.packet instanceof CPlayerPacket
&& MC.player != null && MC.player != null
&& MC.gameMode != null
&& MC.player.fallDistance <= 0.f && MC.player.fallDistance <= 0.f
&& !MC.gameMode.isDestroying() && !MC.gameMode.isDestroying()
) { ) {

View file

@ -28,6 +28,7 @@ public class AutoDisconnect extends AbstractModule {
@SubscribeEvent @SubscribeEvent
public void onPacket(PacketEvent.Incoming event) { public void onPacket(PacketEvent.Incoming event) {
if(MC.player == null) return;
if (event.packet instanceof SUpdateHealthPacket) { if (event.packet instanceof SUpdateHealthPacket) {
SUpdateHealthPacket packet = (SUpdateHealthPacket) event.packet; SUpdateHealthPacket packet = (SUpdateHealthPacket) event.packet;
if (packet.getHealth() < this.threshold.get()) { if (packet.getHealth() < this.threshold.get()) {

View file

@ -5,7 +5,6 @@ import ftbsc.bscv.api.ILoadable;
import ftbsc.bscv.modules.AbstractModule; import ftbsc.bscv.modules.AbstractModule;
import ftbsc.bscv.patches.PacketPatch.PacketEvent; import ftbsc.bscv.patches.PacketPatch.PacketEvent;
import ftbsc.bscv.tools.Setting; import ftbsc.bscv.tools.Setting;
import net.minecraft.client.Minecraft;
import net.minecraft.network.play.server.SPlaySoundEffectPacket; import net.minecraft.network.play.server.SPlaySoundEffectPacket;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.SoundEvents; import net.minecraft.util.SoundEvents;
@ -37,22 +36,23 @@ public class AutoFish extends AbstractModule {
@SubscribeEvent @SubscribeEvent
public void onPacket(PacketEvent.Incoming event) { public void onPacket(PacketEvent.Incoming event) {
if (MC.gameMode == null || MC.player == null || MC.level == null)
return;
if (event.packet instanceof SPlaySoundEffectPacket) { if (event.packet instanceof SPlaySoundEffectPacket) {
SPlaySoundEffectPacket packet = (SPlaySoundEffectPacket) event.packet; SPlaySoundEffectPacket packet = (SPlaySoundEffectPacket) event.packet;
if (packet.getSound().equals(SoundEvents.FISHING_BOBBER_SPLASH)) { if (packet.getSound().equals(SoundEvents.FISHING_BOBBER_SPLASH)) {
MC.gameMode.useItem(MC.player, MC.level, Hand.MAIN_HAND); MC.gameMode.useItem(MC.player, MC.level, Hand.MAIN_HAND);
if (this.recast.get()) { if (this.recast.get()) {
new RecastThread(MC, this.delay.get()).start(); new RecastThread(this.delay.get()).start();
} }
} }
} }
} }
private class RecastThread extends Thread { private static class RecastThread extends Thread {
private long delay; private final long delay;
private Minecraft mc; public RecastThread(long delay) {
public RecastThread(Minecraft mc, long delay) {
this.mc = mc;
this.delay = delay; this.delay = delay;
this.setDaemon(true); this.setDaemon(true);
} }
@ -60,8 +60,10 @@ public class AutoFish extends AbstractModule {
public void run() { public void run() {
try { try {
Thread.sleep(this.delay); Thread.sleep(this.delay);
} catch (InterruptedException e) {} // ignore } catch (InterruptedException ignored) {} // ignore
this.mc.gameMode.useItem(this.mc.player, this.mc.level, Hand.MAIN_HAND); if (MC.gameMode == null || MC.player == null || MC.level == null)
return;
MC.gameMode.useItem(MC.player, MC.level, Hand.MAIN_HAND);
} }
} }
} }

View file

@ -2,7 +2,6 @@ package ftbsc.bscv.modules.self;
import com.google.auto.service.AutoService; import com.google.auto.service.AutoService;
import ftbsc.bscv.Boscovicino;
import ftbsc.bscv.api.ILoadable; import ftbsc.bscv.api.ILoadable;
import ftbsc.bscv.modules.AbstractModule; import ftbsc.bscv.modules.AbstractModule;
import ftbsc.bscv.tools.Inventory; import ftbsc.bscv.tools.Inventory;
@ -22,7 +21,7 @@ import java.util.List;
public class AutoTool extends AbstractModule { public class AutoTool extends AbstractModule {
public final ForgeConfigSpec.ConfigValue<Integer> limit; public final ForgeConfigSpec.ConfigValue<Integer> limit;
public final ForgeConfigSpec.ConfigValue<Boolean> prefer_looting; public final ForgeConfigSpec.ConfigValue<Boolean> preferLooting;
public AutoTool() { public AutoTool() {
super(); super();
@ -33,7 +32,7 @@ public class AutoTool extends AbstractModule {
.fallback(1) .fallback(1)
.build(this); .build(this);
this.prefer_looting = Setting.Bool.builder() this.preferLooting = Setting.Bool.builder()
.name("prefer-looting") .name("prefer-looting")
.comment("when picking best weapon, prefer looting over slight more DPS") .comment("when picking best weapon, prefer looting over slight more DPS")
.fallback(true) .fallback(true)
@ -46,10 +45,11 @@ public class AutoTool extends AbstractModule {
&& item.getMaxDamage() - item.getDamageValue() <= this.limit.get(); && item.getMaxDamage() - item.getDamageValue() <= this.limit.get();
} }
public boolean selectBestWeapon() { public void selectBestWeapon() {
if(MC.player == null || MC.gameMode == null) return;
List<Slot> hotbar = Inventory.hotbar(MC.player); List<Slot> hotbar = Inventory.hotbar(MC.player);
int current_slot = MC.player.inventory.selected; int currentSlot = MC.player.inventory.selected;
double current_damage = Inventory.itemDPS(hotbar.get(current_slot).getItem()); double currentDamage = Inventory.itemDPS(hotbar.get(currentSlot).getItem());
for (int i = 0; i < Inventory.HOTBAR_SIZE; i++) { for (int i = 0; i < Inventory.HOTBAR_SIZE; i++) {
ItemStack item = hotbar.get(i).getItem(); ItemStack item = hotbar.get(i).getItem();
if (this.itemIsTooDamaged(item)) { if (this.itemIsTooDamaged(item)) {
@ -59,51 +59,48 @@ public class AutoTool extends AbstractModule {
double damage = Inventory.itemDPS(item); double damage = Inventory.itemDPS(item);
int looting = Inventory.getEnchLevel(item, Enchantments.MOB_LOOTING); int looting = Inventory.getEnchLevel(item, Enchantments.MOB_LOOTING);
if (this.prefer_looting.get() && looting > 0) { if (this.preferLooting.get() && looting > 0) {
damage += 0.1 * looting; damage += 0.1 * looting;
} }
if (damage > current_damage) { if (damage > currentDamage) {
current_slot = i; currentSlot = i;
current_damage = damage; currentDamage = damage;
} }
} }
if (current_slot != MC.player.inventory.selected) { if (currentSlot != MC.player.inventory.selected) {
MC.player.inventory.selected = current_slot; MC.player.inventory.selected = currentSlot;
MC.gameMode.ensureHasSentCarriedItem(); // ACCESSTRANSFORMER MC.gameMode.ensureHasSentCarriedItem(); // ACCESSTRANSFORMER
return true;
} }
return false;
} }
public boolean selectBestTool() { public void selectBestTool() {
if(MC.player == null || MC.level == null || MC.hitResult == null || MC.gameMode == null) return;
List<Slot> hotbar = Inventory.hotbar(MC.player); List<Slot> hotbar = Inventory.hotbar(MC.player);
int current_slot = MC.player.inventory.selected; int currentSlot = MC.player.inventory.selected;
BlockRayTraceResult result = (BlockRayTraceResult) MC.hitResult; BlockRayTraceResult result = (BlockRayTraceResult) MC.hitResult;
BlockState state = MC.level.getBlockState(result.getBlockPos()); BlockState state = MC.level.getBlockState(result.getBlockPos());
float current_speed = hotbar.get(current_slot).getItem().getDestroySpeed(state); float currentSpeed = hotbar.get(currentSlot).getItem().getDestroySpeed(state);
for (int i = 0; i < Inventory.HOTBAR_SIZE; i++) { for (int i = 0; i < Inventory.HOTBAR_SIZE; i++) {
ItemStack item = hotbar.get(i).getItem(); ItemStack item = hotbar.get(i).getItem();
if (this.itemIsTooDamaged(item)) { if (this.itemIsTooDamaged(item)) {
continue; continue;
} }
float speed = item.getDestroySpeed(state); float speed = item.getDestroySpeed(state);
if (speed > current_speed) { if (speed > currentSpeed) {
current_slot = i; currentSlot = i;
current_speed = speed; currentSpeed = speed;
} }
} }
if (current_slot != MC.player.inventory.selected) { if (currentSlot != MC.player.inventory.selected) {
MC.player.inventory.selected = current_slot; MC.player.inventory.selected = currentSlot;
MC.gameMode.ensureHasSentCarriedItem(); // ACCESSTRANSFORMER MC.gameMode.ensureHasSentCarriedItem(); // ACCESSTRANSFORMER
return true;
} }
return false;
} }
@SubscribeEvent @SubscribeEvent
public void onClick(InputEvent.ClickInputEvent event) { public void onClick(InputEvent.ClickInputEvent event) {
if (MC.player == null) return; if (MC.player == null || MC.hitResult == null) return;
// TODO this is fired many times consecutively, can we filter out // TODO this is fired many times consecutively, can we filter out
// some without putting a dumb time cooldown?; // some without putting a dumb time cooldown?;
if (event.isAttack()) { if (event.isAttack()) {

View file

@ -9,12 +9,8 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
@AutoService(ILoadable.class) @AutoService(ILoadable.class)
public class FastInteract extends QuickModule { public class FastInteract extends QuickModule {
protected int getDefaultKey() { return UNBOUND; }
@SubscribeEvent @SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) { public void onTick(TickEvent.ClientTickEvent event) {
if (MC == null) return;
MC.rightClickDelay = 0; // ACCESSTRANSFORMER MC.rightClickDelay = 0; // ACCESSTRANSFORMER
} }
} }

View file

@ -7,14 +7,17 @@ import ftbsc.bscv.modules.QuickModule;
import ftbsc.bscv.patches.PacketPatch.PacketEvent; import ftbsc.bscv.patches.PacketPatch.PacketEvent;
import ftbsc.bscv.tools.Keyboard; import ftbsc.bscv.tools.Keyboard;
import ftbsc.bscv.tools.Setting; import ftbsc.bscv.tools.Setting;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.entity.player.RemoteClientPlayerEntity; import net.minecraft.client.entity.player.RemoteClientPlayerEntity;
import net.minecraft.client.network.play.NetworkPlayerInfo; import net.minecraft.client.network.play.NetworkPlayerInfo;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.network.play.client.CPlayerPacket; import net.minecraft.network.play.client.CPlayerPacket;
import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.GameType; import net.minecraft.world.GameType;
import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import org.checkerframework.checker.nullness.qual.NonNull;
@AutoService(ILoadable.class) @AutoService(ILoadable.class)
public class Freecam extends QuickModule { public class Freecam extends QuickModule {
@ -23,15 +26,10 @@ public class Freecam extends QuickModule {
public final ForgeConfigSpec.ConfigValue<Double> speed; public final ForgeConfigSpec.ConfigValue<Double> speed;
public final ForgeConfigSpec.ConfigValue<Boolean> drift; public final ForgeConfigSpec.ConfigValue<Boolean> drift;
private Vector3d prev_pos = new Vector3d(0.0, 0.0, 0.0); private Vector3d prevPos = new Vector3d(0.0, 0.0, 0.0);
private float prev_speed = 0.05f; private float prevSpeed = 0.05f;
private GameType prev_gamemode = GameType.SURVIVAL; private GameType prevGamemode = GameType.SURVIVAL;
private MockPlayer mock_player; private MockPlayer mockPlayer;
@Override
protected int getDefaultKey() {
return UNBOUND;
}
public Freecam() { public Freecam() {
super(); super();
@ -77,52 +75,53 @@ public class Freecam extends QuickModule {
@Override @Override
public void enable() { public void enable() {
if (MC.player == null) { if (MC.player == null || MC.gameMode == null || MC.level == null) {
Boscovicino.log("[!] Can only enable freecam while in-game"); Boscovicino.log("[!] Can only enable freecam while in-game");
return; return;
} }
this.prev_speed = MC.player.abilities.getFlyingSpeed(); this.prevSpeed = MC.player.abilities.getFlyingSpeed();
this.prev_pos = MC.player.position(); this.prevPos = MC.player.position();
this.prev_gamemode = MC.gameMode.getPlayerMode(); this.prevGamemode = MC.gameMode.getPlayerMode();
MC.gameMode.setLocalMode(GameType.SPECTATOR); MC.gameMode.setLocalMode(GameType.SPECTATOR);
MC.player.noCulling = true; MC.player.noCulling = true;
if (MC.getConnection() != null) { if (MC.getConnection() != null) {
NetworkPlayerInfo info = MC.getConnection().getPlayerInfo( NetworkPlayerInfo info = MC.getConnection().getPlayerInfo(
MC.player.getGameProfile().getId() MC.player.getGameProfile().getId()
); );
if (info == null) return;
info.gameMode = GameType.SPECTATOR; // ACCESSTRANSFORMER: public net.minecraft.client.network.play.NetworkPlayerInfo field_178866_b info.gameMode = GameType.SPECTATOR; // ACCESSTRANSFORMER: public net.minecraft.client.network.play.NetworkPlayerInfo field_178866_b
} }
this.mock_player = new MockPlayer(); this.mockPlayer = new MockPlayer(MC.level, MC.player);
this.mock_player.setPosAndOldPos(this.prev_pos.x, this.prev_pos.y, this.prev_pos.z); this.mockPlayer.setPosAndOldPos(this.prevPos.x, this.prevPos.y, this.prevPos.z);
this.mock_player.setYBodyRot(MC.player.yBodyRot); this.mockPlayer.setYBodyRot(MC.player.yBodyRot);
MC.level.addPlayer(-666, this.mock_player); MC.level.addPlayer(-666, this.mockPlayer);
super.enable(); super.enable();
} }
@Override @Override
public void disable() { public void disable() {
super.disable(); super.disable();
if (MC.player == null) return; if (MC.player == null || MC.level == null || MC.gameMode == null) return;
MC.gameMode.setLocalMode(this.prev_gamemode); MC.gameMode.setLocalMode(this.prevGamemode);
MC.player.noCulling = false; MC.player.noCulling = false;
MC.player.abilities.setFlyingSpeed(this.prev_speed); MC.player.abilities.setFlyingSpeed(this.prevSpeed);
if (MC.getConnection() != null) { if (MC.getConnection() != null) {
NetworkPlayerInfo info = MC.getConnection().getPlayerInfo( NetworkPlayerInfo info = MC.getConnection().getPlayerInfo(
MC.player.getGameProfile().getId() MC.player.getGameProfile().getId()
); );
info.gameMode = this.prev_gamemode; // ACCESSTRANSFORMER: public net.minecraft.client.network.play.NetworkPlayerInfo field_178866_b if (info != null) info.gameMode = this.prevGamemode; // ACCESSTRANSFORMER: public net.minecraft.client.network.play.NetworkPlayerInfo field_178866_b
} }
MC.player.setPos(this.prev_pos.x, this.prev_pos.y, this.prev_pos.z); MC.player.setPos(this.prevPos.x, this.prevPos.y, this.prevPos.z);
MC.player.setDeltaMovement(Vector3d.ZERO); MC.player.setDeltaMovement(Vector3d.ZERO);
MC.level.removeEntity(this.mock_player.getId()); MC.level.removeEntity(this.mockPlayer.getId());
this.mock_player = null; // get rid of reference this.mockPlayer = null; // get rid of reference
} }
private class MockPlayer extends RemoteClientPlayerEntity { private static class MockPlayer extends RemoteClientPlayerEntity {
public MockPlayer() { public MockPlayer(@NonNull ClientWorld world, @NonNull ClientPlayerEntity player) {
super(MC.level, MC.player.getGameProfile()); super(world, player.getGameProfile());
this.setId(-666); // TODO hax this.setId(-666); // TODO hax
} }

View file

@ -13,8 +13,8 @@ public class HandChanger extends AbstractModule {
public final ForgeConfigSpec.ConfigValue<Double> main; public final ForgeConfigSpec.ConfigValue<Double> main;
public final ForgeConfigSpec.ConfigValue<Double> off; public final ForgeConfigSpec.ConfigValue<Double> off;
public final ForgeConfigSpec.ConfigValue<Boolean> cancel_main; public final ForgeConfigSpec.ConfigValue<Boolean> cancelMain;
public final ForgeConfigSpec.ConfigValue<Boolean> cancel_off; public final ForgeConfigSpec.ConfigValue<Boolean> cancelOff;
public HandChanger() { public HandChanger() {
super(); super();
@ -35,13 +35,13 @@ public class HandChanger extends AbstractModule {
.fallback(1.) .fallback(1.)
.build(this); .build(this);
this.cancel_main = Setting.Bool.builder() this.cancelMain = Setting.Bool.builder()
.name("cancel-main") .name("cancel-main")
.comment("completely prevent main hand rendering") .comment("completely prevent main hand rendering")
.fallback(false) .fallback(false)
.build(this); .build(this);
this.cancel_off = Setting.Bool.builder() this.cancelOff = Setting.Bool.builder()
.name("cancel-off") .name("cancel-off")
.comment("completely prevent off hand rendering") .comment("completely prevent off hand rendering")
.fallback(false) .fallback(false)
@ -52,7 +52,7 @@ public class HandChanger extends AbstractModule {
public void onRenderHands(RenderHandEvent event) { public void onRenderHands(RenderHandEvent event) {
switch (event.getHand()) { switch (event.getHand()) {
case MAIN_HAND: case MAIN_HAND:
if (this.cancel_main.get()) { if (this.cancelMain.get()) {
event.setCanceled(true); event.setCanceled(true);
} else if (this.main.get() != 1.0) { } else if (this.main.get() != 1.0) {
MC.gameRenderer.itemInHandRenderer.mainHandHeight = this.main.get().floatValue(); // ACCESSTRANSFORMER public net.minecraft.client.renderer.FirstPersonRenderer field_187469_f MC.gameRenderer.itemInHandRenderer.mainHandHeight = this.main.get().floatValue(); // ACCESSTRANSFORMER public net.minecraft.client.renderer.FirstPersonRenderer field_187469_f
@ -60,7 +60,7 @@ public class HandChanger extends AbstractModule {
} }
break; break;
case OFF_HAND: case OFF_HAND:
if (this.cancel_off.get()) { if (this.cancelOff.get()) {
event.setCanceled(true); event.setCanceled(true);
} else if (this.off.get() != 1.0) { } else if (this.off.get() != 1.0) {
MC.gameRenderer.itemInHandRenderer.offHandHeight = this.off.get().floatValue(); // ACCESSTRANSFORMER public net.minecraft.client.renderer.FirstPersonRenderer field_187470_g MC.gameRenderer.itemInHandRenderer.offHandHeight = this.off.get().floatValue(); // ACCESSTRANSFORMER public net.minecraft.client.renderer.FirstPersonRenderer field_187470_g

View file

@ -13,8 +13,6 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
@AutoService(ILoadable.class) @AutoService(ILoadable.class)
public class Chams extends QuickModule { public class Chams extends QuickModule {
protected int getDefaultKey() { return UNBOUND; }
@SubscribeEvent @SubscribeEvent
public void onRenderLivingPre(RenderLivingEvent.Pre<?, ?> event) { public void onRenderLivingPre(RenderLivingEvent.Pre<?, ?> event) {
GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL); GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);

View file

@ -23,14 +23,19 @@ public class Fullbright extends QuickModule {
@SubscribeEvent @SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) { public void onTick(TickEvent.ClientTickEvent event) {
if (MC == null) return;
if (MC.player == null) return; if (MC.player == null) return;
MC.player.addEffect(new EffectInstance(Effect.byId(NIGHT_VISION_ID), FOUR_MINUTES_TWENTY_SECONDS)); Effect nv = Effect.byId(NIGHT_VISION_ID);
if(nv != null) {
MC.player.addEffect(new EffectInstance(nv, FOUR_MINUTES_TWENTY_SECONDS));
}
} }
@Override @Override
public void disable() { public void disable() {
super.disable(); super.disable();
MC.player.removeEffect(Effect.byId(NIGHT_VISION_ID)); Effect nv = Effect.byId(NIGHT_VISION_ID);
if(MC.player != null && nv != null) {
MC.player.removeEffect(nv);
}
} }
} }

View file

@ -49,8 +49,6 @@ public class StorageESP extends QuickModule {
private static final Vector3f FURNACE_COLOR = new Vector3f( 85.f/255.f, 85.f/255.f, 85.f/255.f); private static final Vector3f FURNACE_COLOR = new Vector3f( 85.f/255.f, 85.f/255.f, 85.f/255.f);
private static final Vector3f DROPPER_COLOR = new Vector3f( 0.f/255.f, 170.f/255.f, 0.f/255.f); private static final Vector3f DROPPER_COLOR = new Vector3f( 0.f/255.f, 170.f/255.f, 0.f/255.f);
protected int getDefaultKey() { return UNBOUND; }
public final ForgeConfigSpec.ConfigValue<Double> width; public final ForgeConfigSpec.ConfigValue<Double> width;
public final ForgeConfigSpec.ConfigValue<Double> alpha; public final ForgeConfigSpec.ConfigValue<Double> alpha;

View file

@ -0,0 +1,87 @@
package ftbsc.bscv.system;
import ftbsc.bscv.Boscovicino;
import ftbsc.bscv.ICommons;
import ftbsc.bscv.api.IModule;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.client.util.InputMappings;
import net.minecraftforge.client.event.InputEvent;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import java.util.HashMap;
public class Bindings implements ICommons {
public static final int UNBOUND = InputMappings.UNKNOWN.getValue();
private final HashMap<KeyBinding, Runnable> executorMap;
private ForgeConfigSpec.ConfigValue<?> store;
public Bindings(ForgeConfigSpec.Builder spec) {
MinecraftForge.EVENT_BUS.register(this);
this.executorMap = new HashMap<>();
this.store = spec
//.comment("actual friend list")
.define("lol", () -> null, (u) -> {
System.out.println(u.getClass().getName());
return true;
});
}
public KeyBinding registerBinding(String name, int key, IModule module) {
KeyBinding kb = this.createBinding(name, key);
this.executorMap.put(kb, module::toggle);
return kb;
}
public KeyBinding registerBinding(String name, int key, String macroFileName) {
KeyBinding kb = this.createBinding(name, key);
this.executorMap.put(kb, () -> BSCV.macros.execute(macroFileName));
return kb;
}
private KeyBinding createBinding(String name, int key) {
KeyBinding kb = new KeyBinding(getBindName(name), UNBOUND, getCategory());
InputMappings.Input in = 0 <= key && key <= 7
? InputMappings.Type.MOUSE.getOrCreate(key)
: InputMappings.Type.KEYSYM.getOrCreate(key);
kb.setKey(in);
ClientRegistry.registerKeyBinding(kb);
return kb;
}
@SubscribeEvent
public void onKeyPress(InputEvent.KeyInputEvent event) {
this.onKeyPress(event.getKey());
}
@SubscribeEvent
public void onKeyPress(InputEvent.MouseInputEvent event) {
this.onKeyPress(event.getButton());
}
//TODO on keybind change event
private void onKeyPress(int key) {
long windowId = Minecraft.getInstance().getWindow().getWindow();
for(KeyBinding kb : this.executorMap.keySet()) {
if(kb.getKey().getValue() == key) {
if(InputMappings.isKeyDown(windowId, key)) {
MC.execute(this.executorMap.get(kb));
}
return;
}
}
}
private static String getBindName(String name) {
return String.format("key.%s.%s", Boscovicino.MOD_ID, name);
}
private static String getCategory() {
return String.format("key.category.%s", Boscovicino.MOD_ID);
}
}

View file

@ -33,10 +33,10 @@ public class Friends implements ICommons {
return null; return null;
} }
private ForgeConfigSpec.ConfigValue<List<? extends String>> store; public final ForgeConfigSpec.ConfigValue<List<? extends String>> store;
public Friends(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) { public Friends(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
this.store = builder.comment("actual friend list").defineList("data", () -> new ArrayList<String>(), u -> { this.store = builder.comment("actual friend list").defineList("data", ArrayList::new, u -> {
try{ try{
UUID.fromString(u.toString()); UUID.fromString(u.toString());
return true; return true;

View file

@ -0,0 +1,50 @@
package ftbsc.bscv.system;
import ftbsc.bscv.Boscovicino;
import party.iroiro.luajava.Lua;
import party.iroiro.luajava.luajit.LuaJit;
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
public class Macros {
private final Lua lua;
private final HashMap<String, String> macroCache;
public Macros(Boscovicino bscv) throws IOException {
this.lua = new LuaJit();
this.lua.pushJavaObject(bscv); //TODO use instance
this.lua.setGlobal("BSCV");
this.macroCache = new HashMap<>();
// load macros
Path path = Paths.get("macros/");
if(!Files.isDirectory(path)) {
Files.createDirectories(path);
}
//TODO lazy load setting
try(DirectoryStream<Path> stream = Files.newDirectoryStream(path, (p) -> p.toFile().isFile())) {
for(Path macro : stream) {
String name = macro.getFileName().toString();
if(name.endsWith(".lua")) {
String code = String.join("\n", Files.readAllLines(macro));
this.macroCache.put(name, code);
bscv.bindings.registerBinding(name, Bindings.UNBOUND, name);
}
}
}
}
public boolean execute(String macroFilePath) {
String code = this.macroCache.get(macroFilePath);
if(code == null) return false;
this.lua.execute(code);
return true;
}
}

View file

@ -13,7 +13,7 @@ import java.util.HashSet;
import java.util.ServiceLoader; import java.util.ServiceLoader;
import java.util.Set; import java.util.Set;
public class ModManager { public class Modules {
private Builder cfgBuilder; private Builder cfgBuilder;
private CommandDispatcher<CommandSource> dispatcher; private CommandDispatcher<CommandSource> dispatcher;
@ -21,7 +21,7 @@ public class ModManager {
public final Set<IModule> mods; public final Set<IModule> mods;
public final Set<String> categories; public final Set<String> categories;
public ModManager(Builder cfgBuilder, CommandDispatcher<CommandSource> dispatcher) { public Modules(Builder cfgBuilder, CommandDispatcher<CommandSource> dispatcher) {
this.cfgBuilder = cfgBuilder; this.cfgBuilder = cfgBuilder;
this.dispatcher = dispatcher; this.dispatcher = dispatcher;
this.mods = new HashSet<>(); this.mods = new HashSet<>();
@ -39,6 +39,16 @@ public class ModManager {
return null; return null;
} }
@Nullable
public IModule get(String name) {
for (IModule m : this.mods) {
if (m.getName().equals(name)) {
return m;
}
}
return null;
}
public void load() { public void load() {
for (ILoadable module : ServiceLoader.load(ILoadable.class)) { for (ILoadable module : ServiceLoader.load(ILoadable.class)) {
if(module instanceof IModule) { if(module instanceof IModule) {