Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hey there,

 

I've been making a mod for the past month or so, and have recently, with a friend, been going through previous code to clean it up, prevent unnecessary lag etc. However, I have 2 small but annoying problems with a nuclear fission reactor which takes a fuel cell, runs a cycle until the fuel runs out, then leaves behind the depleted cell. The first problem is that the fuel level seems to flicker when I put fuel in, (an updating issue I guess), and the other problem is that a 'ghost' image of the depleted fuel cell appears straight after I put the original fuel cell in (clicking on the depleted cell or re-entering the GUI gets rid of it).

 

Tile Entity class:

package com.nr.mod.blocks.tileentities;

import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
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 cofh.lib.util.helpers.BlockHelper;
import cofh.lib.util.helpers.EnergyHelper;

import com.nr.mod.NuclearRelativistics;
import com.nr.mod.blocks.NRBlocks;
import com.nr.mod.handlers.BombType;
import com.nr.mod.handlers.EntityBomb;
import com.nr.mod.handlers.NRExplosion;
import com.nr.mod.items.NRItems;

public class TileEntityFissionReactorGraphite extends TileEntityInventory implements IEnergyHandler, IEnergyConnection, ISidedInventory, IEnergyReceiver
{
    public EnergyStorage storage = new EnergyStorage(1000000, 1000000);
    
    public int rawR = 1;
    
    public int R = rawR; 
    
    public int D = R*2 + 1;
    public int SR = R-1; 
    public int SD = SR*2 + 1;
    
    public boolean flag;
    public boolean flag1 = false;
    
    public int E;
    public int H;
    public int energy;
    public int fueltime;
public int fueltype;
    public int power = NuclearRelativistics.fissionRF/25;
    public int heat;
    public String typeoffuel = "No Fuel";
    public int fuelmult;
    public int MBNumber;
    public String problem = "Casing Incomplete";
    
    public int maxTransfer = 500000;
    public String direction;
    private static final int[] slotsTop = new int[] {0};
    private static final int[] slotsSides = new int[] {1};

    public TileEntityFissionReactorGraphite()
    {
        super.slots = new ItemStack[3];
        super.localizedName = "Fission Reactor";
    }

    public void updateEntity()
    {
    	super.updateEntity();
    	product();
    	fuel();
        upgrade();
        energy();
        overheat(worldObj, this.xCoord, this.yCoord, this.zCoord, 25F, BombType.BOMB_STANDARD);
        typeoffuelx();
        addEnergy();
        if (flag != flag1) { flag1 = flag; BlockFissionReactorGraphite.updateFissionReactorGraphiteBlockState(flag, this.worldObj, this.xCoord, this.yCoord, this.zCoord); }
    	markDirty();
    }
    
    public void overheat(World world, double x, double y, double z, float radius, BombType type)
    {
    	if (this.heat >= 500000)
    	{
    		if (this.MBNumber == 3)
    		{
    		NRExplosion.createExplosion(new EntityBomb(world).setType(type), world, (double)this.xCoord, (double)this.yCoord + R, (double)this.zCoord - R, 25 + 4*R, 1000F, true);
    		}
    		else if (this.MBNumber == 4)
    		{
    		NRExplosion.createExplosion(new EntityBomb(world).setType(type), world, (double)this.xCoord + R, (double)this.yCoord + R, (double)this.zCoord, 25 + 4*R, 1000F, true);
    		}
    		else if (this.MBNumber == 2)
    		{
    		NRExplosion.createExplosion(new EntityBomb(world).setType(type), world, (double)this.xCoord, (double)this.yCoord + R, (double)this.zCoord + R, 25 + 4*R, 1000F, true);
    		}
    		else if (this.MBNumber == 5)
    		{
    		NRExplosion.createExplosion(new EntityBomb(world).setType(type), world, (double)this.xCoord - R, (double)this.yCoord + R, (double)this.zCoord, 25 + 4*R, 1000F, true);
    		}
    	}
    }
    
    public void typeoffuelx()
    {
    	if (this.fueltype == 1) { typeoffuel = "LEU"; fuelmult = 2; }
    	else if (this.fueltype == 2) { typeoffuel = "HEU"; fuelmult = 4; }
    	else if (this.fueltype == 3) { typeoffuel = "LEP"; fuelmult = 4; }
    	else if (this.fueltype == 4) { typeoffuel = "HEP"; fuelmult = 8; }
    	else if (this.fueltype == 5) { typeoffuel = "MOX"; fuelmult = 4; }
    	else if (this.fueltype == 6) { typeoffuel = "TBU"; fuelmult = 1; }
    	else if (this.fueltype == 7) { typeoffuel = "LEU"; fuelmult = 2; }
    	else if (this.fueltype ==  { typeoffuel = "HEU"; fuelmult = 4; }
    	else if (this.fueltype == 9) { typeoffuel = "LEP"; fuelmult = 4; }
    	else if (this.fueltype == 10) { typeoffuel = "HEP"; fuelmult = 8; }
    	else if (this.fueltype == 11) { typeoffuel = "MOX"; fuelmult = 4; }
    	else if (this.fueltype == 0) { typeoffuel = "No Fuel"; fuelmult = 0; }
    	else { typeoffuel = "No Fuel"; fuelmult = 0; }
    }

    private void energy()
    {
    	int prevE = this.storage.getEnergyStored();
    	int newE;
    	
    	int prevH = this.heat*2;
    	int newH;
    	
    	ForgeDirection forward = ForgeDirection.getOrientation(
          	    this.getBlockMetadata()).getOpposite();
          	  int x = xCoord + R * forward.offsetX;
          	  int y = yCoord;
          	  int z = zCoord + R * forward.offsetZ;
    	
        if (this.getStackInSlot(1) == null && worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord) && this.fueltime > 0 && this.fueltype != 0 && this.multiblock(this.worldObj, this.xCoord, this.yCoord, this.zCoord))
        {
        	flag = true;
        	
        	//LEU
        	if (this.fueltype == 1)
        	{
        		this.storage.receiveEnergy(30*this.power*R, false);
                this.fueltime -= 300*(100/NuclearRelativistics.fissionEfficiency);
                this.heat += 7*2*R;
        	}

        	//HEU
        	if (this.fueltype == 2)
        	{
        		this.storage.receiveEnergy(135*this.power*R, false);
                this.fueltime -= 300*(100/NuclearRelativistics.fissionEfficiency);
                this.heat += 70*2*R;
        	}

        	//LEP
        	if (this.fueltype == 3)
        	{
        		this.storage.receiveEnergy(60*this.power*R, false);
                this.fueltime -= 576*(100/NuclearRelativistics.fissionEfficiency);
                this.heat += 21*2*R;
        	}

        	//HEP
        	if (this.fueltype == 4)
        	{
        		this.storage.receiveEnergy(270*this.power*R, false);
                this.fueltime -= 576*(100/NuclearRelativistics.fissionEfficiency);
                this.heat += 210*2*R;
        	}

        	//MOX
        	if (this.fueltype == 5)
        	{
        		this.storage.receiveEnergy(45*this.power*R, false);
                this.fueltime -= 400*(100/NuclearRelativistics.fissionEfficiency);
                this.heat += 15*2*R;
        	}
        	
        	//TBU
        	if (this.fueltype == 6)
        	{
        		this.storage.receiveEnergy(8*this.power*R, false);
                this.fueltime -= 75*(100/NuclearRelativistics.fissionEfficiency);
                this.heat += 1*2*R;
        	}
        	
        	//LEU
        	if (this.fueltype == 7)
        	{
        		this.storage.receiveEnergy(30*this.power*R, false);
                this.fueltime -= 300*(100/NuclearRelativistics.fissionEfficiency);
                this.heat += 7*2*R;
        	}

        	//HEU
        	if (this.fueltype == 
        	{
        		this.storage.receiveEnergy(135*this.power*R, false);
                this.fueltime -= 300*(100/NuclearRelativistics.fissionEfficiency);
                this.heat += 70*2*R;
        	}

        	//LEP
        	if (this.fueltype == 9)
        	{
        		this.storage.receiveEnergy(60*this.power*R, false);
                this.fueltime -= 576*(100/NuclearRelativistics.fissionEfficiency);
                this.heat += 21*2*R;
        	}

        	//HEP
        	if (this.fueltype == 10)
        	{
        		this.storage.receiveEnergy(270*this.power*R, false);
                this.fueltime -= 576*(100/NuclearRelativistics.fissionEfficiency);
                this.heat += 210*2*R;
        	}

        	//MOX
        	if (this.fueltype == 11)
        	{
        		this.storage.receiveEnergy(45*this.power*R, false);
                this.fueltime -= 400*(100/NuclearRelativistics.fissionEfficiency);
                this.heat += 15*2*R;
        	}
        	
        	for (int Z4 = -SR; Z4 <= SR; Z4++) {
          	   for (int X4 = -SR; X4 <= SR; X4++) {
          		for (int Y4 = 1; Y4 <= SD; Y4++) {
          	    if(this.worldObj.getBlock(x + X4, y + Y4, z + Z4)==NRBlocks.graphiteBlock){
          	    	this.storage.receiveEnergy((this.power*fuelmult)/2, false); this.heat += 2*fuelmult*R; }
          	    if(this.worldObj.getBlock(x + X4, y + Y4, z + Z4)==Blocks.lava){
          	    	this.storage.receiveEnergy((this.power*fuelmult)/10, false); this.heat += 4*fuelmult*R; }
          	}}}
        	
        } else { flag = false; }
          	
          	if (this.multiblock(this.worldObj, this.xCoord, this.yCoord, this.zCoord)) {
          	  for (int Z4 = -SR; Z4 <= SR; Z4++) {
             	   for (int X4 = -SR; X4 <= SR; X4++) {
             		for (int Y4 = 1; Y4 <= SD; Y4++) {
             	    if(this.worldObj.getBlock(x + X4, y + Y4, z + Z4)==NRBlocks.coolerBlock){
             	    	if (this.heat > 16-1) { this.heat -= 16; } else { this.heat = 0; } }
             	    if(this.worldObj.getBlock(x + X4, y + Y4, z + Z4)==Blocks.water){
             	    	if (this.heat > 4-1) { this.heat -= 4; } else { this.heat = 0; } }
             	}}}}
          	
          	newE = this.storage.getEnergyStored();
          	E = newE-prevE;
          	prevE = newE;
          	
          	newH = this.heat*2;
          	H = newH-prevH;
          	prevH = newH;
    }
    
    public boolean multiblock(World world, int x, int y, int z)
    {
    	Block block = this.blockType;
    	@SuppressWarnings("unused")
    	BlockFissionReactorGraphite reactorGraphite = (BlockFissionReactorGraphite)block;
    	if (checkReactor())
    	{
    		return true;
    	}
    		return false;
    }

    public boolean multiblockstring()
    {
    	if (multiblock(getWorldObj(), this.xCoord, this.yCoord, this.zCoord))
    	{
    		return true;
    	}
    		return false;
    }

private void addEnergy()
    {
        TileEntity down = BlockHelper.getAdjacentTileEntity(this, ForgeDirection.DOWN);
        TileEntity up = BlockHelper.getAdjacentTileEntity(this, ForgeDirection.UP);
        TileEntity north = BlockHelper.getAdjacentTileEntity(this, ForgeDirection.NORTH);
        TileEntity south = BlockHelper.getAdjacentTileEntity(this, ForgeDirection.SOUTH);
        TileEntity east = BlockHelper.getAdjacentTileEntity(this, ForgeDirection.EAST);
        TileEntity west = BlockHelper.getAdjacentTileEntity(this, ForgeDirection.WEST);


            if (EnergyHelper.isEnergyReceiverFromSide(down, ForgeDirection.DOWN))
            {
                this.storage.extractEnergy(((IEnergyHandler)down).receiveEnergy(ForgeDirection.UP, this.storage.extractEnergy(this.maxTransfer, true), false), false);
            }


            else if (EnergyHelper.isEnergyReceiverFromSide(up, ForgeDirection.UP))
            {
                this.storage.extractEnergy(((IEnergyHandler)up).receiveEnergy(ForgeDirection.DOWN, this.storage.extractEnergy(this.maxTransfer, true), false), false);
            }


            else if (EnergyHelper.isEnergyReceiverFromSide(west, ForgeDirection.WEST))
            {
                this.storage.extractEnergy(((IEnergyHandler)west).receiveEnergy(ForgeDirection.EAST, this.storage.extractEnergy(this.maxTransfer, true), false), false);
            }


            else if (EnergyHelper.isEnergyReceiverFromSide(east, ForgeDirection.EAST))
            {
                this.storage.extractEnergy(((IEnergyHandler)east).receiveEnergy(ForgeDirection.WEST, this.storage.extractEnergy(this.maxTransfer, true), false), false);
            }


            else if (EnergyHelper.isEnergyReceiverFromSide(north, ForgeDirection.NORTH))
            {
                this.storage.extractEnergy(((IEnergyHandler)north).receiveEnergy(ForgeDirection.SOUTH, this.storage.extractEnergy(this.maxTransfer, true), false), false);
            }

            else if (EnergyHelper.isEnergyReceiverFromSide(south, ForgeDirection.SOUTH))
            {
            this.storage.extractEnergy(((IEnergyHandler)south).receiveEnergy(ForgeDirection.NORTH, this.storage.extractEnergy(this.maxTransfer, true), false), false);
            }
    }

    @SuppressWarnings("unused")
private boolean canAddEnergy()
    {
        return this.storage.getEnergyStored() == 0 ? false : this.direction != "none";
    }

    public void updateHandlers()
    {
        String d = this.getHandlers();

        if (d == null)
        {
            this.direction = "none";
        }
        else
        {
            this.direction = d;
        }
    }
    
    public String getInvName()
{
	return this.isInvNameLocalized() ? this.localizedName : "Fission Reactor";
}

public boolean isInvNameLocalized()
{
	return this.localizedName != null && this.localizedName.length() > 0;
}

    public String getHandlers()
    {
        TileEntity down = this.worldObj.getTileEntity(this.xCoord, this.yCoord - 1, this.zCoord);
        TileEntity up = this.worldObj.getTileEntity(this.xCoord, this.yCoord + 1, this.zCoord);
        TileEntity north = this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord - 1);
        TileEntity south = this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord + 1);
        TileEntity east = this.worldObj.getTileEntity(this.xCoord + 1, this.yCoord, this.zCoord);
        TileEntity west = this.worldObj.getTileEntity(this.xCoord - 1, this.yCoord, this.zCoord);
        return EnergyHelper.isEnergyReceiverFromSide(down, ForgeDirection.DOWN) ? "down" : (EnergyHelper.isEnergyReceiverFromSide(up, ForgeDirection.UP) ? "up" : (EnergyHelper.isEnergyReceiverFromSide(west, ForgeDirection.WEST) ? "west" : (EnergyHelper.isEnergyReceiverFromSide(east, ForgeDirection.EAST) ? "east" : (EnergyHelper.isEnergyReceiverFromSide(north, ForgeDirection.NORTH) ? "north" : (EnergyHelper.isEnergyReceiverFromSide(south, ForgeDirection.SOUTH) ? "south" : "none")))));
    }

    private void fuel()
    {
        ItemStack stack = this.getStackInSlot(0);
        ItemStack pstack = this.getStackInSlot(1);

        if (stack != null && pstack == null && isFuel(stack) && this.fueltime == 0 && this.fueltype == 0)
        {
            this.addFuel(fuelValue(stack));
            
            this.fueltype = TileEntityFissionReactorGraphite.setfueltype(stack);
            
            --this.slots[0].stackSize;

            if (this.slots[0].stackSize <= 0)
            {
                this.slots[0] = null;
            }
        }
    }
    
    private void upgrade()
    {
        ItemStack stack = this.getStackInSlot(2);

        if (stack != null && isUpgrade(stack))
        {
        	R = (int) (rawR + stack.stackSize);
        	D = R*2 + 1;
            SR = R-1; 
            SD = SR*2 + 1;
        	
        	if (R != rawR) {
        	}

            if (this.slots[2].stackSize <= 0)
            {
            	R = rawR;
            	D = R*2 + 1;
                SR = R-1; 
                SD = SR*2 + 1;
                this.slots[2] = null;
            }
        }
        else {
        R = rawR;
        D = R*2 + 1;
        SR = R-1; 
        SD = SR*2 + 1;
        }
    }
    
    private void product()
    {
        if (this.slots[1] == null && this.fueltime == 0 && this.fueltype != 0)
        {    
        	if (this.fueltype == 1)
        	{ this.slots[1] = new ItemStack(NRItems.fuel, 1, 22); this.fueltype = 0; }

        	else if (this.fueltype == 2)
        	{ this.slots[1] = new ItemStack(NRItems.fuel, 1, 23); this.fueltype = 0; }

        	else if (this.fueltype == 3)
        	{ this.slots[1] = new ItemStack(NRItems.fuel, 1, 24); this.fueltype = 0; }

        	else if (this.fueltype == 4)
        	{ this.slots[1] = new ItemStack(NRItems.fuel, 1, 25); this.fueltype = 0; }

        	else if (this.fueltype == 5)
        	{ this.slots[1] = new ItemStack(NRItems.fuel, 1, 26); this.fueltype = 0; }

        	else if (this.fueltype == 6)
        	{ this.slots[1] = new ItemStack(NRItems.fuel, 1, 27); this.fueltype = 0; }
        	
        	else if (this.fueltype == 7)
        	{ this.slots[1] = new ItemStack(NRItems.fuel, 1, 28); this.fueltype = 0; }

        	else if (this.fueltype == 
        	{ this.slots[1] = new ItemStack(NRItems.fuel, 1, 29); this.fueltype = 0; }

        	else if (this.fueltype == 9)
        	{ this.slots[1] = new ItemStack(NRItems.fuel, 1, 30); this.fueltype = 0; }

        	else if (this.fueltype == 10)
        	{ this.slots[1] = new ItemStack(NRItems.fuel, 1, 31); this.fueltype = 0; }

        	else if (this.fueltype == 11)
        	{ this.slots[1] = new ItemStack(NRItems.fuel, 1, 32); this.fueltype = 0; }
        	
        	else {}
        }
    }
    
    public static boolean isFuel(ItemStack stack)
    {
        return fuelValue(stack) > 0 && setfueltype(stack) != 0;
    }
    
    public static boolean isUpgrade(ItemStack stack)
    {
        return stack.getItem() == NRItems.upgrade;
    }
    
    public static int fuelValue(ItemStack stack)
    {
	if (stack == null)
        {
            return 0;
        }
        else
        {
        	Item item = stack.getItem();
        	
        	if(item == new ItemStack (NRItems.fuel, 1, 11).getItem() && item.getDamage(stack) == 11) { return 7200000; }
   		   else if(item == new ItemStack (NRItems.fuel, 1, 12).getItem() && item.getDamage(stack) == 12) { return 7200000; }
   		   else if(item == new ItemStack (NRItems.fuel, 1, 13).getItem() && item.getDamage(stack) == 13) { return 7200000; }
   		   else if(item == new ItemStack (NRItems.fuel, 1, 14).getItem() && item.getDamage(stack) == 14) { return 7200000; }
   		   else if(item == new ItemStack (NRItems.fuel, 1, 15).getItem() && item.getDamage(stack) == 15) { return 7200000; }
   		   else if(item == new ItemStack (NRItems.fuel, 1, 16).getItem() && item.getDamage(stack) == 16) { return 7200000; }
   		   else if(item == new ItemStack (NRItems.fuel, 1, 17).getItem() && item.getDamage(stack) == 17) { return 7200000; }
   		   else if(item == new ItemStack (NRItems.fuel, 1, 18).getItem() && item.getDamage(stack) == 18) { return 7200000; }
   		   else if(item == new ItemStack (NRItems.fuel, 1, 19).getItem() && item.getDamage(stack) == 19) { return 7200000; }
   		   else if(item == new ItemStack (NRItems.fuel, 1, 20).getItem() && item.getDamage(stack) == 20) { return 7200000; }
   		   else if(item == new ItemStack (NRItems.fuel, 1, 21).getItem() && item.getDamage(stack) == 21) { return 7200000; }
         	return 0; }
   }
    
    public static int setfueltype(ItemStack stack)
    {
	if (stack == null)
        {
            return 0;
        }
        else
        {
        	Item item = stack.getItem();
        	
        	if(item == new ItemStack (NRItems.fuel, 1, 11).getItem() && item.getDamage(stack) == 11) { return 1; }
  		   else if(item == new ItemStack (NRItems.fuel, 1, 12).getItem() && item.getDamage(stack) == 12) { return 2; }
  		   else if(item == new ItemStack (NRItems.fuel, 1, 13).getItem() && item.getDamage(stack) == 13) { return 3; }
  		   else if(item == new ItemStack (NRItems.fuel, 1, 14).getItem() && item.getDamage(stack) == 14) { return 4; }
  		   else if(item == new ItemStack (NRItems.fuel, 1, 15).getItem() && item.getDamage(stack) == 15) { return 5; }
  		   else if(item == new ItemStack (NRItems.fuel, 1, 16).getItem() && item.getDamage(stack) == 16) { return 6; }
  		   else if(item == new ItemStack (NRItems.fuel, 1, 17).getItem() && item.getDamage(stack) == 17) { return 7; }
   		   else if(item == new ItemStack (NRItems.fuel, 1, 18).getItem() && item.getDamage(stack) == 18) { return 8; }
   		   else if(item == new ItemStack (NRItems.fuel, 1, 19).getItem() && item.getDamage(stack) == 19) { return 9; }
   		   else if(item == new ItemStack (NRItems.fuel, 1, 20).getItem() && item.getDamage(stack) == 20) { return 10; }
   		   else if(item == new ItemStack (NRItems.fuel, 1, 21).getItem() && item.getDamage(stack) == 21) { return 11; }
        	return 0; }
   }

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

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

        this.typeoffuel = nbt.getString("Typeoffuel");
        this.problem = nbt.getString("problem");
        this.fueltime = nbt.getInteger("Fueltime");
        this.fueltype = nbt.getInteger("Fueltype");
        this.rawR = nbt.getInteger("rawR");
        this.R = nbt.getInteger("R");
        this.SR = nbt.getInteger("SR");
        this.D = nbt.getInteger("D");
        this.SD = nbt.getInteger("SD");
        this.E = nbt.getInteger("E");
        this.H = nbt.getInteger("H");
        this.flag = nbt.getBoolean("flag");
        this.flag1 = nbt.getBoolean("flag1");
        this.fuelmult = nbt.getInteger("Fuelmult");
        this.MBNumber = nbt.getInteger("MBN");
        this.heat = nbt.getInteger("Heat");
        this.power = nbt.getInteger("Power");
        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("Fueltime", this.fueltime);
        nbt.setInteger("Fueltype", this.fueltype);
        nbt.setInteger("rawR", this.rawR);
        nbt.setInteger("R", this.R);
        nbt.setInteger("SR", this.SR);
        nbt.setInteger("D", this.D);
        nbt.setInteger("SD", this.SD);
        nbt.setInteger("E", this.E);
        nbt.setInteger("H", this.H);
        nbt.setBoolean("flag", this.flag);
        nbt.setBoolean("flag1", this.flag1);
        nbt.setInteger("Fuelmult", this.fuelmult);
        nbt.setInteger("MBN", this.MBNumber);
        nbt.setInteger("Heat", this.heat);
        nbt.setInteger("Power", this.power);
        nbt.setString("Typeoffuel", this.typeoffuel);
        nbt.setString("problem", this.problem);
        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.isInvNameLocalized())
	{
		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 addHeat(int add)
    {
        this.heat += add;
    }
    
    public void addFuel(int add)
    {
        this.fueltime += add;
    }

    public void removeHeat(int remove)
    {
        this.heat -= remove;
    }
    
    public void removeFuel(int remove)
    {
        this.fueltime -= remove;
    }

    public boolean canConnectEnergy(ForgeDirection from)
    {
        return true;
    }

    public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate)
    {
        return 0;
    }

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

    public int getEnergyStored(ForgeDirection paramForgeDirection)
    {
        return this.storage.getEnergyStored();
    }

    public int getMaxEnergyStored(ForgeDirection paramForgeDirection)
    {
        return this.storage.getMaxEnergyStored();
    }

    /**
     * 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)
        {
            return isFuel(stack);
        }
        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 slot == 0 ? slotsSides : slotsTop;
    }

    /**
     * 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 this.isItemValidForSlot(slot, stack);
    }

    /**
     * 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 slot == 1;
    }
    
    public int getInventoryStackLimit()
    {
        return 8;
    }
    
    private boolean checkReactor() { 
    	  ForgeDirection forward = ForgeDirection.getOrientation(
    	    this.getBlockMetadata()).getOpposite();
    	  int x = xCoord + R * forward.offsetX;
    	  int y = yCoord;
    	  int z = zCoord + R * forward.offsetZ;

    	  for (int Z4 = -R; Z4 <= R; Z4++) {
       	   for (int X4 = -R; X4 <= R; X4++) {
       		for (int Y4 = 0; Y4 <= 2*R; Y4++) {
       	     if(this.worldObj.getBlock(x + X4, y + Y4, z + Z4)==NRBlocks.fissionReactorGraphiteIdle || this.worldObj.getBlock(x + X4, y + Y4, z + Z4)==NRBlocks.fissionReactorGraphiteActive){
       	    	 if (x + X4 == this.xCoord && y + Y4 == this.yCoord && z + Z4 == this.zCoord) {} else {
       	    		 this.problem = "Multiple Controllers";
       	      return false;
       	}}}}}
    	  
    	  for (int Z1 = -SR; Z1 <= SR; Z1++) {
    	   for (int X1 = -SR; X1 <= SR; X1++) {
    	     if(this.worldObj.getBlock(x + X1, y, z + Z1)!=NRBlocks.reactorBlock){
    	    	 this.problem = "Casing Incomplete";
    	      return false;
    	    }
    	    if(this.worldObj.getBlock(x + X1, y+D-1, z + Z1)!=NRBlocks.reactorBlock){
    	    	this.problem = "Casing Incomplete";
    	     return false;
    	    }}}

    	  for (int Y2 = 1; Y2 <= SD; Y2++) {
    	  for (int XZ = -SR; XZ <= SR; XZ++) {
    	   if(this.worldObj.getBlock(x-R, y+Y2, z+XZ)!=NRBlocks.reactorBlock){
    		   this.problem = "Casing Incomplete";
    	    return false;
    	   	}
    	   if(this.worldObj.getBlock(x+R, y+Y2, z+XZ)!=NRBlocks.reactorBlock){
    		   this.problem = "Casing Incomplete";
    	    return false;
    	   	}
    	   if(x!=R&&x!=-R){
    	   if(this.worldObj.getBlock(x+XZ, y+Y2, z+R)!=NRBlocks.reactorBlock){
    		   this.problem = "Casing Incomplete";
    	    return false;
    	   	}
    	   if(this.worldObj.getBlock(x+XZ, y+Y2, z-R)!=NRBlocks.reactorBlock){
    		   this.problem = "Casing Incomplete";
    	    return false;
    	   }
    	    if(this.worldObj.getBlock(x, y+Y2, z)!=NRBlocks.cellBlock){
    	    	this.problem = "Fuel Rod Incomplete";
        	    return false;
    	    }}}}
    	  
    	  for (int Z3 = -SR; Z3 <= SR; Z3++) {
       	   for (int X3 = -SR; X3 <= SR; X3++) {
       		for (int Y3 = 1; Y3 <= SD; Y3++) {
       	     if(this.worldObj.getBlock(x + X3, y + Y3, z + Z3)==NRBlocks.reactorBlock){
       	    	this.problem = "Casing in Interior";
       	      return false;
       	    }}}}
     	   
    	  this.MBNumber = this.getBlockMetadata();
    	  //this.problem = "No Problem";
    	  return true;
    	 }
}

 

Thanks in advance for any help :)

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.