You are not logged in.

IC2 Experimental builds (jenkins):
v2.0/2.1/2.2 / 2.3 / 2.5 / 2.6 (For Minecraft 1.6.4/1.7.2/1.7.10 / 1.8.9 / 1.9.4 / 1.10)
IndustrialCraft² recent version: v1.117! (For Minecraft 1.5.2 → topic)

Dear visitor, welcome to IC² Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

GregoriusT

inactive IC² Dev but still active GT Dev

  • "GregoriusT" is male
  • "GregoriusT" started this thread
  • Germany

Posts: 11,190

Location: Wherever I want to be (most of the time)

  • Send private message

1

Sunday, April 13th 2014, 1:34pm

IC² API and IC² Addon Creation. (The Code Part)

This is the Thread about the IC2 API and IC2 Addons. If you have a Question about the API or the Dev Environment, you can post it here. If you look for the License Stuff then go here

API shipping

If you make an IC2 Addon where IC2 is always installed, you do not need to ship this API inside your Mod, since it is already contained in IC2 itself. So when you compile your Mod do not zip/jar up the IC2 API itself, because then your old IC2 API can accidentally override the IC2 API of IC2 itself what causes crashes.

If IC2 is not always installed (optional) you can use FML's @Optional annotation to strip missing interfaces at load-time. If you also don't call IC2 code without checking if IC2 is available first, the API isn't even required if IC2 is not installed. Calls to missing classes should only crash when the call actually happens, unreachable calls, e.g. due to a false if clause, don't.

Summary: There's no need to ship the API ever.

IDE / Eclipse / Dev environment

Start with a normal Forge workspace using the Forge src zip, extracting it, running gradle(w) setupDecomWorkspace and gradle(w) eclipse and importing it into Eclipse.
If you want to you can create a separate project for IC2 or just add IC2 to Forge's project. Add the IC2 dev jar as a library to the build path. You can get it from http://jenkins.ic2.player.to/job/IC2_experimental/, the file name is "industrialcraft-x-x.x.xxx-experimental-dev.jar" (should be the second one). It also needs to be copied to your eclipse working (run) directory's mods-Folder.

A Documentation of the API: http://ic2api.player.to/ic2api/html/annotated.html

build.gradle

A maven compatible repository for the api an dev jars is available at http://maven.ic2.player.to.
Add the following to your build.gradle to use it, adjusting the version number as needed:

Source code

1
2
3
4
5
6
7
8
9
10
repositories {
	maven {
		name = "ic2"
		url = "http://maven.ic2.player.to/"
	}
}

dependencies {
	compile 'net.industrial-craft:industrialcraft-2:2.1.470-experimental:api'
}


1.8.9:

Source code

1
2
3
4
5
6
7
8
9
10
repositories {
	maven {
		name = "ic2"
		url = "http://maven.ic2.player.to/"
	}
}

dependencies {
	compile 'net.industrial-craft:industrialcraft-2:2.3.225-ex18:api'
}

Note that the repositories block is different/outside the existing "buildscript { repositories {} }" block. Ordering matters in build.gradle.
If you use IC2 core functionality, which isn't recommended, you have to replace api with dev at the end of dependencies - compile.
I don't say, your "insert whatever here" is bad, I'm only showing possibilities for making it better.

GregTech Website

Patreon really helps me out, so if you consider funding the development of GT, so I might be able to do it full time, why not?

GregTech 6, the Main Thread, Bug Reports go here too.

I'm also reachable on #gt-dev on irc.esper.net, if you don't want to make a Forum account to contact me, for example. ;)
(I'm there almost every day, but only when I'm at my own computer, and yes you can drop bugs there too)

This post has been edited 4 times, last edit by "Aroma1997" (Nov 12th 2016, 9:05am)


Foghrye4

Iron Miner

  • "Foghrye4" is male

Posts: 526

Location: Russian Federation

  • Send private message

2

Friday, April 25th 2014, 6:51pm

I've got a question. I use

Quoted

ElectricItem.manager.discharge(this.dischargeSlot.get(),20,1, false,false);

to discharge battery in discharge slot. In GUI everything looks fine, but when i extract battery from slot, it returns to full charge. What i forgot to add to code?

3

Saturday, April 26th 2014, 1:40am

You probably call it client side, only the server should do this, typically from the tile entity providing the slot.

Foghrye4

Iron Miner

  • "Foghrye4" is male

Posts: 526

Location: Russian Federation

  • Send private message

4

Saturday, April 26th 2014, 6:10am


You probably call it client side, only the server should do this, typically from the tile entity providing the slot.

Yes, thank you. Also i forgot to write

Source code

1
public void updateProgressBar(int index, int value)
in container class.

luacs1998

ForgeEssentials developer

  • Send private message

5

Saturday, May 10th 2014, 10:00am

Those who want to use the dev jar have to include this line in the dependencies closure as well:

compile 'com.googlecode.efficient-java-matrix-library:ejml:0.23'

luacs1998

ForgeEssentials developer

  • Send private message

6

Saturday, May 10th 2014, 10:00am

Those who want to use the dev jar have to include this line in the dependencies closure as well:

compile 'com.googlecode.efficient-java-matrix-library:ejml:0.23'

Foghrye4

Iron Miner

  • "Foghrye4" is male

Posts: 526

Location: Russian Federation

  • Send private message

7

Saturday, May 17th 2014, 7:35pm


Source code

1
2
3
4
5
6
7
8
9
repositories {
	maven {
		name = "ic2"
		url = "http://maven.ic2.player.to/"
	}
}
dependencies {
	compile 'net.industrial-craft:industrialcraft-2:2.1.470-experimental:api'
}


It seems, that it won't work with my version of gradle.

Spoiler Spoiler

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
A:\Forge 1.7.2>gradlew build

FAILURE: Build failed with an exception.

* Where:
Build file 'A:\Forge 1.7.2\build.gradle' line: 21

* What went wrong:
A problem occurred evaluating root project 'Forge 1.7.2-1061'.
> Could not find method compile() for arguments [net.industrial-craft:industrial
craft-2:2.1.470-experimental:dev] on org.gradle.api.internal.artifacts.dsl.depen
dencies.DefaultDependencyHandler_Decorated@23442dbd.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.

BUILD FAILED

Total time: 4.939 secs

Here is build.gradle

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
buildscript {
    repositories {
        mavenCentral()
        maven {
            name = "forge"
            url = "http://files.minecraftforge.net/maven"
        }
        maven {
           name = "sonatype"
          url = "https://oss.sonatype.org/content/repositories/snapshots/"
        }
	maven {
		name = "ic2"
		url = "http://maven.ic2.player.to/"
	}
    }

    dependencies {

        classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
	compile 'net.industrial-craft:industrialcraft-2:2.1.470-experimental:dev'

    }
}

apply plugin: 'forge'

version = "0.40"
group= "com.yourname.modid" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "modid"

minecraft {
    version = "1.7.2-10.12.1.1061"
    assetDir = "eclipse/assets"
}

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


Any guess?

8

Sunday, May 18th 2014, 12:30am

They have to go outside buildscript {}, that block is exclusively for Forge.

Foghrye4

Iron Miner

  • "Foghrye4" is male

Posts: 526

Location: Russian Federation

  • Send private message

9

Sunday, May 18th 2014, 7:21am

*facepalm* I was had to read first message carefully! What a shame... :(

inucune

Industrial Nightmare

Posts: 315

Location: your reactor's gremlin.

  • Send private message

10

Wednesday, June 4th 2014, 4:30pm

I have minecraft and forge set up in eclipse and have downloaded the dev version of ic2e. How do i add the IC2 dev jar as a library to the build path, where is the eclipse working (run) directory's mods-Folder(or what is it called), and is the maven repository required?

Foghrye4

Iron Miner

  • "Foghrye4" is male

Posts: 526

Location: Russian Federation

  • Send private message

11

Thursday, June 5th 2014, 2:39pm

You don't need a special folder to ic2 dev. Place it anywhere you want. Run eclipse with your project, right-click your project root folder, select properties->Java build path-> Libraries-> Add external Jar and select ic2-dev to add.
How to modify build.gradle file is written right in first message in this thread. Just don't repeat my mistake.

xbony2

Copper Miner

  • "xbony2" is male
  • United States

Posts: 1,191

Location: United States of America

  • Send private message

12

Sunday, June 8th 2014, 12:41am

getTransferLimit is confusing me. I see what it's for, but I have no idea what to put as an value. What does the Advanced RE-Battery and Energy Crystal use as their value?
Help the Official FTB Wiki reach 8000 9000 10,000 11,000 12,000 13,000 14,000 pages!

Someone should fix the gravel texture in the background...

Foghrye4

Iron Miner

  • "Foghrye4" is male

Posts: 526

Location: Russian Federation

  • Send private message

13

Sunday, June 8th 2014, 8:07am

256 and 2048

GregoriusT

inactive IC² Dev but still active GT Dev

  • "GregoriusT" is male
  • "GregoriusT" started this thread
  • Germany

Posts: 11,190

Location: Wherever I want to be (most of the time)

  • Send private message

14

Sunday, June 8th 2014, 9:11am

Nope, it is not 256 and 2048, even though it SHOULD be like that, the Values are actually much higher making them charge much faster than they should.
I don't say, your "insert whatever here" is bad, I'm only showing possibilities for making it better.

GregTech Website

Patreon really helps me out, so if you consider funding the development of GT, so I might be able to do it full time, why not?

GregTech 6, the Main Thread, Bug Reports go here too.

I'm also reachable on #gt-dev on irc.esper.net, if you don't want to make a Forum account to contact me, for example. ;)
(I'm there almost every day, but only when I'm at my own computer, and yes you can drop bugs there too)

Foghrye4

Iron Miner

  • "Foghrye4" is male

Posts: 526

Location: Russian Federation

  • Send private message

15

Sunday, June 8th 2014, 11:48am


Nope, it is not 256 and 2048, even though it SHOULD be like that, the Values are actually much higher making them charge much faster than they should.

(with enthusiastic voice) It's magical! Even Notch himself don't know truth!

...i guess.

16

Sunday, June 8th 2014, 5:15pm

It just determines how long the user has to wait until the item is fully charged in a mfe etc, about 10-30s for a full charge depending on the tool should work well

Foghrye4

Iron Miner

  • "Foghrye4" is male

Posts: 526

Location: Russian Federation

  • Send private message

17

Saturday, June 14th 2014, 12:45pm

About IC2 recipe manager. I tried to add this recipe:

Source code

1
Recipes.advRecipes.addRecipe(new ItemStack(IHLMod.chargerEjectorItem,1), new Object[] { "PGP", "GCG", "GLG", Character.valueOf('P'), IC2Items.getItem("platelapi"), Character.valueOf('G'), new ItemStack(Blocks.glass,1), Character.valueOf('C'), IC2Items.getItem("glassFiberCableItem"), Character.valueOf('L'), IC2Items.getItem("lapotronCrystal")});


No result. Nonetheless, this code is working:

Source code

1
Recipes.advRecipes.addRecipe(new ItemStack(IHLMod.chargerEjectorItem,1), new Object[] { "PGP", "GCG", "G G", Character.valueOf('P'), IC2Items.getItem("platelapi"), Character.valueOf('G'), new ItemStack(Blocks.glass,1), Character.valueOf('C'), IC2Items.getItem("glassFiberCableItem")});

It seems, that item damage is important as recipe input, although normal IC2 recipes are working with any charge level.
How i can use items with any charge level as recipe input?

GregoriusT

inactive IC² Dev but still active GT Dev

  • "GregoriusT" is male
  • "GregoriusT" started this thread
  • Germany

Posts: 11,190

Location: Wherever I want to be (most of the time)

  • Send private message

18

Saturday, June 14th 2014, 1:45pm

Use "OreDictionary.Wildcard" as Damage for your Item to make Damage irrelevant. All other Mods and vanilla Minecraft do that too.
I don't say, your "insert whatever here" is bad, I'm only showing possibilities for making it better.

GregTech Website

Patreon really helps me out, so if you consider funding the development of GT, so I might be able to do it full time, why not?

GregTech 6, the Main Thread, Bug Reports go here too.

I'm also reachable on #gt-dev on irc.esper.net, if you don't want to make a Forum account to contact me, for example. ;)
(I'm there almost every day, but only when I'm at my own computer, and yes you can drop bugs there too)

Foghrye4

Iron Miner

  • "Foghrye4" is male

Posts: 526

Location: Russian Federation

  • Send private message

19

Saturday, June 14th 2014, 2:59pm

GregoriusT, thank you!

Source code

1
2
3
ItemStack crystal = IC2Items.getItem("lapotronCrystal").copy();
crystal.setItemDamage(OreDictionary.WILDCARD_VALUE);
Recipes.advRecipes.addRecipe(new ItemStack(IHLMod.chargerEjectorItem,1), new Object[] { "PGP", "GCG", "GLG", Character.valueOf('P'), IC2Items.getItem("platelapi"), Character.valueOf('G'), new ItemStack(Blocks.glass,1), Character.valueOf('C'), IC2Items.getItem("glassFiberCableItem"), Character.valueOf('L'), crystal});

Now it is working.

P.S.:
Khem... it was supposed to be a thread about IC2 API and addon development. I don't mind, if irrelevant questions will be erased from that thread, or moved to another section.

Chocohead

Drowning in mods.

  • "Chocohead" is male
  • Korea, Democratic People's Republic of United Kingdom

Posts: 5,979

Location: Badly generated chunks.

  • Send private message

20

Saturday, June 14th 2014, 4:16pm

it was supposed to be a thread about IC2 API and addon development. I don't mind, if irrelevant questions will be erased from that thread, or moved to another section.

Someone else might have the same problem, so it makes sense if most of the answers are in the same place.
145 Mods isn't too many. 9 types of copper and 8 types of tin aren't too many. 3 types of coffee though?

I know that you believe that you understood what you think I said, but I am not sure you realise that what you read was not what I meant.


---- Minecraft Crash Report ----
// I just don't know what went wrong :(

I see this too much.

Counter:

Hits today: 60,527 | Hits yesterday: 80,423 | Hits record: 152,331 | Hits total: 65,225,218