mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-13 08:14:23 +01:00
Fixed crash due to null interpolator id, and fixed crash when entities other than the player hold an item
This commit is contained in:
parent
fe4c4d784e
commit
c02a46aa7d
7 changed files with 36 additions and 29 deletions
|
@ -8,7 +8,6 @@ import com.minelittlepony.client.render.PonyRenderDispatcher;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||
import net.minecraft.client.render.FirstPersonRenderer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.model.json.ModelTransformation.Type;
|
||||
|
@ -43,6 +42,6 @@ abstract class MixinFirstPersonRenderer {
|
|||
VertexConsumerProvider renderContext,
|
||||
@Nullable World world,
|
||||
int lightUv, int overlayUv) {
|
||||
PonyRenderDispatcher.getInstance().getMagicRenderer().renderItemInFirstPerson(target, (AbstractClientPlayerEntity)entity, item, transform, left, stack, renderContext, world, lightUv);
|
||||
PonyRenderDispatcher.getInstance().getMagicRenderer().renderItemInFirstPerson(target, entity, item, transform, left, stack, renderContext, world, lightUv);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public abstract class ClientPonyModel<T extends LivingEntity> extends MsonPlayer
|
|||
/**
|
||||
* Associated pony data.
|
||||
*/
|
||||
protected IPonyData metadata = new PonyData();
|
||||
protected IPonyData metadata = PonyData.NULL;
|
||||
|
||||
@Override
|
||||
public void updateLivingState(T entity, IPony pony, EquineRenderManager.Mode mode) {
|
||||
|
|
|
@ -23,7 +23,7 @@ public class PonySkullModel extends SkullOverlayEntityModel implements MsonModel
|
|||
|
||||
private ModelPart hair;
|
||||
|
||||
public IPonyData metadata = new PonyData();
|
||||
public IPonyData metadata = PonyData.NULL;
|
||||
|
||||
@Override
|
||||
public void init(ModelContext context) {
|
||||
|
|
|
@ -35,13 +35,15 @@ public class PonyData implements IPonyData {
|
|||
|
||||
private static final PonyDataSerialiser SERIALISER = new PonyDataSerialiser();
|
||||
|
||||
public static final IPonyData NULL = new PonyData(Race.HUMAN);
|
||||
|
||||
/**
|
||||
* Parses the given resource into a new IPonyData.
|
||||
* This may either come from an attached json file or the image itself.
|
||||
*/
|
||||
public static IPonyData parse(@Nullable Identifier identifier) {
|
||||
if (identifier == null) {
|
||||
return new PonyData();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
try (Resource res = MinecraftClient.getInstance().getResourceManager().getResource(identifier)) {
|
||||
|
@ -60,7 +62,7 @@ public class PonyData implements IPonyData {
|
|||
return NativeUtil.parseImage(identifier, PonyData::new);
|
||||
} catch (IllegalStateException e) {
|
||||
MineLittlePony.logger.fatal("Unable to read {} metadata", identifier, e);
|
||||
return new PonyData();
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,8 +84,8 @@ public class PonyData implements IPonyData {
|
|||
@Expose
|
||||
private final boolean[] wearables;
|
||||
|
||||
public PonyData() {
|
||||
race = Race.HUMAN;
|
||||
public PonyData(Race race) {
|
||||
this.race = race;
|
||||
tailSize = TailLength.FULL;
|
||||
gender = Gender.MARE;
|
||||
size = Size.NORMAL;
|
||||
|
|
|
@ -70,7 +70,7 @@ public class PonyManager implements IPonyManager, IdentifiableResourceReloadList
|
|||
try {
|
||||
return poniesCache.get(resource);
|
||||
} catch (ExecutionException e) {
|
||||
return new Pony(resource, new PonyData());
|
||||
return new Pony(resource, PonyData.NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import com.minelittlepony.util.Color;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||
import net.minecraft.client.render.OverlayTexture;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
|
@ -17,6 +16,7 @@ import net.minecraft.client.texture.SpriteAtlasTexture;
|
|||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Arm;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
@ -76,8 +76,11 @@ public class LevitatingItemRenderer {
|
|||
/**
|
||||
* Renders an item in first person optionally with a magical overlay.
|
||||
*/
|
||||
public void renderItemInFirstPerson(ItemRenderer itemRenderer, @Nullable AbstractClientPlayerEntity entity, ItemStack stack, ModelTransformation.Type transform, boolean left, MatrixStack matrix, VertexConsumerProvider renderContext, @Nullable World world, int lightUv) {
|
||||
IPony pony = MineLittlePony.getInstance().getManager().getPony(entity);
|
||||
public void renderItemInFirstPerson(ItemRenderer itemRenderer, @Nullable LivingEntity entity, ItemStack stack, ModelTransformation.Type transform, boolean left, MatrixStack matrix, VertexConsumerProvider renderContext, @Nullable World world, int lightUv) {
|
||||
|
||||
if (entity instanceof PlayerEntity) {
|
||||
|
||||
IPony pony = MineLittlePony.getInstance().getManager().getPony((PlayerEntity)entity);
|
||||
|
||||
matrix.push();
|
||||
|
||||
|
@ -103,6 +106,9 @@ public class LevitatingItemRenderer {
|
|||
}
|
||||
|
||||
matrix.pop();
|
||||
} else {
|
||||
itemRenderer.method_23177(entity, stack, transform, left, matrix, renderContext, world, lightUv, OverlayTexture.DEFAULT_UV);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -70,7 +70,7 @@ public class ModelAttributes<T extends LivingEntity> {
|
|||
* Unique id of the interpolator used for this model.
|
||||
* Usually the UUID of the entity being rendered.
|
||||
*/
|
||||
public UUID interpolatorId;
|
||||
public UUID interpolatorId = UUID.randomUUID();
|
||||
|
||||
/**
|
||||
* The actual, visible height of this model when rendered.
|
||||
|
|
Loading…
Reference in a new issue