fix #31 **seeds saved b4 can have wrong versions**
This commit is contained in:
@@ -29,10 +29,15 @@ 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,
|
||||
@@ -123,7 +128,11 @@ public class WorldGenUtils {
|
||||
Seed seed = Seeds.get().getSeed();
|
||||
BlockPos pos = 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 (mc.player != null) {
|
||||
@@ -131,13 +140,25 @@ public class WorldGenUtils {
|
||||
if (stack.getItem() != Items.FILLED_MAP)
|
||||
stack = mc.player.getStackInHand(Hand.OFF_HAND);
|
||||
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;
|
||||
}
|
||||
}
|
||||
pos = locateFeatureEntities(feature);
|
||||
try {
|
||||
pos = locateFeatureEntities(feature);
|
||||
} catch (Exception | Error ex) {
|
||||
LOG.error(ex);
|
||||
}
|
||||
if (pos != null) return pos;
|
||||
pos = locateFeatureBlocks(feature);
|
||||
try {
|
||||
pos = locateFeatureBlocks(feature);
|
||||
} catch (Exception | Error ex) {
|
||||
LOG.error(ex);
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
@@ -183,6 +204,7 @@ public class WorldGenUtils {
|
||||
return locateStructure(seed, feature, center);
|
||||
}
|
||||
|
||||
// TODO: Fix LinkageError in SpiralIterator
|
||||
private static BlockPos locateSlimeChunk(Seed seed, BlockPos center) {
|
||||
Dimension dimension = getDimension(Feature.slime_chunk);
|
||||
MCVersion mcVersion = seed.version;
|
||||
@@ -218,6 +240,7 @@ public class WorldGenUtils {
|
||||
return toBlockPos(structurePos);
|
||||
}
|
||||
|
||||
// TODO: Fix LinkageError in SpiralIterator
|
||||
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();
|
||||
|
||||
@@ -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) {
|
||||
r = getR(r, width, height);
|
||||
if (r == 0) {
|
||||
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);
|
||||
@@ -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) {
|
||||
r = getR(r, width, height);
|
||||
if (r == 0)
|
||||
if (r <= 0)
|
||||
mb.quad(x, y, width, height, color);
|
||||
else {
|
||||
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) {
|
||||
r = getR(r, width, height);
|
||||
if (r == 0)
|
||||
if (r <= 0)
|
||||
mb.quad(x, y, width, height, color);
|
||||
else {
|
||||
if (right) {
|
||||
|
||||
@@ -14,20 +14,22 @@ public class Seed {
|
||||
|
||||
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()));
|
||||
tag.put("version", NbtString.of(version.name));
|
||||
return tag;
|
||||
}
|
||||
|
||||
public static Seed fromTag(NbtCompound tag) {
|
||||
return new 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.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;
|
||||
|
||||
@@ -28,9 +35,13 @@ public class Seeds extends System<Seeds> {
|
||||
}
|
||||
|
||||
public Seed getSeed() {
|
||||
if (mc.isIntegratedServerRunning() && mc.getServer() != null)
|
||||
return new Seed(mc.getServer().getOverworld().getSeed(), MCVersion.fromString(mc.getServer().getVersion()));
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
@@ -45,8 +56,13 @@ public class Seeds extends System<Seeds> {
|
||||
MCVersion ver = null;
|
||||
if (server != null)
|
||||
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();
|
||||
}
|
||||
|
||||
setSeed(seed, ver);
|
||||
}
|
||||
|
||||
@@ -67,4 +83,20 @@ public class Seeds extends System<Seeds> {
|
||||
});
|
||||
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