summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/ftbsc/bscv/BoSCoVicino.java18
-rw-r--r--src/main/java/ftbsc/bscv/ICommons.java7
-rw-r--r--src/main/java/ftbsc/bscv/module/hud/ActiveModules.java5
-rw-r--r--src/main/java/ftbsc/bscv/module/hud/Coordinates.java10
-rw-r--r--src/main/java/ftbsc/bscv/module/hud/EntityList.java8
-rw-r--r--src/main/java/ftbsc/bscv/module/hud/InfoDisplay.java11
-rw-r--r--src/main/java/ftbsc/bscv/module/motion/VanillaFlight.java13
-rw-r--r--src/main/java/ftbsc/bscv/module/self/FastInteract.java10
-rw-r--r--src/main/java/ftbsc/bscv/module/vision/Fullbright.java12
-rw-r--r--src/main/java/ftbsc/bscv/tools/Anchor.java6
-rw-r--r--src/main/java/ftbsc/bscv/tools/Text.java6
11 files changed, 54 insertions, 52 deletions
diff --git a/src/main/java/ftbsc/bscv/BoSCoVicino.java b/src/main/java/ftbsc/bscv/BoSCoVicino.java
index 9a69620..950be8e 100644
--- a/src/main/java/ftbsc/bscv/BoSCoVicino.java
+++ b/src/main/java/ftbsc/bscv/BoSCoVicino.java
@@ -1,7 +1,6 @@
package ftbsc.bscv;
import net.minecraft.block.Block;
-import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;
@@ -35,14 +34,12 @@ import ftbsc.bscv.module.hud.*;
// The value here should match an entry in the META-INF/mods.toml file
@Mod("bscv")
-public class BoSCoVicino {
+public class BoSCoVicino implements ICommons {
public static String MOD_ID = "bscv";
// Directly reference a log4j logger.
public static final Logger LOGGER = LogManager.getLogger();
- public static Minecraft minecraft;
-
public static List<Module> mods;
private final CommandDispatcher<CommandSource> dispatcher = new CommandDispatcher<>();
@@ -53,9 +50,6 @@ public class BoSCoVicino {
// Register the setup method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientSetup);
- // Store minecraft instance
- BoSCoVicino.minecraft = Minecraft.getInstance();
-
// load and register mods
BoSCoVicino.mods = new ArrayList<Module>();
@@ -81,7 +75,7 @@ public class BoSCoVicino {
}
public static void log(String message) {
- BoSCoVicino.minecraft.gui.getChat().addMessage(new StringTextComponent(message));
+ MC.gui.getChat().addMessage(new StringTextComponent(message));
}
private void clientSetup(final FMLClientSetupEvent event) {
@@ -95,7 +89,7 @@ public class BoSCoVicino {
dispatcher.register(
Commands.literal("hints")
.executes(ctx -> {
- ClientPlayerEntity player = BoSCoVicino.minecraft.player;
+ ClientPlayerEntity player = MC.player;
if (player != null) {
try {
Field commands = player.connection.getClass().getDeclaredField("field_195517_n"); // "commands", it's obfuscated
@@ -125,11 +119,11 @@ public class BoSCoVicino {
@SubscribeEvent
public void onClientChatEvent(ClientChatEvent event) {
if (event.getMessage().startsWith("/")) {
- CommandSource source = BoSCoVicino.minecraft.player.createCommandSourceStack(); // TODO player could be NULL
+ CommandSource source = MC.player.createCommandSourceStack(); // TODO player could be NULL
try {
LOGGER.info(String.format("Running command %s", event.getMessage()));
this.dispatcher.execute(event.getMessage().substring(1), source);
- BoSCoVicino.minecraft.gui.getChat().addRecentChat(event.getMessage());
+ MC.gui.getChat().addRecentChat(event.getMessage());
event.setCanceled(true);
} catch (CommandSyntaxException e) {
LOGGER.error(String.format("Syntax error in command : %s", e.toString()));
@@ -140,7 +134,7 @@ public class BoSCoVicino {
@SubscribeEvent
public void onWorldLoad(WorldEvent.Load event) {
// TEMPORARY! add command to regenerate suggestions
- ClientPlayerEntity player = BoSCoVicino.minecraft.player;
+ ClientPlayerEntity player = MC.player;
if (player != null) {
try {
Field commands = player.connection.getClass().getDeclaredField("field_195517_n"); // "commands", it's obfuscated
diff --git a/src/main/java/ftbsc/bscv/ICommons.java b/src/main/java/ftbsc/bscv/ICommons.java
new file mode 100644
index 0000000..1abe0e5
--- /dev/null
+++ b/src/main/java/ftbsc/bscv/ICommons.java
@@ -0,0 +1,7 @@
+package ftbsc.bscv;
+
+import net.minecraft.client.Minecraft;
+
+public interface ICommons {
+ public static final Minecraft MC = Minecraft.getInstance();
+}
diff --git a/src/main/java/ftbsc/bscv/module/hud/ActiveModules.java b/src/main/java/ftbsc/bscv/module/hud/ActiveModules.java
index 5a1d8ab..cd0a197 100644
--- a/src/main/java/ftbsc/bscv/module/hud/ActiveModules.java
+++ b/src/main/java/ftbsc/bscv/module/hud/ActiveModules.java
@@ -5,6 +5,7 @@ import static ftbsc.bscv.tools.Text.TextBuilder;
import com.mojang.brigadier.CommandDispatcher;
import ftbsc.bscv.BoSCoVicino;
+import ftbsc.bscv.ICommons;
import net.minecraft.command.CommandSource;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
@@ -13,7 +14,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
import ftbsc.bscv.module.HudModule;
import ftbsc.bscv.module.Module;
-public class ActiveModules extends HudModule {
+public class ActiveModules extends HudModule implements ICommons {
public ActiveModules(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
super("ActiveModules", builder, dispatcher);
@@ -32,7 +33,7 @@ public class ActiveModules extends HudModule {
.y(this.y.get() + offset)
.scale(this.scale.get())
.render(event.getMatrixStack(), event.getWindow());
- offset += BoSCoVicino.minecraft.font.lineHeight;
+ offset += MC.font.lineHeight;
}
}
}
diff --git a/src/main/java/ftbsc/bscv/module/hud/Coordinates.java b/src/main/java/ftbsc/bscv/module/hud/Coordinates.java
index 75c88b9..b4e972c 100644
--- a/src/main/java/ftbsc/bscv/module/hud/Coordinates.java
+++ b/src/main/java/ftbsc/bscv/module/hud/Coordinates.java
@@ -2,7 +2,6 @@ package ftbsc.bscv.module.hud;
import com.mojang.brigadier.CommandDispatcher;
-import net.minecraft.client.Minecraft;
import net.minecraft.command.CommandSource;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
@@ -11,10 +10,10 @@ import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import static ftbsc.bscv.tools.Text.TextBuilder;
-import ftbsc.bscv.BoSCoVicino;
+import ftbsc.bscv.ICommons;
import ftbsc.bscv.module.HudModule;
-public class Coordinates extends HudModule {
+public class Coordinates extends HudModule implements ICommons {
public Coordinates(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
super("Coordinates", builder, dispatcher);
@@ -22,9 +21,8 @@ public class Coordinates extends HudModule {
@SubscribeEvent
public void onRenderOverlay(RenderGameOverlayEvent event) {
- Minecraft mc = BoSCoVicino.minecraft;
- if (event.getType() == ElementType.TEXT && mc.player != null) {
- Vector3d position = mc.player.position();
+ if (event.getType() == ElementType.TEXT && MC.player != null) {
+ Vector3d position = MC.player.position();
TextBuilder()
.txt(String.format("[ X %.1f | %.1f Z ] %.1f Y", position.x(), position.z(), position.y()))
.anchor(this.anchor.get())
diff --git a/src/main/java/ftbsc/bscv/module/hud/EntityList.java b/src/main/java/ftbsc/bscv/module/hud/EntityList.java
index ab6707e..acb45b3 100644
--- a/src/main/java/ftbsc/bscv/module/hud/EntityList.java
+++ b/src/main/java/ftbsc/bscv/module/hud/EntityList.java
@@ -9,7 +9,7 @@ import java.util.stream.Collectors;
import com.mojang.brigadier.CommandDispatcher;
-import ftbsc.bscv.BoSCoVicino;
+import ftbsc.bscv.ICommons;
import ftbsc.bscv.module.HudModule;
import net.minecraft.command.CommandSource;
import net.minecraft.entity.Entity;
@@ -18,7 +18,7 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.eventbus.api.SubscribeEvent;
-public class EntityList extends HudModule {
+public class EntityList extends HudModule implements ICommons {
public EntityList(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
super("EntityList", builder, dispatcher);
@@ -29,7 +29,7 @@ public class EntityList extends HudModule {
if (event.getType() != ElementType.TEXT) return;
List<String> entities = new ArrayList<>();
- for (Entity e : BoSCoVicino.minecraft.level.entitiesForRendering()) {
+ for (Entity e : MC.level.entitiesForRendering()) {
// TODO do some filtering here?
entities.add(e.getName().getString());
}
@@ -53,7 +53,7 @@ public class EntityList extends HudModule {
.y(this.y.get() + offset)
.scale(this.scale.get())
.render(event.getMatrixStack(), event.getWindow());
- offset += BoSCoVicino.minecraft.font.lineHeight;
+ offset += MC.font.lineHeight;
}
}
}
diff --git a/src/main/java/ftbsc/bscv/module/hud/InfoDisplay.java b/src/main/java/ftbsc/bscv/module/hud/InfoDisplay.java
index 3a6e6eb..dd7103f 100644
--- a/src/main/java/ftbsc/bscv/module/hud/InfoDisplay.java
+++ b/src/main/java/ftbsc/bscv/module/hud/InfoDisplay.java
@@ -8,6 +8,7 @@ import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.BoolArgumentType;
import ftbsc.bscv.BoSCoVicino;
+import ftbsc.bscv.ICommons;
import ftbsc.bscv.module.HudModule;
import net.minecraft.client.Minecraft;
import net.minecraft.command.CommandSource;
@@ -20,7 +21,7 @@ import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
-public class InfoDisplay extends HudModule {
+public class InfoDisplay extends HudModule implements ICommons {
private Vector3d last_position = new Vector3d(0.0, 0.0, 0.0);
@@ -68,10 +69,10 @@ public class InfoDisplay extends HudModule {
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
if (!this.speed.get()) return;
- if (BoSCoVicino.minecraft.player != null) {
+ if (MC.player != null) {
this.instant_speed =
- this.last_position.distanceTo(BoSCoVicino.minecraft.player.position());
- this.last_position = BoSCoVicino.minecraft.player.position();
+ this.last_position.distanceTo(MC.player.position());
+ this.last_position = MC.player.position();
} else {
this.instant_speed = 0.0;
}
@@ -90,7 +91,7 @@ public class InfoDisplay extends HudModule {
public void onRenderOverlay(RenderGameOverlayEvent event) {
if (event.getType() != ElementType.TEXT) return;
- Minecraft mc = BoSCoVicino.minecraft;
+ Minecraft mc = MC;
int offset = 0;
double scale = this.scale.get();
if (this.logo.get()) {
diff --git a/src/main/java/ftbsc/bscv/module/motion/VanillaFlight.java b/src/main/java/ftbsc/bscv/module/motion/VanillaFlight.java
index 3e99f7d..f29699b 100644
--- a/src/main/java/ftbsc/bscv/module/motion/VanillaFlight.java
+++ b/src/main/java/ftbsc/bscv/module/motion/VanillaFlight.java
@@ -6,6 +6,7 @@ import com.mojang.brigadier.arguments.DoubleArgumentType;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import ftbsc.bscv.BoSCoVicino;
+import ftbsc.bscv.ICommons;
import ftbsc.bscv.module.QuickModule;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.command.CommandSource;
@@ -13,7 +14,7 @@ import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
-public class VanillaFlight extends QuickModule {
+public class VanillaFlight extends QuickModule implements ICommons {
public final ForgeConfigSpec.ConfigValue<Boolean> force;
public final ForgeConfigSpec.ConfigValue<Double> speed;
@@ -64,7 +65,7 @@ public class VanillaFlight extends QuickModule {
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
- ClientPlayerEntity player = BoSCoVicino.minecraft.player;
+ ClientPlayerEntity player = MC.player;
if (player == null) return;
player.abilities.mayfly = true;
@@ -87,16 +88,16 @@ public class VanillaFlight extends QuickModule {
@Override
protected void onEnabled() {
- if (BoSCoVicino.minecraft.player != null) {
- this.couldFlyBefore = BoSCoVicino.minecraft.player.abilities.mayfly;
- this.flyingSpeedBefore = BoSCoVicino.minecraft.player.abilities.getFlyingSpeed();
+ if (MC.player != null) {
+ this.couldFlyBefore = MC.player.abilities.mayfly;
+ this.flyingSpeedBefore = MC.player.abilities.getFlyingSpeed();
BoSCoVicino.log(String.format("Flying speed before = %f", this.flyingSpeedBefore));
}
}
@Override
protected void onDisabled() {
- ClientPlayerEntity player = BoSCoVicino.minecraft.player;
+ ClientPlayerEntity player = MC.player;
if (player != null) {
player.abilities.mayfly = this.couldFlyBefore;
player.abilities.setFlyingSpeed(this.flyingSpeedBefore);
diff --git a/src/main/java/ftbsc/bscv/module/self/FastInteract.java b/src/main/java/ftbsc/bscv/module/self/FastInteract.java
index 2806ba8..15cba96 100644
--- a/src/main/java/ftbsc/bscv/module/self/FastInteract.java
+++ b/src/main/java/ftbsc/bscv/module/self/FastInteract.java
@@ -12,9 +12,9 @@ import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import ftbsc.bscv.module.QuickModule;
-import ftbsc.bscv.BoSCoVicino;
+import ftbsc.bscv.ICommons;
-public class FastInteract extends QuickModule {
+public class FastInteract extends QuickModule implements ICommons {
Field delayField;
@@ -25,7 +25,7 @@ public class FastInteract extends QuickModule {
@Override
protected void onEnabled() {
try {
- delayField = BoSCoVicino.minecraft.getClass().getDeclaredField("field_71467_ac");
+ delayField = MC.getClass().getDeclaredField("field_71467_ac");
delayField.setAccessible(true);
} catch (NoSuchFieldException e) {
log("! failed accessing delay field");
@@ -35,9 +35,9 @@ public class FastInteract extends QuickModule {
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
- if (BoSCoVicino.minecraft == null) return;
+ if (MC == null) return;
try {
- this.delayField.set(BoSCoVicino.minecraft, 0);
+ this.delayField.set(MC, 0);
} catch (IllegalAccessException e) {
log("! failed accessing delay field");
this.disable();
diff --git a/src/main/java/ftbsc/bscv/module/vision/Fullbright.java b/src/main/java/ftbsc/bscv/module/vision/Fullbright.java
index c35748e..21abca7 100644
--- a/src/main/java/ftbsc/bscv/module/vision/Fullbright.java
+++ b/src/main/java/ftbsc/bscv/module/vision/Fullbright.java
@@ -13,9 +13,9 @@ import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import ftbsc.bscv.module.QuickModule;
-import ftbsc.bscv.BoSCoVicino;
+import ftbsc.bscv.ICommons;
-public class Fullbright extends QuickModule {
+public class Fullbright extends QuickModule implements ICommons {
private final ForgeConfigSpec.ConfigValue<String> mode;
@@ -31,17 +31,17 @@ public class Fullbright extends QuickModule {
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
- if (BoSCoVicino.minecraft == null) return;
- if (BoSCoVicino.minecraft.player == null) return;
+ if (MC == null) return;
+ if (MC.player == null) return;
if (this.mode.get().equals("potion")) {
- BoSCoVicino.minecraft.player.addEffect(new EffectInstance(Effect.byId(16), 5204));
+ MC.player.addEffect(new EffectInstance(Effect.byId(16), 5204));
}
}
@Override
protected void onDisabled() {
if (this.mode.get().equals("potion")) {
- BoSCoVicino.minecraft.player.removeEffect(Effect.byId(16));
+ MC.player.removeEffect(Effect.byId(16));
}
}
}
diff --git a/src/main/java/ftbsc/bscv/tools/Anchor.java b/src/main/java/ftbsc/bscv/tools/Anchor.java
index 29e4da7..c1d94d9 100644
--- a/src/main/java/ftbsc/bscv/tools/Anchor.java
+++ b/src/main/java/ftbsc/bscv/tools/Anchor.java
@@ -1,11 +1,11 @@
package ftbsc.bscv.tools;
-import ftbsc.bscv.BoSCoVicino;
+import ftbsc.bscv.ICommons;
import net.minecraft.client.MainWindow;
import net.minecraft.client.gui.screen.ChatScreen;
import net.minecraft.util.math.vector.Vector2f;
-public enum Anchor {
+public enum Anchor implements ICommons {
TOPLEFT("TOPLEFT"), TOPCENTER("TOPCENTER"), TOPRIGHT("TOPRIGHT"),
MIDDLELEFT("MIDDLELEFT"), MIDDLECENTER("MIDDLECENTER"), MIDDLERIGHT("MIDDLERIGHT"),
@@ -19,7 +19,7 @@ public enum Anchor {
case BOTTOMLEFT:
case BOTTOMCENTER:
case BOTTOMRIGHT:
- if (BoSCoVicino.minecraft.screen instanceof ChatScreen) {
+ if (MC.screen instanceof ChatScreen) {
offset = 15;
}
default:
diff --git a/src/main/java/ftbsc/bscv/tools/Text.java b/src/main/java/ftbsc/bscv/tools/Text.java
index c1fa746..36abaae 100644
--- a/src/main/java/ftbsc/bscv/tools/Text.java
+++ b/src/main/java/ftbsc/bscv/tools/Text.java
@@ -3,7 +3,7 @@ package ftbsc.bscv.tools;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
-import ftbsc.bscv.BoSCoVicino;
+import ftbsc.bscv.ICommons;
import net.minecraft.client.MainWindow;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.util.math.vector.Vector2f;
@@ -13,7 +13,7 @@ import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.Style;
-public final class Text {
+public final class Text implements ICommons {
String text;
Anchor anchor;
Style style;
@@ -65,7 +65,7 @@ public final class Text {
}
public void render(MatrixStack stack, MainWindow window) {
- FontRenderer font = BoSCoVicino.minecraft.font;
+ FontRenderer font = MC.font;
ITextComponent text = new StringTextComponent(this.text).setStyle(this.style);
Vector2f abs_coords = this.anchor.translate(
new Vector2f(this.x, this.y),