aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/xmod/ic2/block/RTGGenerator/TileEntityRTG.java
blob: cac4cbf9db0016dde151c5b0ed948e3c82f0d5c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package gtPlusPlus.xmod.ic2.block.RTGGenerator;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gtPlusPlus.xmod.ic2.block.RTGGenerator.gui.CONTAINER_RTG;
import gtPlusPlus.xmod.ic2.block.RTGGenerator.gui.GUI_RTG;
import ic2.core.ContainerBase;
import ic2.core.Ic2Items;
import ic2.core.block.generator.tileentity.TileEntityRTGenerator;
import ic2.core.block.invslot.InvSlotConsumable;
import ic2.core.block.invslot.InvSlotConsumableId;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;

public class TileEntityRTG extends TileEntityRTGenerator {
	public final InvSlotConsumable fuelSlot;

	public TileEntityRTG() {
		this.fuelSlot = new InvSlotConsumableId(this, "fuelSlot", 0, 12, new Item[] {
				Ic2Items.RTGPellets.getItem()
		});
	}

	@Override
	public boolean delayActiveUpdate() {
		return true;
	}

	@Override
	public boolean gainEnergy() {
		int counter = 0;
		for (int i = 0; i < this.fuelSlot.size(); i++) {
			if (this.fuelSlot.get(i) != null) {
				counter++;
			}
		}
		if (counter == 0) {
			return false;
		}
		this.storage += (int) Math.pow(2.0D, counter - 1);
		return true;
	}

	@Override
	public boolean gainFuel() {
		return false;
	}

	@Override
	public int gaugeFuelScaled(final int i) {
		return i;
	}

	@Override
	@SideOnly(Side.CLIENT)
	public GuiScreen getGui(final EntityPlayer entityPlayer, final boolean isAdmin) {
		return new GUI_RTG(new CONTAINER_RTG(entityPlayer, this));
	}

	@Override
	public ContainerBase<TileEntityRTGenerator> getGuiContainer(final EntityPlayer entityPlayer) {
		return new CONTAINER_RTG(entityPlayer, this);
	}

	@Override
	public String getInventoryName() {
		return "RTG";
	}

	@Override
	public boolean needsFuel() {
		return true;
	}

}