mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 11:15:12 -04:00
cc peripherals are now wrapped by default and can be disabled using a blacklist (in the config)
This commit is contained in:
parent
8da6b4bd98
commit
98cbaffca6
@ -25,22 +25,19 @@ public class OpenComponents {
|
||||
|
||||
public static final Logger Log = Logger.getLogger("OpenComponents");
|
||||
|
||||
public static boolean computerCraftWrapEverything;
|
||||
public static String[] peripheralBlacklist = new String[]{
|
||||
"JAKJ.RedstoneInMotion.CarriageControllerEntity"
|
||||
};
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(final FMLPreInitializationEvent e) {
|
||||
final Configuration config = new Configuration(e.getSuggestedConfigurationFile());
|
||||
|
||||
computerCraftWrapEverything = config.
|
||||
get("computercraft", "wrapEverything", computerCraftWrapEverything, "" +
|
||||
"Enable this to automatically make any methods other mods'\n" +
|
||||
"blocks make available to ComputerCraft available via the\n" +
|
||||
"Adapter. BEWARE: this is disabled by default for a good\n" +
|
||||
"reason - this will not fully work for all mods, since we\n" +
|
||||
"cannot fully emulate what ComputerCraft offers to the mods'\n" +
|
||||
"callbacks. Meaning when used on untested blocks this can\n" +
|
||||
"very much crash or deadlock your game.").
|
||||
getBoolean(computerCraftWrapEverything);
|
||||
peripheralBlacklist = config.get("computercraft", "blacklist", peripheralBlacklist, "" +
|
||||
"A list of tile entities by class name that should NOT be\n" +
|
||||
"accessible via the Adapter block. Add blocks here that can\n" +
|
||||
"lead to crashes or deadlocks (and report them, please!)").
|
||||
getStringList();
|
||||
|
||||
config.save();
|
||||
}
|
||||
|
@ -4,14 +4,37 @@ import dan200.computer.api.IPeripheral;
|
||||
import li.cil.oc.api.network.ManagedEnvironment;
|
||||
import li.cil.oc.api.prefab.DriverTileEntity;
|
||||
import li.cil.oc.api.prefab.ManagedPeripheral;
|
||||
import li.cil.occ.OpenComponents;
|
||||
import li.cil.occ.util.Reflection;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class DriverPeripheral extends DriverTileEntity {
|
||||
private static final Set<Class<?>> blacklist = new HashSet<Class<?>>();
|
||||
|
||||
static {
|
||||
for (String name : OpenComponents.peripheralBlacklist) {
|
||||
final Class<?> clazz = Reflection.getClass(name);
|
||||
if (clazz != null) {
|
||||
blacklist.add(clazz);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getTileEntityClass() {
|
||||
return IPeripheral.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean worksWith(final World world, final int x, final int y, final int z) {
|
||||
final TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
return tileEntity != null && !blacklist.contains(tileEntity.getClass()) && super.worksWith(world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManagedEnvironment createEnvironment(final World world, final int x, final int y, final int z) {
|
||||
return new ManagedPeripheral((IPeripheral) world.getBlockTileEntity(x, y, z));
|
||||
|
@ -1,7 +1,6 @@
|
||||
package li.cil.occ.mods.computercraft;
|
||||
|
||||
import li.cil.oc.api.Driver;
|
||||
import li.cil.occ.OpenComponents;
|
||||
import li.cil.occ.mods.IMod;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@ -15,10 +14,8 @@ public final class ModComputerCraft implements IMod {
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
if (OpenComponents.computerCraftWrapEverything) {
|
||||
Driver.add(new DriverPeripheral());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populate(final Map<String, Object> map, final ItemStack stack) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user