mirror of
https://github.com/AlmostReliable/almostunified.git
synced 2024-11-28 10:35:38 -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],
|
The format is based on [Keep a Changelog],
|
||||||
and this project adheres to [Semantic Versioning].
|
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
|
## [0.9.1] - 2024-03-17
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -45,7 +45,7 @@ public final class StoneStrataHandler {
|
||||||
var stoneStrataTagMap = tagMap.filtered(stoneStrataTags::contains, item -> true);
|
var stoneStrataTagMap = tagMap.filtered(stoneStrataTags::contains, item -> true);
|
||||||
Pattern tagMatcher = Pattern.compile(switch (AlmostUnifiedPlatform.INSTANCE.getPlatform()) {
|
Pattern tagMatcher = Pattern.compile(switch (AlmostUnifiedPlatform.INSTANCE.getPlatform()) {
|
||||||
case FORGE -> "forge:ores/.+";
|
case FORGE -> "forge:ores/.+";
|
||||||
case FABRIC -> "(c:ores/.+|c:.+_ores)";
|
case FABRIC -> "(c:ores/.+|(minecraft|c):.+_ores)";
|
||||||
});
|
});
|
||||||
return new StoneStrataHandler(stoneStrataIds, tagMatcher, stoneStrataTagMap);
|
return new StoneStrataHandler(stoneStrataIds, tagMatcher, stoneStrataTagMap);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,25 +38,32 @@ public final class HideHelper {
|
||||||
var itemsByTag = tagMap.getEntriesByTag(unifyTag);
|
var itemsByTag = tagMap.getEntriesByTag(unifyTag);
|
||||||
if (Utils.allSameNamespace(itemsByTag)) continue;
|
if (Utils.allSameNamespace(itemsByTag)) continue;
|
||||||
|
|
||||||
ResourceLocation preferredItem = repMap.getPreferredItemForTag(unifyTag, $ -> true);
|
// it's not enough to exclude the preferred item from hiding because it would hide stone stratas
|
||||||
if (preferredItem == null) continue;
|
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);
|
Set<ResourceLocation> itemsToHide = getItemsToHide(unifyTag, itemsByTag, replacements);
|
||||||
if (itemsToHide == null) continue;
|
if (itemsToHide != null) {
|
||||||
hidingMap.putAll(unifyTag, itemsToHide);
|
hidingMap.putAll(unifyTag, itemsToHide);
|
||||||
|
}
|
||||||
|
|
||||||
Set<ResourceLocation> refItemsToHide = getRefItemsToHide(unifyTag, ownerships, preferredItem);
|
Set<ResourceLocation> refItemsToHide = getRefItemsToHide(unifyTag, ownerships, replacements);
|
||||||
|
if (!refItemsToHide.isEmpty()) {
|
||||||
hidingMap.putAll(unifyTag, refItemsToHide);
|
hidingMap.putAll(unifyTag, refItemsToHide);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return hidingMap;
|
return hidingMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@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<>();
|
Set<ResourceLocation> itemsToHide = new HashSet<>();
|
||||||
for (ResourceLocation item : itemsByTag) {
|
for (ResourceLocation item : itemsByTag) {
|
||||||
if (!item.equals(preferredItem)) {
|
if (!replacements.contains(item)) {
|
||||||
itemsToHide.add(item);
|
itemsToHide.add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +80,7 @@ public final class HideHelper {
|
||||||
return itemsToHide;
|
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);
|
var refTags = ownerships.getRefsByOwner(unifyTag);
|
||||||
Set<ResourceLocation> refItemsToHide = new HashSet<>();
|
Set<ResourceLocation> refItemsToHide = new HashSet<>();
|
||||||
|
|
||||||
|
@ -82,7 +89,7 @@ public final class HideHelper {
|
||||||
|
|
||||||
BuiltInRegistries.ITEM.getTagOrEmpty(asTagKey).forEach(holder -> {
|
BuiltInRegistries.ITEM.getTagOrEmpty(asTagKey).forEach(holder -> {
|
||||||
ResourceLocation item = BuiltInRegistries.ITEM.getKey(holder.value());
|
ResourceLocation item = BuiltInRegistries.ITEM.getKey(holder.value());
|
||||||
if (item.equals(preferredItem)) return;
|
if (replacements.contains(item)) return;
|
||||||
refItemsToHide.add(item);
|
refItemsToHide.add(item);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -130,9 +130,7 @@ public final class Defaults {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> getIgnoredRecipeTypes(AlmostUnifiedPlatform.Platform platform) {
|
public static List<String> getIgnoredRecipeTypes(AlmostUnifiedPlatform.Platform platform) {
|
||||||
return switch (platform) {
|
return List.of("cucumber:shaped_tag");
|
||||||
default -> List.of("cucumber:shaped_tag");
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JsonCompare.CompareSettings getDefaultDuplicateRules(AlmostUnifiedPlatform.Platform platform) {
|
public static JsonCompare.CompareSettings getDefaultDuplicateRules(AlmostUnifiedPlatform.Platform platform) {
|
||||||
|
|
Loading…
Reference in a new issue