Skip to content

Commit 35e4e73

Browse files
committed
Beta 2.2.7.2606.1
-Added `priority` for UI Definitions, so with higher values, you're able to apply it first, and avoid conflicts (with this, `replace` will work properly) -Fixed external components (using text files for translations) and components with variables not allowing fonts and styles -Added support for Forge and NeoForge for 1.21.11
1 parent 83ae710 commit 35e4e73

49 files changed

Lines changed: 411 additions & 255 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build.gradle

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,28 +55,19 @@ dependencies {
5555
stonecutter {
5656
replacements {
5757
string(stonecutter.eval(stonecutter.current.version, ">=1.21.11")) {
58-
replace("ResourceLocation", "Identifier")
58+
replace("net.minecraft.resources.ResourceLocation", "net.minecraft.resources.Identifier")
5959
}
6060
string(stonecutter.eval(stonecutter.current.version, ">=1.21.11")) {
61-
replace("CommonNetwork.Identifier", "CommonNetwork.Identifier")
61+
replace("net/minecraft/resources/ResourceLocation", "net/minecraft/resources/Identifier")
6262
}
6363
string(stonecutter.eval(stonecutter.current.version, ">=1.21.11")) {
64-
replace("Progress.Identifier", "Progress.Identifier")
64+
replace("writeResourceLocation", "writeIdentifier")
6565
}
6666
string(stonecutter.eval(stonecutter.current.version, ">=1.21.11")) {
67-
replace("withSlotIdentifier", "withSlotIdentifier")
67+
replace("readResourceLocation", "readIdentifier")
6868
}
6969
string(stonecutter.eval(stonecutter.current.version, ">=1.21.11")) {
70-
replace("record Identifier", "record Identifier")
71-
}
72-
string(stonecutter.eval(stonecutter.current.version, ">=1.21.11")) {
73-
replace("SlotsIdentifier", "SlotsIdentifier")
74-
}
75-
string(stonecutter.eval(stonecutter.current.version, ">=1.21.11")) {
76-
replace("IHasIdentifier", "IHasIdentifier")
77-
}
78-
string(stonecutter.eval(stonecutter.current.version, ">=1.21.11")) {
79-
replace("Identifier<T extends Payload>", "Identifier<T extends Payload>")
70+
replace("ResourceLocationArgument", "IdentifierArgument")
8071
}
8172
string(stonecutter.eval(stonecutter.current.version, ">=1.21.11")) {
8273
replace("import net.minecraft.Util;", "import net.minecraft.util.Util;")

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
org.gradle.jvmargs=-Xmx3072M
22

33
archives_base_name=FactoryAPI
4-
mod_version=2.2.7
4+
mod_version=2.2.7.2606.1
55
mod_id=factory_api
66
mod_name=Factory API
77
mod_description=An API that is the basis for mods like Legacy4J, Factocrafty and Better Furnaces Reforged, that work on different mod loaders.

settings.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ stonecutter {
3939
version("1.21.10-forge", "1.21.10")
4040
version("1.21.10-neoforge", "1.21.10")
4141
version("1.21.11-fabric", "1.21.11")
42+
version("1.21.11-forge", "1.21.11")
43+
version("1.21.11-neoforge", "1.21.11")
4244
vcsVersion = "1.20.4-fabric"
4345
}
4446
}

src/main/java/wily/factoryapi/FactoryAPI.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
import java.util.stream.Collectors;
5757

5858
//? if forge || neoforge
59-
/*@Mod(FactoryAPI.MOD_ID)*/
59+
//@Mod(FactoryAPI.MOD_ID)
6060
public class FactoryAPI {
6161
public static final String MOD_ID = "factory_api";
6262

@@ -133,7 +133,7 @@ public FactoryAPI(){
133133
});
134134
*///?}
135135
//? if forge || neoforge
136-
/*if (isClient()) FactoryAPIClient.init();*/
136+
//if (isClient()) FactoryAPIClient.init();
137137
}
138138

139139
public static void init() {
@@ -181,23 +181,23 @@ public static void init() {
181181
//?}
182182
}
183183

184-
public static ResourceLocation createLocation(String namespace, String path){
185-
return ResourceLocation.tryBuild(namespace,path);
184+
public static net.minecraft.resources.ResourceLocation createLocation(String namespace, String path){
185+
return net.minecraft.resources.ResourceLocation.tryBuild(namespace,path);
186186
}
187187

188-
public static ResourceLocation createLocation(String location){
189-
return ResourceLocation.tryParse(location);
188+
public static net.minecraft.resources.ResourceLocation createLocation(String location){
189+
return net.minecraft.resources.ResourceLocation.tryParse(location);
190190
}
191191

192-
public static ResourceLocation createModLocation(String path){
192+
public static net.minecraft.resources.ResourceLocation createModLocation(String path){
193193
return createLocation(MOD_ID,path);
194194
}
195195

196-
public static ResourceLocation createVanillaLocation(String path){
196+
public static net.minecraft.resources.ResourceLocation createVanillaLocation(String path){
197197
//? if <1.20.5 {
198-
return new ResourceLocation(path);
198+
return new net.minecraft.resources.ResourceLocation(path);
199199
//?} else
200-
//return ResourceLocation.withDefaultNamespace(path);
200+
//return net.minecraft.resources.ResourceLocation.withDefaultNamespace(path);
201201
}
202202

203203
public static Loader getLoader() {

src/main/java/wily/factoryapi/FactoryAPIClient.java

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@
152152

153153

154154
public class FactoryAPIClient {
155-
public static final ResourceLocation BLOCK_ATLAS = FactoryAPI.createVanillaLocation("textures/atlas/blocks.png");
156-
public static final ResourceLocation BLOCK_ATLAS_ID = FactoryAPI.createVanillaLocation("blocks");
155+
public static final net.minecraft.resources.ResourceLocation BLOCK_ATLAS = FactoryAPI.createVanillaLocation("textures/atlas/blocks.png");
156+
public static final net.minecraft.resources.ResourceLocation BLOCK_ATLAS_ID = FactoryAPI.createVanillaLocation("blocks");
157157
public static final SecureExecutor SECURE_EXECUTOR = new SecureExecutor() {
158158
@Override
159159
public boolean isSecure() {
@@ -164,7 +164,7 @@ public boolean isSecure() {
164164

165165
public static UIDefinitionManager uiDefinitionManager;
166166

167-
public static final Map<ResourceLocation, ExtraModelId> extraModels = new HashMap<>();
167+
public static final Map<net.minecraft.resources.ResourceLocation, ExtraModelId> extraModels = new HashMap<>();
168168

169169
private static final Set<String> playerMods = new HashSet<>();
170170

@@ -183,11 +183,11 @@ public interface PlayerEvent extends Consumer<LocalPlayer>{
183183
}
184184
*///?}
185185
//? if <1.21.5 {
186-
public static BakedModel getExtraModel(ResourceLocation resourceLocation) {
186+
public static BakedModel getExtraModel(net.minecraft.resources.ResourceLocation resourceLocation) {
187187
return Minecraft.getInstance().getModelManager().getModel(extraModels.get(resourceLocation).modelId());
188188
}
189189
//?} else {
190-
/*public static BlockStateModel getExtraModel(ResourceLocation resourceLocation) {
190+
/*public static BlockStateModel getExtraModel(net.minecraft.resources.ResourceLocation resourceLocation) {
191191
return Minecraft.getInstance().getBlockRenderer().getBlockModel(extraModels.get(resourceLocation).blockState());
192192
}
193193
*///?}
@@ -254,15 +254,19 @@ public static void init() {
254254
PlayerEvent.DISCONNECTED_EVENT.register(l->{
255255
DynamicUtil.REGISTRY_OPS_CACHE.invalidateAll();
256256
DynamicUtil.DYNAMIC_ITEMS_CACHE.asMap().keySet().forEach(DynamicUtil.DYNAMIC_ITEMS_CACHE::refresh);
257-
if (hasAPIOnServer()) FactoryConfig.COMMON_STORAGES.values().forEach(c-> {
258-
if (c.isServerOnly()) c.reset();
259-
else if (c.allowSync()) c.load();
257+
if (hasAPIOnServer()) FactoryConfig.COMMON_STORAGES.values().forEach(c -> {
258+
if (!c.isServerOnly() && c.allowSync()) c.load();
260259
});
261260
playerMods.clear();
262261
//? if >=1.21.2 {
263262
/*CommonRecipeManager.clearRecipes();
264263
*///?}
265264
});
265+
FactoryEvent.serverStopped(server -> {
266+
FactoryConfig.COMMON_STORAGES.values().forEach(c -> {
267+
if (c.isServerOnly()) c.resetAndUnload();
268+
});
269+
});
266270
//? if fabric {
267271
//? if >=1.21.9 {
268272
/*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));
@@ -307,7 +311,7 @@ public static <T extends CommonNetwork.Payload> void registerPayload(CommonNetwo
307311
//?} else if forge || neoforge {
308312
/*public static void registerReloadListener(PreparableReloadListener reloadListener) {
309313
//? if >=1.21.4 && neoforge {
310-
/^FactoryAPIPlatform.getModEventBus().addListener(EventPriority.NORMAL,false, AddClientReloadListenersEvent.class, e-> e.addListener(FactoryAPI.createLocation(reloadListener.getName()), reloadListener));
314+
/^FactoryAPIPlatform.getModEventBus().addListener(EventPriority.NORMAL, false, AddClientReloadListenersEvent.class, e-> e.addListener(FactoryAPI.createLocation(reloadListener.getName()), reloadListener));
311315
^///?} else {
312316
((ReloadableResourceManager)Minecraft.getInstance().getResourceManager()).registerReloadListener(reloadListener);
313317
//?}
@@ -324,7 +328,7 @@ public static void setup(Consumer<Minecraft> listener) {
324328
//? if fabric {
325329
ClientLifecycleEvents.CLIENT_STARTED.register(listener::accept);
326330
//?} elif (forge && <1.21.6) || neoforge {
327-
/*FactoryAPIPlatform.getModEventBus().addListener(EventPriority.NORMAL,false, FMLClientSetupEvent.class, e-> listener.accept(Minecraft.getInstance()));
331+
/*FactoryAPIPlatform.getModEventBus().addListener(EventPriority.NORMAL, false, FMLClientSetupEvent.class, e-> listener.accept(Minecraft.getInstance()));
328332
*///?} else if forge {
329333
/*FMLClientSetupEvent.getBus(FactoryAPIPlatform.getModEventBus()).addListener(e-> listener.accept(Minecraft.getInstance()));
330334
*///?} else
@@ -335,7 +339,7 @@ public static void preTick(Consumer<Minecraft> listener) {
335339
//? if fabric {
336340
ClientTickEvents.START_CLIENT_TICK.register(listener::accept);
337341
//?} elif forge && <1.21.6 {
338-
/*MinecraftForge.EVENT_BUS.addListener(EventPriority.NORMAL,false, /^? if <1.21 {^//^TickEvent.ClientTickEvent^//^?} else {^/TickEvent.ClientTickEvent.Pre/^?}^/.class, e-> {
342+
/*MinecraftForge.EVENT_BUS.addListener(EventPriority.NORMAL, false, /^? if <1.21 {^//^TickEvent.ClientTickEvent^//^?} else {^/TickEvent.ClientTickEvent.Pre/^?}^/.class, e-> {
339343
if (e.phase == TickEvent.Phase.START) listener.accept(Minecraft.getInstance());
340344
});
341345
*///?} elif forge {
@@ -352,7 +356,7 @@ public static void postTick(Consumer<Minecraft> listener) {
352356
//? if fabric {
353357
ClientTickEvents.END_CLIENT_TICK.register(listener::accept);
354358
//?} elif forge && <1.21.6 {
355-
/*MinecraftForge.EVENT_BUS.addListener(EventPriority.NORMAL,false, /^? if <1.21 {^//^TickEvent.ClientTickEvent^//^?} else {^/TickEvent.ClientTickEvent.Post/^?}^/.class, e-> {
359+
/*MinecraftForge.EVENT_BUS.addListener(EventPriority.NORMAL, false, /^? if <1.21 {^//^TickEvent.ClientTickEvent^//^?} else {^/TickEvent.ClientTickEvent.Post/^?}^/.class, e-> {
356360
if (e.phase == TickEvent.Phase.END) listener.accept(Minecraft.getInstance());
357361
});
358362
*///?} elif forge {
@@ -409,7 +413,7 @@ public static void registerKeyMapping(Consumer<Consumer<KeyMapping>> registry) {
409413
//? if fabric {
410414
registry.accept(KeyBindingHelper::registerKeyBinding);
411415
//?} elif (forge && <1.21.6) || neoforge {
412-
/*FactoryAPIPlatform.getModEventBus().addListener(EventPriority.NORMAL,false, RegisterKeyMappingsEvent.class, e->registry.accept(e::register));
416+
/*FactoryAPIPlatform.getModEventBus().addListener(EventPriority.NORMAL, false, RegisterKeyMappingsEvent.class, e->registry.accept(e::register));
413417
*///?} elif forge && <1.21.9 {
414418
/*RegisterKeyMappingsEvent.getBus(FactoryAPIPlatform.getModEventBus()).addListener(e->registry.accept(e::register));
415419
*///?} elif forge {
@@ -468,7 +472,7 @@ public static void registerBlockColor(Consumer<BiConsumer<BlockColor, Block>> re
468472
//? if fabric {
469473
registry.accept(ColorProviderRegistry.BLOCK::register);
470474
//?} elif (forge && <1.21.6) || neoforge {
471-
/*FactoryAPIPlatform.getModEventBus().addListener(EventPriority.NORMAL,false, RegisterColorHandlersEvent.Block.class, e->registry.accept(e::register));
475+
/*FactoryAPIPlatform.getModEventBus().addListener(EventPriority.NORMAL, false, RegisterColorHandlersEvent.Block.class, e->registry.accept(e::register));
472476
*///?} elif forge && <1.21.9 {
473477
/*RegisterColorHandlersEvent.Block.getBus(FactoryAPIPlatform.getModEventBus()).addListener(e-> registry.accept(e::register));
474478
*///?} elif forge {
@@ -482,7 +486,7 @@ public static void registerItemColor(Consumer<BiConsumer<ItemColor, Item>> regis
482486
//? if fabric {
483487
registry.accept(ColorProviderRegistry.ITEM::register);
484488
//?} elif forge || neoforge {
485-
/*FactoryAPIPlatform.getModEventBus().addListener(EventPriority.NORMAL,false, RegisterColorHandlersEvent.Item.class, e->registry.accept(e::register));
489+
/*FactoryAPIPlatform.getModEventBus().addListener(EventPriority.NORMAL, false, RegisterColorHandlersEvent.Item.class, e->registry.accept(e::register));
486490
*///?} else
487491
/*throw new AssertionError();*/
488492
}
@@ -510,22 +514,22 @@ public static void registerRenderType(/*? if <1.21.6 {*/RenderType/*?} else {*//
510514
/*throw new AssertionError();*/
511515
}
512516

513-
public record ExtraModelId(StateDefinition<Block,BlockState> stateDefinition, BlockState blockState, ResourceLocation id/*? if <1.21.5 {*/, ModelResourceLocation modelId/*?}*/) {
514-
public static ExtraModelId create(ResourceLocation id) {
517+
public record ExtraModelId(StateDefinition<Block,BlockState> stateDefinition, BlockState blockState, net.minecraft.resources.ResourceLocation id/*? if <1.21.5 {*/, ModelResourceLocation modelId/*?}*/) {
518+
public static ExtraModelId create(net.minecraft.resources.ResourceLocation id) {
515519
StateDefinition<Block,BlockState> stateDefinition = new StateDefinition.Builder<Block, BlockState>(Blocks.AIR).create(Block::defaultBlockState, BlockState::new);
516520
return new ExtraModelId(stateDefinition, stateDefinition.any(), id/*? if <1.21.5 {*/, BlockModelShaper.stateToModelLocation(id, stateDefinition.any())/*?}*/);
517521
}
518522
}
519523

520-
public static void registerExtraModels(Consumer<Consumer<ResourceLocation>> registry) {
524+
public static void registerExtraModels(Consumer<Consumer<net.minecraft.resources.ResourceLocation>> registry) {
521525
registry.accept(id-> extraModels.put(id, ExtraModelId.create(id)));
522526
}
523527

524528
public static <T extends Entity> void registerEntityRenderer(Supplier<? extends EntityType<? extends T>> type, EntityRendererProvider<T> provider) {
525529
//? if fabric {
526530
EntityRendererRegistry.register(type.get(),provider);
527531
//?} else if (forge && <1.21.6) || neoforge {
528-
/*FactoryAPIPlatform.getModEventBus().addListener(EventPriority.NORMAL,false, EntityRenderersEvent.RegisterRenderers.class, e-> e.registerEntityRenderer(type.get(),provider));
532+
/*FactoryAPIPlatform.getModEventBus().addListener(EventPriority.NORMAL, false, EntityRenderersEvent.RegisterRenderers.class, e-> e.registerEntityRenderer(type.get(),provider));
529533
*///?} elif forge && <1.21.9 {
530534
/*EntityRenderersEvent.RegisterRenderers.getBus(FactoryAPIPlatform.getModEventBus()).addListener(e-> e.registerEntityRenderer(type.get(),provider));
531535
*///?} elif forge {
@@ -538,7 +542,7 @@ public static void registerLayerDefinition(ModelLayerLocation location, Supplier
538542
//? if fabric {
539543
EntityModelLayerRegistry.registerModelLayer(location,definition::get);
540544
//?} else if (forge && <1.21.6) || neoforge {
541-
/*FactoryAPIPlatform.getModEventBus().addListener(EventPriority.NORMAL,false, EntityRenderersEvent.RegisterLayerDefinitions.class, e-> e.registerLayerDefinition(location,definition));
545+
/*FactoryAPIPlatform.getModEventBus().addListener(EventPriority.NORMAL, false, EntityRenderersEvent.RegisterLayerDefinitions.class, e-> e.registerLayerDefinition(location,definition));
542546
*///?} else if forge {
543547
/*EntityRenderersEvent.RegisterLayerDefinitions.getBus(FactoryAPIPlatform.getModEventBus()).addListener(e-> e.registerLayerDefinition(location,definition));
544548
*///?} else if forge {
@@ -572,7 +576,7 @@ public EntityModelSet getEntityModelSet() {
572576

573577
}));
574578
//?} else if (forge && <1.21.6) || neoforge {
575-
/*FactoryAPIPlatform.getModEventBus().addListener(EventPriority.NORMAL,false, EntityRenderersEvent.AddLayers.class, e-> registry.accept(new FactoryRenderLayerRegistry() {
579+
/*FactoryAPIPlatform.getModEventBus().addListener(EventPriority.NORMAL, false, EntityRenderersEvent.AddLayers.class, e-> registry.accept(new FactoryRenderLayerRegistry() {
576580
@Override
577581
public EntityRenderer<?/^? if >=1.21.2 {^//^, ? ^//^?}^/> getEntityRenderer(EntityType<? extends LivingEntity> entityType) {
578582
return e./^? if >=1.20.2 && forge {^//^getEntityRenderer^//^?} else {^/getRenderer/^?}^/(entityType);

0 commit comments

Comments
 (0)