Skip to content

Commit

Permalink
SpriteHelper: MOved the leaves from MacawFences & MacawFences' Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Xelbayria committed Dec 31, 2024
1 parent 0b0296f commit d8d48a6
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 246 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,45 @@ public static void addHardcodedSprites() {
addOptional("minecraft:mushroom_stem", "_side", "minecraft:block/mushroom_stem");
addOptional("minecraft:mushroom_stem", "_top", "minecraft:block/mushroom_stem");

// Cultural Delights
// Leaves
addOptional("culturaldelights:fruiting_avocado_leaves", "_leaves", "culturaldelights:block/fruiting_avocado_leaves_0");

// Fruitful Fun
// Leaves
addOptional("fruitfulfun:apple_leaves", "_leaves", "minecraft:block/oak_leaves");

// Vinery
// Leaves
addOptional("vinery:apple_leaves", "_leaves", "vinery:block/apple_leaves_0");

// Meadow
// Leaves
addOptional("meadow:pine_leaves", "_leaves", "meadow:block/pine_leaves_1");

// Autumnity
// Leaves
addOptional("autumnity:red_maple_leaves", "_leaves", "autumnity:block/maple_leaves");
addOptional("autumnity:orange_maple_leaves", "_leaves", "autumnity:block/maple_leaves");
addOptional("autumnity:yellow_maple_leaves", "_leaves", "autumnity:block/maple_leaves");

// Blue Skies
// Leaves
addOptional("blue_skies:comet_leaves", "_leaves", "blue_skies:block/comet_leaves_grown");

// Aether Redux
// Leaves
addOptional("aether_redux:azure_fieldsproot_leaves", "_leaves", "aether_redux:block/natural/fieldsproot_leaves");

// Integrated Dynamics
// Leaves
addOptional("integrateddynamics:menril_leaves", "_leaves", "integrateddynamics:block/menril_leaves_fancy");

// Malum
// Leaves
addOptional("malum:budding_soulwood_leaves", "_leaves", "malum:block/soulwood_leaves");
addOptional("malum:azure_runewood_leaves", "_leaves", "malum:block/runewood_leaves");

// Oh The Biomes We've Gone
// Leaves
addOptional("biomeswevegone:aspen_leaves", "_leaves", "biomeswevegone:block/aspen/leaves");
Expand Down Expand Up @@ -201,6 +240,7 @@ public static void addHardcodedSprites() {
// Leaves
addOptional("twilightforest:beanstalk_leaves", "_leaves", "minecraft:block/azalea_leaves");
addOptional("twilightforest:thorn_leaves", "_leaves", "minecraft:block/oak_leaves");
addOptional("twilightforest:dark_leaves", "_leaves", "twilightforest:block/darkwood_leaves");

// Regions Unexplored
addOptional("regions_unexplored:eucalyptus_log", "_side", EveryCompat.MOD_ID + ":block/regions_unexplored/eucalyptus_log");
Expand All @@ -224,6 +264,10 @@ public static void addHardcodedSprites() {
addOptional("endlessbiomes:penumbra_stem", "_top", "endlessbiomes:block/penumbrallogtopnewest");
addOptional("endlessbiomes:stripped_penumbra_stem", "_side", "endlessbiomes:block/strippedpenumbralogsidenewest");
addOptional("endlessbiomes:stripped_penumbra_stem", "_top", "endlessbiomes:block/strippedpenumbralogtopnewest");
// Leaves
addOptional("endlessbiomes:glowing_penumbral_leaves", "_leaves", "endlessbiomes:block/penumbralleavesglowing");
addOptional("endlessbiomes:penumbral_leaves", "_leaves", "endlessbiomes:block/penumbralleavesnewest");


// Gardens Of The Dead
addOptional("gardens_of_the_dead:whistlecane", "_side", "gardens_of_the_dead:block/whistlecane_block");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.mehvahdjukaar.every_compat.api.RenderLayer;
import net.mehvahdjukaar.every_compat.api.SimpleEntrySet;
import net.mehvahdjukaar.every_compat.api.SimpleModule;
import net.mehvahdjukaar.every_compat.misc.SpriteHelper;
import net.mehvahdjukaar.moonlight.api.set.leaves.LeavesType;
import net.mehvahdjukaar.moonlight.api.set.leaves.LeavesTypeRegistry;
import net.mehvahdjukaar.moonlight.api.set.wood.WoodType;
Expand Down Expand Up @@ -131,107 +132,15 @@ public MacawFencesModule(String modId) {
.setTabKey(tab)
.defaultRecipe()
.copyParentTint()
.addModelTransform(m -> m.addModifier((s, id, l) -> {
/*
* EveryComp's code don't account for "mcwfences:block/oak_leaves" when the mod could have used
* "minecraft:block/oak_leaves" for texturing. Dev said using "minecraft:block/oak_leaves" lead
* to problems
*/
String namespace = l.getNamespace();
String typeName = l.getTypeName();
switch (namespace) {
case "culturaldelights" -> {
if (typeName.equals("fruiting_avocado"))
return LeavesPath("fruiting_avocado_leaves_0", "", s, l);
}
case "fruitfulfun" -> {
if (typeName.equals("apple"))
return LeavesPath("oak_leaves", "", s, l, "minecraft");
}
case "vinery" -> {
if (typeName.equals("apple")) {
return LeavesPath("apple_leaves_0", "", s, l);
}
}
case "meadow" -> {
if (typeName.equals("pine"))
return LeavesPath("pine_leaves_1", "", s, l);
}
case "chipped" -> {
return LeavesPath("","", s, l, "", true);
}
case "regions_unexplored" -> {
switch (typeName) {
case "alpha" -> {
return LeavesPath("alpha_oak_leaves", "", s, l);
}
case "apple_oak" -> {
return LeavesPath("apple_oak_leaves_stage_0", "", s, l);
}
case "small_oak" -> {
return s.replace("\"mcwfences:block/oak_leaves\"",
"\"minecraft:block/oak_leaves\"");
}
case "palm" -> {
return LeavesPath("palm_leaves_side", "", s, l);
}
}
}
case "malum" -> {
switch (typeName) {
case "budding_soulwood" -> {
return LeavesPath("","soulwood", s, l);
}
case "azure_runewood" -> {
return LeavesPath("", "runewood", s, l);
}
}
return LeavesPath("", l.getTypeName(), s, l);
}
}
return LeavesPath("", "", s, l);
}))
.addModelTransform(m -> m.replaceWithTextureFromChild("mcwfences:block/oak_leaves",
"leaves", SpriteHelper.LOOKS_LIKE_LEAF_TEXTURE))
.setRenderType(RenderLayer.CUTOUT_MIPPED)
.build();
this.addEntry(hedges);
}

public String LeavesPath(String leavesName, String folderName, String s, LeavesType l) {
return LeavesPath(leavesName, folderName, s, l,"", false);
}

public String LeavesPath(String leavesName, String folderName, String s, LeavesType l, String namespace) {
return LeavesPath(leavesName, folderName, s, l, namespace,false);
}

public String LeavesPath(String leavesName, String folderName, String s, LeavesType l, String namespace, boolean has_CHIPPED) {
String path = (namespace.isBlank()) ? "\"" + l.getNamespace() : "\"" + namespace;
path += ":block/";

String LeavesTypeName = l.getTypeName();
String folder;
if (!leavesName.isEmpty()) {
if (!folderName.isEmpty()) path += folderName + "/";

return s.replace("\"mcwfences:block/oak_leaves\"",
path + leavesName + "\"");
}
else if (!folderName.isEmpty()) { // only for blue_skies
folder = folderName + "/";
}
else if (has_CHIPPED) { // only for chipped
folder = LeavesTypeName.replaceAll("cherry_|frosted_|dead_|golden_|apple_|magenta_|flower_|red_|white_|orange_",
"") + "_leaves/";
}
else folder = "";

return s.replace("\"mcwfences:block/oak_leaves\"",
path + folder + LeavesTypeName + "_leaves"+ "\"");
}

public static class WiredFence extends FenceBlock {


public WiredFence(Properties properties) {
super(properties);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import net.mehvahdjukaar.every_compat.api.RenderLayer;
import net.mehvahdjukaar.every_compat.api.SimpleEntrySet;
import net.mehvahdjukaar.every_compat.api.SimpleModule;
import net.mehvahdjukaar.every_compat.misc.SpriteHelper;
import net.mehvahdjukaar.moonlight.api.resources.BlockTypeResTransformer;
import net.mehvahdjukaar.moonlight.api.set.leaves.LeavesType;
import net.mehvahdjukaar.moonlight.api.set.leaves.LeavesTypeRegistry;
import net.mehvahdjukaar.moonlight.api.set.wood.WoodType;
Expand Down Expand Up @@ -116,161 +118,11 @@ public MacawFencesModule(String modId) {
.setTabKey(tab)
.copyParentTint()
.defaultRecipe()
.addModelTransform(m -> m.addModifier((s, id, l) -> {
/*
* EveryComp's code don't account for "mcwfences:block/oak_leaves" when the mod could have used
* "minecraft:block/oak_leaves" for texturing. Dev said using "minecraft:block/oak_leaves" lead
* to problems
*/
String namespace = l.getNamespace();
String typeName = l.getTypeName();
switch (namespace) {
case "dreamy_cottage" -> {
if (typeName.equals("white_oak"))
return LeavesPath("whiteoakleaves", "", s, l);
}
case "culturaldelights" -> {
if (typeName.equals("fruiting_avocado"))
return LeavesPath("fruiting_avocado_leaves_0", "", s, l);
}
case "fruitfulfun" -> {
if (typeName.equals("apple"))
return LeavesPath("oak_leaves", "", s, l, "minecraft");
}
case "vinery" -> {
if (typeName.equals("apple")) {
return LeavesPath("apple_leaves_0", "", s, l);
}
}
case "meadow" -> {
if (typeName.equals("pine"))
return LeavesPath("pine_leaves_1", "", s, l);
}
case "autumnity" -> {
if (typeName.equals("red_maple")||typeName.equals("orange_maple")||typeName.equals("yellow_maple"))
return LeavesPath("maple_leaves", "", s, l);
}
case "chipped" -> {
return LeavesPath("","", s, l, "", true);
}
case "blue_skies" -> {
if (typeName.equals("comet"))
return LeavesPath("comet_leaves_grown", "leaves", s, l);

return LeavesPath("", "leaves", s, l);
}
case "regions_unexplored" -> {
switch (typeName) {
case "alpha" -> {
return LeavesPath("alpha_oak_leaves", "", s, l);
}
case "apple_oak" -> {
return LeavesPath("apple_oak_leaves_stage_0", "", s, l);
}
case "small_oak" -> {
return s.replace("\"mcwfences:block/oak_leaves\"",
"\"minecraft:block/oak_leaves\"");
}
case "flowering" -> {
return s.replace("\"mcwfences:block/oak_leaves\"",
"\"regions_unexplored:item/flowering_leaves\"");
}
case "palm" -> {
return LeavesPath("palm_leaves_side", "", s, l);
}
}
}
case "endlessbiomes" -> {
switch (typeName) {
case "glowing_penumbral" -> {
return LeavesPath("penumbralleavesglowing", "", s, l);
}
case "penumbral" -> {
return LeavesPath("penumbralleavesnewest", "", s, l);
}
}
}
case "aether" -> {
return LeavesPath("", "natural", s, l);
}
case "aether_redux" -> {
if (typeName.equals("azure_fieldsproot")) {
return LeavesPath("fieldsproot_leaves", "natural", s, l);
}
return LeavesPath("", "natural", s, l);
}
case "malum" -> {
switch (typeName) {
case "budding_soulwood" -> {
return LeavesPath("","soulwood", s, l);
}
case "azure_runewood" -> {
return LeavesPath("", "runewood", s, l);
}
}
return LeavesPath("", l.getTypeName(), s, l);
}
case "twilightforest" -> {
switch (typeName) {
case "beanstalk" -> {
return LeavesPath("azalea_leaves", "", s, l, "minecraft");
}
case "canopy" -> {
return LeavesPath("spruce_leaves", "", s, l, "minecraft");
}
case "dark" -> {
return LeavesPath("darkwood_leaves", "", s, l);
}
case "mangrove" -> {
return LeavesPath("birch_leaves", "", s, l, "minecraft");
}
case "rainbow_oak", "twilight_oak", "thorn" -> {
return LeavesPath("oak_leaves", "", s, l, "minecraft");
}
}
}
case "integrateddynamics" -> {
return LeavesPath("menril_leaves_fancy", "", s, l);
}
}
return LeavesPath("", "", s, l);
}))
.addModelTransform(m -> m.replaceWithTextureFromChild("mcwfences:block/oak_leaves",
"leaves", SpriteHelper.LOOKS_LIKE_LEAF_TEXTURE))
.setRenderType(RenderLayer.CUTOUT_MIPPED)
.build();
this.addEntry(hedges);
}

public String LeavesPath(String leavesName, String folderName, String s, LeavesType l) {
return LeavesPath(leavesName, folderName, s, l,"", false);
}

public String LeavesPath(String leavesName, String folderName, String s, LeavesType l, String namespace) {
return LeavesPath(leavesName, folderName, s, l, namespace,false);
}

public String LeavesPath(String leavesName, String folderName, String s, LeavesType l, String namespace, boolean has_CHIPPED) {
String path = (namespace.isBlank()) ? "\"" + l.getNamespace() : "\"" + namespace;
path += ":block/";

String LeavesTypeName = l.getTypeName();
String folder;
if (!leavesName.isEmpty()) { // unique name for leaves texture
if (!folderName.isEmpty()) path += folderName + "/";

return s.replace("\"mcwfences:block/oak_leaves\"",
path + leavesName + "\"");
}
else if (!folderName.isEmpty()) { // only for blue_skies
folder = folderName + "/";
}
else if (has_CHIPPED) { // only for chipped
folder = LeavesTypeName.replaceAll(
"cherry_|frosted_|dead_|golden_|apple_|magenta_|flower_|red_|white_|orange_",
"") + "_leaves/";
}
else folder = "";

return s.replace("\"mcwfences:block/oak_leaves\"",
path + folder + LeavesTypeName + "_leaves\"");
}
}

0 comments on commit d8d48a6

Please sign in to comment.