Finish ponyskulls, add the deadmou5 ears, and ad an option to toggle skulls on and off

This commit is contained in:
Sollace 2018-06-20 23:12:12 +02:00
parent 31ce31a109
commit 2c121d2960
11 changed files with 283 additions and 145 deletions

View file

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Tue Apr 10 14:03:42 CAT 2018
build.number=497
#Mon Jun 11 22:03:32 CAT 2018
build.number=499

View file

@ -48,4 +48,9 @@ public class LiteModMineLittlePony implements InitCompleteListener, Tickable, Co
public Class<? extends ConfigPanel> getConfigPanelClass() {
return PonySettingsPanel.class;
}
@Override
public void onTick(Minecraft minecraft, float partialTicks, boolean inGame, boolean clock) {
mlp.onTick();
}
}

View file

@ -77,8 +77,10 @@ public class MineLittlePony {
RenderManager rm = minecraft.getRenderManager();
renderManager.initialisePlayerRenderers(rm);
renderManager.initializeMobRenderers(rm, config);
}
PonySkullRenderer.apply();
void onTick() {
PonySkullRenderer.resolve();
}
void onTick(Minecraft minecraft, boolean inGame) {

View file

@ -21,13 +21,15 @@ public class PonyConfig extends SensibleConfig implements Exposable {
@Expose public boolean hd = true;
@Expose public boolean showscale = true;
@Expose public boolean fpsmagic = true;
@Expose public boolean ponyskulls = true;
public enum PonySettings implements Setting {
SIZES,
SNUZZLES,
HD,
SHOWSCALE,
FPSMAGIC;
FPSMAGIC,
PONYSKULLS;
}
@Expose public boolean villagers = true;

View file

@ -0,0 +1,23 @@
package com.minelittlepony.model.components;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.model.ModelSkeletonHead;
public class ModelDeadMau5Ears extends ModelSkeletonHead {
public ModelDeadMau5Ears() {
super();
skeletonHead = new ModelRenderer(this, 24, 0);
skeletonHead.addBox(-3, -6, -1, 6, 6, 1, 0);
}
public void setVisible(boolean show) {
this.boxList.clear();
skeletonHead = new ModelRenderer(this, 24, 0);
skeletonHead.addBox(-9, -13, -1, 6, 6, 1, 0);
skeletonHead.addBox(3, -13, -1, 6, 6, 1, 0);
skeletonHead.isHidden = !show;
}
}

View file

@ -0,0 +1,25 @@
package com.minelittlepony.render;
import com.minelittlepony.model.components.ModelPonyHead;
import com.minelittlepony.pony.data.Pony;
import com.minelittlepony.render.PonySkullRenderer.ISkull;
public abstract class PonySkull implements ISkull {
private static ModelPonyHead ponyHead = new ModelPonyHead();
@Override
public void preRender(boolean transparency) {
}
@Override
public void bindPony(Pony pony) {
ponyHead.metadata = pony.getMetadata();
}
@Override
public void render(float animateTicks, float rotation, float scale) {
ponyHead.render(null, animateTicks, 0, 0, rotation, 0, scale);
}
}

View file

@ -1,144 +1,119 @@
package com.minelittlepony.render;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import javax.annotation.Nullable;
import org.lwjgl.opengl.GL11;
import com.minelittlepony.MineLittlePony;
import com.minelittlepony.PonyConfig;
import com.minelittlepony.ducks.IRenderItem;
import com.minelittlepony.model.components.ModelPonyHead;
import com.minelittlepony.pony.data.Pony;
import com.minelittlepony.render.ponies.RenderPonySkeleton;
import com.minelittlepony.render.ponies.RenderPonyZombie;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
import com.mumfrey.liteloader.util.ModUtilities;
import com.voxelmodpack.hdskins.HDSkinManager;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.GlStateManager.DestFactor;
import net.minecraft.client.renderer.GlStateManager.SourceFactor;
import net.minecraft.client.renderer.tileentity.TileEntitySkullRenderer;
import net.minecraft.client.resources.DefaultPlayerSkin;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntitySkull;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
/**
* PonySkullRenderer! It renders ponies as skulls, or something...
*/
public class PonySkullRenderer extends TileEntitySkullRenderer implements IRenderItem {
private ModelPonyHead ponyHead = new ModelPonyHead();
private static PonySkullRenderer ponyInstance = new PonySkullRenderer();
private static TileEntitySkullRenderer backup = null;
private boolean renderAsPony = false;
private static final Map<Integer, ISkull> skullMap = new HashMap<Integer, ISkull>();
/**
* Resolves the games skull renderer to either a specialised pony skull renderer
* or some other skull renderer depending on the ponyskulls state.
*
* Original/Existing renderer is stored to a backup variable as a fallback in case of mods.
*/
public static TileEntitySkullRenderer resolve() {
if (MineLittlePony.getConfig().ponyskulls) {
if (!(instance instanceof PonySkullRenderer)) {
backup = instance;
ModUtilities.addRenderer(TileEntitySkull.class, ponyInstance);
instance = ponyInstance;
}
} else {
if ((instance instanceof PonySkullRenderer) && backup != null) {
ponyInstance = (PonySkullRenderer)instance;
ModUtilities.addRenderer(TileEntitySkull.class, backup);
instance = backup;
}
}
return instance;
}
protected boolean transparency = false;
private static final PonySkullRenderer ponyInstance = new PonySkullRenderer();
private static TileEntitySkullRenderer backup = null;
@Override
public void renderSkull(float x, float y, float z, EnumFacing facing, float rotation, int skullType, @Nullable GameProfile profile, int destroyStage, float animateTicks) {
public static TileEntitySkullRenderer apply() {
if (instance != ponyInstance) {
backup = instance;
ModUtilities.addRenderer(TileEntitySkull.class, ponyInstance);
instance = ponyInstance;
}
return instance;
}
ISkull skull = skullMap.getOrDefault(skullType, null);
public static TileEntitySkullRenderer unapply() {
if (instance == ponyInstance && backup != null) {
ModUtilities.addRenderer(TileEntitySkull.class, backup);
instance = backup;
}
return instance;
}
private PonySkullRenderer() {
}
public void renderSkull(float x, float y, float z, EnumFacing facing, float rotationIn, int skullType, @Nullable GameProfile profile, int destroyStage, float animateTicks) {
PonyConfig config = MineLittlePony.getConfig();
switch (skullType)
{
default:
case 0: //skeleton
case 1: //wither skeleton
renderAsPony = config.skeletons;
break;
case 2: //zombie
renderAsPony = config.zombies;
break;
case 3: // player
renderAsPony = true;
break;
case 4: // creeper
case 5: // dragon
renderAsPony = false;
}
if (renderAsPony) {
renderPonySkull(x, y, z, facing, rotationIn, skullType, profile, destroyStage, animateTicks);
} else {
super.renderSkull(x, y, z, facing, rotationIn, skullType, profile, destroyStage, animateTicks);
}
}
protected ResourceLocation getSkinResource(GameProfile profile, int skullType) {
if (skullType == 1) {
return RenderPonySkeleton.WITHER;
}
if (skullType == 2) {
return RenderPonyZombie.ZOMBIE;
}
if (skullType == 3) {
if (profile != null) {
Optional<ResourceLocation> skin = HDSkinManager.INSTANCE.getSkinLocation(profile, Type.SKIN, true);
if (skin.isPresent()) {
return skin.get();
}
Minecraft minecraft = Minecraft.getMinecraft();
Map<Type, MinecraftProfileTexture> map = minecraft.getSkinManager().loadSkinFromCache(profile);
if (map.containsKey(Type.SKIN)) {
return minecraft.getSkinManager().loadSkin(map.get(Type.SKIN), Type.SKIN);
} else {
return DefaultPlayerSkin.getDefaultSkin(EntityPlayer.getUUID(profile));
}
if (skull == null || !skull.canRender(MineLittlePony.getConfig())) {
if (backup != null) {
backup.renderSkull(x, y, z, facing, rotation, skullType, profile, destroyStage, animateTicks);
} else {
super.renderSkull(x, y, z, facing, rotation, skullType, profile, destroyStage, animateTicks);
}
return DefaultPlayerSkin.getDefaultSkinLegacy();
return;
}
return RenderPonySkeleton.SKELETON;
}
float scale = 0.0625F;
public void renderPonySkull(float x, float y, float z, EnumFacing facing, float rotationIn, int skullType, @Nullable GameProfile profile, int destroyStage, float animateTicks) {
if (destroyStage >= 0) {
bindTexture(DESTROY_STAGES[destroyStage]);
GlStateManager.matrixMode(5890);
GlStateManager.matrixMode(GL11.GL_TEXTURE);
GlStateManager.pushMatrix();
GlStateManager.scale(4.0F, 2.0F, 1.0F);
GlStateManager.translate(0.0625F, 0.0625F, 0.0625F);
GlStateManager.matrixMode(5888);
GlStateManager.scale(4, 2, 1);
GlStateManager.translate(scale, scale, scale);
GlStateManager.matrixMode(GL11.GL_MODELVIEW);
} else {
bindTexture(getSkinResource(profile, skullType));
ResourceLocation skin = skull.getSkinResource(profile);
skull.bindPony(MineLittlePony.getInstance().getManager().getPony(skin, false));
bindTexture(skin);
}
GlStateManager.pushMatrix();
GlStateManager.disableCull();
rotation = handleRotation(x, y, z, facing, rotation);
GlStateManager.enableRescaleNormal();
GlStateManager.scale(-1, -1, 1);
GlStateManager.enableAlpha();
skull.preRender(transparency);
skull.render(animateTicks, rotation, scale);
GlStateManager.popMatrix();
if (destroyStage >= 0) {
GlStateManager.matrixMode(GL11.GL_TEXTURE);
GlStateManager.popMatrix();
GlStateManager.matrixMode(GL11.GL_MODELVIEW);
}
}
protected float handleRotation(float x, float y, float z, EnumFacing facing, float rotation) {
switch (facing) {
case EAST:
default:
GlStateManager.translate(x + 0.26F, y + 0.25F, z + 0.5F);
return 90;
case UP:
GlStateManager.translate(x + 0.5F, y, z + 0.5F);
break;
@ -147,49 +122,47 @@ public class PonySkullRenderer extends TileEntitySkullRenderer implements IRende
break;
case SOUTH:
GlStateManager.translate(x + 0.5F, y + 0.25F, z + 0.26F);
rotationIn = 180.0F;
break;
return 180;
case WEST:
GlStateManager.translate(x + 0.74F, y + 0.25F, z + 0.5F);
rotationIn = 270.0F;
break;
case EAST:
default:
GlStateManager.translate(x + 0.26F, y + 0.25F, z + 0.5F);
rotationIn = 90.0F;
return 270;
}
GlStateManager.enableRescaleNormal();
GlStateManager.scale(-1, -1, 1);
GlStateManager.enableAlpha();
if (skullType == 3) {
if (transparency) {
GlStateManager.tryBlendFuncSeparate(SourceFactor.CONSTANT_COLOR, DestFactor.ONE, SourceFactor.ONE, DestFactor.ZERO);
} else {
GlStateManager.enableBlendProfile(GlStateManager.Profile.PLAYER_SKIN);
}
}
ponyHead.render((Entity)null, animateTicks, 0, 0, rotationIn, 0, 0.0625F);
GlStateManager.popMatrix();
if (destroyStage >= 0) {
GlStateManager.matrixMode(5890);
GlStateManager.popMatrix();
GlStateManager.matrixMode(5888);
}
}
@Override
protected void bindTexture(ResourceLocation location) {
Pony pony = MineLittlePony.getInstance().getManager().getPony(location, false);
ponyHead.metadata = pony.getMetadata();
super.bindTexture(location);
return rotation;
}
@Override
public void useTransparency(boolean use) {
transparency = use;
}
/**
* A skull, just a skull.
*
* Implement this interface if you want to extend our behaviour, modders.
*/
public interface ISkull {
public static final int SKELETON = 0;
public static final int WITHER = 1;
public static final int ZOMBIE = 2;
public static final int PLAYER = 3;
public static final int CREEPER = 4;
public static final int DRAGON = 5;
void preRender(boolean transparency);
void render(float animateTicks, float rotation, float scale);
boolean canRender(PonyConfig config);
ResourceLocation getSkinResource(@Nullable GameProfile profile);
void bindPony(Pony pony);
default ISkull register(int metadataId) {
PonySkullRenderer.skullMap.put(metadataId, this);
return this;
}
}
}

View file

@ -4,12 +4,12 @@ import com.minelittlepony.ducks.IRenderPony;
import com.minelittlepony.model.AbstractPonyModel;
import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.ModelWrapper;
import com.minelittlepony.render.PonySkullRenderer;
import com.mojang.authlib.GameProfile;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
import net.minecraft.client.renderer.entity.RenderLivingBase;
import net.minecraft.client.renderer.entity.layers.LayerRenderer;
import net.minecraft.client.renderer.tileentity.TileEntitySkullRenderer;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntityZombieVillager;
import net.minecraft.entity.passive.EntityVillager;
@ -97,9 +97,7 @@ public class LayerPonyCustomHead<T extends EntityLivingBase> implements LayerRen
}
}
// TODO: PonySkullRenderer
TileEntitySkullRenderer.instance.renderSkull(-0.5F, 0, -0.45F, EnumFacing.UP, 180, itemstack.getMetadata(), profile, -1, limbSwing);
PonySkullRenderer.resolve().renderSkull(-0.5F, 0, -0.45F, EnumFacing.UP, 180, itemstack.getMetadata(), profile, -1, limbSwing);
}
private ModelWrapper getModel() {

View file

@ -1,15 +1,81 @@
package com.minelittlepony.render.player;
import com.minelittlepony.model.ModelWrapper;
import com.minelittlepony.util.math.MathUtil;
import java.util.Map;
import java.util.Optional;
import com.minelittlepony.PonyConfig;
import com.minelittlepony.model.ModelWrapper;
import com.minelittlepony.model.components.ModelDeadMau5Ears;
import com.minelittlepony.pony.data.PonyLevel;
import com.minelittlepony.render.PonySkull;
import com.minelittlepony.render.PonySkullRenderer.ISkull;
import com.minelittlepony.util.math.MathUtil;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
import com.voxelmodpack.hdskins.HDSkinManager;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.GlStateManager.DestFactor;
import net.minecraft.client.renderer.GlStateManager.SourceFactor;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.resources.DefaultPlayerSkin;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
public class RenderPonyPlayer extends RenderPonyBase {
public static final ISkull SKULL = new PonySkull() {
private final ModelDeadMau5Ears deadMau5 = new ModelDeadMau5Ears();
@Override
public boolean canRender(PonyConfig config) {
return config.getPonyLevel() != PonyLevel.HUMANS;
}
@Override
public void preRender(boolean transparency) {
if (transparency) {
GlStateManager.tryBlendFuncSeparate(SourceFactor.CONSTANT_COLOR, DestFactor.ONE, SourceFactor.ONE, DestFactor.ZERO);
} else {
GlStateManager.enableBlendProfile(GlStateManager.Profile.PLAYER_SKIN);
}
}
@Override
public ResourceLocation getSkinResource(GameProfile profile) {
if (profile != null) {
deadMau5.setVisible("deadmau5".equals(profile.getName()));
Optional<ResourceLocation> skin = HDSkinManager.INSTANCE.getSkinLocation(profile, Type.SKIN, true);
if (skin.isPresent()) {
return skin.get();
}
Minecraft minecraft = Minecraft.getMinecraft();
Map<Type, MinecraftProfileTexture> map = minecraft.getSkinManager().loadSkinFromCache(profile);
if (map.containsKey(Type.SKIN)) {
return minecraft.getSkinManager().loadSkin(map.get(Type.SKIN), Type.SKIN);
} else {
return DefaultPlayerSkin.getDefaultSkin(EntityPlayer.getUUID(profile));
}
}
return DefaultPlayerSkin.getDefaultSkinLegacy();
}
@Override
public void render(float animateTicks, float rotation, float scale) {
super.render(animateTicks, rotation, scale);
deadMau5.render(null, animateTicks, 0, 0, rotation, 0, scale);
}
}.register(ISkull.PLAYER);
public RenderPonyPlayer(RenderManager renderManager, boolean useSmallArms, ModelWrapper model) {
super(renderManager, useSmallArms, model);
}

View file

@ -1,8 +1,12 @@
package com.minelittlepony.render.ponies;
import com.minelittlepony.PonyConfig;
import com.minelittlepony.model.PMAPI;
import com.minelittlepony.render.RenderPonyMob;
import com.minelittlepony.render.PonySkull;
import com.minelittlepony.render.PonySkullRenderer.ISkull;
import com.minelittlepony.render.layer.LayerPonyStrayOverlay;
import com.mojang.authlib.GameProfile;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.RenderManager;
@ -18,6 +22,18 @@ public class RenderPonySkeleton<Skeleton extends AbstractSkeleton> extends Rende
public static final ResourceLocation WITHER = new ResourceLocation("minelittlepony", "textures/entity/skeleton/skeleton_wither_pony.png");
public static final ResourceLocation STRAY = new ResourceLocation("minelittlepony", "textures/entity/skeleton/stray_pony.png");
public static final ISkull SKULL = new PonySkull() {
@Override
public boolean canRender(PonyConfig config) {
return config.skeletons;
}
@Override
public ResourceLocation getSkinResource(GameProfile profile) {
return RenderPonySkeleton.SKELETON;
}
}.register(ISkull.SKELETON);
public RenderPonySkeleton(RenderManager manager) {
super(manager, PMAPI.skeleton);
}
@ -54,6 +70,18 @@ public class RenderPonySkeleton<Skeleton extends AbstractSkeleton> extends Rende
public static class Wither extends RenderPonySkeleton<EntityWitherSkeleton> {
public static final ISkull SKULL = new PonySkull() {
@Override
public boolean canRender(PonyConfig config) {
return config.skeletons;
}
@Override
public ResourceLocation getSkinResource(GameProfile profile) {
return RenderPonySkeleton.WITHER;
}
}.register(ISkull.WITHER);
public Wither(RenderManager rm) {
super(rm);
}

View file

@ -1,7 +1,11 @@
package com.minelittlepony.render.ponies;
import com.minelittlepony.PonyConfig;
import com.minelittlepony.model.PMAPI;
import com.minelittlepony.render.RenderPonyMob;
import com.minelittlepony.render.PonySkull;
import com.minelittlepony.render.PonySkullRenderer.ISkull;
import com.mojang.authlib.GameProfile;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.RenderManager;
@ -15,6 +19,18 @@ public class RenderPonyZombie<Zombie extends EntityZombie> extends RenderPonyMob
public static final ResourceLocation ZOMBIE = new ResourceLocation("minelittlepony", "textures/entity/zombie/zombie_pony.png");
public static final ResourceLocation HUSK = new ResourceLocation("minelittlepony", "textures/entity/zombie/husk_pony.png");
public static final ISkull SKULL = new PonySkull() {
@Override
public boolean canRender(PonyConfig config) {
return config.zombies;
}
@Override
public ResourceLocation getSkinResource(GameProfile profile) {
return RenderPonyZombie.ZOMBIE;
}
}.register(ISkull.ZOMBIE);
public RenderPonyZombie(RenderManager manager) {
super(manager, PMAPI.zombie);
}