generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cape customization + fix sneaking bugs
- Loading branch information
Showing
13 changed files
with
205 additions
and
10 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
22 changes: 22 additions & 0 deletions
22
src/main/java/btw/mixces/animatium/mixins/model/item/MixinElytraAnimationState.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,22 @@ | ||
package btw.mixces.animatium.mixins.model.item; | ||
|
||
import btw.mixces.animatium.AnimatiumClient; | ||
import btw.mixces.animatium.config.AnimatiumConfig; | ||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation; | ||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; | ||
import net.minecraft.world.entity.ElytraAnimationState; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
@Mixin(ElytraAnimationState.class) | ||
public class MixinElytraAnimationState { | ||
@WrapOperation(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;isCrouching()Z")) | ||
private boolean animatium$sneakAnimationWhileFlying(LivingEntity instance, Operation<Boolean> original) { | ||
if (AnimatiumClient.getEnabled() && AnimatiumConfig.instance().getSneakAnimationWhileFlying()) { | ||
return instance.isShiftKeyDown(); | ||
} else { | ||
return original.call(instance); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/btw/mixces/animatium/mixins/model/item/MixinElytraModel.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,20 @@ | ||
package btw.mixces.animatium.mixins.model.item; | ||
|
||
import btw.mixces.animatium.AnimatiumClient; | ||
import btw.mixces.animatium.config.AnimatiumConfig; | ||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue; | ||
import net.minecraft.client.model.ElytraModel; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
@Mixin(ElytraModel.class) | ||
public class MixinElytraModel { | ||
@ModifyExpressionValue(method = "setupAnim(Lnet/minecraft/client/renderer/entity/state/HumanoidRenderState;)V", at = @At(value = "CONSTANT", args = "floatValue=3.0")) | ||
private float animatium$fixSneakTranslationWhileFlying(float original) { | ||
if (AnimatiumClient.getEnabled() && AnimatiumConfig.instance().getOldSneakingFeetPosition()) { | ||
return 0.0F; | ||
} else { | ||
return original; | ||
} | ||
} | ||
} |
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
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
46 changes: 46 additions & 0 deletions
46
src/main/java/btw/mixces/animatium/mixins/renderer/entity/layer/MixinCapeLayer.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,46 @@ | ||
package btw.mixces.animatium.mixins.renderer.entity.layer; | ||
|
||
import btw.mixces.animatium.AnimatiumClient; | ||
import btw.mixces.animatium.config.AnimatiumConfig; | ||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue; | ||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import net.minecraft.client.model.HumanoidModel; | ||
import net.minecraft.client.renderer.MultiBufferSource; | ||
import net.minecraft.client.renderer.entity.layers.CapeLayer; | ||
import net.minecraft.client.renderer.entity.state.PlayerRenderState; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(CapeLayer.class) | ||
public abstract class MixinCapeLayer { | ||
@Shadow | ||
@Final | ||
private HumanoidModel<PlayerRenderState> model; | ||
|
||
@ModifyExpressionValue(method = "render(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;ILnet/minecraft/client/renderer/entity/state/PlayerRenderState;FF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/layers/CapeLayer;hasLayer(Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/client/resources/model/EquipmentClientInfo$LayerType;)Z", ordinal = 1)) | ||
private boolean animatium$removeChestplateCheck(boolean original) { | ||
if (AnimatiumClient.getEnabled() && AnimatiumConfig.instance().getCapeChestplateTranslation()) { | ||
return false; | ||
} else { | ||
return original; | ||
} | ||
} | ||
|
||
@Inject(method = "render(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;ILnet/minecraft/client/renderer/entity/state/PlayerRenderState;FF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/MultiBufferSource;getBuffer(Lnet/minecraft/client/renderer/RenderType;)Lcom/mojang/blaze3d/vertex/VertexConsumer;")) | ||
private void animatium$capeSneakingOffset(PoseStack poseStack, MultiBufferSource multiBufferSource, int i, PlayerRenderState playerRenderState, float f, float g, CallbackInfo ci) { | ||
if (AnimatiumClient.getEnabled() && AnimatiumConfig.instance().getOldCapePosition() && playerRenderState.isCrouching) { | ||
poseStack.translate(0.0F, playerRenderState.scale * 2.0F / 16.0F, 0.0F); | ||
} | ||
} | ||
|
||
@Inject(method = "render(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;ILnet/minecraft/client/renderer/entity/state/PlayerRenderState;FF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/model/HumanoidModel;setupAnim(Lnet/minecraft/client/renderer/entity/state/HumanoidRenderState;)V", shift = At.Shift.AFTER)) | ||
private void animatium$capeSwingRotation(PoseStack poseStack, MultiBufferSource multiBufferSource, int i, PlayerRenderState playerRenderState, float f, float g, CallbackInfo ci) { | ||
if (AnimatiumClient.getEnabled() && AnimatiumConfig.instance().getCapeSwingRotation()) { | ||
model.body.yRot = 0; | ||
} | ||
} | ||
} |
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
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