mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-13 16:24: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 javax.annotation.Nullable;
|
||||||
|
|
||||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
|
||||||
import net.minecraft.client.render.FirstPersonRenderer;
|
import net.minecraft.client.render.FirstPersonRenderer;
|
||||||
import net.minecraft.client.render.VertexConsumerProvider;
|
import net.minecraft.client.render.VertexConsumerProvider;
|
||||||
import net.minecraft.client.render.model.json.ModelTransformation.Type;
|
import net.minecraft.client.render.model.json.ModelTransformation.Type;
|
||||||
|
@ -43,6 +42,6 @@ abstract class MixinFirstPersonRenderer {
|
||||||
VertexConsumerProvider renderContext,
|
VertexConsumerProvider renderContext,
|
||||||
@Nullable World world,
|
@Nullable World world,
|
||||||
int lightUv, int overlayUv) {
|
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.
|
* Associated pony data.
|
||||||
*/
|
*/
|
||||||
protected IPonyData metadata = new PonyData();
|
protected IPonyData metadata = PonyData.NULL;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateLivingState(T entity, IPony pony, EquineRenderManager.Mode mode) {
|
public void updateLivingState(T entity, IPony pony, EquineRenderManager.Mode mode) {
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class PonySkullModel extends SkullOverlayEntityModel implements MsonModel
|
||||||
|
|
||||||
private ModelPart hair;
|
private ModelPart hair;
|
||||||
|
|
||||||
public IPonyData metadata = new PonyData();
|
public IPonyData metadata = PonyData.NULL;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(ModelContext context) {
|
public void init(ModelContext context) {
|
||||||
|
|
|
@ -35,13 +35,15 @@ public class PonyData implements IPonyData {
|
||||||
|
|
||||||
private static final PonyDataSerialiser SERIALISER = new PonyDataSerialiser();
|
private static final PonyDataSerialiser SERIALISER = new PonyDataSerialiser();
|
||||||
|
|
||||||
|
public static final IPonyData NULL = new PonyData(Race.HUMAN);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses the given resource into a new IPonyData.
|
* Parses the given resource into a new IPonyData.
|
||||||
* This may either come from an attached json file or the image itself.
|
* This may either come from an attached json file or the image itself.
|
||||||
*/
|
*/
|
||||||
public static IPonyData parse(@Nullable Identifier identifier) {
|
public static IPonyData parse(@Nullable Identifier identifier) {
|
||||||
if (identifier == null) {
|
if (identifier == null) {
|
||||||
return new PonyData();
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
try (Resource res = MinecraftClient.getInstance().getResourceManager().getResource(identifier)) {
|
try (Resource res = MinecraftClient.getInstance().getResourceManager().getResource(identifier)) {
|
||||||
|
@ -60,7 +62,7 @@ public class PonyData implements IPonyData {
|
||||||
return NativeUtil.parseImage(identifier, PonyData::new);
|
return NativeUtil.parseImage(identifier, PonyData::new);
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
MineLittlePony.logger.fatal("Unable to read {} metadata", identifier, 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
|
@Expose
|
||||||
private final boolean[] wearables;
|
private final boolean[] wearables;
|
||||||
|
|
||||||
public PonyData() {
|
public PonyData(Race race) {
|
||||||
race = Race.HUMAN;
|
this.race = race;
|
||||||
tailSize = TailLength.FULL;
|
tailSize = TailLength.FULL;
|
||||||
gender = Gender.MARE;
|
gender = Gender.MARE;
|
||||||
size = Size.NORMAL;
|
size = Size.NORMAL;
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class PonyManager implements IPonyManager, IdentifiableResourceReloadList
|
||||||
try {
|
try {
|
||||||
return poniesCache.get(resource);
|
return poniesCache.get(resource);
|
||||||
} catch (ExecutionException e) {
|
} 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 javax.annotation.Nullable;
|
||||||
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
|
||||||
import net.minecraft.client.render.OverlayTexture;
|
import net.minecraft.client.render.OverlayTexture;
|
||||||
import net.minecraft.client.render.RenderLayer;
|
import net.minecraft.client.render.RenderLayer;
|
||||||
import net.minecraft.client.render.VertexConsumerProvider;
|
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.MatrixStack;
|
||||||
import net.minecraft.client.util.math.Vector3f;
|
import net.minecraft.client.util.math.Vector3f;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.Arm;
|
import net.minecraft.util.Arm;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
@ -76,33 +76,39 @@ public class LevitatingItemRenderer {
|
||||||
/**
|
/**
|
||||||
* Renders an item in first person optionally with a magical overlay.
|
* 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) {
|
public void renderItemInFirstPerson(ItemRenderer itemRenderer, @Nullable LivingEntity entity, ItemStack stack, ModelTransformation.Type transform, boolean left, MatrixStack matrix, VertexConsumerProvider renderContext, @Nullable World world, int lightUv) {
|
||||||
IPony pony = MineLittlePony.getInstance().getManager().getPony(entity);
|
|
||||||
|
|
||||||
matrix.push();
|
if (entity instanceof PlayerEntity) {
|
||||||
|
|
||||||
boolean doMagic = MineLittlePony.getInstance().getConfig().fpsmagic.get() && pony.getMetadata().hasMagic();
|
IPony pony = MineLittlePony.getInstance().getManager().getPony((PlayerEntity)entity);
|
||||||
|
|
||||||
if (doMagic) {
|
matrix.push();
|
||||||
setupPerspective(itemRenderer, entity, stack, left, matrix);
|
|
||||||
}
|
|
||||||
|
|
||||||
itemRenderer.method_23177(entity, stack, transform, left, matrix, renderContext, world, lightUv, OverlayTexture.DEFAULT_UV);
|
boolean doMagic = MineLittlePony.getInstance().getConfig().fpsmagic.get() && pony.getMetadata().hasMagic();
|
||||||
|
|
||||||
if (doMagic) {
|
if (doMagic) {
|
||||||
setColor(pony.getMetadata().getGlowColor());
|
setupPerspective(itemRenderer, entity, stack, left, matrix);
|
||||||
|
}
|
||||||
|
|
||||||
matrix.scale(1.1F, 1.1F, 1.1F);
|
|
||||||
|
|
||||||
matrix.translate(0.015F, 0.01F, 0.01F);
|
|
||||||
itemRenderer.method_23177(entity, stack, transform, left, matrix, renderContext, world, lightUv, OverlayTexture.DEFAULT_UV);
|
|
||||||
matrix.translate(-0.03F, -0.02F, -0.02F);
|
|
||||||
itemRenderer.method_23177(entity, stack, transform, left, matrix, renderContext, world, lightUv, OverlayTexture.DEFAULT_UV);
|
itemRenderer.method_23177(entity, stack, transform, left, matrix, renderContext, world, lightUv, OverlayTexture.DEFAULT_UV);
|
||||||
|
|
||||||
unsetColor();
|
if (doMagic) {
|
||||||
}
|
setColor(pony.getMetadata().getGlowColor());
|
||||||
|
|
||||||
matrix.pop();
|
matrix.scale(1.1F, 1.1F, 1.1F);
|
||||||
|
|
||||||
|
matrix.translate(0.015F, 0.01F, 0.01F);
|
||||||
|
itemRenderer.method_23177(entity, stack, transform, left, matrix, renderContext, world, lightUv, OverlayTexture.DEFAULT_UV);
|
||||||
|
matrix.translate(-0.03F, -0.02F, -0.02F);
|
||||||
|
itemRenderer.method_23177(entity, stack, transform, left, matrix, renderContext, world, lightUv, OverlayTexture.DEFAULT_UV);
|
||||||
|
|
||||||
|
unsetColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
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.
|
* Unique id of the interpolator used for this model.
|
||||||
* Usually the UUID of the entity being rendered.
|
* 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.
|
* The actual, visible height of this model when rendered.
|
||||||
|
|
Loading…
Reference in a new issue