-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add(relevant mixins + interfaces for animation)
- Loading branch information
Showing
3 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
src/main/java/elocindev/shield_overhaul/mixin/ClientPlayerEntityMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package elocindev.shield_overhaul.mixin; | ||
|
||
|
||
import com.mojang.authlib.GameProfile; | ||
import dev.kosmx.playerAnim.api.layered.IAnimation; | ||
import dev.kosmx.playerAnim.api.layered.ModifierLayer; | ||
import dev.kosmx.playerAnim.minecraftApi.PlayerAnimationAccess; | ||
import elocindev.shield_overhaul.util.IShieldAnimatedPlayer; | ||
import net.minecraft.client.network.AbstractClientPlayerEntity; | ||
import net.minecraft.client.world.ClientWorld; | ||
import net.minecraft.network.encryption.PlayerPublicKey; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(AbstractClientPlayerEntity.class) | ||
public class ClientPlayerEntityMixin implements IShieldAnimatedPlayer { | ||
|
||
//Unique annotation will rename private methods/fields if needed to avoid collisions. | ||
@Unique | ||
private final ModifierLayer<IAnimation> modAnimationContainer = new ModifierLayer<>(); | ||
|
||
/** | ||
* Add the animation registration to the end of the constructor | ||
* Or you can use {@link dev.kosmx.playerAnim.minecraftApi.PlayerAnimationAccess#REGISTER_ANIMATION_EVENT} event for this | ||
*/ | ||
@Inject(method = "<init>", at = @At(value = "RETURN")) | ||
private void init(ClientWorld world, GameProfile profile, PlayerPublicKey publicKey, CallbackInfo ci) { | ||
//Mixin does not know (yet) that this will be merged with AbstractClientPlayerEntity | ||
PlayerAnimationAccess.getPlayerAnimLayer((AbstractClientPlayerEntity) (Object)this).addAnimLayer(1000, modAnimationContainer); //Register the layer with a priority | ||
//The priority will tell, how important is this animation compared to other mods. Higher number means higher priority | ||
//Mods with higher priority will override the lower priority mods (if they want to animation anything) | ||
} | ||
|
||
/** | ||
* Override the interface function, so we can use it in the future | ||
*/ | ||
@Override | ||
public ModifierLayer<IAnimation> shield_overhaul_getModAnimation() { | ||
return modAnimationContainer; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/elocindev/shield_overhaul/util/IShieldAnimatedPlayer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package elocindev.shield_overhaul.util; | ||
|
||
import dev.kosmx.playerAnim.api.layered.IAnimation; | ||
import dev.kosmx.playerAnim.api.layered.ModifierLayer; | ||
|
||
public interface IShieldAnimatedPlayer { | ||
ModifierLayer<IAnimation> shield_overhaul_getModAnimation(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters