mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-28 23:17:59 +01:00
Fixed guardians not rendering correctly
This commit is contained in:
parent
3fd07b4874
commit
891aa73254
7 changed files with 43 additions and 19 deletions
|
@ -31,7 +31,7 @@ class PonyPreview extends PlayerPreview {
|
|||
@Override
|
||||
public Identifier getDefaultSkin(SkinType type, boolean slim) {
|
||||
if (type == MineLPHDSkins.seaponySkinType) {
|
||||
return DefaultSkinGenerator.generateGreyScale(SeaponyRenderer.TEXTURE, SeaponyRenderer.TEXTURE, getExclusion());
|
||||
return DefaultSkinGenerator.generateGreyScale(SeaponyRenderer.SEAPONY, SeaponyRenderer.SEAPONY, getExclusion());
|
||||
}
|
||||
|
||||
Wearable wearable = MineLPHDSkins.wearableTypes.getOrDefault(type, Wearable.NONE);
|
||||
|
|
|
@ -1,16 +1,12 @@
|
|||
package com.minelittlepony.client.mixin;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityDimensions;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(Entity.class)
|
||||
public interface IResizeable {
|
||||
@Accessor("dimensions")
|
||||
EntityDimensions getCurrentSize();
|
||||
|
||||
@Accessor("dimensions")
|
||||
void setCurrentSize(EntityDimensions size);
|
||||
@Accessor
|
||||
void setStandingEyeHeight(float height);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package com.minelittlepony.client.model.entity;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.entity.model.EntityModel;
|
||||
import net.minecraft.client.render.entity.model.GuardianEntityModel;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.mob.GuardianEntity;
|
||||
import com.minelittlepony.client.model.IPonyMixinModel;
|
||||
import com.minelittlepony.client.model.entity.race.SeaponyModel;
|
||||
|
@ -18,4 +21,25 @@ public class GuardianPonyModel extends GuardianEntityModel implements IPonyMixin
|
|||
public SeaponyModel<GuardianEntity> mixin() {
|
||||
return mixin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) {
|
||||
mixin().render(matrices, vertices, light, overlay, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void animateModel(GuardianEntity entity, float limbAngle, float limbDistance, float tickDelta) {
|
||||
mixin().animateModel(entity, limbAngle, limbDistance, tickDelta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyStateTo(EntityModel<GuardianEntity> copy) {
|
||||
mixin().copyStateTo(copy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAngles(GuardianEntity entity, float limbAngle, float limbSpeed, float animationProgress, float headYaw, float headPitch) {
|
||||
mixin().setVisible(true);
|
||||
mixin().setAngles(entity, limbAngle, limbSpeed, animationProgress, headYaw, headPitch);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,27 +11,32 @@ import net.minecraft.client.render.VertexConsumerProvider;
|
|||
import net.minecraft.client.render.entity.EntityRendererFactory;
|
||||
import net.minecraft.client.render.entity.GuardianEntityRenderer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.EntityDimensions;
|
||||
import net.minecraft.entity.mob.ElderGuardianEntity;
|
||||
import net.minecraft.entity.mob.GuardianEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class SeaponyRenderer extends GuardianEntityRenderer {
|
||||
public static final Identifier TEXTURE = new Identifier("minelittlepony", "textures/entity/seapony.png");
|
||||
public static final Identifier SEAPONY = new Identifier("minelittlepony", "textures/entity/guardian/blueball.png");
|
||||
private static final Identifier SEAPONY_TEXTURES = new Identifier("minelittlepony", "textures/entity/guardian");
|
||||
public static final Identifier ELDER_SEAPONY = new Identifier("minelittlepony", "textures/entity/elder_guardian/blueball.png");
|
||||
private static final Identifier ELDER_SEAPONY_TEXTURES = new Identifier("minelittlepony", "textures/entity/elder_guardian");
|
||||
|
||||
private final AbstractPonyRenderer<GuardianEntity, GuardianPonyModel> ponyRenderer;
|
||||
|
||||
public SeaponyRenderer(EntityRendererFactory.Context context, float scale) {
|
||||
private final float scale;
|
||||
|
||||
public SeaponyRenderer(EntityRendererFactory.Context context, TextureSupplier<GuardianEntity> texture, float scale) {
|
||||
super(context);
|
||||
ponyRenderer = AbstractPonyRenderer.proxy(context, ModelType.GUARDIAN, TextureSupplier.of(TEXTURE), scale, features, m -> model = m);
|
||||
ponyRenderer = AbstractPonyRenderer.proxy(context, ModelType.GUARDIAN, texture, scale, features, m -> model = m);
|
||||
this.scale = scale;
|
||||
}
|
||||
|
||||
public static SeaponyRenderer guardian(EntityRendererFactory.Context context) {
|
||||
return new SeaponyRenderer(context, 1);
|
||||
return new SeaponyRenderer(context, TextureSupplier.ofPool(SEAPONY_TEXTURES, TextureSupplier.of(SEAPONY)), 1);
|
||||
}
|
||||
|
||||
public static SeaponyRenderer elder(EntityRendererFactory.Context context) {
|
||||
return new SeaponyRenderer(context, 1);
|
||||
return new SeaponyRenderer(context, TextureSupplier.ofPool(ELDER_SEAPONY_TEXTURES, TextureSupplier.of(SEAPONY)), ElderGuardianEntity.SCALE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -47,14 +52,13 @@ public class SeaponyRenderer extends GuardianEntityRenderer {
|
|||
|
||||
@Override
|
||||
public void render(GuardianEntity entity, float entityYaw, float tickDelta, MatrixStack stack, VertexConsumerProvider renderContext, int lightUv) {
|
||||
IResizeable resize = (IResizeable)entity;
|
||||
EntityDimensions origin = resize.getCurrentSize();
|
||||
ponyRenderer.manager.preRenderCallback(entity, stack, tickDelta);
|
||||
|
||||
float height = entity.getStandingEyeHeight();
|
||||
|
||||
// aligns the beam to their horns
|
||||
resize.setCurrentSize(EntityDimensions.changing(origin.width, entity instanceof ElderGuardianEntity ? 6 : 3));
|
||||
|
||||
((IResizeable)entity).setStandingEyeHeight(2 * scale * ponyRenderer.manager.getScaleFactor());
|
||||
super.render(entity, entityYaw, tickDelta, stack, renderContext, lightUv);
|
||||
|
||||
resize.setCurrentSize(origin);
|
||||
((IResizeable)entity).setStandingEyeHeight(height);
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 8.8 KiB |
Binary file not shown.
After Width: | Height: | Size: 8.8 KiB |
Binary file not shown.
Before Width: | Height: | Size: 4.8 KiB |
Loading…
Reference in a new issue