修改第五部分
去掉了不是很必要的塔吊API,目前全局使用Service来替代
This commit is contained in:
parent
d305b932ed
commit
3c6416d7ca
|
|
@ -8,5 +8,5 @@ dependencies {
|
||||||
// Do NOT use other classes from Fabric Loader.
|
// Do NOT use other classes from Fabric Loader.
|
||||||
modImplementation "net.fabricmc:fabric-loader:$rootProject.fabric_loader_version"
|
modImplementation "net.fabricmc:fabric-loader:$rootProject.fabric_loader_version"
|
||||||
|
|
||||||
modImplementation "dev.architectury:architectury:$rootProject.architectury_api_version"
|
// modImplementation "dev.architectury:architectury:$rootProject.architectury_api_version"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
package com.leisuretimedock.jsonem;
|
package com.leisuretimedock.jsonem;
|
||||||
|
|
||||||
import dev.architectury.registry.client.level.entity.EntityModelLayerRegistry;
|
import com.leisuretimedock.jsonem.platform.Services;
|
||||||
import net.minecraft.client.model.geom.ModelLayerLocation;
|
import net.minecraft.client.model.geom.ModelLayerLocation;
|
||||||
import net.minecraft.client.model.geom.builders.LayerDefinition;
|
|
||||||
import net.minecraft.client.model.geom.builders.MeshDefinition;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
@ -14,6 +12,6 @@ public final class JsonEm {
|
||||||
// Write common init code here.
|
// Write common init code here.
|
||||||
}
|
}
|
||||||
public static void registerModelLayer(ModelLayerLocation layer) {
|
public static void registerModelLayer(ModelLayerLocation layer) {
|
||||||
EntityModelLayerRegistry.register(layer, () -> LayerDefinition.create(new MeshDefinition(), 32, 32));
|
Services.PLATFORM.registerModelLayer(layer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
package com.leisuretimedock.jsonem.platform;
|
package com.leisuretimedock.jsonem.platform;
|
||||||
|
|
||||||
|
import net.minecraft.client.model.geom.ModelLayerLocation;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
public interface IPlatFormHelper {
|
public interface IPlatFormHelper {
|
||||||
boolean shouldDumpModels();
|
boolean shouldDumpModels();
|
||||||
Path getDumpModelsPath();
|
Path getDumpModelsPath();
|
||||||
|
void registerModelLayer(ModelLayerLocation layer);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ dependencies {
|
||||||
|
|
||||||
modImplementation "net.fabricmc.fabric-api:fabric-api:$rootProject.fabric_api_version"
|
modImplementation "net.fabricmc.fabric-api:fabric-api:$rootProject.fabric_api_version"
|
||||||
|
|
||||||
modImplementation "dev.architectury:architectury-fabric:$rootProject.architectury_api_version"
|
// modImplementation "dev.architectury:architectury-fabric:$rootProject.architectury_api_version"
|
||||||
|
|
||||||
common(project(path: ':common', configuration: 'namedElements')) { transitive false }
|
common(project(path: ':common', configuration: 'namedElements')) { transitive false }
|
||||||
shadowBundle project(path: ':common', configuration: 'transformProductionFabric')
|
shadowBundle project(path: ':common', configuration: 'transformProductionFabric')
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,14 @@ package com.leisuretimedock.jsonem.fabric.platform;
|
||||||
|
|
||||||
import com.leisuretimedock.jsonem.fabric.JsonEmFabric;
|
import com.leisuretimedock.jsonem.fabric.JsonEmFabric;
|
||||||
import com.leisuretimedock.jsonem.platform.IPlatFormHelper;
|
import com.leisuretimedock.jsonem.platform.IPlatFormHelper;
|
||||||
|
import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
|
import net.minecraft.client.model.geom.ModelLayerLocation;
|
||||||
|
import net.minecraft.client.model.geom.builders.LayerDefinition;
|
||||||
|
import net.minecraft.client.model.geom.builders.MeshDefinition;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class FabricPlatformHelper implements IPlatFormHelper {
|
public class FabricPlatformHelper implements IPlatFormHelper {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -16,4 +21,10 @@ public class FabricPlatformHelper implements IPlatFormHelper {
|
||||||
public Path getDumpModelsPath() {
|
public Path getDumpModelsPath() {
|
||||||
return FabricLoader.getInstance().getGameDir().resolve("jsonem_dump");
|
return FabricLoader.getInstance().getGameDir().resolve("jsonem_dump");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerModelLayer(ModelLayerLocation layer) {
|
||||||
|
Objects.requireNonNull(layer);
|
||||||
|
EntityModelLayerRegistry.registerModelLayer(layer, () -> LayerDefinition.create(new MeshDefinition(), 32, 32));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@
|
||||||
"fabricloader": ">=0.16.14",
|
"fabricloader": ">=0.16.14",
|
||||||
"minecraft": "~1.20.1",
|
"minecraft": "~1.20.1",
|
||||||
"java": ">=17",
|
"java": ">=17",
|
||||||
"architectury": ">=9.2.14",
|
|
||||||
"fabric-api": "*"
|
"fabric-api": "*"
|
||||||
},
|
},
|
||||||
"suggests": {
|
"suggests": {
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ dependencies {
|
||||||
|
|
||||||
forge "net.minecraftforge:forge:$rootProject.forge_version"
|
forge "net.minecraftforge:forge:$rootProject.forge_version"
|
||||||
|
|
||||||
modImplementation "dev.architectury:architectury-forge:$rootProject.architectury_api_version"
|
// modImplementation "dev.architectury:architectury-forge:$rootProject.architectury_api_version"
|
||||||
common(project(path: ':common', configuration: 'namedElements')) { transitive false }
|
common(project(path: ':common', configuration: 'namedElements')) { transitive false }
|
||||||
shadowBundle project(path: ':common', configuration: 'transformProductionNeoForge')
|
shadowBundle project(path: ':common', configuration: 'transformProductionNeoForge')
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,7 @@ package com.leisuretimedock.jsonem.forge;
|
||||||
|
|
||||||
import com.leisuretimedock.jsonem.JsonEm;
|
import com.leisuretimedock.jsonem.JsonEm;
|
||||||
import com.leisuretimedock.jsonem.forge.config.JsonEmConfig;
|
import com.leisuretimedock.jsonem.forge.config.JsonEmConfig;
|
||||||
import dev.architectury.platform.forge.EventBuses;
|
import com.leisuretimedock.jsonem.forge.platform.ForgePlatformHelper;
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.config.ModConfig;
|
import net.minecraftforge.fml.config.ModConfig;
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
|
|
@ -11,11 +10,8 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
@Mod(JsonEm.MOD_ID)
|
@Mod(JsonEm.MOD_ID)
|
||||||
public final class JsonEmForge {
|
public final class JsonEmForge {
|
||||||
public JsonEmForge(FMLJavaModLoadingContext context) {
|
public JsonEmForge(FMLJavaModLoadingContext context) {
|
||||||
// Submit our event bus to let Architectury API register our content on the right time.
|
|
||||||
IEventBus modEventBus = context.getModEventBus();
|
|
||||||
EventBuses.registerModEventBus(JsonEm.MOD_ID, modEventBus);
|
|
||||||
context.registerConfig(ModConfig.Type.CLIENT, JsonEmConfig.spec, "jsonem.toml");
|
context.registerConfig(ModConfig.Type.CLIENT, JsonEmConfig.spec, "jsonem.toml");
|
||||||
// Run our common setup.
|
|
||||||
JsonEm.init();
|
JsonEm.init();
|
||||||
|
context.getModEventBus().register(ForgePlatformHelper.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,20 @@ package com.leisuretimedock.jsonem.forge.platform;
|
||||||
|
|
||||||
import com.leisuretimedock.jsonem.forge.config.JsonEmConfig;
|
import com.leisuretimedock.jsonem.forge.config.JsonEmConfig;
|
||||||
import com.leisuretimedock.jsonem.platform.IPlatFormHelper;
|
import com.leisuretimedock.jsonem.platform.IPlatFormHelper;
|
||||||
|
import net.minecraft.client.model.geom.ModelLayerLocation;
|
||||||
|
import net.minecraft.client.model.geom.builders.LayerDefinition;
|
||||||
|
import net.minecraft.client.model.geom.builders.MeshDefinition;
|
||||||
|
import net.minecraftforge.client.event.EntityRenderersEvent;
|
||||||
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.loading.FMLPaths;
|
import net.minecraftforge.fml.loading.FMLPaths;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class ForgePlatformHelper implements IPlatFormHelper {
|
public class ForgePlatformHelper implements IPlatFormHelper {
|
||||||
|
private static final Map<ModelLayerLocation, Supplier<LayerDefinition>> DEFINITIONS = new ConcurrentHashMap<>();
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldDumpModels() {
|
public boolean shouldDumpModels() {
|
||||||
try {
|
try {
|
||||||
|
|
@ -21,4 +30,16 @@ public class ForgePlatformHelper implements IPlatFormHelper {
|
||||||
return FMLPaths.GAMEDIR.get().resolve("jsonem_dump");
|
return FMLPaths.GAMEDIR.get().resolve("jsonem_dump");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerModelLayer(ModelLayerLocation layer) {
|
||||||
|
DEFINITIONS.put(layer, () -> LayerDefinition.create(new MeshDefinition(), 32, 32));
|
||||||
|
}
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void event(EntityRenderersEvent.RegisterLayerDefinitions event) {
|
||||||
|
for (Map.Entry<ModelLayerLocation, Supplier<LayerDefinition>> modelLayerLocationSupplierEntry : DEFINITIONS.entrySet()) {
|
||||||
|
event.registerLayerDefinition(modelLayerLocationSupplierEntry.getKey(), modelLayerLocationSupplierEntry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,3 @@ versionRange = "[1.20.1,)"
|
||||||
ordering = "NONE"
|
ordering = "NONE"
|
||||||
side = "BOTH"
|
side = "BOTH"
|
||||||
|
|
||||||
[[dependencies.jsonem]]
|
|
||||||
modId = "architectury"
|
|
||||||
mandatory = true
|
|
||||||
versionRange = "[9.2.14,)"
|
|
||||||
ordering = "AFTER"
|
|
||||||
side = "BOTH"
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user