Skip to content

Commit

Permalink
Added double-headed yufeng, as a proof of concept for multi-headed la…
Browse files Browse the repository at this point in the history
…texes
  • Loading branch information
LtxProgrammer committed Nov 9, 2024
1 parent 0981f4e commit fe9c7fc
Show file tree
Hide file tree
Showing 25 changed files with 929 additions and 1 deletion.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.util.Mth;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
Expand Down Expand Up @@ -484,4 +485,12 @@ else if (entity instanceof ChangedEntity changed)
return forEntity(changed);
return null;
}

static Optional<IAbstractChangedEntity> forEitherSafe(Entity entity) {
if (entity instanceof Player player && ProcessTransfur.isPlayerTransfurred(player))
return Optional.of(forPlayer(player));
else if (entity instanceof ChangedEntity changed)
return Optional.of(forEntity(changed));
return Optional.empty();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package net.ltxprogrammer.changed.client.renderer;

import net.ltxprogrammer.changed.Changed;
import net.ltxprogrammer.changed.client.renderer.layers.CustomEyesLayer;
import net.ltxprogrammer.changed.client.renderer.layers.LatexParticlesLayer;
import net.ltxprogrammer.changed.client.renderer.layers.TransfurCapeLayer;
import net.ltxprogrammer.changed.client.renderer.model.DarkLatexDoubleYufengModel;
import net.ltxprogrammer.changed.client.renderer.model.armor.ArmorLatexMaleWingedDragonModel;
import net.ltxprogrammer.changed.entity.beast.DarkLatexDoubleYufeng;
import net.ltxprogrammer.changed.util.Color3;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.resources.ResourceLocation;

public class DarkLatexDoubleYufengRenderer extends AdvancedHumanoidRenderer<DarkLatexDoubleYufeng, DarkLatexDoubleYufengModel, ArmorLatexMaleWingedDragonModel<DarkLatexDoubleYufeng>> {
public DarkLatexDoubleYufengRenderer(EntityRendererProvider.Context context) {
super(context, new DarkLatexDoubleYufengModel(context.bakeLayer(DarkLatexDoubleYufengModel.LAYER_LOCATION)), ArmorLatexMaleWingedDragonModel.MODEL_SET, 0.5f);
this.addLayer(new LatexParticlesLayer<>(this, getModel(), model::isPartNotMask));
this.addLayer(TransfurCapeLayer.normalCape(this, context.getModelSet()));
this.addLayer(CustomEyesLayer.builder(this, context.getModelSet())
.withSclera(Color3.fromInt(0x242424))
.withIris(CustomEyesLayer.fixedIfNotDarkLatexOverrideLeft(Color3.WHITE),
CustomEyesLayer.fixedIfNotDarkLatexOverrideRight(Color3.WHITE))
.build());
}

@Override
public ResourceLocation getTextureLocation(DarkLatexDoubleYufeng p_114482_) {
return Changed.modResource("textures/dark_latex_yufeng.png");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package net.ltxprogrammer.changed.client.renderer.animate.multihead;

import net.ltxprogrammer.changed.client.renderer.animate.HumanoidAnimator;
import net.ltxprogrammer.changed.client.renderer.model.AdvancedHumanoidModel;
import net.ltxprogrammer.changed.entity.ChangedEntity;
import net.ltxprogrammer.changed.entity.beast.DoubleHeadedEntity;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.util.Mth;
import org.jetbrains.annotations.NotNull;

public class DoubleHeadAnimator<T extends ChangedEntity & DoubleHeadedEntity, M extends AdvancedHumanoidModel<T>> extends HumanoidAnimator.Animator<T, M> {
private final ModelPart head;
private final ModelPart head2;

public DoubleHeadAnimator(ModelPart head, ModelPart head2) {
this.head = head;
this.head2 = head2;
}

@Override
public HumanoidAnimator.AnimateStage preferredStage() {
return HumanoidAnimator.AnimateStage.FINAL;
}

private float gap = 4.0f;
private float tilt = Mth.DEG_TO_RAD * 5.0f;
@Override
public void setupAnim(@NotNull T entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
boolean fallFlying = entity.getFallFlyingTicks() > 4;
this.head2.copyFrom(this.head);

float partialTicks = Mth.positiveModulo(ageInTicks, 1.0f);

float head2Yaw = Mth.clamp((entity.getHead2YRot(partialTicks) - Mth.rotLerp(partialTicks, entity.yBodyRotO, entity.yBodyRot)) % 360.0f, -90.0f, 90.0f);
float head2Pitch = entity.getHead2XRot(partialTicks);
head2.yRot = head2Yaw * ((float)Math.PI / 180F);
head2.zRot = 0.0F;
if (fallFlying) {
head2.xRot = (-(float)Math.PI / 4F);
} else if (core.swimAmount > 0.0F) {
if (entity.isVisuallySwimming()) {
head2.xRot = HumanoidAnimator.rotlerpRad(core.swimAmount, head2.xRot, (-(float)Math.PI / 4F));
} else {
head2.xRot = HumanoidAnimator.rotlerpRad(core.swimAmount, head2.xRot, head2Pitch * ((float)Math.PI / 180F));
}
} else {
head2.xRot = head2Pitch * ((float)Math.PI / 180F);
}

this.head.x = -gap;
this.head2.x = gap;
this.head.zRot -= tilt;
this.head2.zRot += tilt;
}
}
Loading

0 comments on commit fe9c7fc

Please sign in to comment.