Skip to content
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
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
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
org.gradle.jvmargs=-Xmx4096M

archives_base_name=FactoryAPI
mod_version=2.2.9
mod_version=2.2.10
mod_id=factory_api
mod_name=Factory API
mod_description=An API that is the basis for mods like Legacy4J, Factocrafty and Better Furnaces Reforged, that work on different mod loaders.
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ stonecutter-postprocess = "2.1-beta.8"
mod-publish = "2.2.0"
dotenv-gradle = "4.0.0"
fabric-loom = "1.15-SNAPSHOT"
neoforge-moddev = "2.0.141"
neoforge-moddev = "2.0.147"
forge-gradle = "[7.0.29,8)"
foojay = "1.0.0"
fabric-loader = "0.18.6"
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ stonecutter {
match("1.21.10", "fabric", "forge", "neoforge")
match("1.21.11", "fabric", "forge", "neoforge")
match("26.1.2", "fabric", "forge", "neoforge")
match("26.3", "fabric", "forge", "neoforge")
vcsVersion = "1.20.4-fabric"
}
}
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/wily/factoryapi/FactoryAPIClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,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 +223,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,9 +248,12 @@ public static long getWindow() {
return Minecraft.getInstance().getWindow()./*? if >=1.21.9 {*//*handle()*//*?} else {*/getWindow()/*?}*/;
}

//? if <26.2 {
@Deprecated(since = "2.2.10", forRemoval = true)
public static Screen getScreen() {
return Minecraft.getInstance().screen;
}
//?}

public static void init() {
registerConfigScreen(FactoryAPIPlatform.getModInfo(FactoryAPI.MOD_ID), FactoryConfigScreen::createFactoryAPIConfigScreen);
Expand All @@ -261,7 +263,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(FactoryScreenUtil.getGuiOrHud(Minecraft.getInstance())).getChildrenRenderables().forEach(r -> {
//? if >=26.1 {
/*r.extractRenderState(graphics, 0, 0, getPartialTick());
*///?} else {
Expand Down Expand Up @@ -290,7 +292,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 +344,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(()-> FactoryScreenUtil.setScreen(MenuScreensAccessor.getConstructor(menuType).create(menu, player.getInventory(), payload.component())));
}

public static void setup(Consumer<Minecraft> listener) {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/wily/factoryapi/FactoryEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,10 @@ public <T extends CommonNetwork.Payload> void register(boolean c2s, CommonNetwor
/^GatherComponentsEvent.BUS.addListener(e-> {
if (e.getOwner() == item) e.register(type,value);
});
^///?} elif neoforge && <26.2 {
/^FactoryAPIPlatform.getModEventBus().addListener(ModifyDefaultComponentsEvent.class, e-> e.modify(item, bc -> bc.set(type,value)));
^///?} elif neoforge {
/^FactoryAPIPlatform.getModEventBus().addListener(ModifyDefaultComponentsEvent.class, e-> e.modify(item, bc-> bc.set(type,value)));
/^FactoryAPIPlatform.getModEventBus().addListener(ModifyDefaultComponentsEvent.class, e-> e.modify(item, (bc, ctx, item1) -> bc.set(type,value)));
^///?}
}
*///?}
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
2 changes: 2 additions & 0 deletions src/main/java/wily/factoryapi/base/FuelManager.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//? if <26.3 {
package wily.factoryapi.base;

import net.minecraft.world.item.Item;
Expand Down Expand Up @@ -103,3 +104,4 @@ public static void add(Item item, int burnTime){
/*throw new AssertionError();*/
}
}
//?}
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 {
/*TextColor.fromLegacyFormat(color) instanceof TextColor color ? color.getValue() : 0
*///?}
);
}

public SlotsIdentifier(ChatFormatting color, String name){
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/wily/factoryapi/base/StackIngredient.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@
import net.minecraft.core.component./^? if >1.21.4 {^//^DataComponentExactPredicate^//^?} else {^/DataComponentPredicate/^?}^/;
import net.minecraft.core.component.DataComponentType;
*///?}
//? if <26.3 {
import net.minecraft.resources.HolderSetCodec;
//?} else {
/*import net.minecraft.core.registries.codec.HolderSetCodec;
*///?}
import net.minecraft.util.ExtraCodecs;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
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.util.FactoryScreenUtil;

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(FactoryScreenUtil.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
11 changes: 10 additions & 1 deletion 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 All @@ -63,7 +72,7 @@ default void beforeInit(UIAccessor accessor) {
putStaticElement("windowHeight", minecraft.getWindow().getHeight());
putStaticElement("width", minecraft.getWindow().getGuiScaledWidth());
putStaticElement("height", minecraft.getWindow().getGuiScaledHeight());
getElements().put("hasScreen", ()-> FactoryAPIClient.getScreen() != null);
getElements().put("hasScreen", ()-> FactoryScreenUtil.getScreen() != null);
if (getChildrenRenderables() != null)
getElements().put("renderablesCount", getChildrenRenderables()::size);
FactoryAPIPlatform.getMods().forEach(i -> putStaticElement("loadedMods." + i.getId(), true));
Expand Down
Loading
Loading