Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to biny #8

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
plugins {
id 'babric-loom' version '1.4-SNAPSHOT'
id "maven-publish"
id 'fabric-loom' version '1.7.3'
id 'babric-loom-extension' version '1.7.4'
id 'maven-publish'
id("com.modrinth.minotaur") version "2.+"
id "com.diffplug.spotless" version "6.2.2"
}

sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17

archivesBaseName = project.archives_base_name
group = project.maven_group
version = project.mod_version
group = project.maven_group

loom {
mixin {
useLegacyMixinAp = true
}
customMinecraftManifest.set("https://babric.github.io/manifest-polyfill/${minecraft_version}.json")
intermediaryUrl.set("https://maven.glass-launcher.net/babric/babric/intermediary/%1\$s/intermediary-%1\$s-v2.jar")
}

repositories {
// Add repositories to retrieve artifacts from in here.
Expand Down Expand Up @@ -58,15 +67,9 @@ repositories {
mavenCentral()
}

loom {
gluedMinecraftJar()
customMinecraftManifest.set("https://babric.github.io/manifest-polyfill/${minecraft_version}.json")
intermediaryUrl.set("https://maven.glass-launcher.net/babric/babric/intermediary/%1\$s/intermediary-%1\$s-v2.jar")
}

dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "babric:barn:${project.yarn_mappings}:v2"
mappings "net.glasslauncher:biny:${project.yarn_mappings}:v2"
modImplementation "babric:fabric-loader:${project.loader_version}"

implementation "org.slf4j:slf4j-api:1.8.0-beta4"
Expand All @@ -92,7 +95,7 @@ dependencies {
modImplementation("net.glasslauncher:HowManyItems-Fabric-Unofficial:${project.howmanyitems_version}") {
transitive false
}
modImplementation('com.github.matthewperiut:spc-babric:0.4.3') {
modImplementation('com.github.matthewperiut:spc-babric:0.4.5') {
transitive false
}
}
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ org.gradle.daemon=false
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=b1.7.3
yarn_mappings=b1.7.3+build.8
yarn_mappings=b1.7.3+85f76bb
loader_version=0.14.24-babric.1

# Mod Properties
Expand All @@ -14,7 +14,7 @@ maven_group = pl.telvarost
archives_base_name = mojangfixstationapi

# Dependencies
stapi_version=2.0-alpha.2
stapi_version=2.0-alpha.2.3
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't StationAPI 2.3 broken in prod right now? Shouldn't this be 2.1?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't make a difference, as the things changed in 2.3 versus 2.1 are not touched by this mod, so pretty much the only difference is the runtime version of stationapi as all API things remain the same.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and in dev it works fine

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually like to set it to whatever, players will actually experience. So I will probably revert it back to 2.1 until StationAPI stabilizes

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, it doesn't make much of a difference to me

mixinextras_version = 0.2.1

# Extra Dependencies
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ public void render(int mouseX, int mouseY, float delta) {
this.renderBackground();
TranslationStorage translations = TranslationStorage.getInstance();
this.drawCenteredTextWithShadow(this.textRenderer, (this.server == null ? translations.get("multiplayer.mojangfixstationapi.addServer") : translations.get("multiplayer.mojangfixstationapi.editServerInfo")), this.width / 2, 20, 16777215);
this.drawStringWithShadow(this.textRenderer, translations.get("multiplayer.mojangfixstationapi.serverName"), this.width / 2 - 100, 47, 10526880);
this.drawStringWithShadow(this.textRenderer, translations.get("multiplayer.mojangfixstationapi.serverAddress"), this.width / 2 - 100, 94, 10526880);
this.drawTextWithShadow(this.textRenderer, translations.get("multiplayer.mojangfixstationapi.serverName"), this.width / 2 - 100, 47, 10526880);
this.drawTextWithShadow(this.textRenderer, translations.get("multiplayer.mojangfixstationapi.serverAddress"), this.width / 2 - 100, 94, 10526880);
this.nameTextField.render();
this.ipTextField.render();
super.render(mouseX, mouseY, delta);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ protected void renderBackground() {
@Override
protected void renderEntry(int index, int x, int y, int l, Tessellator arg) {
ServerData server = this.parent.getServersList().get(index);
this.parent.drawStringWithShadow(this.parent.getFontRenderer(), server.getName(), x + 2, y + 1, 0xffffff);
this.parent.drawTextWithShadow(this.parent.getFontRenderer(), server.getName(), x + 2, y + 1, 0xffffff);
if (Config.config.disableServerListIpAddresses) {
TranslationStorage translations = TranslationStorage.getInstance();
String hideIp = "(" + translations.get("multiplayer.mojangfixstationapi.hidden") + ")";
this.parent.drawStringWithShadow(this.parent.getFontRenderer(), hideIp, x + 2, y + 12, 0x808080);
this.parent.drawTextWithShadow(this.parent.getFontRenderer(), hideIp, x + 2, y + 12, 0x808080);
} else {
this.parent.drawStringWithShadow(this.parent.getFontRenderer(), server.getIp(), x + 2, y + 12, 0x808080);
this.parent.drawTextWithShadow(this.parent.getFontRenderer(), server.getIp(), x + 2, y + 12, 0x808080);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.network.ClientNetworkHandler;
import net.minecraft.network.Connection;
import net.minecraft.network.Packet;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.handshake.HandshakePacket;
import net.minecraft.network.packet.login.LoginHelloPacket;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -41,12 +41,12 @@ public abstract class ClientNetworkHandlerMixin {
@Shadow
public abstract void sendPacket(Packet arg);

@Redirect(method = "handleHandshake", at = @At(value = "INVOKE", target = "Ljava/lang/String;equals(Ljava/lang/Object;)Z"))
@Redirect(method = "onHandshake", at = @At(value = "INVOKE", target = "Ljava/lang/String;equals(Ljava/lang/Object;)Z"))
private boolean checkServerId(String serverId, Object offline) {
return serverId.trim().isEmpty() || serverId.equals(offline) || this.minecraft.session.sessionId.trim().isEmpty() || this.minecraft.session.sessionId.equals(offline);
}

@Inject(method = "handleHandshake", at = @At(value = "NEW", target = "java/net/URL"), cancellable = true)
@Inject(method = "onHandshake", at = @At(value = "NEW", target = "java/net/URL"), cancellable = true)
private void onJoinServer(HandshakePacket packet, CallbackInfo ci) {
SessionAccessor session = (SessionAccessor) this.minecraft.session;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
package pl.telvarost.mojangfixstationapi.mixin.client.inventory;

import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.container.ContainerScreen;
import net.minecraft.inventory.Container;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.item.ItemStack;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.slot.Slot;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
Expand All @@ -33,13 +33,13 @@
import java.util.HashSet;
import java.util.Set;

@Mixin(ContainerScreen.class)
@Mixin(HandledScreen.class)
public abstract class ContainerScreenMixin extends Screen {
@Shadow
protected abstract Slot getSlotAt(int x, int y);

@Shadow
public Container container;
public ScreenHandler container;

@Shadow
protected abstract boolean isPointOverSlot(Slot slot, int x, int Y);
Expand Down Expand Up @@ -77,13 +77,13 @@ private void onMouseReleased(int mouseX, int mouseY, int button, CallbackInfo ci
@Unique
private boolean drawingHoveredSlot;

@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/container/ContainerScreen;isPointOverSlot(Lnet/minecraft/screen/slot/Slot;II)Z"))
private boolean redirectIsPointOverSlot(ContainerScreen guiContainer, Slot slot, int x, int y) {
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/ingame/HandledScreen;isPointOverSlot(Lnet/minecraft/screen/slot/Slot;II)Z"))
private boolean redirectIsPointOverSlot(HandledScreen guiContainer, Slot slot, int x, int y) {
return (drawingHoveredSlot = hoveredSlots.contains(slot)) || isPointOverSlot(slot, x, y);
}

@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/container/ContainerScreen;fillGradient(IIIIII)V", ordinal = 0))
private void redirectFillGradient(ContainerScreen instance, int startX, int startY, int endX, int endY, int colorStart, int colorEnd) {
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/ingame/HandledScreen;fillGradient(IIIIII)V", ordinal = 0))
private void redirectFillGradient(HandledScreen instance, int startX, int startY, int endX, int endY, int colorStart, int colorEnd) {
if (colorStart != colorEnd) throw new AssertionError();
int color = drawingHoveredSlot ? 0x20ffffff : colorStart;
this.fillGradient(startX, startY, endX, endY, color, color);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package pl.telvarost.mojangfixstationapi.mixin.client.misc;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.hud.InGameHud;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -26,7 +26,7 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(InGameHud.class)
public class InGameHudMixin extends DrawableHelper {
public class InGameHudMixin extends DrawContext {
@Shadow
private Minecraft minecraft;

Expand All @@ -36,6 +36,6 @@ public class InGameHudMixin extends DrawableHelper {
slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/client/option/GameOptions;debugHud:Z"))
)
private void onRenderGameOverlay(CallbackInfo ci) {
this.drawStringWithShadow(this.minecraft.textRenderer, "Seed: " + this.minecraft.world.getSeed(), 2, 88 + 8 + 8, 0xe0e0e0);
this.drawTextWithShadow(this.minecraft.textRenderer, "Seed: " + this.minecraft.world.getSeed(), 2, 88 + 8 + 8, 0xe0e0e0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

@Mixin(Screen.class)
public class ScreenMixin {
@Redirect(method = "*", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;buttonClicked(Lnet/minecraft/client/gui/widget/ButtonWidget;)V"))
@Redirect(method = "mouseClicked", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;buttonClicked(Lnet/minecraft/client/gui/widget/ButtonWidget;)V"))
private void onActionPerformed(Screen screen, ButtonWidget button) {
if (button instanceof CallbackButtonWidget) {
CallbackButtonWidget buttonWidget = (CallbackButtonWidget) button;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
public abstract class TitleScreenMixin extends Screen {
@Inject(method = "render", at = @At("RETURN"))
private void onDrawScreen(CallbackInfo ci) {
this.drawStringWithShadow(this.textRenderer, MojangFixStationApiMod.getMetadata().getName() + " " + MojangFixStationApiMod.getVersion(), 2, 2 + 10, 0x505050);
this.drawTextWithShadow(this.textRenderer, MojangFixStationApiMod.getMetadata().getName() + " " + MojangFixStationApiMod.getVersion(), 2, 2 + 10, 0x505050);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ public void write(String text) {
this.text = (new StringBuilder(this.text)).insert(this.text.length() + this.cursorPosition, text).toString();
}

@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/TextFieldWidget;drawStringWithShadow(Lnet/minecraft/client/font/TextRenderer;Ljava/lang/String;III)V"))
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/TextFieldWidget;drawTextWithShadow(Lnet/minecraft/client/font/TextRenderer;Ljava/lang/String;III)V"))
private void onDrawTextBox(TextFieldWidget guiTextField, TextRenderer textRenderer, String text, int x, int y, int color) {
guiTextField.drawStringWithShadow(textRenderer, this.getDisplayText(), x, y, color);
guiTextField.drawTextWithShadow(textRenderer, this.getDisplayText(), x, y, color);
}

public String getDisplayText() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ private void onTick(CallbackInfo ci) {
ci.cancel();
}

@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/ChatScreen;drawStringWithShadow(Lnet/minecraft/client/font/TextRenderer;Ljava/lang/String;III)V"))
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/ChatScreen;drawTextWithShadow(Lnet/minecraft/client/font/TextRenderer;Ljava/lang/String;III)V"))
private void redirectDrawString(ChatScreen chatScreen, TextRenderer textRenderer, String text, int x, int y, int color) {
drawStringWithShadow(textRenderer, "> " + ((TextFieldWidgetAccessor) textField).getDisplayText(), x, y, color);
drawTextWithShadow(textRenderer, "> " + ((TextFieldWidgetAccessor) textField).getDisplayText(), x, y, color);
}

@Redirect(method = "*", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/screen/ChatScreen;text:Ljava/lang/String;", opcode = Opcodes.GETFIELD))
Expand Down
Loading