3 ms·
A primary advantage of Mixin is using Java as a DSL to apply various kinds of bytecode transformation with some examples here: - Changing a constant within a t
by gabizou 2y ago
A primary advantage of Mixin is using Java as a DSL to apply various kinds of bytecode transformation with some examples here:
- Changing a constant within a target method https://github.com/SpongePowered/Sponge/blob/06ebd1d3479b9edda29d7de58c036b49db3d0928/src/mixins/java/org/spongepowered/common/mixin/movementcheck/server/network/ServerGamePacketListenerImplMixin_MovementCheck.java#L42-L54 https://github.com/SpongePowered/Sponge/blob/06ebd1d3479b9ed...
- Replacing a method call within a specific method https://github.com/SpongePowered/Sponge/blob/06ebd1d3479b9edda29d7de58c036b49db3d0928/src/mixins/java/org/spongepowered/common/mixin/tracker/server/level/ServerLevelMixin_Tracker.java#L175-L180 https://github.com/SpongePowered/Sponge/blob/06ebd1d3479b9ed...
- Adding an interface and its implementation to the target class (in this case net.minecraft.world.entity.Entity will now implement org.spongepowered.api.entity.Entity and its methods) https://github.com/SpongePowered/Sponge/blob/06ebd1d3479b9edda29d7de58c036b49db3d0928/src/mixins/java/org/spongepowered/common/mixin/api/minecraft/world/entity/EntityMixin_API.java#L81 https://github.com/SpongePowered/Sponge/blob/06ebd1d3479b9ed...
There's a fair bit more that is possible that would otherwise require a fair bit more code wrangling with AspectJ or BytecodeBuddy to achieve the same effects.