Backport: Fix compatibility with CCL and any other mods that use the old proxy object pattern

This commit is contained in:
Sollace 2019-06-27 12:37:08 +02:00
parent eb62d495a6
commit 1c64e49862
6 changed files with 32 additions and 61 deletions

View file

@ -1,9 +0,0 @@
package com.minelittlepony.ducks;
public interface IRenderItem {
/**
* Sets whether items should be rendered with transparency support.
*/
void useTransparency(boolean use);
}

View file

@ -6,7 +6,6 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.minelittlepony.render.LevitatingItemRenderer;
import com.minelittlepony.render.skull.PonySkullRenderer;
import net.minecraft.client.renderer.GlStateManager;
@ -15,8 +14,7 @@ public abstract class MixinGlStateManager {
@Inject(method = "enableBlendProfile(Lnet/minecraft/client/renderer/GlStateManager$Profile;)V", at = @At("HEAD"), cancellable = true)
private static void enableBlendProfile(GlStateManager.Profile profile, CallbackInfo info) {
if (profile == GlStateManager.Profile.PLAYER_SKIN && PonySkullRenderer.ponyInstance.usesTransparency()) {
LevitatingItemRenderer.enableItemGlowRenderProfile();
if (profile == GlStateManager.Profile.PLAYER_SKIN && LevitatingItemRenderer.enableItemGlowRenderProfile()) {
info.cancel();
}
}

View file

@ -1,6 +1,5 @@
package com.minelittlepony.mixin;
import com.minelittlepony.ducks.IRenderItem;
import com.minelittlepony.render.LevitatingItemRenderer;
import net.minecraft.client.renderer.RenderItem;
@ -15,33 +14,24 @@ import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(RenderItem.class)
public abstract class MixinRenderItem implements IResourceManagerReloadListener, IRenderItem {
private boolean transparency;
@Override
public void useTransparency(boolean transparency) {
this.transparency = transparency;
}
public abstract class MixinRenderItem implements IResourceManagerReloadListener {
@Inject(method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/renderer/block/model/IBakedModel;)V", at = @At("HEAD"))
private void onRenderItem(ItemStack stack, IBakedModel model, CallbackInfo info) {
if (transparency) {
LevitatingItemRenderer.enableItemGlowRenderProfile();
}
}
@ModifyArg(method = "renderQuads(Lnet/minecraft/client/renderer/BufferBuilder;Ljava/util/List;ILnet/minecraft/item/ItemStack;)V",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/client/renderer/RenderItem;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;
return LevitatingItemRenderer.usesTransparency() ? -1 : color;
}
@Inject(method = "renderEffect(Lnet/minecraft/client/renderer/block/model/IBakedModel;)V", at = @At("HEAD"), cancellable = true)
private void renderEffect(IBakedModel model, CallbackInfo info) {
if (transparency) {
if (LevitatingItemRenderer.usesTransparency()) {
info.cancel();
}
}

View file

@ -3,9 +3,7 @@ package com.minelittlepony.render;
import org.lwjgl.opengl.GL14;
import com.minelittlepony.MineLittlePony;
import com.minelittlepony.ducks.IRenderItem;
import com.minelittlepony.pony.data.IPony;
import com.minelittlepony.render.skull.PonySkullRenderer;
import com.minelittlepony.util.render.Color;
import com.mumfrey.liteloader.client.overlays.IMinecraft;
@ -25,12 +23,22 @@ import static net.minecraft.client.renderer.GlStateManager.*;
public class LevitatingItemRenderer {
public static void enableItemGlowRenderProfile() {
private static boolean usingTransparency;
public static boolean enableItemGlowRenderProfile() {
if (usesTransparency()) {
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(SourceFactor.CONSTANT_COLOR, DestFactor.ONE, SourceFactor.ONE, DestFactor.ZERO);
Minecraft.getMinecraft().entityRenderer.disableLightmap();
}
return usesTransparency();
}
public static boolean usesTransparency() {
return usingTransparency;
}
/**
* Renders a magical overlay over an item in third person.
*/
@ -40,18 +48,17 @@ public class LevitatingItemRenderer {
setColor(glowColor);
RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
((IRenderItem) renderItem).useTransparency(true);
PonySkullRenderer.ponyInstance.useTransparency(true);
scale(1.1, 1.1, 1.1);
usingTransparency = true;
translate(0, 0.01F, 0.01F);
scale(1.1F, 1.1F, 1.1F);
translate(0.1F, 0.01F, 0.01F);
renderItem.renderItem(drop, entity, transform, hand == EnumHandSide.LEFT);
translate(0.01F, -0.01F, -0.02F);
translate(-0.02F, -0.02F, -0.02F);
renderItem.renderItem(drop, entity, transform, hand == EnumHandSide.LEFT);
((IRenderItem) renderItem).useTransparency(false);
PonySkullRenderer.ponyInstance.useTransparency(false);
usingTransparency = false;
unsetColor();
enableLighting();
popMatrix();
@ -86,21 +93,18 @@ public class LevitatingItemRenderer {
if (doMagic) {
disableLighting();
IRenderItem renderItem = (IRenderItem)Minecraft.getMinecraft().getRenderItem();
renderItem.useTransparency(true);
PonySkullRenderer.ponyInstance.useTransparency(true);
usingTransparency = true;
setColor(pony.getMetadata().getGlowColor());
scale(1.1, 1.1, 1.1);
translate(-0.015F, 0.01F, 0.01F);
translate(0.01F, 0.01F, 0.01F);
renderer.renderItemSide(entity, stack, transform, left);
translate(0.03F, -0.01F, -0.02F);
translate(-0.02F, -0.02F, -0.02F);
renderer.renderItemSide(entity, stack, transform, left);
renderItem.useTransparency(false);
PonySkullRenderer.ponyInstance.useTransparency(false);
usingTransparency = false;
unsetColor();
enableLighting();

View file

@ -2,8 +2,8 @@ package com.minelittlepony.render.skull;
import com.minelittlepony.MineLittlePony;
import com.minelittlepony.PonyConfig;
import com.minelittlepony.ducks.IRenderItem;
import com.minelittlepony.pony.data.IPony;
import com.minelittlepony.render.LevitatingItemRenderer;
import com.mojang.authlib.GameProfile;
import com.mumfrey.liteloader.util.ModUtilities;
import net.minecraft.client.renderer.GlStateManager;
@ -20,7 +20,7 @@ import javax.annotation.Nullable;
/**
* PonySkullRenderer! It renders ponies as skulls, or something...
*/
public class PonySkullRenderer extends TileEntitySkullRenderer implements IRenderItem {
public class PonySkullRenderer extends TileEntitySkullRenderer {
public static final int SKELETON = 0;
public static final int WITHER = 1;
@ -68,8 +68,6 @@ public class PonySkullRenderer extends TileEntitySkullRenderer implements IRende
return instance;
}
protected boolean transparency = false;
@Override
public void renderSkull(float x, float y, float z, EnumFacing facing, float rotation, int skullType, @Nullable GameProfile profile, int destroyStage, float animateTicks) {
@ -111,7 +109,7 @@ public class PonySkullRenderer extends TileEntitySkullRenderer implements IRende
GlStateManager.scale(-1, -1, 1);
GlStateManager.enableAlpha();
skull.preRender(transparency);
skull.preRender(LevitatingItemRenderer.usesTransparency());
skull.render(animateTicks, rotation, scale);
GlStateManager.popMatrix();
@ -146,15 +144,6 @@ public class PonySkullRenderer extends TileEntitySkullRenderer implements IRende
return rotation;
}
@Override
public void useTransparency(boolean use) {
transparency = use;
}
public boolean usesTransparency() {
return transparency;
}
/**
* A skull, just a skull.
*

View file

@ -1,6 +1,5 @@
package com.minelittlepony.transform;
import com.minelittlepony.model.AbstractPonyModel;
import com.minelittlepony.model.capabilities.IModel;
import net.minecraft.client.renderer.GlStateManager;