-
Notifications
You must be signed in to change notification settings - Fork 187
Allow remapping resources via addons #754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow remapping resources via addons #754
Conversation
93e034a to
075f3e9
Compare
|
The currently intended way is a custom BlockRenderer instead. So, you load all the static "actual" blockstates, models and textures at load time, and register a new A possible implementation of the block-renderer e.g. would be something like this: public class EveryCompBlockRenderer implements BlockRenderer {
private final BlockStateModelRenderer blockStateDelegate;
private final ResourceModelRenderer resourceModelDelegate;
public EveryCompBlockRenderer(ResourcePack resourcePack, TextureGallery textureGallery, RenderSettings renderSettings) {
this.blockStateDelegate = new BlockStateModelRenderer(resourcePack, textureGallery, renderSettings);
this.resourceModelDelegate = new ResourceModelRenderer(resourcePack, textureGallery, renderSettings);
}
@Override
public void render(BlockNeighborhood block, Variant variant, TileModelView tileModel, Color blockColor) {
BlockState blockState = block.getBlockState();
Key remappedId = remap(blockState.getId());
if (remappedId == null){
// if we can't do any remapping, we forward the call to the resourceModelDelegate (to render a missing-block-model),
// using the blockStateDelegate here would lead to an infinite recursion-loop
resourceModelDelegate.render(block, variant, tileModel, blockColor);
return;
}
// we remap the blockstate with the new blockstate-id and then call the original BlockStateModelRenderer again
// to handle rendering the remapped blockstate properly
BlockState remappedBlockState = new BlockState(remappedId, blockState.getProperties());
blockStateDelegate.render(block, remappedBlockState, tileModel, blockColor);
}
public Key remap(Key src) {
if (!src.getNamespace().equals("everycomp")) {
return null;
}
String[] segments = src.getValue().split("/", 3);
if (segments.length < 3) {
return null;
}
return new Key(segments[1], segments[2]);
}
}That being said, i do see the issue with this intended approach, which is that the default block-properties would not be generated using the correct block-model. 🤔 |
In my use-case specifically, that's alright (everycomp doesn't remap/provide any sub-resources in the other types), but I do agree it might not be the best. That said, I couldn't find other good ways to handle the mapping as we call the These are my thoughts anyway, it has been a couple years since I've written Java actively, so, yeah, my thoughts might not be fully accurate for modern-ish Java. |
2eb4f63 to
14a1153
Compare
14a1153 to
aa4f8b4
Compare
|
@TBlueF I updated it to pass the If you have better ideas on how to solve this, do let me know |
|
Sorry, that's not exactly the way i meant it :D E.g. I will look into this once i find a bit more time and will come back to you with the results. :) |
|
Implemented with #759 |
This allows remapping ResourcePool from one key to another via an addon programmatically.
The reasoning behind this is a mod called EveryCompat (or WoodGood): It basically adds "missing" blocks to all types of wood to make sure you can build, say, a bookshelf out of every modded wood type you have.
The issue is, this causes it to generate block state names like
everycompat:q/environmental/azalia_bookshelforeverycompat:abnbl/boatload/azalia_boat.This allows making an addon for example like https://github.com/Doridian/BlueMapEveryCompatCompat which remaps the resources correctly as seen here: https://github.com/Doridian/BlueMapEveryCompatCompat/blob/main/src/main/java/net/doridian/bluemapeverycompatcompat/EveryCompatResourcePack.java#L27