Skip to content

Commit

Permalink
fixes some crashes in rendering wearables
Browse files Browse the repository at this point in the history
these can occur due to the new async loading of x3d models
  • Loading branch information
Thutmose committed Jun 29, 2020
1 parent ab1df88 commit d7ed23e
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main/java/pokecube/core/items/megastuff/WearablesCompat.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ public void renderWearable(final MatrixStack mat, final IRenderTypeBuffer buff,
this.strap = new ResourceLocation(PokecubeMod.ID, "textures/worn/megabelt_2.png");
this.watch = new ResourceLocation(PokecubeMod.ID, "textures/worn/watch.png");
}
if (!this.model.isLoaded() || !this.model.isValid()) return;
float s, sy, sx, sz, dx, dy, dz;
dx = 0.f;
dy = .06f;
Expand Down Expand Up @@ -221,10 +222,10 @@ public void renderWearable(final MatrixStack mat, final IRenderTypeBuffer buff,
mat.scale(s, s, s);
mat.rotate(net.minecraft.client.renderer.Vector3f.YP.rotationDegrees(90));
buf = ModelRing.makeBuilder(buff, ModelRing.texture_1);
ring.pass = 1;
this.ring.pass = 1;
this.ring.render(mat, buf, brightness, overlay, 1, 1, 1, 1);
buf = ModelRing.makeBuilder(buff, ModelRing.texture_2);
ring.pass = 2;
this.ring.pass = 2;
this.ring.render(mat, buf, brightness, overlay, 1, 1, 1, 1);
}
});
Expand All @@ -251,6 +252,7 @@ public void renderWearable(final MatrixStack mat, final IRenderTypeBuffer buff,
this.keystone = new ResourceLocation(PokecubeMod.ID, "textures/worn/keystone.png");
this.belt_2 = new ResourceLocation(PokecubeMod.ID, "textures/worn/megabelt_2.png");
}
if (!this.belt.isLoaded() || !this.belt.isValid()) return;
float s, dx, dy, dz;
dx = 0;
dy = -.0f;
Expand Down Expand Up @@ -298,6 +300,7 @@ public void renderWearable(final MatrixStack mat, final IRenderTypeBuffer buff,
if (slot != EnumWearable.HAT) return;
if (this.hat == null)
this.hat = new X3dModel(new ResourceLocation(PokecubeMod.ID, "models/worn/hat.x3d"));
if (!this.hat.isLoaded() || !this.hat.isValid()) return;
Hat.renderHat(mat, buff, wearer, stack, this.hat, this.TEX, brightness, overlay);
}
});
Expand All @@ -310,11 +313,8 @@ public static void init()
final Set<ItemStack> worn = thut.wearables.ThutWearables.getWearables(player).getWearables();
for (final ItemStack stack1 : worn)
if (stack1 != null) if (MegaCapability.matches(stack1, toEvolve)) return true;
for (int i = 0; i < player.inventory.armorInventory.size(); i++)
{
final ItemStack stack2 = player.inventory.armorInventory.get(i);
for (final ItemStack stack2 : player.inventory.armorInventory)
if (stack2 != null) if (MegaCapability.matches(stack2, toEvolve)) return true;
}
return false;
};
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/thut/bling/client/render/Ankle.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public static void renderAnkle(final MatrixStack mat, final IRenderTypeBuffer bu
final ItemStack stack, final IModel model, final ResourceLocation[] textures, final int brightness,
final int overlay)
{
if (!model.isLoaded() || !model.isValid()) return;
float s, sy, sx, sz, dx, dy, dz;
dx = 0.f;
dy = .06f;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/thut/bling/client/render/Back.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public static void renderBack(final MatrixStack mat, final IRenderTypeBuffer buf
final int overlay)
{
if (!(model instanceof IModelCustom)) return;
if (!model.isLoaded() || !model.isValid()) return;
final IModelCustom renderable = (IModelCustom) model;

DyeColor ret;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/thut/bling/client/render/Ear.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public static void renderEar(final MatrixStack mat, final IRenderTypeBuffer buff
final ItemStack stack, final IModel model, final ResourceLocation[] textures, final int brightness,
final int overlay)
{
if (!model.isLoaded() || !model.isValid()) return;
float s, dx, dy, dz;
dx = 0.0f;
dy = .175f;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/thut/bling/client/render/Eye.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public static void renderEye(final MatrixStack mat, final IRenderTypeBuffer buff
final ItemStack stack, final IModel model, final ResourceLocation[] textures, final int brightness,
final int overlay)
{
if (!model.isLoaded() || !model.isValid()) return;
// TODO eye by model instead of texture.
mat.push();
mat.translate(-0.26, -0.175, -0.251);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/thut/bling/client/render/Finger.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public static void renderFinger(final MatrixStack mat, final IRenderTypeBuffer b
final ItemStack stack, final IModel model, final ResourceLocation[] textures, final int brightness,
final int overlay)
{
if (!model.isLoaded() || !model.isValid()) return;
float s, dx, dy, dz;
dx = 0.0f;
dy = .175f;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/thut/bling/client/render/Hat.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public static void renderHat(final MatrixStack mat, final IRenderTypeBuffer buff
{
if (!(model instanceof IModelCustom)) return;
final IModelCustom renderable = (IModelCustom) model;
if (!model.isLoaded() || !model.isValid()) return;

DyeColor ret;
Color colour;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/thut/bling/client/render/Neck.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public static void renderNeck(final MatrixStack mat, final IRenderTypeBuffer buf
final int overlay)
{
if (!(model instanceof IModelCustom)) return;
if (!model.isLoaded() || !model.isValid()) return;
final ResourceLocation[] tex = textures.clone();
final IModelCustom renderable = (IModelCustom) model;
DyeColor ret;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/thut/bling/client/render/Waist.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public static void renderWaist(final MatrixStack mat, final IRenderTypeBuffer bu
final ItemStack stack, final IModel model, final ResourceLocation[] textures, final int brightness,
final int overlay)
{
if (!model.isLoaded() || !model.isValid()) return;
float s, dx, dy, dz;
dx = 0;
dy = -.0f;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/thut/bling/client/render/Wrist.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public static void renderWrist(final MatrixStack mat, final IRenderTypeBuffer bu
final ItemStack stack, final IModel model, final ResourceLocation[] textures, final int brightness,
final int overlay)
{
if (!model.isLoaded() || !model.isValid()) return;
float s, sy, sx, sz, dx, dy, dz;
dx = 0.f;
dy = .06f;
Expand Down

0 comments on commit d7ed23e

Please sign in to comment.