mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-22 04:27:59 +01:00
Port to Mixin
This commit is contained in:
parent
c8ce4aa3ed
commit
15ce8e7ed0
6 changed files with 49 additions and 37 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -6,3 +6,5 @@ run/
|
||||||
.classpath
|
.classpath
|
||||||
.project
|
.project
|
||||||
*.launch
|
*.launch
|
||||||
|
/.apt_generated/
|
||||||
|
.factorypath
|
||||||
|
|
26
build.gradle
26
build.gradle
|
@ -5,18 +5,25 @@ buildscript {
|
||||||
name 'forge'
|
name 'forge'
|
||||||
url 'http://files.minecraftforge.net/maven'
|
url 'http://files.minecraftforge.net/maven'
|
||||||
}
|
}
|
||||||
|
maven {
|
||||||
|
name = 'sponge'
|
||||||
|
url = 'http://repo.spongepowered.org/maven'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.0-SNAPSHOT'
|
classpath 'net.minecraftforge.gradle:ForgeGradle:2.0-SNAPSHOT'
|
||||||
|
classpath 'org.spongepowered:mixingradle:0.1-SNAPSHOT'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plugins {
|
plugins {
|
||||||
|
id 'mnm.gradle.ap-ide' version '1.0.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
ext.voxellib = project ':voxellib'
|
ext.voxellib = project ':voxellib'
|
||||||
ext.revision = 186
|
ext.revision = 186
|
||||||
|
|
||||||
apply plugin: 'net.minecraftforge.gradle.tweaker-client'
|
apply plugin: 'net.minecraftforge.gradle.tweaker-client'
|
||||||
|
apply plugin: 'org.spongepowered.mixin'
|
||||||
|
|
||||||
archivesBaseName = "MineLittlePony"
|
archivesBaseName = "MineLittlePony"
|
||||||
group = 'com.brohoof.minelp'
|
group = 'com.brohoof.minelp'
|
||||||
|
@ -24,7 +31,7 @@ version = '1.8'
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
version = "1.8"
|
version = "1.8"
|
||||||
mappings = 'snapshot_20151027'
|
mappings = 'stable_18'
|
||||||
runDir = 'run'
|
runDir = 'run'
|
||||||
replace '@VERSION@',project.version
|
replace '@VERSION@',project.version
|
||||||
tweakClass = 'com.mumfrey.liteloader.launch.LiteLoaderTweaker'
|
tweakClass = 'com.mumfrey.liteloader.launch.LiteLoaderTweaker'
|
||||||
|
@ -75,12 +82,14 @@ processResources {
|
||||||
exclude 'litemod.json'
|
exclude 'litemod.json'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
allprojects {repositories{
|
allprojects {
|
||||||
maven {
|
repositories{
|
||||||
name 'sponge'
|
maven {
|
||||||
url 'http://repo.spongepowered.org/maven'
|
name 'sponge'
|
||||||
|
url 'http://repo.spongepowered.org/maven'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
provided project('LiteLoader')
|
provided project('LiteLoader')
|
||||||
provided voxellib
|
provided voxellib
|
||||||
|
@ -109,7 +118,10 @@ reobf {
|
||||||
jar.task.enabled = false
|
jar.task.enabled = false
|
||||||
standaloneJar{}
|
standaloneJar{}
|
||||||
}
|
}
|
||||||
|
sourceSets.main.refMap = 'mixin.minelp.refmap.json'
|
||||||
|
mixin {
|
||||||
|
defaultObfuscationEnv notch
|
||||||
|
}
|
||||||
task installMod(type: Copy, dependsOn: build) {
|
task installMod(type: Copy, dependsOn: build) {
|
||||||
from standaloneJar.archivePath
|
from standaloneJar.archivePath
|
||||||
into file("$System.env.APPDATA/.minecraft/mods")
|
into file("$System.env.APPDATA/.minecraft/mods")
|
||||||
|
|
|
@ -1,19 +1,24 @@
|
||||||
package com.brohoof.minelittlepony.renderer;
|
package com.brohoof.minelittlepony.mixin;
|
||||||
|
|
||||||
import static net.minecraft.client.renderer.GlStateManager.scale;
|
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.MineLittlePony;
|
||||||
import com.brohoof.minelittlepony.Pony;
|
import com.brohoof.minelittlepony.Pony;
|
||||||
import com.brohoof.minelittlepony.PonySize;
|
import com.brohoof.minelittlepony.PonySize;
|
||||||
import com.brohoof.minelittlepony.model.PMAPI;
|
import com.brohoof.minelittlepony.model.PMAPI;
|
||||||
import com.brohoof.minelittlepony.model.PlayerModel;
|
import com.brohoof.minelittlepony.model.PlayerModel;
|
||||||
import com.brohoof.minelittlepony.model.pony.ModelHumanPlayer;
|
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.LayerHeldPonyItem;
|
||||||
import com.brohoof.minelittlepony.renderer.layer.LayerPonyArmor;
|
import com.brohoof.minelittlepony.renderer.layer.LayerPonyArmor;
|
||||||
import com.brohoof.minelittlepony.renderer.layer.LayerPonyCape;
|
import com.brohoof.minelittlepony.renderer.layer.LayerPonyCape;
|
||||||
import com.brohoof.minelittlepony.renderer.layer.LayerPonySkull;
|
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.AbstractClientPlayer;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.EntityPlayerSP;
|
||||||
|
@ -26,19 +31,18 @@ import net.minecraft.item.EnumAction;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
public abstract class RenderPony extends RendererLivingEntity implements IRenderPony {
|
@Mixin(RenderPlayer.class)
|
||||||
@SuppressWarnings("unused")
|
public abstract class MixinRenderPlayer extends RendererLivingEntity implements IRenderPony {
|
||||||
private static RenderPlayer __TARGET;
|
|
||||||
private PlayerModel playerModel;
|
private PlayerModel playerModel;
|
||||||
private Pony thePony;
|
private Pony thePony;
|
||||||
|
|
||||||
private RenderPony(RenderManager renderManager) {
|
private MixinRenderPlayer(RenderManager renderManager) {
|
||||||
super(renderManager, null, 0.5F);
|
super(renderManager, null, 0.5F);
|
||||||
throw new InstantiationError("Overlay classes must not be instantiated");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AppendInsns("<init>")
|
@Inject(method="<init>(Lnet/minecraft/client/renderer/entity/RenderManager;Z)V", at=@At("RETURN"))
|
||||||
private void init(RenderManager renderManager, boolean useSmallArms) {
|
private void init(RenderManager renderManager, boolean useSmallArms, CallbackInfo ci) {
|
||||||
this.playerModel = PMAPI.pony;
|
this.playerModel = PMAPI.pony;
|
||||||
this.mainModel = this.playerModel.getModel();
|
this.mainModel = this.playerModel.getModel();
|
||||||
this.shadowSize = this.playerModel.getShadowsize();
|
this.shadowSize = this.playerModel.getShadowsize();
|
||||||
|
@ -51,7 +55,7 @@ public abstract class RenderPony extends RendererLivingEntity implements IRender
|
||||||
this.addLayer(new LayerPonyCape(this));
|
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) {
|
public void doRender(AbstractClientPlayer player, double x, double y, double z, float yaw, float partialTicks) {
|
||||||
ItemStack currentItemStack = player.inventory.getCurrentItem();
|
ItemStack currentItemStack = player.inventory.getCurrentItem();
|
||||||
this.thePony = MineLittlePony.getInstance().getManager().getPonyFromResourceRegistry(player);
|
this.thePony = MineLittlePony.getInstance().getManager().getPonyFromResourceRegistry(player);
|
||||||
|
@ -106,9 +110,8 @@ public abstract class RenderPony extends RendererLivingEntity implements IRender
|
||||||
this.playerModel.getModel().heldItemRight = 0;
|
this.playerModel.getModel().heldItemRight = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@AppendInsns("renderLivingAt")
|
@Inject(method = "renderLivingAt", at = @At("RETURN"))
|
||||||
@Obfuscated({ "a", "func_77039_a" })
|
private void setupPlayerScale(AbstractClientPlayer player, double xPosition, double yPosition, double zPosition, CallbackInfo ci) {
|
||||||
public void setupPlayerScale(AbstractClientPlayer player, double xPosition, double yPosition, double zPosition) {
|
|
||||||
|
|
||||||
if (MineLittlePony.getConfig().getShowScale().get() && !(playerModel.getModel() instanceof ModelHumanPlayer)) {
|
if (MineLittlePony.getConfig().getShowScale().get() && !(playerModel.getModel() instanceof ModelHumanPlayer)) {
|
||||||
PonySize size = thePony.metadata.getSize();
|
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);
|
Pony thePony = MineLittlePony.getInstance().getManager().getPonyFromResourceRegistry(player);
|
||||||
return thePony.getTextureResourceLocation();
|
return thePony.getTextureResourceLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourceLocation getEntityTexture(Entity entity) {
|
public final ResourceLocation getEntityTexture(Entity entity) {
|
||||||
return this.getEntityTexture((AbstractClientPlayer) entity);
|
return this.getEntityTexture((AbstractClientPlayer) entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected PlayerModel getModel(AbstractClientPlayer player) {
|
private PlayerModel getModel(AbstractClientPlayer player) {
|
||||||
Pony thePony = MineLittlePony.getInstance().getManager().getPonyFromResourceRegistry(player);
|
Pony thePony = MineLittlePony.getInstance().getManager().getPonyFromResourceRegistry(player);
|
||||||
return thePony.getModel();
|
return thePony.getModel();
|
||||||
}
|
}
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,7 +5,7 @@
|
||||||
"revision": "${revision}",
|
"revision": "${revision}",
|
||||||
"author": "Verdana, Rene_Z, Mumfrey, JoyJoy",
|
"author": "Verdana, Rene_Z, Mumfrey, JoyJoy",
|
||||||
"voxelCommonJarName": "voxelcommon-2.4.0.jar",
|
"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": "Mine Little Pony turns players and mobs into ponies",
|
||||||
"description.minelittlepony": "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."
|
"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."
|
||||||
|
|
7
src/main/resources/mixin.minelp.json
Normal file
7
src/main/resources/mixin.minelp.json
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"package": "com.brohoof.minelittlepony.mixin",
|
||||||
|
"refmap": "mixin.minelp.refmap.json",
|
||||||
|
"mixins": [
|
||||||
|
"MixinRenderPlayer"
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in a new issue