Jump to content

[1.7.10] Let Blocks Link To the Inventory of Another Block (Multiblock)


turbodiesel4598

Recommended Posts

Hey there,

 

I am trying to make an RF-producing Fusion Reactor. The model is a 3*2*3 structure (height of 2 and square with length 3). The main block is placed down, and around and above it, 17 dummy blocks are placed to make the structure of the model solid (http://i.imgur.com/kXeqxyx.png).

 

I have managed to allow right-clicking on any of the dummy blocks to access the main block's inventory (In the dummy block's Block class).

I have also managed to allow RF to be taken out of any of the dummy blocks (in the main Fusion Reactor block's Tile Entity class) (http://i.imgur.com/yy78jwg.png).

 

However, I am totally stuck trying to work out how to allow items to be taken out and put into the main block's inventory by accessing the dummy blocks with hoppers, pipes etc (http://i.imgur.com/6pZQ47o.png). I am not sure which classes I should give to you or look at since I have made no progress since trying to add this feature - it is quite important as currently there is only one side available to access, which is the bottom of the main block.

 

Any help would be appreciated, and thanks in advance ;)

Link to comment
Share on other sites

First of all, nice model.

 

Could you post TileEntities for main and dummy block?

 

Also, there is a tutorial on how to make Multiblock structures by MineMaarten.

You can take a look at the code, If I remember correctly there is a part about sharing inventories.

Here is a

Link to comment
Share on other sites

Thanks :)

 

Here is the main 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.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.EnergyHelper;import com.nr.mod.NuclearRelativistics;import com.nr.mod.items.NRItems;public class TileEntityFusionReactor extends TileEntityInventory implements IEnergyHandler, IEnergyConnection, ISidedInventory, IEnergyReceiver {    public EnergyStorage storage = new EnergyStorage(10000000, 10000000);    public int energy;    public int EShown;        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 int powerHH = 80*NuclearRelativistics.fusionRF;    public int powerHD = 60*NuclearRelativistics.fusionRF;    public int powerHT = 20*NuclearRelativistics.fusionRF;    public int powerHHe = 20*NuclearRelativistics.fusionRF;    public int powerHB = 80*NuclearRelativistics.fusionRF;    public int powerHLi6 = 30*NuclearRelativistics.fusionRF;    public int powerHLi7 = 120*NuclearRelativistics.fusionRF;        public int powerDD = 180*NuclearRelativistics.fusionRF;    public int powerDT = 200*NuclearRelativistics.fusionRF;    public int powerDHe = 160*NuclearRelativistics.fusionRF;    public int powerDB = 20*NuclearRelativistics.fusionRF;    public int powerDLi6 = 130*NuclearRelativistics.fusionRF;    public int powerDLi7 = 10*NuclearRelativistics.fusionRF;        public int powerTT = 60*NuclearRelativistics.fusionRF;    public int powerTHe = 40*NuclearRelativistics.fusionRF;    public int powerTB = 10*NuclearRelativistics.fusionRF;    public int powerTLi6 = 5*NuclearRelativistics.fusionRF;    public int powerTLi7 = 10*NuclearRelativistics.fusionRF;        public int powerHeHe = 120*NuclearRelativistics.fusionRF;    public int powerHeB = 5*NuclearRelativistics.fusionRF;    public int powerHeLi6 = 140*NuclearRelativistics.fusionRF;    public int powerHeLi7 = 30*NuclearRelativistics.fusionRF;        public int powerBB = 5*NuclearRelativistics.fusionRF;    public int powerBLi6 = 5*NuclearRelativistics.fusionRF;    public int powerBLi7 = 5*NuclearRelativistics.fusionRF;        public int powerLi6Li6 = 5*NuclearRelativistics.fusionRF;    public int powerLi6Li7 = 5*NuclearRelativistics.fusionRF;        public int powerLi7Li7 = 5*NuclearRelativistics.fusionRF;        public int Max = 5000000;        public int requiredHH = 1000;    public int requiredHD = 1000;    public int requiredHT = 800;    public int requiredHHe = 400;    public int requiredHB = 40;    public int requiredHLi6 = 125;    public int requiredHLi7 = 200;    public int requiredDD = 200;    public int requiredDT = 250;    public int requiredDHe = 125;    public int requiredDB = 125;    public int requiredDLi6 = 1000;    public int requiredDLi7 = 100;        public int requiredTT = 200;    public int requiredTHe = 160;    public int requiredTB = 100;    public int requiredTLi6 = 40;    public int requiredTLi7 = 40;    public int requiredHeHe = 250;    public int requiredHeB = 80;    public int requiredHeLi6 = 800;    public int requiredHeLi7 = 200;    public int requiredBB = 40;    public int requiredBLi6 = 80;    public int requiredBLi7 = 40;    public int requiredLi6Li6 = 20;    public int requiredLi6Li7 = 40;    public int requiredLi7Li7 = 20;        public boolean flag;    public boolean flag1 = false;    public int lastE;    public int E;    public int maxTransfer = 1000000;    public String direction;    //private static final int[] slotsTop = new int[] {0};	private static final int[] slotsBottom = new int[] {0, 1};    //private static final int[] slotsSides = new int[] {1};    public TileEntityFusionReactor()    {        super.slots = new ItemStack[2];        super.localizedName = "Fusion Reactor";    }    public void updateEntity()    {    	super.updateEntity();    	if(!this.worldObj.isRemote){    	energy();    	fuel1();    	fuel2();    	addEnergy();    }    	if (flag != flag1) { flag1 = flag; BlockFusionReactor.updateFusionReactorBlockState(this.worldObj, this.xCoord, this.yCoord, this.zCoord); }    	markDirty();    }    private void energy() {    	int prevE = this.storage.getEnergyStored();    	int newE;    	    	if (!worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord)) {    	lastE = storage.getEnergyStored();    	    	if (this.HLevel >= this.requiredHH && this.HLevel2 >= this.requiredHH)    	{this.storage.receiveEnergy(this.powerHH, false); this.HLevel -= this.requiredHH; this.HLevel2 -= this.requiredHH; flag = true;}    	    	else if (this.HLevel >= this.requiredHD && this.DLevel2 >= this.requiredHD)    	{this.storage.receiveEnergy(this.powerHD, false); this.HLevel -= this.requiredHD; this.DLevel2 -= this.requiredHD; flag = true;}    	    	else if (this.DLevel >= this.requiredHD && this.HLevel2 >= this.requiredHD)    	{this.storage.receiveEnergy(this.powerHD, false); this.DLevel -= this.requiredHD; this.HLevel2 -= this.requiredHD; flag = true;}    	    	else if (this.HLevel >= this.requiredHT && this.TLevel2 >= this.requiredHT)    	{this.storage.receiveEnergy(this.powerHT, false); this.HLevel -= this.requiredHT; this.TLevel2 -= this.requiredHT; flag = true;}    	    	else if (this.TLevel >= this.requiredHT && this.HLevel2 >= this.requiredHT)    	{this.storage.receiveEnergy(this.powerHT, false); this.TLevel -= this.requiredHT; this.HLevel2 -= this.requiredHT; flag = true;}    	    	else if (this.HLevel >= this.requiredHHe && this.HeLevel2 >= this.requiredHHe)    	{this.storage.receiveEnergy(this.powerHHe, false); this.HLevel -= this.requiredHHe; this.HeLevel2 -= this.requiredHHe; flag = true;}    	    	else if (this.HeLevel >= this.requiredHHe && this.HLevel2 >= this.requiredHHe)    	{this.storage.receiveEnergy(this.powerHHe, false); this.HeLevel -= this.requiredHHe; this.HLevel2 -= this.requiredHHe; flag = true;}    	else if (this.HLevel >= this.requiredHB && this.BLevel2 >= this.requiredHB)    	{this.storage.receiveEnergy(this.powerHB, false); this.HLevel -= this.requiredHB; this.BLevel2 -= this.requiredHB; flag = true;}    	    	else if (this.BLevel >= this.requiredHB && this.HLevel2 >= this.requiredHB)    	{this.storage.receiveEnergy(this.powerHB, false); this.BLevel -= this.requiredHB; this.HLevel2 -= this.requiredHB; flag = true;}    	    	else if (this.HLevel >= this.requiredHLi6 && this.Li6Level2 >= this.requiredHLi6)    	{this.storage.receiveEnergy(this.powerHLi6, false); this.HLevel -= this.requiredHLi6; this.Li6Level2 -= this.requiredHLi6; flag = true;}    	    	else if (this.Li6Level >= this.requiredHLi6 && this.HLevel2 >= this.requiredHLi6)    	{this.storage.receiveEnergy(this.powerHLi6, false); this.Li6Level -= this.requiredHLi6; this.HLevel2 -= this.requiredHLi6; flag = true;}    	    	else if (this.HLevel >= this.requiredHLi7 && this.Li7Level2 >= this.requiredHLi7)    	{this.storage.receiveEnergy(this.powerHLi7, false); this.HLevel -= this.requiredHLi7; this.Li7Level2 -= this.requiredHLi7; flag = true;}    	    	else if (this.Li7Level >= this.requiredHLi7 && this.HLevel2 >= this.requiredHLi7)    	{this.storage.receiveEnergy(this.powerHLi7, false); this.Li7Level -= this.requiredHLi7; this.HLevel2 -= this.requiredHLi7; flag = true;}    	    	//    	    	else if (this.DLevel >= this.requiredDD && this.DLevel2 >= this.requiredDD)    	{this.storage.receiveEnergy(this.powerDD, false); this.DLevel -= this.requiredDD; this.DLevel2 -= this.requiredDD; flag = true;}    	    	else if (this.DLevel >= this.requiredDT && this.TLevel2 >= this.requiredDT)    	{this.storage.receiveEnergy(this.powerDT, false); this.DLevel -= this.requiredDT; this.TLevel2 -= this.requiredDT; flag = true;}    	    	else if (this.TLevel >= this.requiredDT && this.DLevel2 >= this.requiredDT)    	{this.storage.receiveEnergy(this.powerDT, false); this.TLevel -= this.requiredDT; this.DLevel2 -= this.requiredDT; flag = true;}    	    	else if (this.DLevel >= this.requiredDHe && this.HeLevel2 >= this.requiredDHe)    	{this.storage.receiveEnergy(this.powerDHe, false); this.DLevel -= this.requiredDHe; this.HeLevel2 -= this.requiredDHe; flag = true;}    	    	else if (this.HeLevel >= this.requiredDHe && this.DLevel2 >= this.requiredDHe)    	{this.storage.receiveEnergy(this.powerDHe, false); this.HeLevel -= this.requiredDHe; this.DLevel2 -= this.requiredDHe; flag = true;}    	else if (this.DLevel >= this.requiredDB && this.BLevel2 >= this.requiredDB)    	{this.storage.receiveEnergy(this.powerDB, false); this.DLevel -= this.requiredDB; this.BLevel2 -= this.requiredDB; flag = true;}    	    	else if (this.BLevel >= this.requiredDB && this.DLevel2 >= this.requiredDB)    	{this.storage.receiveEnergy(this.powerDB, false); this.BLevel -= this.requiredDB; this.DLevel2 -= this.requiredDB; flag = true;}    	    	else if (this.DLevel >= this.requiredDLi6 && this.Li6Level2 >= this.requiredDLi6)    	{this.storage.receiveEnergy(this.powerDLi6, false); this.DLevel -= this.requiredDLi6; this.Li6Level2 -= this.requiredDLi6; flag = true;}    	    	else if (this.Li6Level >= this.requiredDLi6 && this.DLevel2 >= this.requiredDLi6)    	{this.storage.receiveEnergy(this.powerDLi6, false); this.Li6Level -= this.requiredDLi6; this.DLevel2 -= this.requiredDLi6; flag = true;}    	    	else if (this.DLevel >= this.requiredDLi7 && this.Li7Level2 >= this.requiredDLi7)    	{this.storage.receiveEnergy(this.powerDLi7, false); this.DLevel -= this.requiredDLi7; this.Li7Level2 -= this.requiredDLi7; flag = true;}    	    	else if (this.Li7Level >= this.requiredDLi7 && this.DLevel2 >= this.requiredDLi7)    	{this.storage.receiveEnergy(this.powerDLi7, false); this.Li7Level -= this.requiredDLi7; this.DLevel2 -= this.requiredDLi7; flag = true;}    	    	//    	    	else if (this.TLevel >= this.requiredTT && this.TLevel2 >= this.requiredTT)    	{this.storage.receiveEnergy(this.powerTT, false); this.TLevel -= this.requiredTT; this.TLevel2 -= this.requiredTT; flag = true;}    	    	else if (this.TLevel >= this.requiredTHe && this.HeLevel2 >= this.requiredTHe)    	{this.storage.receiveEnergy(this.powerTHe, false); this.TLevel -= this.requiredTHe; this.HeLevel2 -= this.requiredTHe; flag = true;}    	    	else if (this.HeLevel >= this.requiredTHe && this.TLevel2 >= this.requiredTHe)    	{this.storage.receiveEnergy(this.powerTHe, false); this.HeLevel -= this.requiredTHe; this.TLevel2 -= this.requiredTHe; flag = true;}    	else if (this.TLevel >= this.requiredTB && this.BLevel2 >= this.requiredTB)    	{this.storage.receiveEnergy(this.powerTB, false); this.TLevel -= this.requiredTB; this.BLevel2 -= this.requiredTB; flag = true;}    	    	else if (this.BLevel >= this.requiredTB && this.TLevel2 >= this.requiredTB)    	{this.storage.receiveEnergy(this.powerTB, false); this.BLevel -= this.requiredTB; this.TLevel2 -= this.requiredTB; flag = true;}    	    	else if (this.TLevel >= this.requiredTLi6 && this.Li6Level2 >= this.requiredTLi6)    	{this.storage.receiveEnergy(this.powerTLi6, false); this.TLevel -= this.requiredTLi6; this.Li6Level2 -= this.requiredTLi6; flag = true;}    	    	else if (this.Li6Level >= this.requiredTLi6 && this.TLevel2 >= this.requiredTLi6)    	{this.storage.receiveEnergy(this.powerTLi6, false); this.Li6Level -= this.requiredTLi6; this.TLevel2 -= this.requiredTLi6; flag = true;}    	    	else if (this.TLevel >= this.requiredTLi7 && this.Li7Level2 >= this.requiredTLi7)    	{this.storage.receiveEnergy(this.powerTLi7, false); this.TLevel -= this.requiredTLi7; this.Li7Level2 -= this.requiredTLi7; flag = true;}    	    	else if (this.Li7Level >= this.requiredTLi7 && this.TLevel2 >= this.requiredTLi7)    	{this.storage.receiveEnergy(this.powerTLi7, false); this.Li7Level -= this.requiredTLi7; this.TLevel2 -= this.requiredTLi7; flag = true;}    	    	//    	    	else if (this.HeLevel >= this.requiredHeHe && this.HeLevel2 >= this.requiredHeHe)    	{this.storage.receiveEnergy(this.powerHeHe, false); this.HeLevel -= this.requiredHeHe; this.HeLevel2 -= this.requiredHeHe; flag = true;}    	else if (this.HeLevel >= this.requiredHeB && this.BLevel2 >= this.requiredHeB)    	{this.storage.receiveEnergy(this.powerHeB, false); this.HeLevel -= this.requiredHeB; this.BLevel2 -= this.requiredHeB; flag = true;}    	    	else if (this.BLevel >= this.requiredHeB && this.HeLevel2 >= this.requiredHeB)    	{this.storage.receiveEnergy(this.powerHeB, false); this.BLevel -= this.requiredHeB; this.HeLevel2 -= this.requiredHeB; flag = true;}    	    	else if (this.HeLevel >= this.requiredHeLi6 && this.Li6Level2 >= this.requiredHeLi6)    	{this.storage.receiveEnergy(this.powerHeLi6, false); this.HeLevel -= this.requiredHeLi6; this.Li6Level2 -= this.requiredHeLi6; flag = true;}    	    	else if (this.Li6Level >= this.requiredHeLi6 && this.HeLevel2 >= this.requiredHeLi6)    	{this.storage.receiveEnergy(this.powerHeLi6, false); this.Li6Level -= this.requiredHeLi6; this.HeLevel2 -= this.requiredHeLi6; flag = true;}    	    	else if (this.HeLevel >= this.requiredHeLi7 && this.Li7Level2 >= this.requiredHeLi7)    	{this.storage.receiveEnergy(this.powerHeLi7, false); this.HeLevel -= this.requiredHeLi7; this.Li7Level2 -= this.requiredHeLi7; flag = true;}    	    	else if (this.Li7Level >= this.requiredHeLi7 && this.HeLevel2 >= this.requiredHeLi7)    	{this.storage.receiveEnergy(this.powerHeLi7, false); this.Li7Level -= this.requiredHeLi7; this.HeLevel2 -= this.requiredHeLi7; flag = true;}    	    	//    	    	else if (this.BLevel >= this.requiredBB && this.BLevel2 >= this.requiredBB)    	{this.storage.receiveEnergy(this.powerBB, false); this.BLevel -= this.requiredBB; this.BLevel2 -= this.requiredBB; flag = true;}    	    	else if (this.BLevel >= this.requiredBLi6 && this.Li6Level2 >= this.requiredBLi6)    	{this.storage.receiveEnergy(this.powerBLi6, false); this.BLevel -= this.requiredBLi6; this.Li6Level2 -= this.requiredBLi6; flag = true;}    	    	else if (this.Li6Level >= this.requiredBLi6 && this.BLevel2 >= this.requiredBLi6)    	{this.storage.receiveEnergy(this.powerBLi6, false); this.Li6Level -= this.requiredBLi6; this.BLevel2 -= this.requiredBLi6; flag = true;}    	    	else if (this.BLevel >= this.requiredBLi7 && this.Li7Level2 >= this.requiredBLi7)    	{this.storage.receiveEnergy(this.powerBLi7, false); this.BLevel -= this.requiredBLi7; this.Li7Level2 -= this.requiredBLi7; flag = true;}    	    	else if (this.Li7Level >= this.requiredBLi7 && this.BLevel2 >= this.requiredBLi7)    	{this.storage.receiveEnergy(this.powerBLi7, false); this.Li7Level -= this.requiredBLi7; this.BLevel2 -= this.requiredBLi7; flag = true;}    	    	//    	    	else if (this.Li6Level >= this.requiredLi6Li6 && this.Li6Level2 >= this.requiredLi6Li6)    	{this.storage.receiveEnergy(this.powerLi6Li6, false); this.Li6Level -= this.requiredLi6Li6; this.Li6Level2 -= this.requiredLi6Li6; flag = true;}    	    	else if (this.Li6Level >= this.requiredLi6Li7 && this.Li7Level2 >= this.requiredLi6Li7)    	{this.storage.receiveEnergy(this.powerLi6Li7, false); this.Li6Level -= this.requiredLi6Li7; this.Li7Level2 -= this.requiredLi6Li7; flag = true;}    	    	else if (this.Li7Level >= this.requiredLi6Li7 && this.Li6Level2 >= this.requiredLi6Li7)    	{this.storage.receiveEnergy(this.powerLi6Li7, false); this.Li7Level -= this.requiredLi6Li7; this.Li6Level2 -= this.requiredLi6Li7; flag = true;}    	    	//    	    	else if (this.Li7Level >= this.requiredLi7Li7 && this.Li7Level2 >= this.requiredLi7Li7)    	{this.storage.receiveEnergy(this.powerLi7Li7, false); this.Li7Level -= this.requiredLi7Li7; this.Li7Level2 -= this.requiredLi7Li7; flag = true;}    	    	//    	    	else {flag = false;}    	E = storage.getEnergyStored();    	if (E != lastE) { BlockFusionReactor.updateFusionReactorBlockState(this.worldObj, this.xCoord, this.yCoord, this.zCoord); } }    	    	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; }    }	private void addEnergy() {		lastE = storage.getEnergyStored();		for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {		for (int x = -1; x < 2; ++x) {		for (int y = 0; y < 2; ++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.updateFusionReactorBlockState(this.worldObj, this.xCoord, this.yCoord, this.zCoord); }		}    @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 : "Fusion 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 fuel1()    {        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;}        }    }        private void fuel2()    {        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;}        }    }        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 100000;    			}    			else if(i == new ItemStack (NRItems.fuel, 1, 37).getItem() && i.getDamage(stack) == 37)    			{    				return 100000;    			}    			else if(i == new ItemStack (NRItems.fuel, 1, 38).getItem() && i.getDamage(stack) == 38)    			{    				return 100000;    			}    			else if(i == new ItemStack (NRItems.fuel, 1, 39).getItem() && i.getDamage(stack) == 39)    			{    				return 100000;    			}    			else if(i == new ItemStack (NRItems.fuel, 1, 44).getItem() && i.getDamage(stack) == 44)    			{    				return 100000;    			}    			else if(i == new ItemStack (NRItems.fuel, 1, 41).getItem() && i.getDamage(stack) == 41)    			{    				return 100000;    			}	    			else if(i == new ItemStack (NRItems.fuel, 1, 42).getItem() && i.getDamage(stack) == 42)    			{    				return 100000;    			}        }        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 100000;}}        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 100000;}}        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 100000;}}        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 100000;}}        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 100000;}}        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 100000;}}        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 100000;}}        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.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.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.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.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.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 addH(int add) {this.HLevel += add;}    public void addD(int add) {this.DLevel += add;}    public void addT(int add) {this.TLevel += add;}    public void addHe(int add) {this.HeLevel += add;}    public void addB(int add) {this.BLevel += add;}    public void addLi6(int add) {this.Li6Level += add;}    public void addLi7(int add) {this.Li7Level += add;}        public void addH2(int add) {this.HLevel2 += add;}    public void addD2(int add) {this.DLevel2 += add;}    public void addT2(int add) {this.TLevel2 += add;}    public void addHe2(int add) {this.HeLevel2 += add;}    public void addB2(int add) {this.BLevel2 += add;}    public void addLi62(int add) {this.Li6Level2 += add;}    public void addLi72(int add) {this.Li7Level2 += add;}        public void removeH(int remove) {this.HLevel -= remove;}    public void removeD(int remove) {this.DLevel -= remove;}    public void removeT(int remove) {this.TLevel -= remove;}    public void removeHe(int remove) {this.HeLevel -= remove;}    public void removeB(int remove) {this.BLevel -= remove;}    public void removeLi6(int remove) {this.Li6Level -= remove;}    public void removeLi7(int remove) {this.Li7Level -= remove;}        public void removeH2(int remove) {this.HLevel2 -= remove;}    public void removeD2(int remove) {this.DLevel2 -= remove;}    public void removeT2(int remove) {this.TLevel2 -= remove;}    public void removeHe2(int remove) {this.HeLevel2 -= remove;}    public void removeB2(int remove) {this.BLevel2 -= remove;}    public void removeLi62(int remove) {this.Li6Level2 -= remove;}    public void removeLi72(int remove) {this.Li7Level2 -= 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)        {            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 slotsBottom;    }    /**     * 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 slots != 0 || slot != 1 || stack.getItem() == Items.bucket;    }}

 

And here is the dummy Tile Entity (not much to it):

 

package com.nr.mod.blocks.tileentities;import net.minecraft.item.ItemStack;import net.minecraft.tileentity.TileEntity;import net.minecraftforge.common.util.ForgeDirection;import cofh.api.energy.IEnergyConnection;import cofh.api.energy.IEnergyHandler;import cofh.api.energy.IEnergyReceiver;public class TileEntityFusionReactorBlock extends TileEntity implements IEnergyHandler, IEnergyConnection, IEnergyReceiver {public int[] getAccessibleSlotsFromSide(int slot) {	return null;}public boolean canInsertItem(int slot, ItemStack stack, int par) {	return false;}public boolean canExtractItem(int slot, ItemStack stack, int slots) {	return false;}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 from) {	return 0;}public int getMaxEnergyStored(ForgeDirection from) {	return 0;}}

 

 

Thanks for posting that link - I'll take a look at it in the meantime ;)

Link to comment
Share on other sites

What I did for my millstone was give each "dummy" block their own inventory (as they were the same block as the operant block, using the same TE, what they did with their inventory was based on metadata).  I was only allowing insertions from these, not extractions, but it basically worked like this. When a "dummy" block had an item inserted into it via ISidedInventory, it would hold onto it and then attempt to insert it into the main block (if there was room and so on).

 

So yes, a whole bunch of items could be inserted into each dummy block and the dummy wouldn't be able to do anything with them because the main block was full, but that was sufficient for my purposes.

 

For you, what you could do is when the dummy is asked if a slot is accessible, it can locate the main TE (it knows its own coordinates and should be able to calculate the offsets and thereby position of the main) and pass the request on.  Likewise for the item insertion, item extraction, and request for slot contents.

 

e.g.

 

 

public boolean canInsertItem(int slot, ItemStack stack, int par) {//'par' here is which side.  0 = bottom, 1 = top, etc.	ISidedInventory main = (ISidedInventory)world.getTileEntity(xCoord + xOffset, yCoord + yOffset, zCoord + zOffset);	if(main == null) { return false; }	return main.canInsertItem(slot, stack, par);}

 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

1.) TileEntityFusionReactorBlock should implement ISidedInventory, you have methods from the interface in there, but implementation is missing

2.) Like Draco18s said, the ReactorBlock (dummy) should have reference to the main block's TE. This will allow you to insert items to the main's block inventory using ISidedInventory methods

Link to comment
Share on other sites

Just TileEntity.  There's no reason to extend something else.

 

As well as implementing ISidedInventory, of course.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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