From 45ddc6baca02a36c1a2543f43d1240d2baf96e1b Mon Sep 17 00:00:00 2001 From: Matthew Messinger Date: Thu, 7 Jul 2016 02:57:52 -0400 Subject: [PATCH] update to 1.10.2 Work on better skin caching. Needs skin hash from server. Fix up the stray skeleton. Still need proper textures --- build.gradle | 38 ++++++------------ build.number | 3 ++ buildSrc | 1 + .../hdskins/HDProfileTexture.java | 26 ++++++++++++ .../voxelmodpack/hdskins/HDSkinManager.java | 34 +++++++++++----- .../brohoof/minelittlepony/PonyManager.java | 1 + .../mixin/MixinRenderPlayer.java | 2 +- .../renderer/RenderPonySkeleton.java | 9 +++-- .../renderer/layer/LayerOverlayBase.java | 35 ++++++++++++++++ .../layer/LayerPonySkeletonOverlay.java | 38 ++++++++++++++++++ .../textures/entity/skeleton/stray_pony.png | Bin 0 -> 1727 bytes .../entity/skeleton/stray_pony_overlay.png | Bin 0 -> 1017 bytes src/main/resources/litemod.json | 3 -- 13 files changed, 146 insertions(+), 44 deletions(-) create mode 100644 build.number create mode 160000 buildSrc create mode 100644 src/hdskins/java/com/voxelmodpack/hdskins/HDProfileTexture.java create mode 100644 src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerOverlayBase.java create mode 100644 src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonySkeletonOverlay.java create mode 100644 src/main/resources/assets/minelittlepony/textures/entity/skeleton/stray_pony.png create mode 100644 src/main/resources/assets/minelittlepony/textures/entity/skeleton/stray_pony_overlay.png diff --git a/build.gradle b/build.gradle index 3184cac9..e75c02b9 100644 --- a/build.gradle +++ b/build.gradle @@ -28,12 +28,12 @@ apply plugin: 'org.spongepowered.mixin' apply plugin: 'mnm.gradle.ap-ide' group = 'com.brohoof.minelp' -version = '1.10.0.0' +version = '1.10.2.0' description = 'Mine Little Pony' minecraft { - version = "1.10" - mappings = 'snapshot_20160619' + version = "1.10.2" + mappings = 'snapshot_20160704' // 'murica! F*** yeah! runDir = 'run' replace '@VERSION@',project.version } @@ -55,29 +55,14 @@ sourceSets { compileClasspath += files(deps + [ main.output, api.output ]) } } -//litemod.json { -// mixinConfigs += ['mixin.minelp.json', 'mixin.hdskins.json'] -// author = "author": "Verdana, Rene_Z, Mumfrey, JoyJoy" -// description = "Mine Little Pony turns players and mobs into ponies" -// description.litemodminelittlepony = """Mine Little Pony turns players and mobs into ponies -// Press F9 ingame to access settings""" -// description.litemodhdskinsmod = """Seperate skin server for Mine Little Pony that also supports HD skins. -// Access via Skin Manager key binding (default: F1) in the main menu.""" -//} -processResources { - def props = [ - version: version, - mcversion: minecraft.version, - revision: revision - ] - inputs.properties props - from(sourceSets.main.resources.srcDirs) { - include 'litemod.json' - expand props - } - from(sourceSets.main.resources.srcDirs) { - exclude 'litemod.json' - } +litemod.json { + author = "Verdana, Rene_Z, Mumfrey, JoyJoy" + description = "Mine Little Pony turns players and mobs into ponies" + description.litemodminelittlepony = """Mine Little Pony turns players and mobs into ponies + Press F9 ingame to access settings""" + description.litemodhdskinsmod = """Seperate skin server for Mine Little Pony that also supports HD skins. + Access via Skin Manager key binding (default: F1) in the main menu.""" + mixinConfigs += ['mixin.minelp.json', 'mixin.hdskins.json'] } afterEvaluate { dependencies { @@ -91,6 +76,7 @@ afterEvaluate { } jar { from sourceSets.findAll { it.name != 'api' }*.output + from litemod.outputs } mixin { defaultObfuscationEnv notch diff --git a/build.number b/build.number new file mode 100644 index 00000000..0df61485 --- /dev/null +++ b/build.number @@ -0,0 +1,3 @@ +#Build Number for ANT. Do not edit! +#Wed Jun 29 02:28:19 EDT 2016 +build.number=232 diff --git a/buildSrc b/buildSrc new file mode 160000 index 00000000..95e55a52 --- /dev/null +++ b/buildSrc @@ -0,0 +1 @@ +Subproject commit 95e55a52799b8d1c70b7fdcb155e77c3f34e7b96 diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/HDProfileTexture.java b/src/hdskins/java/com/voxelmodpack/hdskins/HDProfileTexture.java new file mode 100644 index 00000000..85dfc867 --- /dev/null +++ b/src/hdskins/java/com/voxelmodpack/hdskins/HDProfileTexture.java @@ -0,0 +1,26 @@ +package com.voxelmodpack.hdskins; + +import java.util.Map; + +import javax.annotation.Nullable; + +import com.mojang.authlib.minecraft.MinecraftProfileTexture; + +/** + * Profile texture with a custom hash which is not the file name. + */ +public class HDProfileTexture extends MinecraftProfileTexture { + + private String hash; + + public HDProfileTexture(String url, @Nullable String hash, Map metadata) { + super(url, metadata); + this.hash = hash; + } + + @Override + public String getHash() { + return this.hash == null ? super.getHash() : this.hash; + } + +} diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java b/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java index 0f1346d3..1ce5a1f2 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java @@ -4,6 +4,7 @@ import java.awt.Graphics; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; +import java.net.URL; import java.util.List; import java.util.Map; import java.util.UUID; @@ -11,11 +12,13 @@ import java.util.UUID; import org.apache.commons.codec.binary.Base64; import org.apache.commons.io.FileUtils; +import com.google.common.base.Charsets; import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import com.google.common.io.Resources; import com.google.gson.Gson; import com.google.gson.JsonObject; import com.mojang.authlib.GameProfile; @@ -104,9 +107,9 @@ public final class HDSkinManager { return; } - String dir = type.toString().toLowerCase() + "s/"; - final ResourceLocation skin = new ResourceLocation(dir + texture.getHash()); - File file1 = new File(new File("assets/" + dir), texture.getHash().substring(0, 2)); + String skinDir = "hd" + type.toString().toLowerCase() + "s/"; + final ResourceLocation skin = new ResourceLocation(skinDir + texture.getHash()); + File file1 = new File(new File("assets/" + skinDir), texture.getHash().substring(0, 2)); File file2 = new File(file1, texture.getHash()); final IImageBuffer imagebufferdownload = new ImageBufferDownloadHD(); ThreadDownloadImageData threaddownloadimagedata = new ThreadDownloadImageData(file2, texture.getUrl(), @@ -137,14 +140,16 @@ public final class HDSkinManager { if (textures == null) { String uuid = UUIDTypeAdapter.fromUUID(profile.getId()); - String skinUrl = getCustomTextureURLForId(Type.SKIN, uuid, false); - String capeUrl = getCustomTextureURLForId(Type.CAPE, uuid); - String elytraUrl = getCustomTextureURLForId(Type.ELYTRA, uuid); - textures = ImmutableMap.of( - Type.SKIN, new MinecraftProfileTexture(skinUrl, null), - Type.CAPE, new MinecraftProfileTexture(capeUrl, null), - Type.ELYTRA, new MinecraftProfileTexture(elytraUrl, null)); + ImmutableMap.Builder builder = ImmutableMap.builder(); + for (Type type : Type.values()) { + String url = getCustomTextureURLForId(type, uuid); + String hash = getTextureHash(type, uuid); + + builder.put(type, new HDProfileTexture(url, hash, null)); + } + + textures = builder.build(); this.profileTextures.put(profile.getId(), textures); } return textures; @@ -196,6 +201,15 @@ public final class HDSkinManager { return getCustomTextureURLForId(type, uuid, false); } + private String getTextureHash(Type type, String uuid) { + try { + URL url = new URL(getCustomTextureURLForId(type, uuid) + ".md5"); + return Resources.asCharSource(url, Charsets.UTF_8).readFirstLine(); + } catch (IOException e) { + return null; + } + } + public void setEnabled(boolean enabled) { this.enabled = enabled; } diff --git a/src/main/java/com/brohoof/minelittlepony/PonyManager.java b/src/main/java/com/brohoof/minelittlepony/PonyManager.java index b1e8a115..611f9556 100644 --- a/src/main/java/com/brohoof/minelittlepony/PonyManager.java +++ b/src/main/java/com/brohoof/minelittlepony/PonyManager.java @@ -22,6 +22,7 @@ public class PonyManager { public static final ResourceLocation SKELETON = new ResourceLocation(NAMESPACE, "textures/entity/skeleton/skeleton_pony.png"); public static final ResourceLocation WITHER_SKELETON = new ResourceLocation(NAMESPACE, "textures/entity/skeleton/skeleton_wither_pony.png"); public static final ResourceLocation STRAY_SKELETON = new ResourceLocation(NAMESPACE, "textures/entity/skeleton/stray_pony.png"); + public static final ResourceLocation STRAY_SKELETON_OVERLAY = new ResourceLocation(NAMESPACE, "textures/entity/skeleton/stray_pony_overlay.png"); public static final ResourceLocation STEVE = new ResourceLocation(NAMESPACE, "textures/entity/steve_pony.png"); public static final ResourceLocation ALEX = new ResourceLocation(NAMESPACE, "textures/entity/alex_pony.png"); diff --git a/src/main/java/com/brohoof/minelittlepony/mixin/MixinRenderPlayer.java b/src/main/java/com/brohoof/minelittlepony/mixin/MixinRenderPlayer.java index 7d2f19d8..f987a6cf 100644 --- a/src/main/java/com/brohoof/minelittlepony/mixin/MixinRenderPlayer.java +++ b/src/main/java/com/brohoof/minelittlepony/mixin/MixinRenderPlayer.java @@ -48,7 +48,7 @@ public abstract class MixinRenderPlayer extends RenderLivingBase { public RenderPonySkeleton(RenderManager rm) { super(rm, PMAPI.skeleton); - addLayer(new LayerBipedArmor(this) { + this.addLayer(new LayerBipedArmor(this) { @Override protected void initArmor() { this.modelLeggings = PMAPI.skeleton.getArmor().modelArmor; this.modelArmor = PMAPI.skeleton.getArmor().modelArmorChestplate; } }); + this.addLayer(new LayerPonySkeletonOverlay(this)); } @Override protected void preRenderCallback(EntitySkeleton skeleton, float partialTicks) { super.preRenderCallback(skeleton, partialTicks); - if (skeleton.func_189771_df() == SkeletonType.WITHER) {// getSkeletonType() - // == 1) { + if (skeleton.getSkeletonType() == SkeletonType.WITHER) { GlStateManager.scale(1.2F, 1.2F, 1.2F); } @@ -58,7 +59,7 @@ public class RenderPonySkeleton extends RenderPonyMob { @Override protected ResourceLocation getEntityTexture(EntitySkeleton skeleton) { - SkeletonType type = skeleton.func_189771_df(); + SkeletonType type = skeleton.getSkeletonType(); if (type == SkeletonType.WITHER) return PonyManager.WITHER_SKELETON; else if (type == SkeletonType.STRAY) diff --git a/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerOverlayBase.java b/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerOverlayBase.java new file mode 100644 index 00000000..8aca93f4 --- /dev/null +++ b/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerOverlayBase.java @@ -0,0 +1,35 @@ +package com.brohoof.minelittlepony.renderer.layer; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.renderer.entity.RenderLivingBase; +import net.minecraft.client.renderer.entity.layers.LayerRenderer; +import net.minecraft.entity.EntityLiving; +import net.minecraft.util.ResourceLocation; + +// separate class in case I need it later +public abstract class LayerOverlayBase implements LayerRenderer { + + protected final RenderLivingBase renderer; + + public LayerOverlayBase(RenderLivingBase render) { + this.renderer = render; + } + + @Override + public boolean shouldCombineTextures() { + return true; + } + + protected void renderOverlay(T skele, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + ModelBase overlayModel = this.getOverlayModel(); + overlayModel.setModelAttributes(this.renderer.getMainModel()); + overlayModel.setLivingAnimations(skele, limbSwing, limbSwingAmount, partialTicks); + renderer.bindTexture(this.getOverlayTexture()); + overlayModel.render(skele, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); + } + + protected abstract ModelBase getOverlayModel(); + + protected abstract ResourceLocation getOverlayTexture(); + +} \ No newline at end of file diff --git a/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonySkeletonOverlay.java b/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonySkeletonOverlay.java new file mode 100644 index 00000000..a22c51d4 --- /dev/null +++ b/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonySkeletonOverlay.java @@ -0,0 +1,38 @@ +package com.brohoof.minelittlepony.renderer.layer; + +import com.brohoof.minelittlepony.PonyManager; +import com.brohoof.minelittlepony.model.pony.ModelSkeletonPony; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.renderer.entity.RenderLivingBase; +import net.minecraft.entity.monster.EntitySkeleton; +import net.minecraft.entity.monster.SkeletonType; +import net.minecraft.util.ResourceLocation; + +public class LayerPonySkeletonOverlay extends LayerOverlayBase { + + private final ModelSkeletonPony overlayModel; + + public LayerPonySkeletonOverlay(RenderLivingBase render) { + super(render); + this.overlayModel = new ModelSkeletonPony(); + this.overlayModel.init(0F, 0.25F); + } + + @Override + public void doRenderLayer(EntitySkeleton skele, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + if (skele.getSkeletonType() == SkeletonType.STRAY) { + this.renderOverlay(skele, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale); + } + } + + @Override + protected ModelBase getOverlayModel() { + return this.overlayModel; + } + + @Override + protected ResourceLocation getOverlayTexture() { + return PonyManager.STRAY_SKELETON_OVERLAY; + } +} diff --git a/src/main/resources/assets/minelittlepony/textures/entity/skeleton/stray_pony.png b/src/main/resources/assets/minelittlepony/textures/entity/skeleton/stray_pony.png new file mode 100644 index 0000000000000000000000000000000000000000..6dc5692737f84b3bc8020bcbdc88a82fdb042c32 GIT binary patch literal 1727 zcmV;w20;0VP)-u3k0%rgF2JI?wii2W{; zx4W~R_vZc0dmG`Wd-v!ECr=94#^se2Y8VDSId`t=S}K!)swe<}R3-xen2*P;XY4Sy zv_xyK@$)XPtk7ojKR$c5n@fI6IXutk@C!s#9|l>1X?oJ2qUo=06-F@ zhWD93?Z$4x`}_U-brKFpV%6?229l|?b*~m*T)9#ujIXDr>fWmp-Bv&aO=~!I8v_8a zuzZbPxVlVvl_N!hR3>BXLP66k22@4CNGxWV1jC^N2M~|~wm;TL1Nyo905Gtye2tcj z5`10{zQ1*g@@6m}j|)7Lk|;sbNu4P$@ItD+ZU^>$yRj!4uwPYSm}QVssm=@-1DZ|% z01-88`?9Tc8kE+%1vXbFdPB#_1Y|dM)dwUtHZT$$hR5TEeM9-r5PWGek)lE>TD?lcRR zEW)fO5)H?0LtsvjsjkoK!G2Y(G6zyDK@$DgOlP3!8YEG|P%sFyY$7OC9GmF#;lET0 zCBv+|SP(EhIUzXBBf2hth2?9MX#fBW1%n_(0?{u*4arDlb1xiLNJcCYLCG-j_md}; zP!%0UDx0(B_8JBXng&VqLk-Cg{UUTy z1f>*VIRr(Pad&MEw^wgse&IVj+uX!I>+AUZt9jgBy@?wuH=xKe!g2_dQs|^;X^tfN zt9E-Qc|f7RwirBW$)shV52#R5k}e5RlF1aejPUn4X*vhJryP zHZ~yn{TA~qtVYzZ6;2b$G@w(l)6KW)3E1seGQ#pC&3tGM``8+yIt6D z6a{#&*sl??og4Tn50=fgUThc!yk4(0b_$(ZUzHQ=23ShW#y#r;TGixQfzRuC`>(b2 z+Ix)VpS!xcN(-7+WiC$F*UI!P0Wd~t4=k-{9vSZ3poCsB9=I$4 zu)Lieb9YJuzZ$&-L9`yzTst(ViVe>8)<K z(6lOM+ND#O3>If+1f~ItvojVGi?cHVV}5aVMzE{+>O{A#20L9}O95y)sj9*4lxEl1 zPBJ0PEiKXccwCr|$Ayo+y+9fB{Ij(+zlgdI2cuEg)eU#Ez8xn*d?BM9I#(#vd0Kw= z8_|uzW~E@VWxLSbuCJv4SWS-vS+sWYdoqHWI(L;ZwKblV213l}b2xNzaZ zg$oxhT)1%I!bPXh@s>6F%wFB@3DoxSTh$Pq&Tkh3uet_wyd;*+Wvh0KeH&ny<(|xU zHK5l%z-j;9DV%002ovPDHLkV1nX47uWy* literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/minelittlepony/textures/entity/skeleton/stray_pony_overlay.png b/src/main/resources/assets/minelittlepony/textures/entity/skeleton/stray_pony_overlay.png new file mode 100644 index 0000000000000000000000000000000000000000..a9f29b5bf47cb5aa9773da628ffc7af9a84292d1 GIT binary patch literal 1017 zcmVlS4Haj>Z`gQJSXYc^>iWRUFfo z57!R;$8ehrx>+m=|AUA&pb-J{>BQkq>x8tPfF~!X84=Mcj&nkYhmx3_!Z4Y1)dt4>(VspJkrs~ zM7Ma!kClOY!F4Xiesx| zdhIv_LFFQ1Fxu+;ox@enxI;>*(zZbjz*@Gs9+Uv2J5=7b0HO2g#L?>qC+JY*wEGZ| z;G|$1976Poh&qUbQi_yPTNyT=P8_ZhzyJ7A+ga{i2i(`hx3{-hzu$L=h-R}{c6@xi zleKU@u`30Q8lceA@$S|EC z;ddCTcZ;SjvaUXCVz;Z5%2gobYuER!?`tk)5lvnH_kw`lyn9bCU!2pkvoU@8`pwz^ z=`z{mB>xSx#VU>~HHEFAD-kfCP8_9FsRyVML{$@WhkpL)Q2gt6p-txJ4*Hhh*Ib%& zVtCJCvXKX`iKuf;O%9ATIokF8d}1CMQ+mICbxzZdSJq78bMS+fI?}nMZqk_j^J}oF zEasgbqNo#sa|C|+RJCT;_X`B;w%D4tO*>83#B>$AT;H2gjYkpl=tg;-S2%m%M{)W* z+#XxIy-ly-Zkj%DLa!No@8dp?5_b;wF^8$3;hAmESDj02tpuA)!ig}k4;^80%(RZa zX48VacPR|x&`Rs)g}BGJ0p2=#I=AVgD-jjHAT{}#gfVUU@+1%l1OkCTAP@)y0)apv n5C{YUfj}S-2m}IwVE_0F5)rN18%{N+00000NkvXXu0mjf3klw4 literal 0 HcmV?d00001 diff --git a/src/main/resources/litemod.json b/src/main/resources/litemod.json index 3cd61276..7283764f 100644 --- a/src/main/resources/litemod.json +++ b/src/main/resources/litemod.json @@ -3,10 +3,7 @@ "mcversion": "${mcversion}", "version": "${version}", "revision": "${revision}", - "author": "Verdana, Rene_Z, Mumfrey, JoyJoy", "description": "Mine Little Pony turns players and mobs into ponies", - "description.litemodminelittlepony": "Mine Little Pony turns players and mobs into ponies", - "description.litemodhdskinsmod": "Seperate skin server for Mine Little Pony that also supports HD skins. Access via Skin Manager key binding (default: F1) in the main menu.", "mixinConfigs": [ "mixin.minelp.json", "mixin.hdskins.json"