Compare commits

..

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

21 changed files with 419 additions and 838 deletions

View file

@ -1,251 +1,246 @@
import groovy.json.JsonOutput
def mainVersion = "1.7"
def buildNumber = "38"
// For those who want the bleeding edge
buildscript {
repositories {
jcenter()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}
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
plugins {
id "net.minecraftforge.gradle.forge" version "2.0.2"
}
*/
version = "${mainVersion}-${buildNumber}"
group= "malte0811"
archivesBaseName = "IndustrialWires"
sourceCompatibility = 1.8
targetCompatibility = 1.8
minecraft {
version = "1.12.2-14.23.5.2847"
runDir = "run"
replace '${version}', project.version
mappings = "stable_39"
}
repositories {
maven {
name 'ic2'
url 'http://maven.ic2.player.to/'
}
maven {
name 'tr'
url 'http://maven.modmuss50.me'
}
maven {
name 'jared maven'
url 'http://blamejared.com/maven'
}
maven { // Albedo/Mirage Lights
url 'https://repo.elytradev.com/'
}
maven { // JEI & Tinkers
name 'DVS1 Maven FS'
url 'http://dvs1.progwml6.com/files/maven'
}
// dependencies of TR...
maven {
url 'http://maven.mcmoddev.com'
}
maven {
// HWYLA
name "TehNut"
url "http://tehnut.info/maven/"
}
repositories {//Curseforge maven for project red
maven {
name = "CurseForge"
url = "https://minecraft.curseforge.com/api/maven/"
}
}
maven {
name = "chickenbones"
url = "http://chickenbones.net/maven"
}
}
dependencies {
compile 'net.industrial-craft:industrialcraft-2:2.8.+'
deobfCompile "blusunrize:ImmersiveEngineering:0.12-+"
compileOnly "pl.asie.charset:charset:0.5.6.4.19: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"
//runtime "forge-multipart-cbe:ForgeMultipart-1.12.2:2.5.0.69:universal"
//runtime "codechicken:CodeChickenLib:1.12.2-3.2.1.349:universal"
//runtime "codechicken:ChickenASM:1.12-1.0.2.7"
//runtime "mrtjpcore:MrTJPCore-1.12.2:2.1.3.35:universal"
//Tech Reborn
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 "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"
}
jar {
from 'LICENSE'
manifest {
attributes 'Maven-Artifact': group+':'+archivesBaseName+':'+version
attributes "FMLAT": "industrialwires_at.cfg"
}
}
task signMain(type: SignJar) {
onlyIf {
project.hasProperty('keyStore')
}
dependsOn reobfJar
if (project.hasProperty('keyStore')) {
keyStore = project.keyStore
alias = project.storeAlias
storePass = project.storePass
keyPass = project.storePass
inputFile = jar.archivePath
outputFile = jar.archivePath
}
}
build.dependsOn signMain
processResources
{
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
expand 'version':project.version, 'mcversion':project.minecraft.version
}
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
//Code for automatic update JSON generation
class GenerateUpdateJSON extends DefaultTask {
static def IW_VERSION_PREFIX = "####Version "
static def MC_VERSION_PREFIX = "###Minecraft "
static def UNFINISHED_SUFFIX = " - UNFINISHED"
static def RECOMMENDED = "-recommended"
static def LATEST = "-latest"
static def CF_URL = "https://minecraft.curseforge.com/projects/industrial-wires"
int compareVersions(String vA, String vB) {
String[] vPartsA = vA.split("[\\D]")
String[] vPartsB = vB.split("[\\D]")
if (vPartsA.length==0&&vPartsB.length==0)
return vA <=> vB
else if (vPartsA.length==0)
return -1
else if (vPartsB.length==0)
return 1
int length = Math.min(vPartsA.length, vPartsB.length)
for (int i = 0;i<length;i++) {
int pA = Integer.parseInt(vPartsA[i])
int pB = Integer.parseInt(vPartsB[i])
if (pA!=pB) {
return pA<=>pB
}
}
if (vPartsA.length != vPartsB.length)
return vPartsA.length <=> vPartsB.length
return vA <=> vB
}
def addChangelog(Map<String, Map<String, String>> changelogForVersions, Map<String, String> promos,
String currentMCVersion, String currentVersion, String currentChangelog) {
if (!changelogForVersions.containsKey(currentMCVersion)) {
promos.put(currentMCVersion+RECOMMENDED, currentVersion)
promos.put(currentMCVersion+LATEST, currentVersion)
changelogForVersions[currentMCVersion] = new TreeMap<>({String s1, String s2->
compareVersions(s1, s2)})
}
changelogForVersions[currentMCVersion][currentVersion] = currentChangelog
}
@TaskAction
def generate() {
File changelog = new File("changelog.md")
if (!changelog.exists())
println "Changelog does not exist! Aborting!"
else {
String currentMCVersion = "";
Map<String, Map<String, String>> changelogForVersions = new HashMap<>()
Map<String, String> promos = new TreeMap<>({String s1, String s2->
compareVersions(s1, s2)})
String currentVersion = null
String currentChangelog = ""
changelog.eachLine {line ->
if (line.startsWith(IW_VERSION_PREFIX)) {
if (currentVersion!=null) {
addChangelog(changelogForVersions, promos, currentMCVersion, currentVersion, currentChangelog)
}
if (!line.endsWith(UNFINISHED_SUFFIX)) {
currentVersion = line.substring(IW_VERSION_PREFIX.length())
} else {
currentVersion = (String) null
}
currentChangelog = ""
} else if (line.startsWith(MC_VERSION_PREFIX)) {
if (currentVersion!=null) {
addChangelog(changelogForVersions, promos, currentMCVersion, currentVersion, currentChangelog)
}
currentChangelog = ""
currentVersion = (String) null
currentMCVersion = line.substring(MC_VERSION_PREFIX.length())
} else if (!line.isEmpty()) {
if (currentChangelog.length()==0)
currentChangelog += line
else
currentChangelog += "\n"+line
}
}
Map<String, Object> mainMap = new TreeMap<>({String s1, String s2->
compareVersions(s1, s2)})
mainMap.putAll(changelogForVersions)
mainMap["homepage"] = CF_URL
mainMap["promos"] = promos
def outJson = JsonOutput.toJson(mainMap)
outJson = JsonOutput.prettyPrint(outJson)
File outF = new File("changelog.json")
outF.delete()
outF << outJson
}
}
}
task updateJson(type: GenerateUpdateJSON)
build.finalizedBy updateJson
import groovy.json.JsonOutput
def mainVersion = "1.7"
def buildNumber = "33"
// For those who want the bleeding edge
buildscript {
repositories {
jcenter()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}
apply plugin: 'net.minecraftforge.gradle.forge'
/*
// for people who want stable - not yet functional for MC 1.8.8 - we require the forgegradle 2.1 snapshot
plugins {
id "net.minecraftforge.gradle.forge" version "2.0.2"
}
*/
version = "${mainVersion}-${buildNumber}"
group= "malte0811"
archivesBaseName = "IndustrialWires"
sourceCompatibility = 1.8
targetCompatibility = 1.8
minecraft {
version = "1.12.2-14.23.5.2768"
runDir = "run"
replace '${version}', project.version
mappings = "stable_39"
}
repositories {
maven {
name 'ic2'
url 'http://maven.ic2.player.to/'
}
maven {
name 'tr'
url 'http://maven.modmuss50.me'
}
maven {
name 'jared maven'
url 'http://blamejared.com/maven'
}
maven { // Albedo/Mirage Lights
url 'https://repo.elytradev.com/'
}
maven { // JEI & Tinkers
name 'DVS1 Maven FS'
url 'http://dvs1.progwml6.com/files/maven'
}
// dependencies of TR...
maven {
url 'http://maven.mcmoddev.com'
}
maven {
// HWYLA
name "TehNut"
url "http://tehnut.info/maven/"
}
repositories {//Curseforge maven for project red
maven {
name = "CurseForge"
url = "https://minecraft.curseforge.com/api/maven/"
}
}
maven {
name = "chickenbones"
url = "http://chickenbones.net/maven"
}
}
dependencies {
deobfCompile 'net.industrial-craft:industrialcraft-2:2.8.+'
deobfCompile "blusunrize:ImmersiveEngineering:0.12-+"
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"
//runtime "forge-multipart-cbe:ForgeMultipart-1.12.2:2.5.0.69:universal"
//runtime "codechicken:CodeChickenLib:1.12.2-3.2.1.349:universal"
//runtime "codechicken:ChickenASM:1.12-1.0.2.7"
//runtime "mrtjpcore:MrTJPCore-1.12.2:2.1.3.35:universal"
//Tech Reborn
compileOnly "TechReborn:TechReborn-1.12:2.6.+:dev"
compileOnly "RebornCore:RebornCore-1.12:3.2.+:dev"
//Others
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"
}
jar {
from 'LICENSE'
manifest {
attributes 'Maven-Artifact': group+':'+archivesBaseName+':'+version
attributes "FMLAT": "industrialwires_at.cfg"
}
}
task signMain(type: SignJar) {
onlyIf {
project.hasProperty('keyStore')
}
dependsOn reobfJar
if (project.hasProperty('keyStore')) {
keyStore = project.keyStore
alias = project.storeAlias
storePass = project.storePass
keyPass = project.storePass
inputFile = jar.archivePath
outputFile = jar.archivePath
}
}
build.dependsOn signMain
processResources
{
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
expand 'version':project.version, 'mcversion':project.minecraft.version
}
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
//Code for automatic update JSON generation
class GenerateUpdateJSON extends DefaultTask {
static def IW_VERSION_PREFIX = "####Version "
static def MC_VERSION_PREFIX = "###Minecraft "
static def UNFINISHED_SUFFIX = " - UNFINISHED"
static def RECOMMENDED = "-recommended"
static def LATEST = "-latest"
static def CF_URL = "https://minecraft.curseforge.com/projects/industrial-wires"
int compareVersions(String vA, String vB) {
String[] vPartsA = vA.split("[\\D]")
String[] vPartsB = vB.split("[\\D]")
if (vPartsA.length==0&&vPartsB.length==0)
return vA <=> vB
else if (vPartsA.length==0)
return -1
else if (vPartsB.length==0)
return 1
int length = Math.min(vPartsA.length, vPartsB.length)
for (int i = 0;i<length;i++) {
int pA = Integer.parseInt(vPartsA[i])
int pB = Integer.parseInt(vPartsB[i])
if (pA!=pB) {
return pA<=>pB
}
}
if (vPartsA.length != vPartsB.length)
return vPartsA.length <=> vPartsB.length
return vA <=> vB
}
def addChangelog(Map<String, Map<String, String>> changelogForVersions, Map<String, String> promos,
String currentMCVersion, String currentVersion, String currentChangelog) {
if (!changelogForVersions.containsKey(currentMCVersion)) {
promos.put(currentMCVersion+RECOMMENDED, currentVersion)
promos.put(currentMCVersion+LATEST, currentVersion)
changelogForVersions[currentMCVersion] = new TreeMap<>({String s1, String s2->
compareVersions(s1, s2)})
}
changelogForVersions[currentMCVersion][currentVersion] = currentChangelog
}
@TaskAction
def generate() {
File changelog = new File("changelog.md")
if (!changelog.exists())
println "Changelog does not exist! Aborting!"
else {
String currentMCVersion = "";
Map<String, Map<String, String>> changelogForVersions = new HashMap<>()
Map<String, String> promos = new TreeMap<>({String s1, String s2->
compareVersions(s1, s2)})
String currentVersion = null
String currentChangelog = ""
changelog.eachLine {line ->
if (line.startsWith(IW_VERSION_PREFIX)) {
if (currentVersion!=null) {
addChangelog(changelogForVersions, promos, currentMCVersion, currentVersion, currentChangelog)
}
if (!line.endsWith(UNFINISHED_SUFFIX)) {
currentVersion = line.substring(IW_VERSION_PREFIX.length())
} else {
currentVersion = (String) null
}
currentChangelog = ""
} else if (line.startsWith(MC_VERSION_PREFIX)) {
if (currentVersion!=null) {
addChangelog(changelogForVersions, promos, currentMCVersion, currentVersion, currentChangelog)
}
currentChangelog = ""
currentVersion = (String) null
currentMCVersion = line.substring(MC_VERSION_PREFIX.length())
} else if (!line.isEmpty()) {
if (currentChangelog.length()==0)
currentChangelog += line
else
currentChangelog += "\n"+line
}
}
Map<String, Object> mainMap = new TreeMap<>({String s1, String s2->
compareVersions(s1, s2)})
mainMap.putAll(changelogForVersions)
mainMap["homepage"] = CF_URL
mainMap["promos"] = promos
def outJson = JsonOutput.toJson(mainMap)
outJson = JsonOutput.prettyPrint(outJson)
File outF = new File("changelog.json")
outF.delete()
outF << outJson
}
}
}
task updateJson(type: GenerateUpdateJSON)
build.finalizedBy updateJson

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-33",
"1.12.2-recommended": "1.7-33"
},
"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,6 @@
"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)"
}
}

View file

@ -1,21 +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
####Version 1.7-34
- Control panels can use the texture of any block now
- Added a recipe to copy the settings of an unfinished control panel
- The Marx generator now returns the wires used in its construction when disassembled
- Fixed the RS controller for non-IE wires not keeping its IO state on world reload
- Fixed control panels not working correctly with multiple controllers
####Version 1.7-33
- Fixed the Marx generator not processing ores
- Fixed control panels and the Marx generator not working when connected directly

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

@ -78,7 +78,6 @@ public abstract class TileEntityIWMultiblock extends TileEntityIWBase implements
T master = master(here);
return master!=null?master:def;
}
public void disassemble() {
if (formed && !world.isRemote) {
BlockPos startPos = getOrigin();

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

@ -23,7 +23,6 @@ import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler;
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.IESaveData;
import blusunrize.immersiveengineering.common.blocks.BlockTypes_MetalsIE;
import blusunrize.immersiveengineering.common.blocks.metal.*;
import blusunrize.immersiveengineering.common.util.Utils;
@ -41,6 +40,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;
@ -159,6 +159,8 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
return getPos().subtract(offset).offset(facing.getOpposite(), 3);
}
@SuppressWarnings("unchecked")
@Override
public IBlockState getOriginalBlock() {
int forward = getForward();
@ -189,53 +191,6 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
}
}
@Override
public void disassemble() {
boolean active = formed && !world.isRemote;
IndustrialWires.logger.info("Calling disassemble for {}, active {}", pos, active);
super.disassemble();
if (active) {
final int forward = -1;
BlockPos master = pos.subtract(offset);
ItemStack coil = new ItemStack(IEObjects.itemWireCoil, 1, 2);
WireType type = WireType.STEEL;
TargetingInfo dummy = new TargetingInfo(EnumFacing.DOWN, 0, 0, 0);
for (int up = 0; up < stageCount - 1; ++up) {
for (int right = 0; right < 2; ++right) {
BlockPos lowerPos = offset(master, facing, mirrored, right, forward, up);
BlockPos upperPos = lowerPos.up();
IndustrialWires.logger.info("Lower: {}, upper: {}, master: {}", lowerPos, upperPos, master);
TileEntity lowerTE = world.getTileEntity(lowerPos);
if (!(lowerTE instanceof IImmersiveConnectable)) {
world.spawnEntity(new EntityItem(world, lowerPos.getX() + .5, lowerPos.getY() + .5,
lowerPos.getZ() + .5, coil));
continue;
}
TileEntity upperTE = world.getTileEntity(upperPos);
if (!(upperTE instanceof IImmersiveConnectable)) {
world.spawnEntity(new EntityItem(world, lowerPos.getX() + .5, lowerPos.getY() + .5,
lowerPos.getZ() + .5, coil));
continue;
}
IImmersiveConnectable lowerIIC = (IImmersiveConnectable) lowerTE;
IImmersiveConnectable upperIIC = (IImmersiveConnectable) upperTE;
ImmersiveNetHandler.Connection conn = ImmersiveNetHandler.INSTANCE.addAndGetConnection(world,
lowerPos, upperPos, 1, type);
lowerIIC.connectCable(type, dummy, upperIIC);
upperIIC.connectCable(type, dummy, lowerIIC);
ImmersiveNetHandler.INSTANCE.addBlockData(world, conn);
IESaveData.setDirty(world.provider.getDimension());
lowerTE.markDirty();
IBlockState state = world.getBlockState(lowerPos);
world.notifyBlockUpdate(lowerPos, state, state, 3);
upperTE.markDirty();
state = world.getBlockState(upperPos);
world.notifyBlockUpdate(upperPos, state, state, 3);
}
}
}
}
@Override
public void update() {
ApiUtils.checkForNeedlessTicking(this);
@ -567,7 +522,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);
@ -585,9 +540,8 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
return pos;
}
@Override
public boolean canConnectCable(WireType cableType, TargetingInfo target, Vec3i offset) {
public boolean canConnectCable(WireType cableType, TargetingInfo target) {
if (hasConnection) {
return false;
}
@ -631,7 +585,7 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
}
@Override
public Vec3d getConnectionOffset(ImmersiveNetHandler.Connection con) {
public Vec3d getRaytraceOffset(IImmersiveConnectable link) {
Matrix4 transf = getBaseTransform();
if (getRight()==0) {
return transf.apply(new Vec3d(.5, .5, 7/16D));
@ -640,19 +594,24 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
}
}
@Override
public Vec3d getConnectionOffset(ImmersiveNetHandler.Connection con) {
return getRaytraceOffset(null);
}
@Override
public void validate()
{
super.validate();
if (!world.isRemote)
ApiUtils.addFutureServerTask(world, () -> ImmersiveNetHandler.INSTANCE.onTEValidated(this));
ImmersiveNetHandler.INSTANCE.resetCachedIndirectConnections();
}
@Override
public void invalidate()
{
super.invalidate();
if (world.isRemote && !IndustrialWires.proxy.isSingleplayer())
if (world.isRemote)
ImmersiveNetHandler.INSTANCE.clearConnectionsOriginatingFrom(pos, world);
}

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

@ -42,7 +42,6 @@ import malte0811.industrialwires.client.manual.TextSplitter;
import malte0811.industrialwires.client.multiblock_io_model.MBIOModelLoader;
import malte0811.industrialwires.client.panelmodel.PanelModelLoader;
import malte0811.industrialwires.client.render.*;
import malte0811.industrialwires.compat.Compat;
import malte0811.industrialwires.controlpanel.PanelComponent;
import malte0811.industrialwires.crafting.IC2TRHelper;
import malte0811.industrialwires.entities.EntityBrokenPart;
@ -191,24 +190,22 @@ public class ClientProxy extends CommonProxy {
new ManualPages.Text(m, "industrialwires.jacobs1"));
String text = I18n.format("ie.manual.entry.industrialwires.intro");
splitter = new TextSplitter(m);
splitter.addSpecialPage(0, 0, 9, s -> new ManualPages.Crafting(m, s,
new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.DUMMY.ordinal())));
splitter.addSpecialPage(1, 0, 9, s -> new ManualPages.Crafting(m, s,
new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.UNFINISHED.ordinal())));
splitter.split(text);
m.addEntry("industrialwires.intro", "control_panels",
splitter.toManualEntry().toArray(new IManualPage[0])
new ManualPages.Text(m, "industrialwires.intro0"),
new ManualPages.Text(m, "industrialwires.intro1"),
new ManualPages.Crafting(m, "industrialwires.intro2", new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.DUMMY.ordinal())),
new ManualPages.Text(m, "industrialwires.intro3"),
new ManualPages.Crafting(m, "industrialwires.intro4", new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.UNFINISHED.ordinal())),
new ManualPages.Text(m, "industrialwires.intro5")
);
m.addEntry("industrialwires.panel_creator", "control_panels",
new ManualPages.Crafting(m, "industrialwires.panel_creator0", new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.CREATOR.ordinal())),
new ManualPages.Text(m, "industrialwires.panel_creator1"),
new ManualPages.Text(m, "industrialwires.panel_creator2")
);
text = I18n.format("ie.manual.entry.industrialwires.redstone");
String text = I18n.format("ie.manual.entry.industrialwires.redstone");
splitter = new TextSplitter(m);
splitter.addSpecialPage(-1, 0, Compat.enableOtherRS ? 9 : 12, s -> new ManualPages.CraftingMulti(m, s,
splitter.addSpecialPage(-1, 0, 10, s -> new ManualPages.CraftingMulti(m, s,
new ResourceLocation(IndustrialWires.MODID, "control_panel_rs_other"),
new ResourceLocation(IndustrialWires.MODID, "control_panel_rs_wire")));
splitter.split(text);
@ -227,8 +224,7 @@ public class ClientProxy extends CommonProxy {
new ManualPages.CraftingMulti(m, "industrialwires.lock", new ItemStack(IndustrialWires.panelComponent, 1, 7), new ItemStack(IndustrialWires.key)),
new ManualPages.Crafting(m, "industrialwires.lock1", new ItemStack(IndustrialWires.key, 1, 2)),
new ManualPages.Crafting(m, "industrialwires.panel_meter", new ItemStack(IndustrialWires.panelComponent, 1, 8)),
new ManualPages.Crafting(m, "industrialwires.7seg", new ItemStack(IndustrialWires.panelComponent, 1, 9)),
new ManualPages.Crafting(m, "industrialwires.rgb_led", new ItemStack(IndustrialWires.panelComponent, 1, 10))
new ManualPages.Crafting(m, "industrialwires.7seg", new ItemStack(IndustrialWires.panelComponent, 1, 9))
);
List<MarxOreHandler.OreInfo> ores = MarxOreHandler.getRecipes();
text = I18n.format("ie.manual.entry.industrialwires.marx");
@ -471,8 +467,7 @@ public class ClientProxy extends CommonProxy {
IBakedModel texModel = Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(stack,
null, null);
TextureAtlasSprite sprite = texModel.getParticleTexture();
//noinspection ConstantConditions
if (sprite == null || sprite.hasAnimationMetadata()) {
if (sprite.hasAnimationMetadata()) {
return false;
}
int[][] data = sprite.getFrameTextureData(0);

View file

@ -66,7 +66,6 @@ public abstract class PanelComponent implements IOwner {
baseCreaters.put("lock", Lock::new);
baseCreaters.put("panel_meter", PanelMeter::new);
baseCreaters.put(SevenSegDisplay.NAME, SevenSegDisplay::new);
baseCreaters.put("rgb_led", RGBIndicator::new);
//Check that all components implement equals+hashCode if in a dev env
boolean isDevEnv = "NBTTagCompound".equals(NBTTagCompound.class.getSimpleName());
if (isDevEnv) {

View file

@ -179,7 +179,6 @@ public class PropertyComponents implements IUnlistedProperty<PropertyComponents.
ret.facing = facing;
ret.top = top;
ret.angle = angle;
ret.height = height;
ret.textureSource = textureSource;
return ret;
}

View file

@ -1,277 +0,0 @@
/*
* 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.controlpanel;
import malte0811.industrialwires.IndustrialWires;
import malte0811.industrialwires.client.RawQuad;
import malte0811.industrialwires.client.gui.GuiPanelCreator;
import malte0811.industrialwires.controlpanel.ControlPanelNetwork.RSChannel;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTBase;
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.Vec3d;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.util.vector.Vector3f;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static malte0811.industrialwires.util.NBTKeys.RS_CHANNEL;
import static malte0811.industrialwires.util.NBTKeys.RS_ID;
public class RGBIndicator extends PanelComponent implements IConfigurableComponent {
@Nonnull
private RSChannel[] input = {RSChannel.DEFAULT_CHANNEL, RSChannel.DEFAULT_CHANNEL, RSChannel.DEFAULT_CHANNEL};
private int rgbState;
public RGBIndicator() {
super("rgb_led");
}
public RGBIndicator(@Nonnull RSChannel[] input) {
this();
this.input = input;
}
@Override
protected void writeCustomNBT(NBTTagCompound nbt, boolean toItem) {
NBTTagList channels = new NBTTagList();
for (RSChannel c : input) {
NBTTagCompound ch = new NBTTagCompound();
ch.setInteger(RS_ID, c.getController());
ch.setByte(RS_CHANNEL, c.getColor());
channels.appendTag(ch);
}
nbt.setTag("channels", channels);
if (!toItem) {
nbt.setInteger("rgb", rgbState);
}
}
@Override
protected void readCustomNBT(NBTTagCompound nbt) {
NBTTagList channels = nbt.getTagList("channels", Constants.NBT.TAG_COMPOUND);
if (channels.tagCount() == 3) {
RSChannel[] in = new RSChannel[channels.tagCount()];
for (int i = 0; i < in.length; i++) {
NBTTagCompound ch = channels.getCompoundTagAt(i);
int rsController = ch.getInteger(RS_ID);
byte rsColor = ch.getByte(RS_CHANNEL);
in[i] = new RSChannel(rsController, rsColor);
}
input = in;
}
rgbState = nbt.getInteger("rgb");
}
private static final float size = .0625F;
@Override
@SideOnly(Side.CLIENT)
public List<RawQuad> getQuads() {
float[] color = new float[4];
color[3] = 1;
for (int i = 0; i < 3; i++) {
color[i] = ((rgbState >> (i * 8)) & 255) / 255F;
}
List<RawQuad> ret = new ArrayList<>(1);
PanelUtils.addColoredQuad(ret, new Vector3f(), new Vector3f(0, 0, size), new Vector3f(size, 0, size), new Vector3f(size, 0, 0), EnumFacing.UP, color);
if (rgbState > 0) {
ret.get(ret.size() - 1).light = 0xff0ff;
}
return ret;
}
@Nonnull
@Override
public PanelComponent copyOf() {
RGBIndicator ret = new RGBIndicator(Arrays.copyOf(input, input.length));
ret.rgbState = rgbState;
ret.setX(x);
ret.setY(y);
ret.panelHeight = panelHeight;
return ret;
}
@Nonnull
@Override
public AxisAlignedBB getBlockRelativeAABB() {
if (aabb == null) {
aabb = new AxisAlignedBB(x, 0, y, x + size, 0, y + size);
}
return aabb;
}
@Override
public void interactWith(Vec3d hitRelative, EntityPlayerMP player) {
}
@Override
public void update() {
}
@Override
public void setNetwork(ControlPanelNetwork net) {
super.setNetwork(net);
for (int i = 0; i < input.length; i++) {
int finalI = i;
net.addListener(this, (state) -> {
byte currState = (byte) ((rgbState >> (8 * finalI + 4)) & 15);
if (state.getStrength() != currState) {
rgbState &= ~(255 << (8 * finalI));
rgbState |= state.getStrength() << (8 * finalI + 4);
panel.markDirty();
panel.triggerRenderUpdate();
}
}, input[i]);
}
}
@Override
public float getHeight() {
return 0;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
RGBIndicator that = (RGBIndicator) o;
return rgbState == that.rgbState;
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + rgbState;
return result;
}
@Override
@SideOnly(Side.CLIENT)
public void renderInGUI(GuiPanelCreator gui) {
AxisAlignedBB aabb = getBlockRelativeAABB();
int left = (int) (gui.getX0() + aabb.minX * gui.panelSize);
int top = (int) (gui.getY0() + aabb.minZ * gui.panelSize);
int right = (int) (gui.getX0() + aabb.maxX * gui.panelSize);
int bottom = (int) (gui.getY0() + aabb.maxZ * gui.panelSize);
int width = right - left;
int height = bottom - top;
for (int colorId = 0; colorId < 3; ++colorId) {
int color = (0xff << (colorId * 8)) | 0xff000000;
for (int row = 0; row < 3; ++row) {
int col = (row * (row + 1) + colorId) % 3;
Gui.drawRect(Math.round(left + width * col / 3.0F),
Math.round(top + height * row / 3.0F),
Math.round(left + width * (col + 1) / 3.0F),
Math.round(top + height * (row + 1) / 3.0F),
color);
}
}
}
@Override
public void applyConfigOption(ConfigType type, int id, NBTBase value) {
switch (type) {
case RS_CHANNEL:
input[id] = input[id].withColor(value);
break;
case INT:
input[id] = input[id].withController(value);
break;
}
}
@Nullable
@Override
@SideOnly(Side.CLIENT)
public String fomatConfigName(ConfigType type, int id) {
switch (type) {
case FLOAT:
return I18n.format(IndustrialWires.MODID + ".desc." + (id == 0 ? "red" : (id == 1 ? "green" : "blue")));
case RS_CHANNEL:
case INT:
default:
return null;
}
}
@Nullable
@Override
@SideOnly(Side.CLIENT)
public String fomatConfigDescription(ConfigType type, int id) {
String color = null;
switch (id) {
case 0:
color = "red";
break;
case 1:
color = "green";
break;
case 2:
color = "blue";
break;
}
switch (type) {
case FLOAT:
return null;
case RS_CHANNEL:
return I18n.format(IndustrialWires.MODID + ".desc.rschannel_" + color);
case INT:
return I18n.format(IndustrialWires.MODID + ".desc.rsid_" + color);
default:
return null;
}
}
@Override
public RSColorConfig[] getRSChannelOptions() {
return new RSColorConfig[]{
new RSColorConfig("channelR", 0, 10, input[0].getColor()),
new RSColorConfig("channelG", 50, 10, input[1].getColor()),
new RSColorConfig("channelB", 0, 70, input[2].getColor())
};
}
@Override
public IntConfig[] getIntegerOptions() {
return new IntConfig[]{
new IntConfig("rsIdR", 0, 0, input[0].getController(), 2, false),
new IntConfig("rsIdG", 50, 0, input[1].getController(), 2, false),
new IntConfig("rsIdB", 0, 60, input[2].getController(), 2, false)
};
}
@Override
public int getColor() {
return 0xffffff;
}
}

View file

@ -193,13 +193,13 @@ public class Variac extends PanelComponent implements IConfigurableComponent {
int bottom = (int) Math.floor(gui.getY0() + (aabb.maxZ - offset) * gui.panelSize);
GlStateManager.pushMatrix();
GlStateManager.translate((left + right) / 2F, (top + bottom) / 2F, 0);
GlStateManager.translate((left + right) / 2, (top + bottom) / 2, 0);
GlStateManager.rotate(360 / 17F, 0, 0, 1);
GlStateManager.translate(-(left + right) / 2F, -(top + bottom) / 2F, 0);
GlStateManager.translate(-(left + right) / 2, -(top + bottom) / 2, 0);
Gui.drawRect(left, top, right, bottom, 0xff333333);
GlStateManager.translate((left + right) / 2F, (top + bottom) / 2F, 0);
GlStateManager.translate((left + right) / 2, (top + bottom) / 2, 0);
GlStateManager.rotate(45, 0, 0, 1);
GlStateManager.translate(-(left + right) / 2F, -(top + bottom) / 2F, 0);
GlStateManager.translate(-(left + right) / 2, -(top + bottom) / 2, 0);
Gui.drawRect(left, top, right, bottom, 0xff333333);
GlStateManager.popMatrix();
}

View file

@ -21,15 +21,11 @@ import malte0811.industrialwires.IndustrialWires;
import malte0811.industrialwires.compat.Compat;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraftforge.common.crafting.CompoundIngredient;
import net.minecraftforge.common.crafting.IngredientNBT;
import net.minecraftforge.oredict.OreIngredient;
import techreborn.api.TechRebornAPI;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;
public final class IC2TRHelper {
public static Ingredient getStack(String type, String variant) {
@ -38,57 +34,55 @@ public final class IC2TRHelper {
return new OreIngredient("itemRubber");
}
}
Collection<Ingredient> ingreds;
{
Set<ItemStack> stacks = new HashSet<>(Compat.getIC2Item.apply(type, variant));
if (IndustrialWires.hasTechReborn) {
switch (type) {
case "cable":
stacks.add(getTRCable(variant));
break;
case "crafting":
if ("alloy".equals(variant)) {
Set<ItemStack> stacks = new HashSet<>(Compat.getIC2Item.apply(type, variant));
if (IndustrialWires.hasTechReborn) {
switch (type) {
case "cable":
stacks.add(getTRCable(variant));
break;
case "crafting":
switch (variant) {
case "alloy":
stacks.add(TechRebornAPI.subItemRetriever.getPlateByName("advanced_alloy"));
}
break;
case "te":
if (variant.equals("mv_transformer")) {
stacks.add(new ItemStack(TechRebornAPI.getBlock("MV_TRANSFORMER")));
}
}
break;
}
break;
case "te":
if (variant.equals("mv_transformer")) {
stacks.add(new ItemStack(TechRebornAPI.getBlock("MV_TRANSFORMER")));
}
}
stacks.removeIf(ItemStack::isEmpty);
ingreds = stacks.stream().map(MyNBTIngredient::new).collect(Collectors.toList());
}
if (ingreds.isEmpty()) {
stacks.removeIf(ItemStack::isEmpty);
if (stacks.isEmpty()) {
switch (type) {
case "cable":
return getIECable(variant.substring("type:".length(), variant.indexOf(',')));
case "crafting":
switch (variant) {
case "coil":
ingreds.add(new MyIngredient(new ItemStack(IEObjects.blockMetalDecoration0)));
stacks.add(new ItemStack(IEObjects.blockMetalDecoration0));
break;
case "alloy":
return new OreIngredient("plateConstantan");
case "electric_motor":
ingreds.add(new MyIngredient(new ItemStack(IEObjects.itemMaterial, 1, 27)));
stacks.add(new ItemStack(IEObjects.itemMaterial, 1, 27));
break;
case "rubber":
ingreds.add(new MyIngredient(new ItemStack(IEObjects.itemMaterial, 1, 13)));
stacks.add(new ItemStack(IEObjects.itemMaterial, 1, 13));
break;
}
break;
case "te":
if (variant.equals("mv_transformer")) {
ingreds.add(new MyIngredient(new ItemStack(IEObjects.blockConnectors, 1, 7)));
stacks.add(new ItemStack(IEObjects.blockConnectors, 1, 7));
}
}
}
if (ingreds.size() == 0) {
if (stacks.size()==0) {
IndustrialWires.logger.info("No ingredient found for "+type+", "+variant);
}
return new MyCompoundIngredient(ingreds);
return Ingredient.fromStacks(stacks.toArray(new ItemStack[0]));
}
public static ItemStack getTRCable(String variant) {
@ -133,22 +127,4 @@ public final class IC2TRHelper {
type = Character.toUpperCase(type.charAt(0))+type.substring(1);
return new OreIngredient("wire"+type);
}
private static class MyNBTIngredient extends IngredientNBT {
public MyNBTIngredient(ItemStack stack) {
super(stack);
}
}
private static class MyCompoundIngredient extends CompoundIngredient {
public MyCompoundIngredient(Collection<Ingredient> children) {
super(children);
}
}
private static class MyIngredient extends Ingredient {
public MyIngredient(ItemStack stack) {
super(stack);
}
}
}

View file

@ -34,7 +34,7 @@ import javax.annotation.Nonnull;
public class RecipePanelTexture extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe {
@Override
public boolean matches(@Nonnull InventoryCrafting inv, @Nonnull World worldIn) {
int texX = -1, texY = -1;
boolean foundTexture = false;
boolean foundPanel = false;
for (int x = 0; x < inv.getWidth(); x++) {
for (int y = 0; y < inv.getHeight(); y++) {
@ -44,23 +44,18 @@ public class RecipePanelTexture extends IForgeRegistryEntry.Impl<IRecipe> implem
return false;
}
foundPanel = true;
} else if (!here.isEmpty()) {
if (texX == -1) {
texX = x;
texY = y;
} else {
} else if (IndustrialWires.proxy.isValidTextureSource(here)) {
if (foundTexture || (here.getItem() == Item.getItemFromBlock(IndustrialWires.panel)
&& here.getMetadata() != BlockTypes_Panel.DUMMY.ordinal())) {
return false;
}
foundTexture = true;
} else if (!here.isEmpty()) {
return false;
}
}
}
if (!foundPanel || texX == -1) {
return false;
}
ItemStack texSource = inv.getStackInRowAndColumn(texX, texY);
return IndustrialWires.proxy.isValidTextureSource(texSource) &&
(texSource.getItem() != Item.getItemFromBlock(IndustrialWires.panel)
|| texSource.getMetadata() == BlockTypes_Panel.DUMMY.ordinal());
return foundPanel && foundTexture;
}
private boolean isUnfinishedPanel(ItemStack stack) {
@ -85,7 +80,7 @@ public class RecipePanelTexture extends IForgeRegistryEntry.Impl<IRecipe> implem
}
assert texture != null && panel != null;
NBTTagCompound texAsNBT = texture.serializeNBT();
ItemStack ret = ApiUtils.copyStackWithAmount(panel, 1);
ItemStack ret = panel.copy();
if (ret.getTagCompound() == null) {
ItemNBTHelper.setFloat(ret, NBTKeys.ANGLE, 0);
ItemNBTHelper.setFloat(ret, NBTKeys.HEIGHT, .5F);

View file

@ -17,8 +17,10 @@ package malte0811.industrialwires.crafting.factories;
import com.google.gson.JsonObject;
import malte0811.industrialwires.crafting.IC2TRHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraftforge.common.crafting.IIngredientFactory;
import net.minecraftforge.common.crafting.IngredientNBT;
import net.minecraftforge.common.crafting.JsonContext;
import javax.annotation.Nonnull;
@ -31,4 +33,10 @@ public class IC2ItemFactory implements IIngredientFactory {
String variant = json.get("variant").getAsString();
return IC2TRHelper.getStack(name, variant);
}
private class MyNBTIngredient extends IngredientNBT {
public MyNBTIngredient(ItemStack stack) {
super(stack);
}
}
}

View file

@ -53,7 +53,7 @@ import static malte0811.industrialwires.util.NBTKeys.*;
public class ItemPanelComponent extends Item implements INetGUIItem {
public static final String[] types = {
"lighted_button", "label", "indicator_light", "slider", "variac", "toggle_switch", "toggle_switch_covered",
"lock", "panel_meter", SevenSegDisplay.NAME, "rgb_led"
"lock", "panel_meter", SevenSegDisplay.NAME
};
public static final String NAME = "panel_component";

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;
}
}
}

View file

@ -45,7 +45,6 @@ item.industrialwires.panel_component.toggle_switch_covered.name=Covered Toggle S
item.industrialwires.panel_component.lock.name=Lock Switch
item.industrialwires.panel_component.panel_meter.name=Panel Meter
item.industrialwires.panel_component.7seg.name=7-Segment Display
item.industrialwires.panel_component.rgb_led.name=RGB Indicator
item.industrialwires.key.key.name=Key
item.industrialwires.key.key_named.name=Key for
item.industrialwires.key.blank_key.name=Blank Key
@ -83,12 +82,6 @@ industrialwires.desc.rsid_info=The ID of the redstone wire controller to interac
industrialwires.desc.rschannel_info=The color of the channel to use
industrialwires.desc.rsid_info2=The ID of the redstone wire controller for the second signal. -1 to disable.
industrialwires.desc.rschannel_info2=The color of the channel to use for the second signal
industrialwires.desc.rschannel_red=The color of the channel to use for the red signal
industrialwires.desc.rschannel_green=The color of the channel to use for the green signal
industrialwires.desc.rschannel_blue=The color of the channel to use for the blue signal
industrialwires.desc.rsid_red=The ID of the redstone wire controller for the red signal
industrialwires.desc.rsid_green=The ID of the redstone wire controller for the green signal
industrialwires.desc.rsid_blue=The ID of the redstone wire controller for the blue signal
industrialwires.desc.label_text=The text in this label
industrialwires.desc.red=Red
industrialwires.desc.green=Green
@ -174,7 +167,12 @@ ie.manual.entry.industrialwires.mech_mb_parts.commutator=<np><&4>The commutator
ie.manual.entry.industrialwires.intro.name=Introduction
ie.manual.entry.industrialwires.intro.subtext=
ie.manual.entry.industrialwires.intro=Control Panels allow you to monitor and control a large amount of redstone signals using only a few blocks. Those signals can currently be connected using redstone wires and connectors.<br>Buttons, switches, indicator lights and other things that can be placed on a control panel are called §l(Panel) Components§r<br>To create a control panel you will need a Panel Creator, the individual components and an Unfinished Panel (which determines the shape of the panel). Each component is described in the entry "Panel Components". Right-clicking with a panel component opens up a GUI in which the properties of the component, like the redstone channel and ID or the color, can be configured.<np><&0>A §l(panel) network§r is formed by panel blocks connected to each other, directly or through other panel blocks. Panel blocks include the control panel itself, the panel connector and the Redstone Wire Controller. If multiple components in one network are configured to modify the same redstone signal, the resulting signal will be the highest of the individual signals. Having multiple components accepting the same signal on a network is valid as well.<np><&1>The §lUnfinished Control Panel§r is used as the casing of a control panel. It can be configured by putting it into an Engineer's Workbench. The slider labeled "Height" changes the height in the middle of the panel. The "Angle" slider changes the angle of the panel relative to the surface it is placed on, creating tilted panels. The sliders will automatically clamp to the highest/lowest angle/height the panel can have without being partially outside the block. The values might not visually clamp due to the way the Workbench works, closing and re-opening the GUI should fix this.<br>The texture of the panel can be changed to the texture of most blocks by placing the unfinished panel in a crafting table with the block.<br>All settings (height, angle and texture) of an unfinished panel can be copied by placing it in a crafting table above another unfinished control panel.
ie.manual.entry.industrialwires.intro0=Control Panels allow you to monitor and control a large amount of redstone signals using only a few blocks. Those signals can currently be connected using redstone wires and connectors.<br>Buttons, switches, indicator lights and other things that can be placed on a control panel are called §l(Panel) Components§r<br>To create a control panel you will need a Panel Creator, the individual components and an Unfinished Panel (which determines the shape of the
ie.manual.entry.industrialwires.intro1=panel). Each component is described in the entry "Panel Components". Right-clicking with a panel component opens up a GUI in which the properties of the component, like the redstone channel and ID or the color, can be configured.
ie.manual.entry.industrialwires.intro2=A §l(panel) network§r is formed by panel blocks connected to each other, directly or through other panel blocks. Panel blocks include the control panel itself, the panel connector and the Redstone Wire Controller. If multiple components in one network are configured to modify the same
ie.manual.entry.industrialwires.intro3=redstone signal, the resulting signal will be the highest of the individual signals. Having multiple components accepting the same signal on a network is valid as well.
ie.manual.entry.industrialwires.intro4=The §lUnfinished Control Panel§r is used as the casing of a control panel. It can be configured by putting it into an Engineer's Workbench. The slider labeled "Height" changes the height in the middle of the panel. The "Angle" slider changes the angle of the panel relative to the surface it is
ie.manual.entry.industrialwires.intro5=placed on, creating tilted panels. The sliders will automatically clamp to the highest/lowest angle/height the panel can have without being partially outside the block. The values might not visually clamp due to the way the Workbench works, closing and re-opening the GUI should fix this.
ie.manual.entry.industrialwires.panel_creator.name=Panel Creator
ie.manual.entry.industrialwires.panel_creator.subtext=
@ -199,5 +197,4 @@ ie.manual.entry.industrialwires.variac=A Variac® is a variable autotransformer.
ie.manual.entry.industrialwires.lock=A lock switch activates a redstone signal when a key is inserted and turned. A newly crafted lock will have a unique key configuration. By placing a blank key and a lock in a crafting table a key for the lock can be created. Multiple locks fitting the same key can be created using component copying (see page 1). Keys can be named in a GUI opened by right-clicking with them.
ie.manual.entry.industrialwires.lock1=Up to <config;I;iwKeysOnRing> can be combined on a key ring. Keys are added to the ring by placing both in a crafting table. Shift-right-click the key ring to cycle through the keys on the ring. The selected key can be removed from the ring by placing the ring in a crafting table. The key ring will work just as the selected key would on lock switches.
ie.manual.entry.industrialwires.panel_meter=A panel meter can be used to show display analog redstone signals with some accuracy. Panel meters are available in two different formats, wide and narrow. The difference between the formats is purely visual.
ie.manual.entry.industrialwires.7seg=Seven-Segment Displays are a way of displaying analog redstone signals precisely. Signal strengths 0-9 are displayed as one would expect, levels 10-15 are represented by the letters A-E. Some of the letters are lower-case to differentiate them from digits (e.g. 8 vs B).
ie.manual.entry.industrialwires.rgb_led=RGB Indicators consist of 3 indicator lights placed close together: one is red, one green and one blue. They can be controlled independently, allowing for many different colors to be shown without having to disassemble and recreate the panel.
ie.manual.entry.industrialwires.7seg=Seven-Segment Displays are a way of displaying analog redstone signals precisely. Signal strengths 0-9 are displayed as one would expect, levels 10-15 are represented by the letters A-E. Some of the letters are lower-case to differentiate them from digits (e.g. 8 vs B).

View file

@ -1,25 +0,0 @@
{
"result": {
"item": "industrialwires:panel_component",
"data": 10
},
"ingredients": [
{
"type": "forge:ore_dict",
"ore": "dustRedstone"
},
{
"item": "industrialwires:panel_component",
"data": 2
},
{
"item": "industrialwires:panel_component",
"data": 2
},
{
"item": "industrialwires:panel_component",
"data": 2
}
],
"type": "forge:ore_shapeless"
}