chore: hack to have BSCV as interface static
This commit is contained in:
parent
5076e2b37c
commit
881cbd9bdb
31 changed files with 232 additions and 218 deletions
|
@ -26,6 +26,8 @@ import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
|
||||||
@Mod(Boscovicino.MOD_ID)
|
@Mod(Boscovicino.MOD_ID)
|
||||||
public class Boscovicino implements ICommons {
|
public class Boscovicino implements ICommons {
|
||||||
|
@ -35,9 +37,6 @@ public class Boscovicino implements ICommons {
|
||||||
|
|
||||||
private final CommandDispatcher<CommandSource> dispatcher = new CommandDispatcher<>();
|
private final CommandDispatcher<CommandSource> dispatcher = new CommandDispatcher<>();
|
||||||
|
|
||||||
private static Boscovicino INSTANCE;
|
|
||||||
public static Boscovicino getInstance() { return INSTANCE; }
|
|
||||||
|
|
||||||
public final ForgeConfigSpec spec;
|
public final ForgeConfigSpec spec;
|
||||||
|
|
||||||
public final Modules modules;
|
public final Modules modules;
|
||||||
|
@ -48,23 +47,27 @@ public class Boscovicino implements ICommons {
|
||||||
@SuppressWarnings({"unused", "FieldCanBeLocal"}) // it just needs to exist to be used by player
|
@SuppressWarnings({"unused", "FieldCanBeLocal"}) // it just needs to exist to be used by player
|
||||||
private final Ruler ruler; //TODO remove
|
private final Ruler ruler; //TODO remove
|
||||||
|
|
||||||
public Boscovicino() throws IOException {
|
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;
|
||||||
|
|
||||||
|
// load modules
|
||||||
this.modules = new Modules(cfg, dp);
|
this.modules = new Modules(cfg, dp);
|
||||||
this.modules.load();
|
this.modules.load();
|
||||||
|
|
||||||
this.modules.finish();
|
this.modules.finish();
|
||||||
|
|
||||||
this.ruler = new Ruler(); //TODO remove
|
this.ruler = new Ruler(); //TODO remove
|
||||||
|
|
||||||
|
// macros and bindings
|
||||||
ForgeConfigSpec.Builder bindingSpec = new ForgeConfigSpec.Builder();
|
ForgeConfigSpec.Builder bindingSpec = new ForgeConfigSpec.Builder();
|
||||||
this.bindings = new Bindings(bindingSpec);
|
this.bindings = new Bindings(bindingSpec);
|
||||||
this.macros = new Macros(this);
|
this.macros = new Macros(this);
|
||||||
|
|
||||||
|
//friends
|
||||||
ForgeConfigSpec.Builder friendSpec = new ForgeConfigSpec.Builder();
|
ForgeConfigSpec.Builder friendSpec = new ForgeConfigSpec.Builder();
|
||||||
this.friends = new Friends(friendSpec, dp);
|
this.friends = new Friends(friendSpec, dp);
|
||||||
|
|
||||||
|
@ -77,8 +80,27 @@ public class Boscovicino implements ICommons {
|
||||||
// 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);
|
||||||
|
|
||||||
// create instance
|
// set the ICommons instance with reflection magic
|
||||||
INSTANCE = this;
|
// 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) {
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.getInstance().modules.getDispatcher();
|
return BSCV.modules.getDispatcher();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<LiteralArgumentBuilder<CommandSource>> subcommands() {
|
public List<LiteralArgumentBuilder<CommandSource>> subcommands() {
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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());
|
||||||
|
|
|
@ -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.getInstance().modules.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.getInstance().modules.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.getInstance().modules.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;
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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.getInstance().modules.getCfgBuilder();
|
return BSCV.modules.getCfgBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandDispatcher<CommandSource> getDispatcher() {
|
public CommandDispatcher<CommandSource> getDispatcher() {
|
||||||
return Boscovicino.getInstance().modules.getDispatcher();
|
return BSCV.modules.getDispatcher();
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbstractModule() {
|
public AbstractModule() {
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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.getInstance().modules.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.getInstance().friends.isFriend(player.getGameProfile().getId())) {
|
if (BSCV.friends.isFriend(player.getGameProfile().getId())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.getInstance().modules.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()))
|
||||||
|
|
|
@ -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();
|
||||||
|
|
|
@ -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))
|
||||||
)
|
)
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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()) {
|
||||||
|
|
|
@ -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.getInstance().modules.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);
|
||||||
|
|
|
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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()
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -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()) {
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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()) {
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package ftbsc.bscv.system;
|
package ftbsc.bscv.system;
|
||||||
|
|
||||||
import ftbsc.bscv.Boscovicino;
|
import ftbsc.bscv.Boscovicino;
|
||||||
|
import ftbsc.bscv.ICommons;
|
||||||
import ftbsc.bscv.api.IModule;
|
import ftbsc.bscv.api.IModule;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
|
@ -13,7 +14,7 @@ import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class Bindings {
|
public class Bindings implements ICommons {
|
||||||
public static final int UNBOUND = InputMappings.UNKNOWN.getValue();
|
public static final int UNBOUND = InputMappings.UNKNOWN.getValue();
|
||||||
|
|
||||||
private final HashMap<KeyBinding, Runnable> executorMap;
|
private final HashMap<KeyBinding, Runnable> executorMap;
|
||||||
|
@ -39,9 +40,7 @@ public class Bindings {
|
||||||
|
|
||||||
public KeyBinding registerBinding(String name, int key, String macroFileName) {
|
public KeyBinding registerBinding(String name, int key, String macroFileName) {
|
||||||
KeyBinding kb = this.createBinding(name, key);
|
KeyBinding kb = this.createBinding(name, key);
|
||||||
this.executorMap.put(kb, () -> {
|
this.executorMap.put(kb, () -> BSCV.macros.execute(macroFileName));
|
||||||
Boscovicino.getInstance().macros.execute(macroFileName);
|
|
||||||
});
|
|
||||||
return kb;
|
return kb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +69,9 @@ public class Bindings {
|
||||||
long windowId = Minecraft.getInstance().getWindow().getWindow();
|
long windowId = Minecraft.getInstance().getWindow().getWindow();
|
||||||
for(KeyBinding kb : this.executorMap.keySet()) {
|
for(KeyBinding kb : this.executorMap.keySet()) {
|
||||||
if(kb.getKey().getValue() == key) {
|
if(kb.getKey().getValue() == key) {
|
||||||
if(InputMappings.isKeyDown(windowId, key)) this.executorMap.get(kb).run();
|
if(InputMappings.isKeyDown(windowId, key)) {
|
||||||
|
MC.execute(this.executorMap.get(kb));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class Macros {
|
||||||
if(name.endsWith(".lua")) {
|
if(name.endsWith(".lua")) {
|
||||||
String code = String.join("\n", Files.readAllLines(macro));
|
String code = String.join("\n", Files.readAllLines(macro));
|
||||||
this.macroCache.put(name, code);
|
this.macroCache.put(name, code);
|
||||||
Boscovicino.getInstance().bindings.registerBinding(name, Bindings.UNBOUND, name);
|
bscv.bindings.registerBinding(name, Bindings.UNBOUND, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue