feat: port to architectury

This commit is contained in:
LordMZTE 2023-11-01 17:39:33 +01:00
parent 64a9efbd5b
commit 490f4a7896
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6
49 changed files with 492 additions and 174 deletions

11
.gitignore vendored
View file

@ -1,5 +1,4 @@
# gradle # gradle
.gradle/ .gradle/
build/ build/
out/ out/
@ -7,28 +6,26 @@ classes/
.factorypath .factorypath
# eclipse # eclipse
*.launch *.launch
# idea # idea
.idea/ .idea/
*.iml *.iml
*.ipr *.ipr
*.iws *.iws
# vscode # vscode
.settings/ .settings/
.vscode/ .vscode/
bin/ bin/
.classpath .classpath
.project .project
# macos # kekos
*.DS_Store *.DS_Store
# fabric # fabric
run/ run/
# architectury
.architectury-transformer

View file

@ -1,97 +1,59 @@
plugins { plugins {
id "dev.architectury.loom" version "1.1-SNAPSHOT" id "architectury-plugin" version "3.4-SNAPSHOT"
id "maven-publish" id "dev.architectury.loom" version "1.3-SNAPSHOT" apply false
} }
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17 architectury {
minecraft = rootProject.minecraft_version
}
archivesBaseName = project.archives_base_name subprojects {
version = project.mod_version apply plugin: "dev.architectury.loom"
group = project.maven_group
loom { dependencies {
forge { minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
mixinConfigs = [ // The following line declares the yarn mappings you may select this one as well.
"anvillib.mixins.json" mappings "net.fabricmc:yarn:1.18.2+build.4:v2"
]
} }
} }
repositories { allprojects {
maven { apply plugin: "java"
url "https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/" apply plugin: "architectury-plugin"
apply plugin: "maven-publish"
base {
archivesName = rootProject.archives_base_name
} }
}
dependencies { version = rootProject.mod_version
// to change the versions see the gradle.properties file group = rootProject.maven_group
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
forge "net.minecraftforge:forge:${project.forge_version}"
modImplementation "software.bernie.geckolib:geckolib-forge-1.18:3.0.57"
}
processResources {
// this will replace the property "${version}" in your mods.toml
// with the version you've defined in your gradle.properties
filesMatching("META-INF/mods.toml") {
expand "version": project.version
}
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
options.release = 17
}
java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
}
jar {
// add some additional metadata to the jar manifest
manifest {
attributes([
"Specification-Title" : project.mod_id,
"Specification-Vendor" : project.mod_author,
"Specification-Version" : "1",
"Implementation-Title" : project.name,
"Implementation-Version" : version,
"Implementation-Vendor" : project.mod_author,
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
sourcesJar {
archiveClassifier = "sources"
}
// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifactId = project.archivesBaseName
}
}
repositories { repositories {
if (project.hasProperty("mvnURL")) { maven { url "https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/" }
maven { }
credentials {
username findProperty("mvnUsername") tasks.withType(JavaCompile) {
password findProperty("mvnPassword") options.encoding = "UTF-8"
options.release = 17
}
java {
withSourcesJar()
}
publishing {
repositories {
if (project.hasProperty("mvnURL")) {
maven {
credentials {
username findProperty("mvnUsername")
password findProperty("mvnPassword")
}
url = findProperty("mvnURL")
} }
url = findProperty("mvnURL")
} }
mavenLocal()
} }
mavenLocal()
} }
} }

23
common/build.gradle Normal file
View file

@ -0,0 +1,23 @@
architectury {
common(rootProject.enabled_platforms.split(","))
}
loom {
accessWidenerPath = file("src/main/resources/anvillib.accesswidener")
}
dependencies {
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
// Do NOT use other classes from fabric loader
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
modImplementation "software.bernie.geckolib:geckolib-fabric-1.18:3.0.80"
}
publishing {
publications {
mavenCommon(MavenPublication) {
artifactId = rootProject.archives_base_name
from components.java
}
}
}

View file

@ -3,15 +3,17 @@ package net.anvilcraft.anvillib;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import net.minecraftforge.fml.common.Mod; import net.anvilcraft.anvillib.cosmetics.ClientEventHandler;
import net.anvilcraft.anvillib.event.Bus;
import software.bernie.geckolib3.GeckoLib; import software.bernie.geckolib3.GeckoLib;
@Mod(AnvilLib.MODID)
public class AnvilLib { public class AnvilLib {
public static final String MODID = "anvillib"; public static final String MODID = "anvillib";
public static final Logger LOGGER = LogManager.getLogger(); public static final Logger LOGGER = LogManager.getLogger();
public AnvilLib() { public static void initialize() {
Bus.MAIN.register(new ClientEventHandler());
GeckoLib.initialize(); GeckoLib.initialize();
} }
} }

View file

@ -5,14 +5,13 @@ import net.minecraft.recipe.Ingredient;
import net.minecraft.tag.TagKey; import net.minecraft.tag.TagKey;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import net.minecraftforge.registries.ForgeRegistries;
public class Util { public class Util {
public static ItemStack stackFromRegistry(Identifier id) { public static ItemStack stackFromRegistry(Identifier id) {
if (ForgeRegistries.ITEMS.containsKey(id)) { if (Registry.ITEM.containsId(id)) {
return new ItemStack(ForgeRegistries.ITEMS.getValue(id)); return new ItemStack(Registry.ITEM.get(id));
} else if (ForgeRegistries.BLOCKS.containsKey(id)) { } else if (Registry.BLOCK.containsId(id)) {
return new ItemStack(ForgeRegistries.BLOCKS.getValue(id)); return new ItemStack(Registry.BLOCK.get(id));
} else { } else {
throw new IllegalArgumentException("No block or item with ID " + id + "!"); throw new IllegalArgumentException("No block or item with ID " + id + "!");
} }

View file

@ -0,0 +1,23 @@
package net.anvilcraft.anvillib.cosmetics;
import java.util.Map.Entry;
import net.anvilcraft.anvillib.event.AddEntityRenderLayersEvent;
import net.anvilcraft.anvillib.event.Bus;
import net.anvilcraft.anvillib.event.IEventBusRegisterable;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.client.render.entity.PlayerEntityRenderer;
import net.minecraft.entity.player.PlayerEntity;
public class ClientEventHandler implements IEventBusRegisterable {
private void onAddLayers(AddEntityRenderLayersEvent ev) {
for (Entry<String, EntityRenderer<? extends PlayerEntity>> skin : ev.skinMap().entrySet())
if (skin.getValue() instanceof PlayerEntityRenderer render)
render.addFeature(new CosmeticFeatureRenderer(render, skin.getKey()));
}
@Override
public void registerEventHandlers(Bus bus) {
bus.register(AddEntityRenderLayersEvent.class, this::onAddLayers);
}
}

View file

@ -3,11 +3,6 @@ package net.anvilcraft.anvillib.cosmetics;
import java.util.Arrays; import java.util.Arrays;
import java.util.Objects; import java.util.Objects;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.jetbrains.annotations.ApiStatus.AvailableSince;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
@ -26,8 +21,6 @@ import net.minecraft.util.math.Matrix4f;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3f; import net.minecraft.util.math.Vec3f;
import net.minecraft.util.math.Vector4f; import net.minecraft.util.math.Vector4f;
import net.minecraftforge.fml.ModList;
import software.bernie.geckolib3.compat.PatchouliCompat;
import software.bernie.geckolib3.core.IAnimatable; import software.bernie.geckolib3.core.IAnimatable;
import software.bernie.geckolib3.core.IAnimatableModel; import software.bernie.geckolib3.core.IAnimatableModel;
import software.bernie.geckolib3.core.controller.AnimationController; import software.bernie.geckolib3.core.controller.AnimationController;
@ -72,7 +65,6 @@ public class CosmeticArmorRenderer extends BipedEntityModel<PlayerEntity>
{ AnimationController.addModelFetcher(this); } { AnimationController.addModelFetcher(this); }
@Override @Override
@Nullable
public IAnimatableModel<CosmeticItem> apply(IAnimatable t) { public IAnimatableModel<CosmeticItem> apply(IAnimatable t) {
if (t instanceof CosmeticItem) if (t instanceof CosmeticItem)
return this.getGeoModelProvider(); return this.getGeoModelProvider();
@ -162,8 +154,8 @@ public class CosmeticArmorRenderer extends BipedEntityModel<PlayerEntity>
renderColor.getAlpha() / 255f renderColor.getAlpha() / 255f
); );
if (ModList.get().isLoaded("patchouli")) //if (ModList.get().isLoaded("patchouli"))
PatchouliCompat.patchouliLoaded(poseStack); // PatchouliCompat.patchouliLoaded(poseStack);
poseStack.pop(); poseStack.pop();
} }
@ -298,26 +290,21 @@ public class CosmeticArmorRenderer extends BipedEntityModel<PlayerEntity>
return this.modelProvider; return this.modelProvider;
} }
@AvailableSince(value = "3.1.24")
@Override @Override
@Nonnull
public IRenderCycle getCurrentModelRenderCycle() { public IRenderCycle getCurrentModelRenderCycle() {
return this.currentModelRenderCycle; return this.currentModelRenderCycle;
} }
@AvailableSince(value = "3.1.24")
@Override @Override
public void setCurrentModelRenderCycle(IRenderCycle currentModelRenderCycle) { public void setCurrentModelRenderCycle(IRenderCycle currentModelRenderCycle) {
this.currentModelRenderCycle = currentModelRenderCycle; this.currentModelRenderCycle = currentModelRenderCycle;
} }
@AvailableSince(value = "3.1.24")
@Override @Override
public float getWidthScale(CosmeticItem animatable) { public float getWidthScale(CosmeticItem animatable) {
return this.widthScale; return this.widthScale;
} }
@AvailableSince(value = "3.1.24")
@Override @Override
public float getHeightScale(CosmeticItem entity) { public float getHeightScale(CosmeticItem entity) {
return this.heightScale; return this.heightScale;

View file

@ -0,0 +1,9 @@
package net.anvilcraft.anvillib.event;
import java.util.Map;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.entity.player.PlayerEntity;
public record
AddEntityRenderLayersEvent(Map<String, EntityRenderer<? extends PlayerEntity>> skinMap) {}

View file

@ -0,0 +1,31 @@
package net.anvilcraft.anvillib.event;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
public class Bus {
public static final Bus MAIN = new Bus();
private final Map<Class<?>, List<Consumer<?>>> handlerMap = new HashMap<>();
public void register(IEventBusRegisterable obj) {
obj.registerEventHandlers(this);
}
public <T> void register(Class<T> clazz, Consumer<T> handler) {
handlerMap.computeIfAbsent(clazz, alec -> new ArrayList<>()).add(handler);
}
@SuppressWarnings("unchecked")
public <T> void fire(T ev) {
var clazz = ev.getClass();
if (handlerMap.containsKey(clazz)) {
for (Consumer<?> handler : handlerMap.get(clazz)) {
((Consumer<T>) handler).accept(ev);
}
}
}
}

View file

@ -0,0 +1,12 @@
package net.anvilcraft.anvillib.event;
/**
* IEventBusRegisterable describes a class which contains one or more event handlers to be
* registered on the anvillib event bus.
*/
public interface IEventBusRegisterable {
/**
* Register this object's event handlers on the given bus.
*/
public void registerEventHandlers(Bus bus);
}

View file

@ -12,6 +12,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import net.anvilcraft.anvillib.AnvilLib; import net.anvilcraft.anvillib.AnvilLib;
import net.anvilcraft.anvillib.event.Bus;
import net.anvilcraft.anvillib.recipe.RecipesEvent; import net.anvilcraft.anvillib.recipe.RecipesEvent;
import net.minecraft.recipe.Recipe; import net.minecraft.recipe.Recipe;
import net.minecraft.recipe.RecipeManager; import net.minecraft.recipe.RecipeManager;
@ -19,7 +20,6 @@ import net.minecraft.recipe.RecipeType;
import net.minecraft.resource.ResourceManager; import net.minecraft.resource.ResourceManager;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.profiler.Profiler; import net.minecraft.util.profiler.Profiler;
import net.minecraftforge.fml.ModLoader;
@Mixin(RecipeManager.class) @Mixin(RecipeManager.class)
public class RecipeManagerMixin { public class RecipeManagerMixin {
@ -41,7 +41,7 @@ public class RecipeManagerMixin {
this.recipes.forEach((k, v) -> recipes.put(k, new HashMap<>(v))); this.recipes.forEach((k, v) -> recipes.put(k, new HashMap<>(v)));
var ev = new RecipesEvent(recipes, new HashMap<>(this.recipesById)); var ev = new RecipesEvent(recipes, new HashMap<>(this.recipesById));
ModLoader.get().postEvent(ev); Bus.MAIN.fire(ev);
this.recipes = ev.recipes; this.recipes = ev.recipes;
this.recipesById = ev.recipesById; this.recipesById = ev.recipesById;
} }

View file

@ -9,10 +9,8 @@ import java.util.function.Predicate;
import net.minecraft.recipe.Recipe; import net.minecraft.recipe.Recipe;
import net.minecraft.recipe.RecipeType; import net.minecraft.recipe.RecipeType;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.fml.event.IModBusEvent;
public class RecipesEvent extends Event implements IModBusEvent { public class RecipesEvent {
public Map<RecipeType<?>, Map<Identifier, Recipe<?>>> recipes; public Map<RecipeType<?>, Map<Identifier, Recipe<?>>> recipes;
public Map<Identifier, Recipe<?>> recipesById; public Map<Identifier, Recipe<?>> recipesById;

View file

@ -13,7 +13,6 @@ import net.minecraft.tag.TagKey;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.collection.DefaultedList; import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import net.minecraftforge.registries.ForgeRegistries;
public class ShapedRecipeBuilder { public class ShapedRecipeBuilder {
public Identifier ident; public Identifier ident;
@ -54,9 +53,9 @@ public class ShapedRecipeBuilder {
} }
var ident = new Identifier(s); var ident = new Identifier(s);
var maybeItem = ForgeRegistries.ITEMS.getValue(ident); var maybeItem = Registry.ITEM.get(ident);
if (maybeItem == null) { if (maybeItem == null) {
var maybeBlock = ForgeRegistries.BLOCKS.getValue(ident); var maybeBlock = Registry.BLOCK.get(ident);
if (maybeBlock == null) if (maybeBlock == null)
throw new IllegalArgumentException( throw new IllegalArgumentException(
"ID " + s + " not found in item or block registry!" "ID " + s + " not found in item or block registry!"

View file

@ -3,11 +3,11 @@
"package": "net.anvilcraft.anvillib.mixin", "package": "net.anvilcraft.anvillib.mixin",
"compatibilityLevel": "JAVA_17", "compatibilityLevel": "JAVA_17",
"minVersion": "0.8", "minVersion": "0.8",
"client": [],
"mixins": [ "mixins": [
"common.RecipeManagerMixin", "common.RecipeManagerMixin",
"common.StructurePoolBasedGeneratorMixin" "common.StructurePoolBasedGeneratorMixin"
], ],
"client": [],
"injectors": { "injectors": {
"defaultRequire": 1 "defaultRequire": 1
} }

View file

@ -0,0 +1,12 @@
accessWidener v2 named
# vim: ft=conf
accessible class net/minecraft/recipe/Ingredient$Entry
accessible field net/minecraft/recipe/Ingredient entries [Lnet/minecraft/recipe/Ingredient$Entry;
accessible class net/minecraft/recipe/Ingredient$TagEntry
accessible field net/minecraft/recipe/Ingredient$TagEntry tag Lnet/minecraft/tag/TagKey;
accessible class net/minecraft/recipe/Ingredient$StackEntry
accessible field net/minecraft/recipe/Ingredient$StackEntry stack Lnet/minecraft/item/ItemStack;
accessible method net/minecraft/client/render/entity/LivingEntityRenderer addFeature (Lnet/minecraft/client/render/entity/feature/FeatureRenderer;)Z

View file

@ -0,0 +1,3 @@
{
"accessWidener": "anvillib.accesswidener"
}

71
fabric/build.gradle Normal file
View file

@ -0,0 +1,71 @@
plugins {
id "com.github.johnrengelman.shadow" version "7.1.2"
}
architectury {
platformSetupLoomIde()
fabric()
}
loom {
accessWidenerPath = project(":common").loom.accessWidenerPath
}
configurations {
common
shadowCommon // Don't use shadow from the shadow plugin since it *excludes* files.
compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common
developmentFabric.extendsFrom common
}
dependencies {
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
modImplementation "software.bernie.geckolib:geckolib-fabric-1.18:3.0.80"
common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
}
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
shadowJar {
exclude "architectury.common.json"
configurations = [project.configurations.shadowCommon]
archiveClassifier = "dev-shadow"
}
remapJar {
injectAccessWidener = true
input.set shadowJar.archiveFile
dependsOn shadowJar
}
sourcesJar {
def commonSources = project(":common").sourcesJar
dependsOn commonSources
from commonSources.archiveFile.map { zipTree(it) }
}
components.java {
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
skip()
}
}
publishing {
publications {
mavenFabric(MavenPublication) {
artifactId = rootProject.archives_base_name + "-" + project.name
from components.java
}
}
}

View file

@ -0,0 +1,10 @@
package net.anvilcraft.anvillib;
import net.fabricmc.api.ModInitializer;
public class AnvilLibFabric implements ModInitializer {
@Override
public void onInitialize() {
AnvilLib.initialize();
}
}

View file

@ -0,0 +1,27 @@
package net.anvilcraft.anvillib.mixin.client;
import java.util.Map;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.anvilcraft.anvillib.event.AddEntityRenderLayersEvent;
import net.anvilcraft.anvillib.event.Bus;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.resource.ResourceManager;
@Mixin(EntityRenderDispatcher.class)
public class EntityRenderDispatcherMixin {
@Shadow
private Map<String, EntityRenderer<? extends PlayerEntity>> modelRenderers;
@Inject(method = "reload", at = @At("TAIL"))
public void onReload(ResourceManager alec, CallbackInfo ci) {
Bus.MAIN.fire(new AddEntityRenderLayersEvent(this.modelRenderers));
}
}

View file

@ -0,0 +1,13 @@
{
"required": true,
"package": "net.anvilcraft.anvillib.mixin.fabric",
"compatibilityLevel": "JAVA_17",
"minVersion": "0.8",
"client": [
],
"mixins": [
],
"injectors": {
"defaultRequire": 1
}
}

View file

@ -0,0 +1,29 @@
{
"schemaVersion": 1,
"id": "anvillib",
"version": "${version}",
"name": "AnvilLib",
"description": "ALEC!",
"authors": [
"LordMZTE",
"(tilera)"
],
"contact": {
"homepage": "https://anvilcraft.net/",
"sources": "https://git.tilera.org/anvilcraft/anvillib"
},
"license": "AGPL-3.0+ALEC",
"environment": "*",
"entrypoints": {
"main": [
"net.anvilcraft.anvillib.AnvilLibFabric"
]
},
"mixins": [
"anvillib.mixins.json",
"anvillib-common.mixins.json"
],
"depends": {
"minecraft": "1.18.2"
}
}

79
forge/build.gradle Normal file
View file

@ -0,0 +1,79 @@
plugins {
id "com.github.johnrengelman.shadow" version "7.1.2"
}
architectury {
platformSetupLoomIde()
forge()
}
loom {
accessWidenerPath = project(":common").loom.accessWidenerPath
forge {
convertAccessWideners = true
extraAccessWideners.add loom.accessWidenerPath.get().asFile.name
mixinConfig "anvillib-common.mixins.json"
mixinConfig "anvillib.mixins.json"
}
}
configurations {
common
shadowCommon // Don't use shadow from the shadow plugin since it *excludes* files.
compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common
developmentForge.extendsFrom common
}
dependencies {
forge "net.minecraftforge:forge:${rootProject.forge_version}"
modImplementation "software.bernie.geckolib:geckolib-forge-1.18:3.0.57"
common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false }
}
processResources {
inputs.property "version", project.version
filesMatching("META-INF/mods.toml") {
expand "version": project.version
}
}
shadowJar {
exclude "fabric.mod.json"
exclude "architectury.common.json"
configurations = [project.configurations.shadowCommon]
archiveClassifier = "dev-shadow"
}
remapJar {
input.set shadowJar.archiveFile
dependsOn shadowJar
}
sourcesJar {
def commonSources = project(":common").sourcesJar
dependsOn commonSources
from commonSources.archiveFile.map { zipTree(it) }
}
components.java {
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
skip()
}
}
publishing {
publications {
mavenForge(MavenPublication) {
artifactId = rootProject.archives_base_name + "-" + project.name
from components.java
}
}
}

1
forge/gradle.properties Normal file
View file

@ -0,0 +1 @@
loom.platform=forge

View file

@ -0,0 +1,10 @@
package net.anvilcraft.anvillib;
import net.minecraftforge.fml.common.Mod;
@Mod(AnvilLib.MODID)
public class AnvilLibForge {
public AnvilLibForge() {
AnvilLib.initialize();
}
}

View file

@ -0,0 +1,21 @@
package net.anvilcraft.anvillib.client;
import net.anvilcraft.anvillib.AnvilLib;
import net.anvilcraft.anvillib.event.AddEntityRenderLayersEvent;
import net.anvilcraft.anvillib.event.Bus;
import net.anvilcraft.anvillib.mixin.forge.accessor.AddLayersAccessor;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.EntityRenderersEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
@EventBusSubscriber(
modid = AnvilLib.MODID, bus = EventBusSubscriber.Bus.MOD, value = { Dist.CLIENT }
)
public class ClientEventHandler {
@SubscribeEvent
public static void onAddLayers(EntityRenderersEvent.AddLayers ev) {
Bus.MAIN.fire(new AddEntityRenderLayersEvent(((AddLayersAccessor) ev).getSkinMap()
));
}
}

View file

@ -0,0 +1,16 @@
package net.anvilcraft.anvillib.mixin.forge.accessor;
import java.util.Map;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraftforge.client.event.EntityRenderersEvent.AddLayers;
@Mixin(AddLayers.class)
public interface AddLayersAccessor {
@Accessor(remap = false)
public Map<String, EntityRenderer<? extends PlayerEntity>> getSkinMap();
}

View file

@ -1,27 +1,21 @@
modLoader = "javafml" modLoader = "javafml"
loaderVersion = "[40,)" loaderVersion = "[40,)"
#issueTrackerURL = ""
license = "AGPL-3.0+ALEC" license = "AGPL-3.0+ALEC"
issueTrackerURL = "https://git.tilera.org/Anvilcraft/anvillib/issues"
[[mods]] [[mods]]
modId = "anvillib" modId = "anvillib"
version = "${version}" version = "${version}"
displayName = "anvillib" displayName = "AnvilLib"
displayURL = "https://anvilcraft.net/"
#credits = ""
authors = "LordMZTE, (tilera)" authors = "LordMZTE, (tilera)"
description = ''' description = '''
Core for Notex 4. AnvilLib library mod
Includes recipes and tweaks.
''' '''
#logoFile = ""
[[dependencies.anvillib]] [[dependencies.anvillib]]
modId = "forge" modId = "forge"
mandatory = true mandatory = true
versionRange = "[40,)" versionRange = "[40,)"
ordering = "NONE" ordering = "NONE"
side = "BOTH" side = "BOTH"
@ -39,3 +33,4 @@ mandatory = true
versionRange = "[3.0.57,)" versionRange = "[3.0.57,)"
ordering = "NONE" ordering = "NONE"
side = "BOTH" side = "BOTH"

View file

@ -0,0 +1,13 @@
{
"required": true,
"package": "net.anvilcraft.anvillib.mixin.forge",
"compatibilityLevel": "JAVA_17",
"minVersion": "0.8",
"client": [],
"mixins": [
"accessor.AddLayersAccessor"
],
"injectors": {
"defaultRequire": 1
}
}

View file

@ -1,23 +1,16 @@
# Done to increase the memory available to gradle. # Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G org.gradle.jvmargs=-Xmx2G
# tell architectury loom that this project is a forge project. minecraft_version=1.18.2
# this will enable us to use the "forge" dependency. enabled_platforms=fabric,forge
# using archloom without this is possible and will give you a
# "standard" loom installation with some extra features.
loom.platform=forge
# Base properties #architectury_version=4.11.93
# minecraft version fabric_loader_version=0.14.23
minecraft_version=1.18.2 fabric_api_version=0.76.0+1.18.2
# forge version, latest version can be found on https://files.minecraftforge.net/ forge_version=1.18.2-40.2.10
forge_version=1.18.2-40.2.1
# yarn, latest version can be found on https://fabricmc.net/develop/
yarn_mappings=1.18.2+build.4
# Mod Properties mod_version=0.2.0
mod_version=0.1.1 maven_group=net.anvilcraft
maven_group=net.anvilcraft archives_base_name=anvillib-18
archives_base_name=anvillib-18 mod_id=anvillib
mod_id=anvillib mod_author=LordMZTE, (tilera)
mod_author=LordMZTE

View file

@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View file

@ -1,10 +1,14 @@
pluginManagement { pluginManagement {
// when using additional gradle plugins like shadow,
// add their repositories to this list!
repositories { repositories {
maven { url "https://maven.fabricmc.net/" } maven { url "https://maven.fabricmc.net/" }
maven { url "https://maven.architectury.dev/" } maven { url "https://maven.architectury.dev/" }
maven { url "https://files.minecraftforge.net/maven/" } maven { url "https://maven.minecraftforge.net/" }
gradlePluginPortal() gradlePluginPortal()
} }
} }
include("common")
include("fabric")
include("forge")
rootProject.name = "anvillib"

View file

@ -1,19 +0,0 @@
package net.anvilcraft.anvillib.cosmetics;
import net.anvilcraft.anvillib.AnvilLib;
import net.minecraft.client.render.entity.PlayerEntityRenderer;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.EntityRenderersEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
@EventBusSubscriber(modid = AnvilLib.MODID, bus = Bus.MOD, value = { Dist.CLIENT })
public class ClientEventHandler {
@SubscribeEvent
public static void clientSetup(EntityRenderersEvent.AddLayers event) {
for (String skin : event.getSkins())
if (event.getSkin(skin) instanceof PlayerEntityRenderer render)
render.addFeature(new CosmeticFeatureRenderer(render, skin));
}
}

View file

@ -1,3 +0,0 @@
public net.minecraft.world.item.crafting.Ingredient f_43902_ # Ingredient.entries
public net.minecraft.world.item.crafting.Ingredient$TagValue f_43959_ # Ingredient$TagEntry.tag
public net.minecraft.world.item.crafting.Ingredient$ItemValue f_43951_ # Ingredient$StackEntry.stack