Skip to content

Commit

Permalink
cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
MehVahdJukaar committed Dec 14, 2024
1 parent ce5b7de commit d05720f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,11 @@ public boolean isEntryAlreadyRegistered(String name, BlockType woodType, Registr
String woodFrom = woodType.getNamespace();

String slashConvention = woodFrom + "/" + name; //quark/blossom_chair
String understoreConvention = woodFrom + "_" + name; //quark_blossom_chair
String underscoreConvention = woodFrom + "_" + name; //quark_blossom_chair

if (this.getAlreadySupportedMods().contains(woodFrom)) return true;

// ugly hardcoded stuff
if (woodType instanceof WoodType wt) {
Boolean hardcoded = HardcodedStuff.isWoodBlockAlreadyRegistered(name, wt, modId, shortenedId());
if (hardcoded != null) return hardcoded;
Expand All @@ -211,7 +212,7 @@ public boolean isEntryAlreadyRegistered(String name, BlockType woodType, Registr
if (woodFrom.equals(modId)) return true; //quark, blossom

if (registry.containsKey(new ResourceLocation(modId, name)) || //ones from the mod they are from. usually include vanilla types
registry.containsKey(new ResourceLocation(modId, understoreConvention))) return true;
registry.containsKey(new ResourceLocation(modId, underscoreConvention))) return true;

if (registry.containsKey(new ResourceLocation(woodFrom, name))) return true;

Expand All @@ -221,7 +222,7 @@ public boolean isEntryAlreadyRegistered(String name, BlockType woodType, Registr
if (c.woodsFrom().contains(woodFrom) && c.blocksFrom().contains(modId)) {
if (registry.containsKey(new ResourceLocation(compatModId, name))) return true;
if (registry.containsKey(new ResourceLocation(compatModId, slashConvention))) return true;
if (registry.containsKey(new ResourceLocation(compatModId, understoreConvention))) return true;
if (registry.containsKey(new ResourceLocation(compatModId, underscoreConvention))) return true;
}
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,74 +2,77 @@

import net.mehvahdjukaar.moonlight.api.set.leaves.LeavesType;
import net.mehvahdjukaar.moonlight.api.set.wood.WoodType;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.Nullable;

// ugly mess. Too coupled with wood types and too many hardcoded exceptions
public class HardcodedStuff {

@Nullable
public static Boolean isWoodBlockAlreadyRegistered(String name, WoodType woodType, String modId, String shortenedId) {
String woodFrom = woodType.getNamespace();
String woodNamespace = woodType.getNamespace();
String woodID = woodType.getId().toString();

// Better Nether & Better End have stripped_bark as stripped_wood but bark from Bewitchment caused EC to skip
if (woodFrom.matches("betternether|betterend") && shortenedId.equals("bw")) return false;
if (woodNamespace.matches("betternether|betterend") && shortenedId.equals("bw")) return false;

// Discarding Dynamic Trees and its addons
if (woodFrom.contains("dynamictrees") || woodFrom.contains("dt")) return true;
if (woodNamespace.contains("dynamictrees") || woodNamespace.contains("dt")) return true;

// Garden-Of-The-dead's whistle must be skipped for branches from Regions-Unexplored
// Nether's Exoticism & Snifferent already has branches, branches from Regions-Unexplored is not needed
if ((woodFrom.matches("gardens_of_the_dead|snifferent") ||
woodType.getId().toString().equals("nethers_exoticism:jabuticaba")) && name.contains("branch"))
if ((woodNamespace.matches("gardens_of_the_dead|snifferent") ||
woodID.equals("nethers_exoticism:jabuticaba")) && name.contains("branch"))
return true;

// Quark & Woodworks have chest & trapped_chest.
//is this needed? shouldnt it be covered by the next statements?
if (woodFrom.equals("quark") && shortenedId.equals("abnww") && name.contains("chest")) return true;
if (woodNamespace.equals("quark") && shortenedId.equals("abnww") && name.contains("chest")) return true;

// Create's windows will be skipped blc [Let's do] Blooming Nature & Meadow already has windows
if ((woodFrom.equals("bloomingnature") || woodFrom.equals("meadow")) && name.contains("window")) return false;
if ((woodNamespace.equals("bloomingnature") || woodNamespace.equals("meadow")) && name.contains("window")) return false;

// ArchitectPalette's boards will be skipped blc Upgrade-Aqautic already has boards but have no recipes &
// no item in CreativeMode
if (woodFrom.equals("upgrade_aquatic") && (name.equals("driftwood_boards") || name.equals("river_boards")))
if (woodNamespace.equals("upgrade_aquatic") && (name.equals("driftwood_boards") || name.equals("river_boards")))
return false;

// Similar to above, Architect's Palette - boards will be skipped due to the existing boards in Autumnity
if (woodFrom.equals("autumnity") && name.equals("maple_boards")) return false;
if (woodNamespace.equals("autumnity") && name.equals("maple_boards")) return false;

// check if TerraFirmaCraft (tfc) mod exist, then won't discards wood types
if (woodFrom.equals("tfc")) return false;
if (woodNamespace.equals("tfc")) return false;

if (woodType.getId().toString().equals("ecologics:azalea")) {
if (woodID.equals("ecologics:azalea")) {
if (modId.equals("quark")) return false; //ecologics and quark azalea. tbh not sure why needed
}
if (woodType.getId().toString().equals("twilightforest:mangrove")) {
if (woodID.equals("twilightforest:mangrove")) {
return name.equals("mangrove_chest");//mangrove waaa so much pain
}

if (woodType.getId().toString().equals("architects_palette:twisted")) {
//whats all this code repetition?
if (woodID.equals("architects_palette:twisted")) {
return name.equals("vct:twisted_crafting_table");
}
if (woodType.getId().toString().equals("biomesoplenty:fir")) {
if (woodID.equals("biomesoplenty:fir")) {
return name.equals("vct:fir_crafting_table");
}
if (woodType.getId().toString().equals("biomesoplenty:jacaranda")) {
if (woodID.equals("biomesoplenty:jacaranda")) {
return name.equals("vct:jacaranda_crafting_table");
}
if (woodType.getId().toString().equals("biomesoplenty:maple")) {
if (woodID.equals("biomesoplenty:maple")) {
return name.equals("vct:maple_crafting_table");
}
if (woodType.getId().toString().equals("ecologics:azalea")) {
if (woodID.equals("ecologics:azalea")) {
return name.equals("vct:azalea_crafting_table");
}
if (woodType.getId().toString().equals("ecologics:walnut")) {
if (woodID.equals("ecologics:walnut")) {
return name.equals("vct:walnut_crafting_table");
}
if (shortenedId.equals("af")) return false; //hardcoding
// if (this.shortenedId().equals("ap")) return false; //hardcoding dont remember why i had this. Incase you want o
if (shortenedId.equals("vs")) return false; //we always register everything for these
if (shortenedId.equals("abnww") && woodFrom.equals("architects_palette"))
if (shortenedId.equals("abnww") && woodNamespace.equals("architects_palette"))
return false; //we always register everything for these

return null;
Expand Down

0 comments on commit d05720f

Please sign in to comment.