Posted September 16, 201510 yr Hello! So I made a solar panel that is supposed to send RF out of its storage and into blocks that wants to receive. I made the panel start generating energy if sun is up, but why is it it not sending the storage into other blocks like a Leadstone Energy Cell etc? I saved storage to NBT and tile is implementing IEnergyProvider. Any help and/or tips are very much appriciated! TileSolarPanel: // RF Stuff public EnergyStorage storage; public static int CAPACITY = 100000; public static int MAX_RECEIVE = 0; public static int MAX_EXTRACT = 512; public TileEntitySolarPanel(){ storage = new EnergyStorage(CAPACITY, MAX_RECEIVE, MAX_EXTRACT); } @Override public boolean canConnectEnergy(ForgeDirection from) { return true; } @Override public int getEnergyStored(ForgeDirection from){ return storage.getEnergyStored(); } public int getEnergyStored(){ return storage.getEnergyStored(); } @Override public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { return storage.extractEnergy(maxExtract, simulate); } public int getMaxEnergyStored(){ return storage.getMaxEnergyStored(); } @Override public int getMaxEnergyStored(ForgeDirection from){ return storage.getMaxEnergyStored(); }
September 16, 201510 yr If you want other energy using blocks to be able to actively pull from your solar panel, your current implementation will work fine. If you want your solar panel to actively push into adjacent RF accepting blocks, you will need to add some code. In the updatEntity method of your TE you will need to iterate over all the valid directions, and for each direction, check if the tile entity is A) not null, B) an IEnergyReceiver, and C) can connect on that side. If all of these conditions are true, you can call receiveEnergy on the TileEntity with the correct amount of energy. Side note: If you wanted to improve upon this implementation, you could only check 1 direction every tick (instead of all 6 every tick) to improve on server-side performance a bit. Example: @Override public void updateEntity() { // generate if (storage.getEnergyStored() > 0) { // is there energy to send for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { TileEntity te = world.getTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ); if (te instanceof IEnergyReceiver) { IEnergyReceiver receiver = (IEnergyReceiver)te; int toExtract = receiver.receiveEnergy(dir.getOpposite(), extractEnergy(dir, MAX_EXTRACT, true), false); extractEnergy(dir, toExtract, false); } } } } Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods
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.