Fixed eye position not being updated when joining a world, or when skins load

This commit is contained in:
Sollace 2019-07-03 15:58:28 +02:00
parent 9641bbfe5c
commit 3f1744d98a
4 changed files with 18 additions and 3 deletions

View file

@ -47,6 +47,8 @@ public class Pony implements IPony {
private final Identifier texture;
private final IPonyData metadata;
private boolean initialized = false;
public Pony(Identifier resource) {
texture = resource;
metadata = checkSkin(texture);
@ -70,6 +72,14 @@ public class Pony implements IPony {
return checkSkin(ponyTexture);
}
@Override
public void updateForEntity(Entity entity) {
if (!initialized) {
initialized = true;
entity.calculateDimensions();
}
}
@Nullable
private IPonyData checkPonyMeta(Identifier resource) {
try {
@ -219,8 +229,6 @@ public class Pony implements IPony {
public Vec3d getAbsoluteRidingOffset(LivingEntity entity) {
IPony ridingPony = getMountedPony(entity);
if (ridingPony != null) {
LivingEntity ridee = (LivingEntity)entity.getVehicle();

View file

@ -56,7 +56,7 @@ public class PonyManager implements IPonyManager, IdentifiableResourceReloadList
private final PonyConfig config;
private final LoadingCache<Identifier, Pony> poniesCache = CacheBuilder.newBuilder()
private final LoadingCache<Identifier, IPony> poniesCache = CacheBuilder.newBuilder()
.expireAfterAccess(30, TimeUnit.SECONDS)
.build(CacheLoader.from(Pony::new));

View file

@ -134,6 +134,7 @@ public class RenderPony<T extends LivingEntity, M extends EntityModel<T> & IPony
public void updateModel(T entity) {
pony = renderer.getEntityPony(entity);
playerModel.apply(pony.getMetadata());
pony.updateForEntity(entity);
}
public IPony getPony(T entity) {

View file

@ -1,5 +1,6 @@
package com.minelittlepony.pony;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Box;
@ -18,6 +19,11 @@ public interface IPony {
return MineLittlePony.getInstance().getManager().getPony(texture);
}
/**
* Triggers state updates on the passed entity.
*/
void updateForEntity(Entity entity);
/**
* Returns true if this pony has wings and the will to use them.
*/