|
2 | 2 |
|
3 | 3 | import com.kqp.inventorytabs.mixin.accessor.ScreenAccessor; |
4 | 4 | import com.kqp.inventorytabs.tabs.render.TabRenderInfo; |
| 5 | +import com.kqp.inventorytabs.util.ChestUtil; |
5 | 6 | import net.minecraft.block.ChestBlock; |
6 | 7 | import net.minecraft.client.MinecraftClient; |
7 | 8 | import net.minecraft.client.font.TextRenderer; |
|
22 | 23 | import java.util.List; |
23 | 24 | import java.util.stream.Stream; |
24 | 25 |
|
| 26 | +import static com.kqp.inventorytabs.util.ChestUtil.getOtherChestBlockPos; |
| 27 | + |
25 | 28 | /** |
26 | 29 | * Tab for chests |
27 | 30 | */ |
@@ -64,10 +67,14 @@ public void renderTabIcon(MatrixStack matrices, TabRenderInfo tabRenderInfo, Han |
64 | 67 |
|
65 | 68 | public ItemStack getItemFrame() { |
66 | 69 | World world = MinecraftClient.getInstance().player.world; |
67 | | - itemStack = new ItemStack(MinecraftClient.getInstance().player.world.getBlockState(blockPos).getBlock()); |
68 | | - List<ItemFrameEntity> list1 = world.getNonSpectatingEntities(ItemFrameEntity.class, new Box(blockPos.getX()-0.8, blockPos.getY(), blockPos.getZ(), blockPos.getX()+1.8, blockPos.getY()+0.8, blockPos.getZ()+0.8)); |
69 | | - List<ItemFrameEntity> list2 = world.getNonSpectatingEntities(ItemFrameEntity.class, new Box(blockPos.getX(), blockPos.getY(), blockPos.getZ()-0.8, blockPos.getX()+0.8, blockPos.getY()+0.8, blockPos.getZ()+1.8)); |
70 | | - List<ItemFrameEntity> list3 = world.getNonSpectatingEntities(ItemFrameEntity.class, new Box(blockPos.getX(), blockPos.getY()-0.8, blockPos.getZ(), blockPos.getX()+0.8, blockPos.getY()+1.8, blockPos.getZ()+0.8)); |
| 70 | + itemStack = new ItemStack(world.getBlockState(blockPos).getBlock()); |
| 71 | + BlockPos doubleChestPos = ChestUtil.isDouble(world, blockPos) ? getOtherChestBlockPos(world, blockPos) : blockPos; |
| 72 | + Box box = new Box(blockPos, doubleChestPos); |
| 73 | + double x = box.minX; double y = box.minY; double z = box.minZ; |
| 74 | + double x1 = box.maxX; double y1 = box.maxY; double z1 = box.maxZ; |
| 75 | + List<ItemFrameEntity> list1 = world.getNonSpectatingEntities(ItemFrameEntity.class, new Box(x-0.8, y, z, x1+1.8, y1+0.8, z1+0.8)); |
| 76 | + List<ItemFrameEntity> list2 = world.getNonSpectatingEntities(ItemFrameEntity.class, new Box(x, y, z-0.8, x1+0.8, y1+0.8, z1+1.8)); |
| 77 | + List<ItemFrameEntity> list3 = world.getNonSpectatingEntities(ItemFrameEntity.class, new Box(x, y-0.8, z, x1+0.8, y1+1.8, z1+0.8)); |
71 | 78 | List<ItemFrameEntity> list = new ArrayList<>(); |
72 | 79 | Stream.of(list1, list2, list3).forEach(list::addAll); |
73 | 80 | if (!list.isEmpty()) { |
|
0 commit comments