mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-29 23:48:00 +01:00
Backport: Fix compatibility with CCL and any other mods that use the old proxy object pattern
This commit is contained in:
parent
eb62d495a6
commit
1c64e49862
6 changed files with 32 additions and 61 deletions
|
@ -1,9 +0,0 @@
|
||||||
package com.minelittlepony.ducks;
|
|
||||||
|
|
||||||
public interface IRenderItem {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets whether items should be rendered with transparency support.
|
|
||||||
*/
|
|
||||||
void useTransparency(boolean use);
|
|
||||||
}
|
|
|
@ -6,7 +6,6 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
import com.minelittlepony.render.LevitatingItemRenderer;
|
import com.minelittlepony.render.LevitatingItemRenderer;
|
||||||
import com.minelittlepony.render.skull.PonySkullRenderer;
|
|
||||||
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
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)
|
@Inject(method = "enableBlendProfile(Lnet/minecraft/client/renderer/GlStateManager$Profile;)V", at = @At("HEAD"), cancellable = true)
|
||||||
private static void enableBlendProfile(GlStateManager.Profile profile, CallbackInfo info) {
|
private static void enableBlendProfile(GlStateManager.Profile profile, CallbackInfo info) {
|
||||||
if (profile == GlStateManager.Profile.PLAYER_SKIN && PonySkullRenderer.ponyInstance.usesTransparency()) {
|
if (profile == GlStateManager.Profile.PLAYER_SKIN && LevitatingItemRenderer.enableItemGlowRenderProfile()) {
|
||||||
LevitatingItemRenderer.enableItemGlowRenderProfile();
|
|
||||||
info.cancel();
|
info.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.minelittlepony.mixin;
|
package com.minelittlepony.mixin;
|
||||||
|
|
||||||
import com.minelittlepony.ducks.IRenderItem;
|
|
||||||
import com.minelittlepony.render.LevitatingItemRenderer;
|
import com.minelittlepony.render.LevitatingItemRenderer;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.RenderItem;
|
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;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
@Mixin(RenderItem.class)
|
@Mixin(RenderItem.class)
|
||||||
public abstract class MixinRenderItem implements IResourceManagerReloadListener, IRenderItem {
|
public abstract class MixinRenderItem implements IResourceManagerReloadListener {
|
||||||
|
|
||||||
private boolean transparency;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void useTransparency(boolean transparency) {
|
|
||||||
this.transparency = transparency;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/renderer/block/model/IBakedModel;)V", at = @At("HEAD"))
|
@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) {
|
private void onRenderItem(ItemStack stack, IBakedModel model, CallbackInfo info) {
|
||||||
if (transparency) {
|
|
||||||
LevitatingItemRenderer.enableItemGlowRenderProfile();
|
LevitatingItemRenderer.enableItemGlowRenderProfile();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@ModifyArg(method = "renderQuads(Lnet/minecraft/client/renderer/BufferBuilder;Ljava/util/List;ILnet/minecraft/item/ItemStack;)V",
|
@ModifyArg(method = "renderQuads(Lnet/minecraft/client/renderer/BufferBuilder;Ljava/util/List;ILnet/minecraft/item/ItemStack;)V",
|
||||||
at = @At(value = "INVOKE",
|
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"),
|
target = "Lnet/minecraft/client/renderer/RenderItem;renderQuad(Lnet/minecraft/client/renderer/BufferBuilder;Lnet/minecraft/client/renderer/block/model/BakedQuad;I)V"),
|
||||||
index = 2)
|
index = 2)
|
||||||
private int modifyItemRenderTint(int color) {
|
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)
|
@Inject(method = "renderEffect(Lnet/minecraft/client/renderer/block/model/IBakedModel;)V", at = @At("HEAD"), cancellable = true)
|
||||||
private void renderEffect(IBakedModel model, CallbackInfo info) {
|
private void renderEffect(IBakedModel model, CallbackInfo info) {
|
||||||
if (transparency) {
|
if (LevitatingItemRenderer.usesTransparency()) {
|
||||||
info.cancel();
|
info.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,7 @@ package com.minelittlepony.render;
|
||||||
import org.lwjgl.opengl.GL14;
|
import org.lwjgl.opengl.GL14;
|
||||||
|
|
||||||
import com.minelittlepony.MineLittlePony;
|
import com.minelittlepony.MineLittlePony;
|
||||||
import com.minelittlepony.ducks.IRenderItem;
|
|
||||||
import com.minelittlepony.pony.data.IPony;
|
import com.minelittlepony.pony.data.IPony;
|
||||||
import com.minelittlepony.render.skull.PonySkullRenderer;
|
|
||||||
import com.minelittlepony.util.render.Color;
|
import com.minelittlepony.util.render.Color;
|
||||||
import com.mumfrey.liteloader.client.overlays.IMinecraft;
|
import com.mumfrey.liteloader.client.overlays.IMinecraft;
|
||||||
|
|
||||||
|
@ -25,12 +23,22 @@ import static net.minecraft.client.renderer.GlStateManager.*;
|
||||||
|
|
||||||
public class LevitatingItemRenderer {
|
public class LevitatingItemRenderer {
|
||||||
|
|
||||||
public static void enableItemGlowRenderProfile() {
|
private static boolean usingTransparency;
|
||||||
|
|
||||||
|
public static boolean enableItemGlowRenderProfile() {
|
||||||
|
if (usesTransparency()) {
|
||||||
GlStateManager.enableBlend();
|
GlStateManager.enableBlend();
|
||||||
GlStateManager.tryBlendFuncSeparate(SourceFactor.CONSTANT_COLOR, DestFactor.ONE, SourceFactor.ONE, DestFactor.ZERO);
|
GlStateManager.tryBlendFuncSeparate(SourceFactor.CONSTANT_COLOR, DestFactor.ONE, SourceFactor.ONE, DestFactor.ZERO);
|
||||||
Minecraft.getMinecraft().entityRenderer.disableLightmap();
|
Minecraft.getMinecraft().entityRenderer.disableLightmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return usesTransparency();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean usesTransparency() {
|
||||||
|
return usingTransparency;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders a magical overlay over an item in third person.
|
* Renders a magical overlay over an item in third person.
|
||||||
*/
|
*/
|
||||||
|
@ -40,18 +48,17 @@ public class LevitatingItemRenderer {
|
||||||
setColor(glowColor);
|
setColor(glowColor);
|
||||||
|
|
||||||
RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
|
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);
|
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);
|
renderItem.renderItem(drop, entity, transform, hand == EnumHandSide.LEFT);
|
||||||
|
|
||||||
((IRenderItem) renderItem).useTransparency(false);
|
usingTransparency = false;
|
||||||
PonySkullRenderer.ponyInstance.useTransparency(false);
|
|
||||||
unsetColor();
|
unsetColor();
|
||||||
enableLighting();
|
enableLighting();
|
||||||
popMatrix();
|
popMatrix();
|
||||||
|
@ -86,21 +93,18 @@ public class LevitatingItemRenderer {
|
||||||
if (doMagic) {
|
if (doMagic) {
|
||||||
disableLighting();
|
disableLighting();
|
||||||
|
|
||||||
IRenderItem renderItem = (IRenderItem)Minecraft.getMinecraft().getRenderItem();
|
usingTransparency = true;
|
||||||
renderItem.useTransparency(true);
|
|
||||||
PonySkullRenderer.ponyInstance.useTransparency(true);
|
|
||||||
|
|
||||||
setColor(pony.getMetadata().getGlowColor());
|
setColor(pony.getMetadata().getGlowColor());
|
||||||
|
|
||||||
scale(1.1, 1.1, 1.1);
|
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);
|
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);
|
renderer.renderItemSide(entity, stack, transform, left);
|
||||||
|
|
||||||
renderItem.useTransparency(false);
|
usingTransparency = false;
|
||||||
PonySkullRenderer.ponyInstance.useTransparency(false);
|
|
||||||
|
|
||||||
unsetColor();
|
unsetColor();
|
||||||
enableLighting();
|
enableLighting();
|
||||||
|
|
|
@ -2,8 +2,8 @@ package com.minelittlepony.render.skull;
|
||||||
|
|
||||||
import com.minelittlepony.MineLittlePony;
|
import com.minelittlepony.MineLittlePony;
|
||||||
import com.minelittlepony.PonyConfig;
|
import com.minelittlepony.PonyConfig;
|
||||||
import com.minelittlepony.ducks.IRenderItem;
|
|
||||||
import com.minelittlepony.pony.data.IPony;
|
import com.minelittlepony.pony.data.IPony;
|
||||||
|
import com.minelittlepony.render.LevitatingItemRenderer;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mumfrey.liteloader.util.ModUtilities;
|
import com.mumfrey.liteloader.util.ModUtilities;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
|
@ -20,7 +20,7 @@ import javax.annotation.Nullable;
|
||||||
/**
|
/**
|
||||||
* PonySkullRenderer! It renders ponies as skulls, or something...
|
* 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 SKELETON = 0;
|
||||||
public static final int WITHER = 1;
|
public static final int WITHER = 1;
|
||||||
|
@ -68,8 +68,6 @@ public class PonySkullRenderer extends TileEntitySkullRenderer implements IRende
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean transparency = false;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderSkull(float x, float y, float z, EnumFacing facing, float rotation, int skullType, @Nullable GameProfile profile, int destroyStage, float animateTicks) {
|
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.scale(-1, -1, 1);
|
||||||
GlStateManager.enableAlpha();
|
GlStateManager.enableAlpha();
|
||||||
|
|
||||||
skull.preRender(transparency);
|
skull.preRender(LevitatingItemRenderer.usesTransparency());
|
||||||
skull.render(animateTicks, rotation, scale);
|
skull.render(animateTicks, rotation, scale);
|
||||||
|
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
|
@ -146,15 +144,6 @@ public class PonySkullRenderer extends TileEntitySkullRenderer implements IRende
|
||||||
return rotation;
|
return rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void useTransparency(boolean use) {
|
|
||||||
transparency = use;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean usesTransparency() {
|
|
||||||
return transparency;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A skull, just a skull.
|
* A skull, just a skull.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.minelittlepony.transform;
|
package com.minelittlepony.transform;
|
||||||
|
|
||||||
import com.minelittlepony.model.AbstractPonyModel;
|
|
||||||
import com.minelittlepony.model.capabilities.IModel;
|
import com.minelittlepony.model.capabilities.IModel;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
|
|
Loading…
Reference in a new issue