mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 19:25:20 -04:00
Merge branch 'master' of github.com:MightyPirates/OpenComponents
Conflicts: src/main/java/li/cil/occ/OpenComponents.java
This commit is contained in:
commit
61dc9b78f1
@ -10,7 +10,6 @@ import li.cil.occ.mods.buildcraft.ModBuildCraft;
|
||||
import li.cil.occ.mods.computercraft.ModComputerCraft;
|
||||
import li.cil.occ.mods.enderstorage.ModEnderStorage;
|
||||
import li.cil.occ.mods.ic2.ModIndustrialCraft2;
|
||||
import li.cil.occ.mods.mekanism.ModMekanism;
|
||||
import li.cil.occ.mods.railcraft.ModRailcraft;
|
||||
import li.cil.occ.mods.redstoneinmotion.ModRedstoneInMotion;
|
||||
import li.cil.occ.mods.thermalexpansion.ModThermalExpansion;
|
||||
@ -27,22 +26,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();
|
||||
}
|
||||
@ -54,7 +50,6 @@ public class OpenComponents {
|
||||
Registry.add(new ModBuildCraft());
|
||||
Registry.add(new ModEnderStorage());
|
||||
Registry.add(new ModIndustrialCraft2());
|
||||
Registry.add(new ModMekanism());
|
||||
Registry.add(new ModRailcraft());
|
||||
Registry.add(new ModRedstoneInMotion());
|
||||
Registry.add(new ModThermalExpansion());
|
||||
|
@ -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;
|
||||
|
||||
public class DriverPeripheral extends DriverTileEntity {
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public final 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,9 +14,7 @@ public final class ModComputerCraft implements IMod {
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
if (OpenComponents.computerCraftWrapEverything) {
|
||||
Driver.add(new DriverPeripheral());
|
||||
}
|
||||
Driver.add(new DriverPeripheral());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,7 +1,5 @@
|
||||
package li.cil.occ.mods.ic2;
|
||||
|
||||
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import li.cil.oc.api.network.Arguments;
|
||||
import li.cil.oc.api.network.Callback;
|
||||
import li.cil.oc.api.network.Context;
|
||||
@ -12,7 +10,7 @@ import li.cil.occ.util.Reflection;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class DriverMassFab extends DriverTileEntity {
|
||||
public final class DriverMassFab extends DriverTileEntity {
|
||||
private static final Class<?> TileController = Reflection.getClass("ic2.core.block.machine.tileentity.TileEntityMatter");
|
||||
|
||||
@Override
|
||||
|
@ -17,13 +17,13 @@ public final class ModIndustrialCraft2 implements IMod {
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
Driver.add(new DriverReactor());
|
||||
Driver.add(new DriverReactorChamber());
|
||||
Driver.add(new DriverEnergyConductor());
|
||||
Driver.add(new DriverEnergySink());
|
||||
Driver.add(new DriverEnergySource());
|
||||
Driver.add(new DriverMassFab());
|
||||
Driver.add(new DriverEnergyStorage());
|
||||
Driver.add(new DriverMassFab());
|
||||
Driver.add(new DriverReactor());
|
||||
Driver.add(new DriverReactorChamber());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,13 +0,0 @@
|
||||
package li.cil.occ.mods.mekanism;
|
||||
|
||||
import li.cil.occ.mods.computercraft.DriverPeripheral;
|
||||
import li.cil.occ.util.Reflection;
|
||||
|
||||
public final class DriverBasicMachine extends DriverPeripheral {
|
||||
private static final Class<?> TileEntityBasicMachine = Reflection.getClass("mekanism.common.tileentity.TileEntityBasicMachine");
|
||||
|
||||
@Override
|
||||
public Class<?> getTileEntityClass() {
|
||||
return TileEntityBasicMachine;
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
package li.cil.occ.mods.mekanism;
|
||||
|
||||
import li.cil.occ.mods.computercraft.DriverPeripheral;
|
||||
import li.cil.occ.util.Reflection;
|
||||
|
||||
public final class DriverDigitalMiner extends DriverPeripheral {
|
||||
private static final Class<?> TileEntityDigitalMiner = Reflection.getClass("mekanism.common.tileentity.TileEntityDigitalMiner");
|
||||
|
||||
@Override
|
||||
public Class<?> getTileEntityClass() {
|
||||
return TileEntityDigitalMiner;
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
package li.cil.occ.mods.mekanism;
|
||||
|
||||
import li.cil.occ.mods.computercraft.DriverPeripheral;
|
||||
import li.cil.occ.util.Reflection;
|
||||
|
||||
public final class DriverElectrolyticSeperator extends DriverPeripheral {
|
||||
private static final Class<?> TileEntityElectrolyticSeparator = Reflection.getClass("mekanism.generators.common.tileentity.TileEntityElectrolyticSeparator");
|
||||
|
||||
@Override
|
||||
public Class<?> getTileEntityClass() {
|
||||
return TileEntityElectrolyticSeparator;
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
package li.cil.occ.mods.mekanism;
|
||||
|
||||
import li.cil.occ.mods.computercraft.DriverPeripheral;
|
||||
import li.cil.occ.util.Reflection;
|
||||
|
||||
public final class DriverEnergyCube extends DriverPeripheral {
|
||||
private static final Class<?> TileentityEnergyCube = Reflection.getClass("mekanism.common.tileentity.TileEntityEnergyCube");
|
||||
|
||||
@Override
|
||||
public Class<?> getTileEntityClass() {
|
||||
return TileentityEnergyCube;
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
package li.cil.occ.mods.mekanism;
|
||||
|
||||
import li.cil.occ.mods.computercraft.DriverPeripheral;
|
||||
import li.cil.occ.util.Reflection;
|
||||
|
||||
public final class DriverFactory extends DriverPeripheral {
|
||||
private static final Class<?> TileEntityFactory = Reflection.getClass("mekanism.common.tileentity.TileEntityFactory");
|
||||
|
||||
@Override
|
||||
public Class<?> getTileEntityClass() {
|
||||
return TileEntityFactory;
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
package li.cil.occ.mods.mekanism;
|
||||
|
||||
import li.cil.occ.mods.computercraft.DriverPeripheral;
|
||||
import li.cil.occ.util.Reflection;
|
||||
|
||||
public final class DriverGenerator extends DriverPeripheral {
|
||||
private static final Class<?> TileGenerator = Reflection.getClass("mekanism.generators.common.tileentity.TileEntityGenerator");
|
||||
|
||||
@Override
|
||||
public Class<?> getTileEntityClass() {
|
||||
return TileGenerator;
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
package li.cil.occ.mods.mekanism;
|
||||
|
||||
import li.cil.occ.mods.computercraft.DriverPeripheral;
|
||||
import li.cil.occ.util.Reflection;
|
||||
|
||||
public final class DriverMetallurgicInfuser extends DriverPeripheral {
|
||||
private static final Class<?> TileEntityMetallurgicInfuser = Reflection.getClass("mekanism.common.tileentity.TileEntityMetallurgicInfuser");
|
||||
|
||||
@Override
|
||||
public Class<?> getTileEntityClass() {
|
||||
return TileEntityMetallurgicInfuser;
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
package li.cil.occ.mods.mekanism;
|
||||
|
||||
import li.cil.occ.mods.computercraft.DriverPeripheral;
|
||||
import li.cil.occ.util.Reflection;
|
||||
|
||||
public final class DriverTeleporter extends DriverPeripheral {
|
||||
private static final Class<?> TileEntityTeleporter = Reflection.getClass("mekanism.common.tileentity.TileEntityTeleporter");
|
||||
|
||||
@Override
|
||||
public Class<?> getTileEntityClass() {
|
||||
return TileEntityTeleporter;
|
||||
}
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
package li.cil.occ.mods.mekanism;
|
||||
|
||||
import li.cil.oc.api.Driver;
|
||||
import li.cil.occ.mods.IMod;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public final class ModMekanism implements IMod {
|
||||
@Override
|
||||
public String getModId() {
|
||||
return "Mekanism";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
Driver.add(new DriverBasicMachine());
|
||||
Driver.add(new DriverDigitalMiner());
|
||||
Driver.add(new DriverElectrolyticSeperator());
|
||||
Driver.add(new DriverEnergyCube());
|
||||
Driver.add(new DriverFactory());
|
||||
Driver.add(new DriverGenerator());
|
||||
Driver.add(new DriverMetallurgicInfuser());
|
||||
Driver.add(new DriverTeleporter());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populate(final Map<String, Object> map, final ItemStack stack) {
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ import li.cil.occ.util.Reflection;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class DriverLamp extends DriverTileEntity {
|
||||
public final class DriverLamp extends DriverTileEntity {
|
||||
private static final Class<?> TileLamp = Reflection.getClass("thermalexpansion.block.lamp.TileLamp");
|
||||
|
||||
@Override
|
||||
@ -26,17 +26,12 @@ public class DriverLamp extends DriverTileEntity {
|
||||
|
||||
public static final class Environment extends ManagedTileEntityEnvironment<TileEntity> {
|
||||
public Environment(final TileEntity tileEntity) {
|
||||
super(tileEntity, "Lamp");
|
||||
super(tileEntity, "lamp");
|
||||
}
|
||||
|
||||
@Callback
|
||||
public Object[] setColor(final Context context, final Arguments args) {
|
||||
try {
|
||||
return new Object[]{Reflection.invoke(tileEntity, "setColor", args.checkInteger(0))};
|
||||
} catch (Throwable t) {
|
||||
return new Object[]{null, "Error"};
|
||||
}
|
||||
return new Object[]{Reflection.tryInvoke(tileEntity, "setColor", args.checkInteger(0))};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -18,8 +18,8 @@ public final class ModThermalExpansion implements IMod {
|
||||
public void initialize() {
|
||||
Driver.add(new DriverEnderAttuned());
|
||||
Driver.add(new DriverEnergyHandler());
|
||||
Driver.add(new DriverLamp());
|
||||
Driver.add(new DriverEnergyInfo());
|
||||
Driver.add(new DriverLamp());
|
||||
Driver.add(new DriverRedstoneControl());
|
||||
Driver.add(new DriverSecureTile());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user