generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
pose
power type and change impl. of crawling
power type
* The `crawling` power type now uses the `pose` power type as its base
- Loading branch information
Showing
8 changed files
with
133 additions
and
22 deletions.
There are no files selected for viewing
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
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
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
52 changes: 52 additions & 0 deletions
52
src/main/java/io/github/eggohito/eggolib/mixin/PlayerEntityRendererMixin.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,52 @@ | ||
package io.github.eggohito.eggolib.mixin; | ||
|
||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue; | ||
import com.llamalad7.mixinextras.sugar.Share; | ||
import com.llamalad7.mixinextras.sugar.ref.LocalBooleanRef; | ||
import net.minecraft.client.network.AbstractClientPlayerEntity; | ||
import net.minecraft.client.render.entity.EntityRendererFactory; | ||
import net.minecraft.client.render.entity.LivingEntityRenderer; | ||
import net.minecraft.client.render.entity.PlayerEntityRenderer; | ||
import net.minecraft.client.render.entity.model.PlayerEntityModel; | ||
import net.minecraft.entity.EntityPose; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
@Mixin(PlayerEntityRenderer.class) | ||
public abstract class PlayerEntityRendererMixin extends LivingEntityRenderer<AbstractClientPlayerEntity, PlayerEntityModel<AbstractClientPlayerEntity>> { | ||
|
||
private PlayerEntityRendererMixin(EntityRendererFactory.Context ctx, PlayerEntityModel<AbstractClientPlayerEntity> model, float shadowRadius) { | ||
super(ctx, model, shadowRadius); | ||
} | ||
|
||
@Unique | ||
private int eggolib$pseudoRoll = 0; | ||
|
||
@ModifyExpressionValue(method = "setupTransforms(Lnet/minecraft/client/network/AbstractClientPlayerEntity;Lnet/minecraft/client/util/math/MatrixStack;FFF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;isFallFlying()Z")) | ||
private boolean eggolib$inFallFlyingPose(boolean original, AbstractClientPlayerEntity player, @Share("applyPseudoRoll") LocalBooleanRef applyPseudoRollRef) { | ||
|
||
if (original || player.isInPose(EntityPose.FALL_FLYING)) { | ||
|
||
if (player.isInPose(EntityPose.FALL_FLYING)) { | ||
applyPseudoRollRef.set(true); | ||
++eggolib$pseudoRoll; | ||
} | ||
|
||
return true; | ||
|
||
} | ||
|
||
this.eggolib$pseudoRoll = 0; | ||
return false; | ||
|
||
} | ||
|
||
@ModifyExpressionValue(method = "setupTransforms(Lnet/minecraft/client/network/AbstractClientPlayerEntity;Lnet/minecraft/client/util/math/MatrixStack;FFF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;getRoll()I")) | ||
private int eggolib$applyPseudoRoll(int original, AbstractClientPlayerEntity player, @Share("applyPseudoRoll") LocalBooleanRef applyPseudoRollRef) { | ||
return applyPseudoRollRef.get() | ||
? eggolib$pseudoRoll | ||
: original; | ||
} | ||
|
||
} |
22 changes: 8 additions & 14 deletions
22
src/main/java/io/github/eggohito/eggolib/power/CrawlingPower.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
49 changes: 49 additions & 0 deletions
49
src/main/java/io/github/eggohito/eggolib/power/PosePower.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,49 @@ | ||
package io.github.eggohito.eggolib.power; | ||
|
||
import io.github.apace100.apoli.power.Power; | ||
import io.github.apace100.apoli.power.PowerType; | ||
import io.github.apace100.apoli.power.Prioritized; | ||
import io.github.apace100.apoli.power.factory.PowerFactory; | ||
import io.github.apace100.calio.data.SerializableData; | ||
import io.github.apace100.calio.data.SerializableDataTypes; | ||
import io.github.eggohito.eggolib.Eggolib; | ||
import io.github.eggohito.eggolib.data.EggolibDataTypes; | ||
import net.minecraft.entity.EntityPose; | ||
import net.minecraft.entity.LivingEntity; | ||
|
||
public class PosePower extends Power implements Prioritized<PosePower> { | ||
|
||
private final EntityPose pose; | ||
private final int priority; | ||
|
||
public PosePower(PowerType<?> type, LivingEntity entity, EntityPose pose, int priority) { | ||
super(type, entity); | ||
this.pose = pose; | ||
this.priority = priority; | ||
} | ||
|
||
@Override | ||
public int getPriority() { | ||
return priority; | ||
} | ||
|
||
public EntityPose getPose() { | ||
return pose; | ||
} | ||
|
||
public static PowerFactory<?> getFactory() { | ||
return new PowerFactory<>( | ||
Eggolib.identifier("pose"), | ||
new SerializableData() | ||
.add("pose", EggolibDataTypes.ENTITY_POSE) | ||
.add("priority", SerializableDataTypes.INT, 0), | ||
data -> (powerType, entity) -> new PosePower( | ||
powerType, | ||
entity, | ||
data.get("pose"), | ||
data.get("priority") | ||
) | ||
).allowCondition(); | ||
} | ||
|
||
} |
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
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