Jump to content

[1.11.2] [SOLVED] Hwyla does not display energy data


Recommended Posts

Posted (edited)

Hi,

 

I've got the problem that whenever I've got a block which should output energy to a specific side Hwyla

won't display any information about the energy stored in the block.

 

When the block doesn't require a specific side to output the energy it works perfectly fine.

 

Parent class:

    @Override
    public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
        T cap = this.container.getCapability(capability, facing);
        
        /*if(cap == null)
            return super.getCapability(capability, facing);
        else {
            if(facing == null)
                return cap;
            else if(this.getExposedSides().contains(facing))
                return cap;
        }
        return super.getCapability(capability, facing);*/
        
        
        
        /*if(cap != null && facing == null)
            return cap;
        
        boolean flag = facing == null ? (this.getExposedSides().size() > 0 ? true : false) : this.getExposedSides().contains(facing);*/
        
        if(cap != null && facing == null)
            return cap;
        
        return cap != null && this.getExposedSides().contains(facing) ? cap : super.getCapability(capability, facing);
    }
    
    @Override
    public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) {
        if(capability != null && this.container.hasCapability(capability, facing) && facing == null)
            return true;
        
        /*if(this.container.hasCapability(capability, facing) && facing == null)
            return true;
        else if(this.container.hasCapability(capability, facing))
            return true;
        else return false;*/
        
        
        
        /*if(this.container.hasCapability(capability, facing) && facing == null)
            return true;
        
        boolean flag = facing == null ? (this.getExposedSides().size() > 0 ? true : false) : this.getExposedSides().contains(facing);*/
        return (this.container.hasCapability(capability, facing) && this.getExposedSides().contains(facing)) || 
                super.hasCapability(capability, facing);
    }

 

Subclass (the block which doesn't work cause it requires a specific side):

    @Override
    protected EnumSet<EnumFacing> getExposedSides() {
        return EnumSet.of(EnumFacing.DOWN);
    }

 

Note: all code which is commented out was already tested before and didn't work...

 

Quote from Hwyla doc:

Quote

Added native support for Forge Capabilities.

Information is obtained using a null facing. Mods that do not handle this correctly are unsupported.

  • Forge Energy storage and capacity.

    • Displays the blocks currently stored energy and maximum capacity.
    • This feature only works on energy handlers that provide IEnergyStorage.

These features are disabled by default to prevent conflicts with other mods that introduce similar functionality.

 

 

Note 2: I've enabled this feature as my mod currently does not introduce a similar functionality and like described above, it works perfeclty fine with the default implementation of my method getExposedSides.

 

Thx in advance.

Bektor

Edited by Bektor

Developer of Primeval Forest.

Posted

If you can't test Hwyla in dev, create yourself a dummy item that when right-clicked on a block, will query the energy capability from side-null (as that is the side Hwyla uses). Then set a break point in your code and figure out what pathway it takes.

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.

Posted (edited)
On 10/20/2017 at 9:09 PM, Draco18s said:

If you can't test Hwyla in dev, create yourself a dummy item that when right-clicked on a block, will query the energy capability from side-null (as that is the side Hwyla uses). Then set a break point in your code and figure out what pathway it takes.

Hm... seems like that null will return true for hasCapability and return the capability for getCapability, but in Hwyla itself the folliwing line

        if (accessor.getNBTData().hasKey("forgeEnergy") && accessor.getTileEntity().hasCapability(CapabilityEnergy.ENERGY, accessor.getSide())) {

fails. hasKey("forgeEnergy") should return true as accessor.remoteNbt contains the keyword forgeEnergy with my values. Thought the capability of the tile entitiy seems to be null there for some reason I don't know while my energy manager isn't null.

 

EDIT: Seems like it is an incorrect if-statement in the Hwyla version for Minecraft 1.11.2.

Edited by Bektor

Developer of Primeval Forest.

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.