Jump to content

Recommended Posts

Posted

Hi! I'm using Redstone Flux API to make my blocks (TileEntities) store some energy! Everything worked fine here!

 

But, I'm having some problems... If I have 2 or more blocks placed (they can be far away for each other) they share the same energy, even if they aren't charging... Imagine that I have 3 blocks placed, the X, the Y and the Z... Y and Z are far away from the X... I open the GUI of the 3 of them and the energy is 0... But, if I charge the X, all three blocks start to have energy... The energy is shared , but the GUI don't...

 

I have this in the TileEntity: public static EnergyStorage energyStorage = new EnergyStorage(1000000);

With this, I thought I could separate each block with is own energystorage and not share with others... But that's what's happening... If I'm charging one block, the others are charged too :\

 

What am I doing wrong?

 

Thanks,

João Fernandes

Thanks :)

João Fernandes

Posted

You are right on that, my bad! But now, it doesn't charge!

 

    /* ====================================================================================== */
    /* =================================== IEnergyHandler =================================== */
    /* ====================================================================================== */

    @Override
    public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
        return energyStorage.receiveEnergy(maxReceive, simulate);
    }

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

    @Override
    public int getEnergyStored(ForgeDirection from) {
        return energyStorage.getEnergyStored();
    }

    @Override
    public int getMaxEnergyStored(ForgeDirection from) {
        return energyStorage.getMaxEnergyStored();
    }

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

 

I know I'm missing something, but I'm not sure what is it...

Thanks :)

João Fernandes

Posted

But this is the only code that matters... I implemented IEnergyHandler and implemented those methods... I created an EnergyStorage on my TileEntity and then, the receiveEnergy() method should work if energy is received...

Thanks :)

João Fernandes

Posted

I'm having trouble passing the messages... I implemented the classes correctly, but I don't know how to send the energy through the network...

 

Should I do Mod.network.sendToServer(message)?

Thanks :)

João Fernandes

Posted

i just realized that there are better ways to do that, sorry.

Whenever you open a guicontainer u already got a pipeline to send informations, so no need to use packets, my bad.

u should take a look how the furnace is syncing the values, should be GuiFurnace there is some stuff about updating the variables

Posted

I saw the GuiFurnace and I opened the Container... There are some things diferent, and that might be the case of this not working...

 

public class CentrifugeContainer extends Container {
    private CentrifugeTileEntity machine;

    public CentrifugeContainer(InventoryPlayer inventoryPlayer, CentrifugeTileEntity centrifugeTileEntity) {
        this.machine = centrifugeTileEntity;

        for(int i = 0; i < 9; ++i){
            addSlotToContainer(new Slot(inventoryPlayer, i, 20 + 18*i, 107));
        }

        for(int i = 0; i < 3; ++i){
            for(int j = 0; j < 9; ++j){
                addSlotToContainer(new Slot(inventoryPlayer, j + i*9 + 9, 20 + 18*j, 49 + i*18));
            }
        }

        addSlotToContainer(new Slot(machine, 0, 20, 18));

        addSlotToContainer(new SlotZero(machine, 1, 56, );
        addSlotToContainer(new SlotZero(machine, 2, 75, );
        addSlotToContainer(new SlotZero(machine, 3, 94, );

        addSlotToContainer(new SlotZero(machine, 4, 56, 27));
        addSlotToContainer(new SlotZero(machine, 5, 75, 27));
        addSlotToContainer(new SlotZero(machine, 6, 94, 27));

        addSlotToContainer(new Slot(machine, 7, 164, );
    }

    @Override
    public boolean canInteractWith(EntityPlayer player) {
        return machine.isUseableByPlayer(player);
    }

    @Override
    public ItemStack transferStackInSlot(EntityPlayer player, int i) {
        return null;
    }
}

Thanks :)

João Fernandes

Posted

I am not sure and got no IDE by hands so I need to guess out of my mind.. it SHOULD be something like detectChangesAndUpdate.

Also important should be sth like addCraftingToCrafters

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.