mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-13 16:24:23 +01:00
Code stylee, documentation, fixed leg alignment
This commit is contained in:
parent
f151b31597
commit
9391c1d8c0
31 changed files with 620 additions and 294 deletions
|
@ -15,16 +15,40 @@ import javax.annotation.Nullable;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Proxy class for accessing forge fields and methods.
|
||||||
|
*/
|
||||||
public class ForgeProxy {
|
public class ForgeProxy {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True if forge is present.
|
||||||
|
*/
|
||||||
private static boolean forgeLoaded = ModUtilities.fmlIsPresent();
|
private static boolean forgeLoaded = ModUtilities.fmlIsPresent();
|
||||||
|
|
||||||
public static String getArmorTexture(Entity entity, ItemStack armor, String def, EntityEquipmentSlot slot, @Nullable String type) {
|
/**
|
||||||
|
* Gets the mod armour texture for associated item and slot.
|
||||||
|
*
|
||||||
|
* @param entity The entity to get armour for.
|
||||||
|
* @param item The armour item
|
||||||
|
* @param def Default return value if no mods present
|
||||||
|
* @param slot The slot this armour piece is place in.
|
||||||
|
* @param type unknown
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getArmorTexture(Entity entity, ItemStack item, String def, EntityEquipmentSlot slot, @Nullable String type) {
|
||||||
if (forgeLoaded)
|
if (forgeLoaded)
|
||||||
return ForgeHooksClient.getArmorTexture(entity, armor, def, slot, type);
|
return ForgeHooksClient.getArmorTexture(entity, item, def, slot, type);
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the mod armour texture for associated item and slot.
|
||||||
|
*
|
||||||
|
* @param entity The entity to get armour for.
|
||||||
|
* @param item The armour item
|
||||||
|
* @param slot The slot this armour piece is place in.
|
||||||
|
* @param def Default return value if no mods present
|
||||||
|
*/
|
||||||
public static ModelBiped getArmorModel(EntityLivingBase entity, ItemStack item, EntityEquipmentSlot slot, ModelBiped def) {
|
public static ModelBiped getArmorModel(EntityLivingBase entity, ItemStack item, EntityEquipmentSlot slot, ModelBiped def) {
|
||||||
if (forgeLoaded)
|
if (forgeLoaded)
|
||||||
return ForgeHooksClient.getArmorModel(entity, item, slot, def);
|
return ForgeHooksClient.getArmorModel(entity, item, slot, def);
|
||||||
|
|
|
@ -28,8 +28,6 @@ public class LiteModMineLittlePony implements Tickable, InitCompleteListener {
|
||||||
@Override
|
@Override
|
||||||
public void init(File configPath) {
|
public void init(File configPath) {
|
||||||
this.mlp = new MineLittlePony();
|
this.mlp = new MineLittlePony();
|
||||||
this.mlp.init();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -41,5 +39,4 @@ public class LiteModMineLittlePony implements Tickable, InitCompleteListener {
|
||||||
public void onTick(Minecraft minecraft, float partialTicks, boolean inGame, boolean clock) {
|
public void onTick(Minecraft minecraft, float partialTicks, boolean inGame, boolean clock) {
|
||||||
this.mlp.onTick(minecraft, inGame);
|
this.mlp.onTick(minecraft, inGame);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,93 +1,69 @@
|
||||||
package com.minelittlepony;
|
package com.minelittlepony;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.minelittlepony.hdskins.gui.GuiSkinsMineLP;
|
import com.minelittlepony.hdskins.gui.GuiSkinsMineLP;
|
||||||
import com.minelittlepony.model.PMAPI;
|
|
||||||
import com.minelittlepony.pony.data.IPonyData;
|
import com.minelittlepony.pony.data.IPonyData;
|
||||||
import com.minelittlepony.pony.data.PonyDataSerialzier;
|
import com.minelittlepony.pony.data.PonyDataSerialzier;
|
||||||
import com.minelittlepony.render.player.RenderPonyPlayer;
|
|
||||||
import com.minelittlepony.render.ponies.RenderPonyEvoker;
|
|
||||||
import com.minelittlepony.render.ponies.RenderPonyIllusionIllager;
|
|
||||||
import com.minelittlepony.render.ponies.RenderPonyPigman;
|
|
||||||
import com.minelittlepony.render.ponies.RenderPonySkeleton;
|
|
||||||
import com.minelittlepony.render.ponies.RenderPonyVex;
|
|
||||||
import com.minelittlepony.render.ponies.RenderPonyVillager;
|
|
||||||
import com.minelittlepony.render.ponies.RenderPonyVindicator;
|
|
||||||
import com.minelittlepony.render.ponies.RenderPonyZombie;
|
|
||||||
import com.minelittlepony.render.ponies.RenderPonyZombieVillager;
|
|
||||||
import com.mumfrey.liteloader.core.LiteLoader;
|
import com.mumfrey.liteloader.core.LiteLoader;
|
||||||
import com.mumfrey.liteloader.util.ModUtilities;
|
|
||||||
import com.voxelmodpack.hdskins.HDSkinManager;
|
import com.voxelmodpack.hdskins.HDSkinManager;
|
||||||
import com.voxelmodpack.hdskins.gui.GuiSkins;
|
import com.voxelmodpack.hdskins.gui.GuiSkins;
|
||||||
import com.voxelmodpack.hdskins.skins.SkinServer;
|
import com.voxelmodpack.hdskins.skins.SkinServer;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.entity.Render;
|
|
||||||
import net.minecraft.client.renderer.entity.RenderManager;
|
import net.minecraft.client.renderer.entity.RenderManager;
|
||||||
import net.minecraft.client.resources.IReloadableResourceManager;
|
import net.minecraft.client.resources.IReloadableResourceManager;
|
||||||
import net.minecraft.client.resources.data.MetadataSerializer;
|
import net.minecraft.client.resources.data.MetadataSerializer;
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.monster.EntityEvoker;
|
|
||||||
import net.minecraft.entity.monster.EntityGiantZombie;
|
|
||||||
import net.minecraft.entity.monster.EntityHusk;
|
|
||||||
import net.minecraft.entity.monster.EntityIllusionIllager;
|
|
||||||
import net.minecraft.entity.monster.EntityPigZombie;
|
|
||||||
import net.minecraft.entity.monster.EntitySkeleton;
|
|
||||||
import net.minecraft.entity.monster.EntityStray;
|
|
||||||
import net.minecraft.entity.monster.EntityVex;
|
|
||||||
import net.minecraft.entity.monster.EntityVindicator;
|
|
||||||
import net.minecraft.entity.monster.EntityWitherSkeleton;
|
|
||||||
import net.minecraft.entity.monster.EntityZombie;
|
|
||||||
import net.minecraft.entity.monster.EntityZombieVillager;
|
|
||||||
import net.minecraft.entity.passive.EntityVillager;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
import java.util.Map;
|
/**
|
||||||
|
* Static MineLittlePony singleton class. Everything's controlled from up here.
|
||||||
|
*/
|
||||||
public class MineLittlePony {
|
public class MineLittlePony {
|
||||||
|
|
||||||
public static final Logger logger = LogManager.getLogger("MineLittlePony");
|
public static final Logger logger = LogManager.getLogger("MineLittlePony");
|
||||||
|
|
||||||
public static final String MOD_NAME = "Mine Little Pony";
|
public static final String
|
||||||
public static final String MOD_VERSION = "@VERSION@";
|
MOD_NAME = "Mine Little Pony",
|
||||||
|
MOD_VERSION = "@VERSION@";
|
||||||
|
|
||||||
|
private static final String
|
||||||
|
SKIN_SERVER_URL = "minelpskins.voxelmodpack.com",
|
||||||
|
GATEWAY_URL = "minelpskinmanager.voxelmodpack.com";
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private static final String SKIN_SERVER_URL = "minelpskins.voxelmodpack.com";
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private static final String GATEWAY_URL = "minelpskinmanager.voxelmodpack.com";
|
|
||||||
private static final KeyBinding SETTINGS_GUI = new KeyBinding("Settings", Keyboard.KEY_F9, "Mine Little Pony");
|
private static final KeyBinding SETTINGS_GUI = new KeyBinding("Settings", Keyboard.KEY_F9, "Mine Little Pony");
|
||||||
|
|
||||||
private static MineLittlePony instance;
|
private static MineLittlePony instance;
|
||||||
|
|
||||||
private PonyConfig config;
|
private final PonyConfig config;
|
||||||
private PonyManager ponyManager;
|
private final PonyManager ponyManager;
|
||||||
|
|
||||||
private Map<Class<? extends Entity>, Render<?>> renderMap = Maps.newHashMap();
|
private final PonyRenderManager renderManager;
|
||||||
|
|
||||||
MineLittlePony() {
|
MineLittlePony() {
|
||||||
instance = this;
|
instance = this;
|
||||||
}
|
|
||||||
|
|
||||||
void init() {
|
|
||||||
LiteLoader.getInput().registerKeyBinding(SETTINGS_GUI);
|
LiteLoader.getInput().registerKeyBinding(SETTINGS_GUI);
|
||||||
|
|
||||||
this.config = new PonyConfig();
|
config = new PonyConfig();
|
||||||
this.ponyManager = new PonyManager(config);
|
ponyManager = new PonyManager(config);
|
||||||
|
renderManager = new PonyRenderManager();
|
||||||
|
|
||||||
LiteLoader.getInstance().registerExposable(config, null);
|
LiteLoader.getInstance().registerExposable(config, null);
|
||||||
|
|
||||||
IReloadableResourceManager irrm = (IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager();
|
IReloadableResourceManager irrm = (IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager();
|
||||||
irrm.registerReloadListener(this.ponyManager);
|
irrm.registerReloadListener(ponyManager);
|
||||||
|
|
||||||
MetadataSerializer ms = Minecraft.getMinecraft().getResourcePackRepository().rprMetadataSerializer;
|
MetadataSerializer ms = Minecraft.getMinecraft().getResourcePackRepository().rprMetadataSerializer;
|
||||||
ms.registerMetadataSectionType(new PonyDataSerialzier(), IPonyData.class);
|
ms.registerMetadataSectionType(new PonyDataSerialzier(), IPonyData.class);
|
||||||
|
|
||||||
// This also makes it the default gateway server.
|
// This also makes it the default gateway server.
|
||||||
SkinServer.defaultServers.add("legacy:http://minelpskins.voxelmodpack.com;http://minelpskinmanager.voxelmodpack.com");
|
SkinServer.defaultServers.add("legacy:" + SKIN_SERVER_URL + ";" + GATEWAY_URL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the game is ready.
|
||||||
|
*/
|
||||||
void postInit(Minecraft minecraft) {
|
void postInit(Minecraft minecraft) {
|
||||||
|
|
||||||
HDSkinManager manager = HDSkinManager.INSTANCE;
|
HDSkinManager manager = HDSkinManager.INSTANCE;
|
||||||
|
@ -97,104 +73,13 @@ public class MineLittlePony {
|
||||||
// logger.info("Set MineLP skin server URL.");
|
// logger.info("Set MineLP skin server URL.");
|
||||||
|
|
||||||
RenderManager rm = minecraft.getRenderManager();
|
RenderManager rm = minecraft.getRenderManager();
|
||||||
this.saveCurrentRenderers(rm);
|
renderManager.initialisePlayerRenderers(rm);
|
||||||
//ModUtilities.addRenderer(EntityPonyModel.class, new RenderPonyModel(rm));
|
renderManager.initializeMobRenderers(rm, config);
|
||||||
|
|
||||||
this.initialisePlayerRenderers(rm);
|
|
||||||
this.initializeMobRenderers(rm);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void saveCurrentRenderers(RenderManager rm) {
|
|
||||||
// villagers
|
|
||||||
saveRenderer(rm, EntityVillager.class);
|
|
||||||
saveRenderer(rm, EntityZombieVillager.class);
|
|
||||||
// zombies
|
|
||||||
saveRenderer(rm, EntityZombie.class);
|
|
||||||
saveRenderer(rm, EntityGiantZombie.class);
|
|
||||||
saveRenderer(rm, EntityHusk.class);
|
|
||||||
// pig zombie
|
|
||||||
saveRenderer(rm, EntityPigZombie.class);
|
|
||||||
// skeletons
|
|
||||||
saveRenderer(rm, EntitySkeleton.class);
|
|
||||||
saveRenderer(rm, EntityStray.class);
|
|
||||||
saveRenderer(rm, EntityWitherSkeleton.class);
|
|
||||||
// illagers
|
|
||||||
saveRenderer(rm, EntityVex.class);
|
|
||||||
saveRenderer(rm, EntityEvoker.class);
|
|
||||||
saveRenderer(rm, EntityVindicator.class);
|
|
||||||
saveRenderer(rm, EntityIllusionIllager.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void saveRenderer(RenderManager rm, Class<? extends Entity> cl) {
|
|
||||||
this.renderMap.put(cl, rm.getEntityClassRenderObject(cl));
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private <T extends Entity> Render<T> getRenderer(Class<T> cl) {
|
|
||||||
Render<T> render = (Render<T>) this.renderMap.get(cl);
|
|
||||||
if (render == null) throw new MissingRendererException(cl);
|
|
||||||
return render;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void initialisePlayerRenderers(RenderManager rm) {
|
|
||||||
new RenderPonyPlayer(rm, false, "pony", PMAPI.pony);
|
|
||||||
new RenderPonyPlayer(rm, true, "slimpony", PMAPI.ponySmall);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void initializeMobRenderers(RenderManager rm) {
|
|
||||||
if (this.config.villagers) {
|
|
||||||
ModUtilities.addRenderer(EntityVillager.class, new RenderPonyVillager(rm));
|
|
||||||
ModUtilities.addRenderer(EntityZombieVillager.class, new RenderPonyZombieVillager(rm));
|
|
||||||
logger.info("Villagers are now ponies.");
|
|
||||||
} else {
|
|
||||||
ModUtilities.addRenderer(EntityVillager.class, getRenderer(EntityVillager.class));
|
|
||||||
ModUtilities.addRenderer(EntityZombieVillager.class, getRenderer(EntityZombieVillager.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.config.zombies) {
|
|
||||||
ModUtilities.addRenderer(EntityZombie.class, new RenderPonyZombie<>(rm));
|
|
||||||
ModUtilities.addRenderer(EntityHusk.class, new RenderPonyZombie.Husk(rm));
|
|
||||||
ModUtilities.addRenderer(EntityGiantZombie.class, new RenderPonyZombie.Giant(rm));
|
|
||||||
logger.info("Zombies are now ponies.");
|
|
||||||
} else {
|
|
||||||
ModUtilities.addRenderer(EntityZombie.class, getRenderer(EntityZombie.class));
|
|
||||||
ModUtilities.addRenderer(EntityHusk.class, getRenderer(EntityHusk.class));
|
|
||||||
ModUtilities.addRenderer(EntityGiantZombie.class, getRenderer(EntityGiantZombie.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.config.pigzombies) {
|
|
||||||
ModUtilities.addRenderer(EntityPigZombie.class, new RenderPonyPigman(rm));
|
|
||||||
logger.info("Zombie pigmen are now ponies.");
|
|
||||||
} else {
|
|
||||||
ModUtilities.addRenderer(EntityPigZombie.class, getRenderer(EntityPigZombie.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.config.skeletons) {
|
|
||||||
ModUtilities.addRenderer(EntitySkeleton.class, new RenderPonySkeleton<>(rm));
|
|
||||||
ModUtilities.addRenderer(EntityStray.class, new RenderPonySkeleton.Stray(rm));
|
|
||||||
ModUtilities.addRenderer(EntityWitherSkeleton.class, new RenderPonySkeleton.Wither(rm));
|
|
||||||
logger.info("Skeletons are now ponies.");
|
|
||||||
} else {
|
|
||||||
ModUtilities.addRenderer(EntitySkeleton.class, getRenderer(EntitySkeleton.class));
|
|
||||||
ModUtilities.addRenderer(EntityStray.class, getRenderer(EntityStray.class));
|
|
||||||
ModUtilities.addRenderer(EntityWitherSkeleton.class, getRenderer(EntityWitherSkeleton.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.config.illagers) {
|
|
||||||
ModUtilities.addRenderer(EntityVex.class, new RenderPonyVex(rm));
|
|
||||||
ModUtilities.addRenderer(EntityEvoker.class, new RenderPonyEvoker(rm));
|
|
||||||
ModUtilities.addRenderer(EntityVindicator.class, new RenderPonyVindicator(rm));
|
|
||||||
ModUtilities.addRenderer(EntityIllusionIllager.class, new RenderPonyIllusionIllager(rm));
|
|
||||||
logger.info("Illagers are now ponies.");
|
|
||||||
} else {
|
|
||||||
ModUtilities.addRenderer(EntityVex.class, getRenderer(EntityVex.class));
|
|
||||||
ModUtilities.addRenderer(EntityEvoker.class, getRenderer(EntityEvoker.class));
|
|
||||||
ModUtilities.addRenderer(EntityVindicator.class, getRenderer(EntityVindicator.class));
|
|
||||||
ModUtilities.addRenderer(EntityIllusionIllager.class, getRenderer(EntityIllusionIllager.class));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called on every update tick
|
||||||
|
*/
|
||||||
void onTick(Minecraft minecraft, boolean inGame) {
|
void onTick(Minecraft minecraft, boolean inGame) {
|
||||||
|
|
||||||
if (inGame && minecraft.currentScreen == null && SETTINGS_GUI.isPressed()) {
|
if (inGame && minecraft.currentScreen == null && SETTINGS_GUI.isPressed()) {
|
||||||
|
@ -210,14 +95,30 @@ public class MineLittlePony {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the global MineLP instance.
|
||||||
|
*/
|
||||||
public static MineLittlePony getInstance() {
|
public static MineLittlePony getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the static pony manager instance.
|
||||||
|
*/
|
||||||
public PonyManager getManager() {
|
public PonyManager getManager() {
|
||||||
return ponyManager;
|
return ponyManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the static pony render manager responsible for all entity renderers.
|
||||||
|
*/
|
||||||
|
public PonyRenderManager getRenderManager() {
|
||||||
|
return renderManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the global MineLP client configuration.
|
||||||
|
*/
|
||||||
public static PonyConfig getConfig() {
|
public static PonyConfig getConfig() {
|
||||||
return getInstance().config;
|
return getInstance().config;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,10 @@ import com.mumfrey.liteloader.modconfig.ConfigStrategy;
|
||||||
import com.mumfrey.liteloader.modconfig.Exposable;
|
import com.mumfrey.liteloader.modconfig.Exposable;
|
||||||
import com.mumfrey.liteloader.modconfig.ExposableOptions;
|
import com.mumfrey.liteloader.modconfig.ExposableOptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Storage contained for MineLP client settings.
|
||||||
|
*
|
||||||
|
*/
|
||||||
@ExposableOptions(filename = "minelittlepony", strategy = ConfigStrategy.Unversioned)
|
@ExposableOptions(filename = "minelittlepony", strategy = ConfigStrategy.Unversioned)
|
||||||
public class PonyConfig implements Exposable {
|
public class PonyConfig implements Exposable {
|
||||||
|
|
||||||
|
@ -20,15 +24,26 @@ public class PonyConfig implements Exposable {
|
||||||
@Expose public boolean skeletons = true;
|
@Expose public boolean skeletons = true;
|
||||||
@Expose public boolean illagers = true;
|
@Expose public boolean illagers = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current PonyLevel. That is the level of ponies you would like to see.
|
||||||
|
* @param ignorePony true to ignore whatever value the setting has.
|
||||||
|
*/
|
||||||
public PonyLevel getPonyLevel(boolean ignorePony) {
|
public PonyLevel getPonyLevel(boolean ignorePony) {
|
||||||
return ignorePony ? PonyLevel.BOTH : getPonyLevel();
|
return ignorePony ? PonyLevel.BOTH : getPonyLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Actually gets the pony level value. No option to ignore reality here.
|
||||||
|
*/
|
||||||
public PonyLevel getPonyLevel() {
|
public PonyLevel getPonyLevel() {
|
||||||
if (ponylevel == null) ponylevel = PonyLevel.PONIES;
|
if (ponylevel == null) ponylevel = PonyLevel.PONIES;
|
||||||
return ponylevel;
|
return ponylevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the pony level. Want MOAR PONEHS? Well here you go.
|
||||||
|
* @param ponylevel
|
||||||
|
*/
|
||||||
public void setPonyLevel(PonyLevel ponylevel) {
|
public void setPonyLevel(PonyLevel ponylevel) {
|
||||||
this.ponylevel = ponylevel;
|
this.ponylevel = ponylevel;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,15 +24,22 @@ import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The PonyManager is responsible for reading and recoding all the pony data associated with an entity of skin.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class PonyManager implements IResourceManagerReloadListener {
|
public class PonyManager implements IResourceManagerReloadListener {
|
||||||
|
|
||||||
public static final ResourceLocation STEVE = new ResourceLocation("minelittlepony", "textures/entity/steve_pony.png");
|
public static final ResourceLocation
|
||||||
public static final ResourceLocation ALEX = new ResourceLocation("minelittlepony", "textures/entity/alex_pony.png");
|
STEVE = new ResourceLocation("minelittlepony", "textures/entity/steve_pony.png"),
|
||||||
|
ALEX = new ResourceLocation("minelittlepony", "textures/entity/alex_pony.png"),
|
||||||
private static final ResourceLocation BGPONIES_JSON = new ResourceLocation("minelittlepony", "textures/entity/pony/bgponies.json");
|
BGPONIES_JSON = new ResourceLocation("minelittlepony", "textures/entity/pony/bgponies.json");
|
||||||
|
|
||||||
private static final Gson GSON = new Gson();
|
private static final Gson GSON = new Gson();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All currently loaded background ponies.
|
||||||
|
*/
|
||||||
private List<ResourceLocation> backgroundPonyList = Lists.newArrayList();
|
private List<ResourceLocation> backgroundPonyList = Lists.newArrayList();
|
||||||
|
|
||||||
private PonyConfig config;
|
private PonyConfig config;
|
||||||
|
@ -46,16 +53,27 @@ public class PonyManager implements IResourceManagerReloadListener {
|
||||||
initmodels();
|
initmodels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initmodels() {
|
private void initmodels() {
|
||||||
MineLittlePony.logger.info("Initializing models...");
|
MineLittlePony.logger.info("Initializing models...");
|
||||||
PMAPI.init();
|
PMAPI.init();
|
||||||
MineLittlePony.logger.info("Done initializing models.");
|
MineLittlePony.logger.info("Done initializing models.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Pony getPony(ResourceLocation skinResourceLocation, boolean slim) {
|
/**
|
||||||
return poniesCache.computeIfAbsent(skinResourceLocation, res -> new Pony(res, slim));
|
* Gets or creates a pony for the given skin resource and vanilla model type.
|
||||||
|
*
|
||||||
|
* @param resource A texture resource
|
||||||
|
*/
|
||||||
|
public Pony getPony(ResourceLocation resource, boolean slim) {
|
||||||
|
return poniesCache.computeIfAbsent(resource, res -> new Pony(res, slim));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets or creates a pony for the given player.
|
||||||
|
* Delegates to the background-ponies registry if no pony skins were available and client settings allows it.
|
||||||
|
*
|
||||||
|
* @param player the player
|
||||||
|
*/
|
||||||
public Pony getPony(AbstractClientPlayer player) {
|
public Pony getPony(AbstractClientPlayer player) {
|
||||||
Pony pony = getPony(player.getLocationSkin(), IPlayerInfo.getPlayerInfo(player).usesSlimArms());
|
Pony pony = getPony(player.getLocationSkin(), IPlayerInfo.getPlayerInfo(player).usesSlimArms());
|
||||||
|
|
||||||
|
@ -66,6 +84,16 @@ public class PonyManager implements IResourceManagerReloadListener {
|
||||||
return pony;
|
return pony;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets or creates a pony for the given skin resource and entity id.
|
||||||
|
*
|
||||||
|
* Whether is has slim arms is determined by the id.
|
||||||
|
*
|
||||||
|
* Delegates to the background-ponies registry if no pony skins were available and client settings allows it.
|
||||||
|
*
|
||||||
|
* @param resource A texture resource
|
||||||
|
* @param uuid id of a player or entity
|
||||||
|
*/
|
||||||
public Pony getPony(ResourceLocation resource, UUID uuid) {
|
public Pony getPony(ResourceLocation resource, UUID uuid) {
|
||||||
Pony pony = getPony(resource, isSlimSkin(uuid));
|
Pony pony = getPony(resource, isSlimSkin(uuid));
|
||||||
|
|
||||||
|
@ -76,6 +104,11 @@ public class PonyManager implements IResourceManagerReloadListener {
|
||||||
return pony;
|
return pony;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the default pony. Either STEVE/ALEX, or a background pony based on client settings.
|
||||||
|
*
|
||||||
|
* @param uuid id of a player or entity
|
||||||
|
*/
|
||||||
public Pony getDefaultPony(UUID uuid) {
|
public Pony getDefaultPony(UUID uuid) {
|
||||||
if (config.getPonyLevel() != PonyLevel.PONIES) {
|
if (config.getPonyLevel() != PonyLevel.PONIES) {
|
||||||
return getPony(DefaultPlayerSkin.getDefaultSkin(uuid), isSlimSkin(uuid));
|
return getPony(DefaultPlayerSkin.getDefaultSkin(uuid), isSlimSkin(uuid));
|
||||||
|
@ -93,6 +126,9 @@ public class PonyManager implements IResourceManagerReloadListener {
|
||||||
return getPony(backgroundPonyList.get(bgi), false);
|
return getPony(backgroundPonyList.get(bgi), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* De-registers a pony from the cache.
|
||||||
|
*/
|
||||||
public Pony removePony(ResourceLocation location) {
|
public Pony removePony(ResourceLocation location) {
|
||||||
return poniesCache.remove(location);
|
return poniesCache.remove(location);
|
||||||
}
|
}
|
||||||
|
@ -124,6 +160,9 @@ public class PonyManager implements IResourceManagerReloadListener {
|
||||||
return isSlimSkin(uuid) ? ALEX : STEVE;
|
return isSlimSkin(uuid) ? ALEX : STEVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the given uuid is of a player would would use the ALEX skin type.
|
||||||
|
*/
|
||||||
public static boolean isSlimSkin(UUID uuid) {
|
public static boolean isSlimSkin(UUID uuid) {
|
||||||
return (uuid.hashCode() & 1) == 1;
|
return (uuid.hashCode() & 1) == 1;
|
||||||
}
|
}
|
||||||
|
|
142
src/main/java/com/minelittlepony/PonyRenderManager.java
Normal file
142
src/main/java/com/minelittlepony/PonyRenderManager.java
Normal file
|
@ -0,0 +1,142 @@
|
||||||
|
package com.minelittlepony;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.minelittlepony.hdskins.gui.EntityPonyModel;
|
||||||
|
import com.minelittlepony.hdskins.gui.RenderPonyModel;
|
||||||
|
import com.minelittlepony.model.PMAPI;
|
||||||
|
import com.minelittlepony.render.player.RenderPonyPlayer;
|
||||||
|
import com.minelittlepony.render.ponies.RenderPonyEvoker;
|
||||||
|
import com.minelittlepony.render.ponies.RenderPonyIllusionIllager;
|
||||||
|
import com.minelittlepony.render.ponies.RenderPonyPigman;
|
||||||
|
import com.minelittlepony.render.ponies.RenderPonySkeleton;
|
||||||
|
import com.minelittlepony.render.ponies.RenderPonyVex;
|
||||||
|
import com.minelittlepony.render.ponies.RenderPonyVillager;
|
||||||
|
import com.minelittlepony.render.ponies.RenderPonyVindicator;
|
||||||
|
import com.minelittlepony.render.ponies.RenderPonyZombie;
|
||||||
|
import com.minelittlepony.render.ponies.RenderPonyZombieVillager;
|
||||||
|
import com.mumfrey.liteloader.util.ModUtilities;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.entity.Render;
|
||||||
|
import net.minecraft.client.renderer.entity.RenderManager;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.monster.EntityEvoker;
|
||||||
|
import net.minecraft.entity.monster.EntityGiantZombie;
|
||||||
|
import net.minecraft.entity.monster.EntityHusk;
|
||||||
|
import net.minecraft.entity.monster.EntityIllusionIllager;
|
||||||
|
import net.minecraft.entity.monster.EntityPigZombie;
|
||||||
|
import net.minecraft.entity.monster.EntitySkeleton;
|
||||||
|
import net.minecraft.entity.monster.EntityStray;
|
||||||
|
import net.minecraft.entity.monster.EntityVex;
|
||||||
|
import net.minecraft.entity.monster.EntityVindicator;
|
||||||
|
import net.minecraft.entity.monster.EntityWitherSkeleton;
|
||||||
|
import net.minecraft.entity.monster.EntityZombie;
|
||||||
|
import net.minecraft.entity.monster.EntityZombieVillager;
|
||||||
|
import net.minecraft.entity.passive.EntityVillager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render manager responsible for replacing and restoring entity renderers when the client settings change.
|
||||||
|
* Old values of persisted internally.
|
||||||
|
*/
|
||||||
|
public class PonyRenderManager {
|
||||||
|
|
||||||
|
private final Map<Class<? extends Entity>, Render<?>> renderMap = Maps.newHashMap();
|
||||||
|
|
||||||
|
public PonyRenderManager() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers all new player skin types. (currently only pony and slimpony).
|
||||||
|
*/
|
||||||
|
public void initialisePlayerRenderers(RenderManager rm) {
|
||||||
|
// Preview on the select skin gui
|
||||||
|
ModUtilities.addRenderer(EntityPonyModel.class, new RenderPonyModel(rm));
|
||||||
|
|
||||||
|
new RenderPonyPlayer(rm, false, "pony", PMAPI.pony);
|
||||||
|
new RenderPonyPlayer(rm, true, "slimpony", PMAPI.ponySmall);
|
||||||
|
//TODO: Add skin types for each species? May require model break up.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers all entity model replacements. (except for players).
|
||||||
|
*/
|
||||||
|
public void initializeMobRenderers(RenderManager rm, PonyConfig config) {
|
||||||
|
|
||||||
|
if (config.villagers) {
|
||||||
|
pushNewRenderer(rm, EntityVillager.class, new RenderPonyVillager(rm));
|
||||||
|
pushNewRenderer(rm, EntityZombieVillager.class, new RenderPonyZombieVillager(rm));
|
||||||
|
MineLittlePony.logger.info("Villagers are now ponies.");
|
||||||
|
} else {
|
||||||
|
restoreRenderer(EntityVillager.class);
|
||||||
|
restoreRenderer(EntityZombieVillager.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.zombies) {
|
||||||
|
pushNewRenderer(rm, EntityZombie.class, new RenderPonyZombie<>(rm));
|
||||||
|
pushNewRenderer(rm, EntityHusk.class, new RenderPonyZombie.Husk(rm));
|
||||||
|
pushNewRenderer(rm, EntityGiantZombie.class, new RenderPonyZombie.Giant(rm));
|
||||||
|
MineLittlePony.logger.info("Zombies are now ponies.");
|
||||||
|
} else {
|
||||||
|
restoreRenderer(EntityZombie.class);
|
||||||
|
restoreRenderer(EntityHusk.class);
|
||||||
|
restoreRenderer(EntityGiantZombie.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.pigzombies) {
|
||||||
|
pushNewRenderer(rm, EntityPigZombie.class, new RenderPonyPigman(rm));
|
||||||
|
MineLittlePony.logger.info("Zombie pigmen are now ponies.");
|
||||||
|
} else {
|
||||||
|
restoreRenderer(EntityPigZombie.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.skeletons) {
|
||||||
|
pushNewRenderer(rm, EntitySkeleton.class, new RenderPonySkeleton<>(rm));
|
||||||
|
pushNewRenderer(rm, EntityStray.class, new RenderPonySkeleton.Stray(rm));
|
||||||
|
pushNewRenderer(rm, EntityWitherSkeleton.class, new RenderPonySkeleton.Wither(rm));
|
||||||
|
MineLittlePony.logger.info("Skeletons are now ponies.");
|
||||||
|
} else {
|
||||||
|
restoreRenderer(EntitySkeleton.class);
|
||||||
|
restoreRenderer(EntityStray.class);
|
||||||
|
restoreRenderer(EntityWitherSkeleton.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.illagers) {
|
||||||
|
pushNewRenderer(rm, EntityVex.class, new RenderPonyVex(rm));
|
||||||
|
pushNewRenderer(rm, EntityEvoker.class, new RenderPonyEvoker(rm));
|
||||||
|
pushNewRenderer(rm, EntityVindicator.class, new RenderPonyVindicator(rm));
|
||||||
|
pushNewRenderer(rm, EntityIllusionIllager.class, new RenderPonyIllusionIllager(rm));
|
||||||
|
MineLittlePony.logger.info("Illagers are now ponies.");
|
||||||
|
} else {
|
||||||
|
restoreRenderer(EntityVex.class);
|
||||||
|
restoreRenderer(EntityEvoker.class);
|
||||||
|
restoreRenderer(EntityVindicator.class);
|
||||||
|
restoreRenderer(EntityIllusionIllager.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pushes a new renderer replacement storing the original internally. This change can be undone with {@link #restoreRenderer(Class)}
|
||||||
|
* @param manager The render manager
|
||||||
|
* @param type The type to replace
|
||||||
|
* @param renderer The replacement value
|
||||||
|
* @param <T> The entity type
|
||||||
|
*/
|
||||||
|
public <T extends Entity> void pushNewRenderer(RenderManager manager, Class<T> type, Render<T> renderer) {
|
||||||
|
if (!renderMap.containsKey(type)) {
|
||||||
|
renderMap.put(type, manager.getEntityClassRenderObject(type));
|
||||||
|
}
|
||||||
|
ModUtilities.addRenderer(type, renderer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restores a renderer to its previous value.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public <T extends Entity> void restoreRenderer(Class<T> type) {
|
||||||
|
if (renderMap.containsKey(type)) {
|
||||||
|
ModUtilities.addRenderer(type, (Render<T>)renderMap.get(type));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,6 +9,9 @@ import net.minecraft.client.resources.I18n;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In-Game options menu.
|
||||||
|
*/
|
||||||
public class PonySettingPanel extends GuiScreen {
|
public class PonySettingPanel extends GuiScreen {
|
||||||
|
|
||||||
private static final String _PREFIX = "minelp.options.";
|
private static final String _PREFIX = "minelp.options.";
|
||||||
|
@ -175,6 +178,6 @@ public class PonySettingPanel extends GuiScreen {
|
||||||
@Override
|
@Override
|
||||||
public void onGuiClosed() {
|
public void onGuiClosed() {
|
||||||
LiteLoader.getInstance().writeConfig(config);
|
LiteLoader.getInstance().writeConfig(config);
|
||||||
MineLittlePony.getInstance().initializeMobRenderers(mc.getRenderManager());
|
MineLittlePony.getInstance().getRenderManager().initializeMobRenderers(mc.getRenderManager(), config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,5 +3,8 @@ package com.minelittlepony.ducks;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
public interface IDownloadImageData {
|
public interface IDownloadImageData {
|
||||||
|
/**
|
||||||
|
* Gets the downloaded image data as a buffered image.
|
||||||
|
*/
|
||||||
BufferedImage getBufferedImage();
|
BufferedImage getBufferedImage();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,19 @@ import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||||
|
|
||||||
public interface IPlayerInfo {
|
public interface IPlayerInfo {
|
||||||
|
/**
|
||||||
|
* Gets the pony associated with this player.
|
||||||
|
*/
|
||||||
Pony getPony();
|
Pony getPony();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the vanilla skin (the one returned by NetworkPlayerInfo.getSkinLocation) uses the ALEX model type.
|
||||||
|
*/
|
||||||
boolean usesSlimArms();
|
boolean usesSlimArms();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the player info for the given player.
|
||||||
|
*/
|
||||||
public static IPlayerInfo getPlayerInfo(AbstractClientPlayer player) {
|
public static IPlayerInfo getPlayerInfo(AbstractClientPlayer player) {
|
||||||
return (IPlayerInfo)Minecraft.getMinecraft().getConnection().getPlayerInfo(player.getUniqueID());
|
return (IPlayerInfo)Minecraft.getMinecraft().getConnection().getPlayerInfo(player.getUniqueID());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
package com.minelittlepony.ducks;
|
package com.minelittlepony.ducks;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Holding class for entities that support special pony animations used for the renderers.
|
||||||
|
*/
|
||||||
public interface IPonyAnimationHolder {
|
public interface IPonyAnimationHolder {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates and gets the amount this entity is strafing to each side.
|
||||||
|
*/
|
||||||
float getStrafeAmount(float ticks);
|
float getStrafeAmount(float ticks);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,5 +2,8 @@ package com.minelittlepony.ducks;
|
||||||
|
|
||||||
public interface IRenderItem {
|
public interface IRenderItem {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether items should be rendered with transparency support.
|
||||||
|
*/
|
||||||
void useTransparency(boolean use);
|
void useTransparency(boolean use);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,5 +3,10 @@ package com.minelittlepony.ducks;
|
||||||
import net.minecraft.client.renderer.entity.RenderPlayer;
|
import net.minecraft.client.renderer.entity.RenderPlayer;
|
||||||
|
|
||||||
public interface IRenderManager {
|
public interface IRenderManager {
|
||||||
|
/**
|
||||||
|
* Registers a new player model to the underlying skinMap object.
|
||||||
|
* @param key The key to identify it by.
|
||||||
|
* @param render The renderer to add.
|
||||||
|
*/
|
||||||
void addPlayerSkin(String key, RenderPlayer render);
|
void addPlayerSkin(String key, RenderPlayer render);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,13 @@ package com.minelittlepony.ducks;
|
||||||
|
|
||||||
import com.minelittlepony.model.ModelWrapper;
|
import com.minelittlepony.model.ModelWrapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* I Render Pony now, oky?
|
||||||
|
*/
|
||||||
public interface IRenderPony {
|
public interface IRenderPony {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the wrapped pony model for this renderer.
|
||||||
|
*/
|
||||||
ModelWrapper getPlayerModel();
|
ModelWrapper getPlayerModel();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,9 @@ package com.minelittlepony.hdskins.gui;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.voxelmodpack.hdskins.gui.EntityPlayerModel;
|
import com.voxelmodpack.hdskins.gui.EntityPlayerModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dummy model used for the skin uploading screen.
|
||||||
|
*/
|
||||||
public class EntityPonyModel extends EntityPlayerModel {
|
public class EntityPonyModel extends EntityPlayerModel {
|
||||||
|
|
||||||
public EntityPonyModel(GameProfile profile) {
|
public EntityPonyModel(GameProfile profile) {
|
||||||
|
|
|
@ -8,6 +8,9 @@ import com.voxelmodpack.hdskins.gui.EntityPlayerModel;
|
||||||
import com.voxelmodpack.hdskins.gui.GuiSkins;
|
import com.voxelmodpack.hdskins.gui.GuiSkins;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skin uploading GUI. Usually displayed over the main menu.
|
||||||
|
*/
|
||||||
public class GuiSkinsMineLP extends GuiSkins {
|
public class GuiSkinsMineLP extends GuiSkins {
|
||||||
|
|
||||||
private PonyManager ponyManager;
|
private PonyManager ponyManager;
|
||||||
|
|
|
@ -18,6 +18,9 @@ import net.minecraft.inventory.EntityEquipmentSlot;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renderer used for the dummy pony model when selecting a skin.
|
||||||
|
*/
|
||||||
public class RenderPonyModel extends RenderPlayerModel<EntityPonyModel> {
|
public class RenderPonyModel extends RenderPlayerModel<EntityPonyModel> {
|
||||||
|
|
||||||
public RenderPonyModel(RenderManager renderer) {
|
public RenderPonyModel(RenderManager renderer) {
|
||||||
|
|
|
@ -29,27 +29,40 @@ public abstract class AbstractPonyModel extends ModelPlayer {
|
||||||
public IPonyData metadata = new PonyData();
|
public IPonyData metadata = new PonyData();
|
||||||
public float motionPitch;
|
public float motionPitch;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
// TODO: Why so many arms?
|
// TODO: Why so many arms?
|
||||||
public ModelRenderer steveLeftArm, steveRightArm,
|
public ModelRenderer steveLeftArm;
|
||||||
steveLeftArmwear, steveRightArmwear;
|
public ModelRenderer steveRightArm;
|
||||||
|
|
||||||
public AbstractPonyModel(boolean arms) {
|
public AbstractPonyModel(boolean arms) {
|
||||||
super(0, arms);
|
super(0, arms);
|
||||||
this.steveLeftArm = this.bipedLeftArm;
|
this.steveLeftArm = this.bipedLeftArm;
|
||||||
this.steveRightArm = this.bipedRightArm;
|
this.steveRightArm = this.bipedRightArm;
|
||||||
this.steveLeftArmwear = this.bipedLeftArmwear;
|
|
||||||
this.steveRightArmwear = this.bipedLeftArmwear;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up this model's initial values, like a constructor...
|
||||||
|
* @param yOffset YPosition for this model. Always 0.
|
||||||
|
* @param stretch Scaling factor for this model. Ranges above or below 0 (no change).
|
||||||
|
*/
|
||||||
public void init(float yOffset, float stretch) {
|
public void init(float yOffset, float stretch) {
|
||||||
this.initTextures();
|
initTextures();
|
||||||
this.initPositions(yOffset, stretch);
|
this.initPositions(yOffset, stretch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new pony armour to go with this model. Called on startup by a model wrapper.
|
||||||
|
*/
|
||||||
public abstract PonyArmor createArmour();
|
public abstract PonyArmor createArmour();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads texture values.
|
||||||
|
*/
|
||||||
protected abstract void initTextures();
|
protected abstract void initTextures();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads texture positions and boxes. Pretty much just finishes the job of initTextures.
|
||||||
|
*/
|
||||||
protected abstract void initPositions(float yOffset, float stretch);
|
protected abstract void initPositions(float yOffset, float stretch);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -58,17 +71,19 @@ public abstract class AbstractPonyModel extends ModelPlayer {
|
||||||
super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn);
|
super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.steveRightArm.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float) Math.PI) * 2.0F * limbSwingAmount * 0.5F;
|
|
||||||
|
this.steveRightArm.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float) Math.PI) * 2 * limbSwingAmount * 0.5F;
|
||||||
this.steveRightArm.rotateAngleY = 0;
|
this.steveRightArm.rotateAngleY = 0;
|
||||||
this.steveRightArm.rotateAngleZ = 0;
|
this.steveRightArm.rotateAngleZ = 0;
|
||||||
this.steveLeftArm.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * 2.0F * limbSwingAmount * 0.5F;
|
|
||||||
|
this.steveLeftArm.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * 2 * limbSwingAmount * 0.5F;
|
||||||
this.steveLeftArm.rotateAngleY = 0;
|
this.steveLeftArm.rotateAngleY = 0;
|
||||||
this.steveLeftArm.rotateAngleZ = 0;
|
this.steveLeftArm.rotateAngleZ = 0;
|
||||||
|
|
||||||
copyModelAngles(steveRightArm, steveRightArmwear);
|
|
||||||
copyModelAngles(steveLeftArm, steveLeftArmwear);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the default minecraft handling should be used.
|
||||||
|
*/
|
||||||
protected boolean doCancelRender() {
|
protected boolean doCancelRender() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -79,15 +94,31 @@ public abstract class AbstractPonyModel extends ModelPlayer {
|
||||||
aRenderer.rotationPointZ += shiftZ;
|
aRenderer.rotationPointZ += shiftZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void rotateArmHolding(ModelRenderer arm, float direction, float var8, float var9, float tick) {
|
/**
|
||||||
|
* Rotates the provided arm to the correct orientation for holding an item.
|
||||||
|
*
|
||||||
|
* @param arm The arm to rotate
|
||||||
|
* @param direction Direction multiplier. 1 for right, -1 for left.
|
||||||
|
* @param swingProgress How far we are through the current swing
|
||||||
|
* @param tick Render partial ticks
|
||||||
|
*/
|
||||||
|
protected static void rotateArmHolding(ModelRenderer arm, float direction, float swingProgress, float tick) {
|
||||||
|
float swing = MathHelper.sin(swingProgress * (float)Math.PI);
|
||||||
|
float roll = MathHelper.sin((1 - (1 - swingProgress) * (1 - swingProgress)) * (float)Math.PI);
|
||||||
|
|
||||||
arm.rotateAngleZ = 0.0F;
|
arm.rotateAngleZ = 0.0F;
|
||||||
arm.rotateAngleY = direction * (0.1F - var8 * 0.6F);
|
arm.rotateAngleY = direction * (0.1F - swing * 0.6F);
|
||||||
arm.rotateAngleX = -1.5707964F;
|
arm.rotateAngleX = -1.5707964F;
|
||||||
arm.rotateAngleX -= var8 * 1.2F - var9 * 0.4F;
|
arm.rotateAngleX -= swing * 1.2F - roll * 0.4F;
|
||||||
arm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F;
|
arm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F;
|
||||||
arm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.1F;
|
arm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.1F;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies a transform particular to a certain body part.
|
||||||
|
*
|
||||||
|
* FIXME: Too long! Is there a better way to do this?
|
||||||
|
*/
|
||||||
public void transform(BodyPart part) {
|
public void transform(BodyPart part) {
|
||||||
if (this.isRiding) {
|
if (this.isRiding) {
|
||||||
translate(0.0F, -0.6F, -0.2F);
|
translate(0.0F, -0.6F, -0.2F);
|
||||||
|
@ -221,15 +252,18 @@ public abstract class AbstractPonyModel extends ModelPlayer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copies this model's attributes from some other.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setModelAttributes(ModelBase model) {
|
public void setModelAttributes(ModelBase model) {
|
||||||
super.setModelAttributes(model);
|
super.setModelAttributes(model);
|
||||||
if (model instanceof AbstractPonyModel) {
|
if (model instanceof AbstractPonyModel) {
|
||||||
AbstractPonyModel pony = (AbstractPonyModel) model;
|
AbstractPonyModel pony = (AbstractPonyModel) model;
|
||||||
this.isFlying = pony.isFlying;
|
isFlying = pony.isFlying;
|
||||||
this.isSleeping = pony.isSleeping;
|
isSleeping = pony.isSleeping;
|
||||||
this.metadata = pony.metadata;
|
metadata = pony.metadata;
|
||||||
this.motionPitch = pony.motionPitch;
|
motionPitch = pony.motionPitch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,11 @@ package com.minelittlepony.model;
|
||||||
import com.minelittlepony.model.ponies.ModelPlayerPony;
|
import com.minelittlepony.model.ponies.ModelPlayerPony;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.util.math.MathHelper;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Common class for all humanoid (ponioid?) non-player enemies.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class ModelMobPony extends ModelPlayerPony {
|
public class ModelMobPony extends ModelPlayerPony {
|
||||||
|
|
||||||
public ModelMobPony() {
|
public ModelMobPony() {
|
||||||
|
@ -15,32 +18,42 @@ public class ModelMobPony extends ModelPlayerPony {
|
||||||
protected void rotateLegs(float move, float swing, float tick, Entity entity) {
|
protected void rotateLegs(float move, float swing, float tick, Entity entity) {
|
||||||
super.rotateLegs(move, swing, tick, entity);
|
super.rotateLegs(move, swing, tick, entity);
|
||||||
|
|
||||||
float var8 = MathHelper.sin(swingProgress * (float)Math.PI);
|
rotateRightArm(move, tick);
|
||||||
float var9 = MathHelper.sin((1 - (1 - swingProgress) * (1 - swingProgress)) * (float)Math.PI);
|
rotateLeftArm(move, tick);
|
||||||
|
|
||||||
rotateRightArm(var8, var9, move, tick);
|
|
||||||
rotateLeftArm(var8, var9, move, tick);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void rotateRightArm(float var8, float var9, float move, float tick) {
|
/**
|
||||||
|
* Called to update the left arm's final rotation.
|
||||||
|
* Subclasses may replace it with their own implementations.
|
||||||
|
*
|
||||||
|
* @param move Limb swing amount.
|
||||||
|
* @param tick Render partial ticks.
|
||||||
|
*/
|
||||||
|
protected void rotateRightArm(float move, float tick) {
|
||||||
if (this.rightArmPose == ArmPose.EMPTY) return;
|
if (this.rightArmPose == ArmPose.EMPTY) return;
|
||||||
|
|
||||||
if (!metadata.hasMagic()) {
|
if (!metadata.hasMagic()) {
|
||||||
rotateArmHolding(bipedRightArm, 1, var8, var9, tick);
|
rotateArmHolding(bipedRightArm, 1, swingProgress, tick);
|
||||||
} else {
|
} else {
|
||||||
unicornArmRight.setRotationPoint(-7, 12, -2);
|
unicornArmRight.setRotationPoint(-7, 12, -2);
|
||||||
rotateArmHolding(unicornArmRight, 1, var8, var9, tick);
|
rotateArmHolding(unicornArmRight, 1, swingProgress, tick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void rotateLeftArm(float var8, float var9, float move, float tick) {
|
/**
|
||||||
|
* Same as rotateRightArm but for the left arm (duh).
|
||||||
|
*
|
||||||
|
* @param move Limb swing amount.
|
||||||
|
* @param tick Render partial ticks.
|
||||||
|
*/
|
||||||
|
protected void rotateLeftArm(float move, float tick) {
|
||||||
if (leftArmPose == ArmPose.EMPTY) return;
|
if (leftArmPose == ArmPose.EMPTY) return;
|
||||||
|
|
||||||
if (!metadata.hasMagic()) {
|
if (!metadata.hasMagic()) {
|
||||||
rotateArmHolding(bipedLeftArm, 1, var8, var9, tick);
|
rotateArmHolding(bipedLeftArm, 1, swingProgress, tick);
|
||||||
} else {
|
} else {
|
||||||
unicornArmRight.setRotationPoint(-7, 12, -2);
|
unicornArmRight.setRotationPoint(-7, 12, -2);
|
||||||
rotateArmHolding(unicornArmLeft, 1, var8, var9, tick);
|
rotateArmHolding(unicornArmLeft, 1, swingProgress, tick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,17 @@ package com.minelittlepony.model;
|
||||||
import com.minelittlepony.model.armour.PonyArmor;
|
import com.minelittlepony.model.armour.PonyArmor;
|
||||||
import com.minelittlepony.pony.data.IPonyData;
|
import com.minelittlepony.pony.data.IPonyData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Container class for the various models and their associated piece of armour.
|
||||||
|
*/
|
||||||
public class ModelWrapper {
|
public class ModelWrapper {
|
||||||
|
|
||||||
private final AbstractPonyModel model;
|
private final AbstractPonyModel model;
|
||||||
private final PonyArmor armor;
|
private final PonyArmor armor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created a new model wrapper to contain the given pony.
|
||||||
|
*/
|
||||||
public ModelWrapper(AbstractPonyModel model) {
|
public ModelWrapper(AbstractPonyModel model) {
|
||||||
this.model = model;
|
this.model = model;
|
||||||
this.armor = model.createArmour();
|
this.armor = model.createArmour();
|
||||||
|
@ -18,17 +24,27 @@ public class ModelWrapper {
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
/**
|
||||||
model.init(0, 0);
|
* Returns the contained armour model.
|
||||||
armor.init();
|
* @return
|
||||||
}
|
*/
|
||||||
|
|
||||||
public PonyArmor getArmor() {
|
public PonyArmor getArmor() {
|
||||||
return armor;
|
return armor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates metadata values on this wrapper's armour and model.
|
||||||
|
*/
|
||||||
public void apply(IPonyData meta) {
|
public void apply(IPonyData meta) {
|
||||||
model.metadata = meta;
|
model.metadata = meta;
|
||||||
armor.apply(meta);
|
armor.apply(meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called at startup to configure a model's needed components.
|
||||||
|
*/
|
||||||
|
public void init() {
|
||||||
|
model.init(0, 0);
|
||||||
|
armor.init();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,14 +125,20 @@ public class ModelPonyArmor extends ModelMobPony {
|
||||||
@Override
|
@Override
|
||||||
protected void initLegTextures() {
|
protected void initLegTextures() {
|
||||||
this.bipedRightArm = new ModelRenderer(this, 0, 16);
|
this.bipedRightArm = new ModelRenderer(this, 0, 16);
|
||||||
|
this.steveRightArm = new ModelRenderer(this, 0, 16);
|
||||||
|
|
||||||
this.bipedLeftArm = new ModelRenderer(this, 0, 16);
|
this.bipedLeftArm = new ModelRenderer(this, 0, 16);
|
||||||
this.bipedLeftArm.mirror = true;
|
this.bipedLeftArm.mirror = true;
|
||||||
this.bipedRightLeg = new ModelRenderer(this, 0, 16);
|
|
||||||
this.bipedLeftLeg = new ModelRenderer(this, 0, 16);
|
this.bipedLeftLeg = new ModelRenderer(this, 0, 16);
|
||||||
this.bipedLeftLeg.mirror = true;
|
this.bipedLeftLeg.mirror = true;
|
||||||
this.steveRightArm = new ModelRenderer(this, 0, 16);
|
|
||||||
|
this.bipedRightLeg = new ModelRenderer(this, 0, 16);
|
||||||
|
|
||||||
|
|
||||||
this.unicornArmRight = new ModelRenderer(this, 0, 16);
|
this.unicornArmRight = new ModelRenderer(this, 0, 16);
|
||||||
this.unicornArmLeft = new ModelRenderer(this, 0, 16);
|
this.unicornArmLeft = new ModelRenderer(this, 0, 16);
|
||||||
|
|
||||||
this.extLegs[0] = new ModelRenderer(this, 48, 8);
|
this.extLegs[0] = new ModelRenderer(this, 48, 8);
|
||||||
this.extLegs[1] = new ModelRenderer(this, 48, 8);
|
this.extLegs[1] = new ModelRenderer(this, 48, 8);
|
||||||
this.extLegs[1].mirror = true;
|
this.extLegs[1].mirror = true;
|
||||||
|
|
|
@ -1,15 +1,26 @@
|
||||||
package com.minelittlepony.model.armour;
|
package com.minelittlepony.model.armour;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Armour for skeleton ponies.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class ModelSkeletonPonyArmor extends ModelPonyArmor {
|
public class ModelSkeletonPonyArmor extends ModelPonyArmor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The code here is copied from ModelMobPony, all with but one line of difference.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void rotateRightArm(float var8, float var9, float move, float tick) {
|
protected void rotateRightArm(float move, float tick) {
|
||||||
if (this.rightArmPose == ArmPose.EMPTY) return;
|
if (this.rightArmPose == ArmPose.EMPTY) return;
|
||||||
|
|
||||||
if (!this.metadata.hasMagic()) {
|
if (!this.metadata.hasMagic()) {
|
||||||
rotateArmHolding(bipedRightArm, 1, var8, var9, tick);
|
rotateArmHolding(bipedRightArm, 1, swingProgress, tick);
|
||||||
} else {
|
} else {
|
||||||
rotateArmHolding(unicornArmRight, 1, var8, var9, tick);
|
// With everything that's happening in ModelPonyArmor,
|
||||||
|
// it's hard to tell if this is need or not.
|
||||||
|
// Testing will probably reveal all.
|
||||||
|
//unicornArmRight.setRotationPoint(-7, 12, -2);
|
||||||
|
rotateArmHolding(unicornArmRight, 1, swingProgress, tick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,18 +9,18 @@ public class ModelZombiePonyArmor extends ModelPonyArmor {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void rotateRightArm(float var8, float var9, float move, float tick) {
|
protected void rotateRightArm(float move, float tick) {
|
||||||
if (rightArmPose != ArmPose.EMPTY) return;
|
if (rightArmPose != ArmPose.EMPTY) return;
|
||||||
|
|
||||||
if (isRight(move)) {
|
if (isRight(move)) {
|
||||||
rotateArmHolding(bipedRightArm, 1, var8, var9, tick);
|
rotateArmHolding(bipedRightArm, 1, swingProgress, tick);
|
||||||
} else {
|
} else {
|
||||||
rotateArmHolding(bipedLeftArm, -1, var8, var9, tick);
|
rotateArmHolding(bipedLeftArm, -1, swingProgress, tick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void rotateLeftArm(float var8, float var9, float move, float tick) {
|
protected void rotateLeftArm(float move, float tick) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -222,31 +222,33 @@ public class ModelPlayerPony extends AbstractPonyModel {
|
||||||
leftLeg = MathHelper.cos(mve + PI - (pi * 0.4f)) * srt;
|
leftLeg = MathHelper.cos(mve + PI - (pi * 0.4f)) * srt;
|
||||||
rightLeg = MathHelper.cos(mve + pi * 0.2f) * srt;
|
rightLeg = MathHelper.cos(mve + pi * 0.2f) * srt;
|
||||||
|
|
||||||
this.steveRightArm.rotateAngleY = 0;
|
this.steveRightArm.rotateAngleY = this.bipedRightArm.rotateAngleY = 0;
|
||||||
this.unicornArmRight.rotateAngleY = 0;
|
|
||||||
this.unicornArmLeft.rotateAngleY = 0;
|
|
||||||
|
|
||||||
this.bipedRightArm.rotateAngleY = 0;
|
|
||||||
this.bipedLeftArm.rotateAngleY = 0;
|
this.bipedLeftArm.rotateAngleY = 0;
|
||||||
this.bipedRightLeg.rotateAngleY = 0;
|
this.bipedRightLeg.rotateAngleY = 0;
|
||||||
this.bipedLeftLeg.rotateAngleY = 0;
|
this.bipedLeftLeg.rotateAngleY = 0;
|
||||||
|
|
||||||
|
this.unicornArmRight.rotateAngleY = 0;
|
||||||
|
this.unicornArmLeft.rotateAngleY = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.bipedRightArm.rotateAngleX = rightArm;
|
|
||||||
this.steveRightArm.rotateAngleX = rightArm;
|
|
||||||
|
|
||||||
|
|
||||||
|
this.steveLeftArm.rotateAngleX = this.bipedLeftArm.rotateAngleX = leftArm;
|
||||||
|
this.steveRightArm.rotateAngleX = this.bipedRightArm.rotateAngleX = rightArm;
|
||||||
|
|
||||||
|
this.bipedLeftArm.rotateAngleZ = 0;
|
||||||
|
this.steveRightArm.rotateAngleZ = this.bipedRightArm.rotateAngleZ = 0;
|
||||||
|
|
||||||
|
this.bipedLeftLeg.rotateAngleX = leftLeg;
|
||||||
|
this.bipedRightLeg.rotateAngleX = rightLeg;
|
||||||
|
|
||||||
this.unicornArmRight.rotateAngleX = 0;
|
this.unicornArmRight.rotateAngleX = 0;
|
||||||
this.unicornArmLeft.rotateAngleX = 0;
|
this.unicornArmLeft.rotateAngleX = 0;
|
||||||
|
|
||||||
this.bipedLeftArm.rotateAngleX = leftArm;
|
|
||||||
this.bipedRightLeg.rotateAngleX = rightLeg;
|
|
||||||
this.bipedLeftLeg.rotateAngleX = leftLeg;
|
|
||||||
|
|
||||||
this.bipedRightArm.rotateAngleZ = 0;
|
|
||||||
|
|
||||||
this.steveRightArm.rotateAngleZ = 0;
|
|
||||||
this.unicornArmRight.rotateAngleZ = 0;
|
this.unicornArmRight.rotateAngleZ = 0;
|
||||||
this.unicornArmLeft.rotateAngleZ = 0;
|
this.unicornArmLeft.rotateAngleZ = 0;
|
||||||
this.bipedLeftArm.rotateAngleZ = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getLegOutset() {
|
private float getLegOutset() {
|
||||||
|
@ -256,30 +258,34 @@ public class ModelPlayerPony extends AbstractPonyModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void adjustLegs() {
|
protected void adjustLegs() {
|
||||||
float sinBodyRotateAngleYFactor = MathHelper.sin(this.bipedBody.rotateAngleY) * 5;
|
float sin = MathHelper.sin(bipedBody.rotateAngleY) * 5;
|
||||||
float cosBodyRotateAngleYFactor = MathHelper.cos(this.bipedBody.rotateAngleY) * 5;
|
float cos = MathHelper.cos(bipedBody.rotateAngleY) * 5;
|
||||||
|
|
||||||
|
|
||||||
float legOutset = getLegOutset();
|
|
||||||
float spread = rainboom ? 2 : 1;
|
float spread = rainboom ? 2 : 1;
|
||||||
|
|
||||||
this.bipedRightArm.rotationPointZ = spread + sinBodyRotateAngleYFactor;
|
steveRightArm.rotationPointZ = bipedRightArm.rotationPointZ = spread + sin;
|
||||||
this.steveRightArm.rotationPointZ = spread + sinBodyRotateAngleYFactor;
|
|
||||||
this.bipedLeftArm.rotationPointZ = spread - sinBodyRotateAngleYFactor;
|
|
||||||
this.steveRightArm.rotationPointX = -cosBodyRotateAngleYFactor;
|
|
||||||
|
|
||||||
float rpxl = legOutset - cosBodyRotateAngleYFactor - 1;
|
bipedLeftArm.rotationPointZ = spread - sin;
|
||||||
float rpxr = cosBodyRotateAngleYFactor + 2 - legOutset;
|
steveRightArm.rotationPointZ = -cos;
|
||||||
|
|
||||||
bipedRightArm.rotationPointX = bipedRightLeg.rotationPointX = rpxl;
|
float legOutset = getLegOutset();
|
||||||
bipedLeftArm.rotationPointX = bipedLeftLeg.rotationPointX = rpxr;
|
float rpxl = cos + 1 - legOutset;
|
||||||
|
float rpxr = legOutset - cos - 1;
|
||||||
|
|
||||||
|
bipedRightArm.rotationPointX = rpxr;
|
||||||
|
bipedRightLeg.rotationPointX = rpxr;
|
||||||
|
bipedLeftArm.rotationPointX = rpxl;
|
||||||
|
bipedLeftLeg.rotationPointX = rpxl;
|
||||||
|
|
||||||
|
// Push the front legs back apart if we're a thin pony
|
||||||
|
if (smallArms) {
|
||||||
|
bipedLeftArm.rotationPointX--;
|
||||||
|
bipedLeftArm.rotationPointX += 2;
|
||||||
|
}
|
||||||
|
|
||||||
bipedRightArm.rotateAngleY += bipedBody.rotateAngleY;
|
bipedRightArm.rotateAngleY += bipedBody.rotateAngleY;
|
||||||
bipedLeftArm.rotateAngleY += bipedBody.rotateAngleY;
|
bipedLeftArm.rotateAngleY += bipedBody.rotateAngleY;
|
||||||
|
|
||||||
//noinspection SuspiciousNameCombination
|
|
||||||
this.bipedLeftArm.rotateAngleX += this.bipedBody.rotateAngleY;
|
|
||||||
|
|
||||||
bipedRightArm.rotationPointY = bipedLeftArm.rotationPointY = 8;
|
bipedRightArm.rotationPointY = bipedLeftArm.rotationPointY = 8;
|
||||||
bipedRightLeg.rotationPointZ = bipedLeftLeg.rotationPointZ = 10;
|
bipedRightLeg.rotationPointZ = bipedLeftLeg.rotationPointZ = 10;
|
||||||
}
|
}
|
||||||
|
@ -299,16 +305,15 @@ public class ModelPlayerPony extends AbstractPonyModel {
|
||||||
this.horn.setUsingMagic(this.leftArmPose != ArmPose.EMPTY || this.rightArmPose != ArmPose.EMPTY);
|
this.horn.setUsingMagic(this.leftArmPose != ArmPose.EMPTY || this.rightArmPose != ArmPose.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("incomplete-switch")
|
private void alignArmForAction(ModelRenderer arm, ArmPose pose, boolean both, float swing) {
|
||||||
private void alignArmForAction(ModelRenderer arm, ArmPose pose, boolean bothHoovesAreOccupied, float swing) {
|
|
||||||
switch (pose) {
|
switch (pose) {
|
||||||
case ITEM:
|
case ITEM:
|
||||||
float swag = 1;
|
float swag = 1;
|
||||||
if (!isFlying && bothHoovesAreOccupied) {
|
if (!isFlying && both) {
|
||||||
swag = (float) (1 - Math.pow(swing, 2));
|
swag = (float) (1 - Math.pow(swing, 2));
|
||||||
}
|
}
|
||||||
float rotationMultiplier = 0.5f + (1 - swag)/2;
|
float mult = 0.5f + (1 - swag)/2;
|
||||||
arm.rotateAngleX = this.bipedLeftArm.rotateAngleX * rotationMultiplier - ((float) Math.PI / 10) * swag;
|
arm.rotateAngleX = this.bipedLeftArm.rotateAngleX * mult - ((float) Math.PI / 10) * swag;
|
||||||
case EMPTY:
|
case EMPTY:
|
||||||
arm.rotateAngleY = 0;
|
arm.rotateAngleY = 0;
|
||||||
break;
|
break;
|
||||||
|
@ -316,6 +321,7 @@ public class ModelPlayerPony extends AbstractPonyModel {
|
||||||
arm.rotateAngleX = arm.rotateAngleX / 2 - 0.9424779F;
|
arm.rotateAngleX = arm.rotateAngleX / 2 - 0.9424779F;
|
||||||
arm.rotateAngleY = (float) (Math.PI / 6);
|
arm.rotateAngleY = (float) (Math.PI / 6);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,38 +354,38 @@ public class ModelPlayerPony extends AbstractPonyModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void swingArm(ModelRenderer arm, float f22, float f33, float f28) {
|
private void swingArm(ModelRenderer arm, float f22, float f33, float f28) {
|
||||||
arm.rotateAngleX = (float) (this.unicornArmRight.rotateAngleX - (f22 * 1.2D + f33));
|
arm.rotateAngleX = (float) (arm.rotateAngleX - (f22 * 1.2D + f33));
|
||||||
arm.rotateAngleY += this.bipedBody.rotateAngleY * 2.0F;
|
arm.rotateAngleY += this.bipedBody.rotateAngleY * 2.0F;
|
||||||
arm.rotateAngleZ = f28 * -0.4F;
|
arm.rotateAngleZ = f28 * -0.4F;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void swingArms(float tick) {
|
protected void swingArms(float tick) {
|
||||||
float cosTickFactor = MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F;
|
float cos = MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F;
|
||||||
float sinTickFactor = MathHelper.sin(tick * 0.067F) * 0.05F;
|
float sin = MathHelper.sin(tick * 0.067F) * 0.05F;
|
||||||
|
|
||||||
if (this.rightArmPose != ArmPose.EMPTY && !this.isSleeping) {
|
if (this.rightArmPose != ArmPose.EMPTY && !this.isSleeping) {
|
||||||
|
|
||||||
if (this.metadata.hasMagic()) {
|
if (this.metadata.hasMagic()) {
|
||||||
this.unicornArmRight.rotateAngleZ += cosTickFactor;
|
this.unicornArmRight.rotateAngleZ += cos;
|
||||||
this.unicornArmRight.rotateAngleX += sinTickFactor;
|
this.unicornArmRight.rotateAngleX += sin;
|
||||||
} else {
|
} else {
|
||||||
this.bipedRightArm.rotateAngleZ += cosTickFactor;
|
this.bipedRightArm.rotateAngleZ += cos;
|
||||||
this.bipedRightArm.rotateAngleX += sinTickFactor;
|
this.steveRightArm.rotateAngleZ += cos;
|
||||||
|
|
||||||
this.steveRightArm.rotateAngleZ += cosTickFactor;
|
this.bipedRightArm.rotateAngleX += sin;
|
||||||
this.steveRightArm.rotateAngleX += sinTickFactor;
|
this.steveRightArm.rotateAngleX += sin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.leftArmPose != ArmPose.EMPTY && !this.isSleeping) {
|
if (this.leftArmPose != ArmPose.EMPTY && !this.isSleeping) {
|
||||||
if (this.metadata.hasMagic()) {
|
if (this.metadata.hasMagic()) {
|
||||||
this.unicornArmLeft.rotateAngleZ += cosTickFactor;
|
this.unicornArmLeft.rotateAngleZ += cos;
|
||||||
this.unicornArmLeft.rotateAngleX += sinTickFactor;
|
this.unicornArmLeft.rotateAngleX += sin;
|
||||||
} else {
|
} else {
|
||||||
this.bipedLeftArm.rotateAngleZ += cosTickFactor;
|
this.bipedLeftArm.rotateAngleZ += cos;
|
||||||
this.bipedLeftArm.rotateAngleX += sinTickFactor;
|
this.steveLeftArm.rotateAngleZ += cos;
|
||||||
|
|
||||||
this.steveLeftArm.rotateAngleZ += cosTickFactor;
|
this.bipedLeftArm.rotateAngleX += sin;
|
||||||
this.steveLeftArm.rotateAngleX += sinTickFactor;
|
this.steveLeftArm.rotateAngleX += sin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -412,10 +418,9 @@ public class ModelPlayerPony extends AbstractPonyModel {
|
||||||
this.unicornArmLeft.rotateAngleX += SNEAK_LEG_X_ROTATION_ADJUSTMENT;
|
this.unicornArmLeft.rotateAngleX += SNEAK_LEG_X_ROTATION_ADJUSTMENT;
|
||||||
|
|
||||||
this.bipedRightArm.rotateAngleX -= SNEAK_LEG_X_ROTATION_ADJUSTMENT;
|
this.bipedRightArm.rotateAngleX -= SNEAK_LEG_X_ROTATION_ADJUSTMENT;
|
||||||
this.bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_SNEAK;
|
|
||||||
|
|
||||||
this.bipedLeftArm.rotateAngleX -= SNEAK_LEG_X_ROTATION_ADJUSTMENT;
|
this.bipedLeftArm.rotateAngleX -= SNEAK_LEG_X_ROTATION_ADJUSTMENT;
|
||||||
this.bipedLeftLeg.rotationPointY = FRONT_LEG_RP_Y_SNEAK;
|
|
||||||
|
this.bipedLeftLeg.rotationPointY = this.bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_SNEAK;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void ponySleep() {
|
protected void ponySleep() {
|
||||||
|
@ -675,50 +680,55 @@ public class ModelPlayerPony extends AbstractPonyModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void initLegPositions(float yOffset, float stretch) {
|
protected void initLegPositions(float yOffset, float stretch) {
|
||||||
int armWidth = this.smallArms ? 3 : 4;
|
int armWidth = smallArms ? 3 : 4;
|
||||||
float armY = this.smallArms ? 8.5f : 8f;
|
float rarmY = smallArms ? 8.5f : 8;
|
||||||
float armX = this.smallArms ? -2f : -3f;
|
float rarmX = smallArms ? 2 : 3;
|
||||||
|
|
||||||
this.bipedRightArm.addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, armWidth, 12, 4, stretch);
|
float armX = THIRDP_ARM_CENTRE_X - 2;
|
||||||
this.bipedLeftArm .addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, armWidth, 12, 4, stretch);
|
float armY = THIRDP_ARM_CENTRE_Y - 6;
|
||||||
|
float armZ = THIRDP_ARM_CENTRE_Z - 2;
|
||||||
|
|
||||||
this.bipedRightArm.setRotationPoint(armX, yOffset + armY, 0.0F);
|
this.bipedLeftArm .addBox(armX, armY, armZ, armWidth, 12, 4, stretch);
|
||||||
this.bipedLeftArm .setRotationPoint(3.0F, yOffset + armY, 0.0F);
|
this.bipedRightArm.addBox(armX, armY, armZ, armWidth, 12, 4, stretch);
|
||||||
|
|
||||||
this.bipedRightLeg.addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, 4, 12, 4, stretch);
|
this.bipedLeftLeg .addBox(armX, armY, armZ, 4, 12, 4, stretch);
|
||||||
this.bipedLeftLeg .addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, 4, 12, 4, stretch);
|
this.bipedRightLeg.addBox(armX, armY, armZ, 4, 12, 4, stretch);
|
||||||
|
|
||||||
this.bipedRightLeg.setRotationPoint(-3.0F, 0.0F + yOffset, 0.0F);
|
this.bipedLeftArm .setRotationPoint( rarmX, yOffset + rarmY, 0);
|
||||||
|
this.bipedRightArm.setRotationPoint(-rarmX, yOffset + rarmY, 0);
|
||||||
|
|
||||||
this.unicornArmRight.addBox(-2.0F + FIRSTP_ARM_CENTRE_X, -6.0F + FIRSTP_ARM_CENTRE_Y, -2.0F + FIRSTP_ARM_CENTRE_Z, 4, 12, 4, stretch + .25f);
|
this.bipedLeftLeg .setRotationPoint( rarmX, yOffset, 0);
|
||||||
this.unicornArmLeft .addBox(-2.0F + FIRSTP_ARM_CENTRE_X, -6.0F + FIRSTP_ARM_CENTRE_Y, -2.0F + FIRSTP_ARM_CENTRE_Z, 4, 12, 4, stretch + .25f);
|
this.bipedRightLeg.setRotationPoint(-rarmX, yOffset, 0);
|
||||||
|
|
||||||
this.unicornArmRight.setRotationPoint(-5.0F, 2.0F + yOffset, 0.0F);
|
|
||||||
this.unicornArmLeft .setRotationPoint(-5.0F, 2.0F + yOffset, 0.0F);
|
|
||||||
|
|
||||||
if (bipedRightArmwear != null) {
|
|
||||||
this.bipedRightArmwear.addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, armWidth, 12, 4, stretch + 0.25f);
|
|
||||||
this.bipedRightArmwear.setRotationPoint(-3.0F, yOffset + armY, 0.0F);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bipedLeftArmwear != null) {
|
if (bipedLeftArmwear != null) {
|
||||||
this.bipedLeftArmwear .addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, 3, 12, 4, stretch + 0.25f);
|
this.bipedLeftArmwear.addBox(armX, armY, armZ, 3, 12, 4, stretch + 0.25f);
|
||||||
this.bipedLeftArmwear .setRotationPoint(3.0F, yOffset + armY, 0.0F);
|
this.bipedLeftArmwear.setRotationPoint(3, yOffset + rarmY, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bipedRightLegwear != null) {
|
if (bipedRightArmwear != null) {
|
||||||
this.bipedRightLegwear.addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, 4, 12, 4, stretch + 0.25f);
|
this.bipedRightArmwear.addBox(armX, armY, armZ, armWidth, 12, 4, stretch + 0.25f);
|
||||||
this.bipedRightLegwear.setRotationPoint(-3.0F, 0.0F + yOffset, 0.0F);
|
this.bipedRightArmwear.setRotationPoint(-3, yOffset + rarmY, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.bipedLeftLegwear != null) {
|
if (this.bipedLeftLegwear != null) {
|
||||||
this.bipedLeftLegwear.addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, 4, 12, 4, stretch + 0.25f);
|
this.bipedLeftLegwear.addBox(armX, armY, armZ, 4, 12, 4, stretch + 0.25f);
|
||||||
|
this.bipedRightLegwear.setRotationPoint(3, yOffset, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bipedRightLegwear != null) {
|
||||||
|
this.bipedRightLegwear.addBox(armX, armY, armZ, 4, 12, 4, stretch + 0.25f);
|
||||||
|
this.bipedRightLegwear.setRotationPoint(-3, yOffset, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.unicornArmLeft .addBox(FIRSTP_ARM_CENTRE_X - 2, armY, armZ, 4, 12, 4, stretch + .25f);
|
||||||
|
this.unicornArmRight.addBox(FIRSTP_ARM_CENTRE_X - 2, armY, armZ, 4, 12, 4, stretch + .25f);
|
||||||
|
|
||||||
|
this.unicornArmLeft .setRotationPoint(5, yOffset + 2, 0);
|
||||||
|
this.unicornArmRight.setRotationPoint(-5, yOffset + 2, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderCape(float scale) {
|
public void renderCape(float scale) {
|
||||||
this.bipedCape.render(scale);
|
this.bipedCape.render(scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,6 @@ public class ModelSkeletonPony extends ModelMobPony {
|
||||||
if (rightArmPose != ArmPose.EMPTY && !metadata.hasMagic()) {
|
if (rightArmPose != ArmPose.EMPTY && !metadata.hasMagic()) {
|
||||||
bipedRightArm.setRotationPoint(-1.5F, 9.5F, 4);
|
bipedRightArm.setRotationPoint(-1.5F, 9.5F, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -22,18 +22,18 @@ public class ModelZombiePony extends ModelMobPony {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void rotateRightArm(float var8, float var9, float move, float tick) {
|
protected void rotateRightArm(float move, float tick) {
|
||||||
if (rightArmPose != ArmPose.EMPTY) return;
|
if (rightArmPose != ArmPose.EMPTY) return;
|
||||||
|
|
||||||
if (isRight(move)) {
|
if (isRight(move)) {
|
||||||
rotateArmHolding(bipedRightArm, 1, var8, var9, tick);
|
rotateArmHolding(bipedRightArm, 1, swingProgress, tick);
|
||||||
} else {
|
} else {
|
||||||
rotateArmHolding(bipedLeftArm, -1, var8, var9, tick);
|
rotateArmHolding(bipedLeftArm, -1, swingProgress, tick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void rotateLeftArm(float var8, float var9, float move, float tick) {
|
protected void rotateLeftArm(float move, float tick) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,18 +3,36 @@ package com.minelittlepony.pony.data;
|
||||||
import net.minecraft.client.resources.data.IMetadataSection;
|
import net.minecraft.client.resources.data.IMetadataSection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dummy interface so gson won't go crazy
|
* Metadata for a pony.
|
||||||
*/
|
*/
|
||||||
public interface IPonyData extends IMetadataSection {
|
public interface IPonyData extends IMetadataSection {
|
||||||
|
/**
|
||||||
|
* Gets this pony's race.
|
||||||
|
*/
|
||||||
PonyRace getRace();
|
PonyRace getRace();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the length of the pony's tail.
|
||||||
|
*/
|
||||||
TailLengths getTail();
|
TailLengths getTail();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the pony's gender (usually female).
|
||||||
|
*/
|
||||||
PonyGender getGender();
|
PonyGender getGender();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current pony size.
|
||||||
|
*/
|
||||||
PonySize getSize();
|
PonySize getSize();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the magical glow colour for magic-casting races. Returns 0 otherwise.
|
||||||
|
*/
|
||||||
int getGlowColor();
|
int getGlowColor();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if and only if this metadata represents a pony that can cast magic.
|
||||||
|
*/
|
||||||
boolean hasMagic();
|
boolean hasMagic();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,24 @@
|
||||||
package com.minelittlepony.pony.data;
|
package com.minelittlepony.pony.data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for enums that can be parsed from an image trigger pixel value.
|
||||||
|
* @author Chris Albers
|
||||||
|
*
|
||||||
|
* @param <T>
|
||||||
|
*/
|
||||||
public interface ITriggerPixelMapped<T extends Enum<T> & ITriggerPixelMapped<T>> {
|
public interface ITriggerPixelMapped<T extends Enum<T> & ITriggerPixelMapped<T>> {
|
||||||
|
/**
|
||||||
|
* Gets the pixel colour matching this enum value.
|
||||||
|
*/
|
||||||
int getTriggerPixel();
|
int getTriggerPixel();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the enum value corresponding to the given enum type and pixel value.
|
||||||
|
* If none are found, the first parameter is returned as the default.
|
||||||
|
*
|
||||||
|
* @param type Return type and default value.
|
||||||
|
* @param pixelValue The pixel colour to search for.
|
||||||
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T extends Enum<T> & ITriggerPixelMapped<T>> T getByTriggerPixel(T type, int pixelValue) {
|
public static <T extends Enum<T> & ITriggerPixelMapped<T>> T getByTriggerPixel(T type, int pixelValue) {
|
||||||
for (T i : (T[])type.getClass().getEnumConstants()) {
|
for (T i : (T[])type.getClass().getEnumConstants()) {
|
||||||
|
|
|
@ -6,6 +6,11 @@ import com.minelittlepony.MineLittlePony;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import javax.annotation.concurrent.Immutable;
|
import javax.annotation.concurrent.Immutable;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation for IPonyData.
|
||||||
|
*
|
||||||
|
*/
|
||||||
@Immutable
|
@Immutable
|
||||||
public class PonyData implements IPonyData {
|
public class PonyData implements IPonyData {
|
||||||
private final PonyRace race;
|
private final PonyRace race;
|
||||||
|
@ -71,6 +76,9 @@ public class PonyData implements IPonyData {
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses an image buffer into a new IPonyData representing the values stored in it's individual trigger pixels.
|
||||||
|
*/
|
||||||
static IPonyData parse(BufferedImage image) {
|
static IPonyData parse(BufferedImage image) {
|
||||||
return new PonyData(image);
|
return new PonyData(image);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,22 +29,41 @@ public enum PonyRace implements ITriggerPixelMapped<PonyRace> {
|
||||||
this.model = model;
|
this.model = model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this pony has a horn (and by extension can cast magic).
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public boolean hasHorn() {
|
public boolean hasHorn() {
|
||||||
return horn;
|
return horn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this pony has wings. If it has wings, it can fly, of course.
|
||||||
|
*/
|
||||||
public boolean hasWings() {
|
public boolean hasWings() {
|
||||||
return wings;
|
return wings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this is a human.
|
||||||
|
*/
|
||||||
public boolean isHuman() {
|
public boolean isHuman() {
|
||||||
return this == HUMAN;
|
return this == HUMAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the model type associated with this species.
|
||||||
|
*/
|
||||||
public PlayerModels getModel() {
|
public PlayerModels getModel() {
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the actual race determined by the given pony level.
|
||||||
|
* PonyLevel.HUMANS would force all races to be humans.
|
||||||
|
* PonyLevel.BOTH is no change.
|
||||||
|
* PonyLevel.PONIES (should) return a pony if this is a human. Don't be fooled, though. It doesn't.
|
||||||
|
*/
|
||||||
public PonyRace getEffectiveRace(PonyLevel level) {
|
public PonyRace getEffectiveRace(PonyLevel level) {
|
||||||
if (level == PonyLevel.HUMANS) return HUMAN;
|
if (level == PonyLevel.HUMANS) return HUMAN;
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -2,6 +2,10 @@ package com.minelittlepony.pony.data;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Individual trigger pixels for a pony skin.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public enum TriggerPixels {
|
public enum TriggerPixels {
|
||||||
RACE(PonyRace.HUMAN, 0, 0),
|
RACE(PonyRace.HUMAN, 0, 0),
|
||||||
TAIL(TailLengths.FULL, 1, 0),
|
TAIL(TailLengths.FULL, 1, 0),
|
||||||
|
@ -19,10 +23,20 @@ public enum TriggerPixels {
|
||||||
this.y = y;
|
this.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads tis trigger pixel's value and returns the raw colour value.
|
||||||
|
* @param image Image to read
|
||||||
|
* @param mask Colour mask (0xffffff for rgb, -1 for rgba)
|
||||||
|
*/
|
||||||
public int readColor(BufferedImage image, int mask) {
|
public int readColor(BufferedImage image, int mask) {
|
||||||
return image.getRGB(x, y) & mask;
|
return image.getRGB(x, y) & mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads this trigger pixel's value and parses it to an Enum instance.
|
||||||
|
*
|
||||||
|
* @param image Image to read
|
||||||
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <T extends Enum<T> & ITriggerPixelMapped<T>> T readValue(BufferedImage image) {
|
public <T extends Enum<T> & ITriggerPixelMapped<T>> T readValue(BufferedImage image) {
|
||||||
return ITriggerPixelMapped.getByTriggerPixel((T)def, readColor(image, 0xffffff));
|
return ITriggerPixelMapped.getByTriggerPixel((T)def, readColor(image, 0xffffff));
|
||||||
|
|
|
@ -16,7 +16,7 @@ public class LayerPonyStrayOverlay extends LayerOverlayBase<EntityStray> {
|
||||||
public LayerPonyStrayOverlay(RenderLivingBase<?> render) {
|
public LayerPonyStrayOverlay(RenderLivingBase<?> render) {
|
||||||
super(render);
|
super(render);
|
||||||
this.overlayModel = new ModelSkeletonPony();
|
this.overlayModel = new ModelSkeletonPony();
|
||||||
this.overlayModel.init(0F, 0.25F);
|
this.overlayModel.init(0, 0.25F);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue