Skip to content

Commit

Permalink
feat: port to 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHillcox committed Jun 16, 2024
1 parent ea91406 commit ae7696d
Show file tree
Hide file tree
Showing 44 changed files with 293 additions and 375 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
!contains(github.event.head_commit.message, '[ciskip]')
uses: FTBTeam/mods-meta/.github/workflows/standard-release.yml@main
with:
curse-publish-task: curseforge
curse-publish-task: publishMods
java-version: 21
secrets:
ftb-maven-token: ${{ secrets.FTB_MAVEN_TOKEN }}
saps-token: ${{ secrets.SAPS_TOKEN }}
curse-token: ${{ secrets.CURSEFORGE_KEY }}
curse-token: ${{ secrets.CURSEFORGE_KEY }}
82 changes: 80 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.6-SNAPSHOT" apply false
id "com.matthewprenger.cursegradle" version "1.4.0" apply false
id "me.modmuss50.mod-publish-plugin" version "0.5.1"
}

architectury {
Expand Down Expand Up @@ -67,6 +67,84 @@ allprojects {
java {
withSourcesJar()
}

publishing {
repositories {
if (ftbPublishing.ftbToken) {
maven {
url ftbPublishing.ftbURL
credentials {
username = ftbPublishing.ftbUser
password = ftbPublishing.ftbToken
}
}
}

if (ftbPublishing.sapsToken) {
maven {
url ftbPublishing.sapsURL
credentials {
username = ftbPublishing.sapsUser
password = ftbPublishing.sapsToken
}
}
}
}
}
}

task curseforgePublish
publishMods {
dryRun = providers.environmentVariable("CURSEFORGE_KEY").getOrNull() == null
changelog = providers.environmentVariable("CHANGELOG").getOrElse("No changelog provided")
version = "${mod_version}"

// TODO: Migrate to something else
def tag = providers.environmentVariable("TAG").getOrElse("release")
type = tag == "beta" ? BETA : (tag == "alpha" ? ALPHA : STABLE)

def createOptions = (String projectName) -> {
publishOptions {
file = project.provider { project(":$projectName").tasks.remapJar }.flatMap { it.archiveFile }
displayName = "[${projectName.toUpperCase()}][${minecraft_version}] ${readable_name} ${mod_version}"
modLoaders.add(projectName.toLowerCase())
}
}

def fabricOptions = createOptions("fabric")
def neoForgeOptions = createOptions("neoforge")
def forgeOptions = createOptions("forge")

def curseForgeOptions = curseforgeOptions {
accessToken = providers.environmentVariable("CURSEFORGE_KEY")
minecraftVersions.add("${minecraft_version}")
// javaVersions.add(JavaVersion.JAVA_21)
}

curseforge("curseforgeFabric") {
from(curseForgeOptions, fabricOptions)
projectId = curseforge_id_fabric
requires('architectury-api')
requires('fabric-api')
requires('ftb-library-fabric')
requires('ftb-teams-fabric')
optional('ftb-xmod-compat')
}

curseforge("curseforgeNeoForge") {
from(curseForgeOptions, neoForgeOptions)
projectId = curseforge_id_forge
requires('architectury-api')
requires('ftb-library-forge')
requires('ftb-teams-forge')
optional('ftb-xmod-compat')
}

curseforge("curseforgeForge") {
from(curseForgeOptions, forgeOptions)
projectId = curseforge_id_forge
requires('architectury-api')
requires('ftb-library-forge')
requires('ftb-teams-forge')
optional('ftb-xmod-compat')
}
}
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dependencies {
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"

modApi "dev.architectury:architectury:${rootProject.architectury_version}"
modApi "dev.architectury:architectury:${rootProject.architectury_api_version}"

modApi("dev.ftb.mods:ftb-library:${rootProject.ftb_library_version}") { transitive false }
modApi "dev.ftb.mods:ftb-teams:${rootProject.ftb_teams_version}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ void init() {
LifecycleEvent.SERVER_STARTED.register(this::serverStarted);
LifecycleEvent.SERVER_STOPPING.register(this::serverStopped);
LifecycleEvent.SERVER_LEVEL_SAVE.register(this::worldSaved);
ModDataComponents.register();
ModBlocks.register();
ModItems.register();
ModDataComponents.register();
ModBlockEntityTypes.register();
ClearFileCacheEvent.EVENT.register(this::fileCacheClear);
TeamEvent.PLAYER_LOGGED_IN.register(this::playerLoggedIn);
Expand Down Expand Up @@ -227,4 +227,4 @@ private void containerOpened(Player player, AbstractContainerMenu menu) {
menu.addSlotListener(new FTBQuestsInventoryListener((ServerPlayer) player));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static FTBQuestsAPI.API api() {
* @return a new resource location
*/
public static ResourceLocation rl(String path) {
return new ResourceLocation(MOD_ID, path);
return ResourceLocation.fromNamespaceAndPath(MOD_ID, path);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
package dev.ftb.mods.ftbquests.api;

import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.Item;

public class FTBQuestsTags {
public static class EntityTypes {
public static final TagKey<EntityType<?>> NO_LOOT_CRATES
= TagKey.create(Registries.ENTITY_TYPE, new ResourceLocation(FTBQuestsAPI.MOD_ID, "no_loot_crates"));
public static final TagKey<EntityType<?>> NO_LOOT_CRATES = TagKey.create(Registries.ENTITY_TYPE, FTBQuestsAPI.rl("no_loot_crates"));
}

public static class Items {
public static final TagKey<Item> CHECK_NBT
= TagKey.create(Registries.ITEM, FTBQuestsAPI.rl("match_nbt"));
public static final TagKey<Item> CHECK_NBT = TagKey.create(Registries.ITEM, FTBQuestsAPI.rl("match_nbt"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import dev.ftb.mods.ftbquests.registry.ModItems;
import it.unimi.dsi.fastutil.longs.LongSet;
import net.minecraft.ChatFormatting;
import net.minecraft.client.DeltaTracker;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.player.LocalPlayer;
Expand All @@ -56,7 +57,7 @@
import static dev.ftb.mods.ftbquests.client.TaskScreenRenderer.*;

public class FTBQuestsClientEventHandler {
private static final ResourceLocation QUESTS_BUTTON = new ResourceLocation(FTBQuestsAPI.MOD_ID, "quests");
private static final ResourceLocation QUESTS_BUTTON = FTBQuestsAPI.rl("quests");

static boolean creativeTabRebuildPending = false;

Expand Down Expand Up @@ -275,7 +276,7 @@ private void collectPinnedQuests(ClientQuestFile file) {

}

private void onScreenRender(GuiGraphics graphics, float tickDelta) {
private void onScreenRender(GuiGraphics graphics, DeltaTracker tickDelta) {
if (!ClientQuestFile.exists()) {
return;
}
Expand All @@ -289,7 +290,7 @@ private void onScreenRender(GuiGraphics graphics, float tickDelta) {
}
}

private void renderCurrentlyObserving(Minecraft mc, GuiGraphics graphics, float tickDelta) {
private void renderCurrentlyObserving(Minecraft mc, GuiGraphics graphics, DeltaTracker tickDelta) {
int cx = mc.getWindow().getGuiScaledWidth() / 2;
int cy = mc.getWindow().getGuiScaledHeight() / 2;

Expand All @@ -301,7 +302,7 @@ private void renderCurrentlyObserving(Minecraft mc, GuiGraphics graphics, float
GuiHelper.drawHollowRect(graphics, cx - boxWidth / 2 - 3, cy - 63, boxWidth + 6, 29, Color4I.DARK_GRAY, false);

graphics.drawString(mc.font, txt, cx - txtWidth / 2, cy - 60, 0xFFFFFF);
double completed = (currentlyObservingTicks + tickDelta) / (double) currentlyObserving.getTimer();
double completed = (currentlyObservingTicks + tickDelta.getGameTimeDeltaPartialTick(false)) / (double) currentlyObserving.getTimer();

GuiHelper.drawHollowRect(graphics, cx - boxWidth / 2, cy - 49, boxWidth, 12, Color4I.DARK_GRAY, false);
Color4I.LIGHT_BLUE.withAlpha(130).draw(graphics, cx - boxWidth / 2 + 1, cy - 48, (int) ((boxWidth - 2D) * completed), 10);
Expand Down
36 changes: 16 additions & 20 deletions common/src/main/java/dev/ftb/mods/ftbquests/client/RenderUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,21 @@ public RenderUtil withLighting(int packedLightIn) {

public void draw() {
Matrix4f posMat = matrixStack.last().pose();
builder.vertex(posMat, x, y + h, 0)
.color(color)
.uv(u1, v2)
.uv2(packedLightIn)
.endVertex();
builder.vertex(posMat, x + w, y + h, 0)
.color(color)
.uv(u2, v2)
.uv2(packedLightIn)
.endVertex();
builder.vertex(posMat, x + w, y, 0)
.color(color)
.uv(u2, v1)
.uv2(packedLightIn)
.endVertex();
builder.vertex(posMat, x, y, 0)
.color(color)
.uv(u1, v1)
.uv2(packedLightIn)
.endVertex();
builder.addVertex(posMat, x, y + h, 0)
.setColor(color)
.setUv(u1, v2)
.setLight(packedLightIn);
builder.addVertex(posMat, x + w, y + h, 0)
.setColor(color)
.setUv(u2, v2)
.setLight(packedLightIn);
builder.addVertex(posMat, x + w, y, 0)
.setColor(color)
.setUv(u2, v1)
.setLight(packedLightIn);
builder.addVertex(posMat, x, y, 0)
.setColor(color)
.setUv(u1, v1)
.setLight(packedLightIn);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
import org.joml.Matrix4f;

public class TaskScreenRenderer implements BlockEntityRenderer<TaskScreenBlockEntity> {
public static final ResourceLocation INPUT_ONLY_TEXTURE = new ResourceLocation(FTBQuestsAPI.MOD_ID, "tasks/input_only");
public static final ResourceLocation TANK_TEXTURE = new ResourceLocation(FTBQuestsAPI.MOD_ID, "tasks/tank");
public static final ResourceLocation FE_ENERGY_EMPTY_TEXTURE = new ResourceLocation(FTBQuestsAPI.MOD_ID, "tasks/fe_empty");
public static final ResourceLocation FE_ENERGY_FULL_TEXTURE = new ResourceLocation(FTBQuestsAPI.MOD_ID, "tasks/fe_full");
public static final ResourceLocation TR_ENERGY_EMPTY_TEXTURE = new ResourceLocation(FTBQuestsAPI.MOD_ID, "tasks/ic2_empty");
public static final ResourceLocation TR_ENERGY_FULL_TEXTURE = new ResourceLocation(FTBQuestsAPI.MOD_ID, "tasks/ic2_full");
public static final ResourceLocation INPUT_ONLY_TEXTURE = FTBQuestsAPI.rl("tasks/input_only");
public static final ResourceLocation TANK_TEXTURE = FTBQuestsAPI.rl("tasks/tank");
public static final ResourceLocation FE_ENERGY_EMPTY_TEXTURE = FTBQuestsAPI.rl("tasks/fe_empty");
public static final ResourceLocation FE_ENERGY_FULL_TEXTURE = FTBQuestsAPI.rl("tasks/fe_full");
public static final ResourceLocation TR_ENERGY_EMPTY_TEXTURE = FTBQuestsAPI.rl("tasks/ic2_empty");
public static final ResourceLocation TR_ENERGY_FULL_TEXTURE = FTBQuestsAPI.rl("tasks/ic2_full");

private final BlockEntityRendererProvider.Context context;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ public void drawOffsetBackground(GuiGraphics graphics, Theme theme, int x, int y
}

Tesselator tesselator = Tesselator.getInstance();
BufferBuilder buffer = tesselator.getBuilder();

Icon icon = ThemeProperties.DEPENDENCY_LINE_TEXTURE.get(questScreen.selectedChapter);
if (icon instanceof ImageIcon img) {
Expand All @@ -184,7 +183,7 @@ public void drawOffsetBackground(GuiGraphics graphics, Theme theme, int x, int y
double mt = -(System.currentTimeMillis() * 0.001D);
float lineWidth = (float) (questScreen.getZoom() * ThemeProperties.DEPENDENCY_LINE_THICKNESS.get(questScreen.selectedChapter) / 4D * 3D);

RenderSystem.setShader(GameRenderer::getPositionColorTexShader);
RenderSystem.setShader(GameRenderer::getPositionTexColorShader);
RenderSystem.setShaderColor(1F, 1F, 1F, 1F);

// pass 1: render connections for all visible quests
Expand All @@ -199,7 +198,7 @@ public void drawOffsetBackground(GuiGraphics graphics, Theme theme, int x, int y

for (QuestButton button : qb.getDependencies()) {
if (button.shouldDraw() && button.quest != selectedQuest && qb.quest != selectedQuest && !button.quest.shouldHideDependentLines()) {
renderConnection(widget, button, graphics.pose(), buffer, lineWidth,
renderConnection(widget, button, graphics.pose(), lineWidth,
c.redi(), c.greeni(), c.bluei(), c.alphai(), c.alphai(),
mu, tesselator);
}
Expand All @@ -225,10 +224,10 @@ public void drawOffsetBackground(GuiGraphics graphics, Theme theme, int x, int y
a2 = 30;
toOutline.add(qb);
}
renderConnection(widget, button, graphics.pose(), buffer, lineWidth, c.redi(), c.greeni(), c.bluei(), a2, a, ms, tesselator);
renderConnection(widget, button, graphics.pose(), lineWidth, c.redi(), c.greeni(), c.bluei(), a2, a, ms, tesselator);
} else if (qb.quest == selectedQuest || qb.isMouseOver()) {
Color4I c = ThemeProperties.DEPENDENCY_LINE_REQUIRES_COLOR.get(questScreen.selectedChapter);
renderConnection(widget, button, graphics.pose(), buffer, lineWidth, c.redi(), c.greeni(), c.bluei(), c.alphai(), c.alphai(), ms, tesselator);
renderConnection(widget, button, graphics.pose(), lineWidth, c.redi(), c.greeni(), c.bluei(), c.alphai(), c.alphai(), ms, tesselator);
}
}
}
Expand All @@ -245,7 +244,7 @@ public void drawOffsetBackground(GuiGraphics graphics, Theme theme, int x, int y
});
}

private void renderConnection(Widget widget, QuestButton button, PoseStack poseStack, BufferBuilder buffer, float s, int r, int g, int b, int a, int a1, float mu, Tesselator tesselator) {
private void renderConnection(Widget widget, QuestButton button, PoseStack poseStack, float s, int r, int g, int b, int a, int a1, float mu, Tesselator tesselator) {
int sx = widget.getX() + widget.width / 2;
int sy = widget.getY() + widget.height / 2;
int ex = button.getX() + button.width / 2;
Expand All @@ -257,12 +256,12 @@ private void renderConnection(Widget widget, QuestButton button, PoseStack poseS
poseStack.mulPose(Axis.ZP.rotation((float) Math.atan2(ey - sy, ex - sx)));
Matrix4f m = poseStack.last().pose();

buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR_TEX);
buffer.vertex(m, 0, -s, 0).color(r, g, b, a).uv(len / s / 2F + mu, 0).endVertex();
buffer.vertex(m, 0, s, 0).color(r, g, b, a).uv(len / s / 2F + mu, 1).endVertex();
buffer.vertex(m, len, s, 0).color(r * 3 / 4, g * 3 / 4, b * 3 / 4, a1).uv(mu, 1).endVertex();
buffer.vertex(m, len, -s, 0).color(r * 3 / 4, g * 3 / 4, b * 3 / 4, a1).uv(mu, 0).endVertex();
tesselator.end();
BufferBuilder buffer = tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR);
buffer.addVertex(m, 0, -s, 0).setColor(r, g, b, a).setUv(len / s / 2F + mu, 0);
buffer.addVertex(m, 0, s, 0).setColor(r, g, b, a).setUv(len / s / 2F + mu, 1);
buffer.addVertex(m, len, s, 0).setColor(r * 3 / 4, g * 3 / 4, b * 3 / 4, a1).setUv(mu, 1);
buffer.addVertex(m, len, -s, 0).setColor(r * 3 / 4, g * 3 / 4, b * 3 / 4, a1).setUv(mu, 0);
BufferUploader.drawWithShader(buffer.buildOrThrow());

poseStack.popPose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.*;
import net.minecraft.network.chat.contents.PlainTextContents;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
Expand All @@ -60,7 +59,7 @@
import java.util.function.BiConsumer;

public class ViewQuestPanel extends ModalPanel {
public static final Icon PAGEBREAK_ICON = Icon.getIcon(new ResourceLocation(FTBQuestsAPI.MOD_ID, "textures/gui/pagebreak.png"));
public static final Icon PAGEBREAK_ICON = Icon.getIcon(FTBQuestsAPI.rl("textures/gui/pagebreak.png"));

private final QuestScreen questScreen;
private Quest quest = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import java.util.List;

public class CustomIconItem extends Item {
private static final ResourceLocation FALLBACK_ICON = new ResourceLocation("minecraft:textures/misc/unknown_pack.png");
private static final ResourceLocation FALLBACK_ICON = ResourceLocation.withDefaultNamespace("textures/misc/unknown_pack.png");

public CustomIconItem() {
super(ModItems.defaultProps().stacksTo(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public void fillConfigGroup(ConfigGroup config) {
config.addDouble("height", height, v -> height = v, 1, 0, Double.POSITIVE_INFINITY);
config.addDouble("rotation", rotation, v -> rotation = v, 0, -180, 180);
config.add("image", new ImageResourceConfig(), ImageResourceConfig.getResourceLocation(image),
v -> setImage(Icon.getIcon(v)), new ResourceLocation("minecraft:textures/gui/presets/isles.png"));
v -> setImage(Icon.getIcon(v)), ResourceLocation.withDefaultNamespace("textures/gui/presets/isles.png"));
config.addColor("color", color, v -> color = v, Color4I.WHITE);
config.addInt("order", order, v -> order = v, 0, Integer.MIN_VALUE, Integer.MAX_VALUE);
config.addInt("alpha", alpha, v -> alpha = v, 255, 0, 255);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,10 @@ public HolderLookup.Provider holderLookup() {
}

protected CompoundTag saveItemSingleLine(ItemStack stack) {
if (stack.isEmpty()) {
return new SNBTCompoundTag();
}

return Util.make(SNBTCompoundTag.of(stack.save(holderLookup())), SNBTCompoundTag::singleLine);
}
}
Loading

0 comments on commit ae7696d

Please sign in to comment.