Jump to content

Own energy System like RedstoneFlux and Own Liquid Transport Pipes like BC


Darki

Recommended Posts

Hey Guys,

I have two questions. At the moment I make a mod called Chemical Mixture. In this mod you can be a Chemist - so the name. But I need two things. First of all the energy System. I would like to create my own energy System because I don't want to use RF or EU. So, I want to create 2 items. 1. The generator, it make energy using coal and 2. the cable, it transport the energy to this point you need the energy. Can you help me, I don't know how I can do this?

The second question is about Liquid Transport Pipes. In my mod you work with Chemical Liquids and you need Liquid Pipes to transport the Liquid, who can I do this?

 

Oh I forgot something, to make the Liquid Pipes I need 3D models, who can I create this models and who can I import the models in eclipse?

 

Sorry for my bad english I am from Germany

Link to comment
Share on other sites

Pipes are basically blocks that are custom rendered. You can use block methods to see if the pipe is connected to a block that has stored "liquid" in it and you can give that "liquid" to the pipe so the pipe will transport it to another block that accepts the liquid. For that you will need a tile entity instance of the pipe. About the energy system. That is not hard either. You need a custom class which will hold data about your energyitems or energyblocks, like some energy base values which your blocks or items will hold. Based on these Energy Values you can say if the block will work or not and in what speed it will work. NBT data will be your best friend on this.

Link to comment
Share on other sites

But how can I do this...code please  :(

 

I am sorry but i cannot write the whole code for you. Watch tutorials for custom rendering. Watch tutorials on how to use TileEntities. And also watch tutorials on how to use NBTTagCompound. If i am not mistaken the official forge wiki has tutorials for all three of these so you can see some examples there.

Link to comment
Share on other sites

^What they said.

 

For the generator, you need to use the TileEntity's onUpdate method. If there is fuel in the slot, then find the fuel's value (look in TileEntityFurnace for that), then remove the item and add that value to the TileEntity's saved value. You'll need to use NBT for that.

It's likely you want to show that value in some sort of GUI too, so you'll need to sync it to the client.

 

I won't provide the code, because obviously it's important to learn it, but the methods you'll need in your TileEntity for that are:

 

void writeToNBT(NBTTagCompound nbt) - Writes the custom fuel value

void readFromNBT(NBTTagCompound nbt) - Reads the value back for usage

Packet getDescriptionPacket() - Writes NBT to a packet to be sent to the client

void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) - Reads the packet on the client (to show the value in a GUI)

 

With those, you can generate fuel and save the value, but it won't keep any extra coal in the inventory - you'll need to implement IInventory for that, as well as make a container.

 

As for your pipes, you'll need a tank or similar first (Similar to above, a tile entity with NBT stuff). Then in your onUpdate, check around your tank for a pipe, and if there is one, fill the pipe with your liquid (which is effectively a tiny tank). Alternatively, you could just track through the pipes until you find another tank/block that accepts liquids - which is how ExtraUtilities works but can be slow for large networks.

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Link to comment
Share on other sites

As a general strategy for making an energy delivery system, I would recommend the following.  The cables should basically check around for any blocks next to it that are a generator, if there is a generator beside it then it should consider itself powered. Then cables should look for any cables around itself that are powered and if there are then consider themselves powered.

 

You could leave it at that (it would create a power system) but it would have a couple issues. First of all, if you deleted a power source it would stay powered. So it could be better to calculate all the power system fresh each tick. In that case you need to iterate until you've propagated the power throgh the entire length of the cable. For example, you would keep cycling through all the cable blocks and check for if any adjacent block is powered, if it is then you power the block and then cycle again -- keep going until you don't find any new blocks that need power.

 

Also, many power systems have a limit on how far the power can propagate. In that case you need to have a power level at the gen4erator and subtract some amount for each piece of cable.

 

But generally the idea is still the same -- each block needs to check all surrounding blocks and propogate power where appropriate.

 

Note that where I say blocks above you probably want to use tile entities since they can contain more complicated data fields and also process every tick.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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



×
×
  • Create New...

Important Information

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