Renamed directory to anticope

This commit is contained in:
stormybytes
2021-10-24 09:50:26 +07:00
parent f9753eba09
commit d8c1ad1881
110 changed files with 233 additions and 243 deletions

View File

@@ -0,0 +1,48 @@
package anticope.rejects.commands;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import meteordevelopment.meteorclient.systems.commands.Command;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.command.CommandSource;
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
import com.mojang.brigadier.arguments.IntegerArgumentType;
public class GhostCommand extends Command {
public GhostCommand() {
super("ghost", "Remove ghost blocks & bypass AntiXray", "aax", "anti-anti-xray");
}
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.executes(ctx -> {
execute(4);
return SINGLE_SUCCESS;
});
builder.then(argument("radius", IntegerArgumentType.integer(1)).executes(ctx -> {
int radius = IntegerArgumentType.getInteger(ctx, "radius");
execute(radius);
return SINGLE_SUCCESS;
}));
}
private void execute(int radius) {
ClientPlayNetworkHandler conn = mc.getNetworkHandler();
if (conn == null)
return;
BlockPos pos = mc.player.getBlockPos();
for (int dx = -radius; dx <= radius; dx++)
for (int dy = -radius; dy <= radius; dy++)
for (int dz = -radius; dz <= radius; dz++) {
PlayerActionC2SPacket packet = new PlayerActionC2SPacket(
PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK,
new BlockPos(pos.getX() + dx, pos.getY() + dy, pos.getZ() + dz), Direction.UP);
conn.sendPacket(packet);
}
}
}

View File

@@ -0,0 +1,100 @@
package anticope.rejects.commands;
import anticope.rejects.arguments.EnumStringArgumentType;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import net.minecraft.command.CommandSource;
import net.minecraft.item.*;
import net.minecraft.nbt.*;
import anticope.rejects.utils.GiveUtils;
import meteordevelopment.meteorclient.systems.commands.Command;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.registry.Registry;
import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
import java.util.*;
public class GiveCommand extends Command {
public GiveCommand() {
super("give", "Gives items in creative", "item", "kit");
}
private final Collection<String> PRESETS = GiveUtils.PRESETS.keySet();
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(literal("egg").executes(ctx -> {
ItemStack inHand = mc.player.getMainHandStack();
ItemStack item = new ItemStack(Items.STRIDER_SPAWN_EGG);
NbtCompound ct = new NbtCompound();
if (inHand.getItem() instanceof BlockItem) {
ct.putInt("Time",1);
ct.putString("id", "minecraft:falling_block");
ct.put("BlockState", new NbtCompound());
ct.getCompound("BlockState").putString("Name", Registry.ITEM.getId(inHand.getItem()).toString());
if (inHand.hasNbt() && inHand.getNbt().contains("BlockEntityTag")) {
ct.put("TileEntityData", inHand.getNbt().getCompound("BlockEntityTag"));
}
NbtCompound t = new NbtCompound();
t.put("EntityTag", ct);
item.setNbt(t);
} else {
ct.putString("id", "minecraft:item");
NbtCompound it = new NbtCompound();
it.putString("id", Registry.ITEM.getId(inHand.getItem()).toString());
it.putInt("Count",inHand.getCount());
if (inHand.hasNbt()) {
it.put("tag", inHand.getNbt());
}
ct.put("Item",it);
}
NbtCompound t = new NbtCompound();
t.put("EntityTag", ct);
item.setNbt(t);
item.setCustomName(inHand.getName());
GiveUtils.giveItem(item);
return SINGLE_SUCCESS;
}));
builder.then(literal("holo").then(argument("message", StringArgumentType.greedyString()).executes(ctx -> {
String message = ctx.getArgument("message", String.class);
message = message.replace("&", "\247");
ItemStack stack = new ItemStack(Items.ARMOR_STAND);
NbtCompound tag = new NbtCompound();
NbtList NbtList = new NbtList();
NbtList.add(NbtDouble.of(mc.player.getX()));
NbtList.add(NbtDouble.of(mc.player.getY()));
NbtList.add(NbtDouble.of(mc.player.getZ()));
tag.putBoolean("Invisible", true);
tag.putBoolean("Invulnerable", true);
tag.putBoolean("Interpret", true);
tag.putBoolean("NoGravity", true);
tag.putBoolean("CustomNameVisible", true);
tag.putString("CustomName", Text.Serializer.toJson(new LiteralText(message)));
tag.put("Pos", NbtList);
stack.setSubNbt("EntityTag", tag);
GiveUtils.giveItem(stack);
return SINGLE_SUCCESS;
})));
builder.then(literal("head").then(argument("owner",StringArgumentType.greedyString()).executes(ctx -> {
String playerName = ctx.getArgument("owner",String.class);
ItemStack itemStack = new ItemStack(Items.PLAYER_HEAD);
NbtCompound tag = new NbtCompound();
tag.putString("SkullOwner", playerName);
itemStack.setNbt(tag);
GiveUtils.giveItem(itemStack);
return SINGLE_SUCCESS;
})));
builder.then(literal("preset").then(argument("name", new EnumStringArgumentType(PRESETS)).executes(context -> {
String name = context.getArgument("name", String.class);
GiveUtils.giveItem(GiveUtils.getPreset(name));
return SINGLE_SUCCESS;
})));
}
}

View File

@@ -0,0 +1,30 @@
package anticope.rejects.commands;
import anticope.rejects.gui.screens.HeadScreen;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import net.minecraft.command.CommandSource;
import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.gui.GuiThemes;
import meteordevelopment.meteorclient.systems.commands.Command;
import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
public class HeadsCommand extends Command {
public HeadsCommand() {
super("heads", "Display heads gui");
}
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.executes(ctx -> {
MeteorClient.screenToOpen = new HeadScreen(GuiThemes.get());
return SINGLE_SUCCESS;
});
}
}

View File

@@ -0,0 +1,40 @@
package anticope.rejects.commands;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import net.minecraft.command.CommandSource;
import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket;
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
import net.minecraft.network.packet.s2c.play.DisconnectS2CPacket;
import net.minecraft.text.LiteralText;
import meteordevelopment.meteorclient.systems.commands.Command;
import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
public class KickCommand extends Command {
public KickCommand() {
super("kick", "Kick or disconnect yourself from the server", "disconnect", "quit");
}
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(literal("disconnect").executes(ctx -> {
mc.player.networkHandler.onDisconnect(new DisconnectS2CPacket(new LiteralText("Disconnected via .kick command")));
return SINGLE_SUCCESS;
}));
builder.then(literal("pos").executes(ctx -> {
mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, !mc.player.isOnGround()));
return SINGLE_SUCCESS;
}));
builder.then(literal("hurt").executes(ctx -> {
mc.player.networkHandler.sendPacket(PlayerInteractEntityC2SPacket.attack(mc.player, mc.player.isSneaking()));
return SINGLE_SUCCESS;
}));
builder.then(literal("chat").executes(ctx -> {
mc.player.sendChatMessage("§0§1§");
return SINGLE_SUCCESS;
}));
}
}

View File

@@ -0,0 +1,194 @@
package anticope.rejects.commands;
import anticope.rejects.arguments.EnumArgumentType;
import baritone.api.BaritoneAPI;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.events.packets.PacketEvent;
import meteordevelopment.meteorclient.systems.commands.Command;
import meteordevelopment.meteorclient.utils.Utils;
import meteordevelopment.meteorclient.utils.player.ChatUtils;
import meteordevelopment.meteorclient.utils.player.FindItemResult;
import meteordevelopment.meteorclient.utils.player.InvUtils;
import anticope.rejects.utils.WorldGenUtils;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.command.CommandSource;
import net.minecraft.entity.EntityType;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket;
import net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.BaseText;
import net.minecraft.text.LiteralText;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
public class LocateCommand extends Command {
private final static DynamicCommandExceptionType NOT_FOUND = new DynamicCommandExceptionType(o -> {
if (o instanceof WorldGenUtils.Feature) {
return new LiteralText(String.format(
"%s not found.",
Utils.nameToTitle(o.toString().replaceAll("_", "-")))
);
}
return new LiteralText("Not found.");
});
private Vec3d firstStart;
private Vec3d firstEnd;
private Vec3d secondStart;
private Vec3d secondEnd;
public LocateCommand() {
super("locate", "Locates structures", "loc");
}
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(literal("lodestone").executes(ctx -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (stack.getItem() != Items.COMPASS) {
error("You need to hold a lodestone compass");
return SINGLE_SUCCESS;
}
NbtCompound tag = stack.getNbt();
if (tag == null) {
error("Couldn't get the NBT data. Are you holding a (highlight)lodestone(default) compass?");
return SINGLE_SUCCESS;
}
NbtCompound nbt1 = tag.getCompound("LodestonePos");
if (nbt1 == null) {
error("Couldn't get the NBT data. Are you holding a (highlight)lodestone(default) compass?");
return SINGLE_SUCCESS;
}
Vec3d coords = new Vec3d(nbt1.getDouble("X"),nbt1.getDouble("Y"),nbt1.getDouble("Z"));
BaseText text = new LiteralText("Lodestone located at ");
text.append(ChatUtils.formatCoords(coords));
text.append(".");
info(text);
return SINGLE_SUCCESS;
}));
builder.then(argument("feature", EnumArgumentType.enumArgument(WorldGenUtils.Feature.stronghold)).executes(ctx -> {
WorldGenUtils.Feature feature = EnumArgumentType.getEnum(ctx, "feature", WorldGenUtils.Feature.stronghold);
BlockPos pos = WorldGenUtils.locateFeature(feature, mc.player.getBlockPos());
if (pos != null) {
BaseText text = new LiteralText(String.format(
"%s located at ",
Utils.nameToTitle(feature.toString().replaceAll("_", "-"))
));
Vec3d coords = new Vec3d(pos.getX(), pos.getY(), pos.getZ());
text.append(ChatUtils.formatCoords(coords));
text.append(".");
info(text);
return SINGLE_SUCCESS;
}
if (feature == WorldGenUtils.Feature.stronghold) {
FindItemResult eye = InvUtils.findInHotbar(Items.ENDER_EYE);
if (eye.found()) {
BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute("follow entity minecraft:eye_of_ender");
firstStart = null;
firstEnd = null;
secondStart = null;
secondEnd = null;
MeteorClient.EVENT_BUS.subscribe(this);
info("Please throw the first Eye of Ender");
}
}
throw NOT_FOUND.create(feature);
}));
builder.then(literal("cancel").executes(s -> {
cancel();
return SINGLE_SUCCESS;
}));
}
private void cancel() {
warning("Locate canceled");
MeteorClient.EVENT_BUS.unsubscribe(this);
}
@EventHandler
private void onReadPacket(PacketEvent.Receive event) {
if (event.packet instanceof EntitySpawnS2CPacket) {
EntitySpawnS2CPacket packet = (EntitySpawnS2CPacket) event.packet;
if (packet.getEntityTypeId() == EntityType.EYE_OF_ENDER) {
firstPosition(packet.getX(),packet.getY(),packet.getZ());
}
}
if (event.packet instanceof PlaySoundS2CPacket) {
PlaySoundS2CPacket packet = (PlaySoundS2CPacket) event.packet;
if (packet.getSound() == SoundEvents.ENTITY_ENDER_EYE_DEATH) {
lastPosition(packet.getX(), packet.getY(), packet.getZ());
}
}
}
private void firstPosition(double x, double y, double z) {
Vec3d pos = new Vec3d(x, y, z);
if (this.firstStart == null) {
this.firstStart = pos;
}
else {
this.secondStart = pos;
}
}
private void lastPosition(double x, double y, double z) {
info("%s Eye of Ender's trajectory saved.", (this.firstEnd == null) ? "First" : "Second");
Vec3d pos = new Vec3d(x, y, z);
if (this.firstEnd == null) {
this.firstEnd = pos;
info("Please throw the second Eye Of Ender from a different location.");
}
else {
this.secondEnd = pos;
findStronghold();
}
}
private void findStronghold() {
if (this.firstStart == null || this.firstEnd == null || this.secondStart == null || this.secondEnd == null) {
error("Missing position data");
cancel();
return;
}
final double[] start = new double[]{this.secondStart.x, this.secondStart.z, this.secondEnd.x, this.secondEnd.z};
final double[] end = new double[]{this.firstStart.x, this.firstStart.z, this.firstEnd.x, this.firstEnd.z};
final double[] intersection = calcIntersection(start, end);
if (Double.isNaN(intersection[0]) || Double.isNaN(intersection[1]) || Double.isInfinite(intersection[0]) || Double.isInfinite(intersection[1])) {
error("Lines are parallel");
cancel();
return;
}
BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute("stop");
MeteorClient.EVENT_BUS.unsubscribe(this);
Vec3d coords = new Vec3d(intersection[0],0,intersection[1]);
BaseText text = new LiteralText("Stronghold roughly located at ");
text.append(ChatUtils.formatCoords(coords));
text.append(".");
info(text);
}
private double[] calcIntersection(double[] line, double[] line2) {
final double a1 = line[3] - line[1];
final double b1 = line[0] - line[2];
final double c1 = a1 * line[0] + b1 * line[1];
final double a2 = line2[3] - line2[1];
final double b2 = line2[0] - line2[2];
final double c2 = a2 * line2[0] + b2 * line2[1];
final double delta = a1 * b2 - a2 * b1;
return new double[]{(b2 * c1 - b1 * c2) / delta, (a1 * c2 - a2 * c1) / delta};
}
}

View File

@@ -0,0 +1,94 @@
package anticope.rejects.commands;
import com.google.gson.*;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import meteordevelopment.meteorclient.systems.commands.Command;
import meteordevelopment.meteorclient.systems.commands.arguments.PlayerArgumentType;
import meteordevelopment.meteorclient.utils.network.Http;
import net.minecraft.command.CommandSource;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.LiteralText;
import org.apache.commons.codec.binary.Base64;
import org.lwjgl.BufferUtils;
import org.lwjgl.PointerBuffer;
import org.lwjgl.system.MemoryUtil;
import org.lwjgl.util.tinyfd.TinyFileDialogs;
import java.io.*;
import java.net.URL;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
public class SaveSkinCommand extends Command {
private final static SimpleCommandExceptionType IO_EXCEPTION = new SimpleCommandExceptionType(new LiteralText("An IOException occurred"));
private final PointerBuffer filters;
private final Gson GSON = new Gson();
public SaveSkinCommand() {
super("save-skin","Download a player's skin by name.", "skin","skinsteal");
filters = BufferUtils.createPointerBuffer(1);
ByteBuffer pngFilter = MemoryUtil.memASCII("*.png");
filters.put(pngFilter);
filters.rewind();
}
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(argument("player", PlayerArgumentType.player()).executes(ctx -> {
PlayerEntity playerEntity = ctx.getArgument("player", PlayerEntity.class);
String path = TinyFileDialogs.tinyfd_saveFileDialog("Save image", null, filters, null);
if (path == null) IO_EXCEPTION.create();
if (!path.endsWith(".png")) path += ".png";
saveSkin(playerEntity.getUuidAsString(),path);
return SINGLE_SUCCESS;
}));
}
private void saveSkin(String uuid, String path) throws CommandSyntaxException {
try {
//going to explain what happens so I don't forget
//request their minecraft profile, all so we can get a base64 encoded string that contains ANOTHER json that then has the skin URL
String PROFILE_REQUEST_URL = "https://sessionserver.mojang.com/session/minecraft/profile/%s";
JsonObject object = Http.get(String.format(PROFILE_REQUEST_URL, uuid)).sendJson(JsonObject.class);
//Get the properties array which has what we need
JsonArray array = object.getAsJsonArray("properties");
JsonObject property = array.get(0).getAsJsonObject();
//value is what we grab but it's encoded so we have to decode it
String base64String = property.get("value").getAsString();
byte[] bs = Base64.decodeBase64(base64String);
//Convert the response to json and pull the skin url from there
String secondResponse = new String(bs, StandardCharsets.UTF_8);
JsonObject finalResponseObject = GSON.fromJson(secondResponse, JsonObject.class);
JsonObject texturesObject = finalResponseObject.getAsJsonObject("textures");
JsonObject skinObj = texturesObject.getAsJsonObject("SKIN");
String skinURL = skinObj.get("url").getAsString();
InputStream in = new BufferedInputStream(new URL(skinURL).openStream());
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
int n = 0;
while (-1 != (n = in.read(buf))) {
out.write(buf, 0, n);
}
out.close();
in.close();
byte[] response = out.toByteArray();
File file = new File(path);
FileOutputStream fos = new FileOutputStream(file.getPath());
fos.write(response);
fos.close();
} catch (IOException e) {
throw IO_EXCEPTION.create();
}
}
}

View File

@@ -0,0 +1,67 @@
package anticope.rejects.commands;
import anticope.rejects.arguments.EnumArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import net.minecraft.command.CommandSource;
import net.minecraft.text.BaseText;
import net.minecraft.text.LiteralText;
import kaptainwutax.mcutils.version.MCVersion;
import meteordevelopment.meteorclient.systems.commands.Command;
import anticope.rejects.utils.seeds.Seed;
import anticope.rejects.utils.seeds.Seeds;
import meteordevelopment.meteorclient.utils.Utils;
import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
public class SeedCommand extends Command {
private final static SimpleCommandExceptionType NO_SEED = new SimpleCommandExceptionType(new LiteralText("No seed for current world saved."));
public SeedCommand() {
super("seed", "Get or set seed for the current world.");
}
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.executes(ctx -> {
Seed seed = Seeds.get().getSeed();
if (seed == null) throw NO_SEED.create();
info(seed.toText());
return SINGLE_SUCCESS;
});
builder.then(literal("list").executes(ctx -> {
Seeds.get().seeds.forEach((name, seed) -> {
BaseText text = new LiteralText(name + " ");
text.append(seed.toText());
info(text);
});
return SINGLE_SUCCESS;
}));
builder.then(literal("delete").executes(ctx -> {
Seed seed = Seeds.get().getSeed();
if (seed != null) {
BaseText text = new LiteralText("Deleted ");
text.append(seed.toText());
info(text);
}
Seeds.get().seeds.remove(Utils.getWorldName());
return SINGLE_SUCCESS;
}));
builder.then(argument("seed", StringArgumentType.string()).executes(ctx -> {
Seeds.get().setSeed(StringArgumentType.getString(ctx, "seed"));
return SINGLE_SUCCESS;
}));
builder.then(argument("seed", StringArgumentType.string()).then(argument("version", EnumArgumentType.enumArgument(MCVersion.latest())).executes(ctx -> {
Seeds.get().setSeed(StringArgumentType.getString(ctx, "seed"), EnumArgumentType.getEnum(ctx, "version", MCVersion.latest()));
return SINGLE_SUCCESS;
})));
}
}

View File

@@ -0,0 +1,153 @@
package anticope.rejects.commands;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import net.minecraft.client.network.ServerInfo;
import net.minecraft.command.CommandSource;
import net.minecraft.text.BaseText;
import net.minecraft.text.ClickEvent;
import net.minecraft.text.HoverEvent;
import net.minecraft.text.LiteralText;
import net.minecraft.text.ClickEvent.Action;
import net.minecraft.util.Formatting;
import anticope.rejects.utils.portscanner.PScanRunner;
import anticope.rejects.utils.portscanner.PortScannerManager;
import meteordevelopment.meteorclient.systems.commands.Command;
import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import com.mojang.brigadier.arguments.IntegerArgumentType;
/*
Ported from Cornos
https://github.com/cornos/Cornos/blob/master/src/main/java/me/zeroX150/cornos/features/command/impl/Scan.java
*/
public class ServerCommand extends Command {
private final static SimpleCommandExceptionType ADDRESS_ERROR = new SimpleCommandExceptionType(new LiteralText("Couldn't obtain server address"));
private final static SimpleCommandExceptionType INVALID_RANGE = new SimpleCommandExceptionType(new LiteralText("Invalid range"));
private final static HashMap<Integer, String> ports = new HashMap<Integer, String>();
public ServerCommand() {
super("server", "Prints server information");
ports.put(20, "FTP");
ports.put(22, "SSH");
ports.put(80, "HTTP");
ports.put(443, "HTTPS");
ports.put(25565, "Java Server");
ports.put(25575, "Java Server RCON");
ports.put(19132, "Bedrock Server");
ports.put(19133, "Bedrock Server IPv6");
ports.put(8123, "DynMap");
ports.put(25566, "Minequery");
ports.put(3306, "MySQL");
}
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(literal("ports").executes(ctx -> {
scanKnownPorts(getAddress());
return SINGLE_SUCCESS;
}));
builder.then(literal("ports").then(literal("known").executes(ctx -> {
scanKnownPorts(getAddress());
return SINGLE_SUCCESS;
})));
builder.then(literal("ports").then(argument("from", IntegerArgumentType.integer(0)).then(argument("to", IntegerArgumentType.integer(1)).executes(ctx -> {
scanRange(getAddress(), IntegerArgumentType.getInteger(ctx, "from"),
IntegerArgumentType.getInteger(ctx, "to"));
return SINGLE_SUCCESS;
}))));
}
private InetAddress getAddress() throws CommandSyntaxException {
if (mc.isIntegratedServerRunning()) {
try {
return InetAddress.getLocalHost();
} catch (UnknownHostException e) {
throw ADDRESS_ERROR.create();
}
}
else {
ServerInfo server = mc.getCurrentServerEntry();
if (server == null) throw ADDRESS_ERROR.create();
try {
return InetAddress.getByName(server.address);
} catch (UnknownHostException e) {
throw ADDRESS_ERROR.create();
}
}
}
private void scanPorts(InetAddress address, Collection<Integer> port_list){
info("Started scanning %d ports", port_list.size());
PScanRunner pScanRunner = new PScanRunner(address, 5, 3, 200, port_list, scanResults -> {
int open_ports = 0;
info("Open ports:");
for (PortScannerManager.ScanResult result : scanResults) {
if (result.isOpen()) {
info(formatPort(result.getPort(), address));
open_ports++;
}
}
info("Open count: %d/%d", open_ports, scanResults.size());
});
PortScannerManager.scans.add(pScanRunner);
}
private void scanKnownPorts(InetAddress address) {
scanPorts(address, ports.keySet());
}
private void scanRange(InetAddress address, int min, int max) throws CommandSyntaxException {
if (max<min) throw INVALID_RANGE.create();
List<Integer> port_list = new LinkedList<>();
for (int i = min; i <= max; i++) port_list.add(i);
scanPorts(address, port_list);
}
private BaseText formatPort(int port, InetAddress address) {
BaseText text = new LiteralText(String.format("- %s%d%s ", Formatting.GREEN, port, Formatting.GRAY));
if (ports.containsKey(port)) {
text.append(ports.get(port));
if (ports.get(port).startsWith("HTTP")) {
text.setStyle(text.getStyle()
.withClickEvent(new ClickEvent(
Action.OPEN_URL,
String.format("%s://%s:%d", ports.get(port).toLowerCase(), address.getHostAddress(), port)
))
.withHoverEvent(new HoverEvent(
HoverEvent.Action.SHOW_TEXT,
new LiteralText("Open in browser")
))
);
}
else if (ports.get(port) == "DynMap") {
text.setStyle(text.getStyle()
.withClickEvent(new ClickEvent(
ClickEvent.Action.OPEN_URL,
String.format("http://%s:%d", address.getHostAddress(), port)
))
.withHoverEvent(new HoverEvent(
HoverEvent.Action.SHOW_TEXT,
new LiteralText("Open in browser")
))
);
}
}
return text;
}
}

View File

@@ -0,0 +1,30 @@
package anticope.rejects.commands;
import anticope.rejects.arguments.ClientPosArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import meteordevelopment.meteorclient.systems.commands.Command;
import net.minecraft.block.BlockState;
import net.minecraft.command.CommandSource;
import net.minecraft.command.argument.BlockStateArgument;
import net.minecraft.command.argument.BlockStateArgumentType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
public class SetBlockCommand extends Command {
public SetBlockCommand() {
super("setblock", "Sets client side blocks", "sblk");
}
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(argument("pos", ClientPosArgumentType.pos()).then(argument("block", BlockStateArgumentType.blockState()).executes(ctx -> {
Vec3d pos = ClientPosArgumentType.getPos(ctx, "pos");
BlockState blockState = ctx.getArgument("block", BlockStateArgument.class).getBlockState();
mc.world.setBlockState(new BlockPos((int)pos.getX(), (int)pos.getY(), (int)pos.getZ()), blockState);
return SINGLE_SUCCESS;
})));
}
}

View File

@@ -0,0 +1,35 @@
package anticope.rejects.commands;
import anticope.rejects.arguments.ClientPosArgumentType;
import com.mojang.brigadier.arguments.FloatArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import meteordevelopment.meteorclient.systems.commands.Command;
import net.minecraft.command.CommandSource;
import net.minecraft.util.math.Vec3d;
import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
public class TeleportCommand extends Command {
public TeleportCommand() {
super("teleport","Sends a packet to the server with new position. Allows to teleport small distances.", "tp");
}
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(argument("pos", ClientPosArgumentType.pos()).executes(ctx -> {
Vec3d pos = ClientPosArgumentType.getPos(ctx, "pos");
mc.player.updatePosition(pos.getX(), pos.getY(), pos.getZ());
return SINGLE_SUCCESS;
}));
builder.then(argument("pos", ClientPosArgumentType.pos()).then(argument("yaw", FloatArgumentType.floatArg()).then(argument("pitch",FloatArgumentType.floatArg()).executes(ctx -> {
Vec3d pos = ClientPosArgumentType.getPos(ctx, "pos");
float yaw = FloatArgumentType.getFloat(ctx, "yaw");
float pitch = FloatArgumentType.getFloat(ctx, "pitch");
mc.player.updatePositionAndAngles(pos.getX(), pos.getY(), pos.getZ(), yaw, pitch);
return SINGLE_SUCCESS;
}))));
}
}

View File

@@ -0,0 +1,72 @@
package anticope.rejects.commands;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import meteordevelopment.meteorclient.systems.commands.Command;
import net.minecraft.command.CommandSource;
import net.minecraft.text.LiteralText;
import net.minecraft.util.math.BlockPos;
import org.lwjgl.BufferUtils;
import org.lwjgl.PointerBuffer;
import org.lwjgl.system.MemoryUtil;
import org.lwjgl.util.tinyfd.TinyFileDialogs;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.ByteBuffer;
import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
public class TerrainExport extends Command {
private final PointerBuffer filters;
private final static SimpleCommandExceptionType IO_EXCEPTION = new SimpleCommandExceptionType(new LiteralText("An IOException occurred"));
public TerrainExport() {
super("terrain-export", "Export an area to the c++ terrain finder format (very popbob command).");
filters = BufferUtils.createPointerBuffer(1);
ByteBuffer txtFilter = MemoryUtil.memASCII("*.txt");
filters.put(txtFilter);
filters.rewind();
}
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(argument("distance", IntegerArgumentType.integer(1)).executes(context -> {
int distance = IntegerArgumentType.getInteger(context, "distance");
StringBuilder stringBuilder = new StringBuilder();
for (int x = -distance; x <= distance; x++) {
for (int z = -distance; z <= distance; z++) {
for (int y = distance; y >= -distance; y--) {
BlockPos pos = mc.player.getBlockPos().add(x, y, z);
if (mc.world.getBlockState(pos).isFullCube(mc.world, pos)) {
stringBuilder.append(String.format("%d, %d, %d\n", x + distance, y + distance, z + distance));
}
}
}
}
String path = TinyFileDialogs.tinyfd_saveFileDialog("Save data", null, filters, null);
if (path == null) throw IO_EXCEPTION.create();
if (!path.endsWith(".txt"))
path += ".txt";
try {
FileWriter file = new FileWriter(path);
file.write(stringBuilder.toString().trim());
file.close();
} catch (IOException e) {
throw IO_EXCEPTION.create();
}
return SINGLE_SUCCESS;
}));
}
}