Connection pipes do not implement `ICapabilityProvider`
rlnt opened this issue ยท 10 comments
Bug description
Probably related to my previous issue #69
Since you fixed that, I am using the 1.2.9 Alpha version you pushed to CF after the update.
Seems like the energy pipes which connect to outputs (like batteries) don't have a Tile Entity
which means they don't implement ICapabilityProvider
.
This results in not being able to cache them or receive any further information.
Something like
level.getBlockEntity(worldPosition.relative(inputDirection));
where inputDirection
is the Direction
of one of your energy pipes, will simply return null
.
The ICapabilityProvider
is the Interface which provides methods like getCapability()
. I think this should definitely be implemented to have access to the pipe. Otherwise you can't ensure that it's a valid energy provider and you also can't access the capability.
Steps to reproduce the issue
- Place the pipe next to an own block so it tries to insert power.
- Try to access it with
World#getBlockEntity()
- It will return
null
Code
Same as in the other issue, I basically use this to access and cache inputs and outputs: https://forge.gemwire.uk/wiki/Capabilities/1.16#Accessing_a_Capability
Versions
- Minecraft version: 1.16.5
- Forge version: 36.2.4
- Mod version: 1.2.9
Other mods
Lollipop 3.2.9
Powah 2.3.16
This is completely intended. No pipe block has a tile entity, except the extracting ones.
Interesting, your pipes are the only one that do this.
So far, for all tested mods, I was able to get the tile entity.
That's kinda unfortunate since you can't access the energy capability of the last pipe then and there is no way (without eating a lot of resources) to get the extracting pipe just from that.
Guess I'll implement two ways which you can adjust in the config in case someone plays with Pipez so it checks whether the block on the input side is air or not.
Yeah, its a weird way to implement pipes, but I saves a lot on resources having no tileentity.
As far as I know, you can only let tileentities add capabilities.
The pipes are not supposed to connect with other pipes.
And if other pipes would have the wnergy capability they actually would connect.
I tested around with implementing the interface in the block and it seems to work pretty fine. Tile Entities just implement this interface by default.
It would be very helpful to detect that the block is somewhat smart and has some functionality. Pipez is the only mod I need a workaround for which is okay but somewhat annoying. If the capability isn't an option, I might add support with mixins which would reduce my overall code by a lot since I could remove the workaround.
Yeah, the pipes from Pipez connect to other things but nothing is able to connect to a pipe from Pipez because no capability is exposed, that's what I meant.
Especially when it comes to caching and mod compatibility, the capabilities are very handy. That's just a disadvantage of the design to achieve the performance I guess.
Even if the pipes would expose the interface, they won't be able to transfer energy to the other blocks since they themselves wouldn't connect and there is no capability exposed on the other side. So this wouldn't make sense.
It would also make no real sense, since the implemented interface wouldn't expose any real energy functionality.
That doesn't really matter. Exposing an Energy Capability would just be beneficial for mod support. Energy is usually always pushed and not pulled. I just rely on the instanceof ICapabilityProvider
check to ensure a valid connection.
Also many other mods just check for this exact capability interface to rerender their models to show a connection to the adjacent block which in this case would be your cable.
But it would still make no difference, since energy can only be pushed to extracting pipes.
Yeah, its a weird way to implement pipes, but I saves a lot on resources having no tileentity.
Thought about this again. So what this is all about is performance. You only have a TileEntity for the entry pipe which you can configure. The rest of the line is basically dumb and only acts as connection.
Adding a TileEntity would not be ideal. But what about implementing the ICapabapilityProvider
interface for your pipe block. That way other mods could check if it's a capability provider.
Right now, your mod is very unfriendly when it comes to mod compatibility. A lot of workarounds are needed to properly interact with it. Since implementing the interface doesn't need any form of serialization or loading/saving, this shouldn't impact the performance.
This way this would also fix a lot of the ugly model issues. E.g. when you connect your pipes to some cable from another mod and the other cable doesn't connect because it doesn't find a Capability Provider.