fix #31 **seeds saved b4 can have wrong versions**
This commit is contained in:
@@ -59,8 +59,8 @@ public class SeedCommand extends Command {
|
|||||||
return SINGLE_SUCCESS;
|
return SINGLE_SUCCESS;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
builder.then(argument("seed", LongArgumentType.longArg()).then(argument("version", EnumArgumentType.enumArgument(MCVersion.v1_17_1)).executes(ctx -> {
|
builder.then(argument("seed", LongArgumentType.longArg()).then(argument("version", EnumArgumentType.enumArgument(MCVersion.latest())).executes(ctx -> {
|
||||||
Seeds.get().setSeed(LongArgumentType.getLong(ctx, "seed"), EnumArgumentType.getEnum(ctx, "version", MCVersion.v1_17_1));
|
Seeds.get().setSeed(LongArgumentType.getLong(ctx, "seed"), EnumArgumentType.getEnum(ctx, "version", MCVersion.latest()));
|
||||||
return SINGLE_SUCCESS;
|
return SINGLE_SUCCESS;
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class ServerCommand extends Command {
|
|||||||
private final static SimpleCommandExceptionType ADDRESS_ERROR = new SimpleCommandExceptionType(new LiteralText("Couldn't obtain server address"));
|
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 SimpleCommandExceptionType INVALID_RANGE = new SimpleCommandExceptionType(new LiteralText("Invalid range"));
|
||||||
|
|
||||||
private final static HashMap<Integer, String> ports = new HashMap();
|
private final static HashMap<Integer, String> ports = new HashMap<Integer, String>();
|
||||||
|
|
||||||
public ServerCommand() {
|
public ServerCommand() {
|
||||||
super("server", "Prints server information");
|
super("server", "Prints server information");
|
||||||
|
|||||||
@@ -29,10 +29,15 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.StreamSupport;
|
import java.util.stream.StreamSupport;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import static meteordevelopment.meteorclient.utils.Utils.mc;
|
import static meteordevelopment.meteorclient.utils.Utils.mc;
|
||||||
|
|
||||||
public class WorldGenUtils {
|
public class WorldGenUtils {
|
||||||
|
|
||||||
|
private static final Logger LOG = LogManager.getLogger();
|
||||||
|
|
||||||
private static final HashMap<Feature, List<Block>> FEATURE_BLOCKS = new HashMap<>(){{
|
private static final HashMap<Feature, List<Block>> FEATURE_BLOCKS = new HashMap<>(){{
|
||||||
put(Feature.nether_fortress, Arrays.asList(
|
put(Feature.nether_fortress, Arrays.asList(
|
||||||
Blocks.NETHER_BRICKS,
|
Blocks.NETHER_BRICKS,
|
||||||
@@ -123,7 +128,11 @@ public class WorldGenUtils {
|
|||||||
Seed seed = Seeds.get().getSeed();
|
Seed seed = Seeds.get().getSeed();
|
||||||
BlockPos pos = null;
|
BlockPos pos = null;
|
||||||
if (seed != null) {
|
if (seed != null) {
|
||||||
pos = locateFeature(seed, feature, center);
|
try {
|
||||||
|
pos = locateFeature(seed, feature, center);
|
||||||
|
} catch (Exception | Error ex) {
|
||||||
|
LOG.error(ex);
|
||||||
|
}
|
||||||
if (pos != null) return pos;
|
if (pos != null) return pos;
|
||||||
}
|
}
|
||||||
if (mc.player != null) {
|
if (mc.player != null) {
|
||||||
@@ -131,13 +140,25 @@ public class WorldGenUtils {
|
|||||||
if (stack.getItem() != Items.FILLED_MAP)
|
if (stack.getItem() != Items.FILLED_MAP)
|
||||||
stack = mc.player.getStackInHand(Hand.OFF_HAND);
|
stack = mc.player.getStackInHand(Hand.OFF_HAND);
|
||||||
if (stack.getItem() == Items.FILLED_MAP) {
|
if (stack.getItem() == Items.FILLED_MAP) {
|
||||||
pos = locateFeatureMap(feature, stack);
|
try {
|
||||||
|
pos = locateFeatureMap(feature, stack);
|
||||||
|
} catch (Exception | Error ex) {
|
||||||
|
LOG.error(ex);
|
||||||
|
}
|
||||||
if (pos != null) return pos;
|
if (pos != null) return pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pos = locateFeatureEntities(feature);
|
try {
|
||||||
|
pos = locateFeatureEntities(feature);
|
||||||
|
} catch (Exception | Error ex) {
|
||||||
|
LOG.error(ex);
|
||||||
|
}
|
||||||
if (pos != null) return pos;
|
if (pos != null) return pos;
|
||||||
pos = locateFeatureBlocks(feature);
|
try {
|
||||||
|
pos = locateFeatureBlocks(feature);
|
||||||
|
} catch (Exception | Error ex) {
|
||||||
|
LOG.error(ex);
|
||||||
|
}
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,6 +204,7 @@ public class WorldGenUtils {
|
|||||||
return locateStructure(seed, feature, center);
|
return locateStructure(seed, feature, center);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Fix LinkageError in SpiralIterator
|
||||||
private static BlockPos locateSlimeChunk(Seed seed, BlockPos center) {
|
private static BlockPos locateSlimeChunk(Seed seed, BlockPos center) {
|
||||||
Dimension dimension = getDimension(Feature.slime_chunk);
|
Dimension dimension = getDimension(Feature.slime_chunk);
|
||||||
MCVersion mcVersion = seed.version;
|
MCVersion mcVersion = seed.version;
|
||||||
@@ -218,6 +240,7 @@ public class WorldGenUtils {
|
|||||||
return toBlockPos(structurePos);
|
return toBlockPos(structurePos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Fix LinkageError in SpiralIterator
|
||||||
private static BPos locateStructure(Structure<?, ?> structure, BPos center, int radius, ChunkRand chunkRand, BiomeSource source, TerrainGenerator terrainGenerator) {
|
private static BPos locateStructure(Structure<?, ?> structure, BPos center, int radius, ChunkRand chunkRand, BiomeSource source, TerrainGenerator terrainGenerator) {
|
||||||
if (structure instanceof RegionStructure<?, ?> regionStructure) {
|
if (structure instanceof RegionStructure<?, ?> regionStructure) {
|
||||||
int chunkInRegion = regionStructure.getSpacing();
|
int chunkInRegion = regionStructure.getSpacing();
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public class RoundedRenderer2D {
|
|||||||
|
|
||||||
public static void quadRoundedOutline(Renderer2D mb, double x, double y, double width, double height, Color color, double r, double s) {
|
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);
|
r = getR(r, width, height);
|
||||||
if (r == 0) {
|
if (r <= 0) {
|
||||||
mb.quad(x, y, width, s, color);
|
mb.quad(x, y, width, s, color);
|
||||||
mb.quad(x, y + height - s, 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, y + s, s, height - s * 2, color);
|
||||||
@@ -35,7 +35,7 @@ public class RoundedRenderer2D {
|
|||||||
|
|
||||||
public static void quadRounded(Renderer2D mb, double x, double y, double width, double height, Color color, double r, boolean roundTop) {
|
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);
|
r = getR(r, width, height);
|
||||||
if (r == 0)
|
if (r <= 0)
|
||||||
mb.quad(x, y, width, height, color);
|
mb.quad(x, y, width, height, color);
|
||||||
else {
|
else {
|
||||||
if (roundTop) {
|
if (roundTop) {
|
||||||
@@ -59,7 +59,7 @@ public class RoundedRenderer2D {
|
|||||||
|
|
||||||
public static void quadRoundedSide(Renderer2D mb, double x, double y, double width, double height, Color color, double r, boolean right) {
|
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);
|
r = getR(r, width, height);
|
||||||
if (r == 0)
|
if (r <= 0)
|
||||||
mb.quad(x, y, width, height, color);
|
mb.quad(x, y, width, height, color);
|
||||||
else {
|
else {
|
||||||
if (right) {
|
if (right) {
|
||||||
|
|||||||
@@ -14,20 +14,22 @@ public class Seed {
|
|||||||
|
|
||||||
public Seed(Long seed, MCVersion version) {
|
public Seed(Long seed, MCVersion version) {
|
||||||
this.seed = seed;
|
this.seed = seed;
|
||||||
|
if (version == null)
|
||||||
|
version = MCVersion.latest();
|
||||||
this.version = version;
|
this.version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NbtCompound toTag() {
|
public NbtCompound toTag() {
|
||||||
NbtCompound tag = new NbtCompound();
|
NbtCompound tag = new NbtCompound();
|
||||||
tag.put("seed", NbtLong.of(seed));
|
tag.put("seed", NbtLong.of(seed));
|
||||||
tag.put("version", NbtString.of(version.name()));
|
tag.put("version", NbtString.of(version.name));
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Seed fromTag(NbtCompound tag) {
|
public static Seed fromTag(NbtCompound tag) {
|
||||||
return new Seed(
|
return new Seed(
|
||||||
tag.getLong("seed"),
|
tag.getLong("seed"),
|
||||||
MCVersion.valueOf(tag.getString("version"))
|
MCVersion.fromString(tag.getString("version"))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,11 +4,18 @@ import java.util.HashMap;
|
|||||||
|
|
||||||
import net.minecraft.client.network.ServerInfo;
|
import net.minecraft.client.network.ServerInfo;
|
||||||
import net.minecraft.nbt.NbtCompound;
|
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 kaptainwutax.mcutils.version.MCVersion;
|
||||||
import meteordevelopment.meteorclient.MeteorClient;
|
import meteordevelopment.meteorclient.MeteorClient;
|
||||||
import meteordevelopment.meteorclient.systems.System;
|
import meteordevelopment.meteorclient.systems.System;
|
||||||
|
import meteordevelopment.meteorclient.systems.config.Config;
|
||||||
import meteordevelopment.meteorclient.utils.Utils;
|
import meteordevelopment.meteorclient.utils.Utils;
|
||||||
|
import meteordevelopment.meteorclient.utils.player.ChatUtils;
|
||||||
|
|
||||||
import static meteordevelopment.meteorclient.utils.Utils.mc;
|
import static meteordevelopment.meteorclient.utils.Utils.mc;
|
||||||
|
|
||||||
@@ -28,8 +35,12 @@ public class Seeds extends System<Seeds> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Seed getSeed() {
|
public Seed getSeed() {
|
||||||
if (mc.isIntegratedServerRunning() && mc.getServer() != null)
|
if (mc.isIntegratedServerRunning() && mc.getServer() != null) {
|
||||||
return new Seed(mc.getServer().getOverworld().getSeed(), MCVersion.fromString(mc.getServer().getVersion()));
|
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());
|
return seeds.get(Utils.getWorldName());
|
||||||
}
|
}
|
||||||
@@ -45,8 +56,13 @@ public class Seeds extends System<Seeds> {
|
|||||||
MCVersion ver = null;
|
MCVersion ver = null;
|
||||||
if (server != null)
|
if (server != null)
|
||||||
ver = MCVersion.fromString(server.version.asString());
|
ver = MCVersion.fromString(server.version.asString());
|
||||||
if (ver == null)
|
if (ver == null) {
|
||||||
|
String targetVer = "unknown";
|
||||||
|
if (server != null) targetVer = server.version.asString();
|
||||||
|
sendInvalidVersionWarning(seed, targetVer);
|
||||||
ver = MCVersion.latest();
|
ver = MCVersion.latest();
|
||||||
|
}
|
||||||
|
|
||||||
setSeed(seed, ver);
|
setSeed(seed, ver);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,4 +83,20 @@ public class Seeds extends System<Seeds> {
|
|||||||
});
|
});
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void sendInvalidVersionWarning(long 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 %d ", 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