1.21 Port & Smart Azalea Leaves

- Closes #51
This commit is contained in:
Martin Prokoph
2024-06-18 20:08:31 +02:00
parent 3e24b1ac0a
commit 1ad05aa6bf
10 changed files with 117 additions and 33 deletions

View File

@@ -1,6 +1,6 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.5-SNAPSHOT" apply false
id "dev.architectury.loom" version "1.6-SNAPSHOT" apply false
id "me.shedaniel.unified-publishing" version "0.1.+" apply false
}
@@ -26,7 +26,10 @@ subprojects {
// The following line declares the mojmap mappings, you may use other mappings as well
//mappings loom.officialMojangMappings()
// The following line declares the yarn mappings you may select this one as well.
mappings "net.fabricmc:yarn:${rootProject.yarn_mappings}:v2"
mappings loom.layered {
it.mappings("net.fabricmc:yarn:$rootProject.yarn_mappings:v2")
it.mappings("dev.architectury:yarn-mappings-patch-neoforge:$rootProject.yarn_mappings_patch_neoforge_version")
}
}
}
@@ -49,7 +52,7 @@ allprojects {
tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
options.release = 17
options.release = 21
}
ext {
releaseChangelog = {

View File

@@ -0,0 +1,6 @@
{
"parent": "minecraft:block/leaves_notint",
"textures": {
"all": "minecraft:block/azalea_leaves"
}
}

View File

@@ -0,0 +1,6 @@
{
"parent": "minecraft:block/leaves_notint",
"textures": {
"all": "minecraft:block/flowering_azalea_leaves"
}
}

View File

@@ -0,0 +1,73 @@
{
"credit": "made by Motschen",
"parent": "block/block",
"textures": {
"particle": "#all"
},
"elements": [
{
"name": "main",
"from": [0, 0, 0],
"to": [16, 16, 16],
"faces": {
"north": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "north"},
"east": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "east"},
"south": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "south"},
"west": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "west"},
"up": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "up"},
"down": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "down"}
}
},
{
"name": "bottom",
"from": [0, 0.01, 0],
"to": [16, 0.01, 16],
"faces": {
"up": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "down"}
}
},
{
"name": "west",
"from": [0.01, 0, 0],
"to": [0.01, 16, 16],
"faces": {
"east": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "west"}
}
},
{
"name": "north",
"from": [0, 0, 0.01],
"to": [16, 16, 0.01],
"faces": {
"south": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "north"}
}
},
{
"name": "east",
"from": [15.99, 0, 0],
"to": [15.99, 16, 16],
"rotation": {"angle": 0, "axis": "y", "origin": [23, 8, 8]},
"faces": {
"west": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "east"}
}
},
{
"name": "south",
"from": [0, 0, 15.99],
"to": [16, 16, 15.99],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 23]},
"faces": {
"north": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "south"}
}
},
{
"name": "up",
"from": [0, 15.99, 0],
"to": [16, 15.99, 16],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 23, 8]},
"faces": {
"down": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "up"}
}
}
]
}

View File

@@ -13,7 +13,7 @@ public class CullLeavesClientFabric implements ClientModInitializer {
public void onInitializeClient() {
MidnightConfig.init("cullleaves", CullLeavesConfig.class);
FabricLoader.getInstance().getModContainer("cullleaves").ifPresent(modContainer -> {
ResourceManagerHelper.registerBuiltinResourcePack(new Identifier("cullleaves:smartleaves"), modContainer, ResourcePackActivationType.NORMAL);
ResourceManagerHelper.registerBuiltinResourcePack(Identifier.of("cullleaves:smartleaves"), modContainer, ResourcePackActivationType.NORMAL);
});
}
}

View File

@@ -1,23 +1,24 @@
org.gradle.jvmargs=-Xmx4096M
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
minecraft_version=1.21
yarn_mappings=1.21+build.2
enabled_platforms=fabric,neoforge
archives_base_name=cullleaves
mod_version=3.3.0
mod_version=3.4.0
maven_group=eu.midnightdust
release_type=release
curseforge_id=423254
modrinth_id=GNxdLCoP
midnightlib_version=1.5.3
sodium_version=mc1.20.4-0.5.8
midnightlib_version=1.5.7
sodium_version=mc1.21-0.5.9
fabric_loader_version=0.15.7
fabric_api_version=0.96.3+1.20.4
fabric_loader_version=0.15.11
fabric_api_version=0.100.1+1.21
neoforge_version=20.4.170
neoforge_version=21.0.14-beta
yarn_mappings_patch_neoforge_version = 1.21+build.4
quilt_loader_version=0.18.9
quilt_fabric_api_version=7.0.6+0.85.0-1.20.1

View File

@@ -28,7 +28,7 @@ dependencies {
neoForge "net.neoforged:neoforge:${rootProject.neoforge_version}"
// Remove the next line if you don't want to depend on the API
//modApi "dev.architectury:architectury-forge:${rootProject.architectury_version}"
modImplementation "maven.modrinth:midnightlib:1.5.2-neoforge"
modImplementation "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-neoforge"
//include "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-forge"
common(project(path: ":common", configuration: "namedElements")) { transitive false }
@@ -38,7 +38,7 @@ dependencies {
processResources {
inputs.property "version", project.version
filesMatching("META-INF/mods.toml") {
filesMatching("META-INF/neoforge.mods.toml") {
expand "version": project.version
}
}

View File

@@ -1,32 +1,35 @@
package eu.midnightdust.cullleaves.neoforge;
import net.minecraft.resource.DirectoryResourcePack;
import net.minecraft.resource.ResourcePackProfile;
import net.minecraft.resource.ResourcePackSource;
import net.minecraft.resource.ResourceType;
import net.minecraft.resource.*;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.ModList;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.event.AddPackFindersEvent;
import net.neoforged.neoforgespi.locating.IModFile;
@Mod.EventBusSubscriber(modid = "cullleaves", bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
import java.util.Optional;
@EventBusSubscriber(modid = "cullleaves", bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public class CullLeavesClientEvents {
@SubscribeEvent
public static void addPackFinders(AddPackFindersEvent event) {
if (event.getPackType() == ResourceType.CLIENT_RESOURCES) {
registerResourcePack(event, new Identifier("cullleaves", "smartleaves"), false);
registerResourcePack(event, Identifier.of("cullleaves", "smartleaves"), false);
}
}
private static void registerResourcePack(AddPackFindersEvent event, Identifier id, boolean alwaysEnabled) {
event.addRepositorySource((profileAdder -> {
event.addRepositorySource(((profileAdder) -> {
IModFile file = ModList.get().getModFileById(id.getNamespace()).getFile();
try {
ResourcePackProfile.PackFactory pack = new DirectoryResourcePack.DirectoryBackedFactory(file.findResource("resourcepacks/" + id.getPath()), true);
profileAdder.accept(ResourcePackProfile.create(id.toString(), Text.of(id.getNamespace()+"/"+id.getPath()), alwaysEnabled, pack, ResourceType.CLIENT_RESOURCES, ResourcePackProfile.InsertionPosition.TOP, ResourcePackSource.BUILTIN));
ResourcePackProfile.PackFactory pack = new DirectoryResourcePack.DirectoryBackedFactory(file.findResource("resourcepacks/" + id.getPath()));
ResourcePackInfo info = new ResourcePackInfo(id.toString(), Text.of(id.getNamespace()+"/"+id.getPath()), ResourcePackSource.BUILTIN, Optional.empty());
ResourcePackProfile packProfile = ResourcePackProfile.create(info, pack, ResourceType.CLIENT_RESOURCES, new ResourcePackPosition(alwaysEnabled, ResourcePackProfile.InsertionPosition.TOP, false));
if (packProfile != null) {
profileAdder.accept(packProfile);
}
} catch (NullPointerException e) {e.fillInStackTrace();}
}));
}

View File

@@ -2,19 +2,11 @@ package eu.midnightdust.cullleaves.neoforge;
import eu.midnightdust.cullleaves.config.CullLeavesConfig;
import eu.midnightdust.lib.config.MidnightConfig;
import net.neoforged.fml.IExtensionPoint;
import net.neoforged.fml.ModLoadingContext;
import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.client.ConfigScreenHandler;
import static net.neoforged.fml.IExtensionPoint.DisplayTest.IGNORESERVERONLY;
@Mod("cullleaves")
public class CullLeavesClientForge {
public CullLeavesClientForge() {
MidnightConfig.init("cullleaves", CullLeavesConfig.class);
ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(() -> IGNORESERVERONLY, (remote, server) -> true));
ModLoadingContext.get().registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory.class, () ->
new ConfigScreenHandler.ConfigScreenFactory((client, parent) -> MidnightConfig.getScreen(parent, "cullleaves")));
}
}

View File

@@ -34,5 +34,5 @@ side = "CLIENT"
modId = "midnightlib"
required = true
versionRange = "[1.0.0,)"
ordering = "BEFORE"
ordering = "AFTER"
side = "CLIENT"