Support replaceAll on the wrapping model registry
This commit is contained in:
parent
152cdc4469
commit
d76fd84b76
|
|
@ -21,6 +21,7 @@ import org.embeddedt.modernfix.util.ForwardingInclDefaultsMap;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores a list of all known default block/item models in the game, and provides a namespaced version
|
* Stores a list of all known default block/item models in the game, and provides a namespaced version
|
||||||
|
|
@ -79,7 +80,7 @@ public class ModelBakeEventHelper {
|
||||||
private void logWarning() {
|
private void logWarning() {
|
||||||
if(!WARNED_MOD_IDS.add(modId))
|
if(!WARNED_MOD_IDS.add(modId))
|
||||||
return;
|
return;
|
||||||
ModernFix.LOGGER.warn("Mod '{}' is accessing Map#keySet/entrySet/values on the model registry map inside its event handler." +
|
ModernFix.LOGGER.warn("Mod '{}' is accessing Map#keySet/entrySet/values/replaceAll on the model registry map inside its event handler." +
|
||||||
" This probably won't work as expected with dynamic resources on. Prefer using Map#get/put and constructing ModelResourceLocations another way.", modId);
|
" This probably won't work as expected with dynamic resources on. Prefer using Map#get/put and constructing ModelResourceLocations another way.", modId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,6 +101,12 @@ public class ModelBakeEventHelper {
|
||||||
logWarning();
|
logWarning();
|
||||||
return super.values();
|
return super.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void replaceAll(BiFunction<? super ResourceLocation, ? super BakedModel, ? extends BakedModel> function) {
|
||||||
|
logWarning();
|
||||||
|
super.replaceAll(function);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -139,6 +146,13 @@ public class ModelBakeEventHelper {
|
||||||
public boolean containsKey(@Nullable Object key) {
|
public boolean containsKey(@Nullable Object key) {
|
||||||
return ourModelLocations.contains(key) || super.containsKey(key);
|
return ourModelLocations.contains(key) || super.containsKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void replaceAll(BiFunction<? super ResourceLocation, ? super BakedModel, ? extends BakedModel> function) {
|
||||||
|
for(ResourceLocation location : keySet()) {
|
||||||
|
put(location, function.apply(location, get(location)));
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user