Jump to content

Making a addon, need Help


nickgerrets

Recommended Posts

Hello, I need help on making a addon.

Im making a addon for Industrial Craft 2. I have add some items, like Plutonium and some Ore's. Now i want to have the Nuclear Reactor randomly shoot out a piece of plutonium dust, i want it to be rare.

 

how do I somehow extend the Reactor to randomly emit a piece.

 

Please help me! thanks.

Link to comment
Share on other sites

You need to go learn programming in general.  Not "Java."  Programming.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I programmed before, in multiple languages and also a !Little! bit of java. Im trying to learn java through MC but i dont fully understand everything. I have no idea how the TileEntity is working. Instead of belittling me (Draco18s), you can also just help!

 

If you know programming, why dont you say something useful?

 

Thanks.

 

 

Link to comment
Share on other sites

Maybe he didn't think you knew program as basic java would be easily learnt by anyone who has mastered a different programming language.

 

TE's are just the way to store information past the 16bit limit imposed by metadata.

 

This blog should tell you about some of the inner workings of minecraft.

Especially the first parts makes a good read for trying to understand the internals of a minecraft world.

http://greyminecraftcoder.blogspot.com.au/p/list-of-topics.html

 

The javadocs are the documentation for java programs, it's more or less the same as you would expect from any other language. You can find the documentation along with the other files at the download page over here: http://files.minecraftforge.net/

 

Now for java in particular check out:

http://docs.oracle.com/javase/tutorial/

http://docs.oracle.com/javase/7/docs/api/

 

 

Now for your specific case I would read up on the java docs (if any) for the IC2 API.

Then I would read ALL the code which is included in the API.

That should give you ALL you need :)

 

 

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

Maybe he didn't think you knew program as basic java would be easily learnt by anyone who has mastered a different programming language.

 

And not understanding keywords like "extends" is a clue that someone hasn't ever encountered Object Oriented Programming, the raw basics of which are necessary to understand how Minecraft works.  It's not really possible to learn that through exploring the existing code, because the code assumes you know what inheritance is and how it works.

 

And I'm not going to spend my time explaining those fundamental concepts via forum posts.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I know what inheritance is and i know what extends means. Only i find Java a bit difficult, i understand a big part of it. Its like Minecraft uses a very difficult and advanced way of programming.

 

Also, I still cant figure out how to extend or implement the Nuclear reactor. I also dont know how to "dispens" a item out of it RANDOMLY. I also looked in the dispenser classes, but that didnt help much. Maybe someone has made addons for IC2 before, and is willing to explain some things to me, that would realy help.

 

Thanks.

Link to comment
Share on other sites

Hello,

 

I can show you the code of the chest to dispense it items when it breaks, maybe that helps you a little bit.

 

 

Random random = new Random();

	TileEntity tileentity = par1World.getBlockTileEntity(par2, par3, par4);

	if ((tileentity instanceof IInventory) == false)
	{
		return;
	}

	IInventory inventory = (IInventory)tileentity;

	for (int i = 0; i < inventory.getSizeInventory(); i++)
        {
            ItemStack item = inventory.getStackInSlot(i);

            if (item != null)
            {
                float rx = random.nextFloat() * 0.8F + 0.1F;
                float ry = random.nextFloat() * 0.8F + 0.1F;
                
                EntityItem entityitem;

                for (float rz = random.nextFloat() * 0.8F + 0.1F; item.stackSize > 0; par1World.spawnEntityInWorld(entityitem))
                {
                    int stacksize = random.nextInt(21) + 10;

                    if (stacksize > item.stackSize)
                    {
                        stacksize = item.stackSize;
                    }

                    item.stackSize -= stacksize;
                    entityitem = new EntityItem(par1World, (double)((float)par2 + rx), (double)((float)par3 + ry), (double)((float)par4 + rz), new ItemStack(item.itemID, stacksize, item.getItemDamage()));
                    float factor = 0.05F;
                    entityitem.motionX = (double)((float)random.nextGaussian() * factor);
                    entityitem.motionY = (double)((float)random.nextGaussian() * factor + 0.2F);
                    entityitem.motionZ = (double)((float)random.nextGaussian() * factor);

                    if (item.hasTagCompound())
    		        {
    		        	entityitem.getEntityItem().setTagCompound((NBTTagCompound)item.getTagCompound().copy());
    		        }
                }
            }
        }

 

 

ss7

You sir are a god damn hero.

Link to comment
Share on other sites

You don't need anything the vanilla Dispenser does.  You're trying to use the verb "dispense" and apply it to the context of a block.  Which is getting you confused.

 

You want a block, which works like the nuclear reactor in IC2, that at random, creates an item and does something with it: ejects it into the world as an entity or puts it into its own inventory, or something.

 

That's your goal.

 

Step 1:

Import the IC2 API.

Hopefully this gives you the nuclear reactor itself, it probably won't.

 

Step 2:

Create a new class that Extends TileEntity, call it whatever you want.

 

Step 3:

Give it behaviors.  If you have access to the original reactor block and TE, you will extend those and simply add a handful of lines to the updateTick method by overriding it.  Namely, call super.updateTick(...) and then do what you need to do in order to create a this new item (which is instanciated as a new ItemStack, as item classes themselves are singletons).

If you don't have access to the original, you'll have to duplicate everything that it does (good luck) or learn Reflections.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I think he's asking whether you can:

 

[*]Extend the reactor tile entity class

[*]Cause your subclass to be instantiated instead of the reactor base class, in all cases where Minecraft would normall instantiate it. Crafting, on chunk load, etc..

 

I wish I could answer that. I've actually been wondering the same thing. I came up with the following ideas, but I don't know if they'll work. They're just hypothetical.

 

[*]Override the reactor crafting recipe so it instantiates your extended reactor.

[*]Take over the reactor's block ID. Perhaps this would solve the problem of updating reactors that existed before the addon was installed. If you're messing with the tile entity data, you'll need to be able to detect and read the original data.

Link to comment
Share on other sites

Actually, how you would do things depends on how the API is made.

If the API is good, it provides events classes linked to the Nuclear Reactor, which you can subscribe to and give new results/functions.

Forge provides the event system, I hope IC2 authors were nice enough to use it.

Link to comment
Share on other sites

Maybe a little explainable code would do the trick?

If you do know programming in some other language then you should have NO TROUBLE getting into the API's code and understanding the code. Especially considering that you are able to do google search for comparisons between Java and your mastered language.

 

As I said above, if you are unable to figure out what you need from the above links, then it's back to school for you. You will need to study the Java basics and master it before trying this!

 

Still have no idea what to do. Maybe i have to go in to some more simple stuff first.

That and do some studying :)

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Sup,i use forge 47.2.30 for 1.20.1 and i got this crash error :  https://pastebin.com/SMxVrV3E May someone help me ? Thank you !
    • 🎰 Mainkan Slot Online dengan Hanya 5 Ribu Via Dana, Proses Cepat! 🎰 Buka pintu ke dunia hiburan tanpa batas di UANG69 Slot Online! Bersiaplah untuk merasakan sensasi kemenangan di ujung jari Anda dengan taruhan serendah 5 ribu rupiah saja, melalui metode pembayaran yang mudah via Dana! ⚡ Proses Cepat, Nikmati Keuntungan dalam Sekejap ⚡ Bergabunglah dengan komunitas slot paling dinamis dan terpanas, dengan puluhan permainan slot yang menakjubkan, serta kesempatan untuk memenangkan jackpot besar! Rasakan gemerlapnya Las Vegas langsung dari kenyamanan rumah Anda sendiri. 🔥 Keunggulan UANG69 Slot Online: 🔥 ✅ Taruhan Serendah 5 Ribu Rupiah ✅ Metode Pembayaran Mudah via Dana ✅ Proses Cepat, Penarikan Lancar ✅ Puluhan Permainan Slot Terbaik ✅ Jackpot Besar Menanti untuk Dimenangkan Bergabunglah dengan UANG69 hari ini dan jadilah bagian dari petualangan slot yang tak terlupakan. Nikmati keseruan, kemenangan, dan hiburan di ujung jari Anda! Jangan lewatkan kesempatan ini, bergabunglah sekarang dan mulailah memenangkan hadiah besar! 💰💎🎉
    • Hello, I am trying to play Minecraft (premium version) with the All Of Create mod from CurseForge. When I launch it from the Minecraft launcher I get an error "The game has stopped working" Error code: 1. I tried to create a modpack, without mods, and launch it (in case there was any incompatibility) but it doesn't work either.... Error with mod: https://paste.ee/p/zzvJY I hope someone can help me. Thanks in advance.
    • Jika Anda mencari maxwin secepat kilat, maka Slot Kilat77 adalah tempatnya! Dengan koleksi slot terbaik yang dirancang untuk memberikan kemenangan instan, setiap putaran di Slot Kilat77 adalah kesempatan untuk memenangkan hadiah besar dalam sekejap. Bergabunglah sekarang dan rasakan sensasi kemenangan kilat di setiap gulungan. Jadi, jangan ragu lagi, mari bergabung dan raih maxwin secepat kilat hanya di Slot Kilat77!
    • Jos77 adalah pilihan terbaik untuk meraih maxwin hari ini! Dengan koleksi permainan slot terbaik dan peluang kemenangan yang tinggi, setiap putaran di Jos77 adalah kesempatan untuk memenangkan hadiah besar. Bergabunglah sekarang dan rasakan sensasi kemenangan yang luar biasa di setiap gulungan. Jadi, jangan lewatkan kesempatan untuk menjadi pemenang hari ini di Jos77 Mulailah petualangan slot Anda sekarang di Jos77 dan temukan sendiri mengapa kami adalah pilihan utama para pencari maxwin. Dengan grafis yang memukau, fitur bonus yang menggiurkan, dan dukungan pelanggan yang luar biasa, kami siap membawa pengalaman bermain Anda ke level berikutnya. Tidak peduli apakah Anda seorang pemula atau ahli slot, Jos77 menyediakan lingkungan yang ramah dan menyenangkan bagi semua pemain. Jadi, bersiaplah untuk meraih maxwin dan nikmati kesuksesan Anda di Jos77 hari ini!  
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.