mirror of
https://github.com/AlmostReliable/almostunified.git
synced 2024-11-24 16:48:00 -05:00
fix automated hiding of stone strata variants
This commit is contained in:
parent
461b93f60e
commit
ab51ba3204
4 changed files with 26 additions and 15 deletions
|
@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog],
|
||||
and this project adheres to [Semantic Versioning].
|
||||
|
||||
## Unreleased
|
||||
|
||||
### Fixed
|
||||
- fixed automatic hiding of stone strata variants (bug introduced in 0.9.0)
|
||||
- fixed a bug where stone stratas were not correctly identified (Fabric only)
|
||||
|
||||
## [0.9.1] - 2024-03-17
|
||||
|
||||
### Added
|
||||
|
|
|
@ -45,7 +45,7 @@ public final class StoneStrataHandler {
|
|||
var stoneStrataTagMap = tagMap.filtered(stoneStrataTags::contains, item -> true);
|
||||
Pattern tagMatcher = Pattern.compile(switch (AlmostUnifiedPlatform.INSTANCE.getPlatform()) {
|
||||
case FORGE -> "forge:ores/.+";
|
||||
case FABRIC -> "(c:ores/.+|c:.+_ores)";
|
||||
case FABRIC -> "(c:ores/.+|(minecraft|c):.+_ores)";
|
||||
});
|
||||
return new StoneStrataHandler(stoneStrataIds, tagMatcher, stoneStrataTagMap);
|
||||
}
|
||||
|
|
|
@ -38,25 +38,32 @@ public final class HideHelper {
|
|||
var itemsByTag = tagMap.getEntriesByTag(unifyTag);
|
||||
if (Utils.allSameNamespace(itemsByTag)) continue;
|
||||
|
||||
ResourceLocation preferredItem = repMap.getPreferredItemForTag(unifyTag, $ -> true);
|
||||
if (preferredItem == null) continue;
|
||||
// it's not enough to exclude the preferred item from hiding because it would hide stone stratas
|
||||
Set<ResourceLocation> replacements = new HashSet<>();
|
||||
for (ResourceLocation item : itemsByTag) {
|
||||
ResourceLocation replacement = repMap.getReplacementForItem(item);
|
||||
replacements.add(replacement == null ? item : replacement);
|
||||
}
|
||||
|
||||
Set<ResourceLocation> itemsToHide = getItemsToHide(unifyTag, itemsByTag, preferredItem);
|
||||
if (itemsToHide == null) continue;
|
||||
hidingMap.putAll(unifyTag, itemsToHide);
|
||||
Set<ResourceLocation> itemsToHide = getItemsToHide(unifyTag, itemsByTag, replacements);
|
||||
if (itemsToHide != null) {
|
||||
hidingMap.putAll(unifyTag, itemsToHide);
|
||||
}
|
||||
|
||||
Set<ResourceLocation> refItemsToHide = getRefItemsToHide(unifyTag, ownerships, preferredItem);
|
||||
hidingMap.putAll(unifyTag, refItemsToHide);
|
||||
Set<ResourceLocation> refItemsToHide = getRefItemsToHide(unifyTag, ownerships, replacements);
|
||||
if (!refItemsToHide.isEmpty()) {
|
||||
hidingMap.putAll(unifyTag, refItemsToHide);
|
||||
}
|
||||
}
|
||||
|
||||
return hidingMap;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Set<ResourceLocation> getItemsToHide(UnifyTag<Item> unifyTag, Set<ResourceLocation> itemsByTag, ResourceLocation preferredItem) {
|
||||
private static Set<ResourceLocation> getItemsToHide(UnifyTag<Item> unifyTag, Set<ResourceLocation> itemsByTag, Set<ResourceLocation> replacements) {
|
||||
Set<ResourceLocation> itemsToHide = new HashSet<>();
|
||||
for (ResourceLocation item : itemsByTag) {
|
||||
if (!item.equals(preferredItem)) {
|
||||
if (!replacements.contains(item)) {
|
||||
itemsToHide.add(item);
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +80,7 @@ public final class HideHelper {
|
|||
return itemsToHide;
|
||||
}
|
||||
|
||||
private static Set<ResourceLocation> getRefItemsToHide(UnifyTag<Item> unifyTag, TagOwnerships ownerships, ResourceLocation preferredItem) {
|
||||
private static Set<ResourceLocation> getRefItemsToHide(UnifyTag<Item> unifyTag, TagOwnerships ownerships, Set<ResourceLocation> replacements) {
|
||||
var refTags = ownerships.getRefsByOwner(unifyTag);
|
||||
Set<ResourceLocation> refItemsToHide = new HashSet<>();
|
||||
|
||||
|
@ -82,7 +89,7 @@ public final class HideHelper {
|
|||
|
||||
BuiltInRegistries.ITEM.getTagOrEmpty(asTagKey).forEach(holder -> {
|
||||
ResourceLocation item = BuiltInRegistries.ITEM.getKey(holder.value());
|
||||
if (item.equals(preferredItem)) return;
|
||||
if (replacements.contains(item)) return;
|
||||
refItemsToHide.add(item);
|
||||
});
|
||||
|
||||
|
|
|
@ -130,9 +130,7 @@ public final class Defaults {
|
|||
}
|
||||
|
||||
public static List<String> getIgnoredRecipeTypes(AlmostUnifiedPlatform.Platform platform) {
|
||||
return switch (platform) {
|
||||
default -> List.of("cucumber:shaped_tag");
|
||||
};
|
||||
return List.of("cucumber:shaped_tag");
|
||||
}
|
||||
|
||||
public static JsonCompare.CompareSettings getDefaultDuplicateRules(AlmostUnifiedPlatform.Platform platform) {
|
||||
|
|
Loading…
Reference in a new issue