Fix some mixins

This commit is contained in:
Matthew Messinger 2016-01-26 03:17:08 -05:00
parent 90352517d4
commit 4c6c644f6b
4 changed files with 43 additions and 11 deletions

View file

@ -12,7 +12,7 @@ buildscript {
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.0-SNAPSHOT'
classpath 'org.spongepowered:mixingradle:0.1-SNAPSHOT'
classpath 'org.spongepowered:mixingradle:0.3-SNAPSHOT'
}
}
plugins {
@ -51,8 +51,7 @@ sourceSets {
compileClasspath += hdskins.output
}
forge {
compileClasspath += deps
compileClasspath += [main.output, api.output]
compileClasspath += files(deps + [ main.output, api.output ])
}
}
project('LiteLoader'){
@ -84,8 +83,8 @@ dependencies {
compile project('LiteLoader')
}
jar {
manifest.attributes.remove 'TweakClass'
from sourceSets.findAll{it.name != "api"}*.output
afterEvaluate { manifest.attributes.remove 'TweakClass'}
from sourceSets.findAll { it.name != 'api' }*.output
extension 'litemod'
}

View file

@ -5,8 +5,9 @@ import java.awt.image.BufferedImage;
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.At.Shift;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Surrogate;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
@ -19,10 +20,11 @@ import net.minecraft.client.renderer.ImageBufferDownload;
public abstract class MixinImageBufferDownload implements IImageBuffer {
@Inject(method = "parseUserSkin",
locals = LocalCapture.CAPTURE_FAILHARD,
locals = LocalCapture.CAPTURE_FAILSOFT,
at = @At(value = "INVOKE",
shift = Shift.BEFORE,
target = "Ljava/awt/Graphics;dispose()V") )
target = "Ljava/awt/Graphics;dispose()V",
remap = false) )
private void update(BufferedImage image, CallbackInfo ci, BufferedImage image2, Graphics graphics) {
// convert skins from mojang server
if (image.getHeight() == 32) {
@ -30,4 +32,13 @@ public abstract class MixinImageBufferDownload implements IImageBuffer {
}
}
// for optifine
@Surrogate
private void update(BufferedImage image, CallbackInfo ci, int w, int h, int k, BufferedImage image2, Graphics graphics) {
// convert skins from mojang server
if (image.getHeight() == 32) {
HDSkinManager.INSTANCE.convertSkin(image2, graphics);
}
}
}

View file

@ -35,6 +35,9 @@ import net.minecraft.util.ResourceLocation;
@Mixin(RenderPlayer.class)
public abstract class MixinRenderPlayer extends RendererLivingEntity implements IRenderPony {
private static final String RenderManager = "Lnet/minecraft/client/renderer/entity/RenderManager;";
private static final String AbstractClientPlayer = "Lnet/minecraft/client/entity/AbstractClientPlayer;";
@Shadow
private boolean smallArms;
private PlayerModel playerModel;
@ -45,7 +48,7 @@ public abstract class MixinRenderPlayer extends RendererLivingEntity implements
}
@Inject(
method = "<init>(Lnet/minecraft/client/renderer/entity/RenderManager;Z)V",
method = "<init>(" + RenderManager + "Z)V",
at = @At("RETURN") )
private void init(RenderManager renderManager, boolean useSmallArms, CallbackInfo ci) {
this.playerModel = smallArms ? PMAPI.ponySmall : PMAPI.pony;
@ -60,6 +63,10 @@ public abstract class MixinRenderPlayer extends RendererLivingEntity implements
this.addLayer(new LayerPonyCape(this));
}
/**
* @reason render a pony instead of a human
* @author JoyJoy
*/
@Overwrite
public void doRender(AbstractClientPlayer player, double x, double y, double z, float yaw, float partialTicks) {
ItemStack currentItemStack = player.inventory.getCurrentItem();
@ -80,6 +87,7 @@ public abstract class MixinRenderPlayer extends RendererLivingEntity implements
this.playerModel.getModel().isSneak = player.isSneaking();
this.playerModel.getModel().isFlying = thePony.isPegasusFlying(player);
this.playerModel.getModel().isRiding = player.isRiding();
if (MineLittlePony.getConfig().showscale) {
if (this.playerModel.getModel().metadata.getRace() != null) {
@ -106,7 +114,6 @@ public abstract class MixinRenderPlayer extends RendererLivingEntity implements
this.playerModel.getModel().isSleeping = player.isPlayerSleeping();
this.playerModel.getModel().swingProgress = getSwingProgress(player, partialTicks);
this.playerModel.getModel().isVillager = false;
super.doRender(player, x, yOrigin1, z, yaw, partialTicks);
@ -127,11 +134,24 @@ public abstract class MixinRenderPlayer extends RendererLivingEntity implements
}
}
@Inject(method = "renderRightArm(" + AbstractClientPlayer + ")V", at = @At("HEAD") )
private void onRenderRightArm(AbstractClientPlayer player, CallbackInfo ci) {
bindEntityTexture(player);
}
@Inject(method = "renderLeftArm(" + AbstractClientPlayer + ")V", at = @At("HEAD") )
private void onRenderLeftArm(AbstractClientPlayer player, CallbackInfo ci) {
bindEntityTexture(player);
}
private ResourceLocation getEntityTexture(AbstractClientPlayer player) {
Pony thePony = MineLittlePony.getInstance().getManager().getPonyFromResourceRegistry(player);
return thePony.getTextureResourceLocation();
}
/**
* @reason Change the skin in case of non-pony skin
*/
@Override
public final ResourceLocation getEntityTexture(Entity entity) {
return this.getEntityTexture((AbstractClientPlayer) entity);

View file

@ -1,7 +1,9 @@
{
"required": true,
"minVersion": "0.4.10",
"package": "com.brohoof.minelittlepony.mixin",
"refmap": "mixin.minelp.refmap.json",
"mixins": [
"MixinRenderPlayer"
]
}
}