Switch core to 1.14 (generated via ./gradlew :1.14:setCoreVersion)
This commit is contained in:
@@ -4,19 +4,19 @@ import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import de.johni0702.minecraft.gui.utils.EventRegistrations;
|
||||
import com.replaymod.core.versions.MCVer;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.crash.CrashReportCategory;
|
||||
import net.minecraft.crash.ReportedException;
|
||||
import net.minecraft.client.options.KeyBinding;
|
||||
import net.minecraft.util.crash.CrashReport;
|
||||
import net.minecraft.util.crash.CrashReportSection;
|
||||
import net.minecraft.util.crash.CrashException;
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ import com.replaymod.core.versions.LangResourcePack;
|
||||
//$$ import net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding;
|
||||
//$$ import net.minecraft.client.util.InputUtil;
|
||||
//$$ import net.minecraft.util.Identifier;
|
||||
//$$ import static com.replaymod.core.ReplayMod.MOD_ID;
|
||||
import com.replaymod.core.versions.LangResourcePack;
|
||||
import net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding;
|
||||
import net.minecraft.client.util.InputUtil;
|
||||
import net.minecraft.util.Identifier;
|
||||
import static com.replaymod.core.ReplayMod.MOD_ID;
|
||||
//#else
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
//$$ import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
//#endif
|
||||
|
||||
//#if MC>=11300
|
||||
@@ -39,7 +39,7 @@ import java.util.Map;
|
||||
public class KeyBindingRegistry extends EventRegistrations {
|
||||
private static final String CATEGORY = "replaymod.title";
|
||||
//#if MC>=11400
|
||||
//$$ static { net.fabricmc.fabric.api.client.keybinding.KeyBindingRegistry.INSTANCE.addCategory(CATEGORY); }
|
||||
static { net.fabricmc.fabric.api.client.keybinding.KeyBindingRegistry.INSTANCE.addCategory(CATEGORY); }
|
||||
//#endif
|
||||
|
||||
private Map<String, KeyBinding> keyBindings = new HashMap<String, KeyBinding>();
|
||||
@@ -59,16 +59,16 @@ public class KeyBindingRegistry extends EventRegistrations {
|
||||
KeyBinding keyBinding = keyBindings.get(name);
|
||||
if (keyBinding == null) {
|
||||
//#if MC>=11400
|
||||
//$$ if (keyCode == 0) {
|
||||
//$$ keyCode = -1;
|
||||
//$$ }
|
||||
//$$ Identifier id = new Identifier(MOD_ID, name.substring(LangResourcePack.LEGACY_KEY_PREFIX.length()));
|
||||
//$$ FabricKeyBinding fabricKeyBinding = FabricKeyBinding.Builder.create(id, InputUtil.Type.KEYSYM, keyCode, CATEGORY).build();
|
||||
//$$ net.fabricmc.fabric.api.client.keybinding.KeyBindingRegistry.INSTANCE.register(fabricKeyBinding);
|
||||
//$$ keyBinding = fabricKeyBinding;
|
||||
if (keyCode == 0) {
|
||||
keyCode = -1;
|
||||
}
|
||||
Identifier id = new Identifier(MOD_ID, name.substring(LangResourcePack.LEGACY_KEY_PREFIX.length()));
|
||||
FabricKeyBinding fabricKeyBinding = FabricKeyBinding.Builder.create(id, InputUtil.Type.KEYSYM, keyCode, CATEGORY).build();
|
||||
net.fabricmc.fabric.api.client.keybinding.KeyBindingRegistry.INSTANCE.register(fabricKeyBinding);
|
||||
keyBinding = fabricKeyBinding;
|
||||
//#else
|
||||
keyBinding = new KeyBinding(name, keyCode, CATEGORY);
|
||||
ClientRegistry.registerKeyBinding(keyBinding);
|
||||
//$$ keyBinding = new KeyBinding(name, keyCode, CATEGORY);
|
||||
//$$ ClientRegistry.registerKeyBinding(keyBinding);
|
||||
//#endif
|
||||
keyBindings.put(name, keyBinding);
|
||||
}
|
||||
@@ -103,7 +103,7 @@ public class KeyBindingRegistry extends EventRegistrations {
|
||||
|
||||
public void handleRepeatedKeyBindings() {
|
||||
for (Map.Entry<KeyBinding, Collection<Runnable>> entry : repeatedKeyBindingHandlers.asMap().entrySet()) {
|
||||
if (entry.getKey().isKeyDown()) {
|
||||
if (entry.getKey().isPressed()) {
|
||||
invokeKeyBindingHandlers(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
@@ -111,7 +111,7 @@ public class KeyBindingRegistry extends EventRegistrations {
|
||||
|
||||
public void handleKeyBindings() {
|
||||
for (Map.Entry<KeyBinding, Collection<Runnable>> entry : keyBindingHandlers.asMap().entrySet()) {
|
||||
while (entry.getKey().isPressed()) {
|
||||
while (entry.getKey().wasPressed()) {
|
||||
invokeKeyBindingHandlers(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
@@ -122,11 +122,11 @@ public class KeyBindingRegistry extends EventRegistrations {
|
||||
try {
|
||||
runnable.run();
|
||||
} catch (Throwable cause) {
|
||||
CrashReport crashReport = CrashReport.makeCrashReport(cause, "Handling Key Binding");
|
||||
CrashReportCategory category = crashReport.makeCategory("Key Binding");
|
||||
CrashReport crashReport = CrashReport.create(cause, "Handling Key Binding");
|
||||
CrashReportSection category = crashReport.addElement("Key Binding");
|
||||
MCVer.addDetail(category, "Key Binding", keyBinding::toString);
|
||||
MCVer.addDetail(category, "Handler", runnable::toString);
|
||||
throw new ReportedException(crashReport);
|
||||
throw new CrashException(crashReport);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -142,11 +142,11 @@ public class KeyBindingRegistry extends EventRegistrations {
|
||||
try {
|
||||
runnable.run();
|
||||
} catch (Throwable cause) {
|
||||
CrashReport crashReport = CrashReport.makeCrashReport(cause, "Handling Raw Key Binding");
|
||||
CrashReportCategory category = crashReport.makeCategory("Key Binding");
|
||||
CrashReport crashReport = CrashReport.create(cause, "Handling Raw Key Binding");
|
||||
CrashReportSection category = crashReport.addElement("Key Binding");
|
||||
MCVer.addDetail(category, "Key Code", () -> "" + keyCode);
|
||||
MCVer.addDetail(category, "Handler", runnable::toString);
|
||||
throw new ReportedException(crashReport);
|
||||
throw new CrashException(crashReport);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,50 +19,50 @@ import com.replaymod.replaystudio.util.I18n;
|
||||
import com.replaymod.simplepathing.ReplayModSimplePathing;
|
||||
import de.johni0702.minecraft.gui.container.GuiScreen;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.Style;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.text.TextComponent;
|
||||
import net.minecraft.text.Style;
|
||||
import net.minecraft.text.StringTextComponent;
|
||||
import net.minecraft.text.TranslatableTextComponent;
|
||||
import net.minecraft.text.TextFormat;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ import com.github.steveice10.mc.protocol.MinecraftConstants;
|
||||
//$$ import com.replaymod.core.versions.LangResourcePack;
|
||||
//$$ import net.fabricmc.api.ClientModInitializer;
|
||||
//$$ import net.fabricmc.loader.api.FabricLoader;
|
||||
//$$ import net.minecraft.SharedConstants;
|
||||
//$$ import net.minecraft.client.options.GameOption;
|
||||
//$$ import net.minecraft.resource.DirectoryResourcePack;
|
||||
//$$ import net.minecraft.resource.ResourcePackCreator;
|
||||
//$$ import net.minecraft.resource.ResourcePackContainer;
|
||||
//#else
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
//#if MC>=11300
|
||||
import com.github.steveice10.mc.protocol.MinecraftConstants;
|
||||
import com.replaymod.core.versions.LangResourcePack;
|
||||
import net.minecraft.resources.FolderPack;
|
||||
import net.minecraft.resources.IPackFinder;
|
||||
import net.minecraft.resources.ResourcePackInfo;
|
||||
import net.minecraftforge.fml.DeferredWorkQueue;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.versions.mcp.MCPVersion;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.client.options.GameOption;
|
||||
import net.minecraft.resource.DirectoryResourcePack;
|
||||
import net.minecraft.resource.ResourcePackCreator;
|
||||
import net.minecraft.resource.ResourcePackContainer;
|
||||
//#else
|
||||
//$$ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
//$$
|
||||
//#if MC>=11300
|
||||
//$$ import com.replaymod.core.versions.LangResourcePack;
|
||||
//$$ import net.minecraft.resources.FolderPack;
|
||||
//$$ import net.minecraft.resources.IPackFinder;
|
||||
//$$ import net.minecraft.resources.ResourcePackInfo;
|
||||
//$$ import net.minecraftforge.fml.DeferredWorkQueue;
|
||||
//$$ import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
//$$ import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
//$$ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
//$$ import net.minecraftforge.versions.mcp.MCPVersion;
|
||||
//#else
|
||||
//$$ import net.minecraft.client.resources.FolderResourcePack;
|
||||
//$$ import net.minecraft.client.resources.IResourcePack;
|
||||
//$$ import net.minecraftforge.common.config.Configuration;
|
||||
//#endif
|
||||
|
||||
//$$
|
||||
//#if MC>=10800
|
||||
import net.minecraft.client.GameSettings;
|
||||
//$$ import net.minecraft.client.GameSettings;
|
||||
//#endif
|
||||
|
||||
//$$
|
||||
//#if MC>=11300
|
||||
import net.minecraftforge.fml.ModList;
|
||||
//$$ import net.minecraftforge.fml.ModList;
|
||||
//#else
|
||||
//$$ import net.minecraftforge.fml.common.Loader;
|
||||
//$$ import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||
@@ -77,8 +77,8 @@ import net.minecraftforge.fml.ModList;
|
||||
//$$ import java.util.ArrayDeque;
|
||||
//#endif
|
||||
//#endif
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
//$$ import net.minecraftforge.fml.common.Mod;
|
||||
//$$ import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
//#endif
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
@@ -96,7 +96,7 @@ import static com.replaymod.core.versions.MCVer.*;
|
||||
|
||||
//#if MC<11400
|
||||
//#if MC>=11300
|
||||
@Mod(ReplayMod.MOD_ID)
|
||||
//$$ @Mod(ReplayMod.MOD_ID)
|
||||
//#else
|
||||
//$$ @Mod(modid = ReplayMod.MOD_ID,
|
||||
//$$ useMetadata = true,
|
||||
@@ -112,17 +112,17 @@ import static com.replaymod.core.versions.MCVer.*;
|
||||
//#endif
|
||||
public class ReplayMod implements
|
||||
//#if MC>=11400
|
||||
//$$ ClientModInitializer,
|
||||
ClientModInitializer,
|
||||
//#endif
|
||||
Module
|
||||
{
|
||||
|
||||
@Getter(lazy = true)
|
||||
//#if MC>=11400
|
||||
//$$ private static final String minecraftVersion = MinecraftClient.getInstance().getGame().getVersion().getName();
|
||||
private static final String minecraftVersion = MinecraftClient.getInstance().getGame().getVersion().getName();
|
||||
//#else
|
||||
//#if MC>=11300
|
||||
private static final String minecraftVersion = MCPVersion.getMCVersion();
|
||||
//$$ private static final String minecraftVersion = MCPVersion.getMCVersion();
|
||||
//#else
|
||||
//$$ private static final String minecraftVersion = Loader.MC_VERSION;
|
||||
//#endif
|
||||
@@ -130,10 +130,10 @@ public class ReplayMod implements
|
||||
|
||||
public static final String MOD_ID = "replaymod";
|
||||
|
||||
public static final ResourceLocation TEXTURE = new ResourceLocation("replaymod", "replay_gui.png");
|
||||
public static final Identifier TEXTURE = new Identifier("replaymod", "replay_gui.png");
|
||||
public static final int TEXTURE_SIZE = 256;
|
||||
|
||||
private static final Minecraft mc = MCVer.getMinecraft();
|
||||
private static final MinecraftClient mc = MCVer.getMinecraft();
|
||||
|
||||
//#if MC<11300
|
||||
//$$ @Deprecated
|
||||
@@ -159,26 +159,26 @@ public class ReplayMod implements
|
||||
private final GuiBackgroundProcesses backgroundProcesses = new GuiBackgroundProcesses();
|
||||
|
||||
public ReplayMod() {
|
||||
I18n.setI18n(net.minecraft.client.resources.I18n::format);
|
||||
I18n.setI18n(net.minecraft.client.resource.language.I18n::translate);
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ // Check Minecraft protocol version for compatibility
|
||||
//$$ int supportedProtocol = MinecraftConstants.PROTOCOL_VERSION;
|
||||
//$$ int actualProtocol = SharedConstants.getGameVersion().getProtocolVersion();
|
||||
//$$ if (supportedProtocol != actualProtocol) {
|
||||
//$$ throw new UnsupportedOperationException(String.format(
|
||||
//$$ "Unsupported Minecraft version, supporting protocol version %s (%s) but actual version is %s (%s).",
|
||||
//$$ supportedProtocol, MinecraftConstants.GAME_VERSION,
|
||||
//$$ actualProtocol, SharedConstants.getGameVersion().getName()
|
||||
//$$ ));
|
||||
//$$ }
|
||||
// Check Minecraft protocol version for compatibility
|
||||
int supportedProtocol = MinecraftConstants.PROTOCOL_VERSION;
|
||||
int actualProtocol = SharedConstants.getGameVersion().getProtocolVersion();
|
||||
if (supportedProtocol != actualProtocol) {
|
||||
throw new UnsupportedOperationException(String.format(
|
||||
"Unsupported Minecraft version, supporting protocol version %s (%s) but actual version is %s (%s).",
|
||||
supportedProtocol, MinecraftConstants.GAME_VERSION,
|
||||
actualProtocol, SharedConstants.getGameVersion().getName()
|
||||
));
|
||||
}
|
||||
//#endif
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ // Not needed on fabric, using MixinModResourcePackUtil instead. Could in theory also use it on 1.13 but it already works as is.
|
||||
// Not needed on fabric, using MixinModResourcePackUtil instead. Could in theory also use it on 1.13 but it already works as is.
|
||||
//#else
|
||||
//#if MC>=11300
|
||||
DeferredWorkQueue.runLater(() -> MCVer.getMinecraft().getResourcePackList().addPackFinder(new LangResourcePack.Finder()));
|
||||
//$$ DeferredWorkQueue.runLater(() -> MCVer.getMinecraft().getResourcePackList().addPackFinder(new LangResourcePack.Finder()));
|
||||
//#endif
|
||||
//#endif
|
||||
|
||||
@@ -219,7 +219,7 @@ public class ReplayMod implements
|
||||
|
||||
public File getReplayFolder() throws IOException {
|
||||
String path = getSettingsRegistry().get(Setting.RECORDING_PATH);
|
||||
File folder = new File(path.startsWith("./") ? getMinecraft().gameDir : null, path);
|
||||
File folder = new File(path.startsWith("./") ? getMinecraft().runDirectory : null, path);
|
||||
FileUtils.forceMkdir(folder);
|
||||
return folder;
|
||||
}
|
||||
@@ -234,11 +234,11 @@ public class ReplayMod implements
|
||||
//#endif
|
||||
@SuppressWarnings("unchecked")
|
||||
//#if MC>=11300
|
||||
FolderPack jGuiResourcePack = new FolderPack(new File("../jGui/src/main/resources")) {
|
||||
DirectoryResourcePack jGuiResourcePack = new DirectoryResourcePack(new File("../jGui/src/main/resources")) {
|
||||
@Override
|
||||
protected InputStream getInputStream(String resourceName) throws IOException {
|
||||
protected InputStream openFilename(String resourceName) throws IOException {
|
||||
try {
|
||||
return super.getInputStream(resourceName);
|
||||
return super.openFilename(resourceName);
|
||||
//#else
|
||||
//$$ List<IResourcePack> defaultResourcePacks = ((MinecraftAccessor) mc).getDefaultResourcePacks();
|
||||
//$$ FolderResourcePack jGuiResourcePack = new FolderResourcePack(new File("../jGui/src/main/resources")) {
|
||||
@@ -250,9 +250,9 @@ public class ReplayMod implements
|
||||
} catch (IOException e) {
|
||||
if ("pack.mcmeta".equals(resourceName)) {
|
||||
//#if MC>=11400
|
||||
//$$ int version = 4;
|
||||
int version = 4;
|
||||
//#else
|
||||
int version = 1;
|
||||
//$$ int version = 1;
|
||||
//#endif
|
||||
return new ByteArrayInputStream(("{\"pack\": {\"description\": \"dummy pack for jGui resources in dev-env\", \"pack_format\": "
|
||||
+ version + "}}").getBytes(StandardCharsets.UTF_8));
|
||||
@@ -262,10 +262,10 @@ public class ReplayMod implements
|
||||
}
|
||||
};
|
||||
//#if MC>=11300
|
||||
mc.getResourcePackList().addPackFinder(new IPackFinder() {
|
||||
mc.method_1520().addCreator(new ResourcePackCreator() {
|
||||
@Override
|
||||
public <T extends ResourcePackInfo> void addPackInfosToMap(Map<String, T> map, ResourcePackInfo.IFactory<T> factory) {
|
||||
map.put("jgui", ResourcePackInfo.func_195793_a("jgui", true, () -> jGuiResourcePack, factory, ResourcePackInfo.Priority.BOTTOM));
|
||||
public <T extends ResourcePackContainer> void registerContainer(Map<String, T> map, ResourcePackContainer.Factory<T> factory) {
|
||||
map.put("jgui", ResourcePackContainer.of("jgui", true, () -> jGuiResourcePack, factory, ResourcePackContainer.SortingDirection.BOTTOM));
|
||||
}
|
||||
});
|
||||
//#else
|
||||
@@ -290,19 +290,19 @@ public class ReplayMod implements
|
||||
}}
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ @Override
|
||||
//$$ public void onInitializeClient() {
|
||||
//$$ modules.forEach(Module::initCommon);
|
||||
//$$ modules.forEach(Module::initClient);
|
||||
//$$ modules.forEach(m -> m.registerKeyBindings(keyBindingRegistry));
|
||||
//$$ }
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
modules.forEach(Module::initCommon);
|
||||
modules.forEach(Module::initClient);
|
||||
modules.forEach(m -> m.registerKeyBindings(keyBindingRegistry));
|
||||
}
|
||||
//#else
|
||||
//#if MC>=11300
|
||||
{
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener((FMLCommonSetupEvent event) -> modules.forEach(Module::initCommon));
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener((FMLClientSetupEvent event) -> modules.forEach(Module::initClient));
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener((FMLClientSetupEvent event) -> modules.forEach(m -> m.registerKeyBindings(keyBindingRegistry)));
|
||||
}
|
||||
//$$ {
|
||||
//$$ FMLJavaModLoadingContext.get().getModEventBus().addListener((FMLCommonSetupEvent event) -> modules.forEach(Module::initCommon));
|
||||
//$$ FMLJavaModLoadingContext.get().getModEventBus().addListener((FMLClientSetupEvent event) -> modules.forEach(Module::initClient));
|
||||
//$$ FMLJavaModLoadingContext.get().getModEventBus().addListener((FMLClientSetupEvent event) -> modules.forEach(m -> m.registerKeyBindings(keyBindingRegistry)));
|
||||
//$$ }
|
||||
//#else
|
||||
//$$ @EventHandler
|
||||
//$$ public void init(FMLInitializationEvent event) {
|
||||
@@ -335,9 +335,9 @@ public class ReplayMod implements
|
||||
//#if MC>=10800
|
||||
if (!MCVer.hasOptifine()) {
|
||||
//#if MC>=11400
|
||||
//$$ GameOption.RENDER_DISTANCE.setMax(64f);
|
||||
GameOption.RENDER_DISTANCE.setMax(64f);
|
||||
//#else
|
||||
GameSettings.Options.RENDER_DISTANCE.setValueMax(64f);
|
||||
//$$ GameSettings.Options.RENDER_DISTANCE.setValueMax(64f);
|
||||
//#endif
|
||||
}
|
||||
//#endif
|
||||
@@ -385,64 +385,64 @@ public class ReplayMod implements
|
||||
*/
|
||||
private boolean inRunLater = false;
|
||||
//#if MC>=11400
|
||||
//$$ private boolean inRenderTaskQueue = false;
|
||||
private boolean inRenderTaskQueue = false;
|
||||
//#endif
|
||||
|
||||
public void runLater(Runnable runnable) {
|
||||
//#if MC>=11400
|
||||
//$$ if (mc.isOnThread() && inRunLater && !inRenderTaskQueue) {
|
||||
//$$ ((MinecraftAccessor) mc).getRenderTaskQueue().offer(() -> {
|
||||
//$$ inRenderTaskQueue = true;
|
||||
//$$ try {
|
||||
//$$ runLater(runnable);
|
||||
//$$ } finally {
|
||||
//$$ inRenderTaskQueue = false;
|
||||
//$$ }
|
||||
//$$ });
|
||||
//$$ } else {
|
||||
//$$ mc.method_18858(() -> {
|
||||
//$$ inRunLater = true;
|
||||
//$$ try {
|
||||
//$$ runnable.run();
|
||||
//$$ } finally {
|
||||
//$$ inRunLater = false;
|
||||
//$$ }
|
||||
//$$ });
|
||||
//$$ }
|
||||
//#else
|
||||
if (mc.isCallingFromMinecraftThread() && inRunLater) {
|
||||
//#if MC>=10800
|
||||
FORGE_BUS.register(new Object() {
|
||||
@SubscribeEvent
|
||||
public void onRenderTick(TickEvent.RenderTickEvent event) {
|
||||
if (event.phase == TickEvent.Phase.START) {
|
||||
runLater(runnable);
|
||||
FORGE_BUS.unregister(this);
|
||||
}
|
||||
if (mc.isOnThread() && inRunLater && !inRenderTaskQueue) {
|
||||
((MinecraftAccessor) mc).getRenderTaskQueue().offer(() -> {
|
||||
inRenderTaskQueue = true;
|
||||
try {
|
||||
runLater(runnable);
|
||||
} finally {
|
||||
inRenderTaskQueue = false;
|
||||
}
|
||||
});
|
||||
//#else
|
||||
//$$ FORGE_BUS.register(new RunLaterHelper(runnable));
|
||||
//#endif
|
||||
return;
|
||||
}
|
||||
//#if MC>=10800
|
||||
Queue<FutureTask<?>> tasks = ((MinecraftAccessor) mc).getScheduledTasks();
|
||||
//noinspection SynchronizationOnLocalVariableOrMethodParameter
|
||||
synchronized (tasks) {
|
||||
//#else
|
||||
//$$ Queue<ListenableFutureTask<?>> tasks = scheduledTasks;
|
||||
//$$ synchronized (scheduledTasks) {
|
||||
//#endif
|
||||
tasks.add(ListenableFutureTask.create(() -> {
|
||||
} else {
|
||||
mc.method_18858(() -> {
|
||||
inRunLater = true;
|
||||
try {
|
||||
runnable.run();
|
||||
} finally {
|
||||
inRunLater = false;
|
||||
}
|
||||
}, null));
|
||||
});
|
||||
}
|
||||
//#else
|
||||
//$$ if (mc.isCallingFromMinecraftThread() && inRunLater) {
|
||||
//#if MC>=10800
|
||||
//$$ FORGE_BUS.register(new Object() {
|
||||
//$$ @SubscribeEvent
|
||||
//$$ public void onRenderTick(TickEvent.RenderTickEvent event) {
|
||||
//$$ if (event.phase == TickEvent.Phase.START) {
|
||||
//$$ runLater(runnable);
|
||||
//$$ FORGE_BUS.unregister(this);
|
||||
//$$ }
|
||||
//$$ }
|
||||
//$$ });
|
||||
//#else
|
||||
//$$ FORGE_BUS.register(new RunLaterHelper(runnable));
|
||||
//#endif
|
||||
//$$ return;
|
||||
//$$ }
|
||||
//#if MC>=10800
|
||||
//$$ Queue<FutureTask<?>> tasks = ((MinecraftAccessor) mc).getScheduledTasks();
|
||||
//$$ //noinspection SynchronizationOnLocalVariableOrMethodParameter
|
||||
//$$ synchronized (tasks) {
|
||||
//#else
|
||||
//$$ Queue<ListenableFutureTask<?>> tasks = scheduledTasks;
|
||||
//$$ synchronized (scheduledTasks) {
|
||||
//#endif
|
||||
//$$ tasks.add(ListenableFutureTask.create(() -> {
|
||||
//$$ inRunLater = true;
|
||||
//$$ try {
|
||||
//$$ runnable.run();
|
||||
//$$ } finally {
|
||||
//$$ inRunLater = false;
|
||||
//$$ }
|
||||
//$$ }, null));
|
||||
//$$ }
|
||||
//#endif
|
||||
}
|
||||
|
||||
@@ -479,12 +479,12 @@ public class ReplayMod implements
|
||||
|
||||
public String getVersion() {
|
||||
//#if MC>=11400
|
||||
//$$ return FabricLoader.getInstance().getModContainer(MOD_ID)
|
||||
//$$ .orElseThrow(IllegalStateException::new)
|
||||
//$$ .getMetadata().getVersion().toString();
|
||||
return FabricLoader.getInstance().getModContainer(MOD_ID)
|
||||
.orElseThrow(IllegalStateException::new)
|
||||
.getMetadata().getVersion().toString();
|
||||
//#else
|
||||
//#if MC>=11300
|
||||
return ModList.get().getModContainerById(MOD_ID).get().getModInfo().getVersion().toString();
|
||||
//$$ return ModList.get().getModContainerById(MOD_ID).get().getModInfo().getVersion().toString();
|
||||
//#else
|
||||
//$$ return Loader.instance().getIndexedModList().get(MOD_ID).getVersion();
|
||||
//#endif
|
||||
@@ -497,7 +497,7 @@ public class ReplayMod implements
|
||||
}
|
||||
}
|
||||
|
||||
public Minecraft getMinecraft() {
|
||||
public MinecraftClient getMinecraft() {
|
||||
return mc;
|
||||
}
|
||||
|
||||
@@ -513,13 +513,13 @@ public class ReplayMod implements
|
||||
if (getSettingsRegistry().get(Setting.NOTIFICATIONS)) {
|
||||
// Some nostalgia: "§8[§6Replay Mod§8]§r Your message goes here"
|
||||
//#if MC>=10904
|
||||
Style coloredDarkGray = new Style().setColor(TextFormatting.DARK_GRAY);
|
||||
Style coloredGold = new Style().setColor(TextFormatting.GOLD);
|
||||
ITextComponent text = new TextComponentString("[").setStyle(coloredDarkGray)
|
||||
.appendSibling(new TextComponentTranslation("replaymod.title").setStyle(coloredGold))
|
||||
.appendSibling(new TextComponentString("] "))
|
||||
.appendSibling(new TextComponentTranslation(message, args).setStyle(new Style()
|
||||
.setColor(warning ? TextFormatting.RED : TextFormatting.DARK_GREEN)));
|
||||
Style coloredDarkGray = new Style().setColor(TextFormat.DARK_GRAY);
|
||||
Style coloredGold = new Style().setColor(TextFormat.GOLD);
|
||||
TextComponent text = new StringTextComponent("[").setStyle(coloredDarkGray)
|
||||
.append(new TranslatableTextComponent("replaymod.title").setStyle(coloredGold))
|
||||
.append(new StringTextComponent("] "))
|
||||
.append(new TranslatableTextComponent(message, args).setStyle(new Style()
|
||||
.setColor(warning ? TextFormat.RED : TextFormat.DARK_GREEN)));
|
||||
//#else
|
||||
//$$ ChatStyle coloredDarkGray = new ChatStyle().setColor(EnumChatFormatting.DARK_GRAY);
|
||||
//$$ ChatStyle coloredGold = new ChatStyle().setColor(EnumChatFormatting.GOLD);
|
||||
@@ -531,7 +531,7 @@ public class ReplayMod implements
|
||||
//#endif
|
||||
// Send message to chat GUI
|
||||
// The ingame GUI is initialized at startup, therefore this is possible before the client is connected
|
||||
mc.ingameGUI.getChatGUI().printChatMessage(text);
|
||||
mc.inGameHud.getChatHud().addMessage(text);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,21 +8,21 @@ import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ import com.google.gson.Gson;
|
||||
//$$ import com.google.gson.GsonBuilder;
|
||||
//$$ import com.google.gson.JsonElement;
|
||||
//$$ import com.google.gson.JsonObject;
|
||||
//$$ import com.google.gson.JsonPrimitive;
|
||||
//$$ import java.io.IOException;
|
||||
//$$ import java.nio.charset.StandardCharsets;
|
||||
//$$ import java.nio.file.Files;
|
||||
//$$ import java.nio.file.Path;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
//#else
|
||||
//#if MC>=11300
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
//$$ import net.minecraftforge.common.ForgeConfigSpec;
|
||||
//$$ import net.minecraftforge.fml.ModLoadingContext;
|
||||
//$$ import net.minecraftforge.fml.config.ModConfig;
|
||||
//$$ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
//#else
|
||||
//$$ import net.minecraftforge.common.config.Configuration;
|
||||
//#endif
|
||||
@@ -33,80 +33,80 @@ import static com.replaymod.core.versions.MCVer.*;
|
||||
public class SettingsRegistry {
|
||||
private Map<SettingKey<?>, Object> settings = new ConcurrentHashMap<>();
|
||||
//#if MC>=11400
|
||||
//$$ private final Path configFile = getMinecraft().runDirectory.toPath().resolve("configs/replaymod.json");
|
||||
private final Path configFile = getMinecraft().runDirectory.toPath().resolve("configs/replaymod.json");
|
||||
//#else
|
||||
private static final Object NULL_OBJECT = new Object();
|
||||
//$$ private static final Object NULL_OBJECT = new Object();
|
||||
//#if MC>=11300
|
||||
private ForgeConfigSpec spec;
|
||||
private ModConfig config;
|
||||
//$$ private ForgeConfigSpec spec;
|
||||
//$$ private ModConfig config;
|
||||
//#else
|
||||
//$$ private Configuration configuration;
|
||||
//#endif
|
||||
//#endif
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ public void register() {
|
||||
//$$ String config;
|
||||
//$$ if (Files.exists(configFile)) {
|
||||
//$$ try {
|
||||
//$$ config = new String(Files.readAllBytes(configFile), StandardCharsets.UTF_8);
|
||||
//$$ } catch (IOException e) {
|
||||
//$$ e.printStackTrace();
|
||||
//$$ return;
|
||||
//$$ }
|
||||
//$$ } else {
|
||||
//$$ save();
|
||||
//$$ return;
|
||||
//$$ }
|
||||
//$$ Gson gson = new Gson();
|
||||
//$$ JsonObject root = gson.fromJson(config, JsonObject.class);
|
||||
//$$ for (Map.Entry<SettingKey<?>, Object> entry : settings.entrySet()) {
|
||||
//$$ SettingKey<?> key = entry.getKey();
|
||||
//$$ JsonElement category = root.get(key.getCategory());
|
||||
//$$ if (category != null && category.isJsonObject()) {
|
||||
//$$ JsonElement valueElem = category.getAsJsonObject().get(key.getKey());
|
||||
//$$ if (!valueElem.isJsonPrimitive()) continue;
|
||||
//$$ JsonPrimitive value = valueElem.getAsJsonPrimitive();
|
||||
//$$ if (key.getDefault() instanceof Boolean && value.isBoolean()) {
|
||||
//$$ entry.setValue(value.getAsBoolean());
|
||||
//$$ }
|
||||
//$$ if (key.getDefault() instanceof Integer && value.isNumber()) {
|
||||
//$$ entry.setValue(value.getAsNumber().intValue());
|
||||
//$$ }
|
||||
//$$ if (key.getDefault() instanceof Double && value.isNumber()) {
|
||||
//$$ entry.setValue(value.getAsNumber().doubleValue());
|
||||
//$$ }
|
||||
//$$ if (key.getDefault() instanceof String && value.isString()) {
|
||||
//$$ entry.setValue(value.getAsString());
|
||||
//$$ }
|
||||
//$$ }
|
||||
//$$ }
|
||||
//$$ }
|
||||
//#else
|
||||
//#if MC>=11300
|
||||
public void register() {
|
||||
if (spec == null) {
|
||||
ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
|
||||
for (SettingKey<?> key : settings.keySet()) {
|
||||
builder
|
||||
.translation(key.getDisplayString())
|
||||
.define(key.getCategory() + "." + key.getKey(), key.getDefault());
|
||||
String config;
|
||||
if (Files.exists(configFile)) {
|
||||
try {
|
||||
config = new String(Files.readAllBytes(configFile), StandardCharsets.UTF_8);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
spec = builder.build();
|
||||
} else {
|
||||
save();
|
||||
return;
|
||||
}
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::load);
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, spec);
|
||||
}
|
||||
|
||||
private void load(ModConfig.Loading event) {
|
||||
config = event.getConfig();
|
||||
Gson gson = new Gson();
|
||||
JsonObject root = gson.fromJson(config, JsonObject.class);
|
||||
for (Map.Entry<SettingKey<?>, Object> entry : settings.entrySet()) {
|
||||
SettingKey<?> key = entry.getKey();
|
||||
Object value = config.getConfigData().get(key.getCategory() + "." + key.getKey());
|
||||
entry.setValue(value == null ? key.getDefault() : value);
|
||||
JsonElement category = root.get(key.getCategory());
|
||||
if (category != null && category.isJsonObject()) {
|
||||
JsonElement valueElem = category.getAsJsonObject().get(key.getKey());
|
||||
if (!valueElem.isJsonPrimitive()) continue;
|
||||
JsonPrimitive value = valueElem.getAsJsonPrimitive();
|
||||
if (key.getDefault() instanceof Boolean && value.isBoolean()) {
|
||||
entry.setValue(value.getAsBoolean());
|
||||
}
|
||||
if (key.getDefault() instanceof Integer && value.isNumber()) {
|
||||
entry.setValue(value.getAsNumber().intValue());
|
||||
}
|
||||
if (key.getDefault() instanceof Double && value.isNumber()) {
|
||||
entry.setValue(value.getAsNumber().doubleValue());
|
||||
}
|
||||
if (key.getDefault() instanceof String && value.isString()) {
|
||||
entry.setValue(value.getAsString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//#else
|
||||
//#if MC>=11300
|
||||
//$$ public void register() {
|
||||
//$$ if (spec == null) {
|
||||
//$$ ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
|
||||
//$$ for (SettingKey<?> key : settings.keySet()) {
|
||||
//$$ builder
|
||||
//$$ .translation(key.getDisplayString())
|
||||
//$$ .define(key.getCategory() + "." + key.getKey(), key.getDefault());
|
||||
//$$ }
|
||||
//$$ spec = builder.build();
|
||||
//$$ }
|
||||
//$$ FMLJavaModLoadingContext.get().getModEventBus().addListener(this::load);
|
||||
//$$ ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, spec);
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ private void load(ModConfig.Loading event) {
|
||||
//$$ config = event.getConfig();
|
||||
//$$ for (Map.Entry<SettingKey<?>, Object> entry : settings.entrySet()) {
|
||||
//$$ SettingKey<?> key = entry.getKey();
|
||||
//$$ Object value = config.getConfigData().get(key.getCategory() + "." + key.getKey());
|
||||
//$$ entry.setValue(value == null ? key.getDefault() : value);
|
||||
//$$ }
|
||||
//$$ }
|
||||
//#else
|
||||
//$$ public void setConfiguration(Configuration configuration) {
|
||||
//$$ this.configuration = configuration;
|
||||
//$$
|
||||
@@ -134,13 +134,13 @@ public class SettingsRegistry {
|
||||
|
||||
public void register(SettingKey<?> key) {
|
||||
//#if MC>=11400
|
||||
//$$ settings.put(key, key.getDefault());
|
||||
settings.put(key, key.getDefault());
|
||||
//#else
|
||||
//#if MC>=11300
|
||||
if (spec != null) {
|
||||
throw new IllegalStateException("Cannot register more settings are spec has been built.");
|
||||
}
|
||||
settings.put(key, NULL_OBJECT);
|
||||
//$$ if (spec != null) {
|
||||
//$$ throw new IllegalStateException("Cannot register more settings are spec has been built.");
|
||||
//$$ }
|
||||
//$$ settings.put(key, NULL_OBJECT);
|
||||
//#else
|
||||
//$$ Object value;
|
||||
//$$ if (configuration != null) {
|
||||
@@ -178,9 +178,9 @@ public class SettingsRegistry {
|
||||
public <T> void set(SettingKey<T> key, T value) {
|
||||
//#if MC<11400
|
||||
//#if MC>=11300
|
||||
if (config != null) {
|
||||
config.getConfigData().set(key.getCategory() + "." + key.getKey(), value);
|
||||
}
|
||||
//$$ if (config != null) {
|
||||
//$$ config.getConfigData().set(key.getCategory() + "." + key.getKey(), value);
|
||||
//$$ }
|
||||
//#else
|
||||
//$$ if (key.getDefault() instanceof Boolean) {
|
||||
//$$ configuration.get(key.getCategory(), key.getKey(), (Boolean) key.getDefault()).set((Boolean) value);
|
||||
@@ -201,39 +201,39 @@ public class SettingsRegistry {
|
||||
|
||||
public void save() {
|
||||
//#if MC>=11400
|
||||
//$$ JsonObject root = new JsonObject();
|
||||
//$$ for (Map.Entry<SettingKey<?>, Object> entry : settings.entrySet()) {
|
||||
//$$ SettingKey<?> key = entry.getKey();
|
||||
//$$ JsonObject category = root.getAsJsonObject(key.getCategory());
|
||||
//$$ if (category == null) {
|
||||
//$$ category = new JsonObject();
|
||||
//$$ root.add(key.getCategory(), category);
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ Object value = entry.getValue();
|
||||
//$$ if (value instanceof Boolean) {
|
||||
//$$ category.addProperty(key.getKey(), (Boolean) value);
|
||||
//$$ }
|
||||
//$$ if (value instanceof Number) {
|
||||
//$$ category.addProperty(key.getKey(), (Number) value);
|
||||
//$$ }
|
||||
//$$ if (value instanceof String) {
|
||||
//$$ category.addProperty(key.getKey(), (String) value);
|
||||
//$$ }
|
||||
//$$ }
|
||||
//$$ Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
//$$ String config = gson.toJson(gson);
|
||||
//$$ try {
|
||||
//$$ Files.createDirectories(configFile.getParent());
|
||||
//$$ Files.write(configFile, config.getBytes(StandardCharsets.UTF_8));
|
||||
//$$ } catch (IOException e) {
|
||||
//$$ e.printStackTrace();
|
||||
//$$ }
|
||||
JsonObject root = new JsonObject();
|
||||
for (Map.Entry<SettingKey<?>, Object> entry : settings.entrySet()) {
|
||||
SettingKey<?> key = entry.getKey();
|
||||
JsonObject category = root.getAsJsonObject(key.getCategory());
|
||||
if (category == null) {
|
||||
category = new JsonObject();
|
||||
root.add(key.getCategory(), category);
|
||||
}
|
||||
|
||||
Object value = entry.getValue();
|
||||
if (value instanceof Boolean) {
|
||||
category.addProperty(key.getKey(), (Boolean) value);
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
category.addProperty(key.getKey(), (Number) value);
|
||||
}
|
||||
if (value instanceof String) {
|
||||
category.addProperty(key.getKey(), (String) value);
|
||||
}
|
||||
}
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
String config = gson.toJson(gson);
|
||||
try {
|
||||
Files.createDirectories(configFile.getParent());
|
||||
Files.write(configFile, config.getBytes(StandardCharsets.UTF_8));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//#else
|
||||
//#if MC>=11300
|
||||
if (config != null) {
|
||||
config.save();
|
||||
}
|
||||
//$$ if (config != null) {
|
||||
//$$ config.save();
|
||||
//$$ }
|
||||
//#else
|
||||
//$$ configuration.save();
|
||||
//#endif
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
//#if MC>=11400
|
||||
//$$ package com.replaymod.core.events;
|
||||
//$$
|
||||
//$$ import net.fabricmc.fabric.api.event.Event;
|
||||
//$$ import net.fabricmc.fabric.api.event.EventFactory;
|
||||
//$$
|
||||
//$$ public interface PostRenderWorldCallback {
|
||||
//$$ Event<PostRenderWorldCallback> EVENT = EventFactory.createArrayBacked(
|
||||
//$$ PostRenderWorldCallback.class,
|
||||
//$$ (listeners) -> () -> {
|
||||
//$$ for (PostRenderWorldCallback listener : listeners) {
|
||||
//$$ listener.postRenderWorld();
|
||||
//$$ }
|
||||
//$$ }
|
||||
//$$ );
|
||||
//$$
|
||||
//$$ void postRenderWorld();
|
||||
//$$ }
|
||||
package com.replaymod.core.events;
|
||||
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.api.event.EventFactory;
|
||||
|
||||
public interface PostRenderWorldCallback {
|
||||
Event<PostRenderWorldCallback> EVENT = EventFactory.createArrayBacked(
|
||||
PostRenderWorldCallback.class,
|
||||
(listeners) -> () -> {
|
||||
for (PostRenderWorldCallback listener : listeners) {
|
||||
listener.postRenderWorld();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
void postRenderWorld();
|
||||
}
|
||||
//#endif
|
||||
|
||||
@@ -14,13 +14,13 @@ import de.johni0702.minecraft.gui.utils.lwjgl.Dimension;
|
||||
import de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension;
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ import de.johni0702.minecraft.gui.versions.callbacks.InitScreenCallback;
|
||||
//$$ import net.minecraft.client.gui.Screen;
|
||||
import de.johni0702.minecraft.gui.versions.callbacks.InitScreenCallback;
|
||||
import net.minecraft.client.gui.Screen;
|
||||
//#else
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import static com.replaymod.core.versions.MCVer.getGui;
|
||||
//$$ import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
//$$ import net.minecraftforge.common.MinecraftForge;
|
||||
//$$ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
//$$ import static com.replaymod.core.versions.MCVer.getGui;
|
||||
//#endif
|
||||
|
||||
import static com.replaymod.core.versions.MCVer.getMinecraft;
|
||||
@@ -29,12 +29,12 @@ public class GuiBackgroundProcesses extends EventRegistrations {
|
||||
private GuiPanel panel = new GuiPanel().setLayout(new VerticalLayout().setSpacing(10));
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ { on(InitScreenCallback.EVENT, (screen, buttons) -> onGuiInit(screen)); }
|
||||
//$$ private void onGuiInit(Screen guiScreen) {
|
||||
{ on(InitScreenCallback.EVENT, (screen, buttons) -> onGuiInit(screen)); }
|
||||
private void onGuiInit(Screen guiScreen) {
|
||||
//#else
|
||||
@SubscribeEvent
|
||||
public void onGuiInit(GuiScreenEvent.InitGuiEvent.Post event) {
|
||||
net.minecraft.client.gui.GuiScreen guiScreen = getGui(event);
|
||||
//$$ @SubscribeEvent
|
||||
//$$ public void onGuiInit(GuiScreenEvent.InitGuiEvent.Post event) {
|
||||
//$$ net.minecraft.client.gui.GuiScreen guiScreen = getGui(event);
|
||||
//#endif
|
||||
if (guiScreen != getMinecraft().currentScreen) return; // people tend to construct GuiScreens without opening them
|
||||
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
//#if MC<11400
|
||||
package com.replaymod.core.gui;
|
||||
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
//$$ package com.replaymod.core.gui;
|
||||
//$$
|
||||
//$$ import com.replaymod.core.ReplayMod;
|
||||
//$$ import net.minecraft.client.Minecraft;
|
||||
//$$ import net.minecraft.client.gui.GuiScreen;
|
||||
//$$
|
||||
//#if MC>=10800
|
||||
import net.minecraftforge.fml.client.IModGuiFactory;
|
||||
//$$ import net.minecraftforge.fml.client.IModGuiFactory;
|
||||
//#else
|
||||
//$$ import cpw.mods.fml.client.IModGuiFactory;
|
||||
//#endif
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class GuiFactory implements IModGuiFactory {
|
||||
@Override
|
||||
public void initialize(Minecraft minecraftInstance) {
|
||||
|
||||
}
|
||||
|
||||
//$$
|
||||
//$$ import java.util.Set;
|
||||
//$$
|
||||
//$$ @SuppressWarnings("unused")
|
||||
//$$ public class GuiFactory implements IModGuiFactory {
|
||||
//$$ @Override
|
||||
//$$ public void initialize(Minecraft minecraftInstance) {
|
||||
//$$
|
||||
//$$ }
|
||||
//$$
|
||||
//#if MC>=11200
|
||||
@Override
|
||||
public boolean hasConfigGui() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiScreen createConfigGui(GuiScreen parentScreen) {
|
||||
return new GuiReplaySettings(parentScreen, ReplayMod.instance.getSettingsRegistry()).toMinecraft();
|
||||
}
|
||||
//$$ @Override
|
||||
//$$ public boolean hasConfigGui() {
|
||||
//$$ return true;
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ @Override
|
||||
//$$ public GuiScreen createConfigGui(GuiScreen parentScreen) {
|
||||
//$$ return new GuiReplaySettings(parentScreen, ReplayMod.instance.getSettingsRegistry()).toMinecraft();
|
||||
//$$ }
|
||||
//#else
|
||||
//$$ @Override
|
||||
//$$ public Class<? extends GuiScreen> mainConfigGuiClass() {
|
||||
@@ -54,10 +54,10 @@ public class GuiFactory implements IModGuiFactory {
|
||||
//$$ }
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
@Override
|
||||
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
//$$
|
||||
//$$ @Override
|
||||
//$$ public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
|
||||
//$$ return null;
|
||||
//$$ }
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
@@ -13,17 +13,17 @@ import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
||||
import de.johni0702.minecraft.gui.layout.VerticalLayout;
|
||||
import de.johni0702.minecraft.gui.utils.Consumer;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.resource.language.I18n;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GuiReplaySettings extends AbstractGuiScreen<GuiReplaySettings> {
|
||||
|
||||
public GuiReplaySettings(final net.minecraft.client.gui.GuiScreen parent, final SettingsRegistry settingsRegistry) {
|
||||
public GuiReplaySettings(final net.minecraft.client.gui.Screen parent, final SettingsRegistry settingsRegistry) {
|
||||
final GuiButton doneButton = new GuiButton(this).setI18nLabel("gui.done").setSize(200, 20).onClick(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
getMinecraft().displayGuiScreen(parent);
|
||||
getMinecraft().openScreen(parent);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -42,7 +42,7 @@ public class GuiReplaySettings extends AbstractGuiScreen<GuiReplaySettings> {
|
||||
final SettingsRegistry.SettingKey<Boolean> booleanKey = (SettingsRegistry.SettingKey<Boolean>) key;
|
||||
final GuiToggleButton button = new GuiToggleButton<>().setSize(150, 20)
|
||||
.setI18nLabel(key.getDisplayString()).setSelected(settingsRegistry.get(booleanKey) ? 0 : 1)
|
||||
.setValues(I18n.format("options.on"), I18n.format("options.off"));
|
||||
.setValues(I18n.translate("options.on"), I18n.translate("options.off"));
|
||||
element = button.onClick(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -60,7 +60,7 @@ public class GuiReplaySettings extends AbstractGuiScreen<GuiReplaySettings> {
|
||||
for (int j = 0; j < entries.length; j++) {
|
||||
Object value = values.get(j);
|
||||
entries[j] = new MultipleChoiceDropdownEntry(value,
|
||||
I18n.format(multipleChoiceKey.getDisplayString()) + ": " + I18n.format(value.toString()));
|
||||
I18n.translate(multipleChoiceKey.getDisplayString()) + ": " + I18n.translate(value.toString()));
|
||||
if (currentValue.equals(value)) {
|
||||
selected = j;
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ package com.replaymod.core.handler;
|
||||
|
||||
import com.replaymod.core.mixin.GuiMainMenuAccessor;
|
||||
import de.johni0702.minecraft.gui.utils.EventRegistrations;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiMainMenu;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiScreenRealmsProxy;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.MainMenuScreen;
|
||||
import net.minecraft.client.gui.Screen;
|
||||
import net.minecraft.realms.RealmsScreenProxy;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.List;
|
||||
@@ -13,13 +13,13 @@ import java.util.List;
|
||||
import static com.replaymod.core.versions.MCVer.*;
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ import de.johni0702.minecraft.gui.versions.callbacks.InitScreenCallback;
|
||||
//$$ import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
||||
import de.johni0702.minecraft.gui.versions.callbacks.InitScreenCallback;
|
||||
import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
||||
//#else
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
//$$ import net.minecraft.client.gui.GuiButton;
|
||||
//$$ import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
//$$ import net.minecraftforge.common.MinecraftForge;
|
||||
//$$ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
//#endif
|
||||
|
||||
/**
|
||||
@@ -27,21 +27,21 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
*/
|
||||
public class MainMenuHandler extends EventRegistrations {
|
||||
//#if MC>=11400
|
||||
//$$ { on(InitScreenCallback.EVENT, this::onInit); }
|
||||
//$$ public void onInit(Screen guiScreen, List<AbstractButtonWidget> buttonList) {
|
||||
{ on(InitScreenCallback.EVENT, this::onInit); }
|
||||
public void onInit(Screen guiScreen, List<AbstractButtonWidget> buttonList) {
|
||||
//#else
|
||||
@SubscribeEvent
|
||||
public void onInit(GuiScreenEvent.InitGuiEvent.Post event) {
|
||||
GuiScreen guiScreen = getGui(event);
|
||||
List<GuiButton> buttonList = getButtonList(event);
|
||||
//$$ @SubscribeEvent
|
||||
//$$ public void onInit(GuiScreenEvent.InitGuiEvent.Post event) {
|
||||
//$$ GuiScreen guiScreen = getGui(event);
|
||||
//$$ List<GuiButton> buttonList = getButtonList(event);
|
||||
//#endif
|
||||
if (guiScreen instanceof GuiMainMenu) {
|
||||
GuiMainMenu gui = (GuiMainMenu) guiScreen;
|
||||
if (guiScreen instanceof MainMenuScreen) {
|
||||
MainMenuScreen gui = (MainMenuScreen) guiScreen;
|
||||
int realmsOffset = 0;
|
||||
//#if MC>=11400
|
||||
//$$ for (AbstractButtonWidget button : buttonList) {
|
||||
for (AbstractButtonWidget button : buttonList) {
|
||||
//#else
|
||||
for (GuiButton button : buttonList) {
|
||||
//$$ for (GuiButton button : buttonList) {
|
||||
//#endif
|
||||
// Buttons that aren't in a rectangle directly above our space don't need moving
|
||||
if (button.x + width(button) < gui.width / 2 - 100
|
||||
@@ -53,40 +53,40 @@ public class MainMenuHandler extends EventRegistrations {
|
||||
button.y += offset;
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ // FIXME looks like the button has moved into the realms lib?
|
||||
// FIXME looks like the button has moved into the realms lib?
|
||||
//#else
|
||||
//#if MC>=11300
|
||||
if (button.id == 14) {
|
||||
realmsOffset = offset;
|
||||
}
|
||||
//$$ if (button.id == 14) {
|
||||
//$$ realmsOffset = offset;
|
||||
//$$ }
|
||||
//#endif
|
||||
//#endif
|
||||
}
|
||||
//#if MC>=11300
|
||||
GuiMainMenuAccessor guiA = (GuiMainMenuAccessor) gui;
|
||||
if (realmsOffset != 0 && guiA.getRealmsNotification() instanceof GuiScreenRealmsProxy) {
|
||||
guiA.setRealmsNotification(new RealmsNotificationProxy((GuiScreenRealmsProxy) guiA.getRealmsNotification(), realmsOffset));
|
||||
if (realmsOffset != 0 && guiA.getRealmsNotification() instanceof RealmsScreenProxy) {
|
||||
guiA.setRealmsNotification(new RealmsNotificationProxy((RealmsScreenProxy) guiA.getRealmsNotification(), realmsOffset));
|
||||
}
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
|
||||
//#if MC>=11300
|
||||
private static class RealmsNotificationProxy extends GuiScreen {
|
||||
private final GuiScreenRealmsProxy proxy;
|
||||
private static class RealmsNotificationProxy extends Screen {
|
||||
private final RealmsScreenProxy proxy;
|
||||
private final int offset;
|
||||
|
||||
private RealmsNotificationProxy(GuiScreenRealmsProxy proxy, int offset) {
|
||||
private RealmsNotificationProxy(RealmsScreenProxy proxy, int offset) {
|
||||
//#if MC>=11400
|
||||
//$$ super(null);
|
||||
super(null);
|
||||
//#endif
|
||||
this.proxy = proxy;
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWorldAndResolution(Minecraft mc, int width, int height) {
|
||||
proxy.setWorldAndResolution(mc, width, height);
|
||||
public void init(MinecraftClient mc, int width, int height) {
|
||||
proxy.init(mc, width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -107,8 +107,8 @@ public class MainMenuHandler extends EventRegistrations {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
proxy.onGuiClosed();
|
||||
public void removed() {
|
||||
proxy.removed();
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
//#if MC>=11400
|
||||
//$$ package com.replaymod.core.mixin;
|
||||
//$$
|
||||
//$$ import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
||||
//$$ import org.spongepowered.asm.mixin.Mixin;
|
||||
//$$ import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
//$$
|
||||
//$$ @Mixin(AbstractButtonWidget.class)
|
||||
//$$ public interface AbstractButtonWidgetAccessor {
|
||||
//$$ @Accessor
|
||||
//$$ int getHeight();
|
||||
//$$ }
|
||||
package com.replaymod.core.mixin;
|
||||
|
||||
import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(AbstractButtonWidget.class)
|
||||
public interface AbstractButtonWidgetAccessor {
|
||||
@Accessor
|
||||
int getHeight();
|
||||
}
|
||||
//#endif
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package com.replaymod.core.mixin;
|
||||
|
||||
import net.minecraft.client.gui.GuiMainMenu;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.MainMenuScreen;
|
||||
import net.minecraft.client.gui.Screen;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(GuiMainMenu.class)
|
||||
@Mixin(MainMenuScreen.class)
|
||||
public interface GuiMainMenuAccessor {
|
||||
//#if MC>=10904
|
||||
@Accessor
|
||||
GuiScreen getRealmsNotification();
|
||||
@Accessor
|
||||
void setRealmsNotification(GuiScreen value);
|
||||
@Accessor("realmsNotificationGui")
|
||||
Screen getRealmsNotification();
|
||||
@Accessor("realmsNotificationGui")
|
||||
void setRealmsNotification(Screen value);
|
||||
//#endif
|
||||
}
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
package com.replaymod.core.mixin;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.Screen;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
||||
import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
||||
//#else
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
//$$ import net.minecraft.client.gui.GuiButton;
|
||||
//#endif
|
||||
|
||||
//#if MC>=11300
|
||||
import net.minecraft.client.gui.IGuiEventListener;
|
||||
import net.minecraft.client.gui.Element;
|
||||
//#endif
|
||||
|
||||
@Mixin(GuiScreen.class)
|
||||
@Mixin(Screen.class)
|
||||
public interface GuiScreenAccessor {
|
||||
@Accessor
|
||||
//#if MC>=11400
|
||||
//$$ List<AbstractButtonWidget> getButtons();
|
||||
List<AbstractButtonWidget> getButtons();
|
||||
//#else
|
||||
List<GuiButton> getButtons();
|
||||
//$$ List<GuiButton> getButtons();
|
||||
//#endif
|
||||
|
||||
//#if MC>=11300
|
||||
@Accessor
|
||||
List<IGuiEventListener> getChildren();
|
||||
List<Element> getChildren();
|
||||
//#endif
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.replaymod.core.mixin;
|
||||
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.client.options.KeyBinding;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(KeyBinding.class)
|
||||
public interface KeyBindingAccessor {
|
||||
@Accessor
|
||||
@Accessor("timesPressed")
|
||||
int getPressTime();
|
||||
@Accessor
|
||||
@Accessor("timesPressed")
|
||||
void setPressTime(int value);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package com.replaymod.core.mixin;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.util.Timer;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.util.crash.CrashReport;
|
||||
import net.minecraft.client.render.RenderTickCounter;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import java.util.Queue;
|
||||
|
||||
//#if MC<11400
|
||||
import java.util.concurrent.FutureTask;
|
||||
//$$ import java.util.concurrent.FutureTask;
|
||||
//#endif
|
||||
|
||||
//#if MC<11300
|
||||
@@ -17,25 +17,25 @@ import java.util.concurrent.FutureTask;
|
||||
//$$ import java.util.List;
|
||||
//#endif
|
||||
|
||||
@Mixin(Minecraft.class)
|
||||
@Mixin(MinecraftClient.class)
|
||||
public interface MinecraftAccessor {
|
||||
@Accessor
|
||||
Timer getTimer();
|
||||
@Accessor
|
||||
void setTimer(Timer value);
|
||||
@Accessor("renderTickCounter")
|
||||
RenderTickCounter getTimer();
|
||||
@Accessor("renderTickCounter")
|
||||
void setTimer(RenderTickCounter value);
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ @Accessor
|
||||
//$$ Queue<Runnable> getRenderTaskQueue();
|
||||
//#else
|
||||
@Accessor
|
||||
Queue<FutureTask<?>> getScheduledTasks();
|
||||
Queue<Runnable> getRenderTaskQueue();
|
||||
//#else
|
||||
//$$ @Accessor
|
||||
//$$ Queue<FutureTask<?>> getScheduledTasks();
|
||||
//#endif
|
||||
|
||||
@Accessor("hasCrashed")
|
||||
@Accessor("crashed")
|
||||
boolean hasCrashed();
|
||||
|
||||
@Accessor
|
||||
@Accessor("crashReport")
|
||||
CrashReport getCrashReporter();
|
||||
|
||||
//#if MC<11300
|
||||
|
||||
@@ -1,59 +1,59 @@
|
||||
//#if MC>=11400
|
||||
//$$ package com.replaymod.core.mixin;
|
||||
//$$
|
||||
//$$ import com.replaymod.core.events.PostRenderWorldCallback;
|
||||
//$$ import com.replaymod.core.events.PreRenderHandCallback;
|
||||
//$$ import de.johni0702.minecraft.gui.versions.callbacks.PostRenderHudCallback;
|
||||
//$$ import de.johni0702.minecraft.gui.versions.callbacks.PostRenderScreenCallback;
|
||||
//$$ import net.minecraft.client.render.Camera;
|
||||
//$$ import net.minecraft.client.render.GameRenderer;
|
||||
//$$ import org.spongepowered.asm.mixin.Mixin;
|
||||
//$$ import org.spongepowered.asm.mixin.injection.At;
|
||||
//$$ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
//$$ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
//$$
|
||||
//$$ @Mixin(GameRenderer.class)
|
||||
//$$ public class MixinGameRenderer {
|
||||
//$$ @Inject(
|
||||
//$$ method = "render",
|
||||
//$$ at = @At(
|
||||
//$$ value = "INVOKE",
|
||||
//$$ target = "Lnet/minecraft/client/gui/hud/InGameHud;draw(F)V",
|
||||
//$$ shift = At.Shift.AFTER
|
||||
//$$ )
|
||||
//$$ )
|
||||
//$$ private void postRenderOverlay(float partialTicks, long nanoTime, boolean renderWorld, CallbackInfo ci) {
|
||||
//$$ PostRenderHudCallback.EVENT.invoker().postRenderHud(partialTicks);
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ @Inject(
|
||||
//$$ method = "render",
|
||||
//$$ at = @At(
|
||||
//$$ value = "INVOKE",
|
||||
//$$ target = "Lnet/minecraft/client/gui/Screen;render(IIF)V",
|
||||
//$$ shift = At.Shift.AFTER
|
||||
//$$ )
|
||||
//$$ )
|
||||
//$$ private void postRenderScreen(float partialTicks, long nanoTime, boolean renderWorld, CallbackInfo ci) {
|
||||
//$$ PostRenderScreenCallback.EVENT.invoker().postRenderScreen(partialTicks);
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ @Inject(
|
||||
//$$ method = "renderCenter",
|
||||
//$$ at = @At(
|
||||
//$$ value = "FIELD",
|
||||
//$$ target = "Lnet/minecraft/client/render/GameRenderer;renderHand:Z"
|
||||
//$$ )
|
||||
//$$ )
|
||||
//$$ private void postRenderWorld(float partialTicks, long nanoTime, CallbackInfo ci) {
|
||||
//$$ PostRenderWorldCallback.EVENT.invoker().postRenderWorld();
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ @Inject(method = "renderHand", at = @At("HEAD"), cancellable = true)
|
||||
//$$ private void preRenderHand(Camera camera, float partialTicks, CallbackInfo ci) {
|
||||
//$$ if (PreRenderHandCallback.EVENT.invoker().preRenderHand()) {
|
||||
//$$ ci.cancel();
|
||||
//$$ }
|
||||
//$$ }
|
||||
//$$ }
|
||||
package com.replaymod.core.mixin;
|
||||
|
||||
import com.replaymod.core.events.PostRenderWorldCallback;
|
||||
import com.replaymod.core.events.PreRenderHandCallback;
|
||||
import de.johni0702.minecraft.gui.versions.callbacks.PostRenderHudCallback;
|
||||
import de.johni0702.minecraft.gui.versions.callbacks.PostRenderScreenCallback;
|
||||
import net.minecraft.client.render.Camera;
|
||||
import net.minecraft.client.render.GameRenderer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(GameRenderer.class)
|
||||
public class MixinGameRenderer {
|
||||
@Inject(
|
||||
method = "render",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/gui/hud/InGameHud;draw(F)V",
|
||||
shift = At.Shift.AFTER
|
||||
)
|
||||
)
|
||||
private void postRenderOverlay(float partialTicks, long nanoTime, boolean renderWorld, CallbackInfo ci) {
|
||||
PostRenderHudCallback.EVENT.invoker().postRenderHud(partialTicks);
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "render",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/gui/Screen;render(IIF)V",
|
||||
shift = At.Shift.AFTER
|
||||
)
|
||||
)
|
||||
private void postRenderScreen(float partialTicks, long nanoTime, boolean renderWorld, CallbackInfo ci) {
|
||||
PostRenderScreenCallback.EVENT.invoker().postRenderScreen(partialTicks);
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "renderCenter",
|
||||
at = @At(
|
||||
value = "FIELD",
|
||||
target = "Lnet/minecraft/client/render/GameRenderer;renderHand:Z"
|
||||
)
|
||||
)
|
||||
private void postRenderWorld(float partialTicks, long nanoTime, CallbackInfo ci) {
|
||||
PostRenderWorldCallback.EVENT.invoker().postRenderWorld();
|
||||
}
|
||||
|
||||
@Inject(method = "renderHand", at = @At("HEAD"), cancellable = true)
|
||||
private void preRenderHand(Camera camera, float partialTicks, CallbackInfo ci) {
|
||||
if (PreRenderHandCallback.EVENT.invoker().preRenderHand()) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
||||
@@ -3,59 +3,59 @@ package com.replaymod.core.mixin;
|
||||
|
||||
import com.replaymod.core.events.KeyBindingEventCallback;
|
||||
import com.replaymod.core.events.KeyEventCallback;
|
||||
import net.minecraft.client.KeyboardListener;
|
||||
import net.minecraft.client.Keyboard;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(KeyboardListener.class)
|
||||
@Mixin(Keyboard.class)
|
||||
public class MixinKeyboardListener {
|
||||
@Inject(method = "onKeyEvent", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/settings/KeyBinding;onTick(Lnet/minecraft/client/util/InputMappings$Input;)V", shift = At.Shift.AFTER))
|
||||
@Inject(method = "onKey", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/options/KeyBinding;onKeyPressed(Lnet/minecraft/client/util/InputUtil$KeyCode;)V", shift = At.Shift.AFTER))
|
||||
private void afterKeyBindingTick(long windowPointer, int key, int scanCode, int action, int modifiers, CallbackInfo ci) {
|
||||
KeyBindingEventCallback.EVENT.invoker().onKeybindingEvent();
|
||||
KeyEventCallback.EVENT.invoker().onKeyEvent(key, scanCode, action, modifiers);
|
||||
}
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ /* FIXME we currently don't use these but they also don't work since their target is wrapped in a lambda,
|
||||
//$$ see MixinMouseListener for working examples
|
||||
//$$ @Redirect(
|
||||
//$$ method = "onKey",
|
||||
//$$ at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/ParentElement;keyPressed(III)Z")
|
||||
//$$ )
|
||||
//$$ private boolean keyPressed(ParentElement element, int keyCode, int modifiers, int scanCode) {
|
||||
//$$ if (KeyboardCallback.EVENT.invoker().keyPressed(keyCode, modifiers, scanCode)) {
|
||||
//$$ return true;
|
||||
//$$ } else {
|
||||
//$$ return element.keyPressed(keyCode, modifiers, scanCode);
|
||||
//$$ }
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ @Redirect(
|
||||
//$$ method = "onKey",
|
||||
//$$ at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/ParentElement;keyReleased(III)Z")
|
||||
//$$ )
|
||||
//$$ private boolean keyReleased(ParentElement element, int keyCode, int modifiers, int scanCode) {
|
||||
//$$ if (KeyboardCallback.EVENT.invoker().keyReleased(keyCode, modifiers, scanCode)) {
|
||||
//$$ return true;
|
||||
//$$ } else {
|
||||
//$$ return element.keyReleased(keyCode, modifiers, scanCode);
|
||||
//$$ }
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ @Redirect(
|
||||
//$$ method = "onKey",
|
||||
//$$ at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/ParentElement;charTyped(CI)Z")
|
||||
//$$ )
|
||||
//$$ private boolean charTyped(ParentElement element, char keyChar, int modifiers) {
|
||||
//$$ if (KeyboardCallback.EVENT.invoker().charTyped(keyChar, modifiers)) {
|
||||
//$$ return true;
|
||||
//$$ } else {
|
||||
//$$ return element.charTyped(keyChar, modifiers);
|
||||
//$$ }
|
||||
//$$ }
|
||||
//$$ */
|
||||
/* FIXME we currently don't use these but they also don't work since their target is wrapped in a lambda,
|
||||
see MixinMouseListener for working examples
|
||||
@Redirect(
|
||||
method = "onKey",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/ParentElement;keyPressed(III)Z")
|
||||
)
|
||||
private boolean keyPressed(ParentElement element, int keyCode, int modifiers, int scanCode) {
|
||||
if (KeyboardCallback.EVENT.invoker().keyPressed(keyCode, modifiers, scanCode)) {
|
||||
return true;
|
||||
} else {
|
||||
return element.keyPressed(keyCode, modifiers, scanCode);
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = "onKey",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/ParentElement;keyReleased(III)Z")
|
||||
)
|
||||
private boolean keyReleased(ParentElement element, int keyCode, int modifiers, int scanCode) {
|
||||
if (KeyboardCallback.EVENT.invoker().keyReleased(keyCode, modifiers, scanCode)) {
|
||||
return true;
|
||||
} else {
|
||||
return element.keyReleased(keyCode, modifiers, scanCode);
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = "onKey",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/ParentElement;charTyped(CI)Z")
|
||||
)
|
||||
private boolean charTyped(ParentElement element, char keyChar, int modifiers) {
|
||||
if (KeyboardCallback.EVENT.invoker().charTyped(keyChar, modifiers)) {
|
||||
return true;
|
||||
} else {
|
||||
return element.charTyped(keyChar, modifiers);
|
||||
}
|
||||
}
|
||||
*/
|
||||
//#endif
|
||||
}
|
||||
//#endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.replaymod.core.mixin;
|
||||
|
||||
import com.replaymod.core.versions.MCVer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -11,7 +11,7 @@ import com.replaymod.core.events.PostRenderCallback;
|
||||
import com.replaymod.core.events.PreRenderCallback;
|
||||
import de.johni0702.minecraft.gui.versions.callbacks.OpenGuiScreenCallback;
|
||||
import de.johni0702.minecraft.gui.versions.callbacks.PreTickCallback;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.Screen;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
//#else
|
||||
@@ -23,56 +23,56 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import java.io.IOException;
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ import net.minecraft.util.NonBlockingThreadExecutor;
|
||||
import net.minecraft.util.NonBlockingThreadExecutor;
|
||||
//#endif
|
||||
|
||||
@Mixin(Minecraft.class)
|
||||
@Mixin(MinecraftClient.class)
|
||||
public abstract class MixinMinecraft
|
||||
//#if MC>=11400
|
||||
//$$ extends NonBlockingThreadExecutor<Runnable>
|
||||
extends NonBlockingThreadExecutor<Runnable>
|
||||
//#endif
|
||||
implements MCVer.MinecraftMethodAccessor {
|
||||
//#if MC>=11400
|
||||
//$$ public MixinMinecraft(String string_1) { super(string_1); }
|
||||
public MixinMinecraft(String string_1) { super(string_1); }
|
||||
//#endif
|
||||
|
||||
//#if MC>=11300
|
||||
@Shadow protected abstract void processKeyBinds();
|
||||
@Shadow protected abstract void handleInputEvents();
|
||||
|
||||
@Override
|
||||
public void replayModProcessKeyBinds() {
|
||||
processKeyBinds();
|
||||
handleInputEvents();
|
||||
}
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ @Override
|
||||
//$$ public void replayModExecuteTaskQueue() {
|
||||
//$$ executeTaskQueue();
|
||||
//$$ }
|
||||
@Override
|
||||
public void replayModExecuteTaskQueue() {
|
||||
executeTaskQueue();
|
||||
}
|
||||
//#endif
|
||||
|
||||
@Inject(method = "runGameLoop",
|
||||
@Inject(method = "render",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/renderer/GameRenderer;updateCameraAndRender(FJZ)V"))
|
||||
target = "Lnet/minecraft/client/render/GameRenderer;render(FJZ)V"))
|
||||
private void preRender(boolean unused, CallbackInfo ci) {
|
||||
PreRenderCallback.EVENT.invoker().preRender();
|
||||
}
|
||||
|
||||
@Inject(method = "runGameLoop",
|
||||
@Inject(method = "render",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/renderer/GameRenderer;updateCameraAndRender(FJZ)V",
|
||||
target = "Lnet/minecraft/client/render/GameRenderer;render(FJZ)V",
|
||||
shift = At.Shift.AFTER))
|
||||
private void postRender(boolean unused, CallbackInfo ci) {
|
||||
PostRenderCallback.EVENT.invoker().postRender();
|
||||
}
|
||||
|
||||
@Inject(method = "runTick", at = @At("HEAD"))
|
||||
@Inject(method = "tick", at = @At("HEAD"))
|
||||
private void preTick(CallbackInfo ci) {
|
||||
PreTickCallback.EVENT.invoker().preTick();
|
||||
}
|
||||
|
||||
@Inject(method = "displayGuiScreen", at = @At(value = "FIELD", target = "Lnet/minecraft/client/Minecraft;currentScreen:Lnet/minecraft/client/gui/GuiScreen;"))
|
||||
private void openGuiScreen(GuiScreen newGuiScreen, CallbackInfo ci) {
|
||||
@Inject(method = "openScreen", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/Screen;"))
|
||||
private void openGuiScreen(Screen newGuiScreen, CallbackInfo ci) {
|
||||
OpenGuiScreenCallback.EVENT.invoker().openGuiScreen(newGuiScreen);
|
||||
}
|
||||
//#else
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
//#if MC>=11400
|
||||
//$$ package com.replaymod.core.mixin;
|
||||
//$$
|
||||
//$$ import com.replaymod.core.ReplayMod;
|
||||
//$$ import com.replaymod.core.versions.LangResourcePack;
|
||||
//$$ import net.fabricmc.fabric.api.resource.ModResourcePack;
|
||||
//$$ import net.fabricmc.fabric.impl.resources.ModResourcePackUtil;
|
||||
//$$ import net.fabricmc.loader.api.FabricLoader;
|
||||
//$$ import net.fabricmc.loader.api.ModContainer;
|
||||
//$$ import net.minecraft.resource.ResourcePack;
|
||||
//$$ import net.minecraft.resource.ResourceType;
|
||||
//$$ import org.spongepowered.asm.mixin.Mixin;
|
||||
//$$ import org.spongepowered.asm.mixin.injection.At;
|
||||
//$$ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
//$$ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
//$$
|
||||
//$$ import java.util.List;
|
||||
//$$
|
||||
//$$ @Mixin(value = ModResourcePackUtil.class, remap = false)
|
||||
//$$ public class MixinModResourcePackUtil {
|
||||
//$$ @Inject(method = "appendModResourcePacks", at = @At("RETURN"), remap = false)
|
||||
//$$ private static void injectRMLangPack(List<ResourcePack> packList, ResourceType type, CallbackInfo ci) {
|
||||
//$$ if (type != ResourceType.ASSETS) return;
|
||||
//$$
|
||||
//$$ for (int i = 0; i < packList.size(); i++) {
|
||||
//$$ ResourcePack pack = packList.get(i);
|
||||
//$$ if (pack instanceof ModResourcePack && ((ModResourcePack) pack).getFabricModMetadata().getId().equals(ReplayMod.MOD_ID)) {
|
||||
//$$ ModContainer container = FabricLoader.getInstance().getModContainer(ReplayMod.MOD_ID).orElseThrow(IllegalAccessError::new);
|
||||
//$$ packList.add(i, new LangResourcePack(container.getRootPath()));
|
||||
//$$ return;
|
||||
//$$ }
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ throw new IllegalStateException("Could not find ReplayMod resource pack.");
|
||||
//$$ }
|
||||
//$$ }
|
||||
package com.replaymod.core.mixin;
|
||||
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import com.replaymod.core.versions.LangResourcePack;
|
||||
import net.fabricmc.fabric.api.resource.ModResourcePack;
|
||||
import net.fabricmc.fabric.impl.resources.ModResourcePackUtil;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.ModContainer;
|
||||
import net.minecraft.resource.ResourcePack;
|
||||
import net.minecraft.resource.ResourceType;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(value = ModResourcePackUtil.class, remap = false)
|
||||
public class MixinModResourcePackUtil {
|
||||
@Inject(method = "appendModResourcePacks", at = @At("RETURN"), remap = false)
|
||||
private static void injectRMLangPack(List<ResourcePack> packList, ResourceType type, CallbackInfo ci) {
|
||||
if (type != ResourceType.ASSETS) return;
|
||||
|
||||
for (int i = 0; i < packList.size(); i++) {
|
||||
ResourcePack pack = packList.get(i);
|
||||
if (pack instanceof ModResourcePack && ((ModResourcePack) pack).getFabricModMetadata().getId().equals(ReplayMod.MOD_ID)) {
|
||||
ModContainer container = FabricLoader.getInstance().getModContainer(ReplayMod.MOD_ID).orElseThrow(IllegalAccessError::new);
|
||||
packList.add(i, new LangResourcePack(container.getRootPath()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalStateException("Could not find ReplayMod resource pack.");
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
||||
@@ -1,60 +1,60 @@
|
||||
//#if MC>=11400
|
||||
//$$ package com.replaymod.core.mixin;
|
||||
//$$
|
||||
//$$ import com.replaymod.core.events.KeyBindingEventCallback;
|
||||
//$$ import de.johni0702.minecraft.gui.versions.callbacks.MouseCallback;
|
||||
//$$ import net.minecraft.client.Mouse;
|
||||
//$$ import net.minecraft.client.gui.Element;
|
||||
//$$ import net.minecraft.client.gui.Screen;
|
||||
//$$ import org.spongepowered.asm.mixin.Mixin;
|
||||
//$$ import org.spongepowered.asm.mixin.Shadow;
|
||||
//$$ import org.spongepowered.asm.mixin.injection.At;
|
||||
//$$ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
//$$ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
//$$ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
//$$
|
||||
//$$ @Mixin(Mouse.class)
|
||||
//$$ public class MixinMouseListener {
|
||||
//$$ @Shadow private int activeButton;
|
||||
//$$
|
||||
//$$ @Inject(method = "onMouseButton", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/options/KeyBinding;onKeyPressed(Lnet/minecraft/client/util/InputUtil$KeyCode;)V", shift = At.Shift.AFTER))
|
||||
//$$ private void afterKeyBindingTick(CallbackInfo ci) {
|
||||
//$$ KeyBindingEventCallback.EVENT.invoker().onKeybindingEvent();
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ @Inject(method = "method_1611", at = @At("HEAD"), cancellable = true)
|
||||
//$$ private void mouseDown(boolean[] result, double x, double y, int button, CallbackInfo ci) {
|
||||
//$$ if (MouseCallback.EVENT.invoker().mouseDown(x, y, button)) {
|
||||
//$$ result[0] = true;
|
||||
//$$ ci.cancel();
|
||||
//$$ }
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ @Inject(method = "method_1605", at = @At("HEAD"), cancellable = true)
|
||||
//$$ private void mouseUp(boolean[] result, double x, double y, int button, CallbackInfo ci) {
|
||||
//$$ if (MouseCallback.EVENT.invoker().mouseUp(x, y, button)) {
|
||||
//$$ result[0] = true;
|
||||
//$$ ci.cancel();
|
||||
//$$ }
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ @Inject(method = "method_1602", at = @At("HEAD"), cancellable = true)
|
||||
//$$ private void mouseDrag(Element element, double x, double y, double dx, double dy, CallbackInfo ci) {
|
||||
//$$ if (MouseCallback.EVENT.invoker().mouseDrag(x, y, this.activeButton, dx, dy)) {
|
||||
//$$ ci.cancel();
|
||||
//$$ }
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ @Redirect(
|
||||
//$$ method = "onMouseScroll",
|
||||
//$$ at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Screen;mouseScrolled(DDD)Z")
|
||||
//$$ )
|
||||
//$$ private boolean mouseScroll(Screen element, double x, double y, double scroll) {
|
||||
//$$ if (MouseCallback.EVENT.invoker().mouseScroll(x, y, scroll)) {
|
||||
//$$ return true;
|
||||
//$$ } else {
|
||||
//$$ return element.mouseScrolled(x, y, scroll);
|
||||
//$$ }
|
||||
//$$ }
|
||||
//$$ }
|
||||
package com.replaymod.core.mixin;
|
||||
|
||||
import com.replaymod.core.events.KeyBindingEventCallback;
|
||||
import de.johni0702.minecraft.gui.versions.callbacks.MouseCallback;
|
||||
import net.minecraft.client.Mouse;
|
||||
import net.minecraft.client.gui.Element;
|
||||
import net.minecraft.client.gui.Screen;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(Mouse.class)
|
||||
public class MixinMouseListener {
|
||||
@Shadow private int activeButton;
|
||||
|
||||
@Inject(method = "onMouseButton", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/options/KeyBinding;onKeyPressed(Lnet/minecraft/client/util/InputUtil$KeyCode;)V", shift = At.Shift.AFTER))
|
||||
private void afterKeyBindingTick(CallbackInfo ci) {
|
||||
KeyBindingEventCallback.EVENT.invoker().onKeybindingEvent();
|
||||
}
|
||||
|
||||
@Inject(method = "method_1611", at = @At("HEAD"), cancellable = true)
|
||||
private void mouseDown(boolean[] result, double x, double y, int button, CallbackInfo ci) {
|
||||
if (MouseCallback.EVENT.invoker().mouseDown(x, y, button)) {
|
||||
result[0] = true;
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "method_1605", at = @At("HEAD"), cancellable = true)
|
||||
private void mouseUp(boolean[] result, double x, double y, int button, CallbackInfo ci) {
|
||||
if (MouseCallback.EVENT.invoker().mouseUp(x, y, button)) {
|
||||
result[0] = true;
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "method_1602", at = @At("HEAD"), cancellable = true)
|
||||
private void mouseDrag(Element element, double x, double y, double dx, double dy, CallbackInfo ci) {
|
||||
if (MouseCallback.EVENT.invoker().mouseDrag(x, y, this.activeButton, dx, dy)) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = "onMouseScroll",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Screen;mouseScrolled(DDD)Z")
|
||||
)
|
||||
private boolean mouseScroll(Screen element, double x, double y, double scroll) {
|
||||
if (MouseCallback.EVENT.invoker().mouseScroll(x, y, scroll)) {
|
||||
return true;
|
||||
} else {
|
||||
return element.mouseScrolled(x, y, scroll);
|
||||
}
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
//#if MC>=11400
|
||||
//$$ package com.replaymod.core.mixin;
|
||||
//$$
|
||||
//$$ import de.johni0702.minecraft.gui.versions.callbacks.InitScreenCallback;
|
||||
//$$ import net.minecraft.client.MinecraftClient;
|
||||
//$$ import net.minecraft.client.gui.Screen;
|
||||
//$$ import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
||||
//$$ import org.spongepowered.asm.mixin.Final;
|
||||
//$$ import org.spongepowered.asm.mixin.Mixin;
|
||||
//$$ import org.spongepowered.asm.mixin.Shadow;
|
||||
//$$ import org.spongepowered.asm.mixin.injection.At;
|
||||
//$$ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
//$$ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
//$$
|
||||
//$$ import java.util.List;
|
||||
//$$
|
||||
//$$ @Mixin(Screen.class)
|
||||
//$$ public class MixinScreen {
|
||||
//$$ @Shadow
|
||||
//$$ protected @Final List<AbstractButtonWidget> buttons;
|
||||
//$$
|
||||
//$$ @Inject(method = "init(Lnet/minecraft/client/MinecraftClient;II)V", at = @At("RETURN"))
|
||||
//$$ private void init(MinecraftClient minecraftClient_1, int int_1, int int_2, CallbackInfo ci) {
|
||||
//$$ InitScreenCallback.EVENT.invoker().initScreen((Screen) (Object) this, buttons);
|
||||
//$$ }
|
||||
//$$ }
|
||||
package com.replaymod.core.mixin;
|
||||
|
||||
import de.johni0702.minecraft.gui.versions.callbacks.InitScreenCallback;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.Screen;
|
||||
import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(Screen.class)
|
||||
public class MixinScreen {
|
||||
@Shadow
|
||||
protected @Final List<AbstractButtonWidget> buttons;
|
||||
|
||||
@Inject(method = "init(Lnet/minecraft/client/MinecraftClient;II)V", at = @At("RETURN"))
|
||||
private void init(MinecraftClient minecraftClient_1, int int_1, int int_2, CallbackInfo ci) {
|
||||
InitScreenCallback.EVENT.invoker().initScreen((Screen) (Object) this, buttons);
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
package com.replaymod.core.mixin;
|
||||
|
||||
import net.minecraft.util.Timer;
|
||||
import net.minecraft.client.render.RenderTickCounter;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(Timer.class)
|
||||
@Mixin(RenderTickCounter.class)
|
||||
public interface TimerAccessor {
|
||||
@Accessor
|
||||
@Accessor("prevTimeMillis")
|
||||
long getLastSyncSysClock();
|
||||
@Accessor
|
||||
@Accessor("prevTimeMillis")
|
||||
void setLastSyncSysClock(long value);
|
||||
|
||||
//#if MC>=11200
|
||||
@Accessor
|
||||
@Accessor("timeScale")
|
||||
float getTickLength();
|
||||
@Accessor
|
||||
@Accessor("timeScale")
|
||||
void setTickLength(float value);
|
||||
//#else
|
||||
//$$ @Accessor
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package com.replaymod.core.utils;
|
||||
|
||||
import com.replaymod.replaystudio.data.ModInfo;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ import net.fabricmc.loader.api.FabricLoader;
|
||||
//$$ import net.fabricmc.loader.api.ModContainer;
|
||||
//$$ import net.minecraft.util.registry.Registry;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.ModContainer;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
//#else
|
||||
//#if MC>=11200
|
||||
import net.minecraftforge.registries.ForgeRegistry;
|
||||
import net.minecraftforge.registries.RegistryManager;
|
||||
//$$ import net.minecraftforge.registries.ForgeRegistry;
|
||||
//$$ import net.minecraftforge.registries.RegistryManager;
|
||||
//#else
|
||||
//#if MC>=10800
|
||||
//$$ import net.minecraftforge.fml.common.registry.GameData;
|
||||
@@ -19,10 +19,10 @@ import net.minecraftforge.registries.RegistryManager;
|
||||
//#endif
|
||||
//$$ import java.util.stream.Stream;
|
||||
//#endif
|
||||
|
||||
//$$
|
||||
//#if MC>=10800
|
||||
//#if MC>=11300
|
||||
import net.minecraftforge.fml.ModList;
|
||||
//$$ import net.minecraftforge.fml.ModList;
|
||||
//#else
|
||||
//$$ import net.minecraftforge.fml.common.Loader;
|
||||
//$$ import net.minecraftforge.fml.common.ModContainer;
|
||||
@@ -42,21 +42,21 @@ public class ModCompat {
|
||||
public static Collection<ModInfo> getInstalledNetworkMods() {
|
||||
//#if MC>=11300
|
||||
//#if MC>=11400
|
||||
//$$ Map<String, ModInfo> modInfoMap = FabricLoader.getInstance().getAllMods().stream()
|
||||
//$$ .map(ModContainer::getMetadata)
|
||||
//$$ .map(m -> new ModInfo(m.getId(), m.getName(), m.getVersion().toString()))
|
||||
//$$ .collect(Collectors.toMap(ModInfo::getId, Function.identity()));
|
||||
//$$ return Registry.REGISTRIES.stream()
|
||||
//$$ .map(Registry::getIds).flatMap(Set::stream)
|
||||
//#else
|
||||
Map<String, ModInfo> modInfoMap = ModList.get().getMods().stream()
|
||||
.map(m -> new ModInfo(m.getModId(), m.getDisplayName(), m.getVersion().toString()))
|
||||
Map<String, ModInfo> modInfoMap = FabricLoader.getInstance().getAllMods().stream()
|
||||
.map(ModContainer::getMetadata)
|
||||
.map(m -> new ModInfo(m.getId(), m.getName(), m.getVersion().toString()))
|
||||
.collect(Collectors.toMap(ModInfo::getId, Function.identity()));
|
||||
return RegistryManager.ACTIVE.takeSnapshot(false).keySet().stream()
|
||||
.map(RegistryManager.ACTIVE::getRegistry)
|
||||
.map(ForgeRegistry::getKeys).flatMap(Set::stream)
|
||||
return Registry.REGISTRIES.stream()
|
||||
.map(Registry::getIds).flatMap(Set::stream)
|
||||
//#else
|
||||
//$$ Map<String, ModInfo> modInfoMap = ModList.get().getMods().stream()
|
||||
//$$ .map(m -> new ModInfo(m.getModId(), m.getDisplayName(), m.getVersion().toString()))
|
||||
//$$ .collect(Collectors.toMap(ModInfo::getId, Function.identity()));
|
||||
//$$ return RegistryManager.ACTIVE.takeSnapshot(false).keySet().stream()
|
||||
//$$ .map(RegistryManager.ACTIVE::getRegistry)
|
||||
//$$ .map(ForgeRegistry::getKeys).flatMap(Set::stream)
|
||||
//#endif
|
||||
.map(ResourceLocation::getNamespace).filter(s -> !s.equals("minecraft")).distinct()
|
||||
.map(Identifier::getNamespace).filter(s -> !s.equals("minecraft")).distinct()
|
||||
.map(modInfoMap::get).filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
//#else
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.replaymod.core.utils;
|
||||
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.PacketByteBuf;
|
||||
//#if MC>=10904
|
||||
import net.minecraft.network.play.server.SPacketCustomPayload;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.client.network.packet.CustomPayloadS2CPacket;
|
||||
import net.minecraft.util.Identifier;
|
||||
//#else
|
||||
//$$ import net.minecraft.network.play.server.S3FPacketCustomPayload;
|
||||
//#endif
|
||||
@@ -20,7 +20,7 @@ import static com.replaymod.core.versions.MCVer.readString;
|
||||
*/
|
||||
public class Restrictions {
|
||||
//#if MC>=11300
|
||||
public static final ResourceLocation PLUGIN_CHANNEL = new ResourceLocation("replaymod", "restrict");
|
||||
public static final Identifier PLUGIN_CHANNEL = new Identifier("replaymod", "restrict");
|
||||
//#else
|
||||
//$$ public static final String PLUGIN_CHANNEL = "Replay|Restrict";
|
||||
//#endif
|
||||
@@ -30,12 +30,12 @@ public class Restrictions {
|
||||
private boolean onlyRecordingPlayer;
|
||||
|
||||
//#if MC>=10904
|
||||
public String handle(SPacketCustomPayload packet) {
|
||||
public String handle(CustomPayloadS2CPacket packet) {
|
||||
//#else
|
||||
//$$ public String handle(S3FPacketCustomPayload packet) {
|
||||
//#endif
|
||||
//#if MC>=10800
|
||||
PacketBuffer buffer = packet.getBufferData();
|
||||
PacketByteBuf buffer = packet.getData();
|
||||
//#else
|
||||
//$$ PacketBuffer buffer = new PacketBuffer(Unpooled.wrappedBuffer(packet.func_149168_d()));
|
||||
//#endif
|
||||
|
||||
@@ -21,9 +21,9 @@ import de.johni0702.minecraft.gui.utils.Colors;
|
||||
import de.johni0702.minecraft.gui.utils.lwjgl.Dimension;
|
||||
import de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension;
|
||||
import de.johni0702.minecraft.gui.versions.MCVer;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.client.gui.Screen;
|
||||
import net.minecraft.util.crash.CrashReport;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.apache.commons.io.Charsets;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -34,8 +34,8 @@ import org.apache.logging.log4j.Logger;
|
||||
//#endif
|
||||
|
||||
//#if MC>=10800
|
||||
import net.minecraft.client.network.NetworkPlayerInfo;
|
||||
import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||
import net.minecraft.client.network.PlayerListEntry;
|
||||
import net.minecraft.client.util.DefaultSkinHelper;
|
||||
|
||||
//#else
|
||||
//$$ import net.minecraft.client.Minecraft;
|
||||
@@ -186,14 +186,14 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
public static ResourceLocation getResourceLocationForPlayerUUID(UUID uuid) {
|
||||
public static Identifier getResourceLocationForPlayerUUID(UUID uuid) {
|
||||
//#if MC>=10800
|
||||
NetworkPlayerInfo info = getMinecraft().getConnection().getPlayerInfo(uuid);
|
||||
ResourceLocation skinLocation;
|
||||
if (info != null && info.hasLocationSkin()) {
|
||||
skinLocation = info.getLocationSkin();
|
||||
PlayerListEntry info = getMinecraft().getNetworkHandler().getPlayerListEntry(uuid);
|
||||
Identifier skinLocation;
|
||||
if (info != null && info.hasSkinTexture()) {
|
||||
skinLocation = info.getSkinTexture();
|
||||
} else {
|
||||
skinLocation = DefaultPlayerSkin.getDefaultSkin(uuid);
|
||||
skinLocation = DefaultSkinHelper.getTexture(uuid);
|
||||
}
|
||||
return skinLocation;
|
||||
//#else
|
||||
@@ -207,7 +207,7 @@ public class Utils {
|
||||
|
||||
public static boolean isCtrlDown() {
|
||||
//#if MC>=11300
|
||||
return GuiScreen.isCtrlKeyDown();
|
||||
return Screen.hasControlDown();
|
||||
//#else
|
||||
//$$ return Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL);
|
||||
//#endif
|
||||
@@ -229,7 +229,7 @@ public class Utils {
|
||||
|
||||
public static GuiInfoPopup error(Logger logger, GuiContainer container, CrashReport crashReport, Runnable onClose) {
|
||||
// Convert crash report to string
|
||||
String crashReportStr = crashReport.getCompleteReport();
|
||||
String crashReportStr = crashReport.asString();
|
||||
|
||||
// Log via logger
|
||||
logger.error(crashReportStr);
|
||||
@@ -237,10 +237,10 @@ public class Utils {
|
||||
// Try to save the crash report
|
||||
if (crashReport.getFile() == null) {
|
||||
try {
|
||||
File folder = new File(getMinecraft().gameDir, "crash-reports");
|
||||
File folder = new File(getMinecraft().runDirectory, "crash-reports");
|
||||
File file = new File(folder, "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-client.txt");
|
||||
logger.debug("Saving crash report to file: {}", file);
|
||||
crashReport.saveToFile(file);
|
||||
crashReport.writeToFile(file);
|
||||
} catch (Throwable t) {
|
||||
logger.error("Saving crash report file:", t);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.replaymod.core.utils;
|
||||
|
||||
import com.replaymod.core.mixin.TimerAccessor;
|
||||
import net.minecraft.util.Timer;
|
||||
import net.minecraft.client.render.RenderTickCounter;
|
||||
|
||||
public class WrappedTimer extends Timer {
|
||||
public class WrappedTimer extends RenderTickCounter {
|
||||
public static final float DEFAULT_MS_PER_TICK = 1000 / 20;
|
||||
|
||||
protected final Timer wrapped;
|
||||
protected final RenderTickCounter wrapped;
|
||||
|
||||
public WrappedTimer(Timer wrapped) {
|
||||
public WrappedTimer(RenderTickCounter wrapped) {
|
||||
//#if MC>=11300
|
||||
super(0, 0);
|
||||
//#else
|
||||
@@ -19,13 +19,13 @@ public class WrappedTimer extends Timer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTimer(
|
||||
public void beginRenderTick(
|
||||
//#if MC>=11300
|
||||
long sysClock
|
||||
//#endif
|
||||
) {
|
||||
copy(this, wrapped);
|
||||
wrapped.updateTimer(
|
||||
wrapped.beginRenderTick(
|
||||
//#if MC>=11300
|
||||
sysClock
|
||||
//#endif
|
||||
@@ -33,14 +33,14 @@ public class WrappedTimer extends Timer {
|
||||
copy(wrapped, this);
|
||||
}
|
||||
|
||||
protected void copy(Timer from, Timer to) {
|
||||
protected void copy(RenderTickCounter from, RenderTickCounter to) {
|
||||
TimerAccessor fromA = (TimerAccessor) from;
|
||||
TimerAccessor toA = (TimerAccessor) to;
|
||||
|
||||
to.elapsedTicks = from.elapsedTicks;
|
||||
to.renderPartialTicks = from.renderPartialTicks;
|
||||
to.ticksThisFrame = from.ticksThisFrame;
|
||||
to.tickDelta = from.tickDelta;
|
||||
toA.setLastSyncSysClock(fromA.getLastSyncSysClock());
|
||||
to.elapsedPartialTicks = from.elapsedPartialTicks;
|
||||
to.lastFrameDuration = from.lastFrameDuration;
|
||||
//#if MC>=11200
|
||||
toA.setTickLength(fromA.getTickLength());
|
||||
//#else
|
||||
|
||||
@@ -3,10 +3,10 @@ package com.replaymod.core.versions;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import net.minecraft.resources.AbstractResourcePack;
|
||||
import net.minecraft.resources.ResourcePackFileNotFoundException;
|
||||
import net.minecraft.resources.ResourcePackType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resource.AbstractFilenameResourcePack;
|
||||
import net.minecraft.resource.ResourceNotFoundException;
|
||||
import net.minecraft.resource.ResourceType;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
@@ -28,40 +28,40 @@ import java.util.stream.Collectors;
|
||||
|
||||
//#if MC>=11400
|
||||
//#else
|
||||
import net.minecraft.resources.IPackFinder;
|
||||
import net.minecraft.resources.ResourcePackInfo;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
||||
import net.minecraftforge.fml.packs.ModFileResourcePack;
|
||||
import net.minecraftforge.fml.packs.ResourcePackLoader;
|
||||
//$$ import net.minecraft.resources.IPackFinder;
|
||||
//$$ import net.minecraft.resources.ResourcePackInfo;
|
||||
//$$ import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
||||
//$$ import net.minecraftforge.fml.packs.ModFileResourcePack;
|
||||
//$$ import net.minecraftforge.fml.packs.ResourcePackLoader;
|
||||
//#endif
|
||||
|
||||
/**
|
||||
* Resource pack which on-the-fly converts pre-1.13 language files into 1.13 json format.
|
||||
* Also remaps `replaymod.input.*` bindings to `key.replaymod.*` as convention on Fabric.
|
||||
*/
|
||||
public class LangResourcePack extends AbstractResourcePack {
|
||||
public class LangResourcePack extends AbstractFilenameResourcePack {
|
||||
private static final Gson GSON = new Gson();
|
||||
private static final String NAME = "replaymod_lang";
|
||||
private static final Pattern JSON_FILE_PATTERN = Pattern.compile("^assets/" + ReplayMod.MOD_ID + "/lang/([a-z][a-z])_([a-z][a-z]).json$");
|
||||
private static final Pattern LANG_FILE_NAME_PATTERN = Pattern.compile("^([a-z][a-z])_([a-z][a-z]).lang$");
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ public static final String LEGACY_KEY_PREFIX = "replaymod.input.";
|
||||
//$$ private static final String FABRIC_KEY_FORMAT = "key." + ReplayMod.MOD_ID + ".%s";
|
||||
//$$
|
||||
//$$ private final Path basePath;
|
||||
//$$ public LangResourcePack(Path basePath) {
|
||||
//$$ super(new File(NAME));
|
||||
//$$ this.basePath = basePath;
|
||||
//$$ }
|
||||
//#else
|
||||
public LangResourcePack() {
|
||||
super(new File(NAME));
|
||||
}
|
||||
public static final String LEGACY_KEY_PREFIX = "replaymod.input.";
|
||||
private static final String FABRIC_KEY_FORMAT = "key." + ReplayMod.MOD_ID + ".%s";
|
||||
|
||||
private ModFileResourcePack getParent() {
|
||||
return ResourcePackLoader.getResourcePackFor(ReplayMod.MOD_ID).orElseThrow(() -> new RuntimeException("Failed to get ReplayMod resource pack!"));
|
||||
private final Path basePath;
|
||||
public LangResourcePack(Path basePath) {
|
||||
super(new File(NAME));
|
||||
this.basePath = basePath;
|
||||
}
|
||||
//#else
|
||||
//$$ public LangResourcePack() {
|
||||
//$$ super(new File(NAME));
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ private ModFileResourcePack getParent() {
|
||||
//$$ return ResourcePackLoader.getResourcePackFor(ReplayMod.MOD_ID).orElseThrow(() -> new RuntimeException("Failed to get ReplayMod resource pack!"));
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
private String langName(String path) {
|
||||
@@ -71,16 +71,16 @@ public class LangResourcePack extends AbstractResourcePack {
|
||||
}
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ private Path baseLangPath() {
|
||||
//$$ return basePath.resolve("assets").resolve(ReplayMod.MOD_ID).resolve("lang");
|
||||
//$$ }
|
||||
//#else
|
||||
private Path baseLangPath() {
|
||||
ModFileResourcePack parent = getParent();
|
||||
if (parent == null) return null;
|
||||
ModFile modFile = parent.getModFile();
|
||||
return modFile.getLocator().findPath(modFile, "assets", ReplayMod.MOD_ID, "lang");
|
||||
return basePath.resolve("assets").resolve(ReplayMod.MOD_ID).resolve("lang");
|
||||
}
|
||||
//#else
|
||||
//$$ private Path baseLangPath() {
|
||||
//$$ ModFileResourcePack parent = getParent();
|
||||
//$$ if (parent == null) return null;
|
||||
//$$ ModFile modFile = parent.getModFile();
|
||||
//$$ return modFile.getLocator().findPath(modFile, "assets", ReplayMod.MOD_ID, "lang");
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
private Path langPath(String path) {
|
||||
@@ -88,7 +88,7 @@ public class LangResourcePack extends AbstractResourcePack {
|
||||
if (langName == null) return null;
|
||||
Path basePath = baseLangPath();
|
||||
//#if MC<11400
|
||||
if (basePath == null) return null;
|
||||
//$$ if (basePath == null) return null;
|
||||
//#endif
|
||||
return basePath.resolve(langName);
|
||||
}
|
||||
@@ -98,13 +98,13 @@ public class LangResourcePack extends AbstractResourcePack {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InputStream getInputStream(String path) throws IOException {
|
||||
protected InputStream openFilename(String path) throws IOException {
|
||||
if ("pack.mcmeta".equals(path)) {
|
||||
return new ByteArrayInputStream("{\"pack\": {\"description\": \"ReplayMod language files\", \"pack_format\": 4}}".getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
Path langPath = langPath(path);
|
||||
if (langPath == null) throw new ResourcePackFileNotFoundException(this.file, path);
|
||||
if (langPath == null) throw new ResourceNotFoundException(this.base, path);
|
||||
|
||||
String langFile;
|
||||
try (InputStream in = Files.newInputStream(langPath)) {
|
||||
@@ -119,9 +119,9 @@ public class LangResourcePack extends AbstractResourcePack {
|
||||
String value = line.substring(i + 1);
|
||||
value = convertValue(value);
|
||||
//#if MC>=11400
|
||||
//$$ if (key.startsWith(LEGACY_KEY_PREFIX)) {
|
||||
//$$ key = String.format(FABRIC_KEY_FORMAT, key.substring(LEGACY_KEY_PREFIX.length()));
|
||||
//$$ }
|
||||
if (key.startsWith(LEGACY_KEY_PREFIX)) {
|
||||
key = String.format(FABRIC_KEY_FORMAT, key.substring(LEGACY_KEY_PREFIX.length()));
|
||||
}
|
||||
//#endif
|
||||
properties.put(key, value);
|
||||
}
|
||||
@@ -130,18 +130,18 @@ public class LangResourcePack extends AbstractResourcePack {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean resourceExists(String path) {
|
||||
protected boolean containsFilename(String path) {
|
||||
Path langPath = langPath(path);
|
||||
return langPath != null && Files.exists(langPath);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getAllResourceLocations(ResourcePackType resourcePackType, String path, int maxDepth, Predicate<String> filter) {
|
||||
if (resourcePackType == ResourcePackType.CLIENT_RESOURCES && "lang".equals(path)) {
|
||||
public Collection<Identifier> findResources(ResourceType resourcePackType, String path, int maxDepth, Predicate<String> filter) {
|
||||
if (resourcePackType == ResourceType.ASSETS && "lang".equals(path)) {
|
||||
Path base = baseLangPath();
|
||||
//#if MC<11400
|
||||
if (base == null) return Collections.emptyList();
|
||||
//$$ if (base == null) return Collections.emptyList();
|
||||
//#endif
|
||||
try {
|
||||
return Files.walk(base, 1)
|
||||
@@ -152,7 +152,7 @@ public class LangResourcePack extends AbstractResourcePack {
|
||||
.filter(Matcher::matches)
|
||||
.map(matcher -> String.format("%s_%s.json", matcher.group(1), matcher.group(1)))
|
||||
.filter(filter::test)
|
||||
.map(name -> new ResourceLocation(ReplayMod.MOD_ID, "lang/" + name))
|
||||
.map(name -> new Identifier(ReplayMod.MOD_ID, "lang/" + name))
|
||||
.collect(Collectors.toList());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
@@ -164,8 +164,8 @@ public class LangResourcePack extends AbstractResourcePack {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getResourceNamespaces(ResourcePackType resourcePackType) {
|
||||
if (resourcePackType == ResourcePackType.CLIENT_RESOURCES) {
|
||||
public Set<String> getNamespaces(ResourceType resourcePackType) {
|
||||
if (resourcePackType == ResourceType.ASSETS) {
|
||||
return Collections.singleton("replaymod");
|
||||
} else {
|
||||
return Collections.emptySet();
|
||||
@@ -177,12 +177,12 @@ public class LangResourcePack extends AbstractResourcePack {
|
||||
|
||||
// Not needed on fabric, using MixinModResourcePackUtil instead.
|
||||
//#if MC<11400
|
||||
public static class Finder implements IPackFinder {
|
||||
@Override
|
||||
public <T extends ResourcePackInfo> void addPackInfosToMap(Map<String, T> packList, ResourcePackInfo.IFactory<T> factory) {
|
||||
packList.put(NAME, ResourcePackInfo.func_195793_a(NAME, true, LangResourcePack::new, factory, ResourcePackInfo.Priority.BOTTOM));
|
||||
}
|
||||
}
|
||||
//$$ public static class Finder implements IPackFinder {
|
||||
//$$ @Override
|
||||
//$$ public <T extends ResourcePackInfo> void addPackInfosToMap(Map<String, T> packList, ResourcePackInfo.IFactory<T> factory) {
|
||||
//$$ packList.put(NAME, ResourcePackInfo.func_195793_a(NAME, true, LangResourcePack::new, factory, ResourcePackInfo.Priority.BOTTOM));
|
||||
//$$ }
|
||||
//$$ }
|
||||
//#endif
|
||||
}
|
||||
//#endif
|
||||
|
||||
@@ -2,44 +2,44 @@ package com.replaymod.core.versions;
|
||||
|
||||
import com.replaymod.core.mixin.GuiScreenAccessor;
|
||||
import com.replaymod.core.mixin.MinecraftAccessor;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.entity.model.ModelBox;
|
||||
import net.minecraft.client.renderer.entity.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.crash.CrashReportCategory;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.gui.Screen;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.client.render.Tessellator;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.model.Box;
|
||||
import net.minecraft.client.model.Cuboid;
|
||||
import net.minecraft.client.texture.SpriteAtlasTexture;
|
||||
import net.minecraft.util.crash.CrashReportSection;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.PacketByteBuf;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.SystemUtil;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.WorldChunk;
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ import com.replaymod.core.mixin.AbstractButtonWidgetAccessor;
|
||||
//$$ import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
||||
//$$ import java.util.concurrent.CompletableFuture;
|
||||
import com.replaymod.core.mixin.AbstractButtonWidgetAccessor;
|
||||
import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
//#else
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.client.event.RenderLivingEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
//$$ import com.google.common.util.concurrent.FutureCallback;
|
||||
//$$ import com.google.common.util.concurrent.Futures;
|
||||
//$$ import com.google.common.util.concurrent.ListenableFuture;
|
||||
//$$ import net.minecraft.entity.EntityLivingBase;
|
||||
//$$ import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
//$$ import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
//$$ import net.minecraftforge.client.event.RenderLivingEvent;
|
||||
//$$ import net.minecraftforge.common.MinecraftForge;
|
||||
//$$ import net.minecraftforge.eventbus.api.IEventBus;
|
||||
//#endif
|
||||
|
||||
//#if MC>=11300
|
||||
import net.minecraft.client.MainWindow;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
import net.minecraft.client.util.Window;
|
||||
import net.minecraft.client.util.InputUtil;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
//#else
|
||||
//$$ import net.minecraft.client.gui.ScaledResolution;
|
||||
@@ -58,17 +58,17 @@ import net.minecraft.util.math.Vec3d;
|
||||
//#endif
|
||||
|
||||
//#if MC>=10809
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.render.VertexFormats;
|
||||
//#else
|
||||
//$$ import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
//#endif
|
||||
|
||||
//#if MC>=10800
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import net.minecraft.world.WorldType;
|
||||
import net.minecraft.client.render.BufferBuilder;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.client.render.VertexFormat;
|
||||
import net.minecraft.client.render.VertexFormatElement;
|
||||
import net.minecraft.world.level.LevelGeneratorType;
|
||||
//#else
|
||||
//$$ import com.replaymod.core.mixin.ResourcePackRepositoryAccessor;
|
||||
//$$ import com.google.common.util.concurrent.Futures;
|
||||
@@ -79,10 +79,10 @@ import net.minecraft.world.WorldType;
|
||||
//#endif
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
//#else
|
||||
//#if MC>=11300
|
||||
import net.minecraftforge.fml.ModList;
|
||||
//$$ import net.minecraftforge.fml.ModList;
|
||||
//#else
|
||||
//$$ import net.minecraftforge.fml.common.Loader;
|
||||
//#endif
|
||||
@@ -99,9 +99,9 @@ import java.util.function.Consumer;
|
||||
*/
|
||||
public class MCVer {
|
||||
//#if MC<11400
|
||||
public static IEventBus FORGE_BUS = MinecraftForge.EVENT_BUS;
|
||||
//$$ public static IEventBus FORGE_BUS = MinecraftForge.EVENT_BUS;
|
||||
//#if MC>=10809
|
||||
public static IEventBus FML_BUS = FORGE_BUS;
|
||||
//$$ public static IEventBus FML_BUS = FORGE_BUS;
|
||||
//#else
|
||||
//$$ public static EventBus FML_BUS = FMLCommonHandler.instance().bus();
|
||||
//#endif
|
||||
@@ -109,20 +109,20 @@ public class MCVer {
|
||||
|
||||
public static boolean isModLoaded(String id) {
|
||||
//#if MC>=11400
|
||||
//$$ return FabricLoader.getInstance().isModLoaded(id.toLowerCase());
|
||||
return FabricLoader.getInstance().isModLoaded(id.toLowerCase());
|
||||
//#else
|
||||
//#if MC>=11300
|
||||
return ModList.get().isLoaded(id.toLowerCase());
|
||||
//$$ return ModList.get().isLoaded(id.toLowerCase());
|
||||
//#else
|
||||
//$$ return Loader.isModLoaded(id);
|
||||
//#endif
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static void addDetail(CrashReportCategory category, String name, Callable<String> callable) {
|
||||
public static void addDetail(CrashReportSection category, String name, Callable<String> callable) {
|
||||
//#if MC>=10904
|
||||
//#if MC>=11200
|
||||
category.addDetail(name, callable::call);
|
||||
category.add(name, callable::call);
|
||||
//#else
|
||||
//$$ category.setDetail(name, callable::call);
|
||||
//#endif
|
||||
@@ -132,83 +132,83 @@ public class MCVer {
|
||||
}
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ public static void width(AbstractButtonWidget button, int value) {
|
||||
//$$ button.setWidth(value);
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ public static int width(AbstractButtonWidget button) {
|
||||
//$$ return button.getWidth();
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ public static int height(AbstractButtonWidget button) {
|
||||
//$$ return ((AbstractButtonWidgetAccessor) button).getHeight();
|
||||
//$$ }
|
||||
public static void width(AbstractButtonWidget button, int value) {
|
||||
button.setWidth(value);
|
||||
}
|
||||
|
||||
public static int width(AbstractButtonWidget button) {
|
||||
return button.getWidth();
|
||||
}
|
||||
|
||||
public static int height(AbstractButtonWidget button) {
|
||||
return ((AbstractButtonWidgetAccessor) button).getHeight();
|
||||
}
|
||||
//#else
|
||||
public static void width(GuiButton button, int value) {
|
||||
button.width = value;
|
||||
}
|
||||
|
||||
public static int width(GuiButton button) {
|
||||
return button.width;
|
||||
}
|
||||
|
||||
public static int height(GuiButton button) {
|
||||
return button.height;
|
||||
}
|
||||
//$$ public static void width(GuiButton button, int value) {
|
||||
//$$ button.width = value;
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ public static int width(GuiButton button) {
|
||||
//$$ return button.width;
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ public static int height(GuiButton button) {
|
||||
//$$ return button.height;
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
//#if MC<11400
|
||||
public static void addButton(GuiScreenEvent.InitGuiEvent event, GuiButton button) {
|
||||
//$$ public static void addButton(GuiScreenEvent.InitGuiEvent event, GuiButton button) {
|
||||
//#if MC>=11300
|
||||
event.addButton(button);
|
||||
//$$ event.addButton(button);
|
||||
//#else
|
||||
//$$ getButtonList(event).add(button);
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static void removeButton(GuiScreenEvent.InitGuiEvent event, GuiButton button) {
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ public static void removeButton(GuiScreenEvent.InitGuiEvent event, GuiButton button) {
|
||||
//#if MC>=11300
|
||||
event.removeButton(button);
|
||||
//$$ event.removeButton(button);
|
||||
//#else
|
||||
//$$ getButtonList(event).remove(button);
|
||||
//#endif
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static List<GuiButton> getButtonList(GuiScreenEvent.InitGuiEvent event) {
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ @SuppressWarnings("unchecked")
|
||||
//$$ public static List<GuiButton> getButtonList(GuiScreenEvent.InitGuiEvent event) {
|
||||
//#if MC>=10904
|
||||
return event.getButtonList();
|
||||
//$$ return event.getButtonList();
|
||||
//#else
|
||||
//$$ return event.buttonList;
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static GuiButton getButton(GuiScreenEvent.ActionPerformedEvent event) {
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ public static GuiButton getButton(GuiScreenEvent.ActionPerformedEvent event) {
|
||||
//#if MC>=10904
|
||||
return event.getButton();
|
||||
//$$ return event.getButton();
|
||||
//#else
|
||||
//$$ return event.button;
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static GuiScreen getGui(GuiScreenEvent event) {
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ public static GuiScreen getGui(GuiScreenEvent event) {
|
||||
//#if MC>=10904
|
||||
return event.getGui();
|
||||
//$$ return event.getGui();
|
||||
//#else
|
||||
//$$ return event.gui;
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static EntityLivingBase getEntity(RenderLivingEvent event) {
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ public static EntityLivingBase getEntity(RenderLivingEvent event) {
|
||||
//#if MC>=10904
|
||||
return event.getEntity();
|
||||
//$$ return event.getEntity();
|
||||
//#else
|
||||
//$$ return event.entity;
|
||||
//#endif
|
||||
}
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
public static String readString(PacketBuffer buffer, int max) {
|
||||
public static String readString(PacketByteBuf buffer, int max) {
|
||||
//#if MC>=11102
|
||||
return buffer.readString(max);
|
||||
//#else
|
||||
@@ -225,27 +225,27 @@ public class MCVer {
|
||||
}
|
||||
|
||||
//#if MC<11400
|
||||
public static RenderGameOverlayEvent.ElementType getType(RenderGameOverlayEvent event) {
|
||||
//$$ public static RenderGameOverlayEvent.ElementType getType(RenderGameOverlayEvent event) {
|
||||
//#if MC>=10904
|
||||
return event.getType();
|
||||
//$$ return event.getType();
|
||||
//#else
|
||||
//$$ return event.type;
|
||||
//#endif
|
||||
}
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
//#if MC>=10800
|
||||
public static WorldType WorldType_DEBUG_ALL_BLOCK_STATES
|
||||
public static LevelGeneratorType WorldType_DEBUG_ALL_BLOCK_STATES
|
||||
//#if MC>=11200
|
||||
= WorldType.DEBUG_ALL_BLOCK_STATES;
|
||||
= LevelGeneratorType.DEBUG_ALL_BLOCK_STATES;
|
||||
//#else
|
||||
//$$ = WorldType.DEBUG_WORLD;
|
||||
//#endif
|
||||
//#endif
|
||||
|
||||
//#if MC>=10800
|
||||
public static Entity getRenderViewEntity(Minecraft mc) {
|
||||
return mc.getRenderViewEntity();
|
||||
public static Entity getRenderViewEntity(MinecraftClient mc) {
|
||||
return mc.getCameraEntity();
|
||||
}
|
||||
//#else
|
||||
//$$ public static EntityLivingBase getRenderViewEntity(Minecraft mc) {
|
||||
@@ -254,8 +254,8 @@ public class MCVer {
|
||||
//#endif
|
||||
|
||||
//#if MC>=10800
|
||||
public static void setRenderViewEntity(Minecraft mc, Entity entity) {
|
||||
mc.setRenderViewEntity(entity);
|
||||
public static void setRenderViewEntity(MinecraftClient mc, Entity entity) {
|
||||
mc.setCameraEntity(entity);
|
||||
}
|
||||
//#else
|
||||
//$$ public static void setRenderViewEntity(Minecraft mc, EntityLivingBase entity) {
|
||||
@@ -263,63 +263,63 @@ public class MCVer {
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
public static ResourceLocation LOCATION_BLOCKS_TEXTURE
|
||||
public static Identifier LOCATION_BLOCKS_TEXTURE
|
||||
//#if MC>=10904
|
||||
= TextureMap.LOCATION_BLOCKS_TEXTURE;
|
||||
= SpriteAtlasTexture.BLOCK_ATLAS_TEX;
|
||||
//#else
|
||||
//$$ = TextureMap.locationBlocksTexture;
|
||||
//#endif
|
||||
|
||||
public static Entity getRiddenEntity(Entity ridden) {
|
||||
//#if MC>=10904
|
||||
return ridden.getRidingEntity();
|
||||
return ridden.getVehicle();
|
||||
//#else
|
||||
//$$ return ridden.ridingEntity;
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static Iterable<Entity> loadedEntityList(WorldClient world) {
|
||||
public static Iterable<Entity> loadedEntityList(ClientWorld world) {
|
||||
//#if MC>=11400
|
||||
//$$ return world.getEntities();
|
||||
return world.getEntities();
|
||||
//#else
|
||||
return world.loadedEntityList;
|
||||
//$$ return world.loadedEntityList;
|
||||
//#endif
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Collection<Entity>[] getEntityLists(Chunk chunk) {
|
||||
public static Collection<Entity>[] getEntityLists(WorldChunk chunk) {
|
||||
//#if MC>=10800
|
||||
return chunk.getEntityLists();
|
||||
return chunk.getEntitySectionArray();
|
||||
//#else
|
||||
//$$ return chunk.entityLists;
|
||||
//#endif
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static List<ModelBox> cubeList(ModelRenderer modelRenderer) {
|
||||
return modelRenderer.cubeList;
|
||||
public static List<Box> cubeList(Cuboid modelRenderer) {
|
||||
return modelRenderer.boxes;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static List<EntityPlayer> playerEntities(World world) {
|
||||
public static List<PlayerEntity> playerEntities(World world) {
|
||||
//#if MC>=11400
|
||||
//$$ return (List) world.getPlayers();
|
||||
return (List) world.getPlayers();
|
||||
//#else
|
||||
return world.playerEntities;
|
||||
//$$ return world.playerEntities;
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static boolean isOnMainThread() {
|
||||
//#if MC>=11400
|
||||
//$$ return getMinecraft().isOnThread();
|
||||
return getMinecraft().isOnThread();
|
||||
//#else
|
||||
return getMinecraft().isCallingFromMinecraftThread();
|
||||
//$$ return getMinecraft().isCallingFromMinecraftThread();
|
||||
//#endif
|
||||
}
|
||||
|
||||
//#if MC>=11300
|
||||
public static MainWindow newScaledResolution(Minecraft mc) {
|
||||
return mc.mainWindow;
|
||||
public static Window newScaledResolution(MinecraftClient mc) {
|
||||
return mc.window;
|
||||
}
|
||||
//#else
|
||||
//$$ public static ScaledResolution newScaledResolution(Minecraft mc) {
|
||||
@@ -333,13 +333,13 @@ public class MCVer {
|
||||
|
||||
public static
|
||||
//#if MC>=11400
|
||||
//$$ CompletableFuture<?>
|
||||
CompletableFuture<?>
|
||||
//#else
|
||||
ListenableFuture<?>
|
||||
//$$ ListenableFuture<?>
|
||||
//#endif
|
||||
setServerResourcePack(File file) {
|
||||
//#if MC>=11300
|
||||
return getMinecraft().getPackFinder().func_195741_a(file);
|
||||
return getMinecraft().getResourcePackDownloader().loadServerPack(file);
|
||||
//#else
|
||||
//$$ ResourcePackRepository repo = getMinecraft().getResourcePackRepository();
|
||||
//#if MC>=10809
|
||||
@@ -364,36 +364,36 @@ public class MCVer {
|
||||
|
||||
public static <T> void addCallback(
|
||||
//#if MC>=11400
|
||||
//$$ CompletableFuture<T> future,
|
||||
CompletableFuture<T> future,
|
||||
//#else
|
||||
ListenableFuture<T> future,
|
||||
//$$ ListenableFuture<T> future,
|
||||
//#endif
|
||||
Consumer<T> success,
|
||||
Consumer<Throwable> failure
|
||||
) {
|
||||
//#if MC>=11400
|
||||
//$$ future.thenAccept(success).exceptionally(throwable -> {
|
||||
//$$ failure.accept(throwable);
|
||||
//$$ return null;
|
||||
//$$ });
|
||||
//#else
|
||||
Futures.addCallback(future, new FutureCallback<T>() {
|
||||
@Override
|
||||
public void onSuccess(T result) {
|
||||
success.accept(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable throwable) {
|
||||
failure.accept(throwable);
|
||||
}
|
||||
future.thenAccept(success).exceptionally(throwable -> {
|
||||
failure.accept(throwable);
|
||||
return null;
|
||||
});
|
||||
//#else
|
||||
//$$ Futures.addCallback(future, new FutureCallback<T>() {
|
||||
//$$ @Override
|
||||
//$$ public void onSuccess(T result) {
|
||||
//$$ success.accept(result);
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ @Override
|
||||
//$$ public void onFailure(Throwable throwable) {
|
||||
//$$ failure.accept(throwable);
|
||||
//$$ }
|
||||
//$$ });
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static void BufferBuilder_setTranslation(double x, double y, double z) {
|
||||
//#if MC>=10800
|
||||
Tessellator.getInstance().getBuffer().setTranslation(x, y, z);
|
||||
Tessellator.getInstance().getBufferBuilder().setOffset(x, y, z);
|
||||
//#else
|
||||
//$$ Tessellator.instance.setTranslation(x, y, z);
|
||||
//#endif
|
||||
@@ -401,9 +401,9 @@ public class MCVer {
|
||||
|
||||
public static void BufferBuilder_beginPosCol(int mode) {
|
||||
//#if MC>=10800
|
||||
BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
|
||||
BufferBuilder bufferBuilder = Tessellator.getInstance().getBufferBuilder();
|
||||
//#if MC>=10809
|
||||
bufferBuilder.begin(mode, DefaultVertexFormats.POSITION_COLOR);
|
||||
bufferBuilder.begin(mode, VertexFormats.POSITION_COLOR);
|
||||
//#else
|
||||
//$$ bufferBuilder.startDrawing(mode);
|
||||
//#endif
|
||||
@@ -414,12 +414,12 @@ public class MCVer {
|
||||
|
||||
public static void BufferBuilder_addPosCol(double x, double y, double z, int r, int g, int b, int a) {
|
||||
//#if MC>=10800
|
||||
BufferBuilder worldRenderer = Tessellator.getInstance().getBuffer();
|
||||
BufferBuilder worldRenderer = Tessellator.getInstance().getBufferBuilder();
|
||||
//#else
|
||||
//$$ Tessellator worldRenderer = Tessellator.instance;
|
||||
//#endif
|
||||
//#if MC>=10809
|
||||
worldRenderer.pos(x, y, z).color(r, g, b, a).endVertex();
|
||||
worldRenderer.vertex(x, y, z).color(r, g, b, a).next();
|
||||
//#else
|
||||
//$$ worldRenderer.setColorRGBA(r, g, b, a);
|
||||
//$$ worldRenderer.addVertex(x, y, z);
|
||||
@@ -428,9 +428,9 @@ public class MCVer {
|
||||
|
||||
public static void BufferBuilder_beginPosTex(int mode) {
|
||||
//#if MC>=10800
|
||||
BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
|
||||
BufferBuilder bufferBuilder = Tessellator.getInstance().getBufferBuilder();
|
||||
//#if MC>=10809
|
||||
bufferBuilder.begin(mode, DefaultVertexFormats.POSITION_TEX);
|
||||
bufferBuilder.begin(mode, VertexFormats.POSITION_UV);
|
||||
//#else
|
||||
//$$ bufferBuilder.startDrawing(mode);
|
||||
//#endif
|
||||
@@ -441,12 +441,12 @@ public class MCVer {
|
||||
|
||||
public static void BufferBuilder_addPosTex(double x, double y, double z, double u, double v) {
|
||||
//#if MC>=10800
|
||||
BufferBuilder worldRenderer = Tessellator.getInstance().getBuffer();
|
||||
BufferBuilder worldRenderer = Tessellator.getInstance().getBufferBuilder();
|
||||
//#else
|
||||
//$$ Tessellator worldRenderer = Tessellator.instance;
|
||||
//#endif
|
||||
//#if MC>=10809
|
||||
worldRenderer.pos(x, y, z).tex(u, v).endVertex();
|
||||
worldRenderer.vertex(x, y, z).texture(u, v).next();
|
||||
//#else
|
||||
//$$ worldRenderer.addVertexWithUV(x, y, z, u, v);
|
||||
//#endif
|
||||
@@ -454,9 +454,9 @@ public class MCVer {
|
||||
|
||||
public static void BufferBuilder_beginPosTexCol(int mode) {
|
||||
//#if MC>=10800
|
||||
BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
|
||||
BufferBuilder bufferBuilder = Tessellator.getInstance().getBufferBuilder();
|
||||
//#if MC>=10809
|
||||
bufferBuilder.begin(mode, DefaultVertexFormats.POSITION_TEX_COLOR);
|
||||
bufferBuilder.begin(mode, VertexFormats.POSITION_UV_COLOR);
|
||||
//#else
|
||||
//$$ bufferBuilder.startDrawing(mode);
|
||||
//#endif
|
||||
@@ -467,12 +467,12 @@ public class MCVer {
|
||||
|
||||
public static void BufferBuilder_addPosTexCol(double x, double y, double z, double u, double v, int r, int g, int b, int a) {
|
||||
//#if MC>=10800
|
||||
BufferBuilder worldRenderer = Tessellator.getInstance().getBuffer();
|
||||
BufferBuilder worldRenderer = Tessellator.getInstance().getBufferBuilder();
|
||||
//#else
|
||||
//$$ Tessellator worldRenderer = Tessellator.instance;
|
||||
//#endif
|
||||
//#if MC>=10809
|
||||
worldRenderer.pos(x, y, z).tex(u, v).color(r, g, b, a).endVertex();
|
||||
worldRenderer.vertex(x, y, z).texture(u, v).color(r, g, b, a).next();
|
||||
//#else
|
||||
//$$ worldRenderer.setColorRGBA(r, g, b, a);
|
||||
//$$ worldRenderer.addVertexWithUV(x, y, z, u, v);
|
||||
@@ -494,23 +494,23 @@ public class MCVer {
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static RenderManager getRenderManager() {
|
||||
public static EntityRenderDispatcher getRenderManager() {
|
||||
//#if MC>=10800
|
||||
return getMinecraft().getRenderManager();
|
||||
return getMinecraft().getEntityRenderManager();
|
||||
//#else
|
||||
//$$ return RenderManager.instance;
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static Minecraft getMinecraft() {
|
||||
return Minecraft.getInstance();
|
||||
public static MinecraftClient getMinecraft() {
|
||||
return MinecraftClient.getInstance();
|
||||
}
|
||||
|
||||
public static float getRenderPartialTicks() {
|
||||
return ((MinecraftAccessor) getMinecraft()).getTimer().renderPartialTicks;
|
||||
return ((MinecraftAccessor) getMinecraft()).getTimer().tickDelta;
|
||||
}
|
||||
|
||||
public static void addButton(GuiScreen screen, GuiButton button) {
|
||||
public static void addButton(Screen screen, ButtonWidget button) {
|
||||
GuiScreenAccessor acc = (GuiScreenAccessor) screen;
|
||||
acc.getButtons().add(button);
|
||||
//#if MC>=11300
|
||||
@@ -532,19 +532,19 @@ public class MCVer {
|
||||
//$$ void replayModRunTickKeyboard();
|
||||
//#endif
|
||||
//#if MC>=11400
|
||||
//$$ void replayModExecuteTaskQueue();
|
||||
void replayModExecuteTaskQueue();
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static long milliTime() {
|
||||
//#if MC>=11300
|
||||
return Util.milliTime();
|
||||
return SystemUtil.getMeasuringTimeMs();
|
||||
//#else
|
||||
//$$ return Minecraft.getSystemTime();
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static void bindTexture(ResourceLocation texture) {
|
||||
public static void bindTexture(Identifier texture) {
|
||||
//#if MC>=11300
|
||||
getMinecraft().getTextureManager().bindTexture(texture);
|
||||
//#else
|
||||
@@ -573,7 +573,7 @@ public class MCVer {
|
||||
|
||||
public static void openFile(File file) {
|
||||
//#if MC>=11300
|
||||
Util.getOSType().openFile(file);
|
||||
SystemUtil.getOperatingSystem().open(file);
|
||||
//#else
|
||||
//$$ String path = file.getAbsolutePath();
|
||||
//$$
|
||||
@@ -688,9 +688,9 @@ public class MCVer {
|
||||
|
||||
public static boolean isKeyDown(int keyCode) {
|
||||
//#if MC>=11400
|
||||
//$$ return InputUtil.isKeyPressed(getMinecraft().window.getHandle(), keyCode);
|
||||
return InputUtil.isKeyPressed(getMinecraft().window.getHandle(), keyCode);
|
||||
//#else
|
||||
return InputMappings.isKeyDown(keyCode);
|
||||
//$$ return InputMappings.isKeyDown(keyCode);
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user