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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • In the ever-evolving landscape of cryptocurrency, the challenge of recovering lost or stolen digital assets has long been a pressing concern. However, a pioneering company known as Washington Recovery Pro has emerged as a trailblazer in this domain, offering a revolutionary approach to the recovery of Bitcoin and other cryptocurrencies. Leveraging their deep expertise in blockchain technology and digital forensics, Washington Recovery Pro has developed a suite of innovative tools and techniques that empower individuals and organizations to track, trace, and reclaim their rightful digital holdings, even in the face of sophisticated theft and obfuscation tactics employed by cybercriminals. By tapping into the transparency and immutability of the blockchain, Washington Recovery Pro analysts are able to meticulously follow the digital breadcrumbs left behind by illicit transactions, unraveling complex money-laundering schemes and identifying the ultimate destinations of stolen funds. Through their tireless efforts and cutting-edge investigative methods, Washington Recovery Pro has successfully recovered millions of dollars' worth of cryptocurrency, restoring peace of mind and financial stability to countless victims of crypto-related crimes. As the adoption of digital assets continues to soar, the importance of Washington Recovery Pro work cannot be overstated, as they stand as a bulwark against the growing threat of cryptocurrency theft and a beacon of hope for those seeking to reclaim their rightful digital wealth. For more information, contact:          
    • Ive tried to disable all the mods and repair the installation in curseforge but that didnt change anything sadly.
    • Ive been trying to run some datapacks from vanilla tweaks like multiplayer sleep and Anti Creeper grief, but i cant seem to get them working on CurseForge while they work completely fine in Vanilla on the same version. They are loaded according to the game but they don´t work at all, ive tried using openloader but that doesnt change anything either.   Any ideas on what could be causing this?    Thank you in advance, Nap
    • I am having the same issue when I try to launch the modpack from the launcher. I am on Windows, running 32gb RAM, I have plenty of RAM dedicated to the modpack, but every time I try to launch the game, I get a message saying "Game Crashed - Exit Code: 1" For reference, I have 18.5k MB dedicated to running the game, and it still crashes. I am not sure what the issue is. Any help is appreciated!
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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