diff --git a/Client/src/main/java/de/com/baseband/client/BaseBand.java b/Client/src/main/java/de/com/baseband/client/BaseBand.java index bd656e8..b3895e8 100644 --- a/Client/src/main/java/de/com/baseband/client/BaseBand.java +++ b/Client/src/main/java/de/com/baseband/client/BaseBand.java @@ -1,10 +1,10 @@ package de.com.baseband.client; import de.com.baseband.client.event.Event; -import de.com.baseband.client.event.EventManager; -import de.com.baseband.client.event.FMLEventHandler; +import de.com.baseband.client.event.EventBus; +import de.com.baseband.client.event.StaticEventHandler; import de.com.baseband.client.event.remote.RemoteEvent; -import de.com.baseband.client.event.remote.RemoteEventManager; +import de.com.baseband.client.event.remote.RemoteEventBus; import de.com.baseband.client.feature.Feature; import de.com.baseband.client.feature.Features; import de.com.baseband.client.feature.modules.client.Client; @@ -31,9 +31,9 @@ public class BaseBand { public static final SecureRandom RANDOM = new SecureRandom(); public static String buildString = LoadHandler.data.getBoolean("release-branch") ? "Broadway" : "Dark Side of the Moon"; - public static final EventManager eventManager = new EventManager(LOGGER::error); - public static final RemoteEventManager remoteEventManager = new RemoteEventManager(); - public static final FMLEventHandler fmlEventHandlerInstance = new FMLEventHandler(); + public static final EventBus EVENT_BUS = new EventBus(LOGGER::error); + public static final RemoteEventBus REMOTE_EVENT_BUS = new RemoteEventBus(); + public static final StaticEventHandler STATIC_EVENT_HANDLER_INSTANCE = new StaticEventHandler(); public static boolean enabled = true; public static boolean finishedDisabling = false; public static Minecraft mc; @@ -55,10 +55,12 @@ public class BaseBand { shutdown(); } - MinecraftForge.EVENT_BUS.register(fmlEventHandlerInstance); - mc = Minecraft.getMinecraft(); + MinecraftForge.EVENT_BUS.register(STATIC_EVENT_HANDLER_INSTANCE); + + EVENT_BUS.subscribe(STATIC_EVENT_HANDLER_INSTANCE); + mc.gameSettings.autoJump = false; //fuck autojump, disable it on startup LOGGER.info("Generating features..."); @@ -99,9 +101,9 @@ public class BaseBand { public static T publish(T event) { if(event instanceof RemoteEvent) - remoteEventManager.publish((RemoteEvent) event); + REMOTE_EVENT_BUS.publish((RemoteEvent) event); else - eventManager.publish(event); + EVENT_BUS.publish(event); return event; } diff --git a/Client/src/main/java/de/com/baseband/client/Setup.java b/Client/src/main/java/de/com/baseband/client/Setup.java index d08567c..4fc903e 100644 --- a/Client/src/main/java/de/com/baseband/client/Setup.java +++ b/Client/src/main/java/de/com/baseband/client/Setup.java @@ -55,12 +55,12 @@ public class Setup { new Help(), new HUD(), //new HUD.ShowTPS(), - new ISeeYou(), new MidClick(), new Nametags(), new NoRender(), new NoSlowDown(), new Ping(), + new PvpInfo(), new RenderFun(), new Say(), new SeedOverlay(), diff --git a/Client/src/main/java/de/com/baseband/client/event/EventManager.java b/Client/src/main/java/de/com/baseband/client/event/EventBus.java similarity index 95% rename from Client/src/main/java/de/com/baseband/client/event/EventManager.java rename to Client/src/main/java/de/com/baseband/client/event/EventBus.java index 876a840..fd2963c 100644 --- a/Client/src/main/java/de/com/baseband/client/event/EventManager.java +++ b/Client/src/main/java/de/com/baseband/client/event/EventBus.java @@ -6,7 +6,7 @@ import java.util.concurrent.CopyOnWriteArrayList; import java.util.function.Consumer; //My god it's perfect -public class EventManager { +public class EventBus { private final List subscriberMethods; @@ -14,11 +14,11 @@ public class EventManager { private Consumer crashHandler = t -> {throw new RuntimeException(t);}; - public EventManager() { + public EventBus() { subscriberMethods = new CopyOnWriteArrayList<>(); } - public EventManager(Consumer crashHandler) { + public EventBus(Consumer crashHandler) { this.crashHandler = crashHandler; subscriberMethods = new CopyOnWriteArrayList<>(); } diff --git a/Client/src/main/java/de/com/baseband/client/event/FMLEventHandler.java b/Client/src/main/java/de/com/baseband/client/event/StaticEventHandler.java similarity index 75% rename from Client/src/main/java/de/com/baseband/client/event/FMLEventHandler.java rename to Client/src/main/java/de/com/baseband/client/event/StaticEventHandler.java index 7d5ac6a..d9d67e7 100644 --- a/Client/src/main/java/de/com/baseband/client/event/FMLEventHandler.java +++ b/Client/src/main/java/de/com/baseband/client/event/StaticEventHandler.java @@ -2,12 +2,16 @@ package de.com.baseband.client.event; import de.com.baseband.client.BaseBand; import de.com.baseband.client.Setup; +import de.com.baseband.client.event.events.PacketEvent; import de.com.baseband.client.event.events.PlayerDestroyEvent; +import de.com.baseband.client.event.events.TotemPopEvent; import de.com.baseband.client.feature.Feature; import de.com.baseband.client.feature.Features; import de.com.baseband.client.feature.modules.client.Client; import de.com.baseband.client.util.interact.Chat; import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.entity.Entity; +import net.minecraft.network.play.server.SPacketEntityStatus; import net.minecraftforge.client.event.ClientChatEvent; import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @@ -15,8 +19,10 @@ import net.minecraftforge.fml.common.gameevent.TickEvent; import java.util.Arrays; +import static de.com.baseband.client.BaseBand.mc; + //forge mod loader more like fuck my life this shit BLOWS -public class FMLEventHandler { +public class StaticEventHandler { Setup setup = Setup.get(); @@ -44,6 +50,16 @@ public class FMLEventHandler { } } + public void onPacketIn(PacketEvent.Receive event) { + if (event.getPacket() instanceof SPacketEntityStatus) { + SPacketEntityStatus packet = (SPacketEntityStatus) event.getPacket(); + if (packet.getOpCode() == 35) { + Entity entity = packet.getEntity(mc.world); + BaseBand.EVENT_BUS.publish(new TotemPopEvent(entity)); + } + } + } + @SubscribeEvent public void render(RenderWorldLastEvent event) { KeyManager.updateKeyBinds(); @@ -52,8 +68,8 @@ public class FMLEventHandler { EntityPlayerSP playerLastTick = null; @SubscribeEvent public void tick(TickEvent.ClientTickEvent event) { - BaseBand.remoteEventManager.onTick(); - if(BaseBand.mc.world == null || BaseBand.mc.player == null) { + BaseBand.REMOTE_EVENT_BUS.onTick(); + if(mc.world == null || mc.player == null) { if(playerLastTick != null) { BaseBand.publish(new PlayerDestroyEvent(playerLastTick)); } @@ -62,7 +78,7 @@ public class FMLEventHandler { } if(event.phase != TickEvent.Phase.END) return; - playerLastTick = BaseBand.mc.player; + playerLastTick = mc.player; KeyManager.updateKeyBinds(); for(Feature feature : Features.features) { feature.onEveryTick(); diff --git a/Client/src/main/java/de/com/baseband/client/event/events/SelectEvent.java b/Client/src/main/java/de/com/baseband/client/event/events/SelectEvent.java index 28bd27a..7d6cbef 100644 --- a/Client/src/main/java/de/com/baseband/client/event/events/SelectEvent.java +++ b/Client/src/main/java/de/com/baseband/client/event/events/SelectEvent.java @@ -2,7 +2,7 @@ package de.com.baseband.client.event.events; import de.com.baseband.client.BaseBand; import de.com.baseband.client.event.remote.RemoteEvent; -import de.com.baseband.client.event.remote.RemoteEventManager; +import de.com.baseband.client.event.remote.RemoteEventBus; import de.com.baseband.client.util.interact.BlockUtils; import de.com.baseband.client.util.type.Selection; import de.tudbut.obj.Save; @@ -20,8 +20,8 @@ public class SelectEvent extends RemoteEvent { public Selection getMySelection() { if(selection == null) return null; - if(BaseBand.remoteEventManager.isConnected()) { - RemoteEventManager manager = BaseBand.remoteEventManager; + if(BaseBand.REMOTE_EVENT_BUS.isConnected()) { + RemoteEventBus manager = BaseBand.REMOTE_EVENT_BUS; Selection[] splitSelection = BlockUtils.splitSelection1D(selection, manager.getPeers()); BaseBand.LOGGER.info("Split selection: {}", Arrays.toString(splitSelection)); if(splitSelection.length > manager.getID()) diff --git a/Client/src/main/java/de/com/baseband/client/event/events/TotemPopEvent.java b/Client/src/main/java/de/com/baseband/client/event/events/TotemPopEvent.java new file mode 100644 index 0000000..69455fd --- /dev/null +++ b/Client/src/main/java/de/com/baseband/client/event/events/TotemPopEvent.java @@ -0,0 +1,16 @@ +package de.com.baseband.client.event.events; + +import de.com.baseband.client.event.Event; +import net.minecraft.entity.Entity; + +public class TotemPopEvent extends Event { + public TotemPopEvent(Entity entity) { + this.entity = entity; + } + + Entity entity; + + public Entity getEntity() { + return entity; + } +} diff --git a/Client/src/main/java/de/com/baseband/client/event/remote/RemoteEventManager.java b/Client/src/main/java/de/com/baseband/client/event/remote/RemoteEventBus.java similarity index 98% rename from Client/src/main/java/de/com/baseband/client/event/remote/RemoteEventManager.java rename to Client/src/main/java/de/com/baseband/client/event/remote/RemoteEventBus.java index 7ccf5b6..f73f4ee 100644 --- a/Client/src/main/java/de/com/baseband/client/event/remote/RemoteEventManager.java +++ b/Client/src/main/java/de/com/baseband/client/event/remote/RemoteEventBus.java @@ -20,7 +20,7 @@ import java.util.ArrayList; import java.util.LinkedList; import java.util.Queue; -public class RemoteEventManager { +public class RemoteEventBus { private final de.com.baseband.client.Setup Setup = de.com.baseband.client.Setup.get(); public Socket head = null; @@ -208,7 +208,7 @@ public class RemoteEventManager { BaseBand.notify("[Remote] Peers connected: " + peers + "."); } else { - BaseBand.eventManager.publish(event); + BaseBand.EVENT_BUS.publish(event); } } if(!isConnected()) diff --git a/Client/src/main/java/de/com/baseband/client/feature/Feature.java b/Client/src/main/java/de/com/baseband/client/feature/Feature.java index db450b1..3fcd08e 100644 --- a/Client/src/main/java/de/com/baseband/client/feature/Feature.java +++ b/Client/src/main/java/de/com/baseband/client/feature/Feature.java @@ -86,12 +86,12 @@ public abstract class Feature extends ToggleButton implements SetCommand { public void updateEnabled() { if(enabled) { - BaseBand.eventManager.subscribe(this); + BaseBand.EVENT_BUS.subscribe(this); MinecraftForge.EVENT_BUS.register(this); BaseBand.notify("§l" + this + "§a enabled§r."); onEnable(); } else { - BaseBand.eventManager.unsubscribe(this); + BaseBand.EVENT_BUS.unsubscribe(this); MinecraftForge.EVENT_BUS.unregister(this); BaseBand.notify("§l" + this + "§c disabled§r."); onDisable(); diff --git a/Client/src/main/java/de/com/baseband/client/feature/modules/chat/ISeeYou.java b/Client/src/main/java/de/com/baseband/client/feature/modules/chat/ISeeYou.java deleted file mode 100644 index 6e38633..0000000 --- a/Client/src/main/java/de/com/baseband/client/feature/modules/chat/ISeeYou.java +++ /dev/null @@ -1,49 +0,0 @@ -package de.com.baseband.client.feature.modules.chat; - -import de.com.baseband.client.feature.Feature; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; - -import java.util.ArrayList; - -@de.com.baseband.client.feature.category.Chat -public class ISeeYou extends Feature { - - private final ArrayList names = new ArrayList<>(); - private final ArrayList newnames = new ArrayList<>(); - - @Override - public String toString() { - return "ISeeYou"; - } - - @Override - public void onTick() { - if(!notIngame()) { - localPlayerCheck(); - text = "ISeeYou" + (enabled ? " §7[" + names.size() +"]" : ""); - } - } - - public void localPlayerCheck() { - newnames.clear(); - try { - for (final Entity entity : mc.world.loadedEntityList) if (entity instanceof EntityPlayer && !entity.getName().equalsIgnoreCase(mc.player.getName())) newnames.add(entity.getName()); - if (!names.equals(newnames)) { - for (final String name : newnames) if (!names.contains(name)) de.com.baseband.client.util.interact.Chat.print("[ISeeYou] I locally see "+name); - for (final String name : names) if (!newnames.contains(name)) de.com.baseband.client.util.interact.Chat.print("[ISeeYou] I no longer locally see "+name); - names.clear(); - names.addAll(newnames); - } - } catch (Exception ignored) {} - } - - - - @Override - public void onDisable() { - text = "ISeeYou"; - names.clear(); - newnames.clear(); - } -} diff --git a/Client/src/main/java/de/com/baseband/client/feature/modules/chat/PvpInfo.java b/Client/src/main/java/de/com/baseband/client/feature/modules/chat/PvpInfo.java new file mode 100644 index 0000000..c6a6b7a --- /dev/null +++ b/Client/src/main/java/de/com/baseband/client/feature/modules/chat/PvpInfo.java @@ -0,0 +1,79 @@ +package de.com.baseband.client.feature.modules.chat; + +import de.com.baseband.client.BaseBand; +import de.com.baseband.client.event.events.TotemPopEvent; +import de.com.baseband.client.feature.Feature; +import de.com.baseband.client.registry.annotation.Config; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; + +import java.util.ArrayList; +import java.util.HashMap; + +@de.com.baseband.client.feature.category.Chat +public class PvpInfo extends Feature { + + private final ArrayList names = new ArrayList<>(); + private final ArrayList newnames = new ArrayList<>(); + private HashMap popList = new HashMap<>(); + + @Config("Totem Pops") + public boolean totemPops; + + @Config("Visual Range") + public boolean visualRange; + + @Override + public String toString() { + return "PvpInfo"; + } + + @Override + public void onTick() { + if(visualRange) { + newnames.clear(); + try { + for (final Entity entity : mc.world.loadedEntityList) if (entity instanceof EntityPlayer && !entity.getName().equalsIgnoreCase(mc.player.getName())) newnames.add(entity.getName()); + if (!names.equals(newnames)) { + for (final String name : newnames) if (!names.contains(name)) BaseBand.notify("[PvpInfo] "+name+" has entered Visual Range."); + for (final String name : names) if (!newnames.contains(name)) BaseBand.notify("[PvpInfo] "+name+" has left Visual Range."); + names.clear(); + names.addAll(newnames); + } + } catch (Exception ignored) {} + } + + if(totemPops) { + for (EntityPlayer player : mc.world.playerEntities) { + if (player.getHealth() <= 0) { + if (popList.containsKey(player.getName())) { + BaseBand.notify("[PvpInfo] " + player.getName() + " died after popping " + popList.get(player.getName()) + " totem(s)."); + popList.remove(player.getName(), popList.get(player.getName())); + } + } + } + } + } + + + public void totemPop(TotemPopEvent event) { + if(popList.get(event.getEntity().getName()) == null) { + popList.put(event.getEntity().getName(), 1); + BaseBand.notify("[PvpInfo] " + event.getEntity().getName() + " popped " + 1 + " totem."); + } else if(popList.get(event.getEntity().getName()) != null) { + int popCounter = popList.get(event.getEntity().getName()); + int newPopCounter = popCounter + 1; + popList.put(event.getEntity().getName(), newPopCounter); + BaseBand.notify("[PvpInfo] " + event.getEntity().getName() + " popped " + newPopCounter + " totems."); + } + } + + + @Override + public void onDisable() { + text = "PvpInfo"; + names.clear(); + newnames.clear(); + popList.clear(); + } +} diff --git a/Client/src/main/java/de/com/baseband/client/feature/modules/client/AltControl.java b/Client/src/main/java/de/com/baseband/client/feature/modules/client/AltControl.java index 07843ab..3d6b69d 100644 --- a/Client/src/main/java/de/com/baseband/client/feature/modules/client/AltControl.java +++ b/Client/src/main/java/de/com/baseband/client/feature/modules/client/AltControl.java @@ -34,14 +34,14 @@ public class AltControl extends Feature { public void onEnable() { notEnabled = false; - BaseBand.remoteEventManager.connect(ip); + BaseBand.REMOTE_EVENT_BUS.connect(ip); } @Trigger("Stop") @Gate(M_ENABLED) public void onDisable() { notEnabled = true; - BaseBand.remoteEventManager.end(); + BaseBand.REMOTE_EVENT_BUS.end(); } public void onRemoteSendChat(RemoteSendMessageEvent event) { diff --git a/Client/src/main/java/de/com/baseband/client/feature/modules/client/Client.java b/Client/src/main/java/de/com/baseband/client/feature/modules/client/Client.java index 6219c23..f38daf7 100644 --- a/Client/src/main/java/de/com/baseband/client/feature/modules/client/Client.java +++ b/Client/src/main/java/de/com/baseband/client/feature/modules/client/Client.java @@ -89,7 +89,7 @@ public class Client extends Feature { } disableLock = true; Chat.print("Unloading..."); - MinecraftForge.EVENT_BUS.unregister(BaseBand.fmlEventHandlerInstance); + MinecraftForge.EVENT_BUS.unregister(BaseBand.STATIC_EVENT_HANDLER_INSTANCE); mc.displayGuiScreen(null); BaseBand.enabled = false; Chat.print("Waiting for config..."); diff --git a/Client/src/main/java/de/com/baseband/client/mixin/MixinProxy.java b/Client/src/main/java/de/com/baseband/client/mixin/MixinProxy.java index 26cd010..0c777ed 100644 --- a/Client/src/main/java/de/com/baseband/client/mixin/MixinProxy.java +++ b/Client/src/main/java/de/com/baseband/client/mixin/MixinProxy.java @@ -54,7 +54,7 @@ public class MixinProxy { public static void onPlayerDamageBlock(BlockPos posBlock, EnumFacing directionFacing, CallbackInfoReturnable callbackInfoReturnable) { DamageBlockEvent event = new DamageBlockEvent(posBlock, directionFacing); - BaseBand.eventManager.publish(event); + BaseBand.EVENT_BUS.publish(event); if (event.isCancelled()) { callbackInfoReturnable.setReturnValue(false); }