initial commit

This commit is contained in:
malte0811 2016-09-15 20:43:18 +02:00
commit d8bbbb8170
41 changed files with 1643 additions and 0 deletions

23
.gitignore vendored Normal file
View File

@ -0,0 +1,23 @@
# eclipse
bin
*.launch
.settings
.metadata
.classpath
.project
# idea
out
*.ipr
*.iws
*.iml
.idea
# gradle
build
.gradle
# other
eclipse
run
libs

26
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,26 @@
## Issues
### General
- Make sure to use to the latest version of Industrial Wires, Immersive Engineering and IndustrialCraft2.
- Your bug report should contain answers to these questions (If adding screenshots makes answering one of these questions easier, add them):
- What is the bug? E.g. "The game crashed with this crash report: `<Link to crashlog>`".
- What did you do to make it happen? E.g. "I tried to place a tin connector".
- Does it happen every time you do this? Does it happen if you do something else as well? E.g. "The game crashes with a similar crash every time I place any connector from IndustrialWires.".
- Did this happen on a dedicated server (multiplayer servers), in LAN multiplayer or in singleplayer? E.g. "I first noticed this on a server, but it happens in singleplayer as well".
- What other mods were installed when the bug happened? Crashlogs always contain a modlist, so you can skip this part if you already provided one. You can generate a crash and therefore a mod list by pressing and holding F3 and C for 10 seconds, then releasing. Example: "This happened when playing version 2.4.2 of the FTB Infinity modpack" or "A list of mods can be found here: `<link to pastebin/gist/...>`" or "Only IndustrialWires, IE and IC2 were installed when this happened".
### Crashlogs
If your Minecraft instance has crashed, a file will have been generated in the folder `crash-reports` of your Minecraft folder. To understand what has happened, I need to know the content of that file. But please don't just put it directly in your report (that makes it hard to read), upload it to a site like [pastebin](http://pastebin.com) or [gist](http://gist.github.com) and put a link in the actual bug report.
### Other mods
Some mods are not officially supported by IndustrialWires. They will probably work pretty well, but some thing might not work/look weird. If your modpack contains one or more of these mods and you encounter a bug, try removing the unsupported mods. If the bug/crash does not happen without those mods, don't report it since fixing interactions with those mods is usually impossible or extremely hard. The following mods are not officially supported:
- **Optifine**: Optifine changes a lot of Minecraft's rendering code and it is not legally possible to check what those changes are. Another problem is that there is no `dev`/`deobf` version of Optifine which makes running Optifine in a development environment pretty much impossible.
- **Fastcraft**: same as Optifine.
- **(K)Cauldron** and similar server software: While the source code of some of these is available on GitHub or similar platforms, it would require a lot of extra work to test everything with every server software.
- **Any version of IndustrialCraft2 that is not made by the official IC2 team** (more specifically, any IC2 version not available for download [here](http://jenkins.ic2.player.to/))
### Known issues
It is not unlikely that the issue you want to report has already been reported and maybe it has even been fixed for the next version of IndustrialWires. Try searching for different terms related to your issue [here](https://github.com/malte0811/IndustrialWires/issues?utf8=%E2%9C%93&q=is%3Aissue+).

9
README.md Normal file
View File

@ -0,0 +1,9 @@
#Industrial Wires
![An example of what Industrial Wires can do](Screenshot.png)
An addon for Immersive Engineering and IndustrialCraft2. It adds IE-style wires that are able to transmit IC2 energy (EU). This is different from the IC2 compatibility IE had in MC 1.7.10 as it is not possible to convert IC2 power to RF/IF/Tesla/forge energy/etc.
Recipes for the relays, connectors and wires can be found in the Engineer's Manual.
All textures are modified versions of the textures Immersive Engineering uses and the models are loaded out of IE, so all art is at least based on art Mr. Damien Hazard made.

BIN
Screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 KiB

80
build.gradle Normal file
View File

@ -0,0 +1,80 @@
def mainVersion = "1.0"
def buildNumber = "1"
// 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.2-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 = "12.18.1.2077"
//"1.9.4-12.17.0.1976"
runDir = "run"
replace '${version}', project.version
// the mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD snapshot are built nightly.
// stable_# stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not allways work.
// simply re-run your setup task after changing the mappings to update your workspace.
mappings = "snapshot_20160701"
//"snapshot_20160518" 1.9
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
}
repositories {
}
dependencies {
}
jar {
manifest {
}
}
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'
}
}

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,6 @@
#Mon Sep 14 12:28:28 PDT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-bin.zip

164
gradlew vendored Executable file
View File

@ -0,0 +1,164 @@
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

90
gradlew.bat vendored Normal file
View File

@ -0,0 +1,90 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@ -0,0 +1,6 @@
package malte0811.industrialWires;
public class CommonProxy {
public void preInit() {}
public void postInit() {}
}

View File

@ -0,0 +1,8 @@
package malte0811.industrialWires;
public interface IIC2Connector {
/**
* @return leftover energy.
*/
public double insertEnergy(double eu, boolean simulate);
}

View File

@ -0,0 +1,84 @@
package malte0811.industrialWires;
import blusunrize.immersiveengineering.common.IEContent;
import blusunrize.immersiveengineering.common.blocks.stone.BlockTypes_StoneDecoration;
import ic2.api.item.IC2Items;
import malte0811.industrialWires.blocks.BlockIC2Connector;
import malte0811.industrialWires.blocks.TileEntityIC2ConnectorCopper;
import malte0811.industrialWires.blocks.TileEntityIC2ConnectorGold;
import malte0811.industrialWires.blocks.TileEntityIC2ConnectorHV;
import malte0811.industrialWires.blocks.TileEntityIC2ConnectorTin;
import malte0811.industrialWires.items.ItemIC2Coil;
import malte0811.industrialWires.wires.IC2Wiretype;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.ShapedOreRecipe;
@Mod(modid = IndustrialWires.MODID, version = IndustrialWires.VERSION, dependencies="required-after:immersiveengineering;required-after:IC2")
public class IndustrialWires {
public static final String MODID = "industrialwires";
public static final String VERSION = "${version}";
public static BlockIC2Connector ic2conn;
public static ItemIC2Coil coil;
public static CreativeTabs creativeTab = new CreativeTabs(MODID) {
@Override
public Item getTabIconItem() {
return null;
}
public ItemStack getIconItemStack() {
return new ItemStack(coil, 1, 2);
}
};
@SidedProxy(clientSide="malte0811.industrialWires.client.ClientProxy", serverSide="malte0811.industrialWires.CommonProxy")
public static CommonProxy proxy;
@EventHandler
public void preInit(FMLPreInitializationEvent e) {
ic2conn = new BlockIC2Connector();
coil = new ItemIC2Coil();
GameRegistry.registerTileEntity(TileEntityIC2ConnectorTin.class, "ic2ConnectorTin");
GameRegistry.registerTileEntity(TileEntityIC2ConnectorCopper.class, "ic2ConnectorCopper");
GameRegistry.registerTileEntity(TileEntityIC2ConnectorGold.class, "ic2ConnectorGold");
GameRegistry.registerTileEntity(TileEntityIC2ConnectorHV.class, "ic2ConnectorHV");
if (IC2Wiretype.IC2_TYPES==null) {
throw new IllegalStateException("No IC2 wires registered");
}
proxy.preInit();
}
@EventHandler
public void init(FMLInitializationEvent e) {
//WIRES
ItemStack tinCable = IC2Items.getItem("cable", "type:tin,insulation:0");
ItemStack copperCable = IC2Items.getItem("cable", "type:copper,insulation:0");
ItemStack goldCable = IC2Items.getItem("cable", "type:gold,insulation:0");
ItemStack hvCable = IC2Items.getItem("cable", "type:iron,insulation:0");
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(coil, 2, 0), "ttt", "tst", "ttt", 't', tinCable, 's', "stickWood"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(coil, 2, 1), "ccc", "csc", "ccc", 'c', copperCable, 's', "stickWood"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(coil, 2, 2), "ggg", "gsg", "ggg", 'g', goldCable, 's', "stickWood"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(coil, 2, 3), "hhh", "hsh", "hhh", 'h', hvCable, 's', "stickWood"));
//CONNECTORS
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 1, 0), " t ", "rtr", "rtr", 't', "ingotTin", 'r', "itemRubber"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 1, 2), " c ", "rcr", "rcr", 'c', "ingotCopper", 'r', "itemRubber"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 1, 4), " g ", "rgr", "rgr", 'g', "ingotGold", 'r', "itemRubber"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 1, 6), " i ", "rir", "rir", 'i', "ingotIron", 'r', "itemRubber"));
//RELAYS
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 1, 1), " t ", "rtr", 't', "ingotTin", 'r', "itemRubber"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 1, 3), " c ", "rcr", 'c', "ingotCopper", 'r', "itemRubber"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 1, 5), " g ", "rgr", 'g', "ingotGold", 'r', "itemRubber"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 1, 7), " i ", "gig", "gig", 'i', "ingotIron", 'g', new ItemStack(IEContent.blockStoneDecoration, 1, BlockTypes_StoneDecoration.INSULATING_GLASS.getMeta())));
}
@EventHandler
public void postInit(FMLPostInitializationEvent e) {
proxy.postInit();
}
}

View File

@ -0,0 +1,97 @@
package malte0811.industrialWires.blocks;
import java.util.Arrays;
import blusunrize.immersiveengineering.api.IEProperties;
import blusunrize.immersiveengineering.api.energy.wires.TileEntityImmersiveConnectable;
import blusunrize.immersiveengineering.common.blocks.BlockIETileProvider;
import blusunrize.immersiveengineering.common.blocks.ItemBlockIEBase;
import malte0811.industrialWires.IndustrialWires;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty;
public class BlockIC2Connector extends BlockIETileProvider<BlockTypes_IC2_Connector> {
public BlockIC2Connector() {
super("ic2Connector", Material.IRON, PropertyEnum.create("type", BlockTypes_IC2_Connector.class), ItemBlockIEBase.class, IEProperties.FACING_ALL);
setHardness(3.0F);
setResistance(15.0F);
lightOpacity = 0;
setAllNotNormalBlock();
setBlockLayer(BlockRenderLayer.SOLID, BlockRenderLayer.TRANSLUCENT);
this.setCreativeTab(IndustrialWires.creativeTab);
}
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn) {
TileEntity te = world.getTileEntity(pos);
if(te instanceof TileEntityIC2ConnectorTin) {
TileEntityIC2ConnectorTin connector = (TileEntityIC2ConnectorTin) te;
if(world.isAirBlock(pos.offset(connector.f))) {
this.dropBlockAsItem(connector.getWorld(), pos, world.getBlockState(pos), 0);
connector.getWorld().setBlockToAir(pos);
}
}
}
@Override
protected BlockStateContainer createBlockState() {
BlockStateContainer base = super.createBlockState();
IUnlistedProperty<?>[] unlisted = (base instanceof ExtendedBlockState) ? ((ExtendedBlockState) base).getUnlistedProperties().toArray(new IUnlistedProperty[0]) : new IUnlistedProperty[0];
unlisted = Arrays.copyOf(unlisted, unlisted.length+1);
unlisted[unlisted.length-1] = IEProperties.CONNECTIONS;
return new ExtendedBlockState(this, base.getProperties().toArray(new IProperty[0]), unlisted);
}
@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
state = super.getExtendedState(state, world, pos);
if(state instanceof IExtendedBlockState) {
IExtendedBlockState ext = (IExtendedBlockState) state;
TileEntity te = world.getTileEntity(pos);
if (!(te instanceof TileEntityImmersiveConnectable))
return state;
state = ext.withProperty(IEProperties.CONNECTIONS, ((TileEntityImmersiveConnectable)te).genConnBlockstate());
}
return state;
}
@Override
public boolean isSideSolid(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) {
return false;
}
@Override
public TileEntity createNewTileEntity(World worldIn, int meta) {
if (meta==0)
return new TileEntityIC2ConnectorTin(false);
else if (meta==1)
return new TileEntityIC2ConnectorTin(true);
else if (meta==2)
return new TileEntityIC2ConnectorCopper(false);
else if (meta==3)
return new TileEntityIC2ConnectorCopper(true);
else if (meta==4)
return new TileEntityIC2ConnectorGold(false);
else if (meta==5)
return new TileEntityIC2ConnectorGold(true);
else if (meta==6)
return new TileEntityIC2ConnectorHV(false);
else if (meta==7)
return new TileEntityIC2ConnectorHV(true);
return null;
}
@Override
public String createRegistryName() {
return IndustrialWires.MODID+":"+name;
}
}

View File

@ -0,0 +1,29 @@
package malte0811.industrialWires.blocks;
import blusunrize.immersiveengineering.common.blocks.BlockIEBase.IBlockEnum;
public enum BlockTypes_IC2_Connector implements IBlockEnum {
TIN_CONN,
TIN_RELAY,
COPPER_CONN,
COPPER_RELAY,
GOLD_CONN,
GOLD_RELAY,
HV_CONN,
HV_RELAY;
@Override
public String getName() {
return toString().toLowerCase();
}
@Override
public int getMeta() {
return ordinal();
}
@Override
public boolean listForCreative() {
return true;
}
}

View File

@ -0,0 +1,23 @@
package malte0811.industrialWires.blocks;
import blusunrize.immersiveengineering.api.energy.wires.WireType;
import malte0811.industrialWires.wires.IC2Wiretype;
public class TileEntityIC2ConnectorCopper extends TileEntityIC2ConnectorTin {
public TileEntityIC2ConnectorCopper(boolean rel) {
super(rel);
}
public TileEntityIC2ConnectorCopper() {}
{
tier = 2;
maxStored = IC2Wiretype.IC2_TYPES[1].getTransferRate()/8;
}
@Override
public boolean canConnect(WireType t) {
return t==IC2Wiretype.IC2_TYPES[1];
}
}

View File

@ -0,0 +1,38 @@
package malte0811.industrialWires.blocks;
import blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable;
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection;
import blusunrize.immersiveengineering.api.energy.wires.WireType;
import malte0811.industrialWires.wires.IC2Wiretype;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.Vec3d;
public class TileEntityIC2ConnectorGold extends TileEntityIC2ConnectorTin {
public TileEntityIC2ConnectorGold(boolean rel) {
super(rel);
}
public TileEntityIC2ConnectorGold() {}
{
tier = 3;
maxStored = IC2Wiretype.IC2_TYPES[2].getTransferRate()/8;
}
@Override
public boolean canConnect(WireType t) {
return t==IC2Wiretype.IC2_TYPES[2];
}
@Override
public Vec3d getRaytraceOffset(IImmersiveConnectable link) {
EnumFacing side = f.getOpposite();
return new Vec3d(.5+side.getFrontOffsetX()*.125, .5+side.getFrontOffsetY()*.125, .5+side.getFrontOffsetZ()*.125);
}
@Override
public Vec3d getConnectionOffset(Connection con) {
EnumFacing side = f.getOpposite();
double conRadius = con.cableType.getRenderDiameter()/2;
return new Vec3d(.5+side.getFrontOffsetX()*(.0625-conRadius), .5+side.getFrontOffsetY()*(.0625-conRadius), .5+side.getFrontOffsetZ()*(.0625-conRadius));
}
}

View File

@ -0,0 +1,46 @@
package malte0811.industrialWires.blocks;
import blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable;
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection;
import blusunrize.immersiveengineering.api.energy.wires.WireType;
import malte0811.industrialWires.wires.IC2Wiretype;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.Vec3d;
public class TileEntityIC2ConnectorHV extends TileEntityIC2ConnectorTin {
public TileEntityIC2ConnectorHV(boolean rel) {
super(rel);
}
public TileEntityIC2ConnectorHV() {}
{
tier = 4;
maxStored = IC2Wiretype.IC2_TYPES[3].getTransferRate()/8;
}
@Override
public boolean canConnect(WireType t) {
return t==IC2Wiretype.IC2_TYPES[3];
}
@Override
public Vec3d getRaytraceOffset(IImmersiveConnectable link) {
EnumFacing side = f.getOpposite();
if (relay) {
return new Vec3d(.5+side.getFrontOffsetX()*.4375, .5+side.getFrontOffsetY()*.4375, .5+side.getFrontOffsetZ()*.4375);
} else {
return new Vec3d(.5+side.getFrontOffsetX()*.3125, .5+side.getFrontOffsetY()*.3125, .5+side.getFrontOffsetZ()*.3125);
}
}
@Override
public Vec3d getConnectionOffset(Connection con) {
EnumFacing side = f.getOpposite();
double conRadius = con.cableType.getRenderDiameter()/2;
if (relay) {
return new Vec3d(.5+side.getFrontOffsetX()*(.375-conRadius), .5+side.getFrontOffsetY()*(.375-conRadius), .5+side.getFrontOffsetZ()*(.375-conRadius));
} else {
return new Vec3d(.5+side.getFrontOffsetX()*(.25-conRadius), .5+side.getFrontOffsetY()*(.25-conRadius), .5+side.getFrontOffsetZ()*(.25-conRadius));
}
}
}

View File

@ -0,0 +1,281 @@
package malte0811.industrialWires.blocks;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import blusunrize.immersiveengineering.api.ApiUtils;
import blusunrize.immersiveengineering.api.TargetingInfo;
import blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable;
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler;
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.AbstractConnection;
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection;
import blusunrize.immersiveengineering.api.energy.wires.TileEntityImmersiveConnectable;
import blusunrize.immersiveengineering.api.energy.wires.WireType;
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IBlockBounds;
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IDirectionalTile;
import ic2.api.energy.event.EnergyTileLoadEvent;
import ic2.api.energy.event.EnergyTileUnloadEvent;
import ic2.api.energy.tile.IEnergyAcceptor;
import ic2.api.energy.tile.IEnergyEmitter;
import ic2.api.energy.tile.IEnergySink;
import ic2.api.energy.tile.IEnergySource;
import malte0811.industrialWires.IIC2Connector;
import malte0811.industrialWires.wires.IC2Wiretype;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import net.minecraft.util.math.Vec3d;
import net.minecraftforge.common.MinecraftForge;
public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable implements IEnergySource, IEnergySink, IDirectionalTile, ITickable, IIC2Connector, IBlockBounds {
EnumFacing f = EnumFacing.NORTH;
boolean relay;
boolean first = true;
//IC2 net to IE net buffer
double inBuffer = 0;
//IE net to IC2 net buffer
double outBuffer = 0;
double maxStored = IC2Wiretype.IC2_TYPES[0].getTransferRate()/8;
int tier = 1;
public TileEntityIC2ConnectorTin(boolean rel) {
relay = rel;
}
public TileEntityIC2ConnectorTin() {}
@Override
public void update() {
if (first) {
if (!worldObj.isRemote)
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
first = false;
}
if (!worldObj.isRemote&&inBuffer>.1)
transferPower();
}
public void transferPower() {
Set<AbstractConnection> conns = new HashSet<>(ImmersiveNetHandler.INSTANCE.getIndirectEnergyConnections(pos, worldObj));
Map<AbstractConnection, Pair<IIC2Connector, Double>> maxOutputs = new HashMap<>();
double sum = 0;
for (AbstractConnection c:conns) {
IImmersiveConnectable iic = ApiUtils.toIIC(c.end, worldObj);
if (iic instanceof IIC2Connector) {
double tmp = inBuffer-((IIC2Connector)iic).insertEnergy(inBuffer, true);
if (tmp>.00000001) {
maxOutputs.put(c, new ImmutablePair<>((IIC2Connector)iic, tmp));
sum+=tmp;
}
}
}
if (sum<.0001) {
return;
}
final double oldInBuf = inBuffer;
HashMap<Connection, Integer> transferedPerConn = ImmersiveNetHandler.INSTANCE.getTransferedRates(worldObj.provider.getDimension());
for (AbstractConnection c:maxOutputs.keySet()) {
Pair<IIC2Connector, Double> p = maxOutputs.get(c);
double out = oldInBuf*p.getRight()/sum;
double loss = getAverageLossRate(c);
double inserted = out-p.getLeft().insertEnergy(out-loss, false);
inBuffer-=inserted;
float intermediaryLoss = 0;
HashSet<IImmersiveConnectable> passedConnectors = new HashSet<>();
double energyAtConn = inserted+loss;
for(Connection sub : c.subConnections)
{
int transferredPerCon = transferedPerConn.containsKey(sub)?transferedPerConn.get(sub):0;
energyAtConn-=sub.cableType.getLossRatio()*sub.length;
ImmersiveNetHandler.INSTANCE.getTransferedRates(worldObj.provider.getDimension()).put(sub,(int)(transferredPerCon+energyAtConn));
IImmersiveConnectable subStart = ApiUtils.toIIC(sub.start,worldObj);
IImmersiveConnectable subEnd = ApiUtils.toIIC(sub.end,worldObj);
if(subStart!=null && passedConnectors.add(subStart))
subStart.onEnergyPassthrough((int)(inserted-inserted*intermediaryLoss));
if(subEnd!=null && passedConnectors.add(subEnd))
subEnd.onEnergyPassthrough((int)(inserted-inserted*intermediaryLoss));
}
}
}
public double getAverageLossRate(AbstractConnection conn) {
double f = 0;
for(Connection c : conn.subConnections) {
f += c.length*c.cableType.getLossRatio();
}
return f;
}
@Override
public double insertEnergy(double eu, boolean simulate) {
double insert = Math.min(maxStored-outBuffer, eu);
if (!simulate) {
outBuffer+=insert;
}
return eu-insert;
}
@Override
public void invalidate() {
super.invalidate();
if (!worldObj.isRemote)
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
first = true;
}
@Override
public void onChunkUnload() {
super.onChunkUnload();
if (!worldObj.isRemote)
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
first = true;
}
@Override
public Vec3d getRaytraceOffset(IImmersiveConnectable link) {
EnumFacing side = f.getOpposite();
return new Vec3d(.5+side.getFrontOffsetX()*.0625, .5+side.getFrontOffsetY()*.0625, .5+side.getFrontOffsetZ()*.0625);
}
@Override
public Vec3d getConnectionOffset(Connection con) {
EnumFacing side = f.getOpposite();
double conRadius = con.cableType.getRenderDiameter()/2;
return new Vec3d(.5-conRadius*side.getFrontOffsetX(), .5-conRadius*side.getFrontOffsetY(), .5-conRadius*side.getFrontOffsetZ());
}
@Override
public boolean canConnect() {
return true;
}
@Override
public boolean isEnergyOutput() {
return !relay;
}
@Override
public boolean canConnectCable(WireType cableType, TargetingInfo target) {
return (limitType==null||(this.isRelay() && limitType==cableType))&&canConnect(cableType);
}
public boolean canConnect(WireType t) {
return t==IC2Wiretype.IC2_TYPES[0];
}
@Override
protected boolean isRelay() {
return relay;
}
@Override
public boolean emitsEnergyTo(IEnergyAcceptor receiver, EnumFacing side) {
return !relay&&side==f;
}
@Override
public boolean acceptsEnergyFrom(IEnergyEmitter emitter, EnumFacing side) {
return !relay&&side==f;
}
@Override
public double getDemandedEnergy() {
double ret = maxStored-inBuffer;
if (ret<.1)
ret = 0;
return ret;
}
@Override
public int getSinkTier() {
return tier;
}
@Override
public double injectEnergy(EnumFacing directionFrom, double amount, double voltage) {
if (inBuffer<maxStored) {
inBuffer += amount;
markDirty();
return 0;
}
return amount;
}
@Override
public double getOfferedEnergy() {
return outBuffer;
}
@Override
public void drawEnergy(double amount) {
outBuffer -= amount;
markDirty();
}
@Override
public int getSourceTier() {
return tier;
}
@Override
public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) {
super.readCustomNBT(nbt, descPacket);
f = EnumFacing.getFront(nbt.getInteger("facing"));
relay = nbt.getBoolean("relay");
inBuffer = nbt.getDouble("inBuffer");
outBuffer = nbt.getDouble("outBuffer");
}
@Override
public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) {
super.writeCustomNBT(nbt, descPacket);
nbt.setInteger("facing", f.getIndex());
nbt.setBoolean("relay", relay);
nbt.setDouble("inBuffer", inBuffer);
nbt.setDouble("outBuffer", outBuffer);
}
@Override
public EnumFacing getFacing() {
return f;
}
@Override
public void setFacing(EnumFacing facing) {
f = facing;
}
@Override
public int getFacingLimitation() {
return 0;
}
@Override
public boolean mirrorFacingOnPlacement(EntityLivingBase placer) {
return true;
}
@Override
public boolean canHammerRotate(EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase entity) {
return false;
}
@Override
public float[] getBlockBounds() {
float length = this instanceof TileEntityIC2ConnectorHV?(relay?.875f:.75f): this instanceof TileEntityIC2ConnectorGold?.5625f: .5f;
float wMin = .3125f;
float wMax = .6875f;
switch(f.getOpposite() )
{
case UP:
return new float[]{wMin,0,wMin, wMax,length,wMax};
case DOWN:
return new float[]{wMin,1-length,wMin, wMax,1,wMax};
case SOUTH:
return new float[]{wMin,wMin,0, wMax,wMax,length};
case NORTH:
return new float[]{wMin,wMin,1-length, wMax,wMax,1};
case EAST:
return new float[]{0,wMin,wMin, length,wMax,wMax};
case WEST:
return new float[]{1-length,wMin,wMin, 1,wMax,wMax};
}
return new float[]{0,0,0,1,1,1};
}
@Override
public int hashCode() {
return pos.hashCode();
}
}

View File

@ -0,0 +1,38 @@
package malte0811.industrialWires.client;
import blusunrize.immersiveengineering.api.Lib;
import blusunrize.immersiveengineering.client.ClientUtils;
import blusunrize.immersiveengineering.common.util.ItemNBTHelper;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.wires.IC2Wiretype;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand;
import net.minecraftforge.client.GuiIngameForge;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.oredict.OreDictionary;
public class ClientEventHandler {
@SubscribeEvent
public void renderOverlayPost(RenderGameOverlayEvent.Post e) {
if(ClientUtils.mc().thePlayer!=null && e.getType() == RenderGameOverlayEvent.ElementType.TEXT) {
EntityPlayer player = ClientUtils.mc().thePlayer;
for(EnumHand hand : EnumHand.values())
if(player.getHeldItem(hand)!=null) {
ItemStack equipped = player.getHeldItem(hand);
if(OreDictionary.itemMatches(new ItemStack(IndustrialWires.coil, 1, OreDictionary.WILDCARD_VALUE), equipped, false)) {
if(ItemNBTHelper.hasKey(equipped, "linkingPos")) {
int[] link = ItemNBTHelper.getIntArray(equipped, "linkingPos");
if(link!=null&&link.length>3) {
String s = I18n.format(Lib.DESC_INFO+"attachedTo", link[1],link[2],link[3]);
ClientUtils.font().drawString(s, e.getResolution().getScaledWidth()/2 - ClientUtils.font().getStringWidth(s)/2, e.getResolution().getScaledHeight()-GuiIngameForge.left_height-20, IC2Wiretype.IC2_TYPES[2].getColour(null), true);
}
}
}
}
}
}
}

View File

@ -0,0 +1,91 @@
package malte0811.industrialWires.client;
import java.util.Locale;
import com.google.common.collect.ImmutableMap;
import blusunrize.immersiveengineering.api.ManualHelper;
import blusunrize.immersiveengineering.client.models.smart.ConnLoader;
import blusunrize.lib.manual.ManualInstance;
import blusunrize.lib.manual.ManualPages;
import malte0811.industrialWires.CommonProxy;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.items.ItemIC2Coil;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.registry.GameData;
public class ClientProxy extends CommonProxy {
@Override
public void preInit() {
super.preInit();
ConnLoader.baseModels.put("ic2_conn_tin", new ResourceLocation("immersiveengineering:block/connector/connectorLV.obj"));
ConnLoader.textureReplacements.put("ic2_conn_tin", ImmutableMap.of("#immersiveengineering:blocks/connector_connectorLV",
IndustrialWires.MODID+":blocks/ic2_connTin"));
ConnLoader.baseModels.put("ic2_relay_tin", new ResourceLocation("immersiveengineering:block/connector/connectorLV.obj"));
ConnLoader.textureReplacements.put("ic2_relay_tin", ImmutableMap.of("#immersiveengineering:blocks/connector_connectorLV",
IndustrialWires.MODID+":blocks/ic2_relayTin"));
ConnLoader.baseModels.put("ic2_conn_copper", new ResourceLocation("immersiveengineering:block/connector/connectorLV.obj"));
ConnLoader.textureReplacements.put("ic2_conn_copper", ImmutableMap.of("#immersiveengineering:blocks/connector_connectorLV",
IndustrialWires.MODID+":blocks/ic2_connCopper"));
ConnLoader.baseModels.put("ic2_relay_copper", new ResourceLocation("immersiveengineering:block/connector/connectorLV.obj"));
ConnLoader.textureReplacements.put("ic2_relay_copper", ImmutableMap.of("#immersiveengineering:blocks/connector_connectorLV",
IndustrialWires.MODID+":blocks/ic2_relayCopper"));
ConnLoader.baseModels.put("ic2_conn_gold", new ResourceLocation("immersiveengineering:block/connector/connectorMV.obj"));
ConnLoader.textureReplacements.put("ic2_conn_gold", ImmutableMap.of("#immersiveengineering:blocks/connector_connectorMV",
IndustrialWires.MODID+":blocks/ic2_connGold"));
ConnLoader.baseModels.put("ic2_relay_gold", new ResourceLocation("immersiveengineering:block/connector/connectorMV.obj"));
ConnLoader.textureReplacements.put("ic2_relay_gold", ImmutableMap.of("#immersiveengineering:blocks/connector_connectorMV",
IndustrialWires.MODID+":blocks/ic2_relayGold"));
ConnLoader.baseModels.put("ic2_conn_hv", new ResourceLocation("immersiveengineering:block/connector/connectorHV.obj"));
ConnLoader.textureReplacements.put("ic2_conn_hv", ImmutableMap.of("#immersiveengineering:blocks/connector_connectorHV",
IndustrialWires.MODID+":blocks/ic2_connHV"));
ConnLoader.baseModels.put("ic2_relay_hv", new ResourceLocation("immersiveengineering:block/connector/relayHV.obj"));
ConnLoader.textureReplacements.put("ic2_relay_hv", ImmutableMap.of("#immersiveengineering:blocks/connector_connectorHV",
IndustrialWires.MODID+":blocks/ic2_relayHV"));
for(int meta = 0; meta < ItemIC2Coil.subNames.length; meta++) {
ResourceLocation loc = new ResourceLocation(IndustrialWires.MODID, "ic2wireCoil/" + ItemIC2Coil.subNames[meta]);
ModelBakery.registerItemVariants(IndustrialWires.coil, loc);
ModelLoader.setCustomModelResourceLocation(IndustrialWires.coil, meta, new ModelResourceLocation(loc, "inventory"));
}
Item blockItem = Item.getItemFromBlock(IndustrialWires.ic2conn);
final ResourceLocation loc = GameData.getBlockRegistry().getNameForObject(IndustrialWires.ic2conn);
ModelLoader.setCustomMeshDefinition(blockItem, new ItemMeshDefinition() {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
return new ModelResourceLocation(loc, "inventory");
}
});
for(int meta = 0; meta < IndustrialWires.ic2conn.getMetaEnums().length; meta++) {
String location = loc.toString();
String prop = "inventory,type=" + IndustrialWires.ic2conn.getMetaEnums()[meta].toString().toLowerCase(Locale.US);
try {
ModelLoader.setCustomModelResourceLocation(blockItem, meta, new ModelResourceLocation(location, prop));
} catch(NullPointerException npe) {
throw new RuntimeException(IndustrialWires.ic2conn + " lacks an item!", npe);
}
}
// OBJLoader.INSTANCE.addDomain(IndustrialWires.MODID);
MinecraftForge.EVENT_BUS.register(new ClientEventHandler());
}
@Override
public void postInit() {
super.postInit();
ManualInstance m = ManualHelper.getManual();
m.addEntry("industrialWires.all", "industrialWires",
new ManualPages.CraftingMulti(m, "industrialWires.all0", new ItemStack(IndustrialWires.coil, 1, 0), new ItemStack(IndustrialWires.coil, 1, 1), new ItemStack(IndustrialWires.coil, 1, 2), new ItemStack(IndustrialWires.coil, 1, 3)),
new ManualPages.CraftingMulti(m, "industrialWires.all1", new ItemStack(IndustrialWires.ic2conn, 1, 0), new ItemStack(IndustrialWires.ic2conn, 1, 1), new ItemStack(IndustrialWires.ic2conn, 1, 2), new ItemStack(IndustrialWires.ic2conn, 1, 3),
new ItemStack(IndustrialWires.ic2conn, 1, 4), new ItemStack(IndustrialWires.ic2conn, 1, 5), new ItemStack(IndustrialWires.ic2conn, 1, 6), new ItemStack(IndustrialWires.ic2conn, 1, 7))
);
}
}

View File

@ -0,0 +1,163 @@
package malte0811.industrialWires.items;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import blusunrize.immersiveengineering.ImmersiveEngineering;
import blusunrize.immersiveengineering.api.Lib;
import blusunrize.immersiveengineering.api.TargetingInfo;
import blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable;
import blusunrize.immersiveengineering.api.energy.wires.IWireCoil;
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler;
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection;
import blusunrize.immersiveengineering.api.energy.wires.WireType;
import blusunrize.immersiveengineering.common.IESaveData;
import blusunrize.immersiveengineering.common.util.IEAchievements;
import blusunrize.immersiveengineering.common.util.ItemNBTHelper;
import blusunrize.immersiveengineering.common.util.Utils;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.wires.IC2Wiretype;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.resources.I18n;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
public class ItemIC2Coil extends Item implements IWireCoil{
public final static String[] subNames = {"tin", "copper", "gold", "hv"};
public ItemIC2Coil() {
setUnlocalizedName(IndustrialWires.MODID+".ic2wireCoil");
setHasSubtypes(true);
this.setCreativeTab(IndustrialWires.creativeTab);
setMaxStackSize(64);
ImmersiveEngineering.registerByFullName(this, IndustrialWires.MODID+":"+"ic2WireCoil");
}
@Override
public void getSubItems(Item itemIn, CreativeTabs tab, List<ItemStack> subItems) {
for (int i = 0;i<subNames.length;i++) {
subItems.add(new ItemStack(this, 1, i));
}
}
@Override
public String getUnlocalizedName(ItemStack stack) {
return this.getUnlocalizedName()+"."+subNames[stack.getMetadata()];
}
@Override
public WireType getWireType(ItemStack stack) {
return IC2Wiretype.IC2_TYPES[stack.getMetadata()];
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List<String> list, boolean adv) {
if(stack.getTagCompound()!=null && stack.getTagCompound().hasKey("linkingPos")) {
int[] link = stack.getTagCompound().getIntArray("linkingPos");
if(link!=null&&link.length>3) {
list.add(I18n.format(Lib.DESC_INFO+"attachedToDim", link[1],link[2],link[3],link[0]));
}
}
}
//copied from "vanilla" IE
@Override
public EnumActionResult onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
if(!world.isRemote) {
TileEntity tileEntity = world.getTileEntity(pos);
if(tileEntity instanceof IImmersiveConnectable && ((IImmersiveConnectable)tileEntity).canConnect()) {
TargetingInfo target = new TargetingInfo(side, hitX,hitY,hitZ);
WireType wire = getWireType(stack);
BlockPos masterPos = ((IImmersiveConnectable)tileEntity).getConnectionMaster(wire, target);
tileEntity = world.getTileEntity(masterPos);
if( !(tileEntity instanceof IImmersiveConnectable) || !((IImmersiveConnectable)tileEntity).canConnect()) {
return EnumActionResult.PASS;
}
if( !((IImmersiveConnectable)tileEntity).canConnectCable(wire, target)) {
player.addChatMessage(new TextComponentTranslation(Lib.CHAT_WARN+"wrongCable"));
return EnumActionResult.FAIL;
}
if(!ItemNBTHelper.hasKey(stack, "linkingPos")) {
ItemNBTHelper.setIntArray(stack, "linkingPos", new int[]{world.provider.getDimension(),masterPos.getX(),masterPos.getY(),masterPos.getZ()});
target.writeToNBT(stack.getTagCompound());
} else {
WireType type = getWireType(stack);
int[] array = ItemNBTHelper.getIntArray(stack, "linkingPos");
BlockPos linkPos = new BlockPos(array[1],array[2],array[3]);
TileEntity tileEntityLinkingPos = world.getTileEntity(linkPos);
int distanceSq = (int) Math.ceil( linkPos.distanceSq(masterPos) );
if(array[0]!=world.provider.getDimension()) {
player.addChatMessage(new TextComponentTranslation(Lib.CHAT_WARN+"wrongDimension"));
} else if(linkPos.equals(masterPos)) {
player.addChatMessage(new TextComponentTranslation(Lib.CHAT_WARN+"sameConnection"));
} else if( distanceSq > (type.getMaxLength()*type.getMaxLength())) {
player.addChatMessage(new TextComponentTranslation(Lib.CHAT_WARN+"tooFar"));
} else if(!(tileEntityLinkingPos instanceof IImmersiveConnectable)) {
player.addChatMessage(new TextComponentTranslation(Lib.CHAT_WARN+"invalidPoint"));
} else {
IImmersiveConnectable nodeHere = (IImmersiveConnectable)tileEntity;
IImmersiveConnectable nodeLink = (IImmersiveConnectable)tileEntityLinkingPos;
boolean connectionExists = false;
Set<Connection> outputs = ImmersiveNetHandler.INSTANCE.getConnections(world, Utils.toCC(nodeHere));
if(outputs!=null) {
for(Connection con : outputs) {
if(con.end.equals(Utils.toCC(nodeLink))) {
connectionExists = true;
}
}
}
if(connectionExists) {
player.addChatMessage(new TextComponentTranslation(Lib.CHAT_WARN+"connectionExists"));
} else {
Vec3d rtOff0 = nodeHere.getRaytraceOffset(nodeLink).addVector(masterPos.getX(), masterPos.getY(), masterPos.getZ());
Vec3d rtOff1 = nodeLink.getRaytraceOffset(nodeHere).addVector(linkPos.getX(), linkPos.getY(), linkPos.getZ());
Set<BlockPos> ignore = new HashSet<>();
ignore.addAll(nodeHere.getIgnored(nodeLink));
ignore.addAll(nodeLink.getIgnored(nodeHere));
boolean canSee = Utils.rayTraceForFirst(rtOff0, rtOff1, world, ignore)==null;
if(canSee) {
TargetingInfo targetLink = TargetingInfo.readFromNBT(stack.getTagCompound());
ImmersiveNetHandler.INSTANCE.addConnection(world, Utils.toCC(nodeHere), Utils.toCC(nodeLink), (int)Math.sqrt(distanceSq), type);
nodeHere.connectCable(type, target, nodeLink);
nodeLink.connectCable(type, targetLink, nodeHere);
IESaveData.setDirty(world.provider.getDimension());
player.addStat(IEAchievements.connectWire);
if(!player.capabilities.isCreativeMode) {
stack.stackSize--;
}
((TileEntity)nodeHere).markDirty();
world.addBlockEvent(masterPos, ((TileEntity) nodeHere).getBlockType(), -1, 0);
IBlockState state = world.getBlockState(masterPos);
world.notifyBlockUpdate(masterPos, state,state, 3);
((TileEntity)nodeLink).markDirty();
world.addBlockEvent(linkPos, ((TileEntity) nodeLink).getBlockType(), -1, 0);
state = world.getBlockState(linkPos);
world.notifyBlockUpdate(linkPos, state,state, 3);
} else {
player.addChatMessage(new TextComponentTranslation(Lib.CHAT_WARN+"cantSee"));
}
}
}
ItemNBTHelper.remove(stack, "linkingPos");
ItemNBTHelper.remove(stack, "side");
ItemNBTHelper.remove(stack, "hitX");
ItemNBTHelper.remove(stack, "hitY");
ItemNBTHelper.remove(stack, "hitZ");
}
return EnumActionResult.SUCCESS;
}
}
return EnumActionResult.PASS;
}
}

View File

@ -0,0 +1,67 @@
package malte0811.industrialWires.wires;
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection;
import blusunrize.immersiveengineering.api.energy.wires.WireType;
import malte0811.industrialWires.IndustrialWires;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class IC2Wiretype extends WireType{
final int type;
final int[] ic2Rates = {32*8, 128*8, 512*8, 2048*8};
final int[] ic2Colors = {0xa5bcc7, 0xbc7945, 0xfeff73, 0xb9d6d9};
final String[] ic2Names = {"ic2Tin", "ic2Copper", "ic2Gold", "ic2Hv"};
final double[] lossPerBlock = {.2, .2, .4, .8};
final double[] ic2RenderDiameter = {.03125, .03125, .046875, .0625};
public static final IC2Wiretype[] IC2_TYPES = {new IC2Wiretype(0), new IC2Wiretype(1), new IC2Wiretype(2), new IC2Wiretype(3)};
public IC2Wiretype(int ordinal) {
super();
this.type = ordinal;
}
/**
* In this case, this does not return the loss RATIO but the loss PER BLOCK
*/
@Override
public double getLossRatio() {
return lossPerBlock[type];
}
@Override
public int getTransferRate() {
return ic2Rates[type];
}
@Override
public int getColour(Connection connection) {
return ic2Colors[type];
}
@Override
public double getSlack() {
return type==2?1.03:1.005;
}
@Override
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getIcon(Connection connection) {
return iconDefaultWire;
}
@Override
public int getMaxLength() {
return type==3?32:16;
}
@Override
public ItemStack getWireCoil() {
return new ItemStack(IndustrialWires.coil,1,type);
}
@Override
public String getUniqueName() {
return ic2Names[type];
}
@Override
public double getRenderDiameter() {
return ic2RenderDiameter[type];
}
@Override
public boolean isEnergyWire() {
return true;
}
}

View File

@ -0,0 +1,216 @@
{
"forge_marker": 1,
"defaults": {
"transform": "forge:default-block",
"textures": {
},
"custom": {
"flip-v": true
}
},
"variants": {
"inventory,type=tin_conn": [
{
"model": "immersiveengineering:connector/connectorLV.obj",
"textures": {
"#immersiveengineering:blocks/connector_connectorLV": "industrialwires:blocks/ic2_connTin"
},
"transform": {
"scale": [ 0.5, 0.5, 0.5 ],
"firstperson_righthand": { "translation": [ 0, 0.25, 0.125 ]},
"firstperson_lefthand": { "translation": [ 0, 0.25, 0.125 ]},
"thirdperson_righthand": { "translation": [ -0.0625, 0.125, 0.1875 ], "rotation": [{ "x": 70 }, { "y": 70 }]},
"thirdperson_lefthand": { "translation": [ -0.0625, 0.125, 0.1875 ], "rotation": [{ "x": 70 }, { "y": 70 }]},
"fixed": {"scale": [ 2,2,2 ], "translation": [ 0, 0, 0 ], "rotation": [{ "y": -90 }]},
"gui": { "translation": [ 0, 0.125, 0 ], "rotation": [{ "x": 30 },{ "y": 135 },{ "z": 0 }], "scale": [ 1.5, 1.5, 1.5 ] }
}
}
],
"inventory,type=tin_relay": [
{
"model": "immersiveengineering:connector/connectorLV.obj",
"textures": {
"#immersiveengineering:blocks/connector_connectorLV": "industrialwires:blocks/ic2_relayTin"
},
"transform": {
"scale": [ 0.5, 0.5, 0.5 ],
"firstperson_righthand": { "translation": [ 0, 0.25, 0.125 ]},
"firstperson_lefthand": { "translation": [ 0, 0.25, 0.125 ]},
"thirdperson_righthand": { "translation": [ -0.0625, 0.125, 0.1875 ], "rotation": [{ "x": 70 }, { "y": 70 }]},
"thirdperson_lefthand": { "translation": [ -0.0625, 0.125, 0.1875 ], "rotation": [{ "x": 70 }, { "y": 70 }]},
"fixed": {"scale": [ 2,2,2 ], "translation": [ 0, 0, 0 ], "rotation": [{ "y": -90 }]},
"gui": { "translation": [ 0, 0.125, 0 ], "rotation": [{ "x": 30 },{ "y": 135 },{ "z": 0 }], "scale": [ 1.5, 1.5, 1.5 ] }
}
}
],
"inventory,type=copper_conn": [
{
"model": "immersiveengineering:connector/connectorLV.obj",
"textures": {
"#immersiveengineering:blocks/connector_connectorLV": "industrialwires:blocks/ic2_connCopper"
},
"transform": {
"scale": [ 0.5, 0.5, 0.5 ],
"firstperson_righthand": { "translation": [ 0, 0.25, 0.125 ]},
"firstperson_lefthand": { "translation": [ 0, 0.25, 0.125 ]},
"thirdperson_righthand": { "translation": [ -0.0625, 0.125, 0.1875 ], "rotation": [{ "x": 70 }, { "y": 70 }]},
"thirdperson_lefthand": { "translation": [ -0.0625, 0.125, 0.1875 ], "rotation": [{ "x": 70 }, { "y": 70 }]},
"fixed": {"scale": [ 2,2,2 ], "translation": [ 0, 0, 0 ], "rotation": [{ "y": -90 }]},
"gui": { "translation": [ 0, 0.125, 0 ], "rotation": [{ "x": 30 },{ "y": 135 },{ "z": 0 }], "scale": [ 1.5, 1.5, 1.5 ] }
}
}
],
"inventory,type=copper_relay": [
{
"model": "immersiveengineering:connector/connectorLV.obj",
"textures": {
"#immersiveengineering:blocks/connector_connectorLV": "industrialwires:blocks/ic2_relayCopper"
},
"transform": {
"scale": [ 0.5, 0.5, 0.5 ],
"firstperson_righthand": { "translation": [ 0, 0.25, 0.125 ]},
"firstperson_lefthand": { "translation": [ 0, 0.25, 0.125 ]},
"thirdperson_righthand": { "translation": [ -0.0625, 0.125, 0.1875 ], "rotation": [{ "x": 70 }, { "y": 70 }]},
"thirdperson_lefthand": { "translation": [ -0.0625, 0.125, 0.1875 ], "rotation": [{ "x": 70 }, { "y": 70 }]},
"fixed": {"scale": [ 2,2,2 ], "translation": [ 0, 0, 0 ], "rotation": [{ "y": -90 }]},
"gui": { "translation": [ 0, 0.125, 0 ], "rotation": [{ "x": 30 },{ "y": 135 },{ "z": 0 }], "scale": [ 1.5, 1.5, 1.5 ] }
}
}
],
"inventory,type=gold_conn": [
{
"model": "immersiveengineering:connector/connectorMV.obj",
"textures": {
"#immersiveengineering:blocks/connector_connectorMV": "industrialwires:blocks/ic2_connGold"
},
"transform": {
"scale": [ 0.5, 0.5, 0.5 ],
"firstperson_righthand": { "translation": [ 0, 0.25, 0.125 ]},
"firstperson_lefthand": { "translation": [ 0, 0.25, 0.125 ]},
"thirdperson_righthand": { "translation": [ -0.0625, 0.125, 0.1875 ], "rotation": [{ "x": 70 }, { "y": 70 }]},
"thirdperson_lefthand": { "translation": [ -0.0625, 0.125, 0.1875 ], "rotation": [{ "x": 70 }, { "y": 70 }]},
"fixed": {"scale": [ 2,2,2 ], "translation": [ 0, 0, 0 ], "rotation": [{ "y": -90 }]},
"gui": { "translation": [ 0, 0.125, 0 ], "rotation": [{ "x": 30 },{ "y": 135 },{ "z": 0 }], "scale": [ 1.5, 1.5, 1.5 ] }
}
}
],
"inventory,type=gold_relay": [
{
"model": "immersiveengineering:connector/connectorMV.obj",
"textures": {
"#immersiveengineering:blocks/connector_connectorMV": "industrialwires:blocks/ic2_relayGold"
},
"transform": {
"scale": [ 0.5, 0.5, 0.5 ],
"firstperson_righthand": { "translation": [ 0, 0.25, 0.125 ]},
"firstperson_lefthand": { "translation": [ 0, 0.25, 0.125 ]},
"thirdperson_righthand": { "translation": [ -0.0625, 0.125, 0.1875 ], "rotation": [{ "x": 70 }, { "y": 70 }]},
"thirdperson_lefthand": { "translation": [ -0.0625, 0.125, 0.1875 ], "rotation": [{ "x": 70 }, { "y": 70 }]},
"fixed": {"scale": [ 2,2,2 ], "translation": [ 0, 0, 0 ], "rotation": [{ "y": -90 }]},
"gui": { "translation": [ 0, 0.125, 0 ], "rotation": [{ "x": 30 },{ "y": 135 },{ "z": 0 }], "scale": [ 1.5, 1.5, 1.5 ] }
}
}
],
"inventory,type=hv_conn": [
{
"model": "immersiveengineering:connector/connectorHV.obj",
"textures": {
"#immersiveengineering:blocks/connector_connectorHV": "industrialwires:blocks/ic2_connHV"
},
"transform": {
"scale": [ 0.5, 0.5, 0.5 ],
"firstperson_righthand": { "translation": [ 0, 0.25, 0.125 ]},
"firstperson_lefthand": { "translation": [ 0, 0.25, 0.125 ]},
"thirdperson_righthand": { "translation": [ -0.0625, 0.125, 0.1875 ], "rotation": [{ "x": 70 }, { "y": 70 }]},
"thirdperson_lefthand": { "translation": [ -0.0625, 0.125, 0.1875 ], "rotation": [{ "x": 70 }, { "y": 70 }]},
"fixed": {"scale": [ 2,2,2 ], "translation": [ 0, 0, 0 ], "rotation": [{ "y": -90 }]},
"gui": { "translation": [ 0, 0.125, 0 ], "rotation": [{ "x": 30 },{ "y": 135 },{ "z": 0 }], "scale": [ 1.5, 1.5, 1.5 ] }
}
}
],
"inventory,type=hv_relay": [
{
"model": "immersiveengineering:connector/relayHV.obj",
"textures": {
"#immersiveengineering:blocks/connector_relayHV": "industrialwires:blocks/ic2_relayHV"
},
"transform": {
"scale": [ 0.5, 0.5, 0.5 ],
"firstperson_righthand": { "translation": [ 0, 0.25, 0.125 ]},
"firstperson_lefthand": { "translation": [ 0, 0.25, 0.125 ]},
"thirdperson_righthand": { "translation": [ -0.0625, 0.125, 0.1875 ], "rotation": [{ "x": 70 }, { "y": 70 }]},
"thirdperson_lefthand": { "translation": [ -0.0625, 0.125, 0.1875 ], "rotation": [{ "x": 70 }, { "y": 70 }]},
"fixed": {"scale": [ 2,2,2 ], "translation": [ 0, 0, 0 ], "rotation": [{ "y": -90 }]},
"gui": { "translation": [ 0, 0.125, 0 ], "rotation": [{ "x": 30 },{ "y": 135 },{ "z": 0 }], "scale": [ 1.5, 1.5, 1.5 ] }
}
}
],
"type": {
"tin_conn": {
"model": "immersiveengineering:smartmodel/conn_ic2_conn_tin"
},
"tin_relay": {
"model": "immersiveengineering:smartmodel/conn_ic2_relay_tin"
},
"copper_conn": {
"model": "immersiveengineering:smartmodel/conn_ic2_conn_copper"
},
"copper_relay": {
"model": "immersiveengineering:smartmodel/conn_ic2_relay_copper"
},
"gold_conn": {
"model": "immersiveengineering:smartmodel/conn_ic2_conn_gold"
},
"gold_relay": {
"model": "immersiveengineering:smartmodel/conn_ic2_relay_gold"
},
"hv_conn": {
"model": "immersiveengineering:smartmodel/conn_ic2_conn_hv"
},
"hv_relay": {
"model": "immersiveengineering:smartmodel/conn_ic2_relay_hv"
}
},
"facing": {
"down": {
},
"up": {
"transform": {
"rotation": {
"z": 180
}
}
},
"north": {
"transform": {
"rotation": {
"x": 90
}
}
},
"south": {
"transform": {
"rotation": {
"x": -90
}
}
},
"west": {
"transform": {
"rotation": {
"z": -90
}
}
},
"east": {
"transform": {
"rotation": {
"z": 90
}
}
}
}
}
}

View File

@ -0,0 +1,18 @@
tile.industrialwires.ic2Connector.tin_conn.name=Tin Wire Connector
tile.industrialwires.ic2Connector.tin_relay.name=Tin Wire Relay
tile.industrialwires.ic2Connector.copper_conn.name=Copper Wire Connector
tile.industrialwires.ic2Connector.copper_relay.name=Copper Wire Relay
tile.industrialwires.ic2Connector.gold_conn.name=Gold Wire Connector
tile.industrialwires.ic2Connector.gold_relay.name=Gold Wire Relay
tile.industrialwires.ic2Connector.hv_conn.name=IC2 HV Wire Connector
tile.industrialwires.ic2Connector.hv_relay.name=IC2 HV Wire Relay
item.industrialwires.ic2wireCoil.tin.name=Tin Wire Coil
item.industrialwires.ic2wireCoil.copper.name=Copper Wire Coil
item.industrialwires.ic2wireCoil.gold.name=Gold Wire Coil
item.industrialwires.ic2wireCoil.hv.name=IC2 HV Wire Coil
ie.manual.category.industrialWires.name=Industrial Wires
ie.manual.entry.industrialWires.all.name=Industrial Wires
ie.manual.entry.industrialWires.all.subtext=Everything you need to know
ie.manual.entry.industrialWires.all0=Wires from the IndustrialWires company allow you to transfer energy like you can with cables from the IndustrialCraft2 company.<br>You use them exactly as you would use wires from Immersive Engineering. Each wire transfers as much EU as the corresponding cable would,
ie.manual.entry.industrialWires.all1=so attaching a connector to a power source that would destroy the cable will destroy the connector.

View File

@ -0,0 +1,6 @@
{
"parent":"item/generated",
"textures": {
"layer0":"industrialwires:items/ic2_wireCopper"
}
}

View File

@ -0,0 +1,6 @@
{
"parent":"item/generated",
"textures": {
"layer0":"industrialwires:items/ic2_wireGold"
}
}

View File

@ -0,0 +1,6 @@
{
"parent":"item/generated",
"textures": {
"layer0":"industrialwires:items/ic2_wireHV"
}
}

View File

@ -0,0 +1,6 @@
{
"parent":"item/generated",
"textures": {
"layer0":"industrialwires:items/ic2_wireTin"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 397 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 501 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 471 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 672 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 567 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 609 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 644 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 686 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 693 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 649 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 684 B

View File

@ -0,0 +1,16 @@
[
{
"modid": "industrialwires",
"name": "Industrial wires",
"description": "Addon for IndustrialCraft2 and Immersive Engineering that adds IE wires to transfer IC2 power",
"version": "${version}",
"mcversion": "${mcversion}",
"url": "",
"updateUrl": "",
"authorList": ["malte0811"],
"credits": "BluSunrize and Mr. Damien Hazard for Immersive Engineering, the IC2 team for IC2",
"logoFile": "",
"screenshots": [],
"dependencies": []
}
]