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
34 changes: 34 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,40 @@ dependencies {
}

}


stonecutter {
replacements {
string(stonecutter.eval(stonecutter.current.version, ">=1.21.11")) {
replace("ResourceLocation", "Identifier")
}
string(stonecutter.eval(stonecutter.current.version, ">=1.21.11")) {
replace("CommonNetwork.Identifier", "CommonNetwork.Identifier")
}
string(stonecutter.eval(stonecutter.current.version, ">=1.21.11")) {
replace("Progress.Identifier", "Progress.Identifier")
}
string(stonecutter.eval(stonecutter.current.version, ">=1.21.11")) {
replace("withSlotIdentifier", "withSlotIdentifier")
}
string(stonecutter.eval(stonecutter.current.version, ">=1.21.11")) {
replace("record Identifier", "record Identifier")
}
string(stonecutter.eval(stonecutter.current.version, ">=1.21.11")) {
replace("SlotsIdentifier", "SlotsIdentifier")
}
string(stonecutter.eval(stonecutter.current.version, ">=1.21.11")) {
replace("IHasIdentifier", "IHasIdentifier")
}
string(stonecutter.eval(stonecutter.current.version, ">=1.21.11")) {
replace("Identifier<T extends Payload>", "Identifier<T extends Payload>")
}
string(stonecutter.eval(stonecutter.current.version, ">=1.21.11")) {
replace("import net.minecraft.Util;", "import net.minecraft.util.Util;")
}
}
}

def aw = "${mod_id}-${stonecutter.eval(stonecutter.current.version, ">=1.21.2") ? 1212 : 120}.accesswidener"

loom {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
49 changes: 25 additions & 24 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,35 @@ pluginManagement {
}

plugins {
id("dev.kikugie.stonecutter") version "0.7.6"
id("dev.kikugie.stonecutter") version "0.8.1"
}

stonecutter {
create(rootProject) {
vers("1.20.1-fabric", "1.20.1")
vers("1.20.1-forge", "1.20.1")
vers("1.20.4-fabric", "1.20.4")
vers("1.20.4-forge", "1.20.4")
vers("1.20.4-neoforge", "1.20.4")
vers("1.21.1-fabric", "1.21.1")
vers("1.21.1-forge", "1.21.1")
vers("1.21.1-neoforge", "1.21.1")
vers("1.21.3-fabric", "1.21.3")
vers("1.21.3-forge", "1.21.3")
vers("1.21.3-neoforge", "1.21.3")
vers("1.21.4-fabric", "1.21.4")
vers("1.21.4-forge", "1.21.4")
vers("1.21.4-neoforge", "1.21.4")
vers("1.21.5-fabric", "1.21.5")
vers("1.21.5-forge", "1.21.5")
vers("1.21.5-neoforge", "1.21.5")
vers("1.21.8-fabric", "1.21.8")
vers("1.21.8-forge", "1.21.8")
vers("1.21.8-neoforge", "1.21.8")
vers("1.21.10-fabric", "1.21.10")
vers("1.21.10-forge", "1.21.10")
vers("1.21.10-neoforge", "1.21.10")
version("1.20.1-fabric", "1.20.1")
version("1.20.1-forge", "1.20.1")
version("1.20.4-fabric", "1.20.4")
version("1.20.4-forge", "1.20.4")
version("1.20.4-neoforge", "1.20.4")
version("1.21.1-fabric", "1.21.1")
version("1.21.1-forge", "1.21.1")
version("1.21.1-neoforge", "1.21.1")
version("1.21.3-fabric", "1.21.3")
version("1.21.3-forge", "1.21.3")
version("1.21.3-neoforge", "1.21.3")
version("1.21.4-fabric", "1.21.4")
version("1.21.4-forge", "1.21.4")
version("1.21.4-neoforge", "1.21.4")
version("1.21.5-fabric", "1.21.5")
version("1.21.5-forge", "1.21.5")
version("1.21.5-neoforge", "1.21.5")
version("1.21.8-fabric", "1.21.8")
version("1.21.8-forge", "1.21.8")
version("1.21.8-neoforge", "1.21.8")
version("1.21.10-fabric", "1.21.10")
version("1.21.10-forge", "1.21.10")
version("1.21.10-neoforge", "1.21.10")
version("1.21.11-fabric", "1.21.11")
vcsVersion = "1.20.4-fabric"
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/wily/factoryapi/FactoryAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public static ResourceLocation createVanillaLocation(String path){
//? if <1.20.5 {
return new ResourceLocation(path);
//?} else
/*return ResourceLocation.withDefaultNamespace(path);*/
//return ResourceLocation.withDefaultNamespace(path);
}

public static Loader getLoader() {
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/wily/factoryapi/FactoryAPIClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@
import net.minecraft.client.model.geom.builders.LayerDefinition;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.ItemBlockRenderTypes;
//? if <1.21.11 {
import net.minecraft.client.renderer.RenderType;
//?} else {
/*import net.minecraft.client.renderer.rendertype.RenderTypes;
*///?}
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.LivingEntityRenderer;
Expand Down Expand Up @@ -261,7 +265,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, RenderType.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, 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
11 changes: 6 additions & 5 deletions src/main/java/wily/factoryapi/FactoryAPIPlatform.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@
import net.fabricmc.fabric.api.transfer.v1.storage.Storage;
import net.fabricmc.fabric.api.transfer.v1.storage.base.SingleSlotStorage;
import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext;
//? if <1.21.11 {
import net.fabricmc.fabric.mixin.command.ArgumentTypesAccessor;
//?} else {
/*import net.fabricmc.fabric.mixin.command.ArgumentTypeInfosAccessor;
*///?}
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.ModContainer;
import net.fabricmc.loader.api.metadata.Person;
Expand All @@ -75,9 +79,6 @@
import wily.factoryapi.base.fabric.FabricEnergyStoragePlatform;
import wily.factoryapi.base.fabric.FabricFluidStoragePlatform;
import wily.factoryapi.base.fabric.FabricItemStoragePlatform;
//? if >=1.20.4 {
import net.fabricmc.fabric.impl.resource.loader.FabricResourcePackProfile;
//?}
//?} elif neoforge {
/*import net.neoforged.fml.ModList;
import net.neoforged.neoforge.common.NeoForge;
Expand Down Expand Up @@ -436,7 +437,7 @@ static boolean isClient() {

static <A extends ArgumentType<?>, T extends ArgumentTypeInfo.Template<A>, I extends ArgumentTypeInfo<A, T>> void registerByClassArgumentType(Class<A> infoClass, I argumentTypeInfo) {
//? if fabric {
ArgumentTypesAccessor.fabric_getClassMap().put(infoClass,argumentTypeInfo);
/*? if <1.21.11 {*/ArgumentTypesAccessor/*?} else {*//*ArgumentTypeInfosAccessor*//*?}*/.fabric_getClassMap().put(infoClass,argumentTypeInfo);
//?} else if forge || neoforge {
/*ArgumentTypeInfos.registerByClass(infoClass,argumentTypeInfo);
*///?} else
Expand Down Expand Up @@ -712,6 +713,6 @@ public String getName() {
}

static boolean isPackHidden(Pack pack) {
return /*? if fabric && >=1.20.4 {*/ ((FabricResourcePackProfile)pack).fabric_isHidden() /*?} else {*/ /*false*//*?}*/;
return /*? if fabric && >=1.20.4 && <1.21.11 {*/ ((net.fabricmc.fabric.impl.resource.loader.FabricResourcePackProfile)pack).fabric_isHidden() /*?} else {*/ /*false*//*?}*/;
}
}
4 changes: 2 additions & 2 deletions src/main/java/wily/factoryapi/base/FactoryCapacityTier.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
//? if >=1.20.5
/*import net.minecraft.network.codec.StreamCodec;*/
//import net.minecraft.network.codec.StreamCodec;
import net.minecraft.util.StringRepresentable;
import wily.factoryapi.FactoryAPI;

Expand All @@ -21,7 +21,7 @@ public enum FactoryCapacityTier implements StringRepresentable {

public static final Codec<FactoryCapacityTier> CODEC = StringRepresentable.fromEnum(FactoryCapacityTier::values);
//? if >=1.20.5
/*public static final StreamCodec<FriendlyByteBuf,FactoryCapacityTier> STREAM_CODEC = StreamCodec.of(FriendlyByteBuf::writeEnum, b->b.readEnum(FactoryCapacityTier.class));*/
//public static final StreamCodec<FriendlyByteBuf,FactoryCapacityTier> STREAM_CODEC = StreamCodec.of(FriendlyByteBuf::writeEnum, b->b.readEnum(FactoryCapacityTier.class));

public final ChatFormatting formatting;
private final double conductivity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void setEnergyStored(int energy) {
//? if <1.20.5 {
container.getOrCreateTag().putInt(KEY,energy);
//?} else
/*container.set(FactoryRegistries.ENERGY_COMPONENT.get(),energy);*/
//container.set(FactoryRegistries.ENERGY_COMPONENT.get(),energy);
}
//? if <1.20.5 {
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//? if >=1.21.11 {
/*package wily.factoryapi.base;

import net.minecraft.client.gui.GuiGraphics;

public interface FactoryRenderingTextCollector {
GuiGraphics getGuiGraphics();
}
*///?}
4 changes: 2 additions & 2 deletions src/main/java/wily/factoryapi/base/IFactoryItem.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package wily.factoryapi.base;

//? if >=1.21.2
/*import net.minecraft.core.component.DataComponents;*/
//import net.minecraft.core.component.DataComponents;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity;
Expand All @@ -25,7 +25,7 @@ default <T extends IPlatformHandler> ArbitrarySupplier<T> getStorage(FactoryStor
//?}

default @Nullable ResourceLocation getArmorLocation(ItemStack stack, /*? if <1.21.2 {*/Entity entity, /*?}*/ EquipmentSlot slot) {
return /*? if <1.21.2 {*/null /*?} else if <1.21.4 {*/ /*stack.get(DataComponents.EQUIPPABLE).model().orElse(null)*//*?} else {*//*stack.get(DataComponents.EQUIPPABLE).assetId().map(ResourceKey::location).orElse(null)*//*?}*/;
return /*? if <1.21.2 {*/null /*?} else if <1.21.4 {*/ /*stack.get(DataComponents.EQUIPPABLE).model().orElse(null)*//*?} else {*//*stack.get(DataComponents.EQUIPPABLE).assetId().map(ResourceKey::/^? if <1.21.11 {^/location/^?} else {^//^identifier^//^?}^/).orElse(null)*//*?}*/;
}

default void clientExtension(Consumer<IFactoryItemClientExtension> clientExtensionConsumer){
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/wily/factoryapi/base/Progress.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@

public class Progress implements ITagSerializable<CompoundTag> {

public Identifier identifier;
public Progress.Identifier identifier;
private final List<ProgressEntry> entries;

public Progress(Identifier identifier, List<ProgressEntry> entries){
public Progress(Progress.Identifier identifier, List<ProgressEntry> entries){
this.identifier = identifier;
this.entries = entries;
}
public Progress(Identifier identifier) {
public Progress(Progress.Identifier identifier) {
this(identifier, new ArrayList<>());
}
public Progress(Identifier identifier, int x, int y, int initialMaxProgress){
public Progress(Progress.Identifier identifier, int x, int y, int initialMaxProgress){
this(identifier, List.of(new ProgressEntry(x,y,initialMaxProgress)));
}
public Progress(Identifier identifier, int entries, int defaultMaxProgress){
public Progress(Progress.Identifier identifier, int entries, int defaultMaxProgress){
this(identifier);
for (int i = 0; i < entries; i++)
add(0,0,defaultMaxProgress);
Expand Down Expand Up @@ -109,12 +109,12 @@ public int shrink(int value){
}
}
public record Identifier(String name) {
public static Identifier DEFAULT = new Identifier("progress");
public static Identifier ENERGY_STORAGE = new Identifier("energyStorage");
public static Identifier TANK = new Identifier("tank");
public static Identifier BURN_TIME = new Identifier("burnTime");
public static Identifier GENERATING = new Identifier("gen");
public static Identifier MATTER = new Identifier("matter");
public static Progress.Identifier DEFAULT = new Progress.Identifier("progress");
public static Progress.Identifier ENERGY_STORAGE = new Progress.Identifier("energyStorage");
public static Progress.Identifier TANK = new Progress.Identifier("tank");
public static Progress.Identifier BURN_TIME = new Progress.Identifier("burnTime");
public static Progress.Identifier GENERATING = new Progress.Identifier("gen");
public static Progress.Identifier MATTER = new Progress.Identifier("matter");

}
}
4 changes: 2 additions & 2 deletions src/main/java/wily/factoryapi/base/StackIngredient.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,12 @@ public void encode(CommonNetwork.PlayBuf buf) {
buf.get().writeBoolean(isStrict());
buf.get().writeByte(getCount());
//?} else
/*STREAM_CODEC.encode(buf.get(),this);*/
//STREAM_CODEC.encode(buf.get(),this);
}
public static StackIngredient decode(CommonNetwork.PlayBuf buf){
//? if <1.20.5 {
return new StackIngredient(HolderSet.direct((List<Holder<Item>>) buf.get().readCollection(ArrayList::new,(b)->b.readById(BuiltInRegistries.ITEM.asHolderIdMap()))), buf.get().readNbt(), buf.get().readBoolean(), buf.get().readByte());
//?} else
/*return STREAM_CODEC.decode(buf.get());*/
//return STREAM_CODEC.decode(buf.get());
}
}
12 changes: 12 additions & 0 deletions src/main/java/wily/factoryapi/base/client/AdvancedTextWidget.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package wily.factoryapi.base.client;

import net.minecraft.client.Minecraft;
//? if >=1.21.11 {
/*import net.minecraft.client.gui.ActiveTextCollector;
import net.minecraft.network.chat.Style;
import wily.factoryapi.mixin.base.ScreenAccessor;
*///?}
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.font.glyphs.BakedGlyph;
Expand Down Expand Up @@ -155,7 +160,14 @@ public boolean handleComponentsClicked(double d, double e, int i) {
for (int i1 = 0; i1 < lines.size(); i1++) {
int lineHeight = heightPerLine[i1];
if (e >= actualHeight && e < actualHeight + lineHeight){
//? if >=1.21.11 {
/*ActiveTextCollector.ClickableStyleFinder clickableStyleFinder = new ActiveTextCollector.ClickableStyleFinder(Minecraft.getInstance().font, (int) d, (int) e);
clickableStyleFinder.accept(0, Mth.floor(d - getX()), lines.get(i1)); // TODO WHAT WHAT WHAT WHAT WHAT
Style style = clickableStyleFinder.result();
if (style != null) ScreenAccessor.callDefaultHandleGameClickEvent(style.getClickEvent(), Minecraft.getInstance(), accessor.getScreen());
*///?} else {
accessor.getScreen().handleComponentClicked(Minecraft.getInstance().font.getSplitter().componentStyleAtWidth(lines.get(i1), Mth.floor(d - getX())));
//?}
return true;
}
actualHeight += lineHeight;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public static <T> AbstractWidget createWidget(FactoryConfig<T> config, int x, in
AbstractWidget override = getOverride(config, tooltipFunction, x, y, width, afterSet);
if (override != null) return override;
if (config.control().equals(FactoryConfigControl.TOGGLE)) {
return CycleButton.<Boolean>builder(b -> display.valueToComponent().apply((T) b)).withValues(OptionInstance.BOOLEAN_VALUES.valueListSupplier()).withTooltip(((Function<Boolean, Tooltip>) tooltipFunction)::apply).withInitialValue((Boolean) config.get()).create(x, y, width, 20, display.name(), (cycleButton, object) -> FactoryConfig.saveOptionAndConsume(config, (T)object, afterSet));
return CycleButton.<Boolean>builder(b -> display.valueToComponent().apply((T) b)/*? if >=1.21.11 {*//*, () -> (Boolean) config.get()*//*?}*/).withValues(OptionInstance.BOOLEAN_VALUES.valueListSupplier()).withTooltip(((Function<Boolean, Tooltip>) tooltipFunction)::apply)/*? if <1.21.11 {*/.withInitialValue((Boolean) config.get())/*?}*/.create(x, y, width, 20, display.name(), (cycleButton, object) -> FactoryConfig.saveOptionAndConsume(config, (T)object, afterSet));
} else if (config.control() instanceof FactoryConfigControl.FromInt<T> c) {
return CycleButton.builder(display.valueToComponent()).withValues(listSupplier(c.valueGetter(), c.valuesSize())).withTooltip(tooltipFunction::apply).withInitialValue(config.get()).create(x, y, width, 20, display.name(), (cycleButton, object) -> FactoryConfig.saveOptionAndConsume(config, object,afterSet));
return CycleButton.builder(display.valueToComponent()/*? if >=1.21.11 {*//*, config*//*?}*/).withValues(listSupplier(c.valueGetter(), c.valuesSize())).withTooltip(tooltipFunction::apply)/*? if <1.21.11 {*/.withInitialValue(config.get())/*?}*/.create(x, y, width, 20, display.name(), (cycleButton, object) -> FactoryConfig.saveOptionAndConsume(config, object,afterSet));
} else if (config.control() instanceof FactoryConfigControl.FromDouble<T> c) {
return createSlider(config, x, y, width, afterSet, c.valueGetter(), c.valueSetter(), tooltipFunction);
} else if (config.control() instanceof FactoryConfigControl.Int c) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/wily/factoryapi/base/client/UIAccessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ default Renderable createModifiableRenderable(String name, Renderable renderable
FactoryScreenUtil.enableBlend();
FactoryGuiGraphics.of(guiGraphics).setColor(color);
//?} else
/*FactoryGuiGraphics.of(guiGraphics).setBlitColor(color);*/
//FactoryGuiGraphics.of(guiGraphics).setBlitColor(color);
FactoryGuiMatrixStack.of(guiGraphics.pose()).translate(getDouble(name + ".translateX", 0), getDouble(name + ".translateY", 0), getDouble(name + ".translateZ", 0));
FactoryGuiMatrixStack.of(guiGraphics.pose()).scale(getFloat(name + ".scaleX", 1), getFloat(name + ".scaleY", 1), getFloat(name + ".scaleZ", 1));
renderable.render(guiGraphics, i, j, f);
Expand All @@ -228,7 +228,7 @@ default Renderable createModifiableRenderable(String name, Renderable renderable
//? if <1.21.6 {
FactoryGuiGraphics.of(guiGraphics).clearColor();
//?} else
/*FactoryGuiGraphics.of(guiGraphics).clearBlitColor();*/
//FactoryGuiGraphics.of(guiGraphics).clearBlitColor();

}
};
Expand Down
Loading