Port to 1.17-pre1
This commit is contained in:
@@ -2,19 +2,31 @@
|
||||
package com.replaymod.core.gui;
|
||||
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import io.github.prospector.modmenu.api.ModMenuApi;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
//#if MC>=11700
|
||||
//$$ import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||
//$$ import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||
//#else
|
||||
import io.github.prospector.modmenu.api.ModMenuApi;
|
||||
//#endif
|
||||
|
||||
public class ModMenuApiImpl implements ModMenuApi {
|
||||
//#if MC<11700
|
||||
@Override
|
||||
public String getModId() {
|
||||
return ReplayMod.MOD_ID;
|
||||
}
|
||||
//#endif
|
||||
|
||||
@Override
|
||||
//#if MC>=11700
|
||||
//$$ public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
||||
//#else
|
||||
public Function<Screen, ? extends Screen> getConfigScreenFactory() {
|
||||
//#endif
|
||||
return parent -> new GuiReplaySettings(parent, ReplayMod.instance.getSettingsRegistry()).toMinecraft();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,32 +2,33 @@ package com.replaymod.core.mixin;
|
||||
|
||||
import net.minecraft.client.gui.screen.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;
|
||||
//#if MC>=11700
|
||||
//$$ import net.minecraft.client.gui.Drawable;
|
||||
//$$ import net.minecraft.client.gui.Element;
|
||||
//$$ import net.minecraft.client.gui.Selectable;
|
||||
//#else
|
||||
//$$ import net.minecraft.client.gui.GuiButton;
|
||||
//#endif
|
||||
|
||||
//#if MC>=11400
|
||||
import net.minecraft.client.gui.Element;
|
||||
import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
//#else
|
||||
//$$ import net.minecraft.client.gui.GuiButton;
|
||||
//$$ import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
//$$ import java.util.List;
|
||||
//#endif
|
||||
|
||||
@Mixin(Screen.class)
|
||||
public interface GuiScreenAccessor {
|
||||
//#if MC>=11400
|
||||
@Accessor
|
||||
List<AbstractButtonWidget> getButtons();
|
||||
//#if MC>=11700
|
||||
//$$ @Invoker("addDrawableChild")
|
||||
//$$ <T extends Element & Drawable & Selectable> T invokeAddButton(T drawableElement);
|
||||
//#elseif MC>=11400
|
||||
@Invoker
|
||||
<T extends AbstractButtonWidget> T invokeAddButton(T button);
|
||||
//#else
|
||||
//$$ @Accessor("buttonList")
|
||||
//$$ List<GuiButton> getButtons();
|
||||
//#endif
|
||||
|
||||
//#if MC>=11400
|
||||
@Accessor
|
||||
List<Element> getChildren();
|
||||
//#endif
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.util.crash.CrashReport;
|
||||
import net.minecraft.client.render.RenderTickCounter;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import java.util.Queue;
|
||||
@@ -27,6 +28,9 @@ public interface MinecraftAccessor {
|
||||
@Accessor("renderTickCounter")
|
||||
RenderTickCounter getTimer();
|
||||
@Accessor("renderTickCounter")
|
||||
//#if MC>=11200
|
||||
@Mutable
|
||||
//#endif
|
||||
void setTimer(RenderTickCounter value);
|
||||
|
||||
//#if MC>=11400
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.replaymod.core.mixin;
|
||||
|
||||
import net.minecraft.client.render.RenderTickCounter;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(RenderTickCounter.class)
|
||||
@@ -15,6 +16,7 @@ public interface TimerAccessor {
|
||||
@Accessor("tickTime")
|
||||
float getTickLength();
|
||||
@Accessor("tickTime")
|
||||
@Mutable
|
||||
void setTickLength(float value);
|
||||
//#else
|
||||
//$$ @Accessor
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
package com.replaymod.core.versions;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.replaymod.core.mixin.GuiScreenAccessor;
|
||||
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.MinecraftGuiRenderer;
|
||||
import de.johni0702.minecraft.gui.utils.lwjgl.vector.Vector2f;
|
||||
import de.johni0702.minecraft.gui.utils.lwjgl.vector.Vector3f;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.render.BufferBuilder;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.Util;
|
||||
|
||||
//#if MC>=11600
|
||||
@@ -206,14 +212,15 @@ public class MCVer {
|
||||
//#endif
|
||||
) {
|
||||
GuiScreenAccessor acc = (GuiScreenAccessor) screen;
|
||||
acc.getButtons().add(button);
|
||||
//#if MC>=11400
|
||||
acc.getChildren().add(button);
|
||||
acc.invokeAddButton(button);
|
||||
//#else
|
||||
//$$ acc.getButtons().add(button);
|
||||
//#endif
|
||||
}
|
||||
|
||||
//#if MC>=11400
|
||||
public static Optional<AbstractButtonWidget> findButton(List<AbstractButtonWidget> buttonList, @SuppressWarnings("unused") String text, @SuppressWarnings("unused") int id) {
|
||||
public static Optional<AbstractButtonWidget> findButton(Iterable<AbstractButtonWidget> buttonList, @SuppressWarnings("unused") String text, @SuppressWarnings("unused") int id) {
|
||||
//#if MC>=11600
|
||||
final TranslatableText message = new TranslatableText(text);
|
||||
//#else
|
||||
@@ -233,7 +240,7 @@ public class MCVer {
|
||||
return Optional.empty();
|
||||
}
|
||||
//#else
|
||||
//$$ public static Optional<GuiButton> findButton(List<GuiButton> buttonList, @SuppressWarnings("unused") String text, int id) {
|
||||
//$$ public static Optional<GuiButton> findButton(Iterable<GuiButton> buttonList, @SuppressWarnings("unused") String text, int id) {
|
||||
//$$ for (GuiButton b : buttonList) {
|
||||
//$$ if (b.id == id) {
|
||||
//$$ return Optional.of(b);
|
||||
@@ -332,6 +339,53 @@ public class MCVer {
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static void pushMatrix() {
|
||||
//#if MC>=11700
|
||||
//$$ RenderSystem.getModelViewStack().push();
|
||||
//#else
|
||||
GlStateManager.pushMatrix();
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static void popMatrix() {
|
||||
//#if MC>=11700
|
||||
//$$ RenderSystem.getModelViewStack().pop();
|
||||
//$$ RenderSystem.applyModelViewMatrix();
|
||||
//#else
|
||||
GlStateManager.popMatrix();
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static void emitLine(BufferBuilder buffer, Vector2f p1, Vector2f p2, int color) {
|
||||
emitLine(buffer, new Vector3f(p1.x, p1.y, 0), new Vector3f(p2.x, p2.y, 0), color);
|
||||
}
|
||||
|
||||
public static void emitLine(BufferBuilder buffer, Vector3f p1, Vector3f p2, int color) {
|
||||
int r = color >> 24 & 0xff;
|
||||
int g = color >> 16 & 0xff;
|
||||
int b = color >> 8 & 0xff;
|
||||
int a = color & 0xff;
|
||||
//#if MC>=11700
|
||||
//$$ Vector3f n = Vector3f.sub(p2, p1, null);
|
||||
//#endif
|
||||
buffer.vertex(p1.x, p1.y, p1.z)
|
||||
.color(r, g, b, a)
|
||||
//#if MC>=11700
|
||||
//$$ .normal(n.x, n.y, n.z)
|
||||
//#endif
|
||||
.next();
|
||||
buffer.vertex(p2.x, p2.y, p2.z)
|
||||
.color(r, g, b, a)
|
||||
//#if MC>=11700
|
||||
//$$ .normal(n.x, n.y, n.z)
|
||||
//#endif
|
||||
.next();
|
||||
}
|
||||
|
||||
public static void bindTexture(Identifier id) {
|
||||
new MinecraftGuiRenderer(null).bindTexture(id);
|
||||
}
|
||||
|
||||
//#if MC<10900
|
||||
//$$ public static class SoundEvent {}
|
||||
//#endif
|
||||
|
||||
@@ -3,6 +3,7 @@ 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.render.VertexFormat;
|
||||
import net.minecraft.client.texture.TextureManager;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.client.render.Tessellator;
|
||||
@@ -16,6 +17,11 @@ import net.minecraft.util.Identifier;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.WorldChunk;
|
||||
|
||||
//#if MC>=11700
|
||||
//#else
|
||||
import org.lwjgl.opengl.GL11;
|
||||
//#endif
|
||||
|
||||
//#if MC>=11400
|
||||
import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
||||
import net.minecraft.client.util.Window;
|
||||
@@ -88,6 +94,42 @@ class Patterns {
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static void Entity_setYaw(Entity entity, float value) {
|
||||
//#if MC>=11700
|
||||
//$$ entity.setYaw(value);
|
||||
//#else
|
||||
entity.yaw = value;
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static float Entity_getYaw(Entity entity) {
|
||||
//#if MC>=11700
|
||||
//$$ return entity.getYaw();
|
||||
//#else
|
||||
return entity.yaw;
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static void Entity_setPitch(Entity entity, float value) {
|
||||
//#if MC>=11700
|
||||
//$$ entity.setPitch(value);
|
||||
//#else
|
||||
entity.pitch = value;
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static float Entity_getPitch(Entity entity) {
|
||||
//#if MC>=11700
|
||||
//$$ return entity.getPitch();
|
||||
//#else
|
||||
return entity.pitch;
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static void Entity_setPos(Entity entity, double x, double y, double z) {
|
||||
//#if MC>=11500
|
||||
@@ -187,13 +229,19 @@ class Patterns {
|
||||
}
|
||||
|
||||
@Pattern
|
||||
//#if MC>=11700
|
||||
//$$ private static void getEntitySectionArray() {}
|
||||
//#else
|
||||
private static Collection<Entity>[] getEntitySectionArray(WorldChunk chunk) {
|
||||
//#if MC>=10800
|
||||
//#if MC>=11700
|
||||
//$$ return obsolete(chunk);
|
||||
//#elseif MC>=10800
|
||||
return chunk.getEntitySectionArray();
|
||||
//#else
|
||||
//$$ return chunk.entityLists;
|
||||
//#endif
|
||||
}
|
||||
//#endif
|
||||
|
||||
@Pattern
|
||||
private static List<? extends PlayerEntity> playerEntities(World world) {
|
||||
@@ -244,6 +292,7 @@ class Patterns {
|
||||
//#endif
|
||||
}
|
||||
|
||||
//#if MC<11700
|
||||
@Pattern
|
||||
private static void BufferBuilder_beginPosCol(BufferBuilder buffer, int mode) {
|
||||
//#if MC>=10809
|
||||
@@ -297,6 +346,14 @@ class Patterns {
|
||||
//$$ { 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
|
||||
}
|
||||
//#else
|
||||
@Pattern private static void BufferBuilder_beginPosCol() {}
|
||||
@Pattern private static void BufferBuilder_addPosCol() {}
|
||||
@Pattern private static void BufferBuilder_beginPosTex() {}
|
||||
@Pattern private static void BufferBuilder_addPosTex() {}
|
||||
@Pattern private static void BufferBuilder_beginPosTexCol() {}
|
||||
@Pattern private static void BufferBuilder_addPosTexCol() {}
|
||||
//#endif
|
||||
|
||||
@Pattern
|
||||
private static Tessellator Tessellator_getInstance() {
|
||||
@@ -382,4 +439,64 @@ class Patterns {
|
||||
//$$ return (a.getKeyCode() == b.getKeyCode());
|
||||
//#endif
|
||||
}
|
||||
|
||||
//#if MC>=11600
|
||||
@Pattern
|
||||
private static void BufferBuilder_beginLineStrip(BufferBuilder buffer, VertexFormat vertexFormat) {
|
||||
//#if MC>=11700
|
||||
//$$ buffer.begin(net.minecraft.client.render.VertexFormat.DrawMode.LINE_STRIP, VertexFormats.LINES);
|
||||
//#else
|
||||
buffer.begin(GL11.GL_LINE_STRIP, VertexFormats.POSITION_COLOR);
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static void BufferBuilder_beginLines(BufferBuilder buffer) {
|
||||
//#if MC>=11700
|
||||
//$$ buffer.begin(net.minecraft.client.render.VertexFormat.DrawMode.LINES, VertexFormats.LINES);
|
||||
//#else
|
||||
buffer.begin(GL11.GL_LINES, VertexFormats.POSITION_COLOR);
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static void BufferBuilder_beginQuads(BufferBuilder buffer, VertexFormat vertexFormat) {
|
||||
//#if MC>=11700
|
||||
//$$ buffer.begin(net.minecraft.client.render.VertexFormat.DrawMode.QUADS, vertexFormat);
|
||||
//#else
|
||||
buffer.begin(GL11.GL_QUADS, vertexFormat);
|
||||
//#endif
|
||||
}
|
||||
//#else
|
||||
//$$ @Pattern private static void BufferBuilder_beginLineStrip() {}
|
||||
//$$ @Pattern private static void BufferBuilder_beginLines() {}
|
||||
//$$ @Pattern private static void BufferBuilder_beginQuads() {}
|
||||
//#endif
|
||||
|
||||
@Pattern
|
||||
private static void GL11_glLineWidth(float width) {
|
||||
//#if MC>=11700
|
||||
//$$ com.mojang.blaze3d.systems.RenderSystem.lineWidth(width);
|
||||
//#else
|
||||
GL11.glLineWidth(width);
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static void GL11_glTranslatef(float x, float y, float z) {
|
||||
//#if MC>=11700
|
||||
//$$ com.mojang.blaze3d.systems.RenderSystem.getModelViewStack().translate(x, y, z);
|
||||
//#else
|
||||
GL11.glTranslatef(x, y, z);
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static void GL11_glRotatef(float angle, float x, float y, float z) {
|
||||
//#if MC>=11700
|
||||
//$$ { float $angle = angle; com.mojang.blaze3d.systems.RenderSystem.getModelViewStack().multiply(new net.minecraft.util.math.Quaternion(new net.minecraft.util.math.Vec3f(x, y, z), $angle, true)); }
|
||||
//#else
|
||||
GL11.glRotatef(angle, x, y, z);
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class SchedulerImpl implements Scheduler {
|
||||
runLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mc.overlay != null) {
|
||||
if (mc.getOverlay() != null) {
|
||||
// delay until after resources have been loaded
|
||||
runLater(this);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user