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 00000000..6dc56927 Binary files /dev/null and b/src/main/resources/assets/minelittlepony/textures/entity/skeleton/stray_pony.png differ 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 00000000..a9f29b5b Binary files /dev/null and b/src/main/resources/assets/minelittlepony/textures/entity/skeleton/stray_pony_overlay.png differ 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"