Jump to content

Recommended Posts

Posted

Hi,

I was making a generator for a UniversalElectricity add-on. I wanted to make it so that the generator had to have water in it and lava underneath to work. I have managed to get the lava working, however I ran into a problem with water. I searched the internet and apparently my class had to implement IFluidHandler. However, I am pretty dumbfounded on what to do with the methods.

 

Quick Overview of what I want to do with this:

Add a slot that holds buckets.

Drain the water out of the bucket when inserted and put into internal tank.

If tank has water and lava is underneath the generator will run.

 

TileEntity:

package spaceage.common.tile;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.util.Icon;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import resonant.lib.prefab.vector.Cuboid;
import spaceage.common.SpaceAgeCore;
import universalelectricity.api.energy.EnergyStorageHandler;

public class TileHeatGenerator extends TileEnergyDistribution implements IFluidHandler {

@SideOnly(Side.CLIENT)
public static Icon sside, bottom;

public TileHeatGenerator()
{
	super(Material.iron);
	energy = new EnergyStorageHandler(SpaceAgeCore.HEAT_ENERGY * 20);
	ioMap = 728;
	textureName = "heat_top";
	bounds = new Cuboid(0, 0, 0, 1, 0.3f, 1);
	isOpaqueCube = false;
	normalRender = false;
}

@SideOnly(Side.CLIENT)
@Override
public void registerIcons(IconRegister iconReg)
{
	sside = iconReg.registerIcon(SpaceAgeCore.modid + ":" + "heat_side");
	bottom = iconReg.registerIcon(SpaceAgeCore.modid + ":" + "heat_bottom");
	super.registerIcons(iconReg);
}

@Override
@SideOnly(Side.CLIENT)
public Icon getIcon(int side, int meta) {
	switch(side) {
		case 0: return bottom;
		default: return sside;
		}
/*{
	if (side == 0)
	{
		return solarPanel_bottom;
	}
	else if (side == 1)
	{
		return getIcon();
	}

	return solarPanel_side;*/
}

@Override
public void updateEntity() {
	boolean powered = worldObj.getBlockId(xCoord, yCoord - 1, zCoord) == Block.lavaStill.blockID;

	if(powered == true) {
		this.energy.receiveEnergy(SpaceAgeCore.HEAT_ENERGY, true);
		markDistributionUpdate |= produce() > 0;
			}

	super.updateEntity();		
}

@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
	// TODO Auto-generated method stub
	return 0;
}

@Override
public FluidStack drain(ForgeDirection from, FluidStack resource,
		boolean doDrain) {
	// TODO Auto-generated method stub
	return null;
}

@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
	// TODO Auto-generated method stub
	return null;
}

@Override
public boolean canFill(ForgeDirection from, Fluid fluid) {
	// TODO Auto-generated method stub
	return false;
}

@Override
public boolean canDrain(ForgeDirection from, Fluid fluid) {
	// TODO Auto-generated method stub
	return false;
}

@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
	// TODO Auto-generated method stub
	return null;
}
}

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.