Jump to content

Recommended Posts

Posted

Hey there,

 

I have been working on a multiblock reactor, where there are an indefinite number of 3*2*3 (x, y, z) size fusion chambers stacked on top of each other to make the total reactor. Each fusion chamber consists of one Fusion Reactor tile entity with 17 'dummy' tile entities above and around it.

 

My problem is that, unlike my other machines, whenever the player logs out of the world, the contents of the reactor's inventory disappear and the energy, heat etc. go back to 0. In other words, the reactor totally resets as if it had just been placed.

 

Tile Entity:

package com.nr.mod.blocks.tileentities;

import net.minecraft.init.Items;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import cofh.api.energy.EnergyStorage;
import cofh.api.energy.IEnergyConnection;
import cofh.api.energy.IEnergyHandler;
import cofh.api.energy.IEnergyReceiver;

import com.nr.mod.NuclearRelativistics;
import com.nr.mod.blocks.NRBlocks;
import com.nr.mod.items.NRItems;

public class TileEntityFusionReactor extends TileEntityInventory implements IEnergyHandler, IEnergyConnection, ISidedInventory, IEnergyReceiver {

	public int size = 1;
	public boolean isMain = true;
	public int below = 0;

    public EnergyStorage storage = new EnergyStorage(10000000, 10000000);
    public int energy;
    public int EShown;
    
    public int pMult = NuclearRelativistics.fusionRF/5;
    
    public int HLevel;
    public int DLevel;
    public int TLevel;
    public int HeLevel;
    public int BLevel;
    public int Li6Level;
    public int Li7Level;
    public int HLevel2;
    public int DLevel2;
    public int TLevel2;
    public int HeLevel2;
    public int BLevel2;
    public int Li6Level2;
    public int Li7Level2;
    
    public double HOut;
    public double DOut;
    public double TOut;
    public double HE3Out;
    public double HE4Out;
    
    public int Max = 12096000;
    
    public int powerHH = 80*pMult;
    public int powerHD = 60*pMult;
    public int powerHT = 20*pMult;
    public int powerHHe = 20*pMult;
    public int powerHB = 80*pMult;
    public int powerHLi6 = 30*pMult;
    public int powerHLi7 = 120*pMult;
    
    public int powerDD = 180*pMult;
    public int powerDT = 200*pMult;
    public int powerDHe = 160*pMult;
    public int powerDB = 20*pMult;
    public int powerDLi6 = 130*pMult;
    public int powerDLi7 = 10*pMult;
    
    public int powerTT = 60*pMult;
    public int powerTHe = 40*pMult;
    public int powerTB = 10*pMult;
    public int powerTLi6 = 5*pMult;
    public int powerTLi7 = 10*pMult;
    
    public int powerHeHe = 120*pMult;
    public int powerHeB = 5*pMult;
    public int powerHeLi6 = 140*pMult;
    public int powerHeLi7 = 30*pMult;
    
    public int powerBB = 5*pMult;
    public int powerBLi6 = 5*pMult;
    public int powerBLi7 = 5*pMult;
    
    public int powerLi6Li6 = 5*pMult;
    public int powerLi6Li7 = 5*pMult;
    
    public int powerLi7Li7 = 5*pMult;
    
    public int requiredHH = 100;
    public int requiredHD = 100;
    public int requiredHT = 80;
    public int requiredHHe = 40;
    public int requiredHB = 4;
    public int requiredHLi6 = 10;
    public int requiredHLi7 = 20;

    public int requiredDD = 20;
    public int requiredDT = 25;
    public int requiredDHe = 10;
    public int requiredDB = 10;
    public int requiredDLi6 = 100;
    public int requiredDLi7 = 10;
    
    public int requiredTT = 20;
    public int requiredTHe = 16;
    public int requiredTB = 10;
    public int requiredTLi6 = 4;
    public int requiredTLi7 = 4;

    public int requiredHeHe = 25;
    public int requiredHeB = 8;
    public int requiredHeLi6 = 80;
    public int requiredHeLi7 = 20;

    public int requiredBB = 4;
    public int requiredBLi6 = 8;
    public int requiredBLi7 = 4;

    public int requiredLi6Li6 = 2;
    public int requiredLi6Li7 = 4;

    public int requiredLi7Li7 = 2;

    public double maxHeat = 20000;
    public double efficiency = 0;
    public double heatVar = 9;
    public double heat;

    public double heatHH = 8.87;
    public double heatHD = 8.43;
    public double heatHT = 9.65;
    public double heatHHe = 9.68;
    public double heatHB = 9.84;
    public double heatHLi6 = 9.62;
    public double heatHLi7 = 9.64;

    public double heatDD = 9.67;
    public double heatDT = 7.70;
    public double heatDHe = 8.97;
    public double heatDB = 9.89;
    public double heatDLi6 = 9.78;
    public double heatDLi7 = 10.10;

    public double heatTT = 9.46;
    public double heatTHe = 9.73;
    public double heatTB = 10.16;
    public double heatTLi6 = 10.08;
    public double heatTLi7 = 10.01;

    public double heatHeHe = 9.92;
    public double heatHeB = 10.13;
    public double heatHeLi6 = 10.16;
    public double heatHeLi7 = 10.02;

    public double heatBB = 10.12;
    public double heatBLi6 = 10.00;
    public double heatBLi7 = 10.17;

    public double heatLi6Li6 = 10.18;
    public double heatLi6Li7 = 10.16;

    public double heatLi7Li7 = 10.18;
    
    public boolean flag;
    public boolean flag1 = false;
    public int lastE;
    public int E;
    public int maxTransfer = 1000000;
    public String direction;
    
	private static final int[] slotsBottom = new int[] {0, 1};

    public TileEntityFusionReactor() {
        super.slots = new ItemStack[7];
        super.localizedName = "Fusion Reactor";
    }

    public void updateEntity() {
    	super.updateEntity();
    	if(!this.worldObj.isRemote) {
	    	getMain();
	    	setSize(worldObj, xCoord, yCoord, zCoord);
	    	isMain(worldObj, xCoord, yCoord, zCoord);
	    	getBelow(worldObj, xCoord, yCoord, zCoord);
	    	isMain();
	    	energy();
	    	addEnergy();
	    	fuel1();
	    	fuel2();
	    	efficiency();
	    	if (heat < 8 && storage.getEnergyStored() >= 50000) {
	    		this.storage.receiveEnergy(-50000, false);
	    		heat = heat+0.005;
	    	}
	    	if (heat < 0) {
	    		heat = 0;
	    	}
    	}
    	if (flag != flag1) { flag1 = flag; BlockFusionReactor.updateBlockState(worldObj, xCoord, yCoord, zCoord); }
    	markDirty();
    }
    
    public void efficiency() {
    	if (HLevel + DLevel + TLevel + HeLevel + BLevel + Li6Level + Li7Level <= 0 || HLevel2 + DLevel2 + TLevel2 + HeLevel2 + BLevel2 + Li6Level2 + Li7Level2 <= 0) {
    		efficiency = 0;
    	} else if (heat >=  {
    		efficiency = 100*(Math.exp(-Math.pow(Math.log(heat)-heatVar, 2)/2)/(Math.sqrt(2*Math.PI)*heat))/(Math.exp(0.5-heatVar)/(Math.sqrt(2*Math.PI)));
    	} else {
    		efficiency = 0;
    	}
    }
    
    public void setSize(World world, int x, int y, int z) {
    	int oldSize = size;
		size = 1;
		for (int yUp = 1; yUp < 128; ++yUp) {
			if (world.getBlock(x, y + 2*yUp, z) == NRBlocks.fusionReactor) {
				size++;
			} else break;
		}
		if (oldSize != size) {
			powerHH = 80*pMult*size;
		    powerHD = 60*pMult*size;
		    powerHT = 20*pMult*size;
		    powerHHe = 20*pMult*size;
		    powerHB = 80*pMult*size;
		    powerHLi6 = 30*pMult*size;
		    powerHLi7 = 120*pMult*size;
		    
		    powerDD = 180*pMult*size;
		    powerDT = 200*pMult*size;
		    powerDHe = 160*pMult*size;
		    powerDB = 20*pMult*size;
		    powerDLi6 = 130*pMult*size;
		    powerDLi7 = 10*pMult*size;
		    
		    powerTT = 60*pMult*size;
		    powerTHe = 40*pMult*size;
		    powerTB = 10*pMult*size;
		    powerTLi6 = 5*pMult*size;
		    powerTLi7 = 10*pMult*size;
		    
		    powerHeHe = 120*pMult*size;
		    powerHeB = 5*pMult*size;
		    powerHeLi6 = 140*pMult*size;
		    powerHeLi7 = 30*pMult*size;
		    
		    powerBB = 5*pMult*size;
		    powerBLi6 = 5*pMult*size;
		    powerBLi7 = 5*pMult*size;
		    
		    powerLi6Li6 = 5*pMult*size;
		    powerLi6Li7 = 5*pMult*size;
		    
		    powerLi7Li7 = 5*pMult*size;
		    
		    requiredHH = 100*size;
		    requiredHD = 100*size;
		    requiredHT = 80*size;
		    requiredHHe = 40*size;
		    requiredHB = 4*size;
		    requiredHLi6 = 10*size;
		    requiredHLi7 = 20*size;

		    requiredDD = 20*size;
		    requiredDT = 25*size;
		    requiredDHe = 10*size;
		    requiredDB = 10*size;
		    requiredDLi6 = 100*size;
		    requiredDLi7 = 10*size;
		    
		    requiredTT = 20*size;
		    requiredTHe = 16*size;
		    requiredTB = 10*size;
		    requiredTLi6 = 4*size;
		    requiredTLi7 = 4*size;

		    requiredHeHe = 25*size;
		    requiredHeB = 8*size;
		    requiredHeLi6 = 80*size;
		    requiredHeLi7 = 20*size;

		    requiredBB = 4*size;
		    requiredBLi6 = 8*size;
		    requiredBLi7 = 4*size;

		    requiredLi6Li6 = 2*size;
		    requiredLi6Li7 = 4*size;

		    requiredLi7Li7 = 2*size;
		}
	}
    
    public void isMain(World world, int x, int y, int z) {
    	if (world.getBlock(x, y - 2, z) == NRBlocks.fusionReactor) {
    		isMain = false;
    	} else {
    		isMain = true;
    	}
    }
    
    public void getBelow(World world, int x, int y, int z) {
		below = 0;
		for (int yDown = 1; yDown < 128; ++yDown) {
			if (world.getBlock(x, y - 2*yDown, z) == NRBlocks.fusionReactor) {
				below++;
			} else break;
		}
	}
    
    public TileEntityFusionReactor getMain() {
    	if (below != 0) {
    		TileEntityFusionReactor main = (TileEntityFusionReactor)worldObj.getTileEntity(xCoord, yCoord - 2*below, zCoord);
    		return main;
    	} else {
    		return (TileEntityFusionReactor)worldObj.getTileEntity(xCoord, yCoord, zCoord);
    	}
    }
    
    public boolean isMain() {
    	return getMain() != null ? isMain : false;
    }

    private void energy() {
    	int prevE = this.storage.getEnergyStored();
    	int newE;

    	if (!worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord) && heat >= {
    	lastE = storage.getEnergyStored();
    	
    	if (this.HLevel > 0 && this.HLevel2 > 0) {
	    	if (this.HLevel >= (Math.sqrt(efficiency)/10)*this.requiredHH && this.HLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredHH)
	    	{this.heatVar = this.heatHH; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerHH/100), false); this.HLevel -= (Math.sqrt(efficiency)/10)*this.requiredHH; this.HLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredHH; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	if (this.HLevel < (Math.sqrt(efficiency)/10)*this.requiredHH) {this.HLevel = 0;}
	    	if (this.HLevel2 < (Math.sqrt(efficiency)/10)*this.requiredHH) {this.HLevel2 = 0;}
    	}
    	
    	else if (this.HLevel > 0 && this.DLevel2 > 0) {
	    	 if (this.HLevel >= (Math.sqrt(efficiency)/10)*this.requiredHD && this.DLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredHD)
	    	{this.heatVar = this.heatHD; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerHD/100), false); this.HLevel -= (Math.sqrt(efficiency)/10)*this.requiredHD; this.DLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredHD; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.HLevel < (Math.sqrt(efficiency)/10)*this.requiredHD) {this.HLevel = 0;}
	    	 if (this.DLevel2 < (Math.sqrt(efficiency)/10)*this.requiredHD) {this.DLevel2 = 0;}
    	}
    	
    	else if (this.DLevel > 0 && this.HLevel2 > 0) {
	    	 if (this.DLevel >= (Math.sqrt(efficiency)/10)*this.requiredHD && this.HLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredHD)
	    	{this.heatVar = this.heatHD; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerHD/100), false); this.DLevel -= (Math.sqrt(efficiency)/10)*this.requiredHD; this.HLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredHD; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.DLevel < (Math.sqrt(efficiency)/10)*this.requiredHD) {this.DLevel = 0;}
	    	 if (this.HLevel2 < (Math.sqrt(efficiency)/10)*this.requiredHD) {this.HLevel2 = 0;}
    	}
	    
    	else if (this.HLevel > 0 && this.TLevel2 > 0) {
	    	 if (this.HLevel >= (Math.sqrt(efficiency)/10)*this.requiredHT && this.TLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredHT)
	    	{this.heatVar = this.heatHT; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerHT/100), false); this.HLevel -= (Math.sqrt(efficiency)/10)*this.requiredHT; this.TLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredHT; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.HLevel < (Math.sqrt(efficiency)/10)*this.requiredHT) {this.HLevel = 0;}
	    	 if (this.TLevel2 < (Math.sqrt(efficiency)/10)*this.requiredHT) {this.TLevel2 = 0;}
    	}
	    
    	else if (this.TLevel > 0 && this.HLevel2 > 0) {
	    	 if (this.TLevel >= (Math.sqrt(efficiency)/10)*this.requiredHT && this.HLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredHT)
	    	{this.heatVar = this.heatHT; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerHT/100), false); this.TLevel -= (Math.sqrt(efficiency)/10)*this.requiredHT; this.HLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredHT; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.TLevel < (Math.sqrt(efficiency)/10)*this.requiredHT) {this.TLevel = 0;}
	    	 if (this.HLevel2 < (Math.sqrt(efficiency)/10)*this.requiredHT) {this.HLevel2 = 0;}
    	}
    	
    	else if (this.HLevel > 0 && this.HeLevel2 > 0) {
	    	 if (this.HLevel >= (Math.sqrt(efficiency)/10)*this.requiredHHe && this.HeLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredHHe)
	    	{this.heatVar = this.heatHHe; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerHHe/100), false); this.HLevel -= (Math.sqrt(efficiency)/10)*this.requiredHHe; this.HeLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredHHe; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.HLevel < (Math.sqrt(efficiency)/10)*this.requiredHHe) {this.HLevel = 0;}
	    	 if (this.HeLevel2 < (Math.sqrt(efficiency)/10)*this.requiredHHe) {this.HeLevel2 = 0;}
    	}
    	
    	else if (this.HeLevel > 0 && this.HLevel2 > 0) {
	    	 if (this.HeLevel >= (Math.sqrt(efficiency)/10)*this.requiredHHe && this.HLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredHHe)
	    	{this.heatVar = this.heatHHe; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerHHe/100), false); this.HeLevel -= (Math.sqrt(efficiency)/10)*this.requiredHHe; this.HLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredHHe; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.HeLevel < (Math.sqrt(efficiency)/10)*this.requiredHHe) {this.HeLevel = 0;}
	    	 if (this.HLevel2 < (Math.sqrt(efficiency)/10)*this.requiredHHe) {this.HLevel2 = 0;}
    	}
    	
    	else if (this.HLevel > 0 && this.BLevel2 > 0) {
	    	 if (this.HLevel >= (Math.sqrt(efficiency)/10)*this.requiredHB && this.BLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredHB)
	    	{this.heatVar = this.heatHB; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerHB/100), false); this.HLevel -= (Math.sqrt(efficiency)/10)*this.requiredHB; this.BLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredHB; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.HLevel < (Math.sqrt(efficiency)/10)*this.requiredHB) {this.HLevel = 0;}
	    	 if (this.BLevel2 < (Math.sqrt(efficiency)/10)*this.requiredHB) {this.BLevel2 = 0;}
    	}
    	
    	else if (this.BLevel > 0 && this.HLevel2 > 0) {
	    	 if (this.BLevel >= (Math.sqrt(efficiency)/10)*this.requiredHB && this.HLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredHB)
	    	{this.heatVar = this.heatHB; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerHB/100), false); this.BLevel -= (Math.sqrt(efficiency)/10)*this.requiredHB; this.HLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredHB; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.BLevel < (Math.sqrt(efficiency)/10)*this.requiredHB) {this.BLevel = 0;}
	    	 if (this.HLevel2 < (Math.sqrt(efficiency)/10)*this.requiredHB) {this.HLevel2 = 0;}
    	}
    	
    	else if (this.HLevel > 0 && this.Li6Level2 > 0) {
	    	 if (this.HLevel >= (Math.sqrt(efficiency)/10)*this.requiredHLi6 && this.Li6Level2 >= (Math.sqrt(efficiency)/10)*this.requiredHLi6)
	    	{this.heatVar = this.heatHLi6; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerHLi6/100), false); this.HLevel -= (Math.sqrt(efficiency)/10)*this.requiredHLi6; this.Li6Level2 -= (Math.sqrt(efficiency)/10)*this.requiredHLi6; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.HLevel < (Math.sqrt(efficiency)/10)*this.requiredHLi6) {this.HLevel = 0;}
	    	 if (this.Li6Level2 < (Math.sqrt(efficiency)/10)*this.requiredHLi6) {this.Li6Level2 = 0;}
    	}
    	
    	else if (this.Li6Level > 0 && this.HLevel2 > 0) {
	    	 if (this.Li6Level >= (Math.sqrt(efficiency)/10)*this.requiredHLi6 && this.HLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredHLi6)
	    	{this.heatVar = this.heatHLi6; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerHLi6/100), false); this.Li6Level -= (Math.sqrt(efficiency)/10)*this.requiredHLi6; this.HLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredHLi6; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.Li6Level < (Math.sqrt(efficiency)/10)*this.requiredHLi6) {this.Li6Level = 0;}
	    	 if (this.HLevel2 < (Math.sqrt(efficiency)/10)*this.requiredHLi6) {this.HLevel2 = 0;}
    	}
    	
    	else if (this.HLevel > 0 && this.Li7Level2 > 0) {
	    	 if (this.HLevel >= (Math.sqrt(efficiency)/10)*this.requiredHLi7 && this.Li7Level2 >= (Math.sqrt(efficiency)/10)*this.requiredHLi7)
	    	{this.heatVar = this.heatHLi7; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerHLi7/100), false); this.HLevel -= (Math.sqrt(efficiency)/10)*this.requiredHLi7; this.Li7Level2 -= (Math.sqrt(efficiency)/10)*this.requiredHLi7; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.HLevel < (Math.sqrt(efficiency)/10)*this.requiredHH) {this.HLevel = 0;}
	    	 if (this.Li7Level2 < (Math.sqrt(efficiency)/10)*this.requiredHH) {this.Li7Level2 = 0;}
    	}
    	
    	else if (this.Li7Level > 0 && this.HLevel2 > 0) {
	    	 if (this.Li7Level >= (Math.sqrt(efficiency)/10)*this.requiredHLi7 && this.HLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredHLi7)
	    	{this.heatVar = this.heatHLi7; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerHLi7/100), false); this.Li7Level -= (Math.sqrt(efficiency)/10)*this.requiredHLi7; this.HLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredHLi7; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.Li7Level < (Math.sqrt(efficiency)/10)*this.requiredHLi7) {this.Li7Level = 0;}
	    	 if (this.HLevel2 < (Math.sqrt(efficiency)/10)*this.requiredHLi7) {this.HLevel2 = 0;}
    	}
    	
	    	//
	    	
    	else if (this.DLevel > 0 && this.DLevel2 > 0) {
	    	 if (this.DLevel >= (Math.sqrt(efficiency)/10)*this.requiredDD && this.DLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredDD)
	    	{this.heatVar = this.heatDD; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerDD/100), false); this.DLevel -= (Math.sqrt(efficiency)/10)*this.requiredDD; this.DLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredDD; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.DLevel < (Math.sqrt(efficiency)/10)*this.requiredHLi7) {this.DLevel = 0;}
	    	 if (this.DLevel2 < (Math.sqrt(efficiency)/10)*this.requiredHLi7) {this.DLevel2 = 0;}
    	}
    	
    	else if (this.DLevel > 0 && this.TLevel2 > 0) {
	    	 if (this.DLevel >= (Math.sqrt(efficiency)/10)*this.requiredDT && this.TLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredDT)
	    	{this.heatVar = this.heatDT; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerDT/100), false); this.DLevel -= (Math.sqrt(efficiency)/10)*this.requiredDT; this.TLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredDT; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.DLevel < (Math.sqrt(efficiency)/10)*this.requiredDT) {this.DLevel = 0;}
	    	 if (this.TLevel2 < (Math.sqrt(efficiency)/10)*this.requiredDT) {this.TLevel2 = 0;}
    	}
    	
    	else if (this.TLevel > 0 && this.DLevel2 > 0) {
	    	 if (this.TLevel >= (Math.sqrt(efficiency)/10)*this.requiredDT && this.DLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredDT)
	    	{this.heatVar = this.heatDT; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerDT/100), false); this.TLevel -= (Math.sqrt(efficiency)/10)*this.requiredDT; this.DLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredDT; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.TLevel < (Math.sqrt(efficiency)/10)*this.requiredDT) {this.TLevel = 0;}
	    	 if (this.DLevel2 < (Math.sqrt(efficiency)/10)*this.requiredDT) {this.DLevel2 = 0;}
    	}
    	
    	else if (this.DLevel > 0 && this.HeLevel2 > 0) {
	    	 if (this.DLevel >= (Math.sqrt(efficiency)/10)*this.requiredDHe && this.HeLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredDHe)
	    	{this.heatVar = this.heatDHe; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerDHe/100), false); this.DLevel -= (Math.sqrt(efficiency)/10)*this.requiredDHe; this.HeLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredDHe; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.DLevel < (Math.sqrt(efficiency)/10)*this.requiredDHe) {this.DLevel = 0;}
	    	 if (this.HeLevel2 < (Math.sqrt(efficiency)/10)*this.requiredDHe) {this.HeLevel2 = 0;}
    	}
    	
    	else if (this.HeLevel > 0 && this.DLevel2 > 0) {
	    	 if (this.HeLevel >= (Math.sqrt(efficiency)/10)*this.requiredDHe && this.DLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredDHe)
	    	{this.heatVar = this.heatDHe; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerDHe/100), false); this.HeLevel -= (Math.sqrt(efficiency)/10)*this.requiredDHe; this.DLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredDHe; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.HeLevel < (Math.sqrt(efficiency)/10)*this.requiredDHe) {this.HeLevel = 0;}
	    	 if (this.DLevel2 < (Math.sqrt(efficiency)/10)*this.requiredDHe) {this.DLevel2 = 0;}
    	}
    	
    	else if (this.DLevel > 0 && this.BLevel2 > 0) {
	    	 if (this.DLevel >= (Math.sqrt(efficiency)/10)*this.requiredDB && this.BLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredDB)
	    	{this.heatVar = this.heatDB; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerDB/100), false); this.DLevel -= (Math.sqrt(efficiency)/10)*this.requiredDB; this.BLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredDB; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.DLevel < (Math.sqrt(efficiency)/10)*this.requiredDB) {this.DLevel = 0;}
	    	 if (this.BLevel2 < (Math.sqrt(efficiency)/10)*this.requiredDB) {this.BLevel2 = 0;}
    	}
    	
    	else if (this.BLevel > 0 && this.DLevel2 > 0) {
	    	 if (this.BLevel >= (Math.sqrt(efficiency)/10)*this.requiredDB && this.DLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredDB)
	    	{this.heatVar = this.heatDB; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerDB/100), false); this.BLevel -= (Math.sqrt(efficiency)/10)*this.requiredDB; this.DLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredDB; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.BLevel < (Math.sqrt(efficiency)/10)*this.requiredDB) {this.BLevel = 0;}
	    	 if (this.DLevel2 < (Math.sqrt(efficiency)/10)*this.requiredDB) {this.DLevel2 = 0;}
    	}
    	
    	else if (this.DLevel > 0 && this.Li6Level2 > 0) {
	    	 if (this.DLevel >= (Math.sqrt(efficiency)/10)*this.requiredDLi6 && this.Li6Level2 >= (Math.sqrt(efficiency)/10)*this.requiredDLi6)
	    	{this.heatVar = this.heatDLi6; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerDLi6/100), false); this.DLevel -= (Math.sqrt(efficiency)/10)*this.requiredDLi6; this.Li6Level2 -= (Math.sqrt(efficiency)/10)*this.requiredDLi6; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.DLevel < (Math.sqrt(efficiency)/10)*this.requiredDLi6) {this.DLevel = 0;}
	    	 if (this.Li6Level2 < (Math.sqrt(efficiency)/10)*this.requiredDLi6) {this.Li6Level2 = 0;}
    	}
    	
    	else if (this.Li6Level > 0 && this.DLevel2 > 0) {
	    	 if (this.Li6Level >= (Math.sqrt(efficiency)/10)*this.requiredDLi6 && this.DLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredDLi6)
	    	{this.heatVar = this.heatDLi6; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerDLi6/100), false); this.Li6Level -= (Math.sqrt(efficiency)/10)*this.requiredDLi6; this.DLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredDLi6; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.Li6Level < (Math.sqrt(efficiency)/10)*this.requiredDLi6) {this.Li6Level = 0;}
	    	 if (this.DLevel2 < (Math.sqrt(efficiency)/10)*this.requiredDLi6) {this.DLevel2 = 0;}
    	}
    	
    	else if (this.DLevel > 0 && this.Li7Level2 > 0) {
	    	 if (this.DLevel >= (Math.sqrt(efficiency)/10)*this.requiredDLi7 && this.Li7Level2 >= (Math.sqrt(efficiency)/10)*this.requiredDLi7)
	    	{this.heatVar = this.heatDLi7; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerDLi7/100), false); this.DLevel -= (Math.sqrt(efficiency)/10)*this.requiredDLi7; this.Li7Level2 -= (Math.sqrt(efficiency)/10)*this.requiredDLi7; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.DLevel < (Math.sqrt(efficiency)/10)*this.requiredDLi7) {this.DLevel = 0;}
	    	 if (this.Li7Level2 < (Math.sqrt(efficiency)/10)*this.requiredDLi7) {this.Li7Level2 = 0;}
    	}
    	
    	else if (this.Li7Level > 0 && this.DLevel2 > 0) {
	    	 if (this.Li7Level >= (Math.sqrt(efficiency)/10)*this.requiredDLi7 && this.DLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredDLi7)
	    	{this.heatVar = this.heatDLi7; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerDLi7/100), false); this.Li7Level -= (Math.sqrt(efficiency)/10)*this.requiredDLi7; this.DLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredDLi7; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.Li7Level < (Math.sqrt(efficiency)/10)*this.requiredDLi7) {this.Li7Level = 0;}
	    	 if (this.DLevel2 < (Math.sqrt(efficiency)/10)*this.requiredDLi7) {this.DLevel2 = 0;}
    	}
    	
	    	//
	    	
    	else if (this.TLevel > 0 && this.TLevel2 > 0) {
	    	 if (this.TLevel >= (Math.sqrt(efficiency)/10)*this.requiredTT && this.TLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredTT)
	    	{this.heatVar = this.heatTT; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerTT/100), false); this.TLevel -= (Math.sqrt(efficiency)/10)*this.requiredTT; this.TLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredTT; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.TLevel < (Math.sqrt(efficiency)/10)*this.requiredTT) {this.TLevel = 0;}
	    	 if (this.TLevel2 < (Math.sqrt(efficiency)/10)*this.requiredTT) {this.TLevel2 = 0;}
    	}
    	
    	else if (this.TLevel > 0 && this.HeLevel2 > 0) {
	    	 if (this.TLevel >= (Math.sqrt(efficiency)/10)*this.requiredTHe && this.HeLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredTHe)
	    	{this.heatVar = this.heatTHe; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerTHe/100), false); this.TLevel -= (Math.sqrt(efficiency)/10)*this.requiredTHe; this.HeLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredTHe; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.TLevel < (Math.sqrt(efficiency)/10)*this.requiredTHe) {this.TLevel = 0;}
	    	 if (this.HeLevel2 < (Math.sqrt(efficiency)/10)*this.requiredTHe) {this.HeLevel2 = 0;}
    	}
    	
    	else if (this.HeLevel > 0 && this.TLevel2 > 0) {
	    	 if (this.HeLevel >= (Math.sqrt(efficiency)/10)*this.requiredTHe && this.TLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredTHe)
	    	{this.heatVar = this.heatTHe; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerTHe/100), false); this.HeLevel -= (Math.sqrt(efficiency)/10)*this.requiredTHe; this.TLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredTHe; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.HeLevel < (Math.sqrt(efficiency)/10)*this.requiredTHe) {this.HeLevel = 0;}
	    	 if (this.TLevel2 < (Math.sqrt(efficiency)/10)*this.requiredTHe) {this.TLevel2 = 0;}
    	}
    	
    	else if (this.TLevel > 0 && this.BLevel2 > 0) {
	    	 if (this.TLevel >= (Math.sqrt(efficiency)/10)*this.requiredTB && this.BLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredTB)
	    	{this.heatVar = this.heatTB; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerTB/100), false); this.TLevel -= (Math.sqrt(efficiency)/10)*this.requiredTB; this.BLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredTB; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.TLevel < (Math.sqrt(efficiency)/10)*this.requiredTB) {this.TLevel = 0;}
	    	 if (this.BLevel2 < (Math.sqrt(efficiency)/10)*this.requiredTB) {this.BLevel2 = 0;}
    	}
    	
    	else if (this.BLevel > 0 && this.TLevel2 > 0) {
	    	 if (this.BLevel >= (Math.sqrt(efficiency)/10)*this.requiredTB && this.TLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredTB)
	    	{this.heatVar = this.heatTB; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerTB/100), false); this.BLevel -= (Math.sqrt(efficiency)/10)*this.requiredTB; this.TLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredTB; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.BLevel < (Math.sqrt(efficiency)/10)*this.requiredTB) {this.BLevel = 0;}
	    	 if (this.TLevel2 < (Math.sqrt(efficiency)/10)*this.requiredTB) {this.TLevel2 = 0;}
    	}
    	
    	else if (this.TLevel > 0 && this.Li6Level2 > 0) {
	    	 if (this.TLevel >= (Math.sqrt(efficiency)/10)*this.requiredTLi6 && this.Li6Level2 >= (Math.sqrt(efficiency)/10)*this.requiredTLi6)
	    	{this.heatVar = this.heatTLi6; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerTLi6/100), false); this.TLevel -= (Math.sqrt(efficiency)/10)*this.requiredTLi6; this.Li6Level2 -= (Math.sqrt(efficiency)/10)*this.requiredTLi6; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.TLevel < (Math.sqrt(efficiency)/10)*this.requiredTLi6) {this.TLevel = 0;}
	    	 if (this.Li6Level2 < (Math.sqrt(efficiency)/10)*this.requiredTLi6) {this.Li6Level2 = 0;}
    	}
    	
    	else if (this.Li6Level > 0 && this.TLevel2 > 0) {
	    	 if (this.Li6Level >= (Math.sqrt(efficiency)/10)*this.requiredTLi6 && this.TLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredTLi6)
	    	{this.heatVar = this.heatTLi6; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerTLi6/100), false); this.Li6Level -= (Math.sqrt(efficiency)/10)*this.requiredTLi6; this.TLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredTLi6; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.Li6Level < (Math.sqrt(efficiency)/10)*this.requiredTLi6) {this.Li6Level = 0;}
	    	 if (this.TLevel2 < (Math.sqrt(efficiency)/10)*this.requiredTLi6) {this.TLevel2 = 0;}
    	}
    	
    	else if (this.TLevel > 0 && this.Li7Level2 > 0) {
	    	 if (this.TLevel >= (Math.sqrt(efficiency)/10)*this.requiredTLi7 && this.Li7Level2 >= (Math.sqrt(efficiency)/10)*this.requiredTLi7)
	    	{this.heatVar = this.heatTLi7; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerTLi7/100), false); this.TLevel -= (Math.sqrt(efficiency)/10)*this.requiredTLi7; this.Li7Level2 -= (Math.sqrt(efficiency)/10)*this.requiredTLi7; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.TLevel < (Math.sqrt(efficiency)/10)*this.requiredTLi7) {this.TLevel = 0;}
	    	 if (this.Li7Level2 < (Math.sqrt(efficiency)/10)*this.requiredTLi7) {this.Li7Level2 = 0;}
    	}
    	
    	else if (this.Li7Level > 0 && this.TLevel2 > 0) {
	    	 if (this.Li7Level >= (Math.sqrt(efficiency)/10)*this.requiredTLi7 && this.TLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredTLi7)
	    	{this.heatVar = this.heatTLi7; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerTLi7/100), false); this.Li7Level -= (Math.sqrt(efficiency)/10)*this.requiredTLi7; this.TLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredTLi7; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.Li7Level < (Math.sqrt(efficiency)/10)*this.requiredTLi7) {this.Li7Level = 0;}
	    	 if (this.TLevel2 < (Math.sqrt(efficiency)/10)*this.requiredTLi7) {this.TLevel2 = 0;}
    	}
    	
	    	//
	    	
    	else if (this.HeLevel > 0 && this.HeLevel2 > 0) {
	    	 if (this.HeLevel >= (Math.sqrt(efficiency)/10)*this.requiredHeHe && this.HeLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredHeHe)
	    	{this.heatVar = this.heatHeHe; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerHeHe/100), false); this.HeLevel -= (Math.sqrt(efficiency)/10)*this.requiredHeHe; this.HeLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredHeHe; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.HeLevel < (Math.sqrt(efficiency)/10)*this.requiredHeHe) {this.HeLevel = 0;}
	    	 if (this.HeLevel2 < (Math.sqrt(efficiency)/10)*this.requiredHeHe) {this.HeLevel2 = 0;}
    	}
    	
    	else if (this.HeLevel > 0 && this.BLevel2 > 0) {
	    	 if (this.HeLevel >= (Math.sqrt(efficiency)/10)*this.requiredHeB && this.BLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredHeB)
	    	{this.heatVar = this.heatHeB; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerHeB/100), false); this.HeLevel -= (Math.sqrt(efficiency)/10)*this.requiredHeB; this.BLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredHeB; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.HeLevel < (Math.sqrt(efficiency)/10)*this.requiredHeB) {this.HeLevel = 0;}
	    	 if (this.BLevel2 < (Math.sqrt(efficiency)/10)*this.requiredHeB) {this.BLevel2 = 0;}
    	}
    	
    	else if (this.BLevel > 0 && this.HeLevel2 > 0) {
	    	 if (this.BLevel >= (Math.sqrt(efficiency)/10)*this.requiredHeB && this.HeLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredHeB)
	    	{this.heatVar = this.heatHeB; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerHeB/100), false); this.BLevel -= (Math.sqrt(efficiency)/10)*this.requiredHeB; this.HeLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredHeB; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.BLevel < (Math.sqrt(efficiency)/10)*this.requiredHeB) {this.BLevel = 0;}
	    	 if (this.HeLevel2 < (Math.sqrt(efficiency)/10)*this.requiredHeB) {this.HeLevel2 = 0;}
    	}
    	
    	else if (this.HeLevel > 0 && this.Li6Level2 > 0) {
	    	 if (this.HeLevel >= (Math.sqrt(efficiency)/10)*this.requiredHeLi6 && this.Li6Level2 >= (Math.sqrt(efficiency)/10)*this.requiredHeLi6)
	    	{this.heatVar = this.heatHeLi6; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerHeLi6/100), false); this.HeLevel -= (Math.sqrt(efficiency)/10)*this.requiredHeLi6; this.Li6Level2 -= (Math.sqrt(efficiency)/10)*this.requiredHeLi6; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.HeLevel < (Math.sqrt(efficiency)/10)*this.requiredHeLi6) {this.HeLevel = 0;}
	    	 if (this.Li6Level2 < (Math.sqrt(efficiency)/10)*this.requiredHeLi6) {this.Li6Level2 = 0;}
    	}
    	
    	else if (this.Li6Level > 0 && this.HeLevel2 > 0) {
	    	 if (this.Li6Level >= (Math.sqrt(efficiency)/10)*this.requiredHeLi6 && this.HeLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredHeLi6)
	    	{this.heatVar = this.heatHeLi6; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerHeLi6/100), false); this.Li6Level -= (Math.sqrt(efficiency)/10)*this.requiredHeLi6; this.HeLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredHeLi6; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.Li6Level < (Math.sqrt(efficiency)/10)*this.requiredHeLi6) {this.Li6Level = 0;}
	    	 if (this.HeLevel2 < (Math.sqrt(efficiency)/10)*this.requiredHeLi6) {this.HeLevel2 = 0;}
    	}
    	
    	else if (this.HeLevel > 0 && this.Li7Level2 > 0) {
	    	 if (this.HeLevel >= (Math.sqrt(efficiency)/10)*this.requiredHeLi7 && this.Li7Level2 >= (Math.sqrt(efficiency)/10)*this.requiredHeLi7)
	    	{this.heatVar = this.heatHeLi7; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerHeLi7/100), false); this.HeLevel -= (Math.sqrt(efficiency)/10)*this.requiredHeLi7; this.Li7Level2 -= (Math.sqrt(efficiency)/10)*this.requiredHeLi7; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.HeLevel < (Math.sqrt(efficiency)/10)*this.requiredHeLi7) {this.HeLevel = 0;}
	    	 if (this.Li7Level2 < (Math.sqrt(efficiency)/10)*this.requiredHeLi7) {this.Li7Level2 = 0;}
    	}
    	
    	else if (this.Li7Level > 0 && this.HeLevel2 > 0) {
	    	 if (this.Li7Level >= (Math.sqrt(efficiency)/10)*this.requiredHeLi7 && this.HeLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredHeLi7)
	    	{this.heatVar = this.heatHeLi7; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerHeLi7/100), false); this.Li7Level -= (Math.sqrt(efficiency)/10)*this.requiredHeLi7; this.HeLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredHeLi7; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.Li7Level < (Math.sqrt(efficiency)/10)*this.requiredHeLi7) {this.Li7Level = 0;}
	    	 if (this.HeLevel2 < (Math.sqrt(efficiency)/10)*this.requiredHeLi7) {this.HeLevel2 = 0;}
    	}
    	
	    	//
	    	
    	else if (this.BLevel > 0 && this.BLevel2 > 0) {
	    	 if (this.BLevel >= (Math.sqrt(efficiency)/10)*this.requiredBB && this.BLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredBB)
	    	{this.heatVar = this.heatBB; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerBB/100), false); this.BLevel -= (Math.sqrt(efficiency)/10)*this.requiredBB; this.BLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredBB; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.BLevel < (Math.sqrt(efficiency)/10)*this.requiredBB) {this.BLevel = 0;}
	    	 if (this.BLevel2 < (Math.sqrt(efficiency)/10)*this.requiredBB) {this.BLevel2 = 0;}
    	}
    	
    	else if (this.BLevel > 0 && this.Li6Level2 > 0) {
	    	 if (this.BLevel >= (Math.sqrt(efficiency)/10)*this.requiredBLi6 && this.Li6Level2 >= (Math.sqrt(efficiency)/10)*this.requiredBLi6)
	    	{this.heatVar = this.heatBLi6; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerBLi6/100), false); this.BLevel -= (Math.sqrt(efficiency)/10)*this.requiredBLi6; this.Li6Level2 -= (Math.sqrt(efficiency)/10)*this.requiredBLi6; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.BLevel < (Math.sqrt(efficiency)/10)*this.requiredBLi6) {this.BLevel = 0;}
	    	 if (this.Li6Level2 < (Math.sqrt(efficiency)/10)*this.requiredBLi6) {this.Li6Level2 = 0;}
    	}
    	
    	else if (this.Li6Level > 0 && this.BLevel2 > 0) {
	    	 if (this.Li6Level >= (Math.sqrt(efficiency)/10)*this.requiredBLi6 && this.BLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredBLi6)
	    	{this.heatVar = this.heatBLi6; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerBLi6/100), false); this.Li6Level -= (Math.sqrt(efficiency)/10)*this.requiredBLi6; this.BLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredBLi6; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.Li6Level < (Math.sqrt(efficiency)/10)*this.requiredBLi6) {this.Li6Level = 0;}
	    	 if (this.BLevel2 < (Math.sqrt(efficiency)/10)*this.requiredBLi6) {this.BLevel2 = 0;}
    	}
    	
    	else if (this.BLevel > 0 && this.Li7Level2 > 0) {
	    	 if (this.BLevel >= (Math.sqrt(efficiency)/10)*this.requiredBLi7 && this.Li7Level2 >= (Math.sqrt(efficiency)/10)*this.requiredBLi7)
	    	{this.heatVar = this.heatBLi7; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerBLi7/100), false); this.BLevel -= (Math.sqrt(efficiency)/10)*this.requiredBLi7; this.Li7Level2 -= (Math.sqrt(efficiency)/10)*this.requiredBLi7; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.BLevel < (Math.sqrt(efficiency)/10)*this.requiredBLi7) {this.BLevel = 0;}
	    	 if (this.Li7Level2 < (Math.sqrt(efficiency)/10)*this.requiredBLi7) {this.Li7Level2 = 0;}
    	}
    	
    	else if (this.Li7Level > 0 && this.BLevel2 > 0) {
	    	 if (this.Li7Level >= (Math.sqrt(efficiency)/10)*this.requiredBLi7 && this.BLevel2 >= (Math.sqrt(efficiency)/10)*this.requiredBLi7)
	    	{this.heatVar = this.heatBLi7; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerBLi7/100), false); this.Li7Level -= (Math.sqrt(efficiency)/10)*this.requiredBLi7; this.BLevel2 -= (Math.sqrt(efficiency)/10)*this.requiredBLi7; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.Li7Level < (Math.sqrt(efficiency)/10)*this.requiredBLi7) {this.Li7Level = 0;}
	    	 if (this.BLevel2 < (Math.sqrt(efficiency)/10)*this.requiredBLi7) {this.BLevel2 = 0;}
    	}
    	
	    	//
	    	
    	else if (this.Li6Level > 0 && this.Li6Level2 > 0) {
	    	 if (this.Li6Level >= (Math.sqrt(efficiency)/10)*this.requiredLi6Li6 && this.Li6Level2 >= (Math.sqrt(efficiency)/10)*this.requiredLi6Li6)
	    	{this.heatVar = this.heatLi6Li6; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerLi6Li6/100), false); this.Li6Level -= (Math.sqrt(efficiency)/10)*this.requiredLi6Li6; this.Li6Level2 -= (Math.sqrt(efficiency)/10)*this.requiredLi6Li6; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.Li6Level < (Math.sqrt(efficiency)/10)*this.requiredLi6Li6) {this.Li6Level = 0;}
	    	 if (this.Li6Level2 < (Math.sqrt(efficiency)/10)*this.requiredLi6Li6) {this.Li6Level2 = 0;}
    	}
    	
    	else if (this.Li6Level > 0 && this.Li7Level2 > 0) {
	    	 if (this.Li6Level >= (Math.sqrt(efficiency)/10)*this.requiredLi6Li7 && this.Li7Level2 >= (Math.sqrt(efficiency)/10)*this.requiredLi6Li7)
	    	{this.heatVar = this.heatLi6Li7; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerLi6Li7/100), false); this.Li6Level -= (Math.sqrt(efficiency)/10)*this.requiredLi6Li7; this.Li7Level2 -= (Math.sqrt(efficiency)/10)*this.requiredLi6Li7; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.Li6Level < (Math.sqrt(efficiency)/10)*this.requiredLi6Li7) {this.Li6Level = 0;}
	    	 if (this.Li7Level2 < (Math.sqrt(efficiency)/10)*this.requiredLi6Li7) {this.Li7Level2 = 0;}
    	}
    	
    	else if (this.Li7Level > 0 && this.Li6Level2 > 0) {
	    	 if (this.Li7Level >= (Math.sqrt(efficiency)/10)*this.requiredLi6Li7 && this.Li6Level2 >= (Math.sqrt(efficiency)/10)*this.requiredLi6Li7)
	    	{this.heatVar = this.heatLi6Li7; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerLi6Li7/100), false); this.Li7Level -= (Math.sqrt(efficiency)/10)*this.requiredLi6Li7; this.Li6Level2 -= (Math.sqrt(efficiency)/10)*this.requiredLi6Li7; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.Li7Level < (Math.sqrt(efficiency)/10)*this.requiredLi6Li7) {this.Li7Level = 0;}
	    	 if (this.Li6Level2 < (Math.sqrt(efficiency)/10)*this.requiredLi6Li7) {this.Li6Level2 = 0;}
    	}
    	
	    	//
	    	
    	else if (this.Li7Level > 0 && this.Li7Level2 > 0) {
	    	 if (this.Li7Level >= (Math.sqrt(efficiency)/10)*this.requiredLi7Li7 && this.Li7Level2 >= (Math.sqrt(efficiency)/10)*this.requiredLi7Li7)
	    	{this.heatVar = this.heatLi7Li7; this.storage.receiveEnergy((int) (Math.cbrt(efficiency+1)*efficiency*this.powerLi7Li7/100), false); this.Li7Level -= (Math.sqrt(efficiency)/10)*this.requiredLi7Li7; this.Li7Level2 -= (Math.sqrt(efficiency)/10)*this.requiredLi7Li7; heat += (100-(efficiency*(heat/20000)))/2000; flag = true;}
	    	 if (this.Li7Level < (Math.sqrt(efficiency)/10)*this.requiredLi7Li7) {this.Li7Level = 0;}
	    	 if (this.Li7Level2 < (Math.sqrt(efficiency)/10)*this.requiredLi7Li7) {this.Li7Level2 = 0;}
    	}
    	
	    	//
    	
    	else {
    		flag = false;
    		if (heat >= 8 && heat >= (0.0003*heat*Math.log10(heat+1))) {
    			heat = heat-(0.0003*heat*Math.log10(heat+1));
    		}
    	}
    	E = storage.getEnergyStored();
    	if (E != lastE) { BlockFusionReactor.updateBlockState(this.worldObj, this.xCoord, this.yCoord, this.zCoord); }
    	
    	} else {
    		if (heat >= 8 && heat >= (0.0003*heat*Math.log10(heat+1))) {
    			heat = heat-(0.0003*heat*Math.log10(heat+1));
    		}
    	}
    	
    	newE = this.storage.getEnergyStored();
          	EShown = newE-prevE;
          	prevE = newE;
          	
          	if (HLevel + DLevel + TLevel + HeLevel + BLevel + Li6Level + Li7Level == 0 || HLevel2 + DLevel2 + TLevel2 + HeLevel2 + BLevel2 + Li6Level2 + Li7Level2 == 0) {EShown = 0;}
          	
          	if (HLevel + DLevel + TLevel + HeLevel + BLevel + Li6Level + Li7Level <= 0) {HLevel=0; DLevel=0; TLevel=0; HeLevel=0; BLevel=0; Li6Level=0; Li7Level=0;}
          	if (HLevel2 + DLevel2 + TLevel2 + HeLevel2 + BLevel2 + Li6Level2 + Li7Level2 <= 0) {HLevel2=0; DLevel2=0; TLevel2=0; HeLevel2=0; BLevel2=0; Li6Level2=0; Li7Level2=0;}
    }

	private void addEnergy() {
			lastE = storage.getEnergyStored();
			if (heat >=  {
			for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
				for (int x = -1; x < 2; ++x) {
					for (int y = (0 - 2*below); y < (2 + 2*(size-1)); ++y) {
						for (int z = -1; z < 2; ++z) {

							TileEntity tile = this.worldObj.getTileEntity(xCoord + side.offsetX + x, yCoord + side.offsetY + y, zCoord + side.offsetZ + z);

							if (!(tile instanceof TileEntityFissionReactorGraphite) && !(tile instanceof TileEntityReactionGenerator) && !(tile instanceof TileEntityRTG) && !(tile instanceof TileEntityFusionReactor))
							{
								if ((tile instanceof IEnergyHandler)) {
									storage.extractEnergy(((IEnergyHandler)tile).receiveEnergy(side.getOpposite(), storage.extractEnergy(storage.getMaxEnergyStored(), true), false), false);
								}
							}
						}
					}
				}
			}}
			E = storage.getEnergyStored();
			if (E != lastE) {
				BlockFusionReactor.updateBlockState(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
			}
	}

    @SuppressWarnings("unused")
	private boolean canAddEnergy()
    {
        return getMain() != null ? (isMain() ? (this.storage.getEnergyStored() == 0 ? false : this.direction != "none") : getMain().canAddEnergy()) : false;
    }
    
    public String getInventoryName()
	{
		return "Fusion Reactor";
	}

	public boolean isInventoryNameLocalized()
	{
		return false;
	}

    private void fuel1() {
    	if (getMain() != null) {
    	if (isMain()) {
        ItemStack stack = this.getStackInSlot(1);
        if (stack != null && isHFuel(stack) && this.HLevel() + HFuelValue(stack) <= this.Max && this.DLevel() <= 0 && this.TLevel() <= 0 && this.HeLevel() <= 0 && this.BLevel() <= 0 && this.Li6Level() <= 0 && this.Li7Level() <= 0)
        {
            this.addH(fuelValue(stack)); --this.slots[1].stackSize;
            if (this.slots[1].stackSize <= 0) {this.slots[1] = null;}
        }
        else if (stack != null && isDFuel(stack) && this.DLevel() + DFuelValue(stack) <= this.Max && this.HLevel() <= 0 && this.TLevel() <= 0 && this.HeLevel() <= 0 && this.BLevel() <= 0 && this.Li6Level() <= 0 && this.Li7Level() <= 0)
        {
            this.addD(fuelValue(stack)); --this.slots[1].stackSize;
            if (this.slots[1].stackSize <= 0) {this.slots[1] = null;}
        }
        else if (stack != null && isTFuel(stack) && this.TLevel() + TFuelValue(stack) <= this.Max && this.HLevel() <= 0 && this.DLevel() <= 0 && this.HeLevel() <= 0 && this.BLevel() <= 0 && this.Li6Level() <= 0 && this.Li7Level() <= 0)
        {
            this.addT(fuelValue(stack)); --this.slots[1].stackSize;
            if (this.slots[1].stackSize <= 0) {this.slots[1] = null;}
        }
        else if (stack != null && isHeFuel(stack) && this.HeLevel() + HeFuelValue(stack) <= this.Max && this.HLevel() <= 0 && this.DLevel() <= 0 && this.TLevel() <= 0 && this.BLevel() <= 0 && this.Li6Level() <= 0 && this.Li7Level() <= 0)
        {
            this.addHe(fuelValue(stack)); --this.slots[1].stackSize;
            if (this.slots[1].stackSize <= 0) {this.slots[1] = null;}
        }
        else if (stack != null && isBFuel(stack) && this.BLevel() + BFuelValue(stack) <= this.Max && this.HLevel() <= 0 && this.DLevel() <= 0 && this.TLevel() <= 0 && this.HeLevel() <= 0 && this.Li6Level() <= 0 && this.Li7Level() <= 0)
        {
            this.addB(fuelValue(stack)); --this.slots[1].stackSize;
            if (this.slots[1].stackSize <= 0) {this.slots[1] = null;}
        }
        else if (stack != null && isLi6Fuel(stack) && this.Li6Level() + Li6FuelValue(stack) <= this.Max && this.HLevel() <= 0 && this.DLevel() <= 0 && this.TLevel() <= 0 && this.HeLevel() <= 0 && this.BLevel() <= 0 && this.Li7Level() <= 0)
        {
            this.addLi6(fuelValue(stack)); --this.slots[1].stackSize;
            if (this.slots[1].stackSize <= 0) {this.slots[1] = null;}
        }
        else if (stack != null && isLi7Fuel(stack) && this.Li7Level() + Li7FuelValue(stack) <= this.Max && this.HLevel() <= 0 && this.DLevel() <= 0 && this.TLevel() <= 0 && this.HeLevel() <= 0 && this.BLevel() <= 0 && this.Li6Level() <= 0)
        {
            this.addLi7(fuelValue(stack)); --this.slots[1].stackSize;
            if (this.slots[1].stackSize <= 0) {this.slots[1] = null;}
        }
    	} else {
    		getMain().fuel1();
    	}
    	} else {
    		
    	}
    }
    
    private void fuel2() {
    	if (getMain() != null) {
    	if (isMain()) {
        ItemStack stack = this.getStackInSlot(0);
        if (stack != null && isHFuel(stack) && this.HLevel2() + HFuelValue(stack) <= this.Max && this.DLevel2() <= 0 && this.TLevel2() <= 0 && this.HeLevel2() <= 0 && this.BLevel2() <= 0 && this.Li6Level2() <= 0 && this.Li7Level2() <= 0)
        {
            this.addH2(fuelValue(stack)); --this.slots[0].stackSize;
            if (this.slots[0].stackSize <= 0) {this.slots[0] = null;}
        }
        else if (stack != null && isDFuel(stack) && this.DLevel2() + DFuelValue(stack) <= this.Max && this.HLevel2() <= 0 && this.TLevel2() <= 0 && this.HeLevel2() <= 0 && this.BLevel2() <= 0 && this.Li6Level2() <= 0 && this.Li7Level2() <= 0)
        {
            this.addD2(fuelValue(stack)); --this.slots[0].stackSize;
            if (this.slots[0].stackSize <= 0) {this.slots[0] = null;}
        }
        else if (stack != null && isTFuel(stack) && this.TLevel2() + TFuelValue(stack) <= this.Max && this.HLevel2() <= 0 && this.DLevel2() <= 0 && this.HeLevel2() <= 0 && this.BLevel2() <= 0 && this.Li6Level2() <= 0 && this.Li7Level2() <= 0)
        {
            this.addT2(fuelValue(stack)); --this.slots[0].stackSize;
            if (this.slots[0].stackSize <= 0) {this.slots[0] = null;}
        }
        else if (stack != null && isHeFuel(stack) && this.HeLevel2() + HeFuelValue(stack) <= this.Max && this.HLevel2() <= 0 && this.DLevel2() <= 0 && this.TLevel2() <= 0 && this.BLevel2() <= 0 && this.Li6Level2() <= 0 && this.Li7Level2() <= 0)
        {
            this.addHe2(fuelValue(stack)); --this.slots[0].stackSize;
            if (this.slots[0].stackSize <= 0) {this.slots[0] = null;}
        }
        else if (stack != null && isBFuel(stack) && this.BLevel2() + BFuelValue(stack) <= this.Max && this.HLevel2() <= 0 && this.DLevel2() <= 0 && this.TLevel2() <= 0 && this.HeLevel2() <= 0 && this.Li6Level2() <= 0 && this.Li7Level2() <= 0)
        {
            this.addB2(fuelValue(stack)); --this.slots[0].stackSize;
            if (this.slots[0].stackSize <= 0) {this.slots[0] = null;}
        }
        else if (stack != null && isLi6Fuel(stack) && this.Li6Level2() + Li6FuelValue(stack) <= this.Max && this.HLevel2() <= 0 && this.DLevel2() <= 0 && this.TLevel2() <= 0 && this.HeLevel2() <= 0 && this.BLevel2() <= 0 && this.Li7Level2() <= 0)
        {
            this.addLi62(fuelValue(stack)); --this.slots[0].stackSize;
            if (this.slots[0].stackSize <= 0) {this.slots[0] = null;}
        }
        else if (stack != null && isLi7Fuel(stack) && this.Li7Level2() + Li7FuelValue(stack) <= this.Max && this.HLevel2() <= 0 && this.DLevel2() <= 0 && this.TLevel2() <= 0 && this.HeLevel2() <= 0 && this.BLevel2() <= 0 && this.Li6Level2() <= 0)
        {
            this.addLi72(fuelValue(stack)); --this.slots[0].stackSize;
            if (this.slots[0].stackSize <= 0) {this.slots[0] = null;}
        }
    	} else {
    		getMain().fuel2();
    	}
    	} else {
    		
    	}
    }
    
    public static int fuelValue(ItemStack stack)
    {
    	if (stack == null) {return 0;}
    	else {
    		Item i = stack.getItem();
    			if(i == new ItemStack (NRItems.fuel, 1, 36).getItem() && i.getDamage(stack) == 36)
    			{
    				return 336000;
    			}
    			else if(i == new ItemStack (NRItems.fuel, 1, 37).getItem() && i.getDamage(stack) == 37)
    			{
    				return 336000;
    			}
    			else if(i == new ItemStack (NRItems.fuel, 1, 38).getItem() && i.getDamage(stack) == 38)
    			{
    				return 336000;
    			}
    			else if(i == new ItemStack (NRItems.fuel, 1, 39).getItem() && i.getDamage(stack) == 39)
    			{
    				return 336000;
    			}
    			else if(i == new ItemStack (NRItems.fuel, 1, 44).getItem() && i.getDamage(stack) == 44)
    			{
    				return 336000;
    			}
    			else if(i == new ItemStack (NRItems.fuel, 1, 41).getItem() && i.getDamage(stack) == 41)
    			{
    				return 336000;
    			}	
    			else if(i == new ItemStack (NRItems.fuel, 1, 42).getItem() && i.getDamage(stack) == 42)
    			{
    				return 336000;
    			}
        }
        return 0;
    }

    public static boolean isAnyFuel(ItemStack stack)
    {
        return fuelValue(stack) > 0;
    }

    public static int HFuelValue(ItemStack stack) {
    	if (stack == null) {return 0;} else { Item i = stack.getItem();
    		if(i == new ItemStack (NRItems.fuel, 1, 36).getItem() && i.getDamage(stack) == 36) {return 336000;}}
        return 0;
    }
    
    public static int DFuelValue(ItemStack stack) {
    	if (stack == null) {return 0;} else { Item i = stack.getItem();
    		if(i == new ItemStack (NRItems.fuel, 1, 37).getItem() && i.getDamage(stack) == 37) {return 336000;}}
        return 0;
    }
    
    public static int TFuelValue(ItemStack stack) {
    	if (stack == null) {return 0;} else { Item i = stack.getItem();
    		if(i == new ItemStack (NRItems.fuel, 1, 38).getItem() && i.getDamage(stack) == 38) {return 336000;}}
        return 0;
    }
    
    public static int HeFuelValue(ItemStack stack) {
    	if (stack == null) {return 0;} else { Item i = stack.getItem();
    		if(i == new ItemStack (NRItems.fuel, 1, 39).getItem() && i.getDamage(stack) == 39) {return 336000;}}
        return 0;
    }
    
    public static int BFuelValue(ItemStack stack) {
    	if (stack == null) {return 0;} else { Item i = stack.getItem();
    		if(i == new ItemStack (NRItems.fuel, 1, 44).getItem() && i.getDamage(stack) == 44) {return 336000;}}
        return 0;
    }
    
    public static int Li6FuelValue(ItemStack stack) {
    	if (stack == null) {return 0;} else { Item i = stack.getItem();
    		if(i == new ItemStack (NRItems.fuel, 1, 41).getItem() && i.getDamage(stack) == 41) {return 336000;}}
        return 0;
    }
    
    public static int Li7FuelValue(ItemStack stack) {
    	if (stack == null) {return 0;} else { Item i = stack.getItem();
    		if(i == new ItemStack (NRItems.fuel, 1, 42).getItem() && i.getDamage(stack) == 42) {return 336000;}}
        return 0;
    }
    
    public static boolean isHFuel(ItemStack stack) {return HFuelValue(stack) > 0;}
    public static boolean isDFuel(ItemStack stack) {return DFuelValue(stack) > 0;}
    public static boolean isTFuel(ItemStack stack) {return TFuelValue(stack) > 0;}
    public static boolean isHeFuel(ItemStack stack) {return HeFuelValue(stack) > 0;}
    public static boolean isBFuel(ItemStack stack) {return BFuelValue(stack) > 0;}
    public static boolean isLi6Fuel(ItemStack stack) {return Li6FuelValue(stack) > 0;}
    public static boolean isLi7Fuel(ItemStack stack) {return Li7FuelValue(stack) > 0;}

    public void readFromNBT(NBTTagCompound nbt)
    {
        super.readFromNBT(nbt);

        if (nbt.hasKey("storage"))
        {
            this.storage.readFromNBT(nbt.getCompoundTag("storage"));
        }
        this.EShown = nbt.getInteger("EShown");

        this.direction = nbt.getString("facing");
        this.HLevel = nbt.getInteger("HLevel");
        this.DLevel = nbt.getInteger("DLevel");
        this.TLevel = nbt.getInteger("TLevel");
        this.HeLevel = nbt.getInteger("HeLevel");
        this.BLevel = nbt.getInteger("BLevel");
        this.Li6Level = nbt.getInteger("Li6Level");
        this.Li7Level = nbt.getInteger("Li7Level");
        this.HLevel2 = nbt.getInteger("HLevel2");
        this.DLevel2 = nbt.getInteger("DLevel2");
        this.TLevel2 = nbt.getInteger("TLevel2");
        this.HeLevel2 = nbt.getInteger("HeLevel2");
        this.BLevel2 = nbt.getInteger("BLevel2");
        this.Li6Level2 = nbt.getInteger("Li6Level2");
        this.Li7Level2 = nbt.getInteger("Li7Level2");
        
        this.HOut = nbt.getDouble("HOut");
        this.DOut = nbt.getDouble("DOut");
        this.TOut = nbt.getDouble("TOut");
        this.HE3Out = nbt.getDouble("HE3Out");
        this.HE4Out = nbt.getDouble("HE4Out");
        
        this.powerHH = nbt.getInteger("PowerHH");
        this.powerHD = nbt.getInteger("PowerHD");
        this.powerHT = nbt.getInteger("PowerHT");
        this.powerHHe = nbt.getInteger("PowerHHe");
        this.powerHB = nbt.getInteger("PowerHB");
        this.powerHLi6 = nbt.getInteger("PowerHLi6");
        this.powerHLi7 = nbt.getInteger("PowerHLi7");

        this.powerDD = nbt.getInteger("PowerDD");
        this.powerDT = nbt.getInteger("PowerDT");
        this.powerDHe = nbt.getInteger("PowerDHe");
        this.powerDB = nbt.getInteger("PowerDB");
        this.powerDLi6 = nbt.getInteger("PowerDLi6");
        this.powerDLi7 = nbt.getInteger("PowerDLi7");

        this.powerTT = nbt.getInteger("PowerTT");
        this.powerTHe = nbt.getInteger("PowerTHe");
        this.powerTB = nbt.getInteger("PowerTB");
        this.powerTLi6 = nbt.getInteger("PowerTLi6");
        this.powerTLi7 = nbt.getInteger("PowerTLi7");

        this.powerHeHe = nbt.getInteger("PowerHeHe");
        this.powerHeB = nbt.getInteger("PowerHeB");
        this.powerHeLi6 = nbt.getInteger("PowerHeLi6");
        this.powerHeLi7 = nbt.getInteger("PowerHeLi7");
        
        this.powerBB = nbt.getInteger("PowerBB");
        this.powerBLi6 = nbt.getInteger("PowerBLi6");
        this.powerBLi7 = nbt.getInteger("PowerBLi7");

        this.powerLi6Li6 = nbt.getInteger("PowerLi6Li6");
        this.powerLi6Li7 = nbt.getInteger("PowerLi6Li7");
        
        this.powerLi7Li7 = nbt.getInteger("PowerLi7Li7");
        
        this.size = nbt.getInteger("size");
        this.isMain = nbt.getBoolean("isMain");
        this.below = nbt.getInteger("below");
        this.pMult = nbt.getInteger("pMult");
        
        this.efficiency = nbt.getDouble("efficiency");
        this.heat = nbt.getDouble("heat");
        this.heatVar = nbt.getDouble("heatVar");
        
        this.flag = nbt.getBoolean("flag");
        this.flag1 = nbt.getBoolean("flag1");
        this.lastE = nbt.getInteger("lE");
        this.E = nbt.getInteger("E");
        
        NBTTagList list = nbt.getTagList("Items", 10);
        this.slots = new ItemStack[this.getSizeInventory()];

        for (int i = 0; i < list.tagCount(); ++i)
        {
            NBTTagCompound compound = list.getCompoundTagAt(i);
            byte b = compound.getByte("Slot");

            if (b >= 0 && b < this.slots.length)
            {
                this.slots[b] = ItemStack.loadItemStackFromNBT(compound);
            }
        }
    }

    public void writeToNBT(NBTTagCompound nbt)
    {
        super.writeToNBT(nbt);
        
        NBTTagCompound energyTag = new NBTTagCompound();
        this.storage.writeToNBT(energyTag);
        nbt.setTag("storage", energyTag);
        nbt.setInteger("EShown", this.EShown);
        
        nbt.setInteger("HLevel", this.HLevel);
        nbt.setInteger("DLevel", this.DLevel);
        nbt.setInteger("TLevel", this.TLevel);
        nbt.setInteger("HeLevel", this.HeLevel);
        nbt.setInteger("BLevel", this.BLevel);
        nbt.setInteger("Li6Level", this.Li6Level);
        nbt.setInteger("Li7Level", this.Li7Level);
        nbt.setInteger("HLevel2", this.HLevel2);
        nbt.setInteger("DLevel2", this.DLevel2);
        nbt.setInteger("TLevel2", this.TLevel2);
        nbt.setInteger("HeLevel2", this.HeLevel2);
        nbt.setInteger("BLevel2", this.BLevel2);
        nbt.setInteger("Li6Level2", this.Li6Level2);
        nbt.setInteger("Li7Level2", this.Li7Level2);
        
        nbt.setDouble("HOut", this.HOut);
        nbt.setDouble("DOut", this.DOut);
        nbt.setDouble("TOut", this.TOut);
        nbt.setDouble("HE3Out", this.HE3Out);
        nbt.setDouble("HE4Out", this.HE4Out);
        
        nbt.setInteger("PowerHH", this.powerHH);
        nbt.setInteger("PowerHD", this.powerHD);
        nbt.setInteger("PowerHT", this.powerHT);
        nbt.setInteger("PowerHHe", this.powerHHe);
        nbt.setInteger("PowerHB", this.powerHB);
        nbt.setInteger("PowerHLi6", this.powerHLi6);
        nbt.setInteger("PowerHLi7", this.powerHLi7);

        nbt.setInteger("PowerDD", this.powerDD);
        nbt.setInteger("PowerDT", this.powerDT);
        nbt.setInteger("PowerDHe", this.powerDHe);
        nbt.setInteger("PowerDB", this.powerDB);
        nbt.setInteger("PowerDLi6", this.powerDLi6);
        nbt.setInteger("PowerDLi7", this.powerDLi7);

        nbt.setInteger("PowerTT", this.powerTT);
        nbt.setInteger("PowerTHe", this.powerTHe);
        nbt.setInteger("PowerTB", this.powerTB);
        nbt.setInteger("PowerTLi6", this.powerTLi6);
        nbt.setInteger("PowerTLi7", this.powerTLi7);

        nbt.setInteger("PowerHeHe", this.powerHeHe);
        nbt.setInteger("PowerHeB", this.powerHeB);
        nbt.setInteger("PowerHeLi6", this.powerHeLi6);
        nbt.setInteger("PowerHeLi7", this.powerHeLi7);
        
        nbt.setInteger("PowerBB", this.powerBB);
        nbt.setInteger("PowerBLi6", this.powerBLi6);
        nbt.setInteger("PowerBLi7", this.powerBLi7);

        nbt.setInteger("PowerLi6Li6", this.powerLi6Li6);
        nbt.setInteger("PowerLi6Li7", this.powerLi6Li7);
        
        nbt.setInteger("PowerLi7Li7", this.powerLi7Li7);
        
        nbt.setInteger("size", this.size);
        nbt.setBoolean("isMain", this.isMain);
        nbt.setInteger("below", this.below);
        nbt.setInteger("pMult", this.pMult);
        
        nbt.setDouble("efficiency", this.efficiency);
        nbt.setDouble("heat", this.heat);
        nbt.setDouble("heatVar", this.heatVar);
        
        nbt.setBoolean("flag", this.flag);
        nbt.setBoolean("flag1", this.flag1);
        nbt.setInteger("lE", this.lastE);
        nbt.setInteger("E", this.E);
        NBTTagList list = new NBTTagList();

        for (int i = 0; i < this.slots.length; ++i)
        {
            if (this.slots[i] != null)
            {
                NBTTagCompound compound = new NBTTagCompound();
                compound.setByte("Slot", (byte)i);
                this.slots[i].writeToNBT(compound);
                list.appendTag(compound);
            }
        }

        nbt.setTag("Items", list);
        
        if(this.isInventoryNameLocalized())
		{
			nbt.setString("CustomName", this.localizedName);
		}
    }

    /**
     * Overriden in a sign to provide the text.
     */
    public Packet getDescriptionPacket()
    {
        NBTTagCompound nbtTag = new NBTTagCompound();
        nbtTag.setInteger("Energy", this.storage.getEnergyStored());
        this.energy = nbtTag.getInteger("Energy");
        this.writeToNBT(nbtTag);
        return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbtTag);
    }

    public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet)
    {
    	super.onDataPacket(net, packet);
        this.readFromNBT(packet.func_148857_g());
    }

    public void addH(int add) {if (isMain()) {this.HLevel += add;} else {getMain().addH(add);}}
    public void addD(int add) {if (isMain()) {this.DLevel += add;} else {getMain().addD(add);}}
    public void addT(int add) {if (isMain()) {this.TLevel += add;} else {getMain().addT(add);}}
    public void addHe(int add) {if (isMain()) {this.HeLevel += add;} else {getMain().addHe(add);}}
    public void addB(int add) {if (isMain()) {this.BLevel += add;} else {getMain().addB(add);}}
    public void addLi6(int add) {if (isMain()) {this.Li6Level += add;} else {getMain().addLi6(add);}}
    public void addLi7(int add) {if (isMain()) {this.Li7Level += add;} else {getMain().addLi7(add);}}
    
    public void addH2(int add) {if (isMain()) {this.HLevel2 += add;} else {getMain().addH2(add);}}
    public void addD2(int add) {if (isMain()) {this.DLevel2 += add;} else {getMain().addD2(add);}}
    public void addT2(int add) {if (isMain()) {this.TLevel2 += add;} else {getMain().addT2(add);}}
    public void addHe2(int add) {if (isMain()) {this.HeLevel2 += add;} else {getMain().addHe2(add);}}
    public void addB2(int add) {if (isMain()) {this.BLevel2 += add;} else {getMain().addB2(add);}}
    public void addLi62(int add) {if (isMain()) {this.Li6Level2 += add;} else {getMain().addLi62(add);}}
    public void addLi72(int add) {if (isMain()) {this.Li7Level2 += add;} else {getMain().addLi72(add);}}
    
    public void removeH(int remove) {if (isMain()) {this.HLevel -= remove;} else {getMain().removeH(remove);}}
    public void removeD(int remove) {if (isMain()) {this.DLevel -= remove;} else {getMain().removeD(remove);}}
    public void removeT(int remove) {if (isMain()) {this.TLevel -= remove;} else {getMain().removeT(remove);}}
    public void removeHe(int remove) {if (isMain()) {this.HeLevel -= remove;} else {getMain().removeHe(remove);}}
    public void removeB(int remove) {if (isMain()) {this.BLevel -= remove;} else {getMain().removeB(remove);}}
    public void removeLi6(int remove) {if (isMain()) {this.Li6Level -= remove;} else {getMain().removeLi6(remove);}}
    public void removeLi7(int remove) {if (isMain()) {this.Li7Level -= remove;} else {getMain().removeLi7(remove);}}
    
    public void removeH2(int remove) {if (isMain()) {this.HLevel2 -= remove;} else {getMain().removeH2(remove);}}
    public void removeD2(int remove) {if (isMain()) {this.DLevel2 -= remove;} else {getMain().removeD2(remove);}}
    public void removeT2(int remove) {if (isMain()) {this.TLevel2 -= remove;} else {getMain().removeT2(remove);}}
    public void removeHe2(int remove) {if (isMain()) {this.HeLevel2 -= remove;} else {getMain().removeHe2(remove);}}
    public void removeB2(int remove) {if (isMain()) {this.BLevel2 -= remove;} else {getMain().removeB2(remove);}}
    public void removeLi62(int remove) {if (isMain()) {this.Li6Level2 -= remove;} else {getMain().removeLi62(remove);}}
    public void removeLi72(int remove) {if (isMain()) {this.Li7Level2 -= remove;} else {getMain().removeLi72(remove);}}
    
    public int HLevel() {if (isMain()) {return HLevel;} else {getMain().HLevel();} return HLevel;}
    public int DLevel() {if (isMain()) {return DLevel;} else {getMain().DLevel();} return DLevel;}
    public int TLevel() {if (isMain()) {return TLevel;} else {getMain().TLevel();} return TLevel;}
    public int HeLevel() {if (isMain()) {return HeLevel;} else {getMain().HeLevel();} return HeLevel;}
    public int BLevel() {if (isMain()) {return BLevel;} else {getMain().BLevel();} return BLevel;}
    public int Li6Level() {if (isMain()) {return Li6Level;} else {getMain().Li6Level();} return Li6Level;}
    public int Li7Level() {if (isMain()) {return Li7Level;} else {getMain().Li7Level();} return Li7Level;}
    
    public int HLevel2() {if (isMain()) {return HLevel2;} else {getMain().HLevel2();} return HLevel2;}
    public int DLevel2() {if (isMain()) {return DLevel2;} else {getMain().DLevel2();} return DLevel2;}
    public int TLevel2() {if (isMain()) {return TLevel2;} else {getMain().TLevel2();} return TLevel2;}
    public int HeLevel2() {if (isMain()) {return HeLevel2;} else {getMain().HeLevel2();} return HeLevel2;}
    public int BLevel2() {if (isMain()) {return BLevel2;} else {getMain().BLevel2();} return BLevel2;}
    public int Li6Level2() {if (isMain()) {return Li6Level2;} else {getMain().Li6Level2();} return Li6Level2;}
    public int Li7Level2() {if (isMain()) {return Li7Level2;} else {getMain().Li7Level2();} return Li7Level2;}
    
    public boolean canConnectEnergy(ForgeDirection from)
    {
        return true;
    }

    public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate)
    {
    	if (heat <  {
    		return getMain() != null ? (isMain() ? this.storage.receiveEnergy(maxReceive, simulate) : getMain().storage.receiveEnergy(maxReceive, simulate)) : 0;
    	}
    	else return 0;
    }

    public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate)
    {
    	return 0;
    }

    public int getEnergyStored(ForgeDirection paramForgeDirection)
    {
        return getMain() != null ? (isMain() ? this.storage.getEnergyStored() : getMain().getEnergyStored(paramForgeDirection)) : 0;
    }

    public int getMaxEnergyStored(ForgeDirection paramForgeDirection)
    {
        return getMain() != null ? (isMain() ? this.storage.getMaxEnergyStored() : getMain().getMaxEnergyStored(paramForgeDirection)) : 0;
    }

    /**
     * Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot.
     */
    public boolean isItemValidForSlot(int slot, ItemStack stack)
    {
        if (slot == 0)
        {
            isAnyFuel(stack);
            return true;
        }
        else if (slot == 1)
        {
        	isAnyFuel(stack);
            return true;
        }
        else
        {
            return false;
        }
    }

    /**
     * Returns an array containing the indices of the slots that can be accessed by automation on the given side of this
     * block.
     */
    public int[] getAccessibleSlotsFromSide(int slot) {
        return getMain() != null ? (isMain() ? slotsBottom : getMain().getAccessibleSlotsFromSide(slot)) : null;
    }

    /**
     * Returns true if automation can insert the given item in the given slot from the given side. Args: Slot, item,
     * side
     */
    public boolean canInsertItem(int slot, ItemStack stack, int par) {
    	return getMain() != null ? (isMain() ? this.isItemValidForSlot(slot, stack) : getMain().canInsertItem(slot, stack, par)) : false;
    }

    /**
     * Returns true if automation can extract the given item in the given slot from the given side. Args: Slot, item,
     * side
     */
    public boolean canExtractItem(int slot, ItemStack stack, int slots) {
        return getMain() != null ? (isMain() ? (slots != 0 || slot != 1 || stack.getItem() == Items.bucket) : getMain().canExtractItem(slot, stack, slots)) : false;
    }

    public ItemStack getStackInSlot(int var1) {
    	return getMain() != null ? (isMain() ? slots[var1] : getMain().slots[var1]) : null;
	}
    
    public int getSizeInventory()
    {
        return getMain() != null ? (isMain() ? this.slots.length : getMain().getSizeInventory()) : null;
    }
    
    public void setInventorySlotContents(int i, ItemStack itemstack)
    {
    	if (getMain() != null) {
    	if (isMain()) {
        this.slots[i] = itemstack;

        if (itemstack != null && itemstack.stackSize > this.getInventoryStackLimit())
        {
            itemstack.stackSize = this.getInventoryStackLimit();
        } markDirty();
    	} else {
    		getMain().setInventorySlotContents(i, itemstack);
    	}
    	} else {
    		
    	}
    }
}

 

Any help would be appreciated - thanks in advance ;)

Posted

This is a lot of code so I wont be reading all of it..

So just some common mistakes, maybe urs is in here.

1. Did you double check ur write and read NBT methods?

2. Are u syncing server and client? I guess u are seeing the "0" values in a gui, which might be the case because the client isnt synced with the server (welcome to the world of packets)

Posted

Yeh, sorry that is a lot of code. Perhaps having only the NBT related methods will help:

 

public void readFromNBT(NBTTagCompound nbt)
    {
        super.readFromNBT(nbt);

        if (nbt.hasKey("storage"))
        {
            this.storage.readFromNBT(nbt.getCompoundTag("storage"));
        }
        this.EShown = nbt.getInteger("EShown");

        this.direction = nbt.getString("facing");
        this.HLevel = nbt.getInteger("HLevel");
        this.DLevel = nbt.getInteger("DLevel");
        this.TLevel = nbt.getInteger("TLevel");
        this.HeLevel = nbt.getInteger("HeLevel");
        this.BLevel = nbt.getInteger("BLevel");
        this.Li6Level = nbt.getInteger("Li6Level");
        this.Li7Level = nbt.getInteger("Li7Level");
        this.HLevel2 = nbt.getInteger("HLevel2");
        this.DLevel2 = nbt.getInteger("DLevel2");
        this.TLevel2 = nbt.getInteger("TLevel2");
        this.HeLevel2 = nbt.getInteger("HeLevel2");
        this.BLevel2 = nbt.getInteger("BLevel2");
        this.Li6Level2 = nbt.getInteger("Li6Level2");
        this.Li7Level2 = nbt.getInteger("Li7Level2");
        
        this.HOut = nbt.getDouble("HOut");
        this.DOut = nbt.getDouble("DOut");
        this.TOut = nbt.getDouble("TOut");
        this.HE3Out = nbt.getDouble("HE3Out");
        this.HE4Out = nbt.getDouble("HE4Out");
        
        this.powerHH = nbt.getInteger("PowerHH");
        this.powerHD = nbt.getInteger("PowerHD");
        this.powerHT = nbt.getInteger("PowerHT");
        this.powerHHe = nbt.getInteger("PowerHHe");
        this.powerHB = nbt.getInteger("PowerHB");
        this.powerHLi6 = nbt.getInteger("PowerHLi6");
        this.powerHLi7 = nbt.getInteger("PowerHLi7");

        this.powerDD = nbt.getInteger("PowerDD");
        this.powerDT = nbt.getInteger("PowerDT");
        this.powerDHe = nbt.getInteger("PowerDHe");
        this.powerDB = nbt.getInteger("PowerDB");
        this.powerDLi6 = nbt.getInteger("PowerDLi6");
        this.powerDLi7 = nbt.getInteger("PowerDLi7");

        this.powerTT = nbt.getInteger("PowerTT");
        this.powerTHe = nbt.getInteger("PowerTHe");
        this.powerTB = nbt.getInteger("PowerTB");
        this.powerTLi6 = nbt.getInteger("PowerTLi6");
        this.powerTLi7 = nbt.getInteger("PowerTLi7");

        this.powerHeHe = nbt.getInteger("PowerHeHe");
        this.powerHeB = nbt.getInteger("PowerHeB");
        this.powerHeLi6 = nbt.getInteger("PowerHeLi6");
        this.powerHeLi7 = nbt.getInteger("PowerHeLi7");
        
        this.powerBB = nbt.getInteger("PowerBB");
        this.powerBLi6 = nbt.getInteger("PowerBLi6");
        this.powerBLi7 = nbt.getInteger("PowerBLi7");

        this.powerLi6Li6 = nbt.getInteger("PowerLi6Li6");
        this.powerLi6Li7 = nbt.getInteger("PowerLi6Li7");
        
        this.powerLi7Li7 = nbt.getInteger("PowerLi7Li7");
        
        this.size = nbt.getInteger("size");
        this.isMain = nbt.getBoolean("isMain");
        this.below = nbt.getInteger("below");
        this.pMult = nbt.getInteger("pMult");
        
        this.efficiency = nbt.getDouble("efficiency");
        this.heat = nbt.getDouble("heat");
        this.heatVar = nbt.getDouble("heatVar");
        
        this.flag = nbt.getBoolean("flag");
        this.flag1 = nbt.getBoolean("flag1");
        this.lastE = nbt.getInteger("lE");
        this.E = nbt.getInteger("E");
        
        NBTTagList list = nbt.getTagList("Items", 10);
        this.slots = new ItemStack[this.getSizeInventory()];

        for (int i = 0; i < list.tagCount(); ++i)
        {
            NBTTagCompound compound = list.getCompoundTagAt(i);
            byte b = compound.getByte("Slot");

            if (b >= 0 && b < this.slots.length)
            {
                this.slots[b] = ItemStack.loadItemStackFromNBT(compound);
            }
        }
    }

    public void writeToNBT(NBTTagCompound nbt)
    {
        super.writeToNBT(nbt);
        
        NBTTagCompound energyTag = new NBTTagCompound();
        this.storage.writeToNBT(energyTag);
        nbt.setTag("storage", energyTag);
        nbt.setInteger("EShown", this.EShown);
        
        nbt.setInteger("HLevel", this.HLevel);
        nbt.setInteger("DLevel", this.DLevel);
        nbt.setInteger("TLevel", this.TLevel);
        nbt.setInteger("HeLevel", this.HeLevel);
        nbt.setInteger("BLevel", this.BLevel);
        nbt.setInteger("Li6Level", this.Li6Level);
        nbt.setInteger("Li7Level", this.Li7Level);
        nbt.setInteger("HLevel2", this.HLevel2);
        nbt.setInteger("DLevel2", this.DLevel2);
        nbt.setInteger("TLevel2", this.TLevel2);
        nbt.setInteger("HeLevel2", this.HeLevel2);
        nbt.setInteger("BLevel2", this.BLevel2);
        nbt.setInteger("Li6Level2", this.Li6Level2);
        nbt.setInteger("Li7Level2", this.Li7Level2);
        
        nbt.setDouble("HOut", this.HOut);
        nbt.setDouble("DOut", this.DOut);
        nbt.setDouble("TOut", this.TOut);
        nbt.setDouble("HE3Out", this.HE3Out);
        nbt.setDouble("HE4Out", this.HE4Out);
        
        nbt.setInteger("PowerHH", this.powerHH);
        nbt.setInteger("PowerHD", this.powerHD);
        nbt.setInteger("PowerHT", this.powerHT);
        nbt.setInteger("PowerHHe", this.powerHHe);
        nbt.setInteger("PowerHB", this.powerHB);
        nbt.setInteger("PowerHLi6", this.powerHLi6);
        nbt.setInteger("PowerHLi7", this.powerHLi7);

        nbt.setInteger("PowerDD", this.powerDD);
        nbt.setInteger("PowerDT", this.powerDT);
        nbt.setInteger("PowerDHe", this.powerDHe);
        nbt.setInteger("PowerDB", this.powerDB);
        nbt.setInteger("PowerDLi6", this.powerDLi6);
        nbt.setInteger("PowerDLi7", this.powerDLi7);

        nbt.setInteger("PowerTT", this.powerTT);
        nbt.setInteger("PowerTHe", this.powerTHe);
        nbt.setInteger("PowerTB", this.powerTB);
        nbt.setInteger("PowerTLi6", this.powerTLi6);
        nbt.setInteger("PowerTLi7", this.powerTLi7);

        nbt.setInteger("PowerHeHe", this.powerHeHe);
        nbt.setInteger("PowerHeB", this.powerHeB);
        nbt.setInteger("PowerHeLi6", this.powerHeLi6);
        nbt.setInteger("PowerHeLi7", this.powerHeLi7);
        
        nbt.setInteger("PowerBB", this.powerBB);
        nbt.setInteger("PowerBLi6", this.powerBLi6);
        nbt.setInteger("PowerBLi7", this.powerBLi7);

        nbt.setInteger("PowerLi6Li6", this.powerLi6Li6);
        nbt.setInteger("PowerLi6Li7", this.powerLi6Li7);
        
        nbt.setInteger("PowerLi7Li7", this.powerLi7Li7);
        
        nbt.setInteger("size", this.size);
        nbt.setBoolean("isMain", this.isMain);
        nbt.setInteger("below", this.below);
        nbt.setInteger("pMult", this.pMult);
        
        nbt.setDouble("efficiency", this.efficiency);
        nbt.setDouble("heat", this.heat);
        nbt.setDouble("heatVar", this.heatVar);
        
        nbt.setBoolean("flag", this.flag);
        nbt.setBoolean("flag1", this.flag1);
        nbt.setInteger("lE", this.lastE);
        nbt.setInteger("E", this.E);
        NBTTagList list = new NBTTagList();

        for (int i = 0; i < this.slots.length; ++i)
        {
            if (this.slots[i] != null)
            {
                NBTTagCompound compound = new NBTTagCompound();
                compound.setByte("Slot", (byte)i);
                this.slots[i].writeToNBT(compound);
                list.appendTag(compound);
            }
        }

        nbt.setTag("Items", list);
        
        if(this.isInventoryNameLocalized())
		{
			nbt.setString("CustomName", this.localizedName);
		}
    }

    public Packet getDescriptionPacket()
    {
        NBTTagCompound nbtTag = new NBTTagCompound();
        nbtTag.setInteger("Energy", this.storage.getEnergyStored());
        this.energy = nbtTag.getInteger("Energy");
        this.writeToNBT(nbtTag);
        return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbtTag);
    }

    public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet)
    {
    	super.onDataPacket(net, packet);
        this.readFromNBT(packet.func_148857_g());
    }

 

Otherwise,

1. I'm using the same NBT-related code as I am for other machines, and they work, and

2. I believe they are synced, yes

Posted

My only thought is that there is something wrong with methods such as these:

 

public ItemStack getStackInSlot(int var1) {
    	return getMain() != null ? (isMain() ? slots[var1] : getMain().slots[var1]) : null;
	}

 

public int getEnergyStored(ForgeDirection paramForgeDirection) {
        return getMain() != null ? (isMain() ? this.storage.getEnergyStored() : getMain().getEnergyStored(paramForgeDirection)) : 0;
    }

 

If so, then there may be an issue with this method:

public TileEntityFusionReactor getMain() {
    	if (below != 0) {
    		TileEntityFusionReactor main = (TileEntityFusionReactor)worldObj.getTileEntity(xCoord, yCoord - 2*below, zCoord);
    		return main;
    	} else {
    		return (TileEntityFusionReactor)worldObj.getTileEntity(xCoord, yCoord, zCoord);
    	}
    }

 

This is the method which sets the 'below' integer:

public void getBelow(World world, int x, int y, int z) {
		below = 0;
		for (int yDown = 1; yDown < 128; ++yDown) {
			if (world.getBlock(x, y - 2*yDown, z) == NRBlocks.fusionReactor) {
				below++;
			} else break;
		}
	}

Posted

This is what I have for that:

 

public Packet getDescriptionPacket()
    {
        NBTTagCompound nbtTag = new NBTTagCompound();
        nbtTag.setInteger("Energy", this.storage.getEnergyStored());
        this.energy = nbtTag.getInteger("Energy");
        this.writeToNBT(nbtTag);
        return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbtTag);
    }

    public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet)
    {
    	super.onDataPacket(net, packet);
        this.readFromNBT(packet.func_148857_g());
    }

 

Is there a problem in either of those methods? It must be the fact that it is a multiblock that this bug exists, as all of my other machines load their inventories, energy, etc. fine.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Version 1.19 - Forge 41.0.63 I want to create a wolf entity that I can ride, so far it seems to be working, but the problem is that when I get on the wolf, I can’t control it. I then discovered that the issue is that the server doesn’t detect that I’m riding the wolf, so I’m struggling with synchronization. However, it seems to not be working properly. As I understand it, the server receives the packet but doesn’t register it correctly. I’m a bit new to Java, and I’ll try to provide all the relevant code and prints *The comments and prints are translated by chatgpt since they were originally in Spanish* Thank you very much in advance No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. MountableWolfEntity package com.vals.valscraft.entity; import com.vals.valscraft.network.MountSyncPacket; import com.vals.valscraft.network.NetworkHandler; import net.minecraft.client.Minecraft; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.animal.Wolf; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.Entity; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.network.PacketDistributor; public class MountableWolfEntity extends Wolf { private boolean hasSaddle; private static final EntityDataAccessor<Byte> DATA_ID_FLAGS = SynchedEntityData.defineId(MountableWolfEntity.class, EntityDataSerializers.BYTE); public MountableWolfEntity(EntityType<? extends Wolf> type, Level level) { super(type, level); this.hasSaddle = false; } @Override protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(DATA_ID_FLAGS, (byte)0); } public static AttributeSupplier.Builder createAttributes() { return Wolf.createAttributes() .add(Attributes.MAX_HEALTH, 20.0) .add(Attributes.MOVEMENT_SPEED, 0.3); } @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(hand); if (itemstack.getItem() == Items.SADDLE && !this.hasSaddle()) { if (!player.isCreative()) { itemstack.shrink(1); } this.setSaddle(true); return InteractionResult.SUCCESS; } else if (!level.isClientSide && this.hasSaddle()) { player.startRiding(this); MountSyncPacket packet = new MountSyncPacket(true); // 'true' means the player is mounted NetworkHandler.CHANNEL.sendToServer(packet); // Ensure the server handles the packet return InteractionResult.SUCCESS; } return InteractionResult.PASS; } @Override public void travel(Vec3 travelVector) { if (this.isVehicle() && this.getControllingPassenger() instanceof Player) { System.out.println("The wolf has a passenger."); System.out.println("The passenger is a player."); Player player = (Player) this.getControllingPassenger(); // Ensure the player is the controller this.setYRot(player.getYRot()); this.yRotO = this.getYRot(); this.setXRot(player.getXRot() * 0.5F); this.setRot(this.getYRot(), this.getXRot()); this.yBodyRot = this.getYRot(); this.yHeadRot = this.yBodyRot; float forward = player.zza; float strafe = player.xxa; if (forward <= 0.0F) { forward *= 0.25F; } this.flyingSpeed = this.getSpeed() * 0.1F; this.setSpeed((float) this.getAttributeValue(Attributes.MOVEMENT_SPEED) * 1.5F); this.setDeltaMovement(new Vec3(strafe, travelVector.y, forward).scale(this.getSpeed())); this.calculateEntityAnimation(this, false); } else { // The wolf does not have a passenger or the passenger is not a player System.out.println("No player is mounted, or the passenger is not a player."); super.travel(travelVector); } } public boolean hasSaddle() { return this.hasSaddle; } public void setSaddle(boolean hasSaddle) { this.hasSaddle = hasSaddle; } @Override protected void dropEquipment() { super.dropEquipment(); if (this.hasSaddle()) { this.spawnAtLocation(Items.SADDLE); this.setSaddle(false); } } @SubscribeEvent public static void onServerTick(TickEvent.ServerTickEvent event) { if (event.phase == TickEvent.Phase.START) { MinecraftServer server = net.minecraftforge.server.ServerLifecycleHooks.getCurrentServer(); if (server != null) { for (ServerPlayer player : server.getPlayerList().getPlayers()) { if (player.isPassenger() && player.getVehicle() instanceof MountableWolfEntity) { MountableWolfEntity wolf = (MountableWolfEntity) player.getVehicle(); System.out.println("Tick: " + player.getName().getString() + " is correctly mounted on " + wolf); } } } } } private boolean lastMountedState = false; @Override public void tick() { super.tick(); if (!this.level.isClientSide) { // Only on the server boolean isMounted = this.isVehicle() && this.getControllingPassenger() instanceof Player; // Only print if the state changed if (isMounted != lastMountedState) { if (isMounted) { Player player = (Player) this.getControllingPassenger(); // Verify the passenger is a player System.out.println("Server: Player " + player.getName().getString() + " is now mounted."); } else { System.out.println("Server: The wolf no longer has a passenger."); } lastMountedState = isMounted; } } } @Override public void addPassenger(Entity passenger) { super.addPassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(true)); } } } @Override public void removePassenger(Entity passenger) { super.removePassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is no longer mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(false)); } } } @Override public boolean isControlledByLocalInstance() { Entity entity = this.getControllingPassenger(); return entity instanceof Player; } @Override public void positionRider(Entity passenger) { if (this.hasPassenger(passenger)) { double xOffset = Math.cos(Math.toRadians(this.getYRot() + 90)) * 0.4; double zOffset = Math.sin(Math.toRadians(this.getYRot() + 90)) * 0.4; passenger.setPos(this.getX() + xOffset, this.getY() + this.getPassengersRidingOffset() + passenger.getMyRidingOffset(), this.getZ() + zOffset); } } } MountSyncPacket package com.vals.valscraft.network; import com.vals.valscraft.entity.MountableWolfEntity; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class MountSyncPacket { private final boolean isMounted; public MountSyncPacket(boolean isMounted) { this.isMounted = isMounted; } public void encode(FriendlyByteBuf buffer) { buffer.writeBoolean(isMounted); } public static MountSyncPacket decode(FriendlyByteBuf buffer) { return new MountSyncPacket(buffer.readBoolean()); } public void handle(NetworkEvent.Context context) { context.enqueueWork(() -> { ServerPlayer player = context.getSender(); // Get the player from the context if (player != null) { // Verifies if the player has dismounted if (!isMounted) { Entity vehicle = player.getVehicle(); if (vehicle instanceof MountableWolfEntity wolf) { // Logic to remove the player as a passenger wolf.removePassenger(player); System.out.println("Server: Player " + player.getName().getString() + " is no longer mounted."); } } } }); context.setPacketHandled(true); // Marks the packet as handled } } networkHandler package com.vals.valscraft.network; import com.vals.valscraft.valscraft; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.network.NetworkRegistry; import net.minecraftforge.network.simple.SimpleChannel; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class NetworkHandler { private static final String PROTOCOL_VERSION = "1"; public static final SimpleChannel CHANNEL = NetworkRegistry.newSimpleChannel( new ResourceLocation(valscraft.MODID, "main"), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals ); public static void init() { int packetId = 0; // Register the mount synchronization packet CHANNEL.registerMessage( packetId++, MountSyncPacket.class, MountSyncPacket::encode, MountSyncPacket::decode, (msg, context) -> msg.handle(context.get()) // Get the context with context.get() ); } }  
    • Do you use features of inventory profiles next (ipnext) or is there a change without it?
    • Remove rubidium - you are already using embeddium, which is a fork of rubidium
  • Topics

×
×
  • Create New...

Important Information

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