Hello,
I am SkylordJoel and am here today for the much needed Universal Electricity tutorial for 1.6.4.
Starting your mod:
Not to be lazy here but seriously, there are tonnes of these tutorials. Go find a god one, set it up, and come back here.
Universal Electricity setup:
Download the UE api from here and my UE developing kit here. Unzip them both, then put them in your mcp/src/minecraft folder.
Creating a basic generator:
Ok, so let's look at my code for an example.
package spaceage.common.tile;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import spaceage.common.SpaceAgeCore;
import uedevkit.tile.TileElectricBase;
public class TileSolarPanel extends TileElectricBase {
public TileSolarPanel() {
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
}
@Override
public void updateEntity() {
super.updateEntity();
this.produce();
if (!this.worldObj.isRemote) {
if (this.worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord) && !this.worldObj.provider.hasNoSky) {
if (this.worldObj.isDaytime()) {
if (!(this.worldObj.isThundering() || this.worldObj.isRaining())) {
if(!this.energy.isFull()) {
Long produced = Long.valueOf(SpaceAgeCore.SOLAR_ENERGY);
this.produceEnergy(produced);
}
}
}
}
}
}
}
There is a method called updateEntity that is called whenever there is a tick. The 'super.updateEntity' is required first so that the class that I am extending (in this case TileElectric)'s updateEntity is called. After that, there is the 'this.produce()'. That is in a referenced class and basically allows other machines to pull power from the internal energy storage of this generator. Then there is a test to see whether the conditions that allow power to be generated is met. If it is true, then a certain amount of energy is produced. This is basically everything you need for a generator. For a coal based generator, it would require inventory use and a different test.
I will finish later.
Rollback Post to RevisionRollBack
Check out SpaceAge, a new futuristic themed mod on GitHub: Link
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumI am SkylordJoel and am here today for the much needed Universal Electricity tutorial for 1.6.4.
Starting your mod:
Universal Electricity setup:
Creating a basic generator:
package spaceage.common.tile; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import spaceage.common.SpaceAgeCore; import uedevkit.tile.TileElectricBase; public class TileSolarPanel extends TileElectricBase { public TileSolarPanel() { } @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); } @Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); } @Override public void updateEntity() { super.updateEntity(); this.produce(); if (!this.worldObj.isRemote) { if (this.worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord) && !this.worldObj.provider.hasNoSky) { if (this.worldObj.isDaytime()) { if (!(this.worldObj.isThundering() || this.worldObj.isRaining())) { if(!this.energy.isFull()) { Long produced = Long.valueOf(SpaceAgeCore.SOLAR_ENERGY); this.produceEnergy(produced); } } } } } } }There is a method called updateEntity that is called whenever there is a tick. The 'super.updateEntity' is required first so that the class that I am extending (in this case TileElectric)'s updateEntity is called. After that, there is the 'this.produce()'. That is in a referenced class and basically allows other machines to pull power from the internal energy storage of this generator. Then there is a test to see whether the conditions that allow power to be generated is met. If it is true, then a certain amount of energy is produced. This is basically everything you need for a generator. For a coal based generator, it would require inventory use and a different test.
I will finish later.