mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-17 10:24:23 +01:00
Added a renderer for worn amulets and wings
This commit is contained in:
parent
59c2f400d0
commit
163afc9047
12 changed files with 297 additions and 27 deletions
|
@ -11,6 +11,9 @@ import com.minelittlepony.unicopia.client.particle.RainboomParticle;
|
|||
import com.minelittlepony.unicopia.client.particle.RainbowTrailParticle;
|
||||
import com.minelittlepony.unicopia.client.particle.RaindropsParticle;
|
||||
import com.minelittlepony.unicopia.client.particle.SphereParticle;
|
||||
import com.minelittlepony.unicopia.client.render.AccessoryFeatureRenderer;
|
||||
import com.minelittlepony.unicopia.client.render.AmuletFeatureRenderer;
|
||||
import com.minelittlepony.unicopia.client.render.BraceletFeatureRenderer;
|
||||
import com.minelittlepony.unicopia.client.render.FloatingArtefactEntityRenderer;
|
||||
import com.minelittlepony.unicopia.item.ChameleonItem;
|
||||
import com.minelittlepony.unicopia.item.UItems;
|
||||
|
@ -46,6 +49,9 @@ public interface URenderers {
|
|||
ParticleFactoryRegistry.getInstance().register(UParticles.GROUND_POUND, GroundPoundParticle::new);
|
||||
ParticleFactoryRegistry.getInstance().register(UParticles.CLOUDS_ESCAPING, CloudsEscapingParticle::new);
|
||||
|
||||
AccessoryFeatureRenderer.register(BraceletFeatureRenderer::new);
|
||||
AccessoryFeatureRenderer.register(AmuletFeatureRenderer::new);
|
||||
|
||||
EntityRendererRegistry.INSTANCE.register(UEntities.THROWN_ITEM, (manager, context) -> new FlyingItemEntityRenderer<>(manager, context.getItemRenderer()));
|
||||
EntityRendererRegistry.INSTANCE.register(UEntities.FLOATING_ARTEFACT, FloatingArtefactEntityRenderer::new);
|
||||
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package com.minelittlepony.unicopia.client.render;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.entity.feature.FeatureRenderer;
|
||||
import net.minecraft.client.render.entity.feature.FeatureRendererContext;
|
||||
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
|
||||
public class AccessoryFeatureRenderer<
|
||||
T extends LivingEntity,
|
||||
M extends BipedEntityModel<T>> extends FeatureRenderer<T, M> {
|
||||
|
||||
private static final List<FeatureFactory<?>> REGISTRY = new ArrayList<>();
|
||||
|
||||
public static <T extends LivingEntity> void register(FeatureFactory<T> factory) {
|
||||
REGISTRY.add(factory);
|
||||
}
|
||||
|
||||
private final Iterable<Feature<T>> features;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public AccessoryFeatureRenderer(FeatureRendererContext<T, M> context) {
|
||||
super(context);
|
||||
features = REGISTRY.stream().map(f -> ((FeatureFactory<T>)f).create(context)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, T entity, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) {
|
||||
features.forEach(feature -> {
|
||||
feature.render(matrices, vertexConsumers, light, entity, limbAngle, limbDistance, tickDelta, animationProgress, headYaw, headPitch);
|
||||
});
|
||||
}
|
||||
|
||||
public interface FeatureFactory<T extends LivingEntity> {
|
||||
Feature<T> create(FeatureRendererContext<T, ? extends BipedEntityModel<T>> context);
|
||||
}
|
||||
|
||||
public interface Feature<T extends LivingEntity> {
|
||||
void render(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, T entity, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,161 @@
|
|||
package com.minelittlepony.unicopia.client.render;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.item.AmuletItem;
|
||||
import com.minelittlepony.unicopia.item.UItems;
|
||||
|
||||
import net.minecraft.client.model.Model;
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.OverlayTexture;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.entity.feature.FeatureRendererContext;
|
||||
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
||||
import net.minecraft.client.render.item.ItemRenderer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
public class AmuletFeatureRenderer<E extends LivingEntity> implements AccessoryFeatureRenderer.Feature<E> {
|
||||
|
||||
private final BraceletModel model = new BraceletModel(0.3F);
|
||||
|
||||
private final Map<Identifier, Identifier> textures = new HashMap<>();
|
||||
|
||||
private final FeatureRendererContext<E, ? extends BipedEntityModel<E>> context;
|
||||
|
||||
public AmuletFeatureRenderer(FeatureRendererContext<E, ? extends BipedEntityModel<E>> context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, VertexConsumerProvider renderContext, int lightUv, E entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) {
|
||||
|
||||
ItemStack stack = entity.getEquippedStack(EquipmentSlot.CHEST);
|
||||
Item item = stack.getItem();
|
||||
|
||||
boolean amulet = item instanceof AmuletItem;
|
||||
boolean wings =
|
||||
(amulet && ((AmuletItem)item).isApplicable(stack))
|
||||
|| (entity instanceof PlayerEntity && Pony.of((PlayerEntity)entity).getSpecies().canInteractWithClouds());
|
||||
|
||||
if (wings || amulet) {
|
||||
Identifier texture = textures.computeIfAbsent(Registry.ITEM.getId(amulet ? item : UItems.PEGASUS_AMULET), id -> new Identifier(id.getNamespace(), "textures/models/armor/" + id.getPath() + ".png"));
|
||||
|
||||
VertexConsumer consumer = ItemRenderer.getArmorGlintConsumer(renderContext, RenderLayer.getArmorCutoutNoCull(texture), false, false);
|
||||
|
||||
model.setVisible(amulet, wings);
|
||||
model.setAngles(entity, context.getModel());
|
||||
model.render(matrices, consumer, lightUv, OverlayTexture.DEFAULT_UV, 1, 1, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
static class BraceletModel extends Model {
|
||||
|
||||
private final ModelPart torso;
|
||||
private final ModelPart amulet;
|
||||
|
||||
private final Wing[] wings;
|
||||
|
||||
public BraceletModel(float dilate) {
|
||||
super(RenderLayer::getEntityTranslucent);
|
||||
torso = new ModelPart(this, 0, 0);
|
||||
amulet = new ModelPart(this, 0, 0);
|
||||
amulet.addCuboid(-4, 0, -2, 8, 12, 4, dilate);
|
||||
amulet.setPivot(0, 0, 0);
|
||||
torso.addChild(amulet);
|
||||
wings = new Wing[] {
|
||||
new Wing(this, torso, -1),
|
||||
new Wing(this, torso, 1)
|
||||
};
|
||||
}
|
||||
|
||||
public void setVisible(boolean amulet, boolean wings) {
|
||||
this.amulet.visible = amulet;
|
||||
for (Wing wing : this.wings) {
|
||||
wing.base.visible = wings;
|
||||
}
|
||||
}
|
||||
|
||||
public void setAngles(LivingEntity entity, BipedEntityModel<?> biped) {
|
||||
torso.copyPositionAndRotation(biped.torso);
|
||||
for (Wing wing : wings) {
|
||||
wing.setAngles(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, VertexConsumer vertexConsumer, int i, int j, float f, float g, float h, float k) {
|
||||
torso.render(matrices, vertexConsumer, i, j, f, g, h, k);
|
||||
}
|
||||
|
||||
static class Wing {
|
||||
ModelPart base;
|
||||
|
||||
ModelPart[] feathers;
|
||||
|
||||
int k;
|
||||
|
||||
Wing(Model model, ModelPart torso, int k) {
|
||||
this.k = k;
|
||||
base = new ModelPart(model, 0, 16);
|
||||
|
||||
base.setPivot(k * 2, 2, 2 + k * 0.5F);
|
||||
base.addCuboid(0, 0, 0, 2, 10, 2);
|
||||
|
||||
feathers = new ModelPart[8];
|
||||
|
||||
for (int i = 0; i < feathers.length; i++) {
|
||||
int texX = (i % 2) * 8;
|
||||
|
||||
ModelPart feather = new ModelPart(model, 24 + texX, 0);
|
||||
feather.setPivot(0, 9, 0);
|
||||
|
||||
int featherLength = 21 - i * 2;
|
||||
|
||||
feather.addCuboid(-k * (i % 2) / 90F, 0, 0, 2, featherLength, 2);
|
||||
|
||||
base.addChild(feather);
|
||||
feathers[i] = feather;
|
||||
}
|
||||
|
||||
torso.addChild(base);
|
||||
}
|
||||
|
||||
void setAngles(LivingEntity entity) {
|
||||
if (entity instanceof PlayerEntity) {
|
||||
Pony pony = Pony.of((PlayerEntity)entity);
|
||||
|
||||
float spreadAmount = pony.getMotion().getWingAngle();
|
||||
|
||||
base.pitch = 1.5F + 0.8F - spreadAmount / 9F;
|
||||
base.yaw = k * (0.8F + spreadAmount / 3F);
|
||||
|
||||
spreadAmount /= 7F;
|
||||
|
||||
final float ratio = 4F;
|
||||
|
||||
for (int i = 0; i < feathers.length; i++) {
|
||||
|
||||
float spread = i/ratio + 1.5F;
|
||||
spread -= spreadAmount * ratio;
|
||||
spread += spreadAmount * i / ratio;
|
||||
|
||||
feathers[i].pitch = -spread;
|
||||
feathers[i].yaw = k * 0.3F;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,7 +11,6 @@ import net.minecraft.client.render.OverlayTexture;
|
|||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.entity.feature.FeatureRenderer;
|
||||
import net.minecraft.client.render.entity.feature.FeatureRendererContext;
|
||||
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
|
@ -23,17 +22,17 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.util.Arm;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class BraceletFeatureRenderer<
|
||||
E extends LivingEntity,
|
||||
M extends BipedEntityModel<E>> extends FeatureRenderer<E, M> {
|
||||
public class BraceletFeatureRenderer<E extends LivingEntity> implements AccessoryFeatureRenderer.Feature<E> {
|
||||
|
||||
private static final Identifier TEXTURE = new Identifier("unicopia", "textures/models/armor/bracelet.png");
|
||||
|
||||
private final BraceletModel steveModel = new BraceletModel(0.3F, false);
|
||||
private final BraceletModel alexModel = new BraceletModel(0.3F, true);
|
||||
|
||||
public BraceletFeatureRenderer(FeatureRendererContext<E, M> context) {
|
||||
super(context);
|
||||
private final FeatureRendererContext<E, ? extends BipedEntityModel<E>> context;
|
||||
|
||||
public BraceletFeatureRenderer(FeatureRendererContext<E, ? extends BipedEntityModel<E>> context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -51,9 +50,9 @@ public class BraceletFeatureRenderer<
|
|||
BraceletModel model = alex ? alexModel : steveModel;
|
||||
|
||||
if (entity instanceof ArmorStandEntity) {
|
||||
ModelPart arm = entity.getMainArm() == Arm.LEFT ? getContextModel().leftArm : getContextModel().rightArm;
|
||||
ModelPart arm = entity.getMainArm() == Arm.LEFT ? context.getModel().leftArm : context.getModel().rightArm;
|
||||
arm.visible = true;
|
||||
VertexConsumer consumer = renderContext.getBuffer(getContextModel().getLayer(getTexture(entity)));
|
||||
VertexConsumer consumer = renderContext.getBuffer(context.getModel().getLayer(context.getTexture(entity)));
|
||||
arm.render(stack, consumer, lightUv, OverlayTexture.DEFAULT_UV, 1, 1, 1, 1);
|
||||
}
|
||||
|
||||
|
@ -61,7 +60,7 @@ public class BraceletFeatureRenderer<
|
|||
|
||||
VertexConsumer consumer = CanvasCompat.getGlowingConsumer(glowing, renderContext, RenderLayer.getArmorCutoutNoCull(TEXTURE));
|
||||
|
||||
model.setAngles(getContextModel());
|
||||
model.setAngles(context.getModel());
|
||||
model.setVisible(entity.getMainArm());
|
||||
model.render(stack, consumer, glowing ? 0x0F00F0 : lightUv, OverlayTexture.DEFAULT_UV, Color.r(j), Color.g(j), Color.b(j), 1);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package com.minelittlepony.unicopia.entity;
|
||||
|
||||
public interface Leaner {
|
||||
float getLeaningPitch();
|
||||
|
||||
void setLeaningPitch(float pitch);
|
||||
}
|
|
@ -15,8 +15,11 @@ public interface RotatedView {
|
|||
}
|
||||
|
||||
default void popRotation() {
|
||||
if (!getRotations().isEmpty()) {
|
||||
getRotations().pop();
|
||||
Stack<Integer> rotations = getRotations();
|
||||
synchronized (rotations) {
|
||||
if (!rotations.isEmpty()) {
|
||||
rotations.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,10 +32,13 @@ public interface RotatedView {
|
|||
}
|
||||
|
||||
default int applyRotation(int y) {
|
||||
if (!hasTransform() || getRotations().isEmpty()) {
|
||||
return y;
|
||||
Stack<Integer> rotations = getRotations();
|
||||
synchronized (rotations) {
|
||||
if (!hasTransform() || rotations.isEmpty()) {
|
||||
return y;
|
||||
}
|
||||
return y - ((y - rotations.peek()) * 2);
|
||||
}
|
||||
return y - ((y - getRotations().peek()) * 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,5 +9,9 @@ public interface Motion {
|
|||
*/
|
||||
boolean isFlying();
|
||||
|
||||
boolean isGliding();
|
||||
|
||||
float getWingAngle();
|
||||
|
||||
PlayerDimensions getDimensions();
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.minelittlepony.unicopia.ability.magic.Spell;
|
|||
import com.minelittlepony.unicopia.entity.Creature;
|
||||
import com.minelittlepony.unicopia.entity.EntityPhysics;
|
||||
import com.minelittlepony.unicopia.entity.Jumper;
|
||||
import com.minelittlepony.unicopia.entity.Leaner;
|
||||
import com.minelittlepony.unicopia.entity.player.MagicReserves.Bar;
|
||||
import com.minelittlepony.unicopia.item.AmuletItem;
|
||||
import com.minelittlepony.unicopia.item.UItems;
|
||||
|
@ -67,6 +68,30 @@ public class PlayerPhysics extends EntityPhysics<Pony> implements Tickable, Moti
|
|||
return isFlyingSurvival && !pony.getMaster().isFallFlying() && !pony.getMaster().hasVehicle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGliding() {
|
||||
return isFlying() && (pony.getMaster().isSneaking() || ((Jumper)pony.getMaster()).isJumping()) && !pony.sneakingChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWingAngle() {
|
||||
float spreadAmount = -0.5F;
|
||||
|
||||
if (isFlying()) {
|
||||
//spreadAmount += Math.sin(pony.getEntity().age / 4F) * 8;
|
||||
spreadAmount += isGliding() ? 3 : thrustScale * 60;
|
||||
}
|
||||
|
||||
if (pony.getEntity().isSneaking()) {
|
||||
spreadAmount += 2;
|
||||
}
|
||||
|
||||
spreadAmount += Math.sin(pony.getEntity().age / 9F) / 9F;
|
||||
spreadAmount = MathHelper.clamp(spreadAmount, -2, 5);
|
||||
|
||||
return pony.getInterpolator().interpolate("wingSpreadAmount", spreadAmount, 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
|
@ -260,6 +285,13 @@ public class PlayerPhysics extends EntityPhysics<Pony> implements Tickable, Moti
|
|||
}
|
||||
|
||||
entity.setVelocity(velocity.toImmutable());
|
||||
|
||||
if (isFlying() && !entity.isInSwimmingPose()) {
|
||||
float pitch = ((Leaner)entity).getLeaningPitch();
|
||||
if (pitch < 1) {
|
||||
((Leaner)entity).setLeaningPitch(Math.max(0, pitch + 0.18F));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void handleWallCollission(PlayerEntity player, MutableVector velocity) {
|
||||
|
|
|
@ -16,11 +16,11 @@ import net.minecraft.entity.EquipmentSlot;
|
|||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.attribute.EntityAttribute;
|
||||
import net.minecraft.entity.attribute.EntityAttributeModifier;
|
||||
import net.minecraft.item.ArmorItem;
|
||||
import net.minecraft.item.ArmorMaterial;
|
||||
import net.minecraft.item.ArmorMaterials;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Wearable;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
|
@ -33,19 +33,19 @@ import net.minecraft.text.TranslatableText;
|
|||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class AmuletItem extends ArmorItem {
|
||||
public class AmuletItem extends Item implements Wearable {
|
||||
|
||||
private final int maxEnergy;
|
||||
private final float drain;
|
||||
|
||||
private final ImmutableMultimap<EntityAttribute, EntityAttributeModifier> modifiers;
|
||||
|
||||
public AmuletItem(Item.Settings settings, int maxEnergy, int drainRate) {
|
||||
public AmuletItem(FabricItemSettings settings, int maxEnergy, int drainRate) {
|
||||
this(settings, maxEnergy, drainRate, ImmutableMultimap.builder());
|
||||
}
|
||||
|
||||
public AmuletItem(Item.Settings settings, int maxEnergy, int drainRate, ImmutableMultimap.Builder<EntityAttribute, EntityAttributeModifier> modifiers) {
|
||||
super((Settings)settings, EquipmentSlot.CHEST, settings);
|
||||
public AmuletItem(FabricItemSettings settings, int maxEnergy, int drainRate, ImmutableMultimap.Builder<EntityAttribute, EntityAttributeModifier> modifiers) {
|
||||
super(settings.equipmentSlot(s -> EquipmentSlot.CHEST));
|
||||
this.maxEnergy = maxEnergy;
|
||||
drain = ((float)drainRate / (float)maxEnergy) / 10;
|
||||
|
||||
|
@ -54,7 +54,7 @@ public class AmuletItem extends ArmorItem {
|
|||
|
||||
@Override
|
||||
public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) {
|
||||
if (isChargable() && entity instanceof LivingEntity && ((LivingEntity) entity).getEquippedStack(getSlotType()) == stack) {
|
||||
if (isChargable() && entity instanceof LivingEntity && ((LivingEntity) entity).getEquippedStack(EquipmentSlot.CHEST) == stack) {
|
||||
consumeEnergy(stack, drain);
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ public class AmuletItem extends ArmorItem {
|
|||
|
||||
@Override
|
||||
public Multimap<EntityAttribute, EntityAttributeModifier> getAttributeModifiers(EquipmentSlot slot) {
|
||||
return slot == getSlotType() ? modifiers : ImmutableMultimap.of();
|
||||
return slot == EquipmentSlot.CHEST ? modifiers : ImmutableMultimap.of();
|
||||
}
|
||||
|
||||
public boolean isApplicable(ItemStack stack) {
|
||||
|
@ -92,7 +92,7 @@ public class AmuletItem extends ArmorItem {
|
|||
}
|
||||
|
||||
public boolean isApplicable(LivingEntity entity) {
|
||||
return isApplicable(entity.getEquippedStack(getSlotType()));
|
||||
return isApplicable(entity.getEquippedStack(EquipmentSlot.CHEST));
|
||||
}
|
||||
|
||||
public boolean isChargable() {
|
||||
|
|
|
@ -20,6 +20,7 @@ import com.minelittlepony.unicopia.entity.behaviour.Disguise;
|
|||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.entity.Equine;
|
||||
import com.minelittlepony.unicopia.entity.Jumper;
|
||||
import com.minelittlepony.unicopia.entity.Leaner;
|
||||
import com.minelittlepony.unicopia.entity.ItemWielder;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
|
@ -32,7 +33,7 @@ import net.minecraft.util.Hand;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
@Mixin(LivingEntity.class)
|
||||
abstract class MixinLivingEntity extends Entity implements PonyContainer<Equine<?>>, ItemWielder, Jumper {
|
||||
abstract class MixinLivingEntity extends Entity implements PonyContainer<Equine<?>>, ItemWielder, Jumper, Leaner {
|
||||
@Shadow
|
||||
protected ItemStack activeItemStack;
|
||||
@Shadow
|
||||
|
@ -65,6 +66,14 @@ abstract class MixinLivingEntity extends Entity implements PonyContainer<Equine<
|
|||
@Accessor("jumping")
|
||||
public abstract boolean isJumping();
|
||||
|
||||
@Override
|
||||
@Accessor("leaningPitch")
|
||||
public abstract float getLeaningPitch();
|
||||
|
||||
@Override
|
||||
@Accessor("leaningPitch")
|
||||
public abstract void setLeaningPitch(float pitch);
|
||||
|
||||
@Inject(method = "createLivingAttributes()Lnet/minecraft/entity/attribute/DefaultAttributeContainer$Builder;", at = @At("RETURN"))
|
||||
private static void onCreateAttributes(CallbackInfoReturnable<DefaultAttributeContainer.Builder> info) {
|
||||
Creature.registerAttributes(info.getReturnValue());
|
||||
|
|
|
@ -5,7 +5,7 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import com.minelittlepony.unicopia.client.render.BraceletFeatureRenderer;
|
||||
import com.minelittlepony.unicopia.client.render.AccessoryFeatureRenderer;
|
||||
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.entity.feature.ArmorFeatureRenderer;
|
||||
|
@ -18,17 +18,17 @@ import net.minecraft.entity.LivingEntity;
|
|||
@Mixin(ArmorFeatureRenderer.class)
|
||||
abstract class MixinArmorFeatureRenderer<T extends LivingEntity, M extends BipedEntityModel<T>, A extends BipedEntityModel<T>> extends FeatureRenderer<T, M> {
|
||||
|
||||
private BraceletFeatureRenderer<T, M> bracelet;
|
||||
private AccessoryFeatureRenderer<T, M> accessories;
|
||||
|
||||
MixinArmorFeatureRenderer() { super(null); }
|
||||
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
private void onInit(FeatureRendererContext<T, M> context, A inner, A outer, CallbackInfo info) {
|
||||
bracelet = new BraceletFeatureRenderer<>(context);
|
||||
accessories = new AccessoryFeatureRenderer<>(context);
|
||||
}
|
||||
|
||||
@Inject(method = "render", at = @At("RETURN"))
|
||||
private void onRender(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, T entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch, CallbackInfo info) {
|
||||
bracelet.render(stack, renderContext, lightUv, entity, limbDistance, limbAngle, tickDelta, age, headYaw, headPitch);
|
||||
accessories.render(stack, renderContext, lightUv, entity, limbDistance, limbAngle, tickDelta, age, headYaw, headPitch);
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
Loading…
Reference in a new issue