Renamed directory to anticope
This commit is contained in:
203
src/main/java/anticope/rejects/utils/GiveUtils.java
Normal file
203
src/main/java/anticope/rejects/utils/GiveUtils.java
Normal file
@@ -0,0 +1,203 @@
|
||||
package anticope.rejects.utils;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.nbt.NbtList;
|
||||
import net.minecraft.nbt.StringNbtReader;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
||||
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
import org.apache.commons.lang3.tuple.Triple;
|
||||
|
||||
import static meteordevelopment.meteorclient.utils.Utils.mc;
|
||||
|
||||
public class GiveUtils {
|
||||
|
||||
public static final Map<String, Function<Boolean, ItemStack>> PRESETS = new HashMap<>();
|
||||
|
||||
private final static SimpleCommandExceptionType NOT_IN_CREATIVE = new SimpleCommandExceptionType(new LiteralText("You must be in creative mode to use this."));
|
||||
private final static SimpleCommandExceptionType NO_SPACE = new SimpleCommandExceptionType(new LiteralText("No space in hotbar."));
|
||||
|
||||
private static final List<Identifier> HIDDEN_ENTITIES = Arrays.asList(
|
||||
new Identifier("giant"),
|
||||
new Identifier("ender_dragon"),
|
||||
new Identifier("wither"),
|
||||
new Identifier("iron_golem"),
|
||||
new Identifier("ender_dragon"),
|
||||
new Identifier("tnt_minecart"),
|
||||
new Identifier("lightning_bolt"));
|
||||
|
||||
// Ported from: https://github.com/BleachDrinker420/BleachHack/blob/master/BleachHack-Fabric-1.16/src/main/java/bleach/hack/command/commands/CmdGive.java
|
||||
private static final List<Triple<String, Item, String>> STRING_PRESETS = Arrays.asList(
|
||||
Triple.of("lag_spawner", Items.SPAWNER, "{BlockEntityTag:{MaxNearbyEntities:32767,RequiredPlayerRange:32767,SpawnCount:32767,MaxSpawnDelay:0,SpawnRange:32767,Delay:0,MinSpawnDelay:0}}"),
|
||||
Triple.of("tnt_spawner", Items.SPAWNER, "{BlockEntityTag:{MaxNearbyEntities:32767,RequiredPlayerRange:32767,SpawnCount:50,SpawnData:{Fuse:1,id:\"minecraft:tnt\"},MaxSpawnDelay:0,SpawnRange:10,Delay:0,MinSpawnDelay:0}}"),
|
||||
Triple.of("boat_spawner", Items.SPAWNER, "{BlockEntityTag:{SpawnData:{Type:\"jungle\",CustomName:'{\"text\":\"Boat\",\"color\":\"aqua\",\"bold\":true,\"italic\":true,\"underlined\":true}',Invulnerable:1b,id:\"minecraft:boat\",Glowing:1b,CustomNameVisible:1b},SpawnRange:10,SpawnCount:50}}"),
|
||||
Triple.of("pigs_egg", Items.CHICKEN_SPAWN_EGG, "{EntityTag:{MaxNearbyEntities:1000,RequiredPlayerRange:100,CustomDisplayTile:1b,DisplayState:{Properties:{hinge:\"left\",half:\"upper\",open:\"true\"},Name:\"minecraft:acacia_door\"},SpawnData:{id:\"minecraft:minecart\"},id:\"minecraft:spawner_minecart\",MaxSpawnDelay:0,Delay:1,MinSpawnDelay:0}}"),
|
||||
Triple.of("end_portal_arrow", Items.ELDER_GUARDIAN_SPAWN_EGG, "{EntityTag:{SoundEvent:\"block.end_portal.spawn\",pickup:1b,id:\"minecraft:arrow\"}}"),
|
||||
Triple.of("wither_spawn_arrow", Items.ELDER_GUARDIAN_SPAWN_EGG, "{EntityTag:{SoundEvent:\"entity.wither.spawn\",pickup:1b,id:\"minecraft:arrow\"}}"),
|
||||
Triple.of("eg_curse_arrow", Items.ELDER_GUARDIAN_SPAWN_EGG, "{EntityTag:{SoundEvent:\"entity.elder_guardian.curse\",pickup:1b,id:\"minecraft:arrow\"}}"),
|
||||
Triple.of("big_slime", Items.SLIME_SPAWN_EGG, "{EntityTag:{Size:50,id:\"minecraft:slime\"}}"),
|
||||
Triple.of("particle_area_expand", Items.SKELETON_SPAWN_EGG, "{EntityTag:{Particle:\"angry_villager\",Radius:1.0f,RadiusOnUse:1.0f,Duration:10000,id:\"minecraft:area_effect_cloud\",RadiusPerTick:10.0f}}"),
|
||||
Triple.of("armor_stand_spawner_minecart", Items.BAT_SPAWN_EGG, "{EntityTag:{SpawnData:{id:\"minecraft:armor_stand\"},id:\"minecraft:spawner_minecart\"}}")
|
||||
);
|
||||
|
||||
private static final Random random = new Random();
|
||||
|
||||
public static void giveItem(ItemStack item) throws CommandSyntaxException {
|
||||
if (!mc.player.getAbilities().creativeMode) throw NOT_IN_CREATIVE.create();
|
||||
|
||||
if (!mc.player.getInventory().insertStack(item)) {
|
||||
throw NO_SPACE.create();
|
||||
}
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
STRING_PRESETS.forEach((preset) -> {
|
||||
PRESETS.put(preset.getLeft(), (preview) -> {
|
||||
if (preview) preset.getMiddle().getDefaultStack();
|
||||
ItemStack item = preset.getMiddle().getDefaultStack();
|
||||
try {
|
||||
item.setNbt(StringNbtReader.parse(preset.getRight()));
|
||||
} catch (CommandSyntaxException e) { }
|
||||
item.setCustomName(new LiteralText(toName(preset.getLeft())));
|
||||
return item;
|
||||
});
|
||||
});
|
||||
|
||||
PRESETS.put("force_op", (preview) -> {
|
||||
if (preview) Items.SPIDER_SPAWN_EGG.getDefaultStack();
|
||||
ItemStack item = Items.SPIDER_SPAWN_EGG.getDefaultStack();
|
||||
String nick = mc.player.getName().asString();
|
||||
try {
|
||||
item.setNbt(StringNbtReader.parse("{EntityTag:{Time:1,BlockState:{Name:\"minecraft:spawner\"},id:\"minecraft:falling_block\",TileEntityData:{SpawnCount:20,SpawnData:{id:\"minecraft:villager\",Passengers:[{Time:1,BlockState:{Name:\"minecraft:redstone_block\"},id:\"minecraft:falling_block\",Passengers:[{id:\"minecraft:fox\",Passengers:[{Time:1,BlockState:{Name:\"minecraft:activator_rail\"},id:\"minecraft:falling_block\",Passengers:[{Command:\"execute as @e run op "+nick+"\",id:\"minecraft:command_block_minecart\"}]}],NoAI:1b,Health:1.0f,ActiveEffects:[{Duration:1000,Id:20b,Amplifier:4b}]}]}],NoAI:1b,Health:1.0f,ActiveEffects:[{Duration:1000,Id:20b,Amplifier:4b}]},MaxSpawnDelay:100,SpawnRange:10,Delay:1,MinSpawnDelay:100}}}"));
|
||||
} catch (CommandSyntaxException e) { }
|
||||
item.setCustomName(new LiteralText("Force OP"));
|
||||
return item;
|
||||
});
|
||||
|
||||
PRESETS.put("troll_potion", (preview) -> {
|
||||
if (preview) Items.LINGERING_POTION.getDefaultStack();
|
||||
ItemStack stack = Items.LINGERING_POTION.getDefaultStack();
|
||||
NbtList effects = new NbtList();
|
||||
for(int i = 1; i <= 31; i++)
|
||||
{
|
||||
NbtCompound effect = new NbtCompound();
|
||||
effect.putByte("Amplifier", (byte)127);
|
||||
effect.putInt("Duration", Integer.MAX_VALUE);
|
||||
effect.putInt("Id", i);
|
||||
effects.add(effect);
|
||||
}
|
||||
NbtCompound nbt = new NbtCompound();
|
||||
nbt.put("CustomPotionEffects", effects);
|
||||
stack.setNbt(nbt);
|
||||
stack.setCustomName(new LiteralText("Lingering Potion of Trolling"));
|
||||
return stack;
|
||||
});
|
||||
|
||||
PRESETS.put("32k", (preview) -> {
|
||||
if (preview) return Items.DIAMOND_SWORD.getDefaultStack();
|
||||
ItemStack stack =Items.DIAMOND_SWORD.getDefaultStack();
|
||||
NbtList enchants = new NbtList();
|
||||
addEnchant(enchants, "minecraft:sharpness");
|
||||
addEnchant(enchants, "minecraft:knockback");
|
||||
addEnchant(enchants, "minecraft:fire_aspect");
|
||||
addEnchant(enchants, "minecraft:looting", (short)10);
|
||||
addEnchant(enchants, "minecraft:sweeping", (short)3);
|
||||
addEnchant(enchants, "minecraft:unbreaking");
|
||||
addEnchant(enchants, "minecraft:mending", (short)1);
|
||||
addEnchant(enchants, "minecraft:vanishing_curse", (short)1);
|
||||
NbtCompound nbt = new NbtCompound();
|
||||
nbt.put("Enchantments", enchants);
|
||||
stack.setNbt(nbt);
|
||||
stack.setCustomName(new LiteralText("Bonk"));
|
||||
return stack;
|
||||
});
|
||||
|
||||
PRESETS.put("crash_chest", (preview) -> {
|
||||
if (preview) return Items.CHEST.getDefaultStack();
|
||||
ItemStack stack = Items.CHEST.getDefaultStack();
|
||||
NbtCompound nbtCompound = new NbtCompound();
|
||||
NbtList nbtList = new NbtList();
|
||||
for(int i = 0; i < 40000; i++)
|
||||
nbtList.add(new NbtList());
|
||||
nbtCompound.put("nothingsuspicioushere", nbtList);
|
||||
stack.setNbt(nbtCompound);
|
||||
stack.setCustomName(new LiteralText("Copy Me"));
|
||||
return stack;
|
||||
});
|
||||
|
||||
PRESETS.put("firework", (preview) -> {
|
||||
if (preview) return Items.FIREWORK_ROCKET.getDefaultStack();
|
||||
|
||||
ItemStack firework = new ItemStack(Items.FIREWORK_ROCKET);
|
||||
NbtCompound baseCompound = new NbtCompound();
|
||||
NbtCompound tagCompound = new NbtCompound();
|
||||
NbtList explosionList = new NbtList();
|
||||
for(int i = 0; i < 5000; i++)
|
||||
{
|
||||
NbtCompound explosionCompound = new NbtCompound();
|
||||
explosionCompound.putByte("Type", (byte)random.nextInt(5));
|
||||
|
||||
int colors[] = {1973019,11743532,3887386,5320730,2437522,8073150,2651799,11250603,4408131,14188952,4312372,14602026,6719955,12801229,15435844,15790320};
|
||||
|
||||
explosionCompound.putIntArray("Colors", colors);
|
||||
explosionList.add(explosionCompound);
|
||||
}
|
||||
tagCompound.putInt("Flight", 0);
|
||||
tagCompound.put("Explosions", explosionList);
|
||||
baseCompound.put("Fireworks", tagCompound);
|
||||
firework.setNbt(baseCompound);
|
||||
return firework;
|
||||
});
|
||||
|
||||
HIDDEN_ENTITIES.forEach((id) -> {
|
||||
PRESETS.put(id.getPath()+"_spawn_egg", (preview) -> {
|
||||
if (preview) return Items.PIG_SPAWN_EGG.getDefaultStack();
|
||||
ItemStack egg = Items.PIG_SPAWN_EGG.getDefaultStack();
|
||||
NbtCompound tag = new NbtCompound();
|
||||
NbtCompound entityTag = new NbtCompound();
|
||||
entityTag.putString("id", id.toString());
|
||||
tag.put("EntityTag", entityTag);
|
||||
egg.setNbt(tag);
|
||||
egg.setCustomName(new LiteralText(String.format("%s", toName(id.getPath()))));
|
||||
return egg;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public static ItemStack getPreset(String name, boolean preview) {
|
||||
return PRESETS.get(name).apply(preview);
|
||||
}
|
||||
|
||||
public static ItemStack getPreset(String name) {
|
||||
return getPreset(name, false);
|
||||
}
|
||||
|
||||
private static String toName(Object id) {
|
||||
return WordUtils.capitalizeFully(id.toString().replace("_", " "));
|
||||
}
|
||||
|
||||
private static void addEnchant(NbtList tag, String id, short v) {
|
||||
NbtCompound enchant = new NbtCompound();
|
||||
enchant.putShort("lvl", v);
|
||||
enchant.putString("id", id);
|
||||
tag.add(enchant);
|
||||
}
|
||||
|
||||
private static void addEnchant(NbtList tag, String id) {
|
||||
addEnchant(tag, id, Short.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
78
src/main/java/anticope/rejects/utils/RejectsConfig.java
Normal file
78
src/main/java/anticope/rejects/utils/RejectsConfig.java
Normal file
@@ -0,0 +1,78 @@
|
||||
package anticope.rejects.utils;
|
||||
|
||||
import meteordevelopment.meteorclient.systems.System;
|
||||
import meteordevelopment.meteorclient.systems.modules.Module;
|
||||
import meteordevelopment.meteorclient.systems.modules.Modules;
|
||||
import meteordevelopment.meteorclient.MeteorClient;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.nbt.NbtElement;
|
||||
import net.minecraft.nbt.NbtList;
|
||||
import net.minecraft.nbt.NbtString;
|
||||
|
||||
public class RejectsConfig extends System<RejectsConfig> {
|
||||
private static final RejectsConfig INSTANCE = new RejectsConfig();
|
||||
|
||||
public enum HttpAllowed {
|
||||
Everything,
|
||||
NotMeteorApi,
|
||||
NotMeteorPing,
|
||||
Nothing
|
||||
}
|
||||
|
||||
public HttpAllowed httpAllowed = HttpAllowed.Everything;
|
||||
public Set<String> hiddenModules = new HashSet<String>();
|
||||
|
||||
public RejectsConfig() {
|
||||
super("rejects-config");
|
||||
init();
|
||||
load(MeteorClient.FOLDER);
|
||||
}
|
||||
|
||||
public static RejectsConfig get() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public void setHiddenModules(List<Module> newList) {
|
||||
for (Module module : newList) {
|
||||
if (module.isActive()) module.toggle();
|
||||
hiddenModules.add(module.name);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Module> getHiddenModules() {
|
||||
Modules modules = Modules.get();
|
||||
if (modules == null) return Arrays.asList();
|
||||
return hiddenModules.stream().map(modules::get).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public NbtCompound toTag() {
|
||||
NbtCompound tag = new NbtCompound();
|
||||
tag.putString("httpAllowed", httpAllowed.toString());
|
||||
|
||||
NbtList modulesTag = new NbtList();
|
||||
for (String module : hiddenModules) modulesTag.add(NbtString.of(module));
|
||||
tag.put("hiddenModules", modulesTag);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RejectsConfig fromTag(NbtCompound tag) {
|
||||
httpAllowed = HttpAllowed.valueOf(tag.getString("httpAllowed"));
|
||||
|
||||
NbtList valueTag = tag.getList("hiddenModules", 8);
|
||||
for (NbtElement tagI : valueTag) {
|
||||
hiddenModules.add(tagI.asString());
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
32
src/main/java/anticope/rejects/utils/RejectsUtils.java
Normal file
32
src/main/java/anticope/rejects/utils/RejectsUtils.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package anticope.rejects.utils;
|
||||
|
||||
import anticope.rejects.utils.seeds.Seeds;
|
||||
import meteordevelopment.meteorclient.MeteorClient;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
public class RejectsUtils {
|
||||
public static int CPS = 0;
|
||||
|
||||
public static void init() {
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||
RejectsConfig.get().save(MeteorClient.FOLDER);
|
||||
Seeds.get().save(MeteorClient.FOLDER);
|
||||
}));
|
||||
|
||||
new Timer().scheduleAtFixedRate(newTimerTaskFromLambda(() -> CPS = 0), 0, 1000);
|
||||
}
|
||||
|
||||
public static TimerTask newTimerTaskFromLambda(Runnable runnable)
|
||||
{
|
||||
return new TimerTask()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
runnable.run();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
37
src/main/java/anticope/rejects/utils/TntDamage.java
Normal file
37
src/main/java/anticope/rejects/utils/TntDamage.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package anticope.rejects.utils;
|
||||
|
||||
import meteordevelopment.meteorclient.utils.Utils;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class TntDamage {
|
||||
public static int calculate(BlockPos bp) {
|
||||
if (!Utils.canUpdate()) return 0;
|
||||
int score = 0;
|
||||
|
||||
for(int j = -5; j <= 5; ++j) {
|
||||
for(int k = -5; k <= 5; ++k) {
|
||||
for(int l = -5; l <= 5; ++l) {
|
||||
BlockPos blockPos = new BlockPos(j, k, l);
|
||||
BlockState blockState = Utils.mc.world.getBlockState(blockPos);
|
||||
FluidState fluidState = Utils.mc.world.getFluidState(blockPos);
|
||||
|
||||
float h = 2.8F;
|
||||
Optional<Float> optional = blockState.isAir() && fluidState.isEmpty() ? Optional.empty() : Optional.of(Math.max(blockState.getBlock().getBlastResistance(), fluidState.getBlastResistance()));;
|
||||
if (optional.isPresent()) {
|
||||
h -= (optional.get() + 0.3F) * 0.3F;
|
||||
}
|
||||
|
||||
if (h > 0.0F) {
|
||||
score++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return score;
|
||||
}
|
||||
}
|
||||
349
src/main/java/anticope/rejects/utils/WorldGenUtils.java
Normal file
349
src/main/java/anticope/rejects/utils/WorldGenUtils.java
Normal file
@@ -0,0 +1,349 @@
|
||||
package anticope.rejects.utils;
|
||||
|
||||
import anticope.rejects.utils.seeds.Seed;
|
||||
import anticope.rejects.utils.seeds.Seeds;
|
||||
import baritone.api.BaritoneAPI;
|
||||
import kaptainwutax.biomeutils.source.BiomeSource;
|
||||
import kaptainwutax.featureutils.misc.SlimeChunk;
|
||||
import kaptainwutax.featureutils.structure.*;
|
||||
import kaptainwutax.mcutils.rand.ChunkRand;
|
||||
import kaptainwutax.mcutils.state.Dimension;
|
||||
import kaptainwutax.mcutils.util.data.SpiralIterator;
|
||||
import kaptainwutax.mcutils.util.pos.*;
|
||||
import kaptainwutax.mcutils.version.MCVersion;
|
||||
import kaptainwutax.terrainutils.TerrainGenerator;
|
||||
import meteordevelopment.meteorclient.utils.player.ChatUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.mob.*;
|
||||
import net.minecraft.entity.passive.IronGolemEntity;
|
||||
import net.minecraft.entity.passive.VillagerEntity;
|
||||
import net.minecraft.entity.vehicle.ChestMinecartEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.nbt.*;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import static meteordevelopment.meteorclient.utils.Utils.mc;
|
||||
|
||||
public class WorldGenUtils {
|
||||
|
||||
private static final Logger LOG = LogManager.getLogger();
|
||||
|
||||
private static final HashMap<Feature, List<Block>> FEATURE_BLOCKS = new HashMap<>(){{
|
||||
put(Feature.nether_fortress, Arrays.asList(
|
||||
Blocks.NETHER_BRICKS,
|
||||
Blocks.NETHER_BRICK_FENCE,
|
||||
Blocks.NETHER_WART
|
||||
));
|
||||
put(Feature.ocean_monument, Arrays.asList(
|
||||
Blocks.PRISMARINE_BRICKS,
|
||||
Blocks.SEA_LANTERN,
|
||||
Blocks.DARK_PRISMARINE
|
||||
));
|
||||
put(Feature.stronghold, Arrays.asList(
|
||||
Blocks.END_PORTAL_FRAME,
|
||||
Blocks.END_PORTAL
|
||||
));
|
||||
put(Feature.end_city, Arrays.asList(
|
||||
Blocks.PURPUR_BLOCK,
|
||||
Blocks.PURPUR_PILLAR,
|
||||
Blocks.PURPUR_STAIRS,
|
||||
Blocks.END_ROD
|
||||
));
|
||||
put(Feature.village, Arrays.asList(
|
||||
Blocks.BELL,
|
||||
Blocks.BREWING_STAND,
|
||||
Blocks.SMOKER,
|
||||
Blocks.BLAST_FURNACE,
|
||||
Blocks.FLETCHING_TABLE,
|
||||
Blocks.STONECUTTER,
|
||||
Blocks.LOOM,
|
||||
Blocks.GRINDSTONE,
|
||||
Blocks.LECTERN
|
||||
));
|
||||
put(Feature.mineshaft, Collections.singletonList(
|
||||
Blocks.RAIL
|
||||
));
|
||||
put(Feature.desert_pyramid, Arrays.asList(
|
||||
Blocks.TNT,
|
||||
Blocks.CHISELED_SANDSTONE,
|
||||
Blocks.STONE_PRESSURE_PLATE
|
||||
));
|
||||
}};
|
||||
|
||||
private static final HashMap<Feature, List<Class<? extends Entity>>> FEATURE_ENTITIES = new HashMap<>(){{
|
||||
put(Feature.ocean_monument, Arrays.asList(
|
||||
ElderGuardianEntity.class,
|
||||
GuardianEntity.class
|
||||
));
|
||||
put(Feature.nether_fortress, Arrays.asList(
|
||||
BlazeEntity.class,
|
||||
WitherSkeletonEntity.class
|
||||
));
|
||||
put(Feature.mansion, Collections.singletonList(
|
||||
EvokerEntity.class
|
||||
));
|
||||
put(Feature.slime_chunk, Collections.singletonList(
|
||||
SlimeEntity.class
|
||||
));
|
||||
put(Feature.bastion_remnant, Collections.singletonList(
|
||||
PiglinBruteEntity.class
|
||||
));
|
||||
put(Feature.end_city, Collections.singletonList(
|
||||
ShulkerEntity.class
|
||||
));
|
||||
put(Feature.village, Arrays.asList(
|
||||
VillagerEntity.class,
|
||||
IronGolemEntity.class
|
||||
));
|
||||
put(Feature.mineshaft, Collections.singletonList(
|
||||
ChestMinecartEntity.class
|
||||
));
|
||||
}};
|
||||
|
||||
public enum Feature {
|
||||
buried_treasure,
|
||||
mansion,
|
||||
stronghold,
|
||||
nether_fortress,
|
||||
ocean_monument,
|
||||
bastion_remnant,
|
||||
end_city,
|
||||
village,
|
||||
mineshaft,
|
||||
slime_chunk,
|
||||
desert_pyramid
|
||||
}
|
||||
|
||||
public static BlockPos locateFeature(Feature feature, BlockPos center) {
|
||||
Seed seed = Seeds.get().getSeed();
|
||||
BlockPos pos = null;
|
||||
if (seed != null) {
|
||||
try {
|
||||
pos = locateFeature(seed, feature, center);
|
||||
} catch (Exception | Error ex) {
|
||||
LOG.error(ex);
|
||||
}
|
||||
if (pos != null) return pos;
|
||||
}
|
||||
if (mc.player != null) {
|
||||
ItemStack stack = mc.player.getStackInHand(Hand.MAIN_HAND);
|
||||
if (stack.getItem() != Items.FILLED_MAP)
|
||||
stack = mc.player.getStackInHand(Hand.OFF_HAND);
|
||||
if (stack.getItem() == Items.FILLED_MAP) {
|
||||
try {
|
||||
pos = locateFeatureMap(feature, stack);
|
||||
} catch (Exception | Error ex) {
|
||||
LOG.error(ex);
|
||||
}
|
||||
if (pos != null) return pos;
|
||||
}
|
||||
}
|
||||
try {
|
||||
pos = locateFeatureEntities(feature);
|
||||
} catch (Exception | Error ex) {
|
||||
LOG.error(ex);
|
||||
}
|
||||
if (pos != null) return pos;
|
||||
try {
|
||||
pos = locateFeatureBlocks(feature);
|
||||
} catch (Exception | Error ex) {
|
||||
LOG.error(ex);
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
private static BlockPos locateFeatureMap(Feature feature, ItemStack stack) {
|
||||
if (!isValidMap(feature, stack)) return null;
|
||||
return getMapMarker(stack);
|
||||
}
|
||||
|
||||
private static BlockPos locateFeatureBlocks(Feature feature) {
|
||||
List<Block> blocks = FEATURE_BLOCKS.get(feature);
|
||||
if (blocks == null) return null;
|
||||
List<BlockPos> posList = BaritoneAPI
|
||||
.getProvider()
|
||||
.getWorldScanner()
|
||||
.scanChunkRadius(
|
||||
BaritoneAPI
|
||||
.getProvider()
|
||||
.getPrimaryBaritone()
|
||||
.getPlayerContext(),
|
||||
blocks,64,10,32);
|
||||
if (posList.isEmpty()) return null;
|
||||
if (posList.size() < 5) {
|
||||
ChatUtils.warning("Locate", "Only %d block(s) found. This search might be a false positive.", posList.size());
|
||||
}
|
||||
return posList.get(0);
|
||||
}
|
||||
|
||||
private static BlockPos locateFeatureEntities(Feature feature) {
|
||||
List<Class<? extends Entity>> entities = FEATURE_ENTITIES.get(feature);
|
||||
if (entities == null) return null;
|
||||
if (mc.world == null) return null;
|
||||
for (Entity e: mc.world.getEntities()) {
|
||||
for (Class<? extends Entity> clazz: entities) {
|
||||
if (clazz.isInstance(e))
|
||||
return e.getBlockPos();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static BlockPos locateFeature(Seed seed, Feature feature, BlockPos center) {
|
||||
if (feature == Feature.slime_chunk) return locateSlimeChunk(seed, center);
|
||||
return locateStructure(seed, feature, center);
|
||||
}
|
||||
|
||||
private static BlockPos locateSlimeChunk(Seed seed, BlockPos center) {
|
||||
Dimension dimension = getDimension(Feature.slime_chunk);
|
||||
MCVersion mcVersion = seed.version;
|
||||
CPos centerChunk = new CPos(center.getX() >> 4, center.getZ() >> 4);
|
||||
CPos slimeChunkPos = locateSlimeChunk(new SlimeChunk(mcVersion), centerChunk, 6400, seed.seed, new ChunkRand(), dimension);
|
||||
if (slimeChunkPos == null) return null;
|
||||
return toBlockPos(slimeChunkPos.toBlockPos());
|
||||
}
|
||||
|
||||
private static CPos locateSlimeChunk(SlimeChunk slimeChunk, CPos centerChunk, int radius, long seed, ChunkRand rand, Dimension dimension) {
|
||||
if (!slimeChunk.isValidDimension(dimension))
|
||||
return null;
|
||||
SpiralIterator<CPos> spiralIterator = new SpiralIterator<>(centerChunk, new CPos(radius, radius), (x, y, z) -> new CPos(x, z));
|
||||
for (CPos next : spiralIterator) {
|
||||
SlimeChunk.Data data = slimeChunk.at(next.getX(), next.getZ(), true);
|
||||
if (data.testStart(seed, rand)) {
|
||||
return next;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static BlockPos locateStructure(Seed seed, Feature feature, BlockPos center) {
|
||||
Dimension dimension = getDimension(feature);
|
||||
MCVersion mcVersion = seed.version;
|
||||
Structure<?, ?> structure = getStructure(feature, mcVersion);
|
||||
if (structure == null) return null;
|
||||
BiomeSource biomeSource = BiomeSource.of(dimension, mcVersion, seed.seed);
|
||||
if (!structure.isValidDimension(biomeSource.getDimension()))
|
||||
return null;
|
||||
BPos structurePos = locateStructure(structure, new BPos(center.getX(), center.getY(), center.getZ()), 6400, new ChunkRand(), biomeSource, TerrainGenerator.of(biomeSource));
|
||||
if (structurePos == null) return null;
|
||||
return toBlockPos(structurePos);
|
||||
}
|
||||
|
||||
private static BPos locateStructure(Structure<?, ?> structure, BPos center, int radius, ChunkRand chunkRand, BiomeSource source, TerrainGenerator terrainGenerator) {
|
||||
if (structure instanceof RegionStructure<?, ?> regionStructure) {
|
||||
int chunkInRegion = regionStructure.getSpacing();
|
||||
int regionSize = chunkInRegion * 16;
|
||||
|
||||
final int border = 30_000_000;
|
||||
SpiralIterator<RPos> spiralIterator = new SpiralIterator<>(center.toRegionPos(regionSize), new BPos(-border, 0, -border).toRegionPos(regionSize), new BPos(border, 0, border).toRegionPos(regionSize), 1, (x, y, z) -> new RPos(x, z, regionSize));
|
||||
return StreamSupport.stream(spiralIterator.spliterator(), false)
|
||||
.map(rPos -> regionStructure.getInRegion(source.getWorldSeed(), rPos.getX(), rPos.getZ(), chunkRand))
|
||||
.filter(Objects::nonNull)
|
||||
.filter(cPos -> (regionStructure.canSpawn(cPos, source)) && (terrainGenerator == null || regionStructure.canGenerate(cPos, terrainGenerator)))
|
||||
.findAny().map(cPos -> cPos.toBlockPos().add(9, 0, 9)).orElse(null);
|
||||
} else {
|
||||
if (structure instanceof Stronghold strongholdStructure) {
|
||||
CPos currentChunkPos = center.toChunkPos();
|
||||
int squaredDistance = Integer.MAX_VALUE;
|
||||
CPos closest = new CPos(0, 0);
|
||||
for (CPos stronghold : strongholdStructure.getAllStarts(source, chunkRand)) {
|
||||
int newSquaredDistance = (currentChunkPos.getX() - stronghold.getX()) * (currentChunkPos.getX() - stronghold.getX()) + (currentChunkPos.getZ() - stronghold.getZ()) * (currentChunkPos.getZ() - stronghold.getZ());
|
||||
if (newSquaredDistance < squaredDistance) {
|
||||
squaredDistance = newSquaredDistance;
|
||||
closest = stronghold;
|
||||
}
|
||||
}
|
||||
BPos dimPos = closest.toBlockPos().add(9, 0, 9);
|
||||
return new BPos(dimPos.getX(), 0, dimPos.getZ());
|
||||
} else if (structure instanceof Mineshaft mineshaft) {
|
||||
SpiralIterator<CPos> spiralIterator = new SpiralIterator<>(new CPos(center.getX() >> 4, center.getZ() >> 4), new CPos(radius, radius), (x, y, z) -> new CPos(x, z));
|
||||
|
||||
return StreamSupport.stream(spiralIterator.spliterator(), false)
|
||||
.filter(cPos -> {
|
||||
kaptainwutax.featureutils.Feature.Data<Mineshaft> data = mineshaft.at(cPos.getX(), cPos.getZ());
|
||||
return data.testStart(source.getWorldSeed(), chunkRand) && data.testBiome(source) && data.testGenerate(terrainGenerator);
|
||||
})
|
||||
.findAny().map(cPos -> cPos.toBlockPos().add(9, 0, 9)).orElse(null);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Dimension getDimension(Feature feature) {
|
||||
switch (feature) {
|
||||
case buried_treasure -> { return Dimension.OVERWORLD; }
|
||||
case mansion -> { return Dimension.OVERWORLD; }
|
||||
case stronghold -> { return Dimension.OVERWORLD; }
|
||||
case nether_fortress -> { return Dimension.NETHER; }
|
||||
case ocean_monument -> { return Dimension.OVERWORLD; }
|
||||
case bastion_remnant -> { return Dimension.NETHER; }
|
||||
case slime_chunk -> { return Dimension.OVERWORLD; }
|
||||
case village -> { return Dimension.OVERWORLD; }
|
||||
case mineshaft -> { return Dimension.OVERWORLD; }
|
||||
case end_city -> { return Dimension.END; }
|
||||
case desert_pyramid -> { return Dimension.OVERWORLD; }
|
||||
default -> { return Dimension.OVERWORLD; }
|
||||
}
|
||||
}
|
||||
|
||||
private static Structure<?, ?> getStructure(Feature feature, MCVersion version) {
|
||||
switch (feature) {
|
||||
case buried_treasure -> { return new BuriedTreasure(version); }
|
||||
case mansion -> { return new Mansion(version); }
|
||||
case stronghold -> { return new Stronghold(version); }
|
||||
case nether_fortress -> { return new Fortress(version); }
|
||||
case ocean_monument -> { return new Monument(version); }
|
||||
case bastion_remnant -> { return new BastionRemnant(version); }
|
||||
case end_city -> { return new EndCity(version); }
|
||||
case village -> { return new Village(version); }
|
||||
case mineshaft -> { return new Mineshaft(version); }
|
||||
case desert_pyramid -> { return new DesertPyramid(version); }
|
||||
default -> { return null;}
|
||||
}
|
||||
}
|
||||
|
||||
private static BlockPos toBlockPos(BPos pos) {
|
||||
return new BlockPos(pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
private static boolean isValidMap(Feature feature, ItemStack stack) {
|
||||
if (!stack.hasNbt()) return false;
|
||||
if (!stack.getNbt().contains("display")) return false;
|
||||
NbtCompound displayTag = stack.getNbt().getCompound("display");
|
||||
if (!displayTag.contains("Name")) return false;
|
||||
String nameTag = displayTag.getString("Name");
|
||||
if (!nameTag.contains("translate")) return false;
|
||||
|
||||
if (feature == Feature.buried_treasure) {
|
||||
return nameTag.contains("filled_map.buried_treasure");
|
||||
} else if (feature == Feature.ocean_monument) {
|
||||
return nameTag.contains("filled_map.monument");
|
||||
} else if (feature == Feature.mansion) {
|
||||
return nameTag.contains("filled_map.mansion");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static BlockPos getMapMarker(ItemStack stack) {
|
||||
if (!stack.hasNbt()) return null;
|
||||
if (!stack.getNbt().contains("Decorations")) return null;
|
||||
NbtList decorationsTag = stack.getNbt().getList("Decorations", NbtElement.COMPOUND_TYPE);
|
||||
if (decorationsTag.size() < 1) return null;
|
||||
NbtCompound iconTag = decorationsTag.getCompound(0);
|
||||
return new BlockPos(
|
||||
(int)iconTag.getDouble("x"),
|
||||
(int)iconTag.getDouble("y"),
|
||||
(int)iconTag.getDouble("z")
|
||||
);
|
||||
}
|
||||
}
|
||||
33
src/main/java/anticope/rejects/utils/WorldUtils.java
Normal file
33
src/main/java/anticope/rejects/utils/WorldUtils.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package anticope.rejects.utils;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class WorldUtils {
|
||||
private static final ArrayList<BlockPos> blocks = new ArrayList<>();
|
||||
|
||||
public static List<BlockPos> getSphere(BlockPos centerPos, int radius, int height) {
|
||||
blocks.clear();
|
||||
|
||||
for (int i = centerPos.getX() - radius; i < centerPos.getX() + radius; i++) {
|
||||
for (int j = centerPos.getY() - height; j < centerPos.getY() + height; j++) {
|
||||
for (int k = centerPos.getZ() - radius; k < centerPos.getZ() + radius; k++) {
|
||||
BlockPos pos = new BlockPos(i, j, k);
|
||||
if (distanceBetween(centerPos, pos) <= radius && !blocks.contains(pos)) blocks.add(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return blocks;
|
||||
}
|
||||
|
||||
public static double distanceBetween(BlockPos pos1, BlockPos pos2) {
|
||||
double d = pos1.getX() - pos2.getX();
|
||||
double e = pos1.getY() - pos2.getY();
|
||||
double f = pos1.getZ() - pos2.getZ();
|
||||
return MathHelper.sqrt((float) (d * d + e * e + f * f));
|
||||
}
|
||||
}
|
||||
42
src/main/java/anticope/rejects/utils/gui/GuiUtils.java
Normal file
42
src/main/java/anticope/rejects/utils/gui/GuiUtils.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package anticope.rejects.utils.gui;
|
||||
|
||||
import anticope.rejects.mixin.meteor.GuiRendererAccessor;
|
||||
import meteordevelopment.meteorclient.gui.renderer.GuiRenderer;
|
||||
import meteordevelopment.meteorclient.gui.widgets.WWidget;
|
||||
import meteordevelopment.meteorclient.renderer.Renderer2D;
|
||||
import meteordevelopment.meteorclient.utils.render.color.Color;
|
||||
|
||||
public class GuiUtils {
|
||||
public static void quadRounded(GuiRenderer renderer, double x, double y, double width, double height, Color color, double round, boolean roundTop) {
|
||||
Renderer2D mb = ((GuiRendererAccessor)renderer).getRenderer2D();
|
||||
RoundedRenderer2D.quadRounded(mb, x, y, width, height, color, round, roundTop);
|
||||
}
|
||||
public static void quadRounded(GuiRenderer renderer, double x, double y, double width, double height, Color color, double round) {
|
||||
quadRounded(renderer, x, y, width, height, color, round, true);
|
||||
}
|
||||
public static void quadRounded(GuiRenderer renderer, WWidget widget, Color color, double round) {
|
||||
quadRounded(renderer, widget.x, widget.y, widget.width, widget.height, color, round);
|
||||
}
|
||||
public static void quadOutlineRounded(GuiRenderer renderer, double x, double y, double width, double height, Color color, double round, double s) {
|
||||
Renderer2D mb = ((GuiRendererAccessor)renderer).getRenderer2D();
|
||||
RoundedRenderer2D.quadRoundedOutline(mb, x, y, width, height, color, round, s);
|
||||
}
|
||||
public static void quadOutlineRounded(GuiRenderer renderer, WWidget widget, Color color, double round, double s) {
|
||||
quadOutlineRounded(renderer, widget.x, widget.y, widget.width, widget.height, color, round, s);
|
||||
}
|
||||
public static void quadRoundedSide(GuiRenderer renderer, double x, double y, double width, double height, Color color, double r, boolean right) {
|
||||
Renderer2D mb = ((GuiRendererAccessor)renderer).getRenderer2D();
|
||||
RoundedRenderer2D.quadRoundedSide(mb, x, y, width, height, color, r, right);
|
||||
}
|
||||
public static void quadRoundedSide(GuiRenderer renderer, WWidget widget, Color color, double round, boolean right) {
|
||||
quadRoundedSide(renderer, widget.x, widget.y, widget.width, widget.height, color, round, right);
|
||||
}
|
||||
public static void circlePart(GuiRenderer renderer, double x, double y, double r, double startAngle, double angle, Color color) {
|
||||
Renderer2D mb = ((GuiRendererAccessor)renderer).getRenderer2D();
|
||||
RoundedRenderer2D.circlePart(mb, x, y, r, startAngle, angle, color);
|
||||
}
|
||||
public static void circlePartOutline(GuiRenderer renderer, double x, double y, double r, double startAngle, double angle, Color color, double outlineWidth) {
|
||||
Renderer2D mb = ((GuiRendererAccessor)renderer).getRenderer2D();
|
||||
RoundedRenderer2D.circlePartOutline(mb, x, y, r, startAngle, angle, color, outlineWidth);
|
||||
}
|
||||
}
|
||||
127
src/main/java/anticope/rejects/utils/gui/RoundedRenderer2D.java
Normal file
127
src/main/java/anticope/rejects/utils/gui/RoundedRenderer2D.java
Normal file
@@ -0,0 +1,127 @@
|
||||
package anticope.rejects.utils.gui;
|
||||
|
||||
import meteordevelopment.meteorclient.renderer.Renderer2D;
|
||||
import meteordevelopment.meteorclient.utils.render.color.Color;
|
||||
|
||||
public class RoundedRenderer2D {
|
||||
|
||||
private static final double circleNone = 0;
|
||||
private static final double circleQuarter = Math.PI / 2;
|
||||
private static final double circleHalf = circleQuarter * 2;
|
||||
private static final double circleThreeQuarter = circleQuarter * 3;
|
||||
|
||||
public static void quadRoundedOutline(Renderer2D mb, double x, double y, double width, double height, Color color, double r, double s) {
|
||||
r = getR(r, width, height);
|
||||
if (r <= 0) {
|
||||
mb.quad(x, y, width, s, color);
|
||||
mb.quad(x, y + height - s, width, s, color);
|
||||
mb.quad(x, y + s, s, height - s * 2, color);
|
||||
mb.quad(x + width - s, y + s, s, height - s * 2, color);
|
||||
}
|
||||
else {
|
||||
//top
|
||||
circlePartOutline(mb, x + r, y + r, r, circleThreeQuarter, circleQuarter, color, s);
|
||||
mb.quad(x + r, y, width - r * 2, s, color);
|
||||
circlePartOutline(mb, x + width - r, y + r, r, circleNone, circleQuarter, color, s);
|
||||
//middle
|
||||
mb.quad(x, y + r, s, height - r * 2, color);
|
||||
mb.quad(x + width - s, y + r, s, height - r * 2, color);
|
||||
//bottom
|
||||
circlePartOutline(mb, x + width - r, y + height - r, r, circleQuarter, circleQuarter, color, s);
|
||||
mb.quad(x + r, y + height - s, width - r * 2, s, color);
|
||||
circlePartOutline(mb, x + r, y + height - r, r, circleHalf, circleQuarter, color, s);
|
||||
}
|
||||
}
|
||||
|
||||
public static void quadRounded(Renderer2D mb, double x, double y, double width, double height, Color color, double r, boolean roundTop) {
|
||||
r = getR(r, width, height);
|
||||
if (r <= 0)
|
||||
mb.quad(x, y, width, height, color);
|
||||
else {
|
||||
if (roundTop) {
|
||||
//top
|
||||
circlePart(mb, x + r, y + r, r, circleThreeQuarter, circleQuarter, color);
|
||||
mb.quad(x + r, y, width - 2 * r, r, color);
|
||||
circlePart(mb, x + width - r, y + r, r, circleNone, circleQuarter, color);
|
||||
//middle
|
||||
mb.quad(x, y + r, width, height - 2 * r, color);
|
||||
}
|
||||
else {
|
||||
//middle
|
||||
mb.quad(x, y, width, height - r, color);
|
||||
}
|
||||
//bottom
|
||||
circlePart(mb, x + width - r, y + height - r, r, circleQuarter, circleQuarter, color);
|
||||
mb.quad(x + r, y + height - r, width - 2 * r, r, color);
|
||||
circlePart(mb, x + r, y + height - r, r, circleHalf, circleQuarter, color);
|
||||
}
|
||||
}
|
||||
|
||||
public static void quadRoundedSide(Renderer2D mb, double x, double y, double width, double height, Color color, double r, boolean right) {
|
||||
r = getR(r, width, height);
|
||||
if (r <= 0)
|
||||
mb.quad(x, y, width, height, color);
|
||||
else {
|
||||
if (right) {
|
||||
circlePart(mb, x + width - r, y + r, r, circleNone, circleQuarter, color);
|
||||
circlePart(mb, x + width - r, y + height - r, r, circleQuarter, circleQuarter, color);
|
||||
mb.quad(x, y, width - r, height, color);
|
||||
mb.quad(x + width - r, y + r, r, height - r * 2, color);
|
||||
}
|
||||
else {
|
||||
circlePart(mb, x + r, y + r, r, circleThreeQuarter, circleQuarter, color);
|
||||
circlePart(mb, x + r, y + height - r, r, circleHalf, circleQuarter, color);
|
||||
mb.quad(x + r, y, width - r, height, color);
|
||||
mb.quad(x, y + r, r, height - r * 2, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static double getR(double r, double w, double h) {
|
||||
if (r * 2 > h) {
|
||||
r = h / 2;
|
||||
}
|
||||
if (r * 2 > w) {
|
||||
r = w / 2;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
private static int getCirDepth(double r, double angle) {
|
||||
return Math.max(1, (int)(angle * r / circleQuarter));
|
||||
}
|
||||
|
||||
public static void circlePart(Renderer2D mb, double x, double y, double r, double startAngle, double angle, Color color) {
|
||||
int cirDepth = getCirDepth(r, angle);
|
||||
double cirPart = angle / cirDepth;
|
||||
int center = mb.triangles.vec2(x, y).color(color).next();
|
||||
int prev = vecOnCircle(mb, x, y, r, startAngle, color);
|
||||
for (int i = 1; i < cirDepth + 1; i++) {
|
||||
int next = vecOnCircle(mb, x, y, r, startAngle + cirPart * i, color);
|
||||
mb.triangles.quad(prev, center, next, next);
|
||||
prev = next;
|
||||
}
|
||||
}
|
||||
|
||||
public static void circlePartOutline(Renderer2D mb, double x, double y, double r, double startAngle, double angle, Color color, double outlineWidth) {
|
||||
if (outlineWidth >= r) {
|
||||
circlePart(mb, x, y, r, startAngle, angle, color);
|
||||
return;
|
||||
}
|
||||
int cirDepth = getCirDepth(r, angle);
|
||||
double cirPart = angle / cirDepth;
|
||||
int innerPrev = vecOnCircle(mb, x, y, r - outlineWidth, startAngle, color);
|
||||
int outerPrev = vecOnCircle(mb, x, y, r, startAngle, color);
|
||||
for (int i = 1; i < cirDepth + 1; i++) {
|
||||
int inner = vecOnCircle(mb, x, y, r - outlineWidth, startAngle + cirPart * i, color);
|
||||
int outer = vecOnCircle(mb, x, y, r, startAngle + cirPart * i, color);
|
||||
mb.triangles.quad(inner, innerPrev, outerPrev, outer);
|
||||
innerPrev = inner;
|
||||
outerPrev = outer;
|
||||
}
|
||||
}
|
||||
|
||||
private static int vecOnCircle(Renderer2D mb, double x, double y, double r, double angle, Color color) {
|
||||
return mb.triangles.vec2(x + Math.sin(angle) * r, y - Math.cos(angle) * r).color(color).next();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package anticope.rejects.utils.portscanner;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class PScanRunner {
|
||||
public boolean running = true;
|
||||
public int portsScanned = 0;
|
||||
ExecutorService es;
|
||||
List<Future<PortScannerManager.ScanResult>> futures = new ArrayList<>();
|
||||
Thread runner;
|
||||
|
||||
public PScanRunner(InetAddress address, int threads, int threadDelay, int timeoutMS, Collection<Integer> ports,
|
||||
Consumer<List<PortScannerManager.ScanResult>> callback) {
|
||||
runner = new Thread(() -> {
|
||||
es = Executors.newFixedThreadPool(threads);
|
||||
ports.forEach(port -> {
|
||||
futures.add(isPortOpen(es, address.getHostAddress(), port, timeoutMS, threadDelay));
|
||||
});
|
||||
try {
|
||||
boolean _1 = es.awaitTermination(200L, TimeUnit.MILLISECONDS);
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
List<PortScannerManager.ScanResult> results = new ArrayList<>();
|
||||
for (Future<PortScannerManager.ScanResult> fsc : futures) {
|
||||
try {
|
||||
results.add(fsc.get());
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
callback.accept(results);
|
||||
});
|
||||
runner.start();
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
running = false;
|
||||
}
|
||||
|
||||
private Future<PortScannerManager.ScanResult> isPortOpen(ExecutorService es, String ip, int port, int timeout,
|
||||
int delay) {
|
||||
return es.submit(() -> {
|
||||
if (!running)
|
||||
return new PortScannerManager.ScanResult(port, false);
|
||||
Thread.sleep(delay);
|
||||
portsScanned++;
|
||||
try {
|
||||
//System.out.println(ip + ":" + port);
|
||||
Socket socket = new Socket();
|
||||
socket.connect(new InetSocketAddress(ip, port), timeout);
|
||||
socket.close();
|
||||
return new PortScannerManager.ScanResult(port, true);
|
||||
} catch (Exception exc) {
|
||||
|
||||
return new PortScannerManager.ScanResult(port, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package anticope.rejects.utils.portscanner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PortScannerManager {
|
||||
public static List<PScanRunner> scans = new ArrayList<>();
|
||||
|
||||
public static void killAllScans() {
|
||||
for (PScanRunner runner : scans) {
|
||||
if (runner.running)
|
||||
runner.cancel();
|
||||
}
|
||||
scans.clear();
|
||||
}
|
||||
|
||||
public static class ScanResult {
|
||||
private int port;
|
||||
|
||||
private boolean isOpen;
|
||||
|
||||
public ScanResult(int port, boolean isOpen) {
|
||||
super();
|
||||
this.port = port;
|
||||
this.isOpen = isOpen;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public boolean isOpen() {
|
||||
return isOpen;
|
||||
}
|
||||
|
||||
public void setOpen(boolean isOpen) {
|
||||
this.isOpen = isOpen;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
55
src/main/java/anticope/rejects/utils/seeds/Seed.java
Normal file
55
src/main/java/anticope/rejects/utils/seeds/Seed.java
Normal file
@@ -0,0 +1,55 @@
|
||||
package anticope.rejects.utils.seeds;
|
||||
|
||||
import kaptainwutax.mcutils.version.MCVersion;
|
||||
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.nbt.NbtLong;
|
||||
import net.minecraft.nbt.NbtString;
|
||||
import net.minecraft.text.*;
|
||||
import net.minecraft.util.Formatting;
|
||||
|
||||
public class Seed {
|
||||
public final Long seed;
|
||||
public final MCVersion version;
|
||||
|
||||
public Seed(Long seed, MCVersion version) {
|
||||
this.seed = seed;
|
||||
if (version == null)
|
||||
version = MCVersion.latest();
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public NbtCompound toTag() {
|
||||
NbtCompound tag = new NbtCompound();
|
||||
tag.put("seed", NbtLong.of(seed));
|
||||
tag.put("version", NbtString.of(version.name));
|
||||
return tag;
|
||||
}
|
||||
|
||||
public static Seed fromTag(NbtCompound tag) {
|
||||
return new Seed(
|
||||
tag.getLong("seed"),
|
||||
MCVersion.fromString(tag.getString("version"))
|
||||
);
|
||||
}
|
||||
|
||||
public Text toText() {
|
||||
BaseText text = new LiteralText(String.format("[%s%s%s] (%s)",
|
||||
Formatting.GREEN,
|
||||
seed.toString(),
|
||||
Formatting.WHITE,
|
||||
version.toString()
|
||||
));
|
||||
text.setStyle(text.getStyle()
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.COPY_TO_CLIPBOARD,
|
||||
seed.toString()
|
||||
))
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new LiteralText("Copy to clipboard")
|
||||
))
|
||||
);
|
||||
return text;
|
||||
}
|
||||
}
|
||||
112
src/main/java/anticope/rejects/utils/seeds/Seeds.java
Normal file
112
src/main/java/anticope/rejects/utils/seeds/Seeds.java
Normal file
@@ -0,0 +1,112 @@
|
||||
package anticope.rejects.utils.seeds;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.text.BaseText;
|
||||
import net.minecraft.text.ClickEvent;
|
||||
import net.minecraft.text.HoverEvent;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.util.Formatting;
|
||||
|
||||
import kaptainwutax.mcutils.version.MCVersion;
|
||||
import meteordevelopment.meteorclient.MeteorClient;
|
||||
import meteordevelopment.meteorclient.systems.System;
|
||||
import meteordevelopment.meteorclient.systems.config.Config;
|
||||
import meteordevelopment.meteorclient.utils.Utils;
|
||||
import meteordevelopment.meteorclient.utils.player.ChatUtils;
|
||||
|
||||
import static meteordevelopment.meteorclient.utils.Utils.mc;
|
||||
|
||||
public class Seeds extends System<Seeds> {
|
||||
private static final Seeds INSTANCE = new Seeds();
|
||||
|
||||
public HashMap<String, Seed> seeds = new HashMap<>();
|
||||
|
||||
public Seeds() {
|
||||
super("seeds");
|
||||
init();
|
||||
load(MeteorClient.FOLDER);
|
||||
}
|
||||
|
||||
public static Seeds get() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public Seed getSeed() {
|
||||
if (mc.isIntegratedServerRunning() && mc.getServer() != null) {
|
||||
MCVersion version = MCVersion.fromString(mc.getServer().getVersion());
|
||||
if (version == null)
|
||||
version = MCVersion.latest();
|
||||
return new Seed(mc.getServer().getOverworld().getSeed(), version);
|
||||
}
|
||||
|
||||
return seeds.get(Utils.getWorldName());
|
||||
}
|
||||
|
||||
public void setSeed(String seed, MCVersion version) {
|
||||
if (mc.isIntegratedServerRunning()) return;
|
||||
|
||||
seeds.put(Utils.getWorldName(), new Seed(toSeed(seed), version));
|
||||
}
|
||||
|
||||
public void setSeed(String seed) {
|
||||
if (mc.isIntegratedServerRunning()) return;
|
||||
|
||||
ServerInfo server = mc.getCurrentServerEntry();
|
||||
MCVersion ver = null;
|
||||
if (server != null)
|
||||
ver = MCVersion.fromString(server.version.asString());
|
||||
if (ver == null) {
|
||||
String targetVer = "unknown";
|
||||
if (server != null) targetVer = server.version.asString();
|
||||
sendInvalidVersionWarning(seed, targetVer);
|
||||
ver = MCVersion.latest();
|
||||
}
|
||||
setSeed(seed, ver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NbtCompound toTag() {
|
||||
NbtCompound tag = new NbtCompound();
|
||||
seeds.forEach((key, seed) -> {
|
||||
if (seed == null) return;
|
||||
tag.put(key, seed.toTag());
|
||||
});
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Seeds fromTag(NbtCompound tag) {
|
||||
tag.getKeys().forEach(key -> {
|
||||
seeds.put(key, Seed.fromTag(tag.getCompound(key)));
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
// https://minecraft.fandom.com/wiki/Seed_(level_generation)#Java_Edition
|
||||
private static long toSeed(String inSeed) {
|
||||
try {
|
||||
return Long.parseLong(inSeed);
|
||||
} catch (NumberFormatException e) {
|
||||
return inSeed.hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
private static void sendInvalidVersionWarning(String seed, String targetVer) {
|
||||
BaseText msg = new LiteralText(String.format("Couldn't resolve minecraft version \"%s\". Using %s instead. If you wish to change the version run: ", targetVer, MCVersion.latest().name));
|
||||
String cmd = String.format("%sseed %s ", Config.get().prefix, seed);
|
||||
BaseText cmdText = new LiteralText(cmd+"<version>");
|
||||
cmdText.setStyle(cmdText.getStyle()
|
||||
.withUnderline(true)
|
||||
.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, cmd))
|
||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText("run command")))
|
||||
);
|
||||
msg.append(cmdText);
|
||||
msg.setStyle(msg.getStyle()
|
||||
.withColor(Formatting.YELLOW)
|
||||
);
|
||||
ChatUtils.sendMsg("Seed", msg);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user