Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
33 changes: 33 additions & 0 deletions build-logic/src/main/kotlin/ModPlatformPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,39 @@ abstract class ModPlatformPlugin @Inject constructor() : Plugin<Project> {
string(eval(current.version, ">=26.1"), "!renaming_26") {
replace("renderContextualInfoBar", "extractContextualInfoBar")
}
string(eval(current.version, ">=26.3"), "!renaming_26_3") {
replace("com.mojang.blaze3d.PrimitiveTopology", "com.mojang.renderpearl.api.pipeline.PrimitiveTopology")
}
string(eval(current.version, ">=26.3"), "!renaming_26_3") {
replace("com.mojang.blaze3d.pipeline.", "com.mojang.renderpearl.api.pipeline.")
}
string(eval(current.version, ">=26.3"), "!renaming_26_3") {
replace("com/mojang/blaze3d/pipeline/", "com/mojang/renderpearl/api/pipeline/")
}
string(eval(current.version, ">=26.3"), "!renaming_26_3") {
replace("com.mojang.blaze3d.buffers.", "com.mojang.renderpearl.api.buffers.")
}
string(eval(current.version, ">=26.3"), "!renaming_26_3") {
replace("com.mojang.blaze3d.systems.RenderPass", "com.mojang.renderpearl.api.commands.RenderPass")
}
string(eval(current.version, ">=26.3"), "!renaming_26_3") {
replace("com.mojang.blaze3d.platform.CompareOp", "com.mojang.renderpearl.api.pipeline.CompareOp")
}
string(eval(current.version, ">=26.3"), "!renaming_26_3") {
replace("com.mojang.blaze3d.platform.CompareOp", "com.mojang.renderpearl.api.pipeline.CompareOp")
}
string(eval(current.version, ">=26.3"), "!renaming_26_3") {
replace("com.mojang.blaze3d.pipeline.RenderTarget", "com.mojang.blaze3d.pipeline.RenderTarget")
}
string(eval(current.version, ">=26.3"), "!renaming_26_3") {
replace("com.mojang.blaze3d.vertex.VertexFormat", "com.mojang.renderpearl.api.vertex.VertexFormat")
}
string(eval(current.version, ">=26.3"), "!renaming_26_3") {
replace("com.mojang.blaze3d.textures.GpuSampler", "com.mojang.renderpearl.api.textures.GpuSampler")
}
string(eval(current.version, ">=26.3"), "!renaming_26_3") {
replace("com.mojang.blaze3d.textures.GpuTextureView", "com.mojang.renderpearl.api.textures.GpuTextureView")
}
}
}
}
Expand Down
10 changes: 7 additions & 3 deletions build.fabricmc.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ plugins {
id("net.fabricmc.fabric-loom")
}

val projectVersion = stonecutter.current.version
val semver = if (stonecutter.current.version == "26.3") "26.3-alpha.3" else stonecutter.current.version
val realver = if (stonecutter.current.version == "26.3") "26.3-snapshot-3" else stonecutter.current.version

platform {
loader = "fabric"
dependencies {
required("minecraft") {
versionRange = stonecutter.current.version
versionRange = semver
}
required("fabric-api") {
slug("fabric-api")
Expand Down Expand Up @@ -47,7 +51,7 @@ loom {

fabricApi {
configureDataGeneration {
outputDirectory = file("${rootDir}/versions/datagen/${stonecutter.current.version.split("-")[0]}/src/main/generated")
outputDirectory = file("${rootDir}/versions/datagen/${projectVersion.split("-")[0]}/src/main/generated")
client = true
}
}
Expand All @@ -59,7 +63,7 @@ repositories {
}

dependencies {
minecraft("com.mojang:minecraft:${stonecutter.current.version}")
minecraft("com.mojang:minecraft:${realver}")
implementation(libs.fabric.loader)
implementation("net.fabricmc.fabric-api:fabric-api:${prop("fabric_api_version")}")
implementation("com.terraformersmc:modmenu:${prop("modmenu_version")}")
Expand Down
2 changes: 2 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ stonecutter {
match("1.21.10", "fabric", "forge", "neoforge")
match("1.21.11", "fabric", "forge", "neoforge")
match("26.1.2", "fabric", "forge", "neoforge")
match("26.2", "fabric")
match("26.3", "fabric")
vcsVersion = "1.20.4-fabric"
}
}
Expand Down
29 changes: 23 additions & 6 deletions src/main/java/wily/factoryapi/FactoryAPIClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
import com.mojang.serialization.JsonOps;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
//? if >=26.1 {
/*import net.minecraft.client.color.block.BlockColors;
import net.minecraft.client.color.block.BlockTintSource;
//? if >=26.2 {
/^import net.minecraft.client.gui.Hud;
^///?}
import net.minecraft.client.renderer.block.dispatch.BlockStateModel;
*///?} else if >1.21.4 {
/*import net.minecraft.client.renderer.block.model.BlockStateModel;
Expand Down Expand Up @@ -108,7 +112,6 @@
*///?}
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.model.loading.v1.ModelLoadingPlugin;
import net.fabricmc.fabric.api.transfer.v1.client.fluid.FluidVariantRendering;
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
import net.fabricmc.fabric.api.client.rendering.v1.*;
Expand Down Expand Up @@ -224,7 +227,7 @@ public static ProfilerFiller getProfiler() {
}

public static /*? if <1.21.2 {*/ToastComponent/*?} else {*//*ToastManager*//*?}*/getToasts() {
return Minecraft.getInstance()./*? if <1.21.2 {*/getToasts/*?} else {*//*getToastManager*//*?}*/();
return Minecraft.getInstance()./*? if <1.21.2 {*/getToasts/*?} else if <26.2 {*//*getToastManager*//*?} else {*//*gui.toastManager*//*?}*/();
}

public static float getPartialTick() {
Expand All @@ -249,8 +252,12 @@ public static long getWindow() {
return Minecraft.getInstance().getWindow()./*? if >=1.21.9 {*//*handle()*//*?} else {*/getWindow()/*?}*/;
}

public static void setScreen(Screen screen) {
Minecraft.getInstance()/*? if >=26.2 {*//*.gui*//*?}*/.setScreen(screen);
}

public static Screen getScreen() {
return Minecraft.getInstance().screen;
return Minecraft.getInstance()/*? if <26.2 {*/.screen/*?} else {*//*.gui.screen()*//*?}*/;
}

public static void init() {
Expand All @@ -261,7 +268,7 @@ public static void init() {
FactoryOptions.CLIENT_STORAGE.load();
});
preTick(m-> SECURE_EXECUTOR.executeAll());
FactoryGuiElement.HOTBAR.post().register(graphics -> UIAccessor.of(Minecraft.getInstance().gui).getChildrenRenderables().forEach(r -> {
FactoryGuiElement.HOTBAR.post().register(graphics -> UIAccessor.of(getGuiOrHud(Minecraft.getInstance())).getChildrenRenderables().forEach(r -> {
//? if >=26.1 {
/*r.extractRenderState(graphics, 0, 0, getPartialTick());
*///?} else {
Expand Down Expand Up @@ -290,7 +297,7 @@ public static void init() {
});
//? if fabric {
//? if >=1.21.9 {
/*IFactoryItemClientExtension.map.forEach((i,c)-> ArmorRenderer.register((matrices, vertexConsumers, stack, entity, slot, light, contextModel)-> vertexConsumers.submitModel(c.getHumanoidArmorModel(entity,stack,slot,contextModel), entity, matrices, /^?if <1.21.11 {^/RenderType/^?} else {^//^RenderTypes^//^?}^/.entityCutout(((IFactoryItem) i).getArmorLocation(stack, slot)), light, OverlayTexture.NO_OVERLAY, 0xFFFFFF, null), i));
/*IFactoryItemClientExtension.map.forEach((i,c)-> ArmorRenderer.register((matrices, vertexConsumers, stack, entity, slot, light, contextModel)-> vertexConsumers.submitModel(c.getHumanoidArmorModel(entity,stack,slot,contextModel), entity, matrices, /^?if <1.21.11 {^/RenderType/^?} else {^//^RenderTypes^//^?}^/.entityCutout(((IFactoryItem) i).getArmorLocation(stack, slot)), light, OverlayTexture.NO_OVERLAY, 0xFFFFFF/^? if <26.3 {^/, null/^?}^/), i));
*///?} else {
IFactoryItemClientExtension.map.forEach((i,c)-> ArmorRenderer.register((matrices, vertexConsumers, stack, entity, slot, light, contextModel)-> c.getHumanoidArmorModel(entity,stack,slot,contextModel).renderToBuffer(matrices,vertexConsumers.getBuffer(RenderType.entityCutout(((IFactoryItem) i).getArmorLocation(stack,/*? if <1.21.2 {*/ entity, /*?}*/slot))), light, OverlayTexture.NO_OVERLAY/*? if <=1.20.6 {*/, 1.0F,1.0F,1.0F, 1.0F/*?}*/),i));
//?}
Expand Down Expand Up @@ -342,7 +349,7 @@ public static <T extends CommonNetwork.Payload> void registerPayload(CommonNetwo
public static <T extends AbstractContainerMenu> void handleExtraMenu(SecureExecutor executor, Player player, MenuType<T> menuType, OpenExtraMenuPayload payload) {
var menu = ((MenuTypeAccessor)menuType).getConstructor() instanceof FactoryExtraMenuSupplier<?> supplier ? (T) supplier.create(payload.menuId(), player.getInventory(), payload.extra()) : menuType.create(payload.menuId(), player.getInventory());
player.containerMenu = menu;
executor.execute(()-> Minecraft.getInstance().setScreen(MenuScreensAccessor.getConstructor(menuType).create(menu, player.getInventory(), payload.component())));
executor.execute(()-> setScreen(MenuScreensAccessor.getConstructor(menuType).create(menu, player.getInventory(), payload.component())));
}

public static void setup(Consumer<Minecraft> listener) {
Expand Down Expand Up @@ -514,6 +521,16 @@ public static void registerBlockColor(Consumer<BiConsumer</*? if >=26.1 {*//*Lis
/*throw new AssertionError();*/
}

//? if <26.2 {
public static Gui getGuiOrHud(Minecraft minecraft) {
return minecraft.gui;
}
//?} else {
/*public static Hud getGuiOrHud(Minecraft minecraft) {
return minecraft.gui.hud;
}
*///?}

//? if <1.21.4 {
public static void registerItemColor(Consumer<BiConsumer<ItemColor, Item>> registry) {
//? if fabric {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntityType;
//? if >=26.2 {
/*import net.minecraft.world.level.block.entity.BlockEntityTypes;
*///?}
import org.jetbrains.annotations.NotNull;
import wily.factoryapi.FactoryAPI;
import wily.factoryapi.ItemContainerPlatform;
Expand Down Expand Up @@ -76,7 +79,7 @@ public void setFluid(FluidInstance fluid) {
beTag.put(getStorageKey(), tag);
//? if >=1.21.9 {
/^//TODO Check if this will cause problems when placing the block
container.set(DataComponents.BLOCK_ENTITY_DATA, TypedEntityData.of(BlockEntityType.CHEST, beTag));
container.set(DataComponents.BLOCK_ENTITY_DATA, TypedEntityData.of(/^¹? if <26.2 {¹^/BlockEntityType/^¹?} else {¹^//^¹BlockEntityTypes¹^//^¹?}¹^/.CHEST, beTag));
^///?} else {
container.set(DataComponents.BLOCK_ENTITY_DATA, CustomData.of(beTag));
//?}
Expand Down Expand Up @@ -199,7 +202,7 @@ public void setCapacity(int capacity) {
beTag.put(getStorageKey(),tag);
//? if >=1.21.9 {
/^//TODO Check if this will cause problems when placing the block
container.set(DataComponents.BLOCK_ENTITY_DATA, TypedEntityData.of(BlockEntityType.CHEST, beTag));
container.set(DataComponents.BLOCK_ENTITY_DATA, TypedEntityData.of(/^¹? if <26.2 {¹^/BlockEntityType/^¹?} else {¹^//^¹BlockEntityTypes¹^//^¹?}¹^/.CHEST, beTag));
^///?} else {
container.set(DataComponents.BLOCK_ENTITY_DATA, CustomData.of(beTag));
//?}
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/wily/factoryapi/base/SlotsIdentifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
//? if >=26.2 {
/*import net.minecraft.network.chat.TextColor;
*///?}

import java.awt.*;

Expand All @@ -17,7 +20,13 @@ public record SlotsIdentifier(ChatFormatting color, String name,Component compon
public static final SlotsIdentifier GENERIC = new SlotsIdentifier(ChatFormatting.GRAY,"single");

public Color getColor(){
return new Color(color.getColor());
return new Color(
//? if <26.2 {
color.getColor()
//?} else {
/*switch(TextColor.fromLegacyFormat(color)) { case TextColor color when Boolean.TRUE == true /^it's java 25 why doesn't this work without this hack^/ -> color.getValue(); case null, default -> 0;}
*///?}
);
}

public SlotsIdentifier(ChatFormatting color, String name){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
*///?}

import net.minecraft.client.renderer.GameRenderer;
//? if <26.2 {
import net.minecraft.client.renderer.MultiBufferSource;
//?}
import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -26,9 +28,11 @@
public interface FactoryGuiGraphics {
net.minecraft.client.gui.GuiGraphics context();

//? if <26.2 {
MultiBufferSource.BufferSource getBufferSource();
void pushBufferSource(MultiBufferSource.BufferSource bufferSource);
void popBufferSource();
//?}

FactoryGuiMatrixStack pose();

Expand Down
7 changes: 6 additions & 1 deletion src/main/java/wily/factoryapi/base/client/GuiAccessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
//? if >=26.2 {
/*import net.minecraft.client.gui.Hud;
*///?}
import net.minecraft.client.gui.components.spectator.SpectatorGui;
import net.minecraft.world.item.ItemStack;
import wily.factoryapi.FactoryAPIClient;

public interface GuiAccessor {
ItemStack getLastToolHighlight();
Expand All @@ -12,11 +16,12 @@ public interface GuiAccessor {

SpectatorGui getSpectatorGui();

//~ if >=26.2 'Gui gui' -> 'Hud gui'
static GuiAccessor of(Gui gui){
return (GuiAccessor) gui;
}

static GuiAccessor getInstance(){
return of(Minecraft.getInstance().gui);
return of(FactoryAPIClient.getGuiOrHud(Minecraft.getInstance()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.serialization.MapCodec;
import net.minecraft.client.model.geom.EntityModelSet;
//? if <26.2 {
import net.minecraft.client.renderer.MultiBufferSource;
//?}
//? if >=1.21.4 {
/*import net.minecraft.client.renderer.special.SpecialModelRenderer;
*///?}
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/wily/factoryapi/base/client/UIAccessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
//? if >=26.2 {
/*import net.minecraft.client.gui.Hud;
*///?}
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.components.Renderable;
import net.minecraft.client.gui.components.Tooltip;
Expand Down Expand Up @@ -40,9 +43,15 @@ static UIAccessor of(Screen screen) {
return (UIAccessor) screen;
}

//? if <26.2 {
static UIAccessor of(Gui gui) {
return (UIAccessor) gui;
}
//?} else {
/*static UIAccessor of(Hud hud) {
return (UIAccessor) hud;
}
*///?}

@Nullable
Screen getScreen();
Expand Down
Loading
Loading