Added Magneticraft and Gregtech support
Some checks failed
continuous-integration/drone Build is failing

This commit is contained in:
Timo Ley 2020-04-09 23:52:49 +02:00
parent 7b056c057d
commit 22ebc12fc8
3 changed files with 57 additions and 7 deletions

View file

@ -1,7 +1,7 @@
import groovy.json.JsonOutput
def mainVersion = "1.7"
def buildNumber = "37"
def buildNumber = "38"
// For those who want the bleeding edge
buildscript {
@ -102,6 +102,8 @@ dependencies {
compileOnly "mezz.jei:jei_1.12:4.+"
compileOnly "CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.1.8.460"
compile 'com.elytradev:mirage:2.0.3-rc3-SNAPSHOT'
compile "gregtechce:gregtech:1.12.2:1.9.0.481"
compile "magneticraft:Magneticraft_1.12:2.8.2:dev"
}

View file

@ -5,8 +5,8 @@
"1.10.2-recommended": "1.4-18",
"1.11.2-latest": "1.5-19",
"1.11.2-recommended": "1.5-19",
"1.12.2-latest": "1.7-36",
"1.12.2-recommended": "1.7-36"
"1.12.2-latest": "1.7-36",
"1.12.2-recommended": "1.7-36"
},
"1.10.2": {
"1.1-3": " - fixed incompatibility with IE build 48\n - reduced the amount of calls to core IE classes to make such incompatibilities less likely\n - fixed localization of the creative tab",
@ -43,9 +43,9 @@
"1.7-30": " - Fixed crashes when IC2 isn't installed\n - Fixed connectors allowing too much power output\n - Added a config option for some of the wires' properties\n - Updated chinese translation (thanks @DepletedPrism)",
"1.7-31": " - Fixed accidental conversion from FE to EU\n - Fixed connectors not blowing up as intended\n ",
"1.7-32": " - Fixed connectors not rendering properly without IC2\n - Fixed parts of the mechanical multiblocks not rendering when Optifine is installed\n - Changed some values for the mechanical multiblock sound",
"1.7-33": " - Fixed the Marx generator not processing ores\n - Fixed control panels and the Marx generator not working when connected directly\n - Added Russian translation (thanks @StolenSoda)",
"1.7-34": " - Control panels can use the texture of any block now\n - Added a recipe to copy the settings of an unfinished control panel\n - The Marx generator now returns the wires used in its construction when disassembled\n - Fixed the RS controller for non-IE wires not keeping its IO state on world reload\n - Fixed control panels not working correctly with multiple controllers",
"1.7-35": " - Fixed a crash when placing certain items in the crafting grid",
"1.7-36": " - Added an RGB indicator light, controlled by 3 (independent) RS signals\n - Fixed a bug allowing for unfinished control panels to be duplicated\n - Fixed insulated and uninsulated wire producing the same wire coils\n - Fixed some issues (including a crash) with the IE RS controller on dedicated servers"
"1.7-33": " - Fixed the Marx generator not processing ores\n - Fixed control panels and the Marx generator not working when connected directly\n - Added Russian translation (thanks @StolenSoda)",
"1.7-34": " - Control panels can use the texture of any block now\n - Added a recipe to copy the settings of an unfinished control panel\n - The Marx generator now returns the wires used in its construction when disassembled\n - Fixed the RS controller for non-IE wires not keeping its IO state on world reload\n - Fixed control panels not working correctly with multiple controllers",
"1.7-35": " - Fixed a crash when placing certain items in the crafting grid",
"1.7-36": " - Added an RGB indicator light, controlled by 3 (independent) RS signals\n - Fixed a bug allowing for unfinished control panels to be duplicated\n - Fixed insulated and uninsulated wire producing the same wire coils\n - Fixed some issues (including a crash) with the IE RS controller on dedicated servers"
}
}

View file

@ -20,6 +20,13 @@ import blusunrize.immersiveengineering.api.energy.wires.*;
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.AbstractConnection;
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection;
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IDirectionalTile;
import com.cout970.magneticraft.api.core.INode;
import com.cout970.magneticraft.api.energy.IElectricNode;
import com.cout970.magneticraft.api.energy.IElectricNodeHandler;
import com.cout970.magneticraft.registry.CapabilitiesKt;
import com.cout970.magneticraft.systems.config.Config;
import gregtech.api.capability.GregtechCapabilities;
import gregtech.api.capability.IEnergyContainer;
import ic2.api.energy.tile.IEnergyAcceptor;
import ic2.api.energy.tile.IEnergyEmitter;
import ic2.api.energy.tile.IEnergySink;
@ -41,6 +48,7 @@ import net.minecraft.util.math.*;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.energy.CapabilityEnergy;
import net.minecraftforge.energy.IEnergyStorage;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.Optional;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
@ -158,6 +166,10 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
}
if (bufferToMachine > EPS) {
transferPowerToFEMachine();
if (Loader.isModLoaded("gregtech"))
transferPowerToGTMachine();
if (Loader.isModLoaded("magneticraft"))
transferPowerToMagn();
}
}
}
@ -224,6 +236,42 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
}
}
private void transferPowerToGTMachine() {
BlockPos outPos = pos.offset(facing);
TileEntity te = MiscUtils.getLoadedTE(world, outPos, TileEntity.class);
if (te!=null && te.hasCapability(GregtechCapabilities.CAPABILITY_ENERGY_CONTAINER, facing.getOpposite())) {
IEnergyContainer container = te.getCapability(GregtechCapabilities.CAPABILITY_ENERGY_CONTAINER, facing.getOpposite());
assert container!=null;
double outJoules = Math.min(bufferToMachine, maxToMachine*IWConfig.wireRatio);
long outEU = Math.min(MathHelper.floor(outJoules*ConversionUtil.euPerJoule()), container.getInputVoltage());
long received = container.addEnergy(outEU);
bufferToMachine -= received*ConversionUtil.joulesPerEu();
}
}
private void transferPowerToMagn() {
BlockPos outPos = pos.offset(facing);
TileEntity te = MiscUtils.getLoadedTE(world, outPos, TileEntity.class);
if (te!=null && te.hasCapability(CapabilitiesKt.getELECTRIC_NODE_HANDLER(), facing.getOpposite())) {
IElectricNodeHandler handler = te.getCapability(CapabilitiesKt.getELECTRIC_NODE_HANDLER(), facing.getOpposite());
assert handler!=null;
double outJoules = Math.min(bufferToMachine, maxToMachine*IWConfig.wireRatio);
int outRF = MathHelper.floor(outJoules*ConversionUtil.ifPerJoule());
IElectricNode node = null;
for (INode n : handler.getNodes()) {
if (n instanceof IElectricNode) {
node = (IElectricNode) n;
break;
}
}
if (node != null) {
double insertet = node.applyPower(outRF * Config.INSTANCE.getWattsToFE(), false);
bufferToMachine -= insertet/Config.INSTANCE.getWattsToFE();
}
}
}
private void notifyAvailableEnergy(double storedNew)
{
Set<AbstractConnection> outputs = ImmersiveNetHandler.INSTANCE.getIndirectEnergyConnections(pos, world, true);