-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
166 additions
and
6 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
85 changes: 85 additions & 0 deletions
85
src/main/java/com/ninni/spawn/client/model/BatRemodel.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,85 @@ | ||
package com.ninni.spawn.client.model; | ||
|
||
import net.minecraft.client.model.BatModel; | ||
import net.minecraft.client.model.geom.ModelPart; | ||
import net.minecraft.client.model.geom.PartPose; | ||
import net.minecraft.client.model.geom.builders.*; | ||
import net.minecraft.util.Mth; | ||
import net.minecraft.world.entity.ambient.Bat; | ||
|
||
public class BatRemodel extends BatModel { | ||
private final ModelPart root; | ||
private final ModelPart head; | ||
private final ModelPart body; | ||
private final ModelPart rightWing; | ||
private final ModelPart leftWing; | ||
private final ModelPart rightWingTip; | ||
private final ModelPart leftWingTip; | ||
|
||
public BatRemodel(ModelPart modelPart) { | ||
super(modelPart); | ||
this.root = modelPart; | ||
this.head = modelPart.getChild("head"); | ||
this.body = modelPart.getChild("body"); | ||
this.rightWing = this.body.getChild("right_wing"); | ||
this.rightWingTip = this.rightWing.getChild("right_wing_tip"); | ||
this.leftWing = this.body.getChild("left_wing"); | ||
this.leftWingTip = this.leftWing.getChild("left_wing_tip"); | ||
} | ||
|
||
@Override | ||
public void setupAnim(Bat bat, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) { | ||
float pi = (float) Math.PI; | ||
|
||
this.head.xRot = headPitch * (pi / 180); | ||
this.head.yRot = headYaw * (pi / 180); | ||
|
||
if (bat.isResting()) { | ||
this.head.xRot = pi; | ||
this.head.setPos(0.0f, 16.0f, 0.0f); | ||
this.body.xRot = pi; | ||
this.rightWing.xRot = -0.2f; | ||
this.rightWing.yRot = -1.2f; | ||
this.rightWingTip.yRot = -2f; | ||
this.leftWing.xRot = this.rightWing.xRot; | ||
this.leftWing.yRot = -this.rightWing.yRot; | ||
this.leftWingTip.yRot = -this.rightWingTip.yRot; | ||
} else { | ||
this.body.xRot = Mth.sin(animationProgress * 0.3f) * -0.2f + 0.6f; | ||
this.head.y = Mth.cos(animationProgress * 0.3f) * -0.2f + 16f; | ||
this.rightWing.xRot = Mth.sin(animationProgress * 0.9f + pi) * 0.25f; | ||
this.rightWing.yRot = Mth.cos(animationProgress * 0.9f + pi) * 1.25f; | ||
this.rightWingTip.yRot = Mth.cos(animationProgress * 0.9f + pi) * 0.5f; | ||
this.leftWing.xRot = Mth.sin(animationProgress * 0.9f) * 0.25f; | ||
this.leftWing.yRot = Mth.cos(animationProgress * 0.9f) * 1.25f; | ||
this.leftWingTip.yRot = Mth.cos(animationProgress * 0.9f) * 0.5f; | ||
} | ||
} | ||
|
||
@Override | ||
public ModelPart root() { | ||
return this.root; | ||
} | ||
|
||
public static LayerDefinition createRemodel() { | ||
MeshDefinition meshdefinition = new MeshDefinition(); | ||
PartDefinition partdefinition = meshdefinition.getRoot(); | ||
|
||
PartDefinition head = partdefinition.addOrReplaceChild("head", CubeListBuilder.create().texOffs(0, 0).addBox(-2.5F, -4.0F, -2.0F, 5.0F, 4.0F, 4.0F, new CubeDeformation(0.0F)) | ||
.texOffs(14, 0).addBox(1.5F, -6.0F, 0.0F, 2.0F, 3.0F, 1.0F, new CubeDeformation(0.0F)) | ||
.texOffs(14, 0).mirror().addBox(-3.5F, -6.0F, 0.0F, 2.0F, 3.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offset(0.0F, 16.0F, 0.0F)); | ||
|
||
PartDefinition body = partdefinition.addOrReplaceChild("body", CubeListBuilder.create().texOffs(0, 8).addBox(-2.0F, -0.5F, -1.0F, 4.0F, 5.0F, 2.0F, new CubeDeformation(0.0F)) | ||
.texOffs(12, 8).addBox(-1.5F, 4.5F, 0.0F, 3.0F, 3.0F, 0.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 16.5F, 0.0F)); | ||
|
||
PartDefinition left_wing = body.addOrReplaceChild("left_wing", CubeListBuilder.create().texOffs(0, 15).addBox(0.0F, -3.0F, 0.0F, 5.0F, 7.0F, 0.0F, new CubeDeformation(0.0F)), PartPose.offset(2.0F, 0.5F, 0.5F)); | ||
|
||
PartDefinition left_wing_tip = left_wing.addOrReplaceChild("left_wing_tip", CubeListBuilder.create().texOffs(10, 15).addBox(0.0F, -2.0F, 0.0F, 5.0F, 7.0F, 0.0F, new CubeDeformation(0.0F)), PartPose.offset(5.0F, -1.0F, 0.0F)); | ||
|
||
PartDefinition right_wing = body.addOrReplaceChild("right_wing", CubeListBuilder.create().texOffs(0, 15).mirror().addBox(-5.0F, -3.0F, 0.0F, 5.0F, 7.0F, 0.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offset(-2.0F, 0.5F, 0.5F)); | ||
|
||
PartDefinition right_wing_tip = right_wing.addOrReplaceChild("right_wing_tip", CubeListBuilder.create().texOffs(10, 15).mirror().addBox(-5.0F, -2.0F, 0.0F, 5.0F, 7.0F, 0.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offset(-5.0F, -1.0F, 0.0F)); | ||
|
||
return LayerDefinition.create(meshdefinition, 32, 32); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/com/ninni/spawn/mixin/client/BatRendererMixin.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,48 @@ | ||
package com.ninni.spawn.mixin.client; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import com.ninni.spawn.SpawnRPTweaks; | ||
import com.ninni.spawn.client.model.BatRemodel; | ||
import com.ninni.spawn.client.model.RabbitRemodel; | ||
import com.ninni.spawn.registry.SpawnEntityModelLayers; | ||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.minecraft.client.model.BatModel; | ||
import net.minecraft.client.model.RabbitModel; | ||
import net.minecraft.client.renderer.MultiBufferSource; | ||
import net.minecraft.client.renderer.entity.BatRenderer; | ||
import net.minecraft.client.renderer.entity.EntityRendererProvider; | ||
import net.minecraft.client.renderer.entity.MobRenderer; | ||
import net.minecraft.client.renderer.entity.RabbitRenderer; | ||
import net.minecraft.world.entity.ambient.Bat; | ||
import net.minecraft.world.entity.animal.Rabbit; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(BatRenderer.class) | ||
@Environment(value= EnvType.CLIENT) | ||
public abstract class BatRendererMixin extends MobRenderer<Bat, BatModel> { | ||
private BatRemodel remodel; | ||
|
||
public BatRendererMixin(EntityRendererProvider.Context context, BatModel entityModel, float f) { | ||
super(context, entityModel, f); | ||
} | ||
|
||
@Inject(method = "<init>", at = @At("TAIL")) | ||
private void S$init(EntityRendererProvider.Context context, CallbackInfo ci) { | ||
this.remodel = new BatRemodel(context.bakeLayer(SpawnEntityModelLayers.BAT_REMODEL)); | ||
} | ||
|
||
@Inject(method = "scale(Lnet/minecraft/world/entity/ambient/Bat;Lcom/mojang/blaze3d/vertex/PoseStack;F)V", at = @At("HEAD"), cancellable = true) | ||
private void S$scale(Bat bat, PoseStack poseStack, float f, CallbackInfo ci) { | ||
if (SpawnRPTweaks.isPresent(SpawnRPTweaks.Tweaks.BAT_REMODEL)) ci.cancel(); | ||
} | ||
|
||
@Override | ||
public void render(Bat mob, float f, float g, PoseStack poseStack, MultiBufferSource multiBufferSource, int i) { | ||
if (SpawnRPTweaks.isPresent(SpawnRPTweaks.Tweaks.BAT_REMODEL)) this.model = this.remodel; | ||
super.render(mob, f, g, poseStack, multiBufferSource, i); | ||
} | ||
} |
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
Binary file added
BIN
+585 Bytes
.../resources/resourcepacks/animal_tweaks/assets/minecraft/textures/entity/bat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions
15
src/main/resources/resourcepacks/animal_tweaks/assets/minecraft/tweaks/bat_remodel.txt
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,15 @@ | ||
|
||
|
||
* This tweak enables a new bat model with new animations and textures. | ||
|
||
|
||
|
||
What is a Tweak? | ||
|
||
Tweaks are client side modifications. | ||
They are .txt files stored in the "minecraft/tweaks/" folder of resource packs, | ||
each of them alters specific aspects of your game as long as Spawn is installed. | ||
By including the desired tweaks in your resource pack, you can selectively activate features like model enhancements, animation freshen-ups and visual changes. | ||
The "Animal Tweaks" resource pack, bundled with Spawn, automatically contains all available tweaks for you to choose from, go check the GitHub to see! | ||
|
||
https://github.com/N1nn1/spawn/tree/update-2/src/main/resources/resourcepacks/animal_tweaks |
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