[Feature Request] Access transforming
SirEndii opened this issue ยท 7 comments
Hey,
I want to create an add-on for DE, for that I would need access to the fields and methods core
(TileEnergyPylon), lastTickEnergy
(TileEnergyCore) and getCachedCore
(TileReactorComponent) (Probably more in the future).
I just want to ask, am I allowed to create an PR for this to change the access of these methods/fields or create getters for them?
I wanted to prevent that, that's the reason I created this request.
If DE does not change the access of the fields/methods, I will use reflection.
Your best bet would be to use mixin accessors.
For example:
@Mixin (ServerWorld.class)
public interface ServerLevelAccessor {
@Accessor
Int2ObjectMap<Entity> getEntitiesById();
}
Exposes the entitiesByID
field on ServerWorld.
Then to use that you do
ServerWorld world = ...;
Int2ObjectMap<Entity> entitiesById = ((ServerLevelAccessor)world).getEntitiesById();
Thank you for the advice
But I did it already with reflections.
https://github.com/Seniorendi/AdvancedPeripherals/blob/1.16/src/main/java/de/srendi/advancedperipherals/common/addons/draconicevolution/EnergyPylonIntegration.java