Compare commits

..

No commits in common. "MC1.12" and "feature/rgbLED" have entirely different histories.

9 changed files with 105 additions and 136 deletions

View file

@ -1,7 +1,7 @@
import groovy.json.JsonOutput
def mainVersion = "1.7"
def buildNumber = "38"
def buildNumber = "35"
// For those who want the bleeding edge
buildscript {
@ -17,7 +17,6 @@ buildscript {
}
}
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'idea'
/*
// for people who want stable - not yet functional for MC 1.8.8 - we require the forgegradle 2.1 snapshot
@ -33,7 +32,7 @@ sourceCompatibility = 1.8
targetCompatibility = 1.8
minecraft {
version = "1.12.2-14.23.5.2847"
version = "1.12.2-14.23.5.2768"
runDir = "run"
replace '${version}', project.version
@ -83,9 +82,9 @@ repositories {
}
dependencies {
compile 'net.industrial-craft:industrialcraft-2:2.8.+'
deobfCompile 'net.industrial-craft:industrialcraft-2:2.8.+'
deobfCompile "blusunrize:ImmersiveEngineering:0.12-+"
compileOnly "pl.asie.charset:charset:0.5.6.4.19:full"
compileOnly "pl.asie.charset:charset:0.5.4.2.3:full"
//Project red and runtime dependencies
compileOnly "project-red-base:ProjectRed-1.12.2:4.9.1.92:Base"
//runtime "project-red-integration:ProjectRed-1.12.2:4.9.1.92:integration"
@ -97,13 +96,9 @@ dependencies {
compileOnly "TechReborn:TechReborn-1.12:2.6.9.7:universal"
compileOnly "RebornCore:RebornCore-1.12:3.2.+:universal"
//Others
//TODO do something about this
// compileOnly 'com.elytradev:mirage:2.0.1-SNAPSHOT'
compileOnly 'com.elytradev:mirage:2.0.1-SNAPSHOT'
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-35",
"1.12.2-recommended": "1.7-35"
},
"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,8 @@
"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"
}
}

View file

@ -1,11 +1,5 @@
###Minecraft 1.12.2
####Version 1.7-36
- Added an RGB indicator light, controlled by 3 (independent) RS signals
- Fixed a bug allowing for unfinished control panels to be duplicated
- Fixed insulated and uninsulated wire producing the same wire coils
- Fixed some issues (including a crash) with the IE RS controller on dedicated servers
####Version 1.7-35
- Fixed a crash when placing certain items in the crafting grid

View file

@ -17,13 +17,14 @@ package malte0811.industrialwires;
import blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable;
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler;
import malte0811.industrialwires.util.ConversionUtil;
import malte0811.industrialwires.wires.EnergyType;
import net.minecraft.entity.Entity;
public interface IMixedConnector extends IImmersiveConnectable {
/**
* @return leftover energy.
*/
double insertEnergy(double joules, boolean simulate);
double insertEnergy(double joules, boolean simulate, EnergyType type);
@Override
default float getDamageAmount(Entity e, ImmersiveNetHandler.Connection c)

View file

@ -22,25 +22,19 @@ import blusunrize.immersiveengineering.api.energy.wires.WireType;
import blusunrize.immersiveengineering.api.energy.wires.redstone.IRedstoneConnector;
import blusunrize.immersiveengineering.api.energy.wires.redstone.RedstoneWireNetwork;
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces;
import blusunrize.immersiveengineering.common.util.Utils;
import malte0811.industrialwires.IndustrialWires;
import malte0811.industrialwires.blocks.IBlockBoundsIW;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i;
import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Set;
import static blusunrize.immersiveengineering.api.energy.wires.WireType.REDSTONE_CATEGORY;
@ -56,49 +50,16 @@ public class TileEntityRSPanelIE extends TileEntityRSPanel
super.writeNBT(nbt, updatePacket);
nbt.setBoolean("hasConn", hasConn);
nbt.setInteger("facing", facing.getIndex());
if (updatePacket) {
writeConnsToNBT(nbt);
}
}
@Override
public void readNBT(NBTTagCompound nbt, boolean updatePacket) {
super.readNBT(nbt, updatePacket);
if (nbt.hasKey("connectionList", Constants.NBT.TAG_LIST)) {
loadConnsFromNBT(nbt);
}
hasConn = nbt.getBoolean("hasConn");
facing = EnumFacing.VALUES[nbt.getInteger("facing")];
aabb = null;
}
//Copied from IE (TileEntityImmersiveConnectable)
private void loadConnsFromNBT(NBTTagCompound nbt) {
if (world != null && world.isRemote && !Minecraft.getMinecraft().isSingleplayer() && nbt != null) {
NBTTagList connectionList = nbt.getTagList("connectionList", Constants.NBT.TAG_COMPOUND);
ImmersiveNetHandler.INSTANCE.clearConnectionsOriginatingFrom(Utils.toCC(this), world);
for (int i = 0; i < connectionList.tagCount(); i++) {
NBTTagCompound conTag = connectionList.getCompoundTagAt(i);
ImmersiveNetHandler.Connection con = ImmersiveNetHandler.Connection.readFromNBT(conTag);
if (con != null) {
ImmersiveNetHandler.INSTANCE.addConnection(world, Utils.toCC(this), con);
} else
IndustrialWires.logger.error("CLIENT read connection as null from {}", nbt);
}
}
}
private void writeConnsToNBT(NBTTagCompound nbt) {
if (world != null && !world.isRemote && nbt != null) {
NBTTagList connectionList = new NBTTagList();
Set<ImmersiveNetHandler.Connection> conL = ImmersiveNetHandler.INSTANCE.getConnections(world, Utils.toCC(this));
if (conL != null)
for (ImmersiveNetHandler.Connection con : conL)
connectionList.appendTag(con.writeToNBT());
nbt.setTag("connectionList", connectionList);
}
}
@Override
protected void updateOutput() {
wireNetwork.updateValues();
@ -256,12 +217,4 @@ public class TileEntityRSPanelIE extends TileEntityRSPanel
}
return aabb;
}
@Override
public void invalidate() {
super.invalidate();
if (world.isRemote && !Minecraft.getMinecraft().isSingleplayer()) {
ImmersiveNetHandler.INSTANCE.clearAllConnectionsFor(pos, world, this, false);
}
}
}

View file

@ -41,6 +41,7 @@ import malte0811.industrialwires.network.MessageTileSyncIW;
import malte0811.industrialwires.util.ConversionUtil;
import malte0811.industrialwires.util.JouleEnergyStorage;
import malte0811.industrialwires.util.MiscUtils;
import malte0811.industrialwires.wires.EnergyType;
import malte0811.industrialwires.wires.MixedWireType;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
@ -567,7 +568,7 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
}
@Override
public double insertEnergy(double joules, boolean simulate) {
public double insertEnergy(double joules, boolean simulate, EnergyType type) {
TileEntityMarx master = master(this);
if (master!=null) {
double ret = master.storage.insert(joules, 1, simulate, master.leftover);

View file

@ -20,13 +20,6 @@ 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;
@ -38,6 +31,7 @@ import malte0811.industrialwires.blocks.IBlockBoundsIW;
import malte0811.industrialwires.compat.Compat;
import malte0811.industrialwires.util.ConversionUtil;
import malte0811.industrialwires.util.MiscUtils;
import malte0811.industrialwires.wires.EnergyType;
import malte0811.industrialwires.wires.MixedWireType;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
@ -48,7 +42,6 @@ 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;
@ -58,6 +51,7 @@ import javax.annotation.Nullable;
import java.util.*;
import java.util.function.Consumer;
import static malte0811.industrialwires.wires.EnergyType.*;
import static malte0811.industrialwires.wires.MixedWireType.TIN;
@Optional.InterfaceList({
@ -78,7 +72,7 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
private double bufferToMachine = 0;
private double externalInputInTick = 0;
private double maxToMachine = 0;
//private EnergyType energyType = NONE;
private EnergyType energyType = NONE;
private boolean shouldBreak = false;
private final double maxIO;
private final MixedWireType wireType;
@ -141,6 +135,9 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
}
return;
}
if (externalInputInTick ==0 && potentialIEInputInTick == 0 && bufferToNet == 0 && bufferToMachine == 0) {
energyType = NONE;
}
if (bufferToNet < maxToNet) {
maxToNet = bufferToNet;
}
@ -164,12 +161,8 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
if (bufferToNet >EPS) {
notifyAvailableEnergy(bufferToNet);
}
if (bufferToMachine > EPS) {
if (bufferToMachine > EPS && energyType==FE_AC) {
transferPowerToFEMachine();
if (Loader.isModLoaded("gregtech"))
transferPowerToGTMachine();
if (Loader.isModLoaded("magneticraft"))
transferPowerToMagn();
}
}
}
@ -184,7 +177,7 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
IImmersiveConnectable iic = ApiUtils.toIIC(c.end, world);
if (iic instanceof IMixedConnector) {
double extract =
outputMax - ((IMixedConnector) iic).insertEnergy(outputMax, true);
outputMax - ((IMixedConnector) iic).insertEnergy(outputMax, true, energyType);
if (extract > EPS) {
maxOutputs.put(c, new ImmutablePair<>((IMixedConnector) iic, extract));
sum += extract;
@ -198,11 +191,11 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
Pair<IMixedConnector, Double> p = entry.getValue();
AbstractConnection c = entry.getKey();
double out = outputMax * p.getRight() / sum;
double loss = Math.min(getAverageLossRate(c), 1)*out;
double loss = energyType.getLoss(getAverageLossRate(c), bufferToNet, out);
out = Math.min(out, bufferToNet -loss);
if (out<=0)
continue;
double inserted = out - p.getLeft().insertEnergy(out, false);
double inserted = out - p.getLeft().insertEnergy(out, false, energyType);
double energyAtConn = inserted + loss;
bufferToNet -= energyAtConn;
float intermediaryLoss = 0;
@ -210,7 +203,7 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
for (Connection sub : c.subConnections) {
int transferredPerCon = transferedPerConn.getOrDefault(sub, 0);
energyAtConn -= sub.cableType.getLossRatio() * sub.length;
double wireLoad = energyAtConn;
double wireLoad = energyAtConn/(energyType==FE_AC?IWConfig.wireRatio:1);
transferedPerConn.put(sub, (int) (transferredPerCon + wireLoad));
IImmersiveConnectable subStart = ApiUtils.toIIC(sub.start, world);
IImmersiveConnectable subEnd = ApiUtils.toIIC(sub.end, world);
@ -236,42 +229,6 @@ 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);
@ -300,7 +257,7 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
for (Connection c : conn.subConnections) {
WireType type = c.cableType;
if (type instanceof MixedWireType) {
f += c.length * ((MixedWireType)type).getLoss();
f += c.length * ((MixedWireType)type).getLoss(energyType);
} else {
f = Double.POSITIVE_INFINITY;
}
@ -310,7 +267,13 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
//Input through the net
@Override
public double insertEnergy(double joules, boolean simulate) {
public double insertEnergy(double joules, boolean simulate, EnergyType type) {
if (energyType==NONE) {
energyType = type;
} else if (energyType!=type) {
shouldBreak = true;
return 0;
}
double insert = Math.min(getMaxIO() - bufferToMachine, joules);
insert = Math.min(getMaxIO()-actualIEInputInTick, insert);
if (!simulate) {
@ -324,7 +287,7 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
}
private double getMaxIO() {
return maxIO;
return maxIO*(energyType==FE_AC?IWConfig.wireRatio:1);
}
@Override
@ -401,18 +364,24 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
@Override
@Optional.Method(modid="ic2")
public double injectEnergy(EnumFacing directionFrom, double amount, double voltage) {
return amount-ConversionUtil.euPerJoule()*addToIn(ConversionUtil.joulesPerEu()*amount, false);
return amount-ConversionUtil.euPerJoule()*addToIn(ConversionUtil.joulesPerEu()*amount, false, EU_DC);
}
@Override
@Optional.Method(modid="ic2")
public double getOfferedEnergy() {
if (energyType != NONE && energyType != EU_DC) {
return .01;
}
return Math.min(maxToMachine, bufferToMachine) * ConversionUtil.euPerJoule();
}
@Override
@Optional.Method(modid="ic2")
public void drawEnergy(double amount) {
if (energyType != NONE && energyType != EU_DC) {
shouldBreak = true;
}
bufferToMachine -= amount*ConversionUtil.joulesPerEu();
markDirty();
}
@ -436,7 +405,12 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
}
// Returns amount of energy consumed
private double addToIn(double joules, boolean simulate) {
private double addToIn(double joules, boolean simulate, EnergyType type) {
if (energyType==NONE) {
energyType = type;
} else if (energyType!=type) {
shouldBreak = true;
}
joules = Math.min(getMaxIO() - externalInputInTick + .5, joules);
if (bufferToNet < getMaxIO()) {
if (!simulate) {
@ -468,6 +442,7 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
} else {
maxToMachine = bufferToMachine;
}
energyType = EnergyType.values()[nbt.getInteger("energyType")];
if (version==0) {
bufferToNet *= ConversionUtil.joulesPerEu();
bufferToMachine *= ConversionUtil.joulesPerEu();
@ -485,6 +460,7 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
nbt.setDouble("outBuffer", bufferToMachine);
nbt.setDouble("maxToNet", maxToNet);
nbt.setDouble("maxToMachine", maxToMachine);
nbt.setInteger("energyType", energyType.ordinal());
nbt.setInteger("version", 1);
}
@ -606,12 +582,15 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
return 0;
}
double joules = maxReceive*ConversionUtil.joulesPerIf();
double accepted = addToIn(joules, simulate);
double accepted = addToIn(joules, simulate, FE_AC);
return MathHelper.ceil(accepted*ConversionUtil.ifPerJoule());
}
@Override
public int extractEnergy(int maxExtract, boolean simulate) {
if (energyType!=FE_AC) {
return 0;
}
double joules = maxExtract*ConversionUtil.joulesPerIf();
if (joules>maxToMachine) {
joules = maxToMachine;

View file

@ -0,0 +1,38 @@
/*
* This file is part of Industrial Wires.
* Copyright (C) 2016-2018 malte0811
* Industrial Wires is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* Industrial Wires is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
*/
package malte0811.industrialwires.wires;
import malte0811.industrialwires.util.ConversionUtil;
public enum EnergyType {
FE_AC() {
@Override
public double getLoss(double averageLossRate, double available, double outMax) {
return Math.min(averageLossRate, 1)*outMax;
}
},
EU_DC() {
@Override
public double getLoss(double averageLossRate, double available, double outMax) {
return averageLossRate * ConversionUtil.joulesPerEu();
}
},
NONE;
public double getLoss(double averageLossRate, double available, double outMax) {
return available;
}
}

View file

@ -31,9 +31,9 @@ import javax.annotation.Nullable;
public class MixedWireType extends WireType {
public static final String IC2_TIN_CAT = "IC_TIN";
public static final String IC2_COPPER_CAT = "LV";
public static final String IC2_GOLD_CAT = "MV";
public static final String IC2_HV_CAT = "HV";
public static final String IC2_COPPER_CAT = "IC_COPPER";
public static final String IC2_GOLD_CAT = "IC_GOLD";
public static final String IC2_HV_CAT = "IC_HV";
public static final String IC2_GLASS_CAT = "IC_GLASS";
private final int type;
private final int[] ic2Colors = {0xa5bcc7, 0xbc7945, 0xfeff73, 0xb9d6d9, 0xf1f1f1};
@ -168,7 +168,16 @@ public class MixedWireType extends WireType {
return this==HV||this==GLASS;
}
public double getLoss() {
return getLossRatio();
public double getLoss(EnergyType energyType) {
switch (energyType) {
case FE_AC:
return getLossRatio();
case EU_DC:
return getLossRateEU();
case NONE:
default:
return 10;
}
}
}