Skip to content

Commit

Permalink
1.19.1 + popcounter rework (#27)
Browse files Browse the repository at this point in the history
Co-authored-by: Cloudburst <[email protected]>
  • Loading branch information
RacoonDog and C10udburst authored Sep 18, 2022
1 parent f00c960 commit 2179b7d
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 81 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/devbuild.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: devbuild

concurrency:
group: "build-1.19"
group: "build-1.19.1"
cancel-in-progress: true

on:
Expand Down Expand Up @@ -30,8 +30,8 @@ jobs:
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest-1.19"
automatic_release_tag: "latest-1.19.1"
prerelease: false
title: "1.19 Build"
title: "1.19.1 Build"
files: |
./build/libs/*.jar
8 changes: 2 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ version = project.mod_version
group = project.maven_group

repositories {
maven {
name = "jitpack"
url = "https://jitpack.io"
}
maven {
name = "meteor-maven"
url = "https://maven.meteordev.org/releases"
Expand All @@ -30,7 +26,7 @@ dependencies {
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

// Meteor
modImplementation "meteordevelopment:meteor-client:0.5.0-SNAPSHOT"
modImplementation "meteordevelopment:meteor-client:0.5.1-SNAPSHOT"

// Required for loading logo hud element images
modImplementation "net.fabricmc.fabric-api:fabric-resource-loader-v0:+"
Expand All @@ -50,5 +46,5 @@ processResources {

tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
it.options.release = 16
it.options.release = 17
}
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
org.gradle.jvmargs=-Xmx2G

# Fabric (https://fabricmc.net/versions.html)
minecraft_version=1.19
yarn_version=1.19+build.1
loader_version=0.14.7
minecraft_version=1.19.1
yarn_version=1.19.1+build.4
loader_version=0.14.8

# Mod Properties
mod_version=0.1
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStorePath=wrapper/dists
2 changes: 0 additions & 2 deletions src/main/java/me/ghosttypes/orion/mixins/NametagMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

@Mixin(EntityRenderer.class)
public abstract class NametagMixin<T extends Entity> implements IEntityRenderer {
@Shadow
public abstract Identifier getTexture(Entity entity);
@Inject(method = "renderLabelIfPresent", at = @At("HEAD"), cancellable = true)
private void onRenderLabel(T entity, Text text, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo info) {
if (!(entity instanceof PlayerEntity)) return;
Expand Down
87 changes: 58 additions & 29 deletions src/main/java/me/ghosttypes/orion/modules/chat/PopCounter.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,15 @@
import meteordevelopment.orbit.EventHandler;
import meteordevelopment.starscript.Script;
import meteordevelopment.starscript.compiler.Parser;
import meteordevelopment.starscript.utils.StarscriptError;
import meteordevelopment.starscript.compiler.Compiler;

import meteordevelopment.starscript.utils.StarscriptError;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.packet.s2c.play.EntityStatusS2CPacket;
import net.minecraft.util.Formatting;

import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.UUID;
import java.util.*;

public class PopCounter extends Module {

Expand All @@ -48,22 +45,51 @@ public class PopCounter extends Module {
private final Setting<Boolean> dontAnnounceFriends = sgGeneral.add(new BoolSetting.Builder().name("dont-announce-friends").description("Don't annnounce when your friends pop.").defaultValue(true).build());
public final Setting<Boolean> autoEz = sgAutoEz.add(new BoolSetting.Builder().name("auto-ez").description("Sends a message when you kill players.").defaultValue(false).build());
public final Setting<Boolean> suffix = sgAutoEz.add(new BoolSetting.Builder().name("suffix").description("Add Orion suffix to the end of pop messages.").defaultValue(false).visible(autoEz::get).build());
public final Setting<String> suffixMessage = sgAutoEz.add(new StringSetting.Builder().name("suffix-message").description("The suffix to be added at the end of pop messages.").renderer(StarscriptTextBoxRenderer.class).defaultValue(" | {orion_prefix} {orion_version}").visible(suffix::get).onChanged(e -> updateSuffixScript()).build());
public final Setting<Boolean> killStr = sgAutoEz.add(new BoolSetting.Builder().name("killstreak").description("Add your killstreak to the end of autoez messages").defaultValue(false).visible(autoEz::get).build());
public final Setting<Boolean> pmEz = sgAutoEz.add(new BoolSetting.Builder().name("pm-ez").description("Send the autoez message to the player's dm.").defaultValue(false).visible(autoEz::get).build());
private final Setting<List<String>> popMessages = sgMessages.add(new StringListSetting.Builder().name("pop-messages").description("Messages to use when announcing pops.").defaultValue(Collections.emptyList()).build());
public final Setting<List<String>> ezMessages = sgMessages.add(new StringListSetting.Builder().name("ez-messages").description("Messages to use for autoez.").renderer(StarscriptTextBoxRenderer.class).defaultValue(Collections.emptyList()).visible(autoEz::get).build());
public final Setting<List<String>> popMessages = sgMessages.add(new StringListSetting.Builder().name("pop-messages").description("Messages to use when announcing pops.").renderer(StarscriptTextBoxRenderer.class).defaultValue(Collections.emptyList()).onChanged(e -> updatePopScripts()).build());
public final Setting<List<String>> ezMessages = sgMessages.add(new StringListSetting.Builder().name("ez-messages").description("Messages to use for autoez.").renderer(StarscriptTextBoxRenderer.class).defaultValue(Collections.emptyList()).visible(() -> autoEz.get() || announceOthers.get()).onChanged(e -> updateEzScripts()).build());

public final Object2IntMap<UUID> totemPops = new Object2IntOpenHashMap<>();
private final Object2IntMap<UUID> chatIds = new Object2IntOpenHashMap<>();

private final Random random = new Random();
private static final Random RANDOM = new Random();
private int updateWait = 45;
public Script suffixScript;
private final List<Script> popScripts = new ArrayList<>();
public final List<Script> ezScripts = new ArrayList<>();

public PopCounter() {
super(Orion.CATEGORY, "pop-counter", "Count player's totem pops.");
updateSuffixScript();
updateEzScripts();
updatePopScripts();
}

private void updateSuffixScript() {
String suffix = suffixMessage.get();
suffixScript = compile(suffix);
}
private int announceWait;

private void updatePopScripts() {
List<String> list = popMessages.get();
popScripts.clear();
for (var entry : list) {
var script = compile(entry);
if (script != null) popScripts.add(script);
}
}

private void updateEzScripts() {
List<String> list = ezMessages.get();
ezScripts.clear();
for (var entry : list) {
var script = compile(entry);
if (script != null) ezScripts.add(script);
}
}
private int announceWait;

@Override
public void onActivate() {
Expand All @@ -82,9 +108,8 @@ private void onGameJoin(GameJoinedEvent event) {

@EventHandler
private void onReceivePacket(PacketEvent.Receive event) {
if (!(event.packet instanceof EntityStatusS2CPacket)) return;
if (!(event.packet instanceof EntityStatusS2CPacket p)) return;

EntityStatusS2CPacket p = (EntityStatusS2CPacket) event.packet;
if (p.getStatus() != 35) return;

Entity entity = p.getEntity(mc.world);
Expand All @@ -103,11 +128,21 @@ private void onReceivePacket(PacketEvent.Receive event) {
}
if (announceOthers.get() && announceWait <= 1 && mc.player.distanceTo(entity) <= announceRange.get()) {
if (dontAnnounceFriends.get() && Friends.get().isFriend((PlayerEntity) entity)) return;
String popMessage = getPopMessage((PlayerEntity) entity);
String name = entity.getEntityName();
if (suffix.get()) { popMessage = popMessage + " | Orion " + Orion.VERSION; }
mc.player.sendChatMessage(popMessage);
if (pmOthers.get()) Wrapper.messagePlayer(name, StringHelper.stripName(name, popMessage));

try {
StringBuilder sb = new StringBuilder(getPopMessage((PlayerEntity) entity));
if (suffix.get() && suffixScript != null) sb.append(MeteorStarscript.ss.run(suffixScript).toString());
String popMessage = sb.toString();
ChatUtils.sendPlayerMsg(popMessage);

if (pmOthers.get()) {
String name = entity.getEntityName();
Wrapper.messagePlayer(name, StringHelper.stripName(name, popMessage));
}
} catch (StarscriptError error) {
MeteorStarscript.printChatError(error);
}

announceWait = announceDelay.get() * 20;
}
}
Expand Down Expand Up @@ -136,28 +171,22 @@ private void onTick(TickEvent.Post event) {
}
}

private int getChatId(Entity entity) {
return chatIds.computeIntIfAbsent(entity.getUuid(), value -> random.nextInt());
private int getChatId(Entity entity) throws StarscriptError {
return chatIds.computeIfAbsent(entity.getUuid(), value -> RANDOM.nextInt());
}

private String getPopMessage(PlayerEntity p) {
MeteorStarscript.ss.set("pops", totemPops.getOrDefault(p.getUuid(), 0));
MeteorStarscript.ss.set("killed", p.getEntityName());

if (popMessages.get().isEmpty()) {
if (popScripts.isEmpty()) {
ChatUtils.warning("Your pop message list is empty!");
return "Ez pop";
}
var script = compile(popMessages.get().get(new Random().nextInt(popMessages.get().size())));
if (script == null) warning("Malformed pop message");
try {
var section = MeteorStarscript.ss.run(script);
return section.text;
}
catch (StarscriptError e) {
MeteorStarscript.printChatError(e);
}
return "Ezz pop";

Script script = popScripts.get(RANDOM.nextInt(popScripts.size()));

return MeteorStarscript.ss.run(script).toString();
}

private static Script compile(String script) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import meteordevelopment.meteorclient.events.world.TickEvent;
import meteordevelopment.meteorclient.settings.*;
import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.meteorclient.utils.player.ChatUtils;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.client.gui.screen.DeathScreen;

Expand Down Expand Up @@ -68,19 +69,18 @@ private void onTick(TickEvent.Post event) {
if (shouldRekit && rekitWait <= 1) {
if (shouldHS) {
if (alertHS.get()) info("You reached a new highscore of " + Stats.highscore + "!");
if (announceHS.get()) mc.player.sendChatMessage("I reached a new highscore of " + Stats.highscore + " thanks to Orion!");
if (announceHS.get()) ChatUtils.sendPlayerMsg("I reached a new highscore of " + Stats.highscore + " thanks to Orion!");
shouldHS = false;
}
info("Rekitting with kit " + kitName.get());
mc.player.sendChatMessage("/kit " + kitName.get());
mc.player.sendCommand("/kit " + kitName.get());
shouldRekit = false;
shouldHS = false;
rekitWait = 50;
return;
} else { rekitWait--; }
if (shouldExcuse && excuseWait <= 1) {
String excuseMessage = getExcuseMessage();
mc.player.sendChatMessage(excuseMessage);
ChatUtils.sendPlayerMsg(getExcuseMessage());
shouldExcuse = false;
excuseWait = 50;
} else { excuseWait--; }
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/me/ghosttypes/orion/utils/Wrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public static int randomNum(int min, int max) {

public static void messagePlayer(String playerName, String m) {
assert mc.player != null;
mc.player.sendChatMessage("/msg " + playerName + " " + m);
mc.player.sendCommand("/msg " + playerName + " " + m);
}

}
41 changes: 12 additions & 29 deletions src/main/java/me/ghosttypes/orion/utils/chat/EzUtil.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package me.ghosttypes.orion.utils.chat;

import me.ghosttypes.orion.Orion;
import me.ghosttypes.orion.modules.chat.PopCounter;
import me.ghosttypes.orion.modules.main.BedAura;
import me.ghosttypes.orion.utils.Wrapper;
Expand All @@ -12,43 +11,38 @@
import meteordevelopment.meteorclient.systems.modules.combat.KillAura;
import meteordevelopment.meteorclient.utils.misc.MeteorStarscript;
import meteordevelopment.meteorclient.utils.player.ChatUtils;
import meteordevelopment.starscript.Script;
import meteordevelopment.starscript.compiler.Compiler;
import meteordevelopment.starscript.compiler.Parser;
import meteordevelopment.starscript.utils.StarscriptError;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import static meteordevelopment.meteorclient.MeteorClient.mc;

public class EzUtil {
private static final Random RANDOM = new Random();
public static List<String> currentTargets = new ArrayList<>();

public static void sendAutoEz(String playerName) {
increaseKC();
MeteorStarscript.ss.set("killed", playerName);
PopCounter popCounter = Modules.get().get(PopCounter.class);
List<String> ezMessages = popCounter.ezMessages.get();
if (ezMessages.isEmpty()) {
if (popCounter.ezScripts.isEmpty()) {
ChatUtils.warning("Your auto ez message list is empty!");
return;
}

var script = compile(ezMessages.get(new Random().nextInt(ezMessages.size())));
if (script == null) ChatUtils.warning("Malformed ez message");
var script = popCounter.ezScripts.get(RANDOM.nextInt(popCounter.ezScripts.size()));

try {
var section = MeteorStarscript.ss.run(script);
var ezMessage = section.text;
if (popCounter.killStr.get()) { ezMessage = ezMessage + " | Killstreak: " + Stats.killStreak; }
if (popCounter.suffix.get()) { ezMessage = ezMessage + " | Orion " + Orion.VERSION; }
mc.player.sendChatMessage(ezMessage);
StringBuilder stringBuilder = new StringBuilder(MeteorStarscript.ss.run(script).toString());
if (popCounter.killStr.get()) stringBuilder.append(" | Killstreak: ").append(Stats.killStreak);
if (popCounter.suffix.get() && popCounter.suffixScript != null) stringBuilder.append(MeteorStarscript.ss.run(popCounter.suffixScript).toString());

String ezMessage = stringBuilder.toString();
ChatUtils.sendPlayerMsg(ezMessage);
if (popCounter.pmEz.get()) Wrapper.messagePlayer(playerName, StringHelper.stripName(playerName, ezMessage));
} catch (StarscriptError e) {
MeteorStarscript.printChatError(e);
} catch (StarscriptError error) {
MeteorStarscript.printChatError(error);
}

}

public static void increaseKC() {
Expand All @@ -64,15 +58,4 @@ public static void updateTargets() {
modules.add(Modules.get().get(BedAura.class));
for (Module module : modules) currentTargets.add(module.getInfoString());
}

private static Script compile(String script) {
if (script == null) return null;
Parser.Result result = Parser.parse(script);
if (result.hasErrors()) {
MeteorStarscript.printChatError(result.errors.get(0));
return null;
}
return Compiler.compile(result);
}

}
3 changes: 2 additions & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"description": "A combat addon for Meteor Client.",
"authors": [
"GhostTypes",
"Cloudburst"
"Cloudburst",
"Crosby"
],
"contact": {
"repo": "https://github.com/GhostTypes/orion"
Expand Down

0 comments on commit 2179b7d

Please sign in to comment.