Begin creating small addon (внутри так же есть русский текст)

  • For Russians (для русских): Хочу написать аддон с нормальным, технологичным оружием для ИК2Е, но исходя из многих страниц, в том числе этой: IC² API and IC² Addon Creation. (The Code Part) не могу понять каким образом получить доступ к IC2.core.* части мода, а не только к IC.api.* части, ибо комментарии не работают и я даже не могу создать простейший инструмент, который можно заряжать (просто крашится, если я пытаюсь хоть что то использовать из IC2e, в данном случае унаследовать класс от ElecticItem), так вот вопрос: либо объясните, пожалуйста, каким образом создавать нормально все это дело, либо каким образом получить доступ ко всей части IC2e, что б я мог смотреть примеры и брать код с них.


    For not-Russians: I want to create small addon with normal, industial weapon (for example, wave-gun, EMP-gun, electric-field-gun e.t.c.), but no matter how much i read different sites and this forum also with that thread IC² API and IC² Addon Creation. (The Code Part) at least 10 times, i still can't understand how to write simple working (chargable, at least) item, because when i trying to "extends ElecticTool" it's simply crashed, i understand that i need to give some start values for this tool, but i don't know what i need to write, comments in API's files of mod don't help, it gives description just about few methods that i can use, and i can't get IC2.core.* files to get examples (mining laser, for example) of working items, when i trying to open, eclipse writing this: 'someFolders'\industrial-craft-'current version'-dev.jar has no source attachment. what i can do? please, if you can, if you writing in Eng, write what you want to say few different ways with some splitter, i don't want be confused c:

    hope i don't mix up something in Eng version of this text


    надеюсь я не слишком много прошу, заранее спасибо.
    hope i don't asking too much, thanks in advance.

    • Official Post

    First of all: you should add the IC2 API to your classpath (it has the source code of the API included with documentation and all.)

    Secondly: All you need to do to make your Item Chargable it to implement IElectricItem and IC2 will recognize it as an electric item.

    Thirdly: If you get a crash, please send us the crash log as we cannot help you without it.

  • at first you meant this? https://yadi.sk/i/TOBqk0yN3H6V8Q (chosen in left), if not, then, please, describe what i need to do

    about third:
    code of future weapon (i hope :D): https://yadi.sk/i/J5twY5H73H6VTN
    code where it's added to minecraft (if i understand it properly, of course, because i only started writing java, before i only writing soft on C# about 4-5 years): https://yadi.sk/i/t-ok43eO3H6Vru


    and crash-log at current code, if trying to launch:

    • Official Post

    at first you meant this? https://yadi.sk/i/TOBqk0yN3H6V8Q (chosen in left), if not, then, please, describe what i need to do

    You download the API jar and add it to your classpath (the same way you added the dev jar to you classpath) (probably in the gradle build script)

    about third:

    code of future weapon (i hope :D): https://yadi.sk/i/J5twY5H73H6VTN
    code where it's added to minecraft (if i understand it properly, of course, because i only started writing java, before i only writing soft on C# about 4-5 years): https://yadi.sk/i/t-ok43eO3H6Vru

    You either need to give the constructor of your item a InternalName (any of them will work) or you don't use IC2 core classes. (The latter one is recommended)
    To go a bit more in detail: instead of extendine ItemElectricTool, you extend ItemTool or Item or so and implement IElectric Item (which you currently have commented out). That should amke it not crash anymore.

  • You download the API jar and add it to your classpath (the same way you added the dev jar to you classpath) (probably in the gradle build script)

    still can't understand what really i need to do, i read thread here about these "build.gradle" (file) and comments to this thread, trying to write needed parts of code in this file and make "gradlew.bat setupDecompWorkspace eclipse", nothing happens, or gives me an error.

    You either need to give the constructor of your item a InternalName (any of them will work) or you don't use IC2 core classes. (The latter one is recommended)
    To go a bit more in detail: instead of extendine ItemElectricTool, you extend ItemTool or Item or so and implement IElectric Item (which you currently have commented out). That should amke it not crash anymore.

    i tried some InternalNames and no one work (crashing also), because of that i need some examples of IC2e code (mining lazer or plazma launcher will be best)

    • Official Post

    i tried some InternalNames and no one work (crashing also), because of that i need some examples of IC2e code (mining lazer or plazma launcher will be best)

    That's the most basic example I can think of:


    still can't understand what really i need to do, i read thread here about these "build.gradle" (file) and comments to this thread, trying to write needed parts of code in this file and make "gradlew.bat setupDecompWorkspace eclipse", nothing happens, or gives me an error.

    Add the API dependency to your buildscript according to this guide.

    In specific this part:

    Code
    repositories {
        maven {
            name = "ic2"
            url = "http://maven.ic2.player.to/"
        }
    }
    dependencies {
        compile 'net.industrial-craft:industrialcraft-2:2.2.827-experimental:api'
    }
  • about first: with this i can work too, but for weapon i need a tool, i think, and tool have "getChargedItem" and "getUnchargedItem" it's returns type Item and i can't understand what to return, if i can't simply "charge" item by code (i didn't find field like "charge" or something like this)
    about second: i read it a lot times and still can't understand what i'm doing wrong, this my file "build.gradle" after adding this strings: https://yadi.sk/i/4vFeylkM3H6kGn
    and this gives console after "gradlew.bat setupDecompWorkspace eclipse" after adding strings: https://yadi.sk/i/rxP4PcfU3H6kop

  • i'm really sorry for my stupidity, i think i just have not needed experience at Java at all, or i'm worse than thought at Eng, but i really want to try myself in working with alredy existing big projects like minecraft and IC2E and i really want to make my idea come true c:

    • Official Post

    about first: with this i can work too, but for weapon i need a tool, i think, and tool have "getChargedItem" and "getUnchargedItem" it's returns type Item and i can't understand what to return, if i can't simply "charge" item by code (i didn't find field like "charge" or something like this)

    How you can charge an item and discharge it, it says in the API documentation, but what you essentially need is:

    Code
    ElectricItem.manager.charge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean simulate);

    about second: i read it a lot times and still can't understand what i'm doing wrong, this my file "build.gradle" after adding this strings: https://yadi.sk/i/4vFeylkM3H6kGn
    and this gives console after "gradlew.bat setupDecompWorkspace eclipse" after adding strings: https://yadi.sk/i/rxP4PcfU3H6kop

    A detailled guide of how to setup your workspace is available here.

    Note:

    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. Alternatively, you can use forged "deobfCompile" with the normal jar file instead of the dev one. This will make sure, that it will work no matter if you use different mappings than we use.

    • Official Post

    regarding getChargedItem() and getEmptyItem(), you should in 99% of all cases just "return this;" and nothing else.

    Regarding the other thing: you cannot get the source code of IC2 core (You could install a java decompiler plugin to eclipse to see it without comments, but we do not ship the source code). However you can get the source code of the API, which is contained in the API jar, but not the DEV jar. Adding the api jar as (additional) dependency in the gradle build script should make it show up in eclipse (don't know for sure though)

  • regarding getChargedItem() and getEmptyItem(), you should in 99% of all cases just "return this;" and nothing else.

    Regarding the other thing: you cannot get the source code of IC2 core (You could install a java decompiler plugin to eclipse to see it without comments, but we do not ship the source code). However you can get the source code of the API, which is contained in the API jar, but not the DEV jar. Adding the api jar as (additional) dependency in the gradle build script should make it show up in eclipse (don't know for sure though)

    I completely understand you, big thanks for that, somehow minecraft stopped crashing and item begin working (charging, i don't writing item logic yet), maybe, as programmers says, it's magic aura of main programmer (now it's developer)? :D
    at least, big thanks to you for all this help, i'm surprised that you are not tired of all it :D

  • When I wrote that last post, it was only 5 in the afternoon. How could I possibly be tired at such a time?

    i meant that you spend a lot of time to this thread)) and i have 1:10 (night (don't know when uses PM and when AM :D)) already :D

  • So... i don't know can i still write in this thread or not already, but it's about some IC2e mechanics: i made electric item, with texture (texture don't want working about 2 days!) and see: item haven't charge indicator (standart line under item, green if fully charged, black if discharged e.t.c.), why item don't have it?

    item code: https://yadi.sk/i/gSYH0EHr3H7WEN

    now i will go sleep. Will check thread at morning)

  • The item needs to have setMaxDamage() set. (IC2's items use a value of 27 iirc)

    thanks, before this i think "setMaxDamage" somehow working with damage, possible dealt with that item, now i understand thats it is about how many divisions will have this line under item)