-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Bigger baby villager heads (Close #354)
- Loading branch information
1 parent
6fc92c9
commit d1d5de1
Showing
15 changed files
with
110 additions
and
8 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
20 changes: 20 additions & 0 deletions
20
...oscp52/bedrockify/mixin/client/features/babyVillagerHeads/SinglePartEntityModelMixin.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 me.juancarloscp52.bedrockify.mixin.client.features.babyVillagerHeads; | ||
|
||
import net.minecraft.client.render.VertexConsumer; | ||
import net.minecraft.client.render.entity.model.EntityModel; | ||
import net.minecraft.client.render.entity.model.SinglePartEntityModel; | ||
import net.minecraft.client.util.math.MatrixStack; | ||
import net.minecraft.entity.Entity; | ||
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(SinglePartEntityModel.class) | ||
public abstract class SinglePartEntityModelMixin <E extends Entity> extends EntityModel<E> { | ||
|
||
@Inject(method = "render", at = @At("HEAD"), cancellable = true) | ||
protected void injectCustomBabyRender(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, int color, CallbackInfo ci){ | ||
//Empty injection to be modified in child mixin (see https://www.fabricmc.net/wiki/tutorial:mixinheritance) | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
...cp52/bedrockify/mixin/client/features/babyVillagerHeads/VillagerResemblingModelMixin.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,62 @@ | ||
package me.juancarloscp52.bedrockify.mixin.client.features.babyVillagerHeads; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import me.juancarloscp52.bedrockify.client.BedrockifyClient; | ||
import net.minecraft.client.model.ModelPart; | ||
import net.minecraft.client.render.VertexConsumer; | ||
import net.minecraft.client.render.entity.model.EntityModelPartNames; | ||
import net.minecraft.client.render.entity.model.VillagerResemblingModel; | ||
import net.minecraft.client.util.math.MatrixStack; | ||
import net.minecraft.entity.Entity; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
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(VillagerResemblingModel.class) | ||
public abstract class VillagerResemblingModelMixin<T extends Entity> extends SinglePartEntityModelMixin<T> { | ||
|
||
@Shadow @Final private ModelPart rightLeg; | ||
@Shadow @Final private ModelPart leftLeg; | ||
@Shadow @Final private ModelPart head; | ||
@Unique | ||
public ModelPart body; | ||
@Unique | ||
public ModelPart arms; | ||
|
||
@Inject(method = "<init>", at=@At("RETURN")) | ||
private void ctr(ModelPart root, CallbackInfo ci){ | ||
this.body = root.getChild(EntityModelPartNames.BODY); | ||
this.arms = root.getChild(EntityModelPartNames.ARMS); | ||
} | ||
|
||
//Override parent injection with baby villager renderer. For more information see: https://www.fabricmc.net/wiki/tutorial:mixinheritance | ||
@Override | ||
protected void injectCustomBabyRender(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, int color, CallbackInfo ci) { | ||
if(this.child && BedrockifyClient.getInstance().settings.babyVillagerHeads){ | ||
// Render scaled head. | ||
float scale = 1.5f; | ||
matrices.push(); | ||
matrices.scale(scale,scale,scale); | ||
this.getHeadParts().forEach(modelPart -> modelPart.render(matrices,vertices,light,overlay,color)); | ||
matrices.pop(); | ||
|
||
// Render rest of the body. | ||
this.getBodyParts().forEach(modelPart -> modelPart.render(matrices,vertices,light,overlay,color)); | ||
ci.cancel(); | ||
} | ||
} | ||
|
||
@Unique | ||
public Iterable<ModelPart> getHeadParts() { | ||
return ImmutableList.of(this.head); | ||
} | ||
|
||
@Unique | ||
protected Iterable<ModelPart> getBodyParts() { | ||
return ImmutableList.of(this.body, this.rightLeg, this.leftLeg, this.arms); | ||
} | ||
} |
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
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
Oops, something went wrong.