Posted August 20, 201510 yr 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
August 20, 201510 yr 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
August 20, 201510 yr Never worked with RF API but i will give it a try. Show whole code, code taken out of context wont help any1
August 20, 201510 yr 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
August 20, 201510 yr What are you using to charge the blocks? Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
August 20, 201510 yr Author Forestry Engines... When I had the static in the EnergyStorage, it charged... But now, it doesn't charge... Thanks João Fernandes
August 20, 201510 yr 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
August 20, 201510 yr Author I'll do that I'll comment the results later thanks! Thanks João Fernandes
August 20, 201510 yr 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
August 20, 201510 yr 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
August 20, 201510 yr 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
August 20, 201510 yr 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
August 20, 201510 yr Author I'll try to do that! I'll use ContainerFurnace as my guide! Thanks Thanks João Fernandes
August 20, 201510 yr Author It worked ^^ Using detectAndSendChanges(), I could retrieve the energy and pass it to the interface! Thanks Thanks João Fernandes
August 20, 201510 yr 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.