Make use of new @Pattern feature to centralize version-aware code
That is, most of the business code should not be aware that it is being compiled to multiple versions even when it heavily interacts with MC, preprocessor statements should be an escape hatch, not the norm. Similarly, code should not be forced to do `MCVer.getWindow(mc)` instead of the much more intuitive `mc.getWindow()`, and a new preprocessor (technically remap) feature makes this possible by defining "search and replace"-like patterns (but smarter in that they are type-aware) in one or more central places (the "Patterns.java" files) which then are applied all over the code base. In a way, this is another step in the automatic back-porting process where preprocessor statements are used when we cannot yet do something automatically. Previously we "merely" automatically converted between different mapping, this new feature now also allows us to automatically perform simple refactoring tasks like changing field access to a getter+setter (e.g. `mc.getWindow()`), or changing how a method is called (e.g. `BufferBuilder.begin`), or changing a method call chain (e.g. `dispatcher.camera.getYaw()`), or most other search-and-replace-like changes and any combination of those. The only major limitation is that the replacement itself is not smart, so arguments must be kept in same order (or be temporarily assigned to local variables which then can be used in any order).
This commit is contained in:
@@ -7,7 +7,6 @@ import com.replaymod.core.mixin.KeyBindingAccessor;
|
||||
import de.johni0702.minecraft.gui.utils.EventRegistrations;
|
||||
import com.replaymod.core.events.KeyBindingEventCallback;
|
||||
import com.replaymod.core.events.KeyEventCallback;
|
||||
import com.replaymod.core.versions.MCVer;
|
||||
import net.minecraft.client.options.KeyBinding;
|
||||
import net.minecraft.util.crash.CrashReport;
|
||||
import net.minecraft.util.crash.CrashReportSection;
|
||||
@@ -121,8 +120,8 @@ public class KeyBindingRegistry extends EventRegistrations {
|
||||
} catch (Throwable cause) {
|
||||
CrashReport crashReport = CrashReport.create(cause, "Handling Key Binding");
|
||||
CrashReportSection category = crashReport.addElement("Key Binding");
|
||||
MCVer.addDetail(category, "Key Binding", () -> binding.name);
|
||||
MCVer.addDetail(category, "Handler", runnable::toString);
|
||||
category.add("Key Binding", () -> binding.name);
|
||||
category.add("Handler", runnable::toString);
|
||||
throw new CrashException(crashReport);
|
||||
}
|
||||
}
|
||||
@@ -139,8 +138,8 @@ public class KeyBindingRegistry extends EventRegistrations {
|
||||
} catch (Throwable cause) {
|
||||
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", handler::toString);
|
||||
category.add("Key Code", () -> "" + keyCode);
|
||||
category.add("Handler", handler::toString);
|
||||
throw new CrashException(crashReport);
|
||||
}
|
||||
}
|
||||
@@ -161,7 +160,12 @@ public class KeyBindingRegistry extends EventRegistrations {
|
||||
}
|
||||
|
||||
public String getBoundKey() {
|
||||
return MCVer.getBoundKey(keyBinding);
|
||||
try {
|
||||
return keyBinding.getBoundKeyLocalizedText().getString();
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
// Apparently windows likes to press strange keys, see https://www.replaymod.com/forum/thread/55
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isBound() {
|
||||
|
||||
@@ -22,15 +22,15 @@ import com.replaymod.simplepathing.ReplayModSimplePathing;
|
||||
import de.johni0702.minecraft.gui.container.GuiScreen;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.options.Option;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.resource.DirectoryResourcePack;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.Style;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.Style;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.Formatting;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
@@ -355,6 +355,14 @@ public class ReplayMod implements Module, Scheduler {
|
||||
return backend.getVersion();
|
||||
}
|
||||
|
||||
public String getMinecraftVersion() {
|
||||
return backend.getMinecraftVersion();
|
||||
}
|
||||
|
||||
public boolean isModLoaded(String id) {
|
||||
return backend.isModLoaded(id);
|
||||
}
|
||||
|
||||
public MinecraftClient getMinecraft() {
|
||||
return mc;
|
||||
}
|
||||
|
||||
@@ -18,4 +18,12 @@ public class ReplayModBackend implements ClientModInitializer {
|
||||
.orElseThrow(IllegalStateException::new)
|
||||
.getMetadata().getVersion().toString();
|
||||
}
|
||||
|
||||
public String getMinecraftVersion() {
|
||||
return mod.getMinecraft().getGame().getVersion().getName();
|
||||
}
|
||||
|
||||
public boolean isModLoaded(String id) {
|
||||
return FabricLoader.getInstance().isModLoaded(id.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,6 @@ import net.minecraft.util.Identifier;
|
||||
//$$ import io.netty.buffer.Unpooled;
|
||||
//#endif
|
||||
|
||||
import static com.replaymod.core.versions.MCVer.readString;
|
||||
|
||||
/**
|
||||
* Restrictions set by the server,
|
||||
* @see <a href="https://gist.github.com/Johni0702/2547c463e51f65f312cb">Replay Restrictions Gist</a>
|
||||
@@ -34,7 +32,7 @@ public class Restrictions {
|
||||
//$$ PacketBuffer buffer = new PacketBuffer(Unpooled.wrappedBuffer(packet.func_149168_d()));
|
||||
//#endif
|
||||
while (buffer.isReadable()) {
|
||||
String name = readString(buffer, 64);
|
||||
String name = buffer.readString(64);
|
||||
boolean active = buffer.readBoolean();
|
||||
// if ("no_xray".equals(name)) {
|
||||
// noXray = active;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
// 1.7.10 and below
|
||||
1
src/main/java/com/replaymod/core/versions/GLFW.java
Normal file
1
src/main/java/com/replaymod/core/versions/GLFW.java
Normal file
@@ -0,0 +1 @@
|
||||
// 1.12.2 and below
|
||||
@@ -1,45 +1,19 @@
|
||||
package com.replaymod.core.versions;
|
||||
|
||||
import com.replaymod.core.mixin.GuiScreenAccessor;
|
||||
import com.replaymod.core.mixin.MinecraftAccessor;
|
||||
import com.replaymod.render.mixin.MainWindowAccessor;
|
||||
import com.replaymod.replaystudio.protocol.PacketTypeRegistry;
|
||||
import com.replaymod.replaystudio.us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
||||
import com.replaymod.replaystudio.us.myles.ViaVersion.packets.State;
|
||||
import de.johni0702.minecraft.gui.utils.NonNull;
|
||||
import de.johni0702.minecraft.gui.utils.lwjgl.Dimension;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.options.KeyBinding;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.client.render.Tessellator;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.util.crash.CrashReportSection;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.WorldChunk;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
//#if MC>=11600
|
||||
import net.minecraft.resource.ResourcePackSource;
|
||||
//#endif
|
||||
|
||||
//#if MC>=11500
|
||||
import net.minecraft.client.model.ModelPart.Cuboid;
|
||||
import java.util.ArrayList;
|
||||
//#else
|
||||
//$$ import net.minecraft.client.model.Box;
|
||||
//#endif
|
||||
|
||||
//#if MC>=11400
|
||||
import com.replaymod.core.mixin.AbstractButtonWidgetAccessor;
|
||||
import com.replaymod.render.mixin.MainWindowAccessor;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.client.gl.Framebuffer;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
@@ -62,20 +36,14 @@ import net.minecraft.text.TranslatableText;
|
||||
|
||||
//#if FABRIC>=1
|
||||
//#else
|
||||
//$$ import net.minecraft.entity.LivingEntity;
|
||||
//$$ 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>=11400
|
||||
import net.minecraft.client.util.Window;
|
||||
import net.minecraft.client.util.InputUtil;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
//#else
|
||||
//$$ import net.minecraft.client.gui.ScaledResolution;
|
||||
//$$ import net.minecraft.client.resources.ResourcePackRepository;
|
||||
//$$ import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
//$$ import org.apache.logging.log4j.LogManager;
|
||||
@@ -84,28 +52,18 @@ import org.lwjgl.glfw.GLFW;
|
||||
//$$ import java.io.IOException;
|
||||
//#endif
|
||||
|
||||
//#if MC>=11400
|
||||
import net.minecraft.client.sound.PositionedSoundInstance;
|
||||
//#else
|
||||
//$$ import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
//#endif
|
||||
|
||||
//#if MC>=10904
|
||||
import com.replaymod.render.blend.mixin.ParticleAccessor;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
//#endif
|
||||
|
||||
//#if MC>=10809
|
||||
import net.minecraft.client.render.VertexFormats;
|
||||
//#else
|
||||
//$$ import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
//#endif
|
||||
|
||||
//#if MC>=10800
|
||||
import net.minecraft.client.render.BufferBuilder;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.client.render.VertexFormat;
|
||||
import net.minecraft.client.render.VertexFormatElement;
|
||||
//#if MC<11500
|
||||
@@ -113,28 +71,17 @@ import net.minecraft.client.render.VertexFormatElement;
|
||||
//#endif
|
||||
//#else
|
||||
//$$ import com.replaymod.core.mixin.ResourcePackRepositoryAccessor;
|
||||
//$$ import com.google.common.util.concurrent.Futures;
|
||||
//$$ import io.netty.handler.codec.DecoderException;
|
||||
//$$ import net.minecraft.client.renderer.entity.RenderManager;
|
||||
//$$ import net.minecraft.client.resources.FileResourcePack;
|
||||
//$$ import net.minecraft.network.PacketBuffer;
|
||||
//$$
|
||||
//$$ import static org.lwjgl.opengl.GL11.*;
|
||||
//#endif
|
||||
|
||||
//#if FABRIC>=1
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
//#else
|
||||
//#if MC>=11400
|
||||
//$$ import net.minecraftforge.fml.ModList;
|
||||
//#else
|
||||
//$$ import net.minecraftforge.fml.common.Loader;
|
||||
//#endif
|
||||
//#endif
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -142,8 +89,6 @@ import java.util.Optional;
|
||||
* Abstraction over things that have changed between different MC versions.
|
||||
*/
|
||||
public class MCVer {
|
||||
private static Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
//#if FABRIC<=0
|
||||
//$$ public static IEventBus FORGE_BUS = MinecraftForge.EVENT_BUS;
|
||||
//#if MC>=10809
|
||||
@@ -153,18 +98,6 @@ public class MCVer {
|
||||
//#endif
|
||||
//#endif
|
||||
|
||||
public static boolean isModLoaded(String id) {
|
||||
//#if FABRIC>=1
|
||||
return FabricLoader.getInstance().isModLoaded(id.toLowerCase());
|
||||
//#else
|
||||
//#if MC>=11400
|
||||
//$$ return ModList.get().isLoaded(id.toLowerCase());
|
||||
//#else
|
||||
//$$ return Loader.isModLoaded(id);
|
||||
//#endif
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static int getProtocolVersion() {
|
||||
//#if MC>=11400
|
||||
return SharedConstants.getGameVersion().getProtocolVersion();
|
||||
@@ -180,38 +113,6 @@ public class MCVer {
|
||||
);
|
||||
}
|
||||
|
||||
public static String getMinecraftVersion() {
|
||||
//#if MC>=11400
|
||||
return getMinecraft().getGame().getVersion().getName();
|
||||
//#else
|
||||
//$$ return Loader.MC_VERSION;
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static void addDetail(CrashReportSection category, String name, Callable<String> callable) {
|
||||
//#if MC>=10904
|
||||
//#if MC>=11200
|
||||
category.add(name, callable::call);
|
||||
//#else
|
||||
//$$ category.setDetail(name, callable::call);
|
||||
//#endif
|
||||
//#else
|
||||
//$$ category.addCrashSectionCallable(name, callable);
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static Dimension getMainWindowSize(MinecraftClient mc) {
|
||||
return new Dimension(
|
||||
//#if MC>=11400
|
||||
getWindow(mc).getFramebufferWidth(),
|
||||
getWindow(mc).getFramebufferHeight()
|
||||
//#else
|
||||
//$$ mc.displayWidth,
|
||||
//$$ mc.displayHeight
|
||||
//#endif
|
||||
);
|
||||
}
|
||||
|
||||
public static void resizeMainWindow(MinecraftClient mc, int width, int height) {
|
||||
//#if MC>=11400
|
||||
Framebuffer fb = mc.getFramebuffer();
|
||||
@@ -219,7 +120,7 @@ public class MCVer {
|
||||
fb.resize(width, height, false);
|
||||
}
|
||||
//noinspection ConstantConditions
|
||||
MainWindowAccessor mainWindow = (MainWindowAccessor) (Object) getWindow(mc);
|
||||
MainWindowAccessor mainWindow = (MainWindowAccessor) (Object) mc.getWindow();
|
||||
mainWindow.setFramebufferWidth(width);
|
||||
mainWindow.setFramebufferHeight(height);
|
||||
//#if MC>=11500
|
||||
@@ -232,263 +133,13 @@ public class MCVer {
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static double Entity_getX(Entity entity) {
|
||||
//#if MC>=11500
|
||||
return entity.getX();
|
||||
//#else
|
||||
//$$ return entity.x;
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static double Entity_getY(Entity entity) {
|
||||
//#if MC>=11500
|
||||
return entity.getY();
|
||||
//#else
|
||||
//$$ return entity.y;
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static double Entity_getZ(Entity entity) {
|
||||
//#if MC>=11500
|
||||
return entity.getZ();
|
||||
//#else
|
||||
//$$ return entity.z;
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static void Entity_setPos(Entity entity, double x, double y, double z) {
|
||||
//#if MC>=11500
|
||||
entity.setPos(x, y, z);
|
||||
//#else
|
||||
//$$ entity.x = x;
|
||||
//$$ entity.y = y;
|
||||
//$$ entity.z = z;
|
||||
//#endif
|
||||
}
|
||||
|
||||
//#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();
|
||||
}
|
||||
//#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;
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
//#if FABRIC<=0
|
||||
//#if MC>=11400
|
||||
//$$ public static void addButton(GuiScreenEvent.InitGuiEvent event, Widget button) {
|
||||
//$$ event.addWidget(button);
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ public static void removeButton(GuiScreenEvent.InitGuiEvent event, Widget button) {
|
||||
//$$ event.removeWidget(button);
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ public static List<Widget> getButtonList(GuiScreenEvent.InitGuiEvent event) {
|
||||
//$$ return event.getWidgetList();
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ public static Widget getButton(GuiScreenEvent.ActionPerformedEvent event) {
|
||||
//$$ return event.getButton();
|
||||
//$$ }
|
||||
//#else
|
||||
//$$ public static void addButton(GuiScreenEvent.InitGuiEvent event, GuiButton button) {
|
||||
//#if MC>=11400
|
||||
//$$ event.addButton(button);
|
||||
//#else
|
||||
//$$ getButtonList(event).add(button);
|
||||
//#endif
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ public static void removeButton(GuiScreenEvent.InitGuiEvent event, GuiButton button) {
|
||||
//#if MC>=11400
|
||||
//$$ event.removeButton(button);
|
||||
//#else
|
||||
//$$ getButtonList(event).remove(button);
|
||||
//#endif
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ @SuppressWarnings("unchecked")
|
||||
//$$ public static List<GuiButton> getButtonList(GuiScreenEvent.InitGuiEvent event) {
|
||||
//#if MC>=10904
|
||||
//$$ return event.getButtonList();
|
||||
//#else
|
||||
//$$ return event.buttonList;
|
||||
//#endif
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ public static GuiButton getButton(GuiScreenEvent.ActionPerformedEvent event) {
|
||||
//#if MC>=10904
|
||||
//$$ return event.getButton();
|
||||
//#else
|
||||
//$$ return event.button;
|
||||
//#endif
|
||||
//$$ }
|
||||
//#endif
|
||||
//$$
|
||||
//$$ public static Screen getGui(GuiScreenEvent event) {
|
||||
//#if MC>=10904
|
||||
//$$ return event.getGui();
|
||||
//#else
|
||||
//$$ return event.gui;
|
||||
//#endif
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ public static LivingEntity getEntity(RenderLivingEvent event) {
|
||||
//#if MC>=10904
|
||||
//$$ return event.getEntity();
|
||||
//#else
|
||||
//$$ return event.entity;
|
||||
//#endif
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
public static String readString(PacketByteBuf buffer, int max) {
|
||||
//#if MC>=10800
|
||||
return buffer.readString(max);
|
||||
//#else
|
||||
//$$ try {
|
||||
//$$ return buffer.readStringFromBuffer(max);
|
||||
//$$ } catch (IOException e) {
|
||||
//$$ throw new DecoderException(e);
|
||||
//$$ }
|
||||
//#endif
|
||||
}
|
||||
|
||||
//#if FABRIC<=0
|
||||
//$$ public static RenderGameOverlayEvent.ElementType getType(RenderGameOverlayEvent event) {
|
||||
//#if MC>=10904
|
||||
//$$ return event.getType();
|
||||
//#else
|
||||
//$$ return event.type;
|
||||
//#endif
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
//#if MC>=10800
|
||||
public static Entity getRenderViewEntity(MinecraftClient mc) {
|
||||
return mc.getCameraEntity();
|
||||
}
|
||||
//#else
|
||||
//$$ public static EntityLivingBase getRenderViewEntity(Minecraft mc) {
|
||||
//$$ return mc.renderViewEntity;
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
//#if MC>=10800
|
||||
public static void setRenderViewEntity(MinecraftClient mc, Entity entity) {
|
||||
mc.setCameraEntity(entity);
|
||||
}
|
||||
//#else
|
||||
//$$ public static void setRenderViewEntity(Minecraft mc, EntityLivingBase entity) {
|
||||
//$$ mc.renderViewEntity = entity;
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
public static Entity getRiddenEntity(Entity ridden) {
|
||||
//#if MC>=10904
|
||||
return ridden.getVehicle();
|
||||
//#else
|
||||
//$$ return ridden.ridingEntity;
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static Iterable<Entity> loadedEntityList(ClientWorld world) {
|
||||
//#if MC>=11400
|
||||
return world.getEntities();
|
||||
//#else
|
||||
//$$ return world.loadedEntityList;
|
||||
//#endif
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Collection<Entity>[] getEntityLists(WorldChunk chunk) {
|
||||
//#if MC>=10800
|
||||
return chunk.getEntitySectionArray();
|
||||
//#else
|
||||
//$$ return chunk.entityLists;
|
||||
//#endif
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
//#if MC>=11500
|
||||
public static List<Cuboid> cubeList(ModelPart modelRenderer) {
|
||||
return new ArrayList<>(); // FIXME 1.15
|
||||
}
|
||||
//#else
|
||||
//$$ public static List<Box> cubeList(ModelPart modelRenderer) {
|
||||
//$$ return modelRenderer.boxes;
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static List<PlayerEntity> playerEntities(World world) {
|
||||
//#if MC>=11400
|
||||
return (List) world.getPlayers();
|
||||
//#else
|
||||
//$$ return world.playerEntities;
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static boolean isOnMainThread() {
|
||||
//#if MC>=11400
|
||||
return getMinecraft().isOnThread();
|
||||
//#else
|
||||
//$$ return getMinecraft().isCallingFromMinecraftThread();
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static void scheduleOnMainThread(Runnable runnable) {
|
||||
//#if MC>=11400
|
||||
getMinecraft().send(runnable);
|
||||
//#else
|
||||
//$$ getMinecraft().addScheduledTask(runnable);
|
||||
//#endif
|
||||
}
|
||||
|
||||
//#if MC>=11400
|
||||
public static @NonNull Window getWindow(MinecraftClient mc) {
|
||||
//#if MC>=11500
|
||||
return mc.getWindow();
|
||||
//#else
|
||||
//$$ return mc.window;
|
||||
//#endif
|
||||
}
|
||||
//#else
|
||||
//$$ public static @NonNull MainWindowAccessor getWindow(Minecraft mc) {
|
||||
//$$ return (MainWindowAccessor) mc;
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
//#if MC>=11400
|
||||
public static Window newScaledResolution(MinecraftClient mc) {
|
||||
return getWindow(mc);
|
||||
}
|
||||
//#else
|
||||
//$$ public static ScaledResolution newScaledResolution(Minecraft mc) {
|
||||
//#if MC>=10809
|
||||
//$$ return new ScaledResolution(mc);
|
||||
//#else
|
||||
//$$ return new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||
//#endif
|
||||
//#if MC<10800
|
||||
//$$ public static String tryReadString(PacketBuffer buffer, int max) {
|
||||
//$$ try {
|
||||
//$$ return buffer.readStringFromBuffer(max);
|
||||
//$$ } catch (IOException e) {
|
||||
//$$ throw new DecoderException(e);
|
||||
//$$ }
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
@@ -549,69 +200,6 @@ public class MCVer {
|
||||
//#endif
|
||||
}
|
||||
|
||||
//#if MC>=10800
|
||||
public static BufferBuilder Tessellator_getBufferBuilder() {
|
||||
return Tessellator.getInstance().getBuffer();
|
||||
}
|
||||
//#else
|
||||
//$$ public static Tessellator Tessellator_getBufferBuilder() {
|
||||
//$$ return Tessellator.instance;
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
public static void BufferBuilder_beginPosCol(int mode) {
|
||||
Tessellator_getBufferBuilder().begin(
|
||||
mode
|
||||
//#if MC>=10809
|
||||
, VertexFormats.POSITION_COLOR
|
||||
//#endif
|
||||
);
|
||||
}
|
||||
|
||||
public static void BufferBuilder_addPosCol(double x, double y, double z, int r, int g, int b, int a) {
|
||||
//#if MC>=10809
|
||||
Tessellator_getBufferBuilder().vertex(x, y, z).color(r, g, b, a).next();
|
||||
//#else
|
||||
//$$ Tessellator_getBufferBuilder().setColorRGBA(r, g, b, a);
|
||||
//$$ Tessellator_getBufferBuilder().addVertex(x, y, z);
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static void BufferBuilder_beginPosTex(int mode) {
|
||||
Tessellator_getBufferBuilder().begin(
|
||||
mode
|
||||
//#if MC>=10809
|
||||
, VertexFormats.POSITION_TEXTURE
|
||||
//#endif
|
||||
);
|
||||
}
|
||||
|
||||
public static void BufferBuilder_addPosTex(double x, double y, double z, float u, float v) {
|
||||
//#if MC>=10809
|
||||
Tessellator_getBufferBuilder().vertex(x, y, z).texture(u, v).next();
|
||||
//#else
|
||||
//$$ Tessellator_getBufferBuilder().addVertexWithUV(x, y, z, u, v);
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static void BufferBuilder_beginPosTexCol(int mode) {
|
||||
Tessellator_getBufferBuilder().begin(
|
||||
mode
|
||||
//#if MC>=10809
|
||||
, VertexFormats.POSITION_TEXTURE_COLOR
|
||||
//#endif
|
||||
);
|
||||
}
|
||||
|
||||
public static void BufferBuilder_addPosTexCol(double x, double y, double z, float u, float v, int r, int g, int b, int a) {
|
||||
//#if MC>=10809
|
||||
Tessellator_getBufferBuilder().vertex(x, y, z).texture(u, v).color(r, g, b, a).next();
|
||||
//#else
|
||||
//$$ Tessellator_getBufferBuilder().setColorRGBA(r, g, b, a);
|
||||
//$$ Tessellator_getBufferBuilder().addVertexWithUV(x, y, z, u, v);
|
||||
//#endif
|
||||
}
|
||||
|
||||
//#if MC>=10800
|
||||
@SuppressWarnings("unchecked")
|
||||
public static List<VertexFormatElement> getElements(VertexFormat vertexFormat) {
|
||||
@@ -619,30 +207,16 @@ public class MCVer {
|
||||
}
|
||||
//#endif
|
||||
|
||||
public static Tessellator Tessellator_getInstance() {
|
||||
//#if MC>=10800
|
||||
return Tessellator.getInstance();
|
||||
//#else
|
||||
//$$ return Tessellator.instance;
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static EntityRenderDispatcher getRenderManager() {
|
||||
//#if MC>=10800
|
||||
return getMinecraft().getEntityRenderDispatcher();
|
||||
//#else
|
||||
//$$ return RenderManager.instance;
|
||||
//#endif
|
||||
}
|
||||
//#if MC<10800
|
||||
//$$ public static RenderManager getRenderManager(@SuppressWarnings("unused") Minecraft mc) {
|
||||
//$$ return RenderManager.instance;
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
public static MinecraftClient getMinecraft() {
|
||||
return MinecraftClient.getInstance();
|
||||
}
|
||||
|
||||
public static float getRenderPartialTicks() {
|
||||
return ((MinecraftAccessor) getMinecraft()).getTimer().tickDelta;
|
||||
}
|
||||
|
||||
public static void addButton(
|
||||
Screen screen,
|
||||
//#if MC>=11400
|
||||
@@ -719,26 +293,6 @@ public class MCVer {
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static void bindTexture(Identifier texture) {
|
||||
//#if MC>=11500
|
||||
getMinecraft().getTextureManager().bindTexture(texture);
|
||||
//#else
|
||||
//#if MC>=11400
|
||||
//$$ getMinecraft().getTextureManager().bindTexture(texture);
|
||||
//#else
|
||||
//$$ getMinecraft().renderEngine.bindTexture(texture);
|
||||
//#endif
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static float cos(float val) {
|
||||
return MathHelper.cos(val);
|
||||
}
|
||||
|
||||
public static float sin(float val) {
|
||||
return MathHelper.sin(val);
|
||||
}
|
||||
|
||||
//#if MC>=10904
|
||||
// TODO: this can be inlined once https://github.com/SpongePowered/Mixin/issues/305 is fixed
|
||||
public static Vec3d getPosition(Particle particle, float partialTicks) {
|
||||
@@ -781,51 +335,20 @@ public class MCVer {
|
||||
}
|
||||
|
||||
public static void openURL(URI url) {
|
||||
//#if MC>=11400
|
||||
//#if MC>=11400
|
||||
Util.getOperatingSystem().open(url);
|
||||
//#else
|
||||
//$$ Util.getOSType().openURI(url);
|
||||
//#endif
|
||||
//#else
|
||||
//$$ try {
|
||||
//$$ Desktop.getDesktop().browse(url);
|
||||
//$$ } catch (Throwable e) {
|
||||
//$$ LOGGER.error("Failed to open URL: ", e);
|
||||
//$$ LogManager.getLogger().error("Failed to open URL: ", e);
|
||||
//$$ }
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static String getBoundKey(KeyBinding keyBinding) {
|
||||
try {
|
||||
//#if MC>=11600
|
||||
return keyBinding.getBoundKeyLocalizedText().getString();
|
||||
//#else
|
||||
//#if MC>=11400
|
||||
//$$ return keyBinding.getLocalizedName();
|
||||
//#else
|
||||
//$$ return Keyboard.getKeyName(keyBinding.getKeyCode());
|
||||
//#endif
|
||||
//#endif
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
// Apparently windows likes to press strange keys, see https://www.replaymod.com/forum/thread/55
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
public static void playSound(Identifier sound) {
|
||||
getMinecraft().getSoundManager().play(
|
||||
//#if MC>=11400
|
||||
PositionedSoundInstance.master(new SoundEvent(sound), 1.0F)
|
||||
//#elseif MC>=10904
|
||||
//$$ PositionedSoundRecord.getMasterRecord(new SoundEvent(sound), 1.0F)
|
||||
//#elseif MC>=10800
|
||||
//$$ PositionedSoundRecord.create(sound, 1.0F)
|
||||
//#else
|
||||
//$$ PositionedSoundRecord.createPositionedSoundRecord(sound, 1.0F)
|
||||
//#endif
|
||||
);
|
||||
}
|
||||
//#if MC<10900
|
||||
//$$ public static class SoundEvent {}
|
||||
//#endif
|
||||
|
||||
//#if MC>=11400
|
||||
private static Boolean hasOptifine;
|
||||
|
||||
376
src/main/java/com/replaymod/core/versions/Patterns.java
Normal file
376
src/main/java/com/replaymod/core/versions/Patterns.java
Normal file
@@ -0,0 +1,376 @@
|
||||
package com.replaymod.core.versions;
|
||||
|
||||
import com.replaymod.gradle.remap.Pattern;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.options.KeyBinding;
|
||||
import net.minecraft.client.texture.TextureManager;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.client.render.Tessellator;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.sound.PositionedSoundInstance;
|
||||
import net.minecraft.util.crash.CrashReportSection;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.WorldChunk;
|
||||
|
||||
//#if MC>=11400
|
||||
import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
||||
import net.minecraft.client.util.Window;
|
||||
//#else
|
||||
//$$ import net.minecraft.client.gui.GuiButton;
|
||||
//#endif
|
||||
|
||||
//#if MC>=10904
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.crash.CrashCallable;
|
||||
//#else
|
||||
//$$ import java.util.concurrent.Callable;
|
||||
//#endif
|
||||
|
||||
//#if MC>=10809
|
||||
import net.minecraft.client.render.VertexFormats;
|
||||
//#else
|
||||
//#endif
|
||||
|
||||
//#if MC>=10800
|
||||
import net.minecraft.client.render.BufferBuilder;
|
||||
//#else
|
||||
//$$ import net.minecraft.entity.EntityLivingBase;
|
||||
//#endif
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
class Patterns {
|
||||
//#if MC>=10904
|
||||
@Pattern
|
||||
private static void addCrashCallable(CrashReportSection category, String name, CrashCallable<String> callable) {
|
||||
//#if MC>=11200
|
||||
category.add(name, callable);
|
||||
//#else
|
||||
//$$ category.setDetail(name, callable);
|
||||
//#endif
|
||||
}
|
||||
//#else
|
||||
//$$ @Pattern
|
||||
//$$ private static void addCrashCallable(CrashReportCategory category, String name, Callable<String> callable) {
|
||||
//$$ category.addCrashSectionCallable(name, callable);
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
@Pattern
|
||||
private static double Entity_getX(Entity entity) {
|
||||
//#if MC>=11500
|
||||
return entity.getX();
|
||||
//#else
|
||||
//$$ return entity.x;
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static double Entity_getY(Entity entity) {
|
||||
//#if MC>=11500
|
||||
return entity.getY();
|
||||
//#else
|
||||
//$$ return entity.y;
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static double Entity_getZ(Entity entity) {
|
||||
//#if MC>=11500
|
||||
return entity.getZ();
|
||||
//#else
|
||||
//$$ return entity.z;
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static void Entity_setPos(Entity entity, double x, double y, double z) {
|
||||
//#if MC>=11500
|
||||
entity.setPos(x, y, z);
|
||||
//#else
|
||||
//$$ { net.minecraft.entity.Entity self = entity; self.x = x; self.y = y; self.z = z; }
|
||||
//#endif
|
||||
}
|
||||
|
||||
//#if MC>=11400
|
||||
@Pattern
|
||||
private static void setWidth(AbstractButtonWidget button, int value) {
|
||||
button.setWidth(value);
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static int getWidth(AbstractButtonWidget button) {
|
||||
return button.getWidth();
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static int getHeight(AbstractButtonWidget button) {
|
||||
//#if MC>=11600
|
||||
return button.getHeight();
|
||||
//#else
|
||||
//$$ return ((com.replaymod.core.mixin.AbstractButtonWidgetAccessor) button).getHeight();
|
||||
//#endif
|
||||
}
|
||||
//#else
|
||||
//$$ @Pattern
|
||||
//$$ private static void setWidth(GuiButton button, int value) {
|
||||
//$$ button.width = value;
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ @Pattern
|
||||
//$$ private static int getWidth(GuiButton button) {
|
||||
//$$ return button.width;
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ @Pattern
|
||||
//$$ private static int getHeight(GuiButton button) {
|
||||
//$$ return button.height;
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
@Pattern
|
||||
private static String readString(PacketByteBuf buffer, int max) {
|
||||
//#if MC>=10800
|
||||
return buffer.readString(max);
|
||||
//#else
|
||||
//$$ return com.replaymod.core.versions.MCVer.tryReadString(buffer, max);
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
//#if MC>=10800
|
||||
private static Entity getRenderViewEntity(MinecraftClient mc) {
|
||||
return mc.getCameraEntity();
|
||||
}
|
||||
//#else
|
||||
//$$ private static EntityLivingBase getRenderViewEntity(Minecraft mc) {
|
||||
//$$ return mc.renderViewEntity;
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
@Pattern
|
||||
//#if MC>=10800
|
||||
private static void setRenderViewEntity(MinecraftClient mc, Entity entity) {
|
||||
mc.setCameraEntity(entity);
|
||||
}
|
||||
//#else
|
||||
//$$ private static void setRenderViewEntity(Minecraft mc, EntityLivingBase entity) {
|
||||
//$$ mc.renderViewEntity = entity;
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
@Pattern
|
||||
private static Entity getVehicle(Entity passenger) {
|
||||
//#if MC>=10904
|
||||
return passenger.getVehicle();
|
||||
//#else
|
||||
//$$ return passenger.ridingEntity;
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static Iterable<Entity> loadedEntityList(ClientWorld world) {
|
||||
//#if MC>=11400
|
||||
return world.getEntities();
|
||||
//#else
|
||||
//#if MC>=10809
|
||||
//$$ return world.loadedEntityList;
|
||||
//#else
|
||||
//$$ return ((java.util.List<net.minecraft.entity.Entity>) world.loadedEntityList);
|
||||
//#endif
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static Collection<Entity>[] getEntitySectionArray(WorldChunk chunk) {
|
||||
//#if MC>=10800
|
||||
return chunk.getEntitySectionArray();
|
||||
//#else
|
||||
//$$ return chunk.entityLists;
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static List<? extends PlayerEntity> playerEntities(World world) {
|
||||
//#if MC>=11400
|
||||
return world.getPlayers();
|
||||
//#elseif MC>=10809
|
||||
//$$ return world.playerEntities;
|
||||
//#else
|
||||
//$$ return ((List<? extends net.minecraft.entity.player.EntityPlayer>) world.playerEntities);
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static boolean isOnMainThread(MinecraftClient mc) {
|
||||
//#if MC>=11400
|
||||
return mc.isOnThread();
|
||||
//#else
|
||||
//$$ return mc.isCallingFromMinecraftThread();
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static void scheduleOnMainThread(MinecraftClient mc, Runnable runnable) {
|
||||
//#if MC>=11400
|
||||
mc.send(runnable);
|
||||
//#else
|
||||
//$$ mc.addScheduledTask(runnable);
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static Window getWindow(MinecraftClient mc) {
|
||||
//#if MC>=11500
|
||||
return mc.getWindow();
|
||||
//#elseif MC>=11400
|
||||
//$$ return mc.window;
|
||||
//#else
|
||||
//$$ return new com.replaymod.core.versions.Window(mc);
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static BufferBuilder Tessellator_getBuffer(Tessellator tessellator) {
|
||||
//#if MC>=10800
|
||||
return tessellator.getBuffer();
|
||||
//#else
|
||||
//$$ return new BufferBuilder(tessellator);
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static void BufferBuilder_beginPosCol(BufferBuilder buffer, int mode) {
|
||||
//#if MC>=10809
|
||||
buffer.begin(mode, VertexFormats.POSITION_COLOR);
|
||||
//#else
|
||||
//$$ buffer.startDrawing(mode /* POSITION_COLOR */);
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static void BufferBuilder_addPosCol(BufferBuilder buffer, double x, double y, double z, int r, int g, int b, int a) {
|
||||
//#if MC>=10809
|
||||
buffer.vertex(x, y, z).color(r, g, b, a).next();
|
||||
//#else
|
||||
//$$ { WorldRenderer $buffer = buffer; double $x = x; double $y = y; double $z = z; $buffer.setColorRGBA(r, g, b, a); $buffer.addVertex($x, $y, $z); }
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static void BufferBuilder_beginPosTex(BufferBuilder buffer, int mode) {
|
||||
//#if MC>=10809
|
||||
buffer.begin(mode, VertexFormats.POSITION_TEXTURE);
|
||||
//#else
|
||||
//$$ buffer.startDrawing(mode /* POSITION_TEXTURE */);
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static void BufferBuilder_addPosTex(BufferBuilder buffer, double x, double y, double z, float u, float v) {
|
||||
//#if MC>=10809
|
||||
buffer.vertex(x, y, z).texture(u, v).next();
|
||||
//#else
|
||||
//$$ buffer.addVertexWithUV(x, y, z, u, v);
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static void BufferBuilder_beginPosTexCol(BufferBuilder buffer, int mode) {
|
||||
//#if MC>=10809
|
||||
buffer.begin(mode, VertexFormats.POSITION_TEXTURE_COLOR);
|
||||
//#else
|
||||
//$$ buffer.startDrawing(mode /* POSITION_TEXTURE_COLOR */);
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static void BufferBuilder_addPosTexCol(BufferBuilder buffer, double x, double y, double z, float u, float v, int r, int g, int b, int a) {
|
||||
//#if MC>=10809
|
||||
buffer.vertex(x, y, z).texture(u, v).color(r, g, b, a).next();
|
||||
//#else
|
||||
//$$ { WorldRenderer $buffer = buffer; double $x = x; double $y = y; double $z = z; float $u = u; float $v = v; $buffer.setColorRGBA(r, g, b, a); $buffer.addVertexWithUV($x, $y, $z, $u, $v); }
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static Tessellator Tessellator_getInstance() {
|
||||
//#if MC>=10800
|
||||
return Tessellator.getInstance();
|
||||
//#else
|
||||
//$$ return Tessellator.instance;
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static EntityRenderDispatcher getEntityRenderDispatcher(MinecraftClient mc) {
|
||||
//#if MC>=10800
|
||||
return mc.getEntityRenderDispatcher();
|
||||
//#else
|
||||
//$$ return com.replaymod.core.versions.MCVer.getRenderManager(mc);
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static float getCameraYaw(EntityRenderDispatcher dispatcher) {
|
||||
//#if MC>=11500
|
||||
return dispatcher.camera.getYaw();
|
||||
//#else
|
||||
//$$ return dispatcher.cameraYaw;
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static float getCameraPitch(EntityRenderDispatcher dispatcher) {
|
||||
//#if MC>=11500
|
||||
return dispatcher.camera.getPitch();
|
||||
//#else
|
||||
//$$ return dispatcher.cameraPitch;
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static float getRenderPartialTicks(MinecraftClient mc) {
|
||||
//#if MC>=10900
|
||||
return mc.getTickDelta();
|
||||
//#else
|
||||
//$$ return ((com.replaymod.core.mixin.MinecraftAccessor) mc).getTimer().renderPartialTicks;
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static TextureManager getTextureManager(MinecraftClient mc) {
|
||||
//#if MC>=11400
|
||||
return mc.getTextureManager();
|
||||
//#else
|
||||
//$$ return mc.renderEngine;
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static String getBoundKeyName(KeyBinding keyBinding) {
|
||||
//#if MC>=11600
|
||||
return keyBinding.getBoundKeyLocalizedText().getString();
|
||||
//#elseif MC>=11400
|
||||
//$$ return keyBinding.getLocalizedName();
|
||||
//#else
|
||||
//$$ return org.lwjgl.input.Keyboard.getKeyName(keyBinding.getKeyCode());
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static PositionedSoundInstance master(Identifier sound, float pitch) {
|
||||
//#if MC>=10900
|
||||
return PositionedSoundInstance.master(new SoundEvent(sound), pitch);
|
||||
//#elseif MC>=10800
|
||||
//$$ return PositionedSoundRecord.create(sound, pitch);
|
||||
//#else
|
||||
//$$ return PositionedSoundRecord.createPositionedSoundRecord(sound, pitch);
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
1
src/main/java/com/replaymod/core/versions/Window.java
Normal file
1
src/main/java/com/replaymod/core/versions/Window.java
Normal file
@@ -0,0 +1 @@
|
||||
// 1.12.2 and below
|
||||
@@ -0,0 +1 @@
|
||||
// 1.12.2 and before
|
||||
Reference in New Issue
Block a user