From a3e936102a94bdb9e32f4d8078e4c3c46bc41ab6 Mon Sep 17 00:00:00 2001 From: trinsdar <30245301+Trinsdar@users.noreply.github.com> Date: Sun, 25 Aug 2024 23:18:03 -0400 Subject: [PATCH] added IExtendingBlockEntity --- .../muramasa/antimatter/blockentity/BlockEntityBase.java | 6 +++++- .../antimatter/blockentity/IExtendingBlockEntity.java | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 common/src/main/java/muramasa/antimatter/blockentity/IExtendingBlockEntity.java diff --git a/common/src/main/java/muramasa/antimatter/blockentity/BlockEntityBase.java b/common/src/main/java/muramasa/antimatter/blockentity/BlockEntityBase.java index f0f1ab8b3..157b12902 100644 --- a/common/src/main/java/muramasa/antimatter/blockentity/BlockEntityBase.java +++ b/common/src/main/java/muramasa/antimatter/blockentity/BlockEntityBase.java @@ -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; diff --git a/common/src/main/java/muramasa/antimatter/blockentity/IExtendingBlockEntity.java b/common/src/main/java/muramasa/antimatter/blockentity/IExtendingBlockEntity.java new file mode 100644 index 000000000..c5bc89ebf --- /dev/null +++ b/common/src/main/java/muramasa/antimatter/blockentity/IExtendingBlockEntity.java @@ -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); +}