mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 11:48:02 -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 final Logger Log = Logger.getLogger("OpenComponents");
|
||||||
|
|
||||||
public static boolean computerCraftWrapEverything;
|
public static String[] peripheralBlacklist = new String[]{
|
||||||
|
"JAKJ.RedstoneInMotion.CarriageControllerEntity"
|
||||||
|
};
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void preInit(final FMLPreInitializationEvent e) {
|
public void preInit(final FMLPreInitializationEvent e) {
|
||||||
final Configuration config = new Configuration(e.getSuggestedConfigurationFile());
|
final Configuration config = new Configuration(e.getSuggestedConfigurationFile());
|
||||||
|
|
||||||
computerCraftWrapEverything = config.
|
peripheralBlacklist = config.get("computercraft", "blacklist", peripheralBlacklist, "" +
|
||||||
get("computercraft", "wrapEverything", computerCraftWrapEverything, "" +
|
"A list of tile entities by class name that should NOT be\n" +
|
||||||
"Enable this to automatically make any methods other mods'\n" +
|
"accessible via the Adapter block. Add blocks here that can\n" +
|
||||||
"blocks make available to ComputerCraft available via the\n" +
|
"lead to crashes or deadlocks (and report them, please!)").
|
||||||
"Adapter. BEWARE: this is disabled by default for a good\n" +
|
getStringList();
|
||||||
"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);
|
|
||||||
|
|
||||||
config.save();
|
config.save();
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,37 @@ import dan200.computer.api.IPeripheral;
|
|||||||
import li.cil.oc.api.network.ManagedEnvironment;
|
import li.cil.oc.api.network.ManagedEnvironment;
|
||||||
import li.cil.oc.api.prefab.DriverTileEntity;
|
import li.cil.oc.api.prefab.DriverTileEntity;
|
||||||
import li.cil.oc.api.prefab.ManagedPeripheral;
|
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 net.minecraft.world.World;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class DriverPeripheral extends DriverTileEntity {
|
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
|
@Override
|
||||||
public Class<?> getTileEntityClass() {
|
public Class<?> getTileEntityClass() {
|
||||||
return IPeripheral.class;
|
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
|
@Override
|
||||||
public ManagedEnvironment createEnvironment(final World world, final int x, final int y, final int z) {
|
public ManagedEnvironment createEnvironment(final World world, final int x, final int y, final int z) {
|
||||||
return new ManagedPeripheral((IPeripheral) world.getBlockTileEntity(x, y, z));
|
return new ManagedPeripheral((IPeripheral) world.getBlockTileEntity(x, y, z));
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package li.cil.occ.mods.computercraft;
|
package li.cil.occ.mods.computercraft;
|
||||||
|
|
||||||
import li.cil.oc.api.Driver;
|
import li.cil.oc.api.Driver;
|
||||||
import li.cil.occ.OpenComponents;
|
|
||||||
import li.cil.occ.mods.IMod;
|
import li.cil.occ.mods.IMod;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
@ -15,9 +14,7 @@ public final class ModComputerCraft implements IMod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
if (OpenComponents.computerCraftWrapEverything) {
|
Driver.add(new DriverPeripheral());
|
||||||
Driver.add(new DriverPeripheral());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user