Fixed magic rendering of items that have permanent enchantment effects AND items with a dark tint

This commit is contained in:
Sollace 2018-08-18 14:15:05 +02:00
parent ad18186382
commit dca3cad2cd
2 changed files with 19 additions and 17 deletions

View file

@ -1,6 +1,7 @@
package com.minelittlepony.mixin;
import com.minelittlepony.ducks.IRenderItem;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.GlStateManager.DestFactor;
import net.minecraft.client.renderer.GlStateManager.SourceFactor;
@ -12,6 +13,7 @@ import net.minecraft.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(RenderItem.class)
@ -30,4 +32,19 @@ public abstract class MixinRenderItem implements IResourceManagerReloadListener,
GlStateManager.tryBlendFuncSeparate(SourceFactor.CONSTANT_COLOR, DestFactor.ONE, SourceFactor.ONE, DestFactor.ZERO);
}
}
@ModifyArg(method = "renderQuads(Lnet/minecraft/client/renderer/BufferBuilder;ILjava/util/List;Lnet/minecraft/item/Itemstack;)V",
at = @At(value = "INVOKE",
target = "renderQuad(Lnet/minecraft/client/renderer/BufferBuilder;Lnet/minecraft/client/renderer/block/model/BakedQuad;I)V"),
index = 2)
private int modifyItemRenderTint(int color) {
return transparency ? -1 : color;
}
@Inject(method = "renderEffect(Lnet/minecraft/client/renderer/block/model/IBakedQuad;)V", at = @At("HEAD"), cancellable = true)
private void renderEffect(IBakedModel model, CallbackInfo info) {
if (transparency) {
info.cancel();
}
}
}

View file

@ -25,10 +25,6 @@ public class LevitatingItemRenderer {
* Renders a magical overlay over an item in third person.
*/
public void renderItemGlow(EntityLivingBase entity, ItemStack drop, TransformType transform, EnumHandSide hand, int glowColor) {
// enchantments mess up the rendering
drop = stackWithoutEnchantment(drop);
pushMatrix();
disableLighting();
setColor(glowColor);
@ -65,7 +61,6 @@ public class LevitatingItemRenderer {
* Renders an item in first person optionally with a magical overlay.
*/
public void renderItemInFirstPerson(ItemRenderer renderer, AbstractClientPlayer entity, ItemStack stack, TransformType transform, boolean left) {
Pony pony = MineLittlePony.getInstance().getManager().getPony(entity);
pushMatrix();
@ -79,7 +74,6 @@ public class LevitatingItemRenderer {
renderer.renderItemSide(entity, stack, transform, left);
if (doMagic) {
disableLighting();
IRenderItem renderItem = (IRenderItem)Minecraft.getMinecraft().getRenderItem();
@ -90,9 +84,9 @@ public class LevitatingItemRenderer {
scale(1.1, 1.1, 1.1);
translate(0, 0.01F, 0.01F);
translate(-0.015F, 0.01F, 0.01F);
renderer.renderItemSide(entity, stack, transform, left);
translate(0.01F, -0.01F, -0.02F);
translate(0.03F, -0.01F, -0.02F);
renderer.renderItemSide(entity, stack, transform, left);
renderItem.useTransparency(false);
@ -135,13 +129,4 @@ public class LevitatingItemRenderer {
}
}
}
private ItemStack stackWithoutEnchantment(ItemStack original) {
if (original.isItemEnchanted()) {
original = original.copy();
original.getTagCompound().removeTag("ench");
}
return original;
}
}