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

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

  • Author

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

Never worked with RF API but i will give it a try.

Show whole code, code taken out of context wont help any1

  • Author

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

  • Author

Forestry Engines... When I had the static in the EnergyStorage, it charged... But now, it doesn't charge...

Thanks :)

João Fernandes

aaaaah i got it. u arent syncing the values between client and server, which isnt an issue when it was static, because client and server was in the same machine. but now the values arent static, so u need to manually sync the values between client and server side if u want to display them, which means that u will need to use packets

 

EDIT: http://www.minecraftforge.net/forum/index.php?topic=20135.0

  • Author

I'll do that ;)

I'll comment the results later ;) thanks!

Thanks :)

João Fernandes

  • Author

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

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

  • Author

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

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

  • Author

I'll try to do that! I'll use ContainerFurnace as my guide! Thanks :)

Thanks :)

João Fernandes

  • Author

It worked ^^

Using detectAndSendChanges(), I could retrieve the energy and pass it to the interface! Thanks :)

Thanks :)

João Fernandes

  • Author

No worries ^^ I never actually learn well how to work with the packets, but I tryed to!

 

Thanks :)

Thanks :)

João Fernandes

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.