Skip to content

Commit

Permalink
added IExtendingBlockEntity
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinsdar committed Aug 26, 2024
1 parent 41d606e commit a3e9361
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@ public BlockEntity getCachedBlockEntity(Direction side){
BlockEntity entity;
if (!blockEntityCache.asMap().containsKey(side)){
entity = level.getBlockEntity(this.getBlockPos().relative(side));
if (entity instanceof IExtendingBlockEntity extendingBlockEntity) {
entity = extendingBlockEntity.getExtendedBlockEntity(side);
}
if (entity == null) return null;
} else {
entity = null;
}
return blockEntityCache.get(side, () -> entity);
BlockEntity finalEntity = entity;
return blockEntityCache.get(side, () -> finalEntity);
} catch (ExecutionException e) {
Antimatter.LOGGER.error(e);
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package muramasa.antimatter.blockentity;

import net.minecraft.core.Direction;
import net.minecraft.world.level.block.entity.BlockEntity;

public interface IExtendingBlockEntity {
BlockEntity getExtendedBlockEntity(Direction side);
}

0 comments on commit a3e9361

Please sign in to comment.