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
charset = utf-8
indent_style = tab
indent_size = 4
[*.java]
indent_size = 2
[*.gradle]
indent_size = 4
indent_size = 2

View file

@ -4,13 +4,14 @@ plugins {
alias libs.plugins.forgeGradle
alias libs.plugins.gitVersion
alias libs.plugins.checkerFramework
alias libs.plugins.shadow
}
version = gitVersion()
group = 'ftbsc'
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 {
deployJarDo = getProjectProperty("deployJar.do", "false")
@ -61,6 +62,9 @@ dependencies {
implementation libs.lillero
implementation libs.lilleroProcessor
implementation libs.autoServiceAnnotations
implementation libs.luaJava
implementation libs.luaJit
runtimeOnly libs.luaNatives.get().toString() + ":natives-desktop" //lol
annotationProcessor libs.lilleroProcessor
annotationProcessor libs.autoService
}
@ -69,8 +73,26 @@ compileJava { //mappings for lillero-processor
options.compilerArgs << '-AmappingsFile=https://data.fantabos.co/1.16.5.tsrg'
}
def simpleFileName = "${jar.archiveBaseName.get()}-${shortVersion}.${jar.archiveExtension.get()}"
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 {
attributes([
"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
tasks.register('deployJar', Copy) {

View file

@ -7,11 +7,14 @@ autoService = "1.0.1"
lillero = "0.4.1"
lilleroProcessor = "0.5.2"
checkerFramework = "0.6.24"
shadow = "7.1.2"
luaJava = "3.5.0"
[plugins]
forgeGradle = { id = "net.minecraftforge.gradle", version.ref = "forgeGradle" }
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]
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" }
lillero = { group = "ftbsc", name = "lll", version.ref = "lillero" }
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.patches.CommandsPatch.CommandsBuiltEvent;
import ftbsc.bscv.system.Friends;
import ftbsc.bscv.system.ModManager;
import ftbsc.bscv.system.Ruler;
import ftbsc.bscv.system.*;
import net.minecraft.client.gui.screen.IngameMenuScreen;
import net.minecraft.client.gui.widget.button.Button;
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.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 static String MOD_ID = "bscv";
public static final String MOD_ID = "bscv";
public static final Logger LOGGER = LogManager.getLogger();
public static ModManager modManager; //todo this should not be static
private final CommandDispatcher<CommandSource> dispatcher = new CommandDispatcher<>();
public static ForgeConfigSpec spec;
public final ForgeConfigSpec spec;
private static Friends friends;
public static Friends friends() { return Boscovicino.friends; }
public final Modules modules;
public final Friends friends;
public final Bindings bindings;
public final Macros macros;
@SuppressWarnings("unused") // it just needs to exist to be used by player
private static Ruler ruler;
@SuppressWarnings({"unused", "FieldCanBeLocal"}) // it just needs to exist to be used by player
private final Ruler ruler; //TODO remove
public Boscovicino() {
public Boscovicino() throws IOException, ReflectiveOperationException {
// add listener
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onSetupComplete);
// initialise config
ForgeConfigSpec.Builder cfg = new ForgeConfigSpec.Builder();
CommandDispatcher<CommandSource> dp = this.dispatcher;
Boscovicino.modManager = new ModManager(cfg, dp);
Boscovicino.modManager.load();
// load modules
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();
Boscovicino.spec = cfg.build();
// macros and bindings
ForgeConfigSpec.Builder bindingSpec = new ForgeConfigSpec.Builder();
this.bindings = new Bindings(bindingSpec);
this.macros = new Macros(this);
//friends
ForgeConfigSpec.Builder friendSpec = new ForgeConfigSpec.Builder();
Boscovicino.friends = new Friends(friendSpec, dp);
this.friends = new Friends(friendSpec, dp);
// register config handler
ModLoadingContext.get().registerConfig(Type.CLIENT, spec, "bscv.toml");
// register config handlers
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, 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);
// 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) {
@ -86,7 +117,7 @@ public class Boscovicino implements ICommons {
private void onSetupComplete(final FMLLoadCompleteEvent event) {
LOGGER.info("Initializing modules");
for (IModule m : modManager.mods) {
for (IModule m : modules.mods) {
if (m.isEnabled()) {
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
public void onClientChatEvent(ClientChatEvent event) {
if (event.getMessage().startsWith("/")) {
CommandSource source = MC.player.createCommandSourceStack(); // TODO player could be NULL
if (MC.player != null && event.getMessage().startsWith("/")) {
CommandSource source = MC.player.createCommandSourceStack();
try {
LOGGER.info(String.format("Running command %s", event.getMessage()));
this.dispatcher.execute(event.getMessage().substring(1), source);
@ -116,14 +147,15 @@ public class Boscovicino implements ICommons {
}
@SubscribeEvent
// TODO de-jank this, maybe by extending IngameMenuScreen
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();
screen.buttons.remove(3);
screen.buttons.remove(3);
screen.children.remove(3);
screen.children.remove(3);
Button mods_btn = new Button(
Button modsBtn = new Button(
screen.width / 2 + 4,
screen.height / 4 + 72 + -16, 98, 20,
new TranslationTextComponent("fml.menu.mods"),
@ -132,10 +164,10 @@ public class Boscovicino implements ICommons {
}
);
// need to add it twice for it to work once...
screen.buttons.add(3, mods_btn);
screen.buttons.add(3, mods_btn);
screen.children.add(3, mods_btn);
screen.children.add(3, mods_btn);
screen.buttons.add(3, modsBtn);
screen.buttons.add(3, modsBtn);
screen.children.add(3, modsBtn);
screen.children.add(3, modsBtn);
}
}
}

View file

@ -3,5 +3,6 @@ package ftbsc.bscv;
import net.minecraft.client.Minecraft;
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.builder.LiteralArgumentBuilder;
import ftbsc.bscv.Boscovicino;
import ftbsc.bscv.ICommons;
import ftbsc.bscv.api.ICommand;
import net.minecraft.command.CommandSource;
@ -19,7 +18,7 @@ public abstract class AbstractCommand implements ICommand, ICommons {
}
public CommandDispatcher<CommandSource> getDispatcher() {
return Boscovicino.modManager.getDispatcher();
return BSCV.modules.getDispatcher();
}
public List<LiteralArgumentBuilder<CommandSource>> subcommands() {

View file

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

View file

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

View file

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

View file

@ -23,6 +23,8 @@ public class Teleport extends AbstractCommand {
.then(
Commands.argument("distance", DoubleArgumentType.doubleArg())
.executes( ctx -> {
if(MC.player == null)
return 0;
double distance = ctx.getArgument("distance", Double.class);
MC.player.setPos(
MC.player.position().x,
@ -41,6 +43,8 @@ public class Teleport extends AbstractCommand {
.then(
Commands.argument("z", DoubleArgumentType.doubleArg())
.executes( ctx -> {
if(MC.player == null)
return 0;
double x = ctx.getArgument("x", Double.class);
double y = ctx.getArgument("y", 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.arguments.BoolArgumentType;
import ftbsc.bscv.Boscovicino;
import ftbsc.bscv.ICommons;
import ftbsc.bscv.api.IModule;
import net.minecraft.command.CommandSource;
@ -27,12 +26,12 @@ public abstract class AbstractModule implements IModule, ICommons {
@Override
public ForgeConfigSpec.Builder getConfigBuilder() {
return Boscovicino.modManager.getCfgBuilder();
return BSCV.modules.getCfgBuilder();
}
@Override
public CommandDispatcher<CommandSource> getDispatcher() {
return Boscovicino.modManager.getDispatcher();
return BSCV.modules.getDispatcher();
}
public AbstractModule() {

View file

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

View file

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

View file

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

View file

@ -26,7 +26,7 @@ public class Coordinates extends HudModule {
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
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.posY = MC.player.getY();

View file

@ -38,6 +38,7 @@ public class EntityList extends HudModule {
@SubscribeEvent
public void onRenderOverlay(RenderGameOverlayEvent event) {
if (event.getType() != ElementType.TEXT) return;
if (MC.level == null) return;
if (this.shouldHide()) return;
List<String> entities = new ArrayList<>();
@ -65,7 +66,7 @@ public class EntityList extends HudModule {
.y(this.y.get() + offset)
.scale(this.scale.get())
.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.withColor(Color.fromLegacyFormat(TextFormatting.WHITE))
)

View file

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

View file

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

View file

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

View file

@ -2,7 +2,6 @@ package ftbsc.bscv.modules.motion;
import com.google.auto.service.AutoService;
import ftbsc.bscv.Boscovicino;
import ftbsc.bscv.api.ILoadable;
import ftbsc.bscv.modules.AbstractModule;
import ftbsc.bscv.patches.BackgroundPatch.RenderBackgroundEvent;
@ -30,7 +29,7 @@ public class GuiMove extends AbstractModule {
public final ForgeConfigSpec.ConfigValue<Boolean> background;
private AutoWalk autoWalk_mod;
private AutoWalk autoWalkMod;
public GuiMove() {
super();
@ -44,7 +43,7 @@ public class GuiMove extends AbstractModule {
@Override
public void enable() {
this.autoWalk_mod = (AutoWalk) Boscovicino.modManager.get(AutoWalk.class);
this.autoWalkMod = (AutoWalk) BSCV.modules.get(AutoWalk.class);
super.enable();
}
@ -72,7 +71,7 @@ public class GuiMove extends AbstractModule {
private void forceMovementTick(MovementInput input) {
// 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.left = this.isKeyDown(MC.options.keyLeft);
input.right = this.isKeyDown(MC.options.keyRight);

View file

@ -16,7 +16,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
@AutoService(ILoadable.class)
public class VanillaFlight extends QuickModule {
private enum AntikickMode {
public enum AntiKickMode {
NONE,
PACKET,
FORCED
@ -27,10 +27,10 @@ public class VanillaFlight extends QuickModule {
public final ForgeConfigSpec.ConfigValue<Boolean> force;
public final ForgeConfigSpec.ConfigValue<Boolean> drift;
public final ForgeConfigSpec.ConfigValue<Double> speed;
public final ForgeConfigSpec.ConfigValue<AntikickMode> antikick;
public final ForgeConfigSpec.ConfigValue<Double> antikick_magnitude;
public final ForgeConfigSpec.ConfigValue<Integer> antikick_cycle;
public final ForgeConfigSpec.ConfigValue<Integer> antikick_duration;
public final ForgeConfigSpec.ConfigValue<AntiKickMode> antikick;
public final ForgeConfigSpec.ConfigValue<Double> antikickMagnitude;
public final ForgeConfigSpec.ConfigValue<Integer> antikickCycle;
public final ForgeConfigSpec.ConfigValue<Integer> antikickDuration;
private int tick = 0;
@ -56,20 +56,20 @@ public class VanillaFlight extends QuickModule {
.comment("flight speed to set")
.build(this);
this.antikick = Setting.Switch.builder(AntikickMode.class)
.fallback(AntikickMode.PACKET)
this.antikick = Setting.Switch.builder(AntiKickMode.class)
.fallback(AntiKickMode.PACKET)
.name("antikick")
.comment("prevent vanilla flight kick by descending")
.build(this);
this.antikick_magnitude = Setting.Decimal.builder()
this.antikickMagnitude = Setting.Decimal.builder()
.min(0.)
.fallback(0.032)
.name("magnitude")
.comment("magnitude of antikick push")
.build(this);
this.antikick_cycle = Setting.Number.builder()
this.antikickCycle = Setting.Number.builder()
.min(1)
.max(80)
.fallback(70)
@ -77,7 +77,7 @@ public class VanillaFlight extends QuickModule {
.comment("how often to run antikick routine")
.build(this);
this.antikick_duration = Setting.Number.builder()
this.antikickDuration = Setting.Number.builder()
.min(1)
.max(80)
.fallback(5)
@ -86,7 +86,7 @@ public class VanillaFlight extends QuickModule {
.build(this);
}
private long last_event = 0;
private long lastEvent = 0;
private boolean couldFlyBefore = false;
private float flyingSpeedBefore = 0.05f;
@ -113,11 +113,11 @@ public class VanillaFlight extends QuickModule {
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();
if (this.tick == 0 && this.antikick.get() == AntikickMode.PACKET) {
MC.player.setPos(pos.x, pos.y - this.antikick_magnitude.get(), pos.z);
if (this.tick == 0 && this.antikick.get() == AntiKickMode.PACKET) {
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();
switch (this.antikickState) {
case COOLDOWN:
if (now - this.last_event < this.antikick_cycle.get() * MS_PER_TICK) break;
this.last_event = now;
if (now - this.lastEvent < this.antikickCycle.get() * MS_PER_TICK) break;
this.lastEvent = now;
this.antikickState = AntikickState.ACTIVE; // don't break and also run 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;
break;
}
@ -139,7 +139,7 @@ public class VanillaFlight extends QuickModule {
event.packet instanceof CPlayerPacket.PositionRotationPacket
) {
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
public void onPacketOutgoing(PacketEvent.Outgoing event) {
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) {
Boscovicino.LOGGER.warn("Could not process fields of packet {}", event.packet.toString());
}
@ -68,7 +68,7 @@ public class PacketLogger extends QuickModule {
@SubscribeEvent
public void onPacketIncoming(PacketEvent.Incoming event) {
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) {
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();
List<String> classNames = new ArrayList<>();
JsonObject fields = new JsonObject();
@ -97,7 +97,7 @@ public class PacketLogger extends QuickModule {
for (Field field : clazz.getDeclaredFields()) {
if (!Modifier.isStatic(field.getModifiers())) {
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();
@ -105,12 +105,12 @@ public class PacketLogger extends QuickModule {
JsonObject json = new JsonObject();
json.addProperty("time", time);
json.addProperty("name", this.compose_packet_name(classNames));
json.addProperty("name", this.composePacketName(classNames));
json.add("fields", fields);
return json;
}
private JsonElement format_value(Object value) {
private JsonElement formatValue(Object value) {
if (value == null) return null;
if (value instanceof ITextComponent) {
ITextComponent component = (ITextComponent) value;
@ -119,7 +119,7 @@ public class PacketLogger extends QuickModule {
return obj;
}
if (value.getClass().isArray()) {
return this.array_to_string(value);
return this.arrayToString(value);
}
if (value instanceof Number) {
return new JsonPrimitive((Number) value);
@ -135,17 +135,17 @@ public class PacketLogger extends QuickModule {
}
if (value instanceof Vector3d) {
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) {
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
return new JsonPrimitive(value.toString());
}
private JsonArray array_to_string(Object value) {
private JsonArray arrayToString(Object value) {
JsonArray out = new JsonArray();
if (value instanceof byte[]) {
byte[] arr = (byte[]) value;
@ -192,7 +192,7 @@ public class PacketLogger extends QuickModule {
return out;
}
private String compose_packet_name(List<String> classNames) {
private String composePacketName(List<String> classNames) {
StringBuilder builder = new StringBuilder();
for (int i = classNames.size() - 1; i >= 0; i--) {
builder.append(classNames.get(i));
@ -201,7 +201,7 @@ public class PacketLogger extends QuickModule {
return builder.toString();
}
private double pretty_time() {
private double prettyTime() {
return (double) System.nanoTime() / 1000000000.;
}
}

View file

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

View file

@ -28,6 +28,7 @@ public class AutoDisconnect extends AbstractModule {
@SubscribeEvent
public void onPacket(PacketEvent.Incoming event) {
if(MC.player == null) return;
if (event.packet instanceof SUpdateHealthPacket) {
SUpdateHealthPacket packet = (SUpdateHealthPacket) event.packet;
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.patches.PacketPatch.PacketEvent;
import ftbsc.bscv.tools.Setting;
import net.minecraft.client.Minecraft;
import net.minecraft.network.play.server.SPlaySoundEffectPacket;
import net.minecraft.util.Hand;
import net.minecraft.util.SoundEvents;
@ -37,22 +36,23 @@ public class AutoFish extends AbstractModule {
@SubscribeEvent
public void onPacket(PacketEvent.Incoming event) {
if (MC.gameMode == null || MC.player == null || MC.level == null)
return;
if (event.packet instanceof SPlaySoundEffectPacket) {
SPlaySoundEffectPacket packet = (SPlaySoundEffectPacket) event.packet;
if (packet.getSound().equals(SoundEvents.FISHING_BOBBER_SPLASH)) {
MC.gameMode.useItem(MC.player, MC.level, Hand.MAIN_HAND);
if (this.recast.get()) {
new RecastThread(MC, this.delay.get()).start();
new RecastThread(this.delay.get()).start();
}
}
}
}
private class RecastThread extends Thread {
private long delay;
private Minecraft mc;
public RecastThread(Minecraft mc, long delay) {
this.mc = mc;
private static class RecastThread extends Thread {
private final long delay;
public RecastThread(long delay) {
this.delay = delay;
this.setDaemon(true);
}
@ -60,8 +60,10 @@ public class AutoFish extends AbstractModule {
public void run() {
try {
Thread.sleep(this.delay);
} catch (InterruptedException e) {} // ignore
this.mc.gameMode.useItem(this.mc.player, this.mc.level, Hand.MAIN_HAND);
} catch (InterruptedException ignored) {} // ignore
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 ftbsc.bscv.Boscovicino;
import ftbsc.bscv.api.ILoadable;
import ftbsc.bscv.modules.AbstractModule;
import ftbsc.bscv.tools.Inventory;
@ -22,7 +21,7 @@ import java.util.List;
public class AutoTool extends AbstractModule {
public final ForgeConfigSpec.ConfigValue<Integer> limit;
public final ForgeConfigSpec.ConfigValue<Boolean> prefer_looting;
public final ForgeConfigSpec.ConfigValue<Boolean> preferLooting;
public AutoTool() {
super();
@ -33,7 +32,7 @@ public class AutoTool extends AbstractModule {
.fallback(1)
.build(this);
this.prefer_looting = Setting.Bool.builder()
this.preferLooting = Setting.Bool.builder()
.name("prefer-looting")
.comment("when picking best weapon, prefer looting over slight more DPS")
.fallback(true)
@ -46,10 +45,11 @@ public class AutoTool extends AbstractModule {
&& 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);
int current_slot = MC.player.inventory.selected;
double current_damage = Inventory.itemDPS(hotbar.get(current_slot).getItem());
int currentSlot = MC.player.inventory.selected;
double currentDamage = Inventory.itemDPS(hotbar.get(currentSlot).getItem());
for (int i = 0; i < Inventory.HOTBAR_SIZE; i++) {
ItemStack item = hotbar.get(i).getItem();
if (this.itemIsTooDamaged(item)) {
@ -59,51 +59,48 @@ public class AutoTool extends AbstractModule {
double damage = Inventory.itemDPS(item);
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;
}
if (damage > current_damage) {
current_slot = i;
current_damage = damage;
if (damage > currentDamage) {
currentSlot = i;
currentDamage = damage;
}
}
if (current_slot != MC.player.inventory.selected) {
MC.player.inventory.selected = current_slot;
if (currentSlot != MC.player.inventory.selected) {
MC.player.inventory.selected = currentSlot;
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);
int current_slot = MC.player.inventory.selected;
int currentSlot = MC.player.inventory.selected;
BlockRayTraceResult result = (BlockRayTraceResult) MC.hitResult;
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++) {
ItemStack item = hotbar.get(i).getItem();
if (this.itemIsTooDamaged(item)) {
continue;
}
float speed = item.getDestroySpeed(state);
if (speed > current_speed) {
current_slot = i;
current_speed = speed;
if (speed > currentSpeed) {
currentSlot = i;
currentSpeed = speed;
}
}
if (current_slot != MC.player.inventory.selected) {
MC.player.inventory.selected = current_slot;
if (currentSlot != MC.player.inventory.selected) {
MC.player.inventory.selected = currentSlot;
MC.gameMode.ensureHasSentCarriedItem(); // ACCESSTRANSFORMER
return true;
}
return false;
}
@SubscribeEvent
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
// some without putting a dumb time cooldown?;
if (event.isAttack()) {

View file

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

View file

@ -7,14 +7,17 @@ import ftbsc.bscv.modules.QuickModule;
import ftbsc.bscv.patches.PacketPatch.PacketEvent;
import ftbsc.bscv.tools.Keyboard;
import ftbsc.bscv.tools.Setting;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.entity.player.RemoteClientPlayerEntity;
import net.minecraft.client.network.play.NetworkPlayerInfo;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.network.play.client.CPlayerPacket;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.GameType;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import org.checkerframework.checker.nullness.qual.NonNull;
@AutoService(ILoadable.class)
public class Freecam extends QuickModule {
@ -23,15 +26,10 @@ public class Freecam extends QuickModule {
public final ForgeConfigSpec.ConfigValue<Double> speed;
public final ForgeConfigSpec.ConfigValue<Boolean> drift;
private Vector3d prev_pos = new Vector3d(0.0, 0.0, 0.0);
private float prev_speed = 0.05f;
private GameType prev_gamemode = GameType.SURVIVAL;
private MockPlayer mock_player;
@Override
protected int getDefaultKey() {
return UNBOUND;
}
private Vector3d prevPos = new Vector3d(0.0, 0.0, 0.0);
private float prevSpeed = 0.05f;
private GameType prevGamemode = GameType.SURVIVAL;
private MockPlayer mockPlayer;
public Freecam() {
super();
@ -77,52 +75,53 @@ public class Freecam extends QuickModule {
@Override
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");
return;
}
this.prev_speed = MC.player.abilities.getFlyingSpeed();
this.prev_pos = MC.player.position();
this.prev_gamemode = MC.gameMode.getPlayerMode();
this.prevSpeed = MC.player.abilities.getFlyingSpeed();
this.prevPos = MC.player.position();
this.prevGamemode = MC.gameMode.getPlayerMode();
MC.gameMode.setLocalMode(GameType.SPECTATOR);
MC.player.noCulling = true;
if (MC.getConnection() != null) {
NetworkPlayerInfo info = MC.getConnection().getPlayerInfo(
MC.player.getGameProfile().getId()
);
if (info == null) return;
info.gameMode = GameType.SPECTATOR; // ACCESSTRANSFORMER: public net.minecraft.client.network.play.NetworkPlayerInfo field_178866_b
}
this.mock_player = new MockPlayer();
this.mock_player.setPosAndOldPos(this.prev_pos.x, this.prev_pos.y, this.prev_pos.z);
this.mock_player.setYBodyRot(MC.player.yBodyRot);
MC.level.addPlayer(-666, this.mock_player);
this.mockPlayer = new MockPlayer(MC.level, MC.player);
this.mockPlayer.setPosAndOldPos(this.prevPos.x, this.prevPos.y, this.prevPos.z);
this.mockPlayer.setYBodyRot(MC.player.yBodyRot);
MC.level.addPlayer(-666, this.mockPlayer);
super.enable();
}
@Override
public void disable() {
super.disable();
if (MC.player == null) return;
MC.gameMode.setLocalMode(this.prev_gamemode);
if (MC.player == null || MC.level == null || MC.gameMode == null) return;
MC.gameMode.setLocalMode(this.prevGamemode);
MC.player.noCulling = false;
MC.player.abilities.setFlyingSpeed(this.prev_speed);
MC.player.abilities.setFlyingSpeed(this.prevSpeed);
if (MC.getConnection() != null) {
NetworkPlayerInfo info = MC.getConnection().getPlayerInfo(
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.level.removeEntity(this.mock_player.getId());
this.mock_player = null; // get rid of reference
MC.level.removeEntity(this.mockPlayer.getId());
this.mockPlayer = null; // get rid of reference
}
private class MockPlayer extends RemoteClientPlayerEntity {
public MockPlayer() {
super(MC.level, MC.player.getGameProfile());
private static class MockPlayer extends RemoteClientPlayerEntity {
public MockPlayer(@NonNull ClientWorld world, @NonNull ClientPlayerEntity player) {
super(world, player.getGameProfile());
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> off;
public final ForgeConfigSpec.ConfigValue<Boolean> cancel_main;
public final ForgeConfigSpec.ConfigValue<Boolean> cancel_off;
public final ForgeConfigSpec.ConfigValue<Boolean> cancelMain;
public final ForgeConfigSpec.ConfigValue<Boolean> cancelOff;
public HandChanger() {
super();
@ -35,13 +35,13 @@ public class HandChanger extends AbstractModule {
.fallback(1.)
.build(this);
this.cancel_main = Setting.Bool.builder()
this.cancelMain = Setting.Bool.builder()
.name("cancel-main")
.comment("completely prevent main hand rendering")
.fallback(false)
.build(this);
this.cancel_off = Setting.Bool.builder()
this.cancelOff = Setting.Bool.builder()
.name("cancel-off")
.comment("completely prevent off hand rendering")
.fallback(false)
@ -52,7 +52,7 @@ public class HandChanger extends AbstractModule {
public void onRenderHands(RenderHandEvent event) {
switch (event.getHand()) {
case MAIN_HAND:
if (this.cancel_main.get()) {
if (this.cancelMain.get()) {
event.setCanceled(true);
} 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
@ -60,7 +60,7 @@ public class HandChanger extends AbstractModule {
}
break;
case OFF_HAND:
if (this.cancel_off.get()) {
if (this.cancelOff.get()) {
event.setCanceled(true);
} 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

View file

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

View file

@ -23,14 +23,19 @@ public class Fullbright extends QuickModule {
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
if (MC == 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
public void 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 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> 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;
}
private ForgeConfigSpec.ConfigValue<List<? extends String>> store;
public final ForgeConfigSpec.ConfigValue<List<? extends String>> store;
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{
UUID.fromString(u.toString());
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.Set;
public class ModManager {
public class Modules {
private Builder cfgBuilder;
private CommandDispatcher<CommandSource> dispatcher;
@ -21,7 +21,7 @@ public class ModManager {
public final Set<IModule> mods;
public final Set<String> categories;
public ModManager(Builder cfgBuilder, CommandDispatcher<CommandSource> dispatcher) {
public Modules(Builder cfgBuilder, CommandDispatcher<CommandSource> dispatcher) {
this.cfgBuilder = cfgBuilder;
this.dispatcher = dispatcher;
this.mods = new HashSet<>();
@ -39,6 +39,16 @@ public class ModManager {
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() {
for (ILoadable module : ServiceLoader.load(ILoadable.class)) {
if(module instanceof IModule) {