Skip to content

Commit

Permalink
Fix generic inv adapter for parts (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
Technici4n authored Mar 8, 2024
1 parent 27f0381 commit 9edc8cf
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/main/java/me/ramidzkh/mekae2/AppliedMekanistics.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,13 @@ private void initializeAttunement() {

private static <T> void registerGenericInvAdapter(RegisterCapabilitiesEvent event, Block block,
BlockCapability<T, Direction> capability, Function<GenericInternalInventory, T> adapter) {
if (!event.isBlockRegistered(capability, block)) {
event.registerBlock(capability, (level, pos, state, blockEntity, context) -> {
var genericInv = level.getCapability(AppEngCapabilities.GENERIC_INTERNAL_INV, pos, state,
blockEntity, context);
if (genericInv != null) {
return adapter.apply(genericInv);
}
return null;
}, block);
}
event.registerBlock(capability, (level, pos, state, blockEntity, context) -> {
var genericInv = level.getCapability(AppEngCapabilities.GENERIC_INTERNAL_INV, pos, state,
blockEntity, context);
if (genericInv != null) {
return adapter.apply(genericInv);
}
return null;
}, block);
}
}

0 comments on commit 9edc8cf

Please sign in to comment.