Port to Mixin

This commit is contained in:
Matthew Messinger 2016-01-15 02:59:50 -05:00
parent c8ce4aa3ed
commit 15ce8e7ed0
6 changed files with 49 additions and 37 deletions

2
.gitignore vendored
View file

@ -6,3 +6,5 @@ run/
.classpath
.project
*.launch
/.apt_generated/
.factorypath

View file

@ -5,18 +5,25 @@ buildscript {
name 'forge'
url 'http://files.minecraftforge.net/maven'
}
maven {
name = 'sponge'
url = 'http://repo.spongepowered.org/maven'
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.0-SNAPSHOT'
classpath 'org.spongepowered:mixingradle:0.1-SNAPSHOT'
}
}
plugins {
id 'mnm.gradle.ap-ide' version '1.0.2'
}
ext.voxellib = project ':voxellib'
ext.revision = 186
apply plugin: 'net.minecraftforge.gradle.tweaker-client'
apply plugin: 'org.spongepowered.mixin'
archivesBaseName = "MineLittlePony"
group = 'com.brohoof.minelp'
@ -24,7 +31,7 @@ version = '1.8'
minecraft {
version = "1.8"
mappings = 'snapshot_20151027'
mappings = 'stable_18'
runDir = 'run'
replace '@VERSION@',project.version
tweakClass = 'com.mumfrey.liteloader.launch.LiteLoaderTweaker'
@ -75,12 +82,14 @@ processResources {
exclude 'litemod.json'
}
}
allprojects {repositories{
maven {
name 'sponge'
url 'http://repo.spongepowered.org/maven'
allprojects {
repositories{
maven {
name 'sponge'
url 'http://repo.spongepowered.org/maven'
}
}
}}
}
dependencies {
provided project('LiteLoader')
provided voxellib
@ -109,7 +118,10 @@ reobf {
jar.task.enabled = false
standaloneJar{}
}
sourceSets.main.refMap = 'mixin.minelp.refmap.json'
mixin {
defaultObfuscationEnv notch
}
task installMod(type: Copy, dependsOn: build) {
from standaloneJar.archivePath
into file("$System.env.APPDATA/.minecraft/mods")

View file

@ -1,19 +1,24 @@
package com.brohoof.minelittlepony.renderer;
package com.brohoof.minelittlepony.mixin;
import static net.minecraft.client.renderer.GlStateManager.scale;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.brohoof.minelittlepony.MineLittlePony;
import com.brohoof.minelittlepony.Pony;
import com.brohoof.minelittlepony.PonySize;
import com.brohoof.minelittlepony.model.PMAPI;
import com.brohoof.minelittlepony.model.PlayerModel;
import com.brohoof.minelittlepony.model.pony.ModelHumanPlayer;
import com.brohoof.minelittlepony.renderer.IRenderPony;
import com.brohoof.minelittlepony.renderer.layer.LayerHeldPonyItem;
import com.brohoof.minelittlepony.renderer.layer.LayerPonyArmor;
import com.brohoof.minelittlepony.renderer.layer.LayerPonyCape;
import com.brohoof.minelittlepony.renderer.layer.LayerPonySkull;
import com.mumfrey.liteloader.transformers.AppendInsns;
import com.mumfrey.liteloader.transformers.Obfuscated;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.entity.EntityPlayerSP;
@ -26,19 +31,18 @@ import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
public abstract class RenderPony extends RendererLivingEntity implements IRenderPony {
@SuppressWarnings("unused")
private static RenderPlayer __TARGET;
@Mixin(RenderPlayer.class)
public abstract class MixinRenderPlayer extends RendererLivingEntity implements IRenderPony {
private PlayerModel playerModel;
private Pony thePony;
private RenderPony(RenderManager renderManager) {
private MixinRenderPlayer(RenderManager renderManager) {
super(renderManager, null, 0.5F);
throw new InstantiationError("Overlay classes must not be instantiated");
}
@AppendInsns("<init>")
private void init(RenderManager renderManager, boolean useSmallArms) {
@Inject(method="<init>(Lnet/minecraft/client/renderer/entity/RenderManager;Z)V", at=@At("RETURN"))
private void init(RenderManager renderManager, boolean useSmallArms, CallbackInfo ci) {
this.playerModel = PMAPI.pony;
this.mainModel = this.playerModel.getModel();
this.shadowSize = this.playerModel.getShadowsize();
@ -51,7 +55,7 @@ public abstract class RenderPony extends RendererLivingEntity implements IRender
this.addLayer(new LayerPonyCape(this));
}
@Obfuscated({ "a", "func_180596_a" })
@Overwrite
public void doRender(AbstractClientPlayer player, double x, double y, double z, float yaw, float partialTicks) {
ItemStack currentItemStack = player.inventory.getCurrentItem();
this.thePony = MineLittlePony.getInstance().getManager().getPonyFromResourceRegistry(player);
@ -106,9 +110,8 @@ public abstract class RenderPony extends RendererLivingEntity implements IRender
this.playerModel.getModel().heldItemRight = 0;
}
@AppendInsns("renderLivingAt")
@Obfuscated({ "a", "func_77039_a" })
public void setupPlayerScale(AbstractClientPlayer player, double xPosition, double yPosition, double zPosition) {
@Inject(method = "renderLivingAt", at = @At("RETURN"))
private void setupPlayerScale(AbstractClientPlayer player, double xPosition, double yPosition, double zPosition, CallbackInfo ci) {
if (MineLittlePony.getConfig().getShowScale().get() && !(playerModel.getModel() instanceof ModelHumanPlayer)) {
PonySize size = thePony.metadata.getSize();
@ -119,17 +122,17 @@ public abstract class RenderPony extends RendererLivingEntity implements IRender
}
}
public ResourceLocation getEntityTexture(AbstractClientPlayer player) {
private ResourceLocation getEntityTexture(AbstractClientPlayer player) {
Pony thePony = MineLittlePony.getInstance().getManager().getPonyFromResourceRegistry(player);
return thePony.getTextureResourceLocation();
}
@Override
public ResourceLocation getEntityTexture(Entity entity) {
public final ResourceLocation getEntityTexture(Entity entity) {
return this.getEntityTexture((AbstractClientPlayer) entity);
}
protected PlayerModel getModel(AbstractClientPlayer player) {
private PlayerModel getModel(AbstractClientPlayer player) {
Pony thePony = MineLittlePony.getInstance().getManager().getPonyFromResourceRegistry(player);
return thePony.getModel();
}

View file

@ -1,12 +0,0 @@
package com.brohoof.minelittlepony.transformers;
import com.mumfrey.liteloader.transformers.ClassOverlayTransformer;
public class RenderPlayerTransformer extends ClassOverlayTransformer {
private static final String overlayClassName = "com.brohoof.minelittlepony.renderer.RenderPony";
public RenderPlayerTransformer() {
super(overlayClassName);
}
}

View file

@ -5,7 +5,7 @@
"revision": "${revision}",
"author": "Verdana, Rene_Z, Mumfrey, JoyJoy",
"voxelCommonJarName": "voxelcommon-2.4.0.jar",
"classTransformerClasses": "com.brohoof.minelittlepony.transformers.RenderPlayerTransformer",
"mixinConfigs": "mixin.minelp.json",
"description": "Mine Little Pony turns players and mobs into ponies",
"description.minelittlepony": "Mine Little Pony turns players and mobs into ponies",
"description.hdskins": "Seperate skin server for Mine Little Pony that also supports HD skins. Access via Skin Manager key binding (default: F1) in the main menu."

View file

@ -0,0 +1,7 @@
{
"package": "com.brohoof.minelittlepony.mixin",
"refmap": "mixin.minelp.refmap.json",
"mixins": [
"MixinRenderPlayer"
]
}