mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-22 04:27:59 +01:00
Improved compatibility with not enough animations (maps) #235
This commit is contained in:
parent
77584ea2fa
commit
d97403fd26
17 changed files with 163 additions and 229 deletions
|
@ -10,8 +10,8 @@ import java.util.*;
|
|||
|
||||
import net.minecraft.client.render.entity.model.BipedEntityModel.ArmPose;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.util.Arm;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
|
@ -110,6 +110,11 @@ public class ModelAttributes {
|
|||
*/
|
||||
public IPonyData metadata = PonyData.NULL;
|
||||
|
||||
public Arm mainArm;
|
||||
public Hand activeHand;
|
||||
public ItemStack heldStack = ItemStack.EMPTY;
|
||||
public int itemUseTime;
|
||||
|
||||
/**
|
||||
* Checks flying and speed conditions and sets rainboom to true if we're a species with wings and is going faaast.
|
||||
*/
|
||||
|
@ -154,6 +159,9 @@ public class ModelAttributes {
|
|||
isLeftHanded = entity.getMainArm() == Arm.LEFT;
|
||||
isHorsey = MineLittlePony.getInstance().getConfig().horsieMode.get();
|
||||
featureSkins = SkinsProxy.instance.getAvailableSkins(entity);
|
||||
mainArm = entity.getMainArm();
|
||||
activeHand = entity.getActiveHand();
|
||||
itemUseTime = entity.getItemUseTimeLeft();
|
||||
}
|
||||
|
||||
public Interpolator getMainInterpolator() {
|
||||
|
|
|
@ -16,7 +16,7 @@ import net.minecraft.client.model.ModelPart;
|
|||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.util.Arm;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.*;
|
||||
|
||||
/**
|
||||
|
@ -560,6 +560,38 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
|||
parts.forEach(part -> part.setVisible(visible, attributes));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setArmAngle(Arm arm, MatrixStack matrices) {
|
||||
super.setArmAngle(arm, matrices);
|
||||
positionheldItem(arm, matrices);
|
||||
}
|
||||
|
||||
protected void positionheldItem(Arm arm, MatrixStack matrices) {
|
||||
float left = arm == Arm.LEFT ? -1 : 1;
|
||||
|
||||
UseAction action = getAttributes().heldStack.getUseAction();
|
||||
|
||||
if (action == UseAction.SPYGLASS && getAttributes().itemUseTime > 0) {
|
||||
|
||||
Arm main = getAttributes().mainArm;
|
||||
if (getAttributes().activeHand == Hand.OFF_HAND) {
|
||||
main = main.getOpposite();
|
||||
}
|
||||
if (main == arm) {
|
||||
matrices.translate(left * -0.05F, 0.5F, 0.2F);
|
||||
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(-60));
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (getAttributes().isRidingInteractive) {
|
||||
matrices.translate(left / 10, -0.2F, -0.5F);
|
||||
}
|
||||
|
||||
matrices.translate(left * 0.1F, 0.45F, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transform(BodyPart part, MatrixStack stack) {
|
||||
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
package com.minelittlepony.client.model;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.entity.model.*;
|
||||
import net.minecraft.client.render.model.json.ModelTransformationMode;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Arm;
|
||||
import net.minecraft.util.Hand;
|
||||
|
||||
|
@ -23,7 +27,7 @@ import com.minelittlepony.mson.api.model.biped.MsonPlayer;
|
|||
*
|
||||
* Modders can extend this class to make their own pony models if they wish.
|
||||
*/
|
||||
public abstract class ClientPonyModel<T extends LivingEntity> extends MsonPlayer<T> implements IPonyModel<T>, ModelWithHat {
|
||||
public abstract class ClientPonyModel<T extends LivingEntity> extends MsonPlayer<T> implements IPonyModel<T>, ModelWithHat, ModelWithArms {
|
||||
|
||||
/**
|
||||
* The model attributes.
|
||||
|
@ -106,6 +110,10 @@ public abstract class ClientPonyModel<T extends LivingEntity> extends MsonPlayer
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postItemRender(IPony pony, T entity, ItemStack drop, ModelTransformationMode transform, Arm hand, MatrixStack stack, VertexConsumerProvider renderContext) {
|
||||
}
|
||||
|
||||
static void resetPivot(ModelPart part) {
|
||||
part.setPivot(part.getDefaultTransform().pivotX, part.getDefaultTransform().pivotY, part.getDefaultTransform().pivotZ);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package com.minelittlepony.client.model;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
||||
import net.minecraft.client.render.entity.model.ModelWithArms;
|
||||
import net.minecraft.client.render.model.json.ModelTransformationMode;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Arm;
|
||||
|
||||
import com.minelittlepony.api.model.BodyPart;
|
||||
|
@ -90,6 +93,11 @@ public interface IPonyMixinModel<T extends LivingEntity, M extends IPonyModel<T>
|
|||
return mixin().getBodyPart(part);
|
||||
}
|
||||
|
||||
@Override
|
||||
default void postItemRender(IPony pony, T entity, ItemStack drop, ModelTransformationMode transform, Arm hand, MatrixStack stack, VertexConsumerProvider renderContext) {
|
||||
mixin().postItemRender(pony, entity, drop, transform, hand, stack, renderContext);
|
||||
}
|
||||
|
||||
interface Caster<T extends LivingEntity, M extends IPonyModel<T> & IUnicorn, ArmModel> extends IPonyMixinModel<T, M>, IUnicorn {
|
||||
@Override
|
||||
default boolean isCasting() {
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
package com.minelittlepony.client.model;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
||||
import net.minecraft.client.render.entity.model.ModelWithArms;
|
||||
import net.minecraft.client.render.model.json.ModelTransformationMode;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Arm;
|
||||
|
||||
import com.minelittlepony.api.model.BodyPart;
|
||||
import com.minelittlepony.api.model.ICapitated;
|
||||
|
@ -11,11 +17,13 @@ import com.minelittlepony.api.model.ModelAttributes;
|
|||
import com.minelittlepony.api.pony.IPony;
|
||||
import com.minelittlepony.mson.api.MsonModel;
|
||||
|
||||
public interface IPonyModel<T extends LivingEntity> extends IModel, ICapitated<ModelPart>, MsonModel {
|
||||
public interface IPonyModel<T extends LivingEntity> extends IModel, ICapitated<ModelPart>, ModelWithArms, MsonModel {
|
||||
|
||||
void copyAttributes(BipedEntityModel<T> other);
|
||||
|
||||
void updateLivingState(T entity, IPony pony, ModelAttributes.Mode mode);
|
||||
|
||||
ModelPart getBodyPart(BodyPart part);
|
||||
|
||||
void postItemRender(IPony pony, T entity, ItemStack drop, ModelTransformationMode transform, Arm hand, MatrixStack stack, VertexConsumerProvider renderContext);
|
||||
}
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
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,26 +14,6 @@ public class GuardianPonyModel extends GuardianEntityModel implements IPonyMixin
|
|||
mixin = new SeaponyModel<>(tree);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAngles(GuardianEntity entity, float move, float swing, float ticks, float headYaw, float headPitch) {
|
||||
mixin().setAngles(entity, move, swing, ticks, headYaw, headPitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float limbDistance, float limbAngle, float tickDelta, float alpha) {
|
||||
mixin().render(stack, vertices, overlayUv, lightUv, limbDistance, limbAngle, tickDelta, alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void animateModel(GuardianEntity entity, float move, float swing, float float_3) {
|
||||
mixin().animateModel(entity, move, swing, float_3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyStateTo(EntityModel<GuardianEntity> model) {
|
||||
mixin().copyStateTo(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SeaponyModel<GuardianEntity> mixin() {
|
||||
return mixin;
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
package com.minelittlepony.client.model.entity;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.mob.WitchEntity;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RotationAxis;
|
||||
|
||||
import com.minelittlepony.api.model.ModelAttributes;
|
||||
import com.minelittlepony.api.pony.IPony;
|
||||
import com.minelittlepony.api.pony.meta.Wearable;
|
||||
import com.minelittlepony.api.pony.meta.*;
|
||||
import com.minelittlepony.client.model.entity.race.EarthPonyModel;
|
||||
|
||||
public class WitchPonyModel extends EarthPonyModel<WitchEntity> {
|
||||
|
@ -60,6 +63,12 @@ public class WitchPonyModel extends EarthPonyModel<WitchEntity> {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void positionheldItem(Arm arm, MatrixStack matrices) {
|
||||
super.positionheldItem(arm, matrices);
|
||||
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(10));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWearing(Wearable wearable) {
|
||||
if (wearable == Wearable.HAT) {
|
||||
|
|
|
@ -1,15 +1,22 @@
|
|||
package com.minelittlepony.client.model.entity.race;
|
||||
|
||||
import com.minelittlepony.api.model.BodyPart;
|
||||
import com.minelittlepony.api.model.IUnicorn;
|
||||
import com.minelittlepony.api.model.*;
|
||||
import com.minelittlepony.api.pony.IPony;
|
||||
import com.minelittlepony.api.pony.meta.Size;
|
||||
import com.minelittlepony.api.pony.meta.Sizes;
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.client.model.part.UnicornHorn;
|
||||
import com.minelittlepony.client.render.PonyRenderDispatcher;
|
||||
import com.minelittlepony.client.util.render.RenderList;
|
||||
import com.minelittlepony.mson.api.ModelView;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.model.json.ModelTransformationMode;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.util.Arm;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.*;
|
||||
|
||||
/**
|
||||
* Used for both unicorns and alicorns since there's no logical way to keep them distinct and not duplicate stuff.
|
||||
|
@ -73,4 +80,54 @@ public class UnicornModel<T extends LivingEntity> extends EarthPonyModel<T> impl
|
|||
}
|
||||
return super.getArm(side);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void positionheldItem(Arm arm, MatrixStack matrices) {
|
||||
super.positionheldItem(arm, matrices);
|
||||
|
||||
if (!MineLittlePony.getInstance().getConfig().tpsmagic.get() || !hasMagic()) {
|
||||
return;
|
||||
}
|
||||
|
||||
float left = arm == Arm.LEFT ? -1 : 1;
|
||||
|
||||
matrices.translate(-0.3F, -0.675F, -0.3F - (0.3F * left));
|
||||
|
||||
UseAction action = getAttributes().heldStack.getUseAction();
|
||||
|
||||
if ((action == UseAction.SPYGLASS || action == UseAction.BOW) && getAttributes().itemUseTime > 0) {
|
||||
Arm main = getAttributes().mainArm;
|
||||
if (getAttributes().activeHand == Hand.OFF_HAND) {
|
||||
main = main.getOpposite();
|
||||
}
|
||||
if (main == arm) {
|
||||
if (action == UseAction.SPYGLASS) {
|
||||
Size size = getSize();
|
||||
float x = 0.4F;
|
||||
float z = -0.5F;
|
||||
|
||||
if (size == Sizes.TALL || size == Sizes.YEARLING) {
|
||||
z += 0.05F;
|
||||
} else if (size == Sizes.FOAL) {
|
||||
x -= 0.1F;
|
||||
z -= 0.1F;
|
||||
}
|
||||
|
||||
//matrices.translate(x * left, -0.2, z);
|
||||
matrices.translate(-z, 0.9, x * left);
|
||||
} else {
|
||||
matrices.translate(-0.6, -0.2, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postItemRender(IPony pony, T entity, ItemStack drop, ModelTransformationMode transform, Arm hand, MatrixStack stack, VertexConsumerProvider renderContext) {
|
||||
if (!MineLittlePony.getInstance().getConfig().tpsmagic.get() || !hasMagic()) {
|
||||
return;
|
||||
}
|
||||
|
||||
PonyRenderDispatcher.getInstance().getMagicRenderer().renderItemGlow(pony, entity, drop, transform, hand, getMagicColor(), stack, renderContext);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,14 +20,13 @@ import net.minecraft.client.render.VertexConsumerProvider;
|
|||
import net.minecraft.client.render.entity.EntityRendererFactory;
|
||||
import net.minecraft.client.render.entity.MobEntityRenderer;
|
||||
import net.minecraft.client.render.entity.feature.FeatureRenderer;
|
||||
import net.minecraft.client.render.entity.model.EntityModel;
|
||||
import net.minecraft.client.render.entity.model.PlayerEntityModel;
|
||||
import net.minecraft.client.render.entity.model.*;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.mob.MobEntity;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public abstract class AbstractPonyRenderer<T extends MobEntity, M extends EntityModel<T> & IPonyModel<T>> extends MobEntityRenderer<T, M> implements IPonyRenderContext<T, M> {
|
||||
public abstract class AbstractPonyRenderer<T extends MobEntity, M extends EntityModel<T> & IPonyModel<T> & ModelWithArms> extends MobEntityRenderer<T, M> implements IPonyRenderContext<T, M> {
|
||||
|
||||
protected final EquineRenderManager<T, M> manager = new EquineRenderManager<>(this);
|
||||
|
||||
|
@ -54,7 +53,7 @@ public abstract class AbstractPonyRenderer<T extends MobEntity, M extends Entity
|
|||
}
|
||||
|
||||
protected HeldItemFeature<T, M> createHeldItemFeature(EntityRendererFactory.Context context) {
|
||||
return new GlowingItemFeature<>(this);
|
||||
return new HeldItemFeature<>(this, context.getHeldItemRenderer());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -144,7 +143,7 @@ public abstract class AbstractPonyRenderer<T extends MobEntity, M extends Entity
|
|||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public static <T extends MobEntity, M extends EntityModel<T> & IPonyModel<T>> AbstractPonyRenderer<T, M> proxy(EntityRendererFactory.Context context, ModelKey<? super M> key, TextureSupplier<T> texture, float scale,
|
||||
public static <T extends MobEntity, M extends EntityModel<T> & IPonyModel<T> & ModelWithArms> AbstractPonyRenderer<T, M> proxy(EntityRendererFactory.Context context, ModelKey<? super M> key, TextureSupplier<T> texture, float scale,
|
||||
List exportedLayers, Consumer<M> modelConsumer) {
|
||||
var renderer = new AbstractPonyRenderer<T, M>(context, key, texture, scale) {
|
||||
@Override
|
||||
|
|
|
@ -5,7 +5,6 @@ import com.minelittlepony.client.model.entity.EnderStallionModel;
|
|||
import com.minelittlepony.client.render.entity.feature.GlowingEyesFeature;
|
||||
import com.minelittlepony.client.render.entity.feature.HeldItemFeature;
|
||||
import com.minelittlepony.client.render.entity.npc.textures.TextureSupplier;
|
||||
import com.minelittlepony.client.render.entity.feature.GlowingItemFeature;
|
||||
import com.minelittlepony.client.render.entity.feature.GlowingEyesFeature.IGlowingRenderer;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
|
@ -39,7 +38,7 @@ public class EnderStallionRenderer extends PonyRenderer<EndermanEntity, EnderSta
|
|||
|
||||
@Override
|
||||
protected HeldItemFeature<EndermanEntity, EnderStallionModel> createHeldItemFeature(EntityRendererFactory.Context context) {
|
||||
return new GlowingItemFeature<EndermanEntity, EnderStallionModel>(this) {
|
||||
return new HeldItemFeature<EndermanEntity, EnderStallionModel>(this, context.getHeldItemRenderer()) {
|
||||
@Override
|
||||
protected ItemStack getRightItem(EndermanEntity entity) {
|
||||
BlockState state = entity.getCarriedBlock();
|
||||
|
|
|
@ -7,15 +7,8 @@ import com.minelittlepony.client.SkinsProxy;
|
|||
import com.minelittlepony.client.model.*;
|
||||
import com.minelittlepony.client.render.DebugBoundingBoxRenderer;
|
||||
import com.minelittlepony.client.render.IPonyRenderContext;
|
||||
import com.minelittlepony.client.render.entity.feature.*;
|
||||
import com.minelittlepony.client.render.EquineRenderManager;
|
||||
import com.minelittlepony.client.render.entity.feature.DJPon3Feature;
|
||||
import com.minelittlepony.client.render.entity.feature.PassengerFeature;
|
||||
import com.minelittlepony.client.render.entity.feature.GearFeature;
|
||||
import com.minelittlepony.client.render.entity.feature.GlowingItemFeature;
|
||||
import com.minelittlepony.client.render.entity.feature.ArmourFeature;
|
||||
import com.minelittlepony.client.render.entity.feature.CapeFeature;
|
||||
import com.minelittlepony.client.render.entity.feature.SkullFeature;
|
||||
import com.minelittlepony.client.render.entity.feature.ElytraFeature;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -57,7 +50,7 @@ public class PlayerPonyRenderer extends PlayerEntityRenderer implements IPonyRen
|
|||
|| feature instanceof ShoulderParrotFeatureRenderer;
|
||||
});
|
||||
addLayer(new ArmourFeature<>(this, context.getModelManager()));
|
||||
addLayer(new GlowingItemFeature<>(this));
|
||||
addLayer(new HeldItemFeature(this, context.getHeldItemRenderer()));
|
||||
addLayer(new DJPon3Feature<>(this));
|
||||
addLayer(new CapeFeature<>(this));
|
||||
addLayer(new SkullFeature<>(this, context.getModelLoader()));
|
||||
|
|
|
@ -2,16 +2,10 @@ package com.minelittlepony.client.render.entity;
|
|||
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.client.model.entity.WitchPonyModel;
|
||||
import com.minelittlepony.client.render.entity.feature.HeldItemFeature;
|
||||
import com.minelittlepony.client.render.entity.npc.textures.TextureSupplier;
|
||||
|
||||
import net.minecraft.client.render.entity.EntityRendererFactory;
|
||||
import net.minecraft.client.render.model.json.ModelTransformationMode;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.util.math.RotationAxis;
|
||||
import net.minecraft.entity.mob.WitchEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Arm;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class WitchRenderer extends PonyRenderer<WitchEntity, WitchPonyModel> {
|
||||
|
@ -21,15 +15,4 @@ public class WitchRenderer extends PonyRenderer<WitchEntity, WitchPonyModel> {
|
|||
public WitchRenderer(EntityRendererFactory.Context context) {
|
||||
super(context, ModelType.WITCH, TextureSupplier.of(WITCH_TEXTURES), BASE_MODEL_SCALE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected HeldItemFeature<WitchEntity, WitchPonyModel> createHeldItemFeature(EntityRendererFactory.Context context) {
|
||||
return new HeldItemFeature<WitchEntity, WitchPonyModel>(this) {
|
||||
@Override
|
||||
protected void preItemRender(WitchEntity entity, ItemStack drop, ModelTransformationMode transform, Arm hand, MatrixStack stack) {
|
||||
super.preItemRender(entity, drop, transform, hand, stack);
|
||||
stack.multiply(RotationAxis.POSITIVE_X.rotationDegrees(10));
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
package com.minelittlepony.client.render.entity.feature;
|
||||
|
||||
import com.minelittlepony.api.model.IUnicorn;
|
||||
import com.minelittlepony.api.pony.meta.Size;
|
||||
import com.minelittlepony.api.pony.meta.Sizes;
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.client.model.IPonyModel;
|
||||
import com.minelittlepony.client.render.IPonyRenderContext;
|
||||
import com.minelittlepony.client.render.PonyRenderDispatcher;
|
||||
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.entity.model.EntityModel;
|
||||
import net.minecraft.client.render.model.json.ModelTransformationMode;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Arm;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.UseAction;
|
||||
|
||||
public class GlowingItemFeature<T extends LivingEntity, M extends EntityModel<T> & IPonyModel<T>> extends HeldItemFeature<T, M> {
|
||||
|
||||
public GlowingItemFeature(IPonyRenderContext<T, M> context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
protected boolean isUnicorn() {
|
||||
return MineLittlePony.getInstance().getConfig().tpsmagic.get()
|
||||
&& getContextModel() instanceof IUnicorn
|
||||
&& ((IUnicorn)getContextModel()).hasMagic();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preItemRender(T entity, ItemStack drop, ModelTransformationMode transform, Arm arm, MatrixStack stack) {
|
||||
super.preItemRender(entity, drop, transform, arm, stack);
|
||||
|
||||
if (!isUnicorn()) {
|
||||
return;
|
||||
}
|
||||
|
||||
float left = arm == Arm.LEFT ? 1 : -1;
|
||||
|
||||
stack.translate(-0.3F - (0.3F * left), 0.375F, 0.6F);
|
||||
|
||||
UseAction action = drop.getUseAction();
|
||||
|
||||
if ((action == UseAction.SPYGLASS || action == UseAction.BOW) && entity.getItemUseTimeLeft() > 0) {
|
||||
Arm main = entity.getMainArm();
|
||||
if (entity.getActiveHand() == Hand.OFF_HAND) {
|
||||
main = main.getOpposite();
|
||||
}
|
||||
if (main == arm) {
|
||||
if (action == UseAction.SPYGLASS) {
|
||||
Size size = getContextModel().getSize();
|
||||
float x = 0.4F;
|
||||
float z = -0.8F;
|
||||
|
||||
if (size == Sizes.TALL || size == Sizes.YEARLING) {
|
||||
z += 0.05F;
|
||||
} else if (size == Sizes.FOAL) {
|
||||
x -= 0.1F;
|
||||
z -= 0.1F;
|
||||
}
|
||||
|
||||
stack.translate(x * left, -0.2, z);
|
||||
} else {
|
||||
stack.translate(0, 0.2, -0.6);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void postItemRender(T entity, ItemStack drop, ModelTransformationMode transform, Arm hand, MatrixStack stack, VertexConsumerProvider renderContext) {
|
||||
if (isUnicorn()) {
|
||||
PonyRenderDispatcher.getInstance().getMagicRenderer().renderItemGlow(getContext().getEntityPony(entity), entity, drop, transform, hand, ((IUnicorn)getContextModel()).getMagicColor(), stack, renderContext);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,26 +2,23 @@ package com.minelittlepony.client.render.entity.feature;
|
|||
|
||||
import com.minelittlepony.api.model.BodyPart;
|
||||
import com.minelittlepony.client.model.IPonyModel;
|
||||
import com.minelittlepony.client.render.IPonyRenderContext;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.OverlayTexture;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.entity.feature.FeatureRendererContext;
|
||||
import net.minecraft.client.render.entity.feature.HeldItemFeatureRenderer;
|
||||
import net.minecraft.client.render.entity.model.EntityModel;
|
||||
import net.minecraft.client.render.entity.model.ModelWithArms;
|
||||
import net.minecraft.client.render.item.HeldItemRenderer;
|
||||
import net.minecraft.client.render.model.json.ModelTransformationMode;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Arm;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.UseAction;
|
||||
import net.minecraft.util.math.RotationAxis;
|
||||
|
||||
public class HeldItemFeature<T extends LivingEntity, M extends EntityModel<T> & IPonyModel<T>> extends AbstractPonyFeature<T, M> {
|
||||
public class HeldItemFeature<T extends LivingEntity, M extends EntityModel<T> & IPonyModel<T> & ModelWithArms> extends HeldItemFeatureRenderer<T, M> {
|
||||
|
||||
public HeldItemFeature(IPonyRenderContext<T, M> livingPony) {
|
||||
super(livingPony);
|
||||
public HeldItemFeature(FeatureRendererContext<T, M> context, HeldItemRenderer renderer) {
|
||||
super(context, renderer);
|
||||
}
|
||||
|
||||
protected ItemStack getLeftItem(T entity) {
|
||||
|
@ -35,7 +32,6 @@ public class HeldItemFeature<T extends LivingEntity, M extends EntityModel<T> &
|
|||
|
||||
return main ? entity.getMainHandStack() : entity.getOffHandStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, T entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) {
|
||||
|
||||
|
@ -49,70 +45,12 @@ public class HeldItemFeature<T extends LivingEntity, M extends EntityModel<T> &
|
|||
|
||||
model.transform(BodyPart.LEGS, stack);
|
||||
|
||||
renderHeldItem(entity, right, ModelTransformationMode.THIRD_PERSON_RIGHT_HAND, Arm.RIGHT, stack, renderContext, lightUv);
|
||||
renderHeldItem(entity, left, ModelTransformationMode.THIRD_PERSON_LEFT_HAND, Arm.LEFT, stack, renderContext, lightUv);
|
||||
|
||||
model.getAttributes().heldStack = right;
|
||||
renderItem(entity, right, ModelTransformationMode.THIRD_PERSON_RIGHT_HAND, Arm.RIGHT, stack, renderContext, lightUv);
|
||||
model.getAttributes().heldStack = left;
|
||||
renderItem(entity, left, ModelTransformationMode.THIRD_PERSON_LEFT_HAND, Arm.LEFT, stack, renderContext, lightUv);
|
||||
model.getAttributes().heldStack = ItemStack.EMPTY;
|
||||
stack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
private void renderHeldItem(T entity, ItemStack drop, ModelTransformationMode transform, Arm arm, MatrixStack stack, VertexConsumerProvider renderContext, int lightUv) {
|
||||
if (!drop.isEmpty()) {
|
||||
stack.push();
|
||||
renderArm(arm, stack);
|
||||
|
||||
if (getContextModel().getAttributes().isCrouching) {
|
||||
stack.translate(0, 0.2F, 0);
|
||||
}
|
||||
|
||||
preItemRender(entity, drop, transform, arm, stack);
|
||||
MinecraftClient.getInstance().getItemRenderer().renderItem(entity, drop, transform, arm == Arm.LEFT, stack, renderContext, entity.world, lightUv, OverlayTexture.DEFAULT_UV, 0);
|
||||
postItemRender(entity, drop, transform, arm, stack, renderContext);
|
||||
|
||||
stack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
protected void preItemRender(T entity, ItemStack drop, ModelTransformationMode transform, Arm arm, MatrixStack stack) {
|
||||
float left = arm == Arm.LEFT ? 1 : -1;
|
||||
|
||||
UseAction action = drop.getUseAction();
|
||||
|
||||
if (action == UseAction.SPYGLASS && entity.getItemUseTimeLeft() > 0) {
|
||||
Arm main = entity.getMainArm();
|
||||
if (entity.getActiveHand() == Hand.OFF_HAND) {
|
||||
main = main.getOpposite();
|
||||
}
|
||||
if (main == arm) {
|
||||
stack.translate(left * -0.05F, 0.5F, 0.7F);
|
||||
stack.multiply(RotationAxis.POSITIVE_X.rotationDegrees(-60));
|
||||
stack.multiply(RotationAxis.POSITIVE_X.rotationDegrees(-90));
|
||||
stack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(left * 180));
|
||||
stack.translate(left * -0.2F, 0.125F, -1);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (entity.hasVehicle()) {
|
||||
stack.translate(left / 10, -0.2F, -0.5F);
|
||||
}
|
||||
|
||||
stack.multiply(RotationAxis.POSITIVE_X.rotationDegrees(-90));
|
||||
stack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(left * 180));
|
||||
stack.translate(left * -0.2F, 0.125F, -1);
|
||||
}
|
||||
|
||||
protected void postItemRender(T entity, ItemStack drop, ModelTransformationMode transform, Arm hand, MatrixStack stack, VertexConsumerProvider renderContext) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the main arm
|
||||
*/
|
||||
protected void renderArm(Arm arm, MatrixStack stack) {
|
||||
M model = getContextModel();
|
||||
if (model instanceof ModelWithArms) {
|
||||
((ModelWithArms)model).setArmAngle(arm, stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
package com.minelittlepony.client.render.entity.feature;
|
||||
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.entity.feature.FeatureRendererContext;
|
||||
import net.minecraft.client.render.item.HeldItemRenderer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.mob.IllagerEntity;
|
||||
import net.minecraft.util.Arm;
|
||||
|
||||
import com.minelittlepony.client.model.entity.race.AlicornModel;
|
||||
import com.minelittlepony.client.render.IPonyRenderContext;
|
||||
|
||||
public class IllagerHeldItemFeature<T extends IllagerEntity, M extends AlicornModel<T>> extends HeldItemFeature<T, M> {
|
||||
|
||||
public IllagerHeldItemFeature(IPonyRenderContext<T,M> livingPony) {
|
||||
super(livingPony);
|
||||
public IllagerHeldItemFeature(FeatureRendererContext<T,M> livingPony, HeldItemRenderer renderer) {
|
||||
super(livingPony, renderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,11 +21,6 @@ public class IllagerHeldItemFeature<T extends IllagerEntity, M extends AlicornMo
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderArm(Arm arm, MatrixStack stack) {
|
||||
getContextModel().getArm(arm).rotate(stack);
|
||||
}
|
||||
|
||||
public boolean shouldRender(T entity) {
|
||||
return entity.getState() != IllagerEntity.State.CROSSED;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public class IllagerPonyRenderer<T extends IllagerEntity> extends PonyRenderer<T
|
|||
|
||||
@Override
|
||||
protected HeldItemFeature<T, IllagerPonyModel<T>> createHeldItemFeature(EntityRendererFactory.Context context) {
|
||||
return new IllagerHeldItemFeature<>(this);
|
||||
return new IllagerHeldItemFeature<>(this, context.getHeldItemRenderer());
|
||||
}
|
||||
|
||||
public static IllagerPonyRenderer<VindicatorEntity> vindicator(EntityRendererFactory.Context context) {
|
||||
|
|
|
@ -21,6 +21,6 @@ public class PillagerRenderer extends PonyRenderer<PillagerEntity, PillagerPonyM
|
|||
|
||||
@Override
|
||||
protected HeldItemFeature<PillagerEntity, PillagerPonyModel<PillagerEntity>> createHeldItemFeature(EntityRendererFactory.Context context) {
|
||||
return new IllagerHeldItemFeature<>(this);
|
||||
return new IllagerHeldItemFeature<>(this, context.getHeldItemRenderer());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue