Skip to content

Commit

Permalink
start port
Browse files Browse the repository at this point in the history
  • Loading branch information
ferriarnus committed May 12, 2024
1 parent c45fb9d commit 938c72e
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 52 deletions.
17 changes: 16 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

loom {
mixin.defaultRefmapName = "mixins.replaymod.refmap.json"
forge {
mixinConfigs = [
"mixins.compat.mapwriter.replaymod.json",
"mixins.compat.shaders.replaymod.json",
"mixins.core.replaymod.json",
"mixins.extras.playeroverview.replaymod.json",
"mixins.jgui.json",
"mixins.nonmmlauncher.replaymod.json",
"mixins.recording.replaymod.json",
"mixins.render.blend.replaymod.json",
"mixins.render.replaymod.json",
"mixins.replay.replaymod.json"
]
}
runs {
it.configureEach {
vmArgs("-Xmx8G", "-XX:+UseZGC")
Expand Down Expand Up @@ -73,7 +88,7 @@ dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
//mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
neoForge "net.neoforged:neoforge:${project.neoforge_version}"
forge "net.minecraftforge:forge:${project.minecraft_version}-${project.forge_version}"

bundle("com.github.ReplayMod:ReplayStudio:d9f7c11-slim")
minecraftRuntimeLibraries(implementation("com.github.ReplayMod:ReplayStudio:d9f7c11"))
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ org.gradle.jvmargs=-Xmx3G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html

minecraft_version=1.20.4
yarn_mappings=1.20.4+build.1
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.1
loader_version=0.15.0

#Fabric api
fabric_version=0.91.1+1.20.4
fabric_version=0.91.1+1.20.1

# Mod Properties
mod_version=0.1
maven_group=com.replaymod
archives_base_name=replaymod
# Dependencies
# check this on https://modmuss50.me/fabric.html
loom.platform=neoforge
neoforge_version=20.4.234
loom.platform=forge
forge_version=47.1.3
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ public void onConnectedToServerEvent(ClientConnection networkManager) {
serverName = worldName;
//#if MC>=11100
//#if MC>=12002
} else if (serverInfo != null && serverInfo.isRealm()) {
//$$ } else if (serverInfo != null && serverInfo.isRealm()) {
//#else
//$$ } else if (mc.isConnectedToRealms()) {
} else if (mc.isConnectedToRealms()) {
//#endif
// we can't access the server name without tapping too deep in the Realms Library
worldName = "A Realms Server";
Expand Down
28 changes: 14 additions & 14 deletions src/main/java/com/replaymod/replay/camera/CameraEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
//#endif

//#if MC>=12002
import net.minecraft.client.util.SkinTextures;
//$$ import net.minecraft.client.util.SkinTextures;
//#endif

//#if MC>=11400
Expand Down Expand Up @@ -480,24 +480,24 @@ public boolean isInvisible() {
}

//#if MC>=12002
@Override
public SkinTextures getSkinTextures() {
Entity view = this.client.getCameraEntity();
if (view != this && view instanceof AbstractClientPlayerEntity) {
return ((AbstractClientPlayerEntity) view).getSkinTextures();
}
return super.getSkinTextures();
}
//#else
//$$ @Override
//$$ public Identifier getSkinTexture() {
//$$ public SkinTextures getSkinTextures() {
//$$ Entity view = this.client.getCameraEntity();
//$$ if (view != this && view instanceof AbstractClientPlayerEntity) {
//$$ return ((AbstractClientPlayerEntity) view).getSkinTexture();
//$$ return ((AbstractClientPlayerEntity) view).getSkinTextures();
//$$ }
//$$ return super.getSkinTexture();
//$$ return super.getSkinTextures();
//$$ }
//$$
//#else
@Override
public Identifier getSkinTexture() {
Entity view = this.client.getCameraEntity();
if (view != this && view instanceof AbstractClientPlayerEntity) {
return ((AbstractClientPlayerEntity) view).getSkinTexture();
}
return super.getSkinTexture();
}

//#if MC>=10800
//$$ @Override
//$$ public String getModel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ public boolean mouseScrolled(
double mouseY,
//#endif
//#if MC>=12002
double dWheelHorizontal,
//$$ double dWheelHorizontal,
//#endif
double dWheel
) {
Expand Down Expand Up @@ -398,9 +398,9 @@ public void removed() {
}

//#if MC>=12002
@Override
public void renderBackground(DrawContext context, int mouseX, int mouseY, float delta) {
}
//$$ @Override
//$$ public void renderBackground(DrawContext context, int mouseX, int mouseY, float delta) {
//$$ }
//#endif

public AbstractGuiOverlay<T> getOverlay() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ public void draw(GuiRenderer renderer, ReadableDimension size, RenderInfo render
break;
case DEFAULT:
//#if MC>=12002
wrapped.renderBackground(renderer.getContext(), renderInfo.mouseX, renderInfo.mouseY, renderInfo.partialTick);
//$$ wrapped.renderBackground(renderer.getContext(), renderInfo.mouseX, renderInfo.mouseY, renderInfo.partialTick);
//#elseif MC>=12000
//$$ wrapped.renderBackground(renderer.getContext());
wrapped.renderBackground(renderer.getContext());
//#elseif MC>=11600
//$$ wrapped.renderBackground(renderer.getMatrixStack());
//#else
Expand Down Expand Up @@ -361,7 +361,7 @@ public boolean mouseScrolled(
double mouseY,
//#endif
//#if MC>=12002
double dWheelHorizontal,
//$$ double dWheelHorizontal,
//#endif
double dWheel
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@
public abstract class AbstractGuiButton<T extends AbstractGuiButton<T>> extends AbstractGuiClickable<T> implements Clickable, IGuiButton<T> {
protected static final Identifier BUTTON_SOUND = new Identifier("gui.button.press");
//#if MC>=12002
protected static final Identifier[] BUTTON_TEXTURES = new Identifier[] {
new Identifier("widget/button_disabled"),
new Identifier("widget/button"),
new Identifier("widget/button_highlighted"),
};
//$$ protected static final Identifier[] BUTTON_TEXTURES = new Identifier[] {
//$$ new Identifier("widget/button_disabled"),
//$$ new Identifier("widget/button"),
//$$ new Identifier("widget/button_highlighted"),
//$$ };
//#else
//$$ protected static final Identifier WIDGETS_TEXTURE = new Identifier("textures/gui/widgets.png");
protected static final Identifier WIDGETS_TEXTURE = new Identifier("textures/gui/widgets.png");
//#endif

//#if MC>=11903
Expand Down Expand Up @@ -107,14 +107,14 @@ public void draw(GuiRenderer renderer, ReadableDimension size, RenderInfo render
int secondHalfHeight = size.getHeight() - halfHeight;

//#if MC>=12002
ReadablePoint offset = renderer.getOpenGlOffset();
renderer.getContext().drawGuiTexture(BUTTON_TEXTURES[texture], offset.getX(), offset.getY(), size.getWidth(), size.getHeight());
//$$ ReadablePoint offset = renderer.getOpenGlOffset();
//$$ renderer.getContext().drawGuiTexture(BUTTON_TEXTURES[texture], offset.getX(), offset.getY(), size.getWidth(), size.getHeight());
//#else
//$$ renderer.bindTexture(WIDGETS_TEXTURE);
//$$ renderer.drawTexturedRect(0, 0, 0, textureY, halfWidth, halfHeight);
//$$ renderer.drawTexturedRect(0, halfHeight, 0, textureY + 20 - secondHalfHeight, halfWidth, secondHalfHeight);
//$$ renderer.drawTexturedRect(halfWidth, 0, 200 - secondHalfWidth, textureY, secondHalfWidth, halfHeight);
//$$ renderer.drawTexturedRect(halfWidth, halfHeight, 200 - secondHalfWidth, textureY + 20 - secondHalfHeight, secondHalfWidth, secondHalfHeight);
renderer.bindTexture(WIDGETS_TEXTURE);
renderer.drawTexturedRect(0, 0, 0, textureY, halfWidth, halfHeight);
renderer.drawTexturedRect(0, halfHeight, 0, textureY + 20 - secondHalfHeight, halfWidth, secondHalfHeight);
renderer.drawTexturedRect(halfWidth, 0, 200 - secondHalfWidth, textureY, secondHalfWidth, halfHeight);
renderer.drawTexturedRect(halfWidth, halfHeight, 200 - secondHalfWidth, textureY + 20 - secondHalfHeight, secondHalfWidth, secondHalfHeight);
//#endif

if (this.texture != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
// TODO: Currently assumes a height of 20
public abstract class AbstractGuiSlider<T extends AbstractGuiSlider<T>> extends AbstractGuiElement<T> implements Clickable, Draggable, IGuiSlider<T> {
//#if MC>=12002
protected static final Identifier TEXTURE = new Identifier("widget/slider");
protected static final Identifier HANDLE_TEXTURE = new Identifier("widget/slider_handle");
//$$ protected static final Identifier TEXTURE = new Identifier("widget/slider");
//$$ protected static final Identifier HANDLE_TEXTURE = new Identifier("widget/slider_handle");
//#endif

private Runnable onValueChanged;
Expand Down Expand Up @@ -120,26 +120,26 @@ public void draw(GuiRenderer renderer, ReadableDimension size, RenderInfo render
int height = size.getHeight();

//#if MC>=12002
ReadablePoint offset = renderer.getOpenGlOffset();
//$$ ReadablePoint offset = renderer.getOpenGlOffset();
//#else
//$$ renderer.bindTexture(GuiButton.WIDGETS_TEXTURE);
renderer.bindTexture(GuiButton.WIDGETS_TEXTURE);
//#endif

// Draw background
//#if MC>=12002
renderer.getContext().drawGuiTexture(TEXTURE, offset.getX(), offset.getY(), width, height);
//$$ renderer.getContext().drawGuiTexture(TEXTURE, offset.getX(), offset.getY(), width, height);
//#else
//$$ renderer.drawTexturedRect(0, 0, 0, 46, width / 2, height);
//$$ renderer.drawTexturedRect(width / 2, 0, 200 - width / 2, 46, width / 2, height);
renderer.drawTexturedRect(0, 0, 0, 46, width / 2, height);
renderer.drawTexturedRect(width / 2, 0, 200 - width / 2, 46, width / 2, height);
//#endif

// Draw slider
int sliderX = (width - 8) * value / steps;
//#if MC>=12002
renderer.getContext().drawGuiTexture(HANDLE_TEXTURE, offset.getX() + sliderX, offset.getY(), 8, 20);
//$$ renderer.getContext().drawGuiTexture(HANDLE_TEXTURE, offset.getX() + sliderX, offset.getY(), 8, 20);
//#else
//$$ renderer.drawTexturedRect(sliderX, 0, 0, 66, 4, 20);
//$$ renderer.drawTexturedRect(sliderX + 4, 0, 196, 66, 4, 20);
renderer.drawTexturedRect(sliderX, 0, 0, 66, 4, 20);
renderer.drawTexturedRect(sliderX + 4, 0, 196, 66, 4, 20);
//#endif

// Draw text
Expand Down

0 comments on commit 938c72e

Please sign in to comment.