mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-12-17 23:48:00 +01:00
Add glint and tint to the gem model
This commit is contained in:
parent
86c7ff2150
commit
21ad06c792
1 changed files with 18 additions and 7 deletions
|
@ -1,7 +1,12 @@
|
||||||
package com.minelittlepony.unicopia.client.render.model;
|
package com.minelittlepony.unicopia.client.render.model;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.entity.SpellcastEntity;
|
import com.minelittlepony.unicopia.entity.SpellcastEntity;
|
||||||
import com.minelittlepony.unicopia.item.UItems;
|
import com.minelittlepony.unicopia.item.UItems;
|
||||||
|
import com.minelittlepony.unicopia.magic.Affinity;
|
||||||
|
import com.minelittlepony.unicopia.magic.MagicEffect;
|
||||||
|
import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
|
||||||
import com.minelittlepony.util.Color;
|
import com.minelittlepony.util.Color;
|
||||||
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
@ -19,7 +24,8 @@ public class GemEntityModel extends EntityModel<SpellcastEntity> {
|
||||||
|
|
||||||
private ModelPart body;
|
private ModelPart body;
|
||||||
|
|
||||||
private int tint;
|
@Nullable
|
||||||
|
private MagicEffect effect;
|
||||||
|
|
||||||
public GemEntityModel() {
|
public GemEntityModel() {
|
||||||
textureWidth = 256;
|
textureWidth = 256;
|
||||||
|
@ -31,7 +37,7 @@ public class GemEntityModel extends EntityModel<SpellcastEntity> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAngles(SpellcastEntity entity, float limbAngle, float limbDistance, float customAngle, float headYaw, float headPitch) {
|
public void setAngles(SpellcastEntity entity, float limbAngle, float limbDistance, float customAngle, float headYaw, float headPitch) {
|
||||||
tint = entity.hasEffect() ? entity.getEffect().getTint() : -1;
|
effect = entity.hasEffect() ? entity.getEffect() : null;
|
||||||
|
|
||||||
float floatOffset = MathHelper.sin((entity.age + customAngle) / 10 + entity.hoverStart) / 10 + 0.1F;
|
float floatOffset = MathHelper.sin((entity.age + customAngle) / 10 + entity.hoverStart) / 10 + 0.1F;
|
||||||
|
|
||||||
|
@ -56,18 +62,23 @@ public class GemEntityModel extends EntityModel<SpellcastEntity> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack matrices, VertexConsumer vertexConsumer, int light, int overlay, float red, float green, float blue, float alpha) {
|
public void render(MatrixStack matrices, VertexConsumer vertexConsumer, int light, int overlay, float red, float green, float blue, float alpha) {
|
||||||
if (tint != -1) {
|
if (effect != null) {
|
||||||
red = Color.r(tint);
|
red = Color.r(effect.getTint());
|
||||||
green = Color.g(tint);
|
green = Color.g(effect.getTint());
|
||||||
blue = Color.b(tint);
|
blue = Color.b(effect.getTint());
|
||||||
}
|
}
|
||||||
matrices.push();
|
matrices.push();
|
||||||
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(body.yaw));
|
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(body.yaw));
|
||||||
matrices.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(body.pitch));
|
matrices.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(body.pitch));
|
||||||
matrices.translate(body.pivotX, body.pivotY, body.pivotZ);
|
matrices.translate(body.pivotX, body.pivotY, body.pivotZ);
|
||||||
|
|
||||||
|
ItemStack stack = new ItemStack(effect != null && effect.getAffinity() == Affinity.BAD ? UItems.CORRUPTED_GEM : UItems.GEM);
|
||||||
|
if (effect != null) {
|
||||||
|
SpellRegistry.instance().enchantStack(stack, effect.getName());
|
||||||
|
}
|
||||||
|
|
||||||
MinecraftClient.getInstance().getItemRenderer().renderItem(
|
MinecraftClient.getInstance().getItemRenderer().renderItem(
|
||||||
new ItemStack(UItems.GEM),
|
stack,
|
||||||
ModelTransformation.Mode.GROUND, light,
|
ModelTransformation.Mode.GROUND, light,
|
||||||
overlay,
|
overlay,
|
||||||
matrices,
|
matrices,
|
||||||
|
|
Loading…
Reference in a new issue