Port to MC 1.19-pre3

This commit is contained in:
Jonas Herzig
2022-05-27 07:03:35 +02:00
parent 9f8957f468
commit 9ce25f711f
41 changed files with 299 additions and 98 deletions

View File

@@ -18,7 +18,6 @@ import com.replaymod.replaystudio.studio.ReplayStudio;
import com.replaymod.replaystudio.util.I18n;
import com.replaymod.simplepathing.ReplayModSimplePathing;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.options.Option;
import net.minecraft.resource.DirectoryResourcePack;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Style;
@@ -37,6 +36,11 @@ import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
//#if MC>=11900
//#else
import net.minecraft.client.options.Option;
//#endif
public class ReplayMod implements Module, Scheduler {
public static final String MOD_ID = "replaymod";
@@ -162,7 +166,8 @@ public class ReplayMod implements Module, Scheduler {
keyBindingRegistry.register();
// 1.7.10 crashes when render distance > 16
//#if MC>=10800
// Post 1.19 this has become non-trivial to do, install Sodium+Bobby or OptiFine if you need it
//#if MC>=10800 && MC<11900
if (!MCVer.hasOptifine()) {
Option.RENDER_DISTANCE.setMax(64f);
}

View File

@@ -0,0 +1 @@
// 1.19+

View File

@@ -158,8 +158,12 @@ public class LangResourcePack extends AbstractFileResourcePack {
String namespace,
//#endif
String path,
//#if MC>=11900
//$$ Predicate<Identifier> filter
//#else
int maxDepth,
Predicate<String> filter
//#endif
) {
if (resourcePackType == ResourceType.CLIENT_RESOURCES && "lang".equals(path)) {
Path base = baseLangPath();
@@ -174,8 +178,13 @@ public class LangResourcePack extends AbstractFileResourcePack {
.map(LANG_FILE_NAME_PATTERN::matcher)
.filter(Matcher::matches)
.map(matcher -> String.format("%s_%s.json", matcher.group(1), matcher.group(1)))
.filter(filter::test)
//#if MC<11900
.filter(filter)
//#endif
.map(name -> new Identifier(ReplayMod.MOD_ID, "lang/" + name))
//#if MC>=11900
//$$ .filter(filter)
//#endif
.collect(Collectors.toList());
} catch (IOException e) {
e.printStackTrace();

View File

@@ -34,6 +34,7 @@ import net.minecraft.client.util.Window;
import java.util.concurrent.CompletableFuture;
//#if MC>=11600
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
//#else
//$$ import net.minecraft.client.resource.language.I18n;
@@ -220,7 +221,7 @@ public class MCVer {
//#if MC>=11400
public static Optional<AbstractButtonWidget> findButton(Iterable<AbstractButtonWidget> buttonList, @SuppressWarnings("unused") String text, @SuppressWarnings("unused") int id) {
//#if MC>=11600
final TranslatableText message = new TranslatableText(text);
final Text message = new TranslatableText(text);
//#else
//$$ final String message = I18n.translate(text);
//#endif

View File

@@ -6,6 +6,7 @@ import com.google.common.util.concurrent.ListenableFuture;
import com.replaymod.core.mixin.MinecraftAccessor;
import com.replaymod.gradle.remap.Pattern;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.options.GameOptions;
import net.minecraft.client.options.KeyBinding;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.texture.TextureManager;
@@ -14,6 +15,11 @@ import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.resource.Resource;
import net.minecraft.resource.ResourceManager;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.crash.CrashException;
import net.minecraft.util.crash.CrashReport;
import net.minecraft.util.crash.CrashReportSection;
@@ -61,6 +67,7 @@ import net.minecraft.client.render.BufferBuilder;
//$$ import net.minecraft.entity.EntityLivingBase;
//#endif
import java.io.IOException;
import java.util.Collection;
import java.util.List;
@@ -549,7 +556,9 @@ class Patterns {
@Pattern
private static void setCrashReport(MinecraftClient mc, CrashReport report) {
//#if MC>=11800
//#if MC>=11900
//$$ mc.setCrashReportSupplier(report);
//#elseif MC>=11800
//$$ mc.setCrashReportSupplier(() -> report);
//#else
mc.setCrashReport(report);
@@ -573,4 +582,91 @@ class Patterns {
//$$ return com.replaymod.core.versions.MCVer.getTrackedPosition(entity);
//#endif
}
@Pattern
private static Text newTextLiteral(String str) {
//#if MC>=11900
//$$ return net.minecraft.text.Text.literal(str);
//#else
return new LiteralText(str);
//#endif
}
@Pattern
private static Text newTextTranslatable(String key, Object...args) {
//#if MC>=11900
//$$ return net.minecraft.text.Text.translatable(key, args);
//#else
return new TranslatableText(key, args);
//#endif
}
//#if MC>=11500
@Pattern
private static Vec3d getTrackedPos(Entity entity) {
//#if MC>=11900
//$$ return entity.getTrackedPosition().withDelta(0, 0, 0);
//#else
return entity.getTrackedPosition();
//#endif
}
//#else
//$$ @Pattern private static void getTrackedPos() {}
//#endif
@Pattern
private static void setGamma(GameOptions options, double value) {
//#if MC>=11900
//$$ ((com.replaymod.core.mixin.SimpleOptionAccessor<Double>) (Object) options.getGamma()).setRawValue(value);
//#elseif MC>=11400
options.gamma = value;
//#else
//$$ options.gammaSetting = (float) value;
//#endif
}
@Pattern
private static double getGamma(GameOptions options) {
//#if MC>=11900
//$$ return options.getGamma().getValue();
//#else
return options.gamma;
//#endif
}
@Pattern
private static int getViewDistance(GameOptions options) {
//#if MC>=11900
//$$ return options.getViewDistance().getValue();
//#else
return options.viewDistance;
//#endif
}
@Pattern
private static double getFov(GameOptions options) {
//#if MC>=11900
//$$ return options.getFov().getValue();
//#else
return options.fov;
//#endif
}
@Pattern
private static int getGuiScale(GameOptions options) {
//#if MC>=11900
//$$ return options.getGuiScale().getValue();
//#else
return options.guiScale;
//#endif
}
@Pattern
private static Resource getResource(ResourceManager manager, Identifier id) throws IOException {
//#if MC>=11900
//$$ return manager.getResourceOrThrow(id);
//#else
return manager.getResource(id);
//#endif
}
}