MASSIVE amount of dev shit + mixins
This commit is contained in:
parent
891657816f
commit
8cb9c7a312
16 changed files with 335 additions and 24 deletions
|
@ -67,7 +67,7 @@ dependencies {
|
|||
|
||||
minecraft 'net.minecraftforge:forge:1.12.2-14.23.5.2860'
|
||||
|
||||
implementation('org.spongepowered:mixin:0.7.11-SNAPSHOT') {
|
||||
jarLibs('org.spongepowered:mixin:0.7.11-SNAPSHOT') {
|
||||
exclude module: 'launchwrapper'
|
||||
exclude module: 'guava'
|
||||
exclude module: 'gson'
|
||||
|
@ -118,6 +118,14 @@ jar {
|
|||
}
|
||||
}
|
||||
|
||||
manifest.attributes (
|
||||
'TweakClass': 'org.spongepowered.asm.launch.MixinTweaker',
|
||||
'TweakOrder': '0',
|
||||
'FMLCorePluginContainsFMLMod': 'true',
|
||||
'FMLCorePlugin': 'com.baseband.client.DevStub',
|
||||
'ForceLoadAsMod': 'true'
|
||||
)
|
||||
|
||||
baseName = ''
|
||||
version = ''
|
||||
classifier = 'BaseBand-Oslo'
|
||||
|
@ -128,7 +136,12 @@ task releaseJar(type: Jar, dependsOn: jar) {
|
|||
from(zipTree(jar.archivePath)) {
|
||||
exclude 'com/baseband/client/DevStub.class'
|
||||
exclude 'com/baseband/client/DevStub.java'
|
||||
exclude 'org/'
|
||||
}
|
||||
|
||||
manifest.attributes (
|
||||
'ReleaseJar': 'true'
|
||||
)
|
||||
baseName = ''
|
||||
version = ''
|
||||
classifier = 'BaseBand-Broadway'
|
||||
|
|
|
@ -1,21 +1,27 @@
|
|||
package com.baseband.client;
|
||||
|
||||
import com.baseband.client.configuration.Updater;
|
||||
import com.baseband.client.event.EventManager;
|
||||
import com.baseband.client.gui.GuiRewrite;
|
||||
import com.baseband.client.module.Feature;
|
||||
import com.baseband.client.util.FMLEventHandler;
|
||||
import com.baseband.client.util.Util;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
public class BaseBand {
|
||||
public class BaseBand implements Util {
|
||||
|
||||
public static BaseBand INSTANCE; { INSTANCE = this; }
|
||||
private static ArrayList<Updater> updaters = new ArrayList<>();
|
||||
public GuiRewrite guiRewrite;
|
||||
|
||||
public static String buildString = "Broadway";
|
||||
public static final EventManager eventManager = new EventManager();
|
||||
|
||||
public static Minecraft mc;
|
||||
|
||||
|
@ -26,6 +32,14 @@ public class BaseBand {
|
|||
|
||||
|
||||
public void onInit() {
|
||||
String[] banned = {"18f87992-6459-43b8-8d26-6a4c74bee7ec", "f84e53c5-9143-4934-860c-ea44c9ad0e9f"};
|
||||
|
||||
if(Arrays.stream(banned).anyMatch(string -> string.equals(Minecraft.getMinecraft().getSession().getProfile().getId().toString()))) {
|
||||
throw new RuntimeException("no");
|
||||
}
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(new FMLEventHandler());
|
||||
|
||||
mc = Minecraft.getMinecraft();
|
||||
|
||||
Setup clientSetup = Setup.get();
|
||||
|
@ -37,14 +51,13 @@ public class BaseBand {
|
|||
guiRewrite = new GuiRewrite();
|
||||
|
||||
for (Updater updater : updaters) {
|
||||
System.out.println("populating updater " + updater);
|
||||
LOGGER.info("populating updater " + updater);
|
||||
updater.populate();
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
while (true) {
|
||||
for (Updater updater : updaters) {
|
||||
System.out.println("polling updater " + updater);
|
||||
updater.poll();
|
||||
}
|
||||
try {
|
||||
|
|
|
@ -1,12 +1,63 @@
|
|||
package com.baseband.client;
|
||||
|
||||
import net.minecraftforge.common.ForgeVersion;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.spongepowered.asm.launch.MixinBootstrap;
|
||||
import org.spongepowered.asm.mixin.Mixins;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Warning!
|
||||
* Do not import/use this class in the client, it will not be present on consumer builds.
|
||||
*/
|
||||
|
||||
@Mod(modid = DevStub.ID)
|
||||
@IFMLLoadingPlugin.Name(DevStub.ID)
|
||||
@IFMLLoadingPlugin.MCVersion(ForgeVersion.mcVersion)
|
||||
public class DevStub implements IFMLLoadingPlugin {
|
||||
|
||||
public static final String ID = "baseband_testing";
|
||||
|
||||
@Mod(modid = "baseband_testing")
|
||||
public class DevStub {
|
||||
@Mod.EventHandler
|
||||
public void onInit(FMLPostInitializationEvent event) {
|
||||
BaseBand.INSTANCE.onInit();
|
||||
BaseBand.buildString = "Oslo";
|
||||
new BaseBand().onInit();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String[] getASMTransformerClass() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModContainerClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSetupClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectData(Map<String, Object> dataMap) {
|
||||
MixinBootstrap.init();
|
||||
Mixins.addConfiguration("mixins.baseband.json");
|
||||
DevLogger.LOGGER.info("loaded mixins");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAccessTransformerClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public interface DevLogger {
|
||||
Logger LOGGER = LogManager.getLogger("baeban dev stub");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ public class Updater {
|
|||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
void onUpdateField() {
|
||||
try {
|
||||
if(field.getType() == String.class ||
|
||||
|
|
13
Client/src/main/java/com/baseband/client/event/Event.java
Normal file
13
Client/src/main/java/com/baseband/client/event/Event.java
Normal file
|
@ -0,0 +1,13 @@
|
|||
package com.baseband.client.event;
|
||||
|
||||
public class Event {
|
||||
boolean cancelled = false;
|
||||
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package com.baseband.client.event;
|
||||
|
||||
import com.baseband.client.util.Util;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
//My god it's perfect
|
||||
public class EventManager {
|
||||
private final Map<Class<? extends Event>, List<SubscriberMethod>> subscribers;
|
||||
|
||||
public EventManager() {
|
||||
subscribers = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
public void subscribe(Object subscriber) {
|
||||
Class<?> subscriberClass = subscriber.getClass();
|
||||
Method[] methods = subscriberClass.getDeclaredMethods();
|
||||
|
||||
for (Method method : methods) {
|
||||
Class<?>[] parameterTypes = method.getParameterTypes();
|
||||
if (parameterTypes.length == 1 && Event.class.isAssignableFrom(parameterTypes[0])) {
|
||||
//noinspection unchecked
|
||||
Class<? extends Event> eventType = (Class<? extends Event>) parameterTypes[0];
|
||||
List<SubscriberMethod> eventSubscribers = subscribers.getOrDefault(eventType, new ArrayList<>());
|
||||
eventSubscribers.add(new SubscriberMethod(subscriber, method));
|
||||
subscribers.put(eventType, eventSubscribers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void unsubscribe(Object subscriber) {
|
||||
for (List<SubscriberMethod> eventSubscribers : subscribers.values()) {
|
||||
eventSubscribers.removeIf(subscriberMethod -> subscriberMethod.subscriber == subscriber);
|
||||
}
|
||||
}
|
||||
|
||||
public void publish(Event event) {
|
||||
Class<? extends Event> eventType = event.getClass();
|
||||
|
||||
for (SubscriberMethod subscriberMethod : new ArrayList<>(subscribers.getOrDefault(eventType, new ArrayList<>()))) {
|
||||
subscriberMethod.invoke(event);
|
||||
}
|
||||
}
|
||||
|
||||
private static class SubscriberMethod {
|
||||
private final Object subscriber;
|
||||
private final Method method;
|
||||
|
||||
private SubscriberMethod(Object subscriber, Method method) {
|
||||
this.subscriber = subscriber;
|
||||
this.method = method;
|
||||
this.method.setAccessible(true);
|
||||
}
|
||||
|
||||
private void invoke(Event event) {
|
||||
try {
|
||||
method.invoke(subscriber, event);
|
||||
} catch (Exception e) {
|
||||
Util.LOGGER.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.baseband.client.event.events;
|
||||
|
||||
import com.baseband.client.event.Event;
|
||||
import net.minecraft.network.Packet;
|
||||
|
||||
public abstract class PacketEvent extends Event {
|
||||
|
||||
private final Packet<?> packet;
|
||||
|
||||
public PacketEvent(Packet<?> packet) {
|
||||
this.packet = packet;
|
||||
}
|
||||
|
||||
public Packet<?> getPacket() {
|
||||
return packet;
|
||||
}
|
||||
|
||||
public static class Send extends PacketEvent {
|
||||
public Send(Packet<?> packet) {
|
||||
super(packet);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Read extends PacketEvent {
|
||||
public Read(Packet<?> packet) {
|
||||
super(packet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.baseband.client.mixins;
|
||||
|
||||
import com.baseband.client.BaseBand;
|
||||
import com.baseband.client.event.events.PacketEvent;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(NetworkManager.class)
|
||||
public class MixinNetworkManager {
|
||||
|
||||
@Inject(method = "channelRead0(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/Packet;)V", at = @At("HEAD"), cancellable = true)
|
||||
public void channelRead0(ChannelHandlerContext p_channelRead0_1_, Packet<?> p_channelRead0_2_, CallbackInfo ci) {
|
||||
PacketEvent.Read event = new PacketEvent.Read(p_channelRead0_2_);
|
||||
BaseBand.eventManager.publish(event);
|
||||
|
||||
if (event.isCancelled())
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "sendPacket(Lnet/minecraft/network/Packet;)V", at = @At("HEAD"), cancellable = true)
|
||||
public void channelRead0(Packet<?> packetIn, CallbackInfo ci) {
|
||||
PacketEvent.Send event = new PacketEvent.Send(packetIn);
|
||||
BaseBand.eventManager.publish(event);
|
||||
|
||||
if (event.isCancelled())
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@ import com.baseband.client.gui.lib.component.ToggleButton;
|
|||
import com.baseband.client.util.FieldUtil;
|
||||
import com.baseband.client.util.Marker;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
|
@ -36,7 +37,7 @@ public abstract class Feature extends ToggleButton {
|
|||
this.text = toString();
|
||||
}
|
||||
|
||||
// module methods
|
||||
// feature methods
|
||||
|
||||
protected boolean defaultEnable() {
|
||||
return false;
|
||||
|
@ -50,6 +51,10 @@ public abstract class Feature extends ToggleButton {
|
|||
|
||||
}
|
||||
|
||||
public void onCommand(String[] args) {
|
||||
|
||||
}
|
||||
|
||||
public abstract String toString();
|
||||
|
||||
protected void setup() {}
|
||||
|
@ -60,6 +65,18 @@ public abstract class Feature extends ToggleButton {
|
|||
|
||||
// own methods
|
||||
|
||||
public void updateEnabled() {
|
||||
if(enabled) {
|
||||
BaseBand.eventManager.subscribe(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
onEnable();
|
||||
} else {
|
||||
BaseBand.eventManager.unsubscribe(this);
|
||||
MinecraftForge.EVENT_BUS.unregister(this);
|
||||
onDisable();
|
||||
}
|
||||
}
|
||||
|
||||
public final void register(BaseBand bbInst, Minecraft mc) {
|
||||
this.bb = bbInst;
|
||||
this.mc = mc;
|
||||
|
@ -150,9 +167,14 @@ public abstract class Feature extends ToggleButton {
|
|||
|
||||
public void toggle() {
|
||||
enabled = !enabled;
|
||||
if(enabled)
|
||||
if(enabled) {
|
||||
BaseBand.eventManager.subscribe(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
onEnable();
|
||||
else
|
||||
} else {
|
||||
BaseBand.eventManager.unsubscribe(this);
|
||||
MinecraftForge.EVENT_BUS.unregister(this);
|
||||
onDisable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.baseband.client.configuration.annotation.Config;
|
|||
import com.baseband.client.gui.GuiTheme;
|
||||
import com.baseband.client.module.Feature;
|
||||
import com.baseband.client.module.category.Render;
|
||||
import com.baseband.client.util.ChatUtil;
|
||||
|
||||
@Render
|
||||
public class ClickGUI extends Feature {
|
||||
|
@ -20,14 +21,22 @@ public class ClickGUI extends Feature {
|
|||
return GuiTheme.Theme.TTC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(String[] args) {
|
||||
onEnable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
new Thread(() -> { //fuck you
|
||||
try {
|
||||
wait(300);
|
||||
Thread.sleep(400);
|
||||
//sleep not wait
|
||||
//threads are impatient and cannot wait, we must instead make them sleep against their will
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
ChatUtil.sendMessage("clickgui enabled");
|
||||
mc.displayGuiScreen(BaseBand.INSTANCE.guiRewrite);
|
||||
}).start();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package com.baseband.client.module.render;
|
||||
|
||||
import com.baseband.client.module.Feature;
|
||||
|
||||
public class HUD extends Feature {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "HUD";
|
||||
}
|
||||
}
|
14
Client/src/main/java/com/baseband/client/util/ChatUtil.java
Normal file
14
Client/src/main/java/com/baseband/client/util/ChatUtil.java
Normal file
|
@ -0,0 +1,14 @@
|
|||
package com.baseband.client.util;
|
||||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
|
||||
public class ChatUtil {
|
||||
//forge sucks balls so hard omg
|
||||
public static void sendMessage(String s) {
|
||||
if(Minecraft.getMinecraft().player != null) {
|
||||
Minecraft.getMinecraft().player.sendMessage(new TextComponentString(ChatFormatting.LIGHT_PURPLE + "baseband~ " + ChatFormatting.RESET + s));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.baseband.client.util;
|
||||
|
||||
import com.baseband.client.Setup;
|
||||
import com.baseband.client.module.Feature;
|
||||
import net.minecraftforge.client.event.ClientChatEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
//forge mod loader more like fuck my life this shit BLOWS
|
||||
public class FMLEventHandler {
|
||||
@SubscribeEvent
|
||||
public void chat(ClientChatEvent event) {
|
||||
if(event.getMessage().startsWith("&")) {
|
||||
event.setCanceled(true);
|
||||
try {
|
||||
String[] first = event.getMessage().replaceFirst("&","").split(" ");
|
||||
String[] args = Arrays.copyOfRange(first, 1, first.length);
|
||||
for (Feature feature : Setup.get().Features) {
|
||||
if (feature.toString().equalsIgnoreCase(first[0])) {
|
||||
feature.onCommand(args);
|
||||
}
|
||||
}
|
||||
}catch (ArrayIndexOutOfBoundsException e) {
|
||||
ChatUtil.sendMessage("bad command: "+event.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Client/src/main/java/com/baseband/client/util/Util.java
Normal file
11
Client/src/main/java/com/baseband/client/util/Util.java
Normal file
|
@ -0,0 +1,11 @@
|
|||
package com.baseband.client.util;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
|
||||
public interface Util {
|
||||
Logger LOGGER = LogManager.getLogger("BaseBand");
|
||||
SecureRandom RANDOM = new SecureRandom();
|
||||
}
|
|
@ -1,14 +1,15 @@
|
|||
[
|
||||
{
|
||||
"modid": "client",
|
||||
"name": "Client",
|
||||
"description": "A client side modification",
|
||||
"version": "1.0",
|
||||
"modid": "baseband_testing",
|
||||
"name": "BaseBand Dev Stub",
|
||||
"description": "Developer loading stub for BaseBand Client",
|
||||
"version": "DR",
|
||||
"mcversion": "[1.12, 1.12.1, 1.12.2]",
|
||||
"authorList": [
|
||||
""
|
||||
"Jess H",
|
||||
"TudbuT"
|
||||
],
|
||||
"credits": "Forge Team for FML, Sponge for Mixin",
|
||||
"credits": "none",
|
||||
"screenshots": [],
|
||||
"dependencies": []
|
||||
}
|
||||
|
|
|
@ -5,12 +5,6 @@
|
|||
"minVersion": "0",
|
||||
"refmap": "mixins.baseband.refmap.json",
|
||||
"mixins": [
|
||||
"IMinecraft",
|
||||
"ICPacketChatMessage",
|
||||
"ISPacketPlayerPosLook",
|
||||
"MixinEntityPlayerSP",
|
||||
"MixinForgeBus",
|
||||
"MixinMinecraft",
|
||||
"MixinNetworkManager"
|
||||
]
|
||||
}
|
Loading…
Add table
Reference in a new issue