Skip to content

Commit

Permalink
HardcodedBlockType: Huge Reorganized & Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Xelbayria committed Dec 23, 2024
1 parent 9996996 commit 146c54c
Showing 1 changed file with 117 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,70 +7,152 @@
// ugly mess. Too coupled with WoodTypes|LeavesTypes and too many hardcoded exceptions
public class HardcodedBlockType {

public static String woodidentify;
public static String woodTypeFromMod;
public static String leavesidentify;
public static String leavesTypeFromMod;
public static String modId;
public static String supportedBlockName;
public static String shortenedIdenfity;

@Nullable
public static Boolean isWoodBlockAlreadyRegistered(String blockName, WoodType woodType, String supportedModId, String shortenedId) {
String woodMod = woodType.getNamespace();
String woodTypeID = woodType.getId().toString();
public static Boolean isWoodBlockAlreadyRegistered(String blockName, WoodType woodType, String ModId, String shortenedId) {
woodTypeFromMod = woodType.getNamespace();
woodidentify = woodType.getId().toString();
modId = ModId;
supportedBlockName = blockName;
shortenedIdenfity = shortenedId;

//!! EXCLUDE ==========
// Discarding Dynamic Trees and its addons
if (isWoodRegistryOf("", "", "dynamictrees|dt", "", "")) return true;

// Better Nether & Better End have stripped_bark as stripped_wood but bark from Bewitchment caused EC to skip
if (woodMod.matches("betternether|betterend") && shortenedId.equals("bw")) return false;
// Garden-Of-The-dead's whistle & Snifferent already has branches, branches from Regions-Unexplored is not needed
if (isWoodRegistryOf("", "", "gardens_of_the_dead|snifferent", "", "branch")) return true;

// Discarding Dynamic Trees and its addons
if (woodMod.contains("dynamictrees") || woodMod.contains("dt")) return true;
// Nether's Exoticism already has branches, branches from Regions-Unexplored is not needed
if (isWoodRegistryOf("", "", "", "nethers_exoticism:jabuticaba", "branch")) return true;

// Quark & Woodworks have chest & trapped_chest. | is this needed? shouldnt it be covered by the next statements?
if (isWoodRegistryOf("", "abnww", "quark", "", "chest")) 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 ((woodMod.matches("gardens_of_the_dead|snifferent") ||
woodTypeID.equals("nethers_exoticism:jabuticaba")) && blockName.contains("branch"))
return true;

// Quark & Woodworks have chest & trapped_chest.
//is this needed? shouldnt it be covered by the next statements?
if (woodMod.equals("quark") && shortenedId.equals("abnww") && blockName.contains("chest")) return true;
//!! INCLUDE ==========
// Better Nether & Better End have stripped_bark as stripped_wood but bark from Bewitchment caused EC to skip
if (isWoodRegistryOf("", "bw", "betternether|betterend", "", "")) return false;

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

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

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

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

if (woodTypeID.equals("ecologics:azalea")) {
if (supportedModId.equals("quark")) return false; //ecologics and quark azalea. tbh not sure why needed
}
//also this is wrong
if (woodTypeID.equals("twilightforest:mangrove") && blockName.equals("mangrove_chest")) {
return false;//mangrove waaa so much pain
}
//ecologics and quark azalea. tbh not sure why needed
if (isWoodRegistryOf("quark", "", "", "ecologics:azalea", "")) return false;

//also this is wrong & //mangrove waaa so much pain (mehvahdjukaar
if (isWoodRegistryOf("", "", "", "twilightforest:mangrove", "mangrove_chest")) return false;

// what's the reason for below? | hardcoding
if (isWoodRegistryOf("", "af", "", "", "")) return false;

// Valhelsia Structure's blocks must be not be discarded
if (isWoodRegistryOf("", "vs", "", "", "")) return false;

// we always register everything for these (mehvahdjukaar)
if (isWoodRegistryOf("", "abnww", "architects_palette", "", "")) return false;

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") && woodMod.equals("architects_palette"))
return false; //we always register everything for these
if (isWoodRegistryOf("", "ap", "", "", "")) return false;

return null;
}

@Nullable
public static Boolean isLeavesBlockAlreadyRegistered(String blockName, LeavesType leavesType, String supportedModId, String shortenedId) {
String leaveMod = leavesType.getNamespace();
String leaveTypeID = leavesType.getId().toString();
leavesTypeFromMod = leavesType.getNamespace();
leavesidentify = leavesType.getId().toString();
modId = supportedModId;
supportedBlockName = blockName;
shortenedIdenfity = shortenedId;

//!! INCLUDE ==========
// Unrelated to Quark's ancient_leaves & Alex's Cave (ancient_leaves) should be included
if (supportedModId.equals("quark") && leaveTypeID.equals("alexscaves:ancient")) return false;
if (isLeavesRegistryOf("quark", "", "", "alexscaves:ancient", "")) return false;

// Macaw's Fences&Walls or MrCrayFish's Furniture - hedges will be skipped because Quark already has hedges
if (leaveMod.equals("quark") && (shortenedId.equals("mcf") || shortenedId.equals("cfm"))) return false;
if (isLeavesRegistryOf("", "mcf|cfm", "quark", "", "")) return false;

//!! EXCLUDE ==========


return null;
}

public static Boolean isWoodRegistryOf(String whichSupportedModId, String shortenedId, String woodtypeFromMod, String woodTypeId, String whichSupportedBlockName) {

String[] expressions = {
whichSupportedModId,
shortenedId,
woodtypeFromMod,
woodTypeId,
whichSupportedBlockName
};

String[] values = {
modId,
shortenedIdenfity,
woodTypeFromMod,
woodidentify,
supportedBlockName
};

for (int idx = 0; idx < values.length; idx++ ) {

if (!expressions[idx].isEmpty()) { // Skip the blank expressions
boolean isNotMatched = !values[idx].matches(expressions[idx]);
if (isNotMatched) return false;
}
}

return true;
}

public static Boolean isLeavesRegistryOf(String whichSupportedModId, String shortenedId, String woodtypeFromMod, String leavesTypeId, String whichSupportedBlockName) {

String[] expressions = {
whichSupportedModId,
shortenedId,
woodtypeFromMod,
leavesTypeId,
whichSupportedBlockName
};

String[] values = {
modId,
shortenedIdenfity,
leavesTypeFromMod,
leavesidentify,
supportedBlockName
};

for (int idx = 0; idx < values.length; idx++ ) {

if (!expressions[idx].isEmpty()) { // Skip the blank expressions
boolean isNotMatched = !values[idx].matches(expressions[idx]);
if (isNotMatched) return false;
}
}

return true;
}


}

0 comments on commit 146c54c

Please sign in to comment.