Generic peripherals for any tile entities (#478)

This exposes a basic peripheral for any tile entity which does not have methods
already registered. We currently provide the following methods:

 - Inventories: size, list, getItemMeta, pushItems, pullItems.
 - Energy storage: getEnergy, getEnergyCapacity
 - Fluid tanks: tanks(), pushFluid, pullFluid.

These methods are currently experimental - it must be enabled through 
`experimental.generic_peripherals`. While this is an initial step towards
implementing #452, but is by no means complete.
This commit is contained in:
Jonathan Coates
2020-06-27 10:47:31 +01:00
committed by GitHub
parent 613a28a5af
commit 08181f72d4
19 changed files with 960 additions and 44 deletions
@@ -73,6 +73,8 @@ public final class Config
private static final ConfigValue<Boolean> turtlesCanPush;
private static final ConfigValue<List<? extends String>> turtleDisabledActions;
private static final ConfigValue<Boolean> genericPeripheral;
private static final ConfigValue<MonitorRenderer> monitorRenderer;
private static final ForgeConfigSpec serverSpec;
@@ -260,6 +262,17 @@ public final class Config
builder.pop();
}
{
builder.comment( "Options for various experimental features. These are not guaranteed to be stable, and may change or be removed across versions." );
builder.push( "experimental" );
genericPeripheral = builder
.comment( "Attempt to make any existing block (or tile entity) a peripheral.\n" +
"This provides peripheral methods for any inventory, fluid tank or energy storage block. It will" +
"_not_ provide methods which have an existing peripheral provider." )
.define( "generic_peripherals", false );
}
serverSpec = builder.build();
Builder clientBuilder = new Builder();
@@ -322,6 +335,8 @@ public final class Config
ComputerCraft.turtleDisabledActions.clear();
for( String value : turtleDisabledActions.get() ) ComputerCraft.turtleDisabledActions.add( getAction( value ) );
ComputerCraft.genericPeripheral = genericPeripheral.get();
// Client
ComputerCraft.monitorRenderer = monitorRenderer.get();
}