mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-13 16:24:23 +01:00
Fixed compatibility with CCL and other mods using the old proxy object pattern
This commit is contained in:
parent
fe82f60ca3
commit
4ddbc897cf
5 changed files with 27 additions and 62 deletions
|
@ -1,14 +0,0 @@
|
||||||
package com.minelittlepony.client.ducks;
|
|
||||||
|
|
||||||
public interface IRenderItem {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets whether items should be rendered with transparency support.
|
|
||||||
*/
|
|
||||||
void useTransparency(boolean use);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if this renderer is set to render models as a transparent overlay.
|
|
||||||
*/
|
|
||||||
boolean usesTransparency();
|
|
||||||
}
|
|
|
@ -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.client.render.LevitatingItemRenderer;
|
import com.minelittlepony.client.render.LevitatingItemRenderer;
|
||||||
import com.minelittlepony.client.render.tileentities.skull.PonySkullRenderer;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
|
|
||||||
|
@ -18,8 +17,7 @@ public abstract class MixinGlStateManager {
|
||||||
at = @At("HEAD"),
|
at = @At("HEAD"),
|
||||||
cancellable = true)
|
cancellable = true)
|
||||||
private static void enableBlendProfile(GlStateManager.RenderMode profile, CallbackInfo info) {
|
private static void enableBlendProfile(GlStateManager.RenderMode profile, CallbackInfo info) {
|
||||||
if (profile == GlStateManager.RenderMode.PLAYER_SKIN && PonySkullRenderer.ponyInstance.usesTransparency()) {
|
if (profile == GlStateManager.RenderMode.PLAYER_SKIN && LevitatingItemRenderer.enableItemGlowRenderProfile()) {
|
||||||
LevitatingItemRenderer.enableItemGlowRenderProfile();
|
|
||||||
info.cancel();
|
info.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.minelittlepony.client.mixin;
|
package com.minelittlepony.client.mixin;
|
||||||
|
|
||||||
import com.minelittlepony.client.ducks.IRenderItem;
|
|
||||||
import com.minelittlepony.client.render.LevitatingItemRenderer;
|
import com.minelittlepony.client.render.LevitatingItemRenderer;
|
||||||
|
|
||||||
import net.minecraft.client.render.item.ItemRenderer;
|
import net.minecraft.client.render.item.ItemRenderer;
|
||||||
|
@ -15,24 +14,15 @@ import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
@Mixin(ItemRenderer.class)
|
@Mixin(ItemRenderer.class)
|
||||||
public abstract class MixinItemRenderer implements SynchronousResourceReloadListener, IRenderItem {
|
public abstract class MixinItemRenderer implements SynchronousResourceReloadListener {
|
||||||
|
|
||||||
private boolean transparency;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void useTransparency(boolean transparency) {
|
|
||||||
this.transparency = transparency;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "renderItemAndGlow("
|
@Inject(method = "renderItemAndGlow("
|
||||||
+ "Lnet/minecraft/item/ItemStack;"
|
+ "Lnet/minecraft/item/ItemStack;"
|
||||||
+ "Lnet/minecraft/client/render/model/BakedModel;)V",
|
+ "Lnet/minecraft/client/render/model/BakedModel;)V",
|
||||||
at = @At("HEAD"))
|
at = @At("HEAD"))
|
||||||
private void onRenderItem(ItemStack stack, BakedModel model, CallbackInfo info) {
|
private void onRenderItem(ItemStack stack, BakedModel model, CallbackInfo info) {
|
||||||
if (transparency) {
|
|
||||||
LevitatingItemRenderer.enableItemGlowRenderProfile();
|
LevitatingItemRenderer.enableItemGlowRenderProfile();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "renderItemAndGlow("
|
@Inject(method = "renderItemAndGlow("
|
||||||
+ "Lnet/minecraft/item/ItemStack;"
|
+ "Lnet/minecraft/item/ItemStack;"
|
||||||
|
@ -43,12 +33,11 @@ public abstract class MixinItemRenderer implements SynchronousResourceReloadList
|
||||||
+ "Ljava/lang/Runnable;I)V"),
|
+ "Ljava/lang/Runnable;I)V"),
|
||||||
cancellable = true)
|
cancellable = true)
|
||||||
private void beforeRenderEffect(ItemStack stack, BakedModel model, CallbackInfo info) {
|
private void beforeRenderEffect(ItemStack stack, BakedModel model, CallbackInfo info) {
|
||||||
if (transparency) {
|
if (LevitatingItemRenderer.usesTransparency()) {
|
||||||
info.cancel();
|
info.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ModifyArg(method = "renderQuads("
|
@ModifyArg(method = "renderQuads("
|
||||||
+ "Lnet/minecraft/client/render/BufferBuilder;"
|
+ "Lnet/minecraft/client/render/BufferBuilder;"
|
||||||
+ "Ljava/util/List;I"
|
+ "Ljava/util/List;I"
|
||||||
|
@ -59,6 +48,6 @@ public abstract class MixinItemRenderer implements SynchronousResourceReloadList
|
||||||
+ "Lnet/minecraft/client/render/model/BakedQuad;I)V"),
|
+ "Lnet/minecraft/client/render/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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,6 @@ package com.minelittlepony.client.render;
|
||||||
import org.lwjgl.opengl.GL14;
|
import org.lwjgl.opengl.GL14;
|
||||||
|
|
||||||
import com.minelittlepony.MineLittlePony;
|
import com.minelittlepony.MineLittlePony;
|
||||||
import com.minelittlepony.client.ducks.IRenderItem;
|
|
||||||
import com.minelittlepony.client.render.tileentities.skull.PonySkullRenderer;
|
|
||||||
import com.minelittlepony.client.util.render.Color;
|
import com.minelittlepony.client.util.render.Color;
|
||||||
import com.minelittlepony.pony.IPony;
|
import com.minelittlepony.pony.IPony;
|
||||||
import com.minelittlepony.settings.PonySettings;
|
import com.minelittlepony.settings.PonySettings;
|
||||||
|
@ -23,12 +21,22 @@ import static com.mojang.blaze3d.platform.GlStateManager.*;
|
||||||
|
|
||||||
public class LevitatingItemRenderer {
|
public class LevitatingItemRenderer {
|
||||||
|
|
||||||
public static void enableItemGlowRenderProfile() {
|
private static boolean usingTransparency;
|
||||||
|
|
||||||
|
public static boolean enableItemGlowRenderProfile() {
|
||||||
|
if (usesTransparency()) {
|
||||||
enableBlend();
|
enableBlend();
|
||||||
blendFuncSeparate(SourceFactor.CONSTANT_COLOR, DestFactor.ONE, SourceFactor.ONE, DestFactor.ZERO);
|
blendFuncSeparate(SourceFactor.CONSTANT_COLOR, DestFactor.ONE, SourceFactor.ONE, DestFactor.ZERO);
|
||||||
MinecraftClient.getInstance().gameRenderer.disableLightmap();
|
MinecraftClient.getInstance().gameRenderer.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.
|
||||||
*/
|
*/
|
||||||
|
@ -38,8 +46,8 @@ public class LevitatingItemRenderer {
|
||||||
setColor(glowColor);
|
setColor(glowColor);
|
||||||
|
|
||||||
ItemRenderer renderItem = MinecraftClient.getInstance().getItemRenderer();
|
ItemRenderer renderItem = MinecraftClient.getInstance().getItemRenderer();
|
||||||
((IRenderItem) renderItem).useTransparency(true);
|
|
||||||
PonySkullRenderer.ponyInstance.useTransparency(true);
|
usingTransparency = true;
|
||||||
|
|
||||||
scalef(1.1F, 1.1F, 1.1F);
|
scalef(1.1F, 1.1F, 1.1F);
|
||||||
|
|
||||||
|
@ -48,8 +56,7 @@ public class LevitatingItemRenderer {
|
||||||
translatef(-0.02F, -0.02F, -0.02F);
|
translatef(-0.02F, -0.02F, -0.02F);
|
||||||
renderItem.renderHeldItem(drop, entity, transform, hand == AbsoluteHand.LEFT);
|
renderItem.renderHeldItem(drop, entity, transform, hand == AbsoluteHand.LEFT);
|
||||||
|
|
||||||
((IRenderItem) renderItem).useTransparency(false);
|
usingTransparency = false;
|
||||||
PonySkullRenderer.ponyInstance.useTransparency(false);
|
|
||||||
unsetColor();
|
unsetColor();
|
||||||
enableLighting();
|
enableLighting();
|
||||||
popMatrix();
|
popMatrix();
|
||||||
|
@ -86,8 +93,7 @@ public class LevitatingItemRenderer {
|
||||||
if (doMagic) {
|
if (doMagic) {
|
||||||
disableLighting();
|
disableLighting();
|
||||||
|
|
||||||
((IRenderItem)itemRenderer).useTransparency(true);
|
usingTransparency = true;
|
||||||
PonySkullRenderer.ponyInstance.useTransparency(true);
|
|
||||||
|
|
||||||
setColor(pony.getMetadata().getGlowColor());
|
setColor(pony.getMetadata().getGlowColor());
|
||||||
|
|
||||||
|
@ -98,9 +104,7 @@ public class LevitatingItemRenderer {
|
||||||
translatef(-0.02F, -0.02F, -0.02F);
|
translatef(-0.02F, -0.02F, -0.02F);
|
||||||
renderer.renderItemFromSide(entity, stack, transform, left);
|
renderer.renderItemFromSide(entity, stack, transform, left);
|
||||||
|
|
||||||
((IRenderItem)itemRenderer).useTransparency(false);
|
usingTransparency = false;
|
||||||
|
|
||||||
PonySkullRenderer.ponyInstance.useTransparency(false);
|
|
||||||
|
|
||||||
unsetColor();
|
unsetColor();
|
||||||
enableLighting();
|
enableLighting();
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.minelittlepony.client.render.tileentities.skull;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.minelittlepony.MineLittlePony;
|
import com.minelittlepony.MineLittlePony;
|
||||||
import com.minelittlepony.client.MineLPClient;
|
import com.minelittlepony.client.MineLPClient;
|
||||||
import com.minelittlepony.client.ducks.IRenderItem;
|
import com.minelittlepony.client.render.LevitatingItemRenderer;
|
||||||
import com.minelittlepony.pony.IPony;
|
import com.minelittlepony.pony.IPony;
|
||||||
import com.minelittlepony.settings.PonyConfig;
|
import com.minelittlepony.settings.PonyConfig;
|
||||||
import com.minelittlepony.settings.PonySettings;
|
import com.minelittlepony.settings.PonySettings;
|
||||||
|
@ -26,13 +26,11 @@ import static com.mojang.blaze3d.platform.GlStateManager.*;
|
||||||
/**
|
/**
|
||||||
* PonySkullRenderer! It renders ponies as skulls, or something...
|
* PonySkullRenderer! It renders ponies as skulls, or something...
|
||||||
*/
|
*/
|
||||||
public class PonySkullRenderer extends SkullBlockEntityRenderer implements IRenderItem {
|
public class PonySkullRenderer extends SkullBlockEntityRenderer {
|
||||||
|
|
||||||
public static PonySkullRenderer ponyInstance = new PonySkullRenderer();
|
public static PonySkullRenderer ponyInstance = new PonySkullRenderer();
|
||||||
private static SkullBlockEntityRenderer backup = null;
|
private static SkullBlockEntityRenderer backup = null;
|
||||||
|
|
||||||
private boolean transparency = false;
|
|
||||||
|
|
||||||
private static final Map<SkullBlock.SkullType, ISkull> skullMap = SystemUtil.consume(Maps.newHashMap(), (skullMap) -> {
|
private static final Map<SkullBlock.SkullType, ISkull> skullMap = SystemUtil.consume(Maps.newHashMap(), (skullMap) -> {
|
||||||
skullMap.put(SkullBlock.Type.SKELETON, new SkeletonSkullRenderer());
|
skullMap.put(SkullBlock.Type.SKELETON, new SkeletonSkullRenderer());
|
||||||
skullMap.put(SkullBlock.Type.WITHER_SKELETON, new WitherSkullRenderer());
|
skullMap.put(SkullBlock.Type.WITHER_SKELETON, new WitherSkullRenderer());
|
||||||
|
@ -108,7 +106,7 @@ public class PonySkullRenderer extends SkullBlockEntityRenderer implements IRend
|
||||||
scalef(-1, -1, 1);
|
scalef(-1, -1, 1);
|
||||||
enableAlphaTest();
|
enableAlphaTest();
|
||||||
|
|
||||||
skull.preRender(usesTransparency());
|
skull.preRender(LevitatingItemRenderer.usesTransparency());
|
||||||
skull.render(animateTicks, rotation, scale);
|
skull.render(animateTicks, rotation, scale);
|
||||||
|
|
||||||
popMatrix();
|
popMatrix();
|
||||||
|
@ -146,16 +144,6 @@ public class PonySkullRenderer extends SkullBlockEntityRenderer implements IRend
|
||||||
return rotation;
|
return rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void useTransparency(boolean use) {
|
|
||||||
transparency = use;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean usesTransparency() {
|
|
||||||
return transparency;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A skull, just a skull.
|
* A skull, just a skull.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue