11package com .gregtechceu .gtceu .integration .cctweaked ;
22
33import com .gregtechceu .gtceu .api .capability .forge .GTCapability ;
4+ import com .gregtechceu .gtceu .api .placeholder .*;
5+ import com .gregtechceu .gtceu .api .placeholder .exceptions .NotSupportedException ;
6+ import com .gregtechceu .gtceu .api .placeholder .exceptions .PlaceholderException ;
47import com .gregtechceu .gtceu .integration .cctweaked .peripherals .*;
58
69import dan200 .computercraft .api .ComputerCraftAPI ;
710import dan200 .computercraft .api .ForgeComputerCraftAPI ;
811
12+ import java .util .List ;
13+
914public class CCTweakedPlugin {
1015
1116 public static void init () {
@@ -21,5 +26,17 @@ public static void init() {
2126 ForgeComputerCraftAPI .registerGenericCapability (GTCapability .CAPABILITY_WORKABLE );
2227 ForgeComputerCraftAPI .registerGenericCapability (GTCapability .CAPABILITY_COVERABLE );
2328 ForgeComputerCraftAPI .registerGenericCapability (GTCapability .CAPABILITY_CENTRAL_MONITOR );
29+ PlaceholderHandler .addPlaceholder (new Placeholder ("bufferText" ) {
30+
31+ @ Override
32+ public MultiLineComponent apply (PlaceholderContext ctx ,
33+ List <MultiLineComponent > args ) throws PlaceholderException {
34+ PlaceholderUtils .checkArgs (args , 1 );
35+ if (!(ctx .cover () instanceof IPlaceholderInfoProviderCover cover )) throw new NotSupportedException ();
36+ int i = PlaceholderUtils .toInt (args .get (0 ));
37+ PlaceholderUtils .checkRange ("line number" , 1 , 100 , i );
38+ return MultiLineComponent .of (cover .getComputerCraftTextBuffer ().get (i - 1 ));
39+ }
40+ });
2441 }
2542}
0 commit comments