mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-19 19:04:23 +01:00
Further decouple client/common code
This commit is contained in:
parent
0cba35ec89
commit
edc70b302e
20 changed files with 200 additions and 121 deletions
|
@ -16,6 +16,8 @@ import java.io.File;
|
||||||
|
|
||||||
public class LiteModMineLittlePony implements InitCompleteListener, Tickable, Configurable {
|
public class LiteModMineLittlePony implements InitCompleteListener, Tickable, Configurable {
|
||||||
|
|
||||||
|
private final MineLPClient mlp = new MineLPClient();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return MineLittlePony.MOD_NAME;
|
return MineLittlePony.MOD_NAME;
|
||||||
|
@ -34,20 +36,20 @@ public class LiteModMineLittlePony implements InitCompleteListener, Tickable, Co
|
||||||
public void init(File configPath) {
|
public void init(File configPath) {
|
||||||
Config config = new Config();
|
Config config = new Config();
|
||||||
|
|
||||||
MineLittlePony.getInstance().init(config);
|
mlp.init(config);
|
||||||
|
|
||||||
LiteLoader.getInput().registerKeyBinding(MineLittlePony.SETTINGS_GUI);
|
LiteLoader.getInput().registerKeyBinding(MineLPClient.SETTINGS_GUI);
|
||||||
LiteLoader.getInstance().registerExposable(config, null);
|
LiteLoader.getInstance().registerExposable(config, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitCompleted(Minecraft minecraft, LiteLoader loader) {
|
public void onInitCompleted(Minecraft minecraft, LiteLoader loader) {
|
||||||
MineLittlePony.getInstance().postInit(minecraft);
|
mlp.postInit(minecraft);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTick(Minecraft minecraft, float partialTicks, boolean inGame, boolean clock) {
|
public void onTick(Minecraft minecraft, float partialTicks, boolean inGame, boolean clock) {
|
||||||
MineLittlePony.getInstance().onTick(minecraft, inGame);
|
mlp.onTick(minecraft, inGame);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -21,19 +21,12 @@ import net.minecraft.util.text.TextComponentString;
|
||||||
import net.minecraft.util.text.TextComponentTranslation;
|
import net.minecraft.util.text.TextComponentTranslation;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.util.text.TextFormatting;
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Static MineLittlePony singleton class. Everything's controlled from up here.
|
* Static MineLittlePony singleton class. Everything's controlled from up here.
|
||||||
*/
|
*/
|
||||||
public class MineLittlePony {
|
public class MineLPClient extends MineLittlePony {
|
||||||
|
|
||||||
public static final Logger logger = LogManager.getLogger("MineLittlePony");
|
|
||||||
|
|
||||||
public static final String MOD_NAME = "Mine Little Pony";
|
|
||||||
public static final String MOD_VERSION = "@VERSION@";
|
|
||||||
|
|
||||||
private static final String MINELP_VALHALLA_SERVER = "http://skins.minelittlepony-mod.com";
|
private static final String MINELP_VALHALLA_SERVER = "http://skins.minelittlepony-mod.com";
|
||||||
private static final String MINELP_LEGACY_SERVER = "http://minelpskins.voxelmodpack.com";
|
private static final String MINELP_LEGACY_SERVER = "http://minelpskins.voxelmodpack.com";
|
||||||
|
@ -41,15 +34,13 @@ public class MineLittlePony {
|
||||||
|
|
||||||
static final KeyBinding SETTINGS_GUI = new KeyBinding("Settings", Keyboard.KEY_F9, "Mine Little Pony");
|
static final KeyBinding SETTINGS_GUI = new KeyBinding("Settings", Keyboard.KEY_F9, "Mine Little Pony");
|
||||||
|
|
||||||
private static final MineLittlePony instance = new MineLittlePony();
|
|
||||||
|
|
||||||
private static int modelUpdateCounter = 0;
|
private static int modelUpdateCounter = 0;
|
||||||
private static boolean reloadingModels = false;
|
private static boolean reloadingModels = false;
|
||||||
|
|
||||||
private PonyConfig config;
|
private PonyConfig config;
|
||||||
private PonyManager ponyManager;
|
private PonyManager ponyManager;
|
||||||
|
|
||||||
private final PonyRenderManager renderManager = new PonyRenderManager();
|
private final PonyRenderManager renderManager = PonyRenderManager.getInstance();
|
||||||
|
|
||||||
void init(PonyConfig newConfig) {
|
void init(PonyConfig newConfig) {
|
||||||
config = newConfig;
|
config = newConfig;
|
||||||
|
@ -82,6 +73,7 @@ public class MineLittlePony {
|
||||||
manager.setSkinsGui(GuiSkinsMineLP::new);
|
manager.setSkinsGui(GuiSkinsMineLP::new);
|
||||||
|
|
||||||
RenderManager rm = minecraft.getRenderManager();
|
RenderManager rm = minecraft.getRenderManager();
|
||||||
|
|
||||||
renderManager.initialisePlayerRenderers(rm);
|
renderManager.initialisePlayerRenderers(rm);
|
||||||
renderManager.initializeMobRenderers(rm, config);
|
renderManager.initializeMobRenderers(rm, config);
|
||||||
}
|
}
|
||||||
|
@ -115,36 +107,21 @@ public class MineLittlePony {
|
||||||
PonySkullRenderer.resolve();
|
PonySkullRenderer.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
/**
|
|
||||||
* Gets the global MineLP instance.
|
|
||||||
*/
|
|
||||||
public static MineLittlePony getInstance() {
|
|
||||||
return MineLittlePony.instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the static pony manager instance.
|
|
||||||
*/
|
|
||||||
public PonyManager getManager() {
|
public PonyManager getManager() {
|
||||||
return ponyManager;
|
return ponyManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Gets the static pony render manager responsible for all entity renderers.
|
public int getModelRevisionNumber() {
|
||||||
*/
|
|
||||||
public PonyRenderManager getRenderManager() {
|
|
||||||
return renderManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getModelRevisionNumber() {
|
|
||||||
return modelUpdateCounter;
|
return modelUpdateCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the global MineLP client configuration.
|
* Gets the global MineLP client configuration.
|
||||||
*/
|
*/
|
||||||
public static PonyConfig getConfig() {
|
@Override
|
||||||
return getInstance().config;
|
public PonyConfig getConfig() {
|
||||||
|
return config;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -28,6 +28,15 @@ import net.minecraft.entity.EntityLivingBase;
|
||||||
*/
|
*/
|
||||||
public class PonyRenderManager {
|
public class PonyRenderManager {
|
||||||
|
|
||||||
|
private static final PonyRenderManager renderManager = new PonyRenderManager();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the static pony render manager responsible for all entity renderers.
|
||||||
|
*/
|
||||||
|
public static PonyRenderManager getInstance() {
|
||||||
|
return renderManager;
|
||||||
|
}
|
||||||
|
|
||||||
private LevitatingItemRenderer magicRenderer = new LevitatingItemRenderer();
|
private LevitatingItemRenderer magicRenderer = new LevitatingItemRenderer();
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class GuiPonySettings extends SettingsPanel {
|
||||||
private PonyConfig config;
|
private PonyConfig config;
|
||||||
|
|
||||||
public GuiPonySettings() {
|
public GuiPonySettings() {
|
||||||
config = MineLittlePony.getConfig();
|
config = MineLittlePony.getInstance().getConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.minelittlepony.hdskins.gui;
|
||||||
import com.minelittlepony.MineLittlePony;
|
import com.minelittlepony.MineLittlePony;
|
||||||
import com.minelittlepony.gui.IconicToggle;
|
import com.minelittlepony.gui.IconicToggle;
|
||||||
import com.minelittlepony.gui.Style;
|
import com.minelittlepony.gui.Style;
|
||||||
import com.minelittlepony.pony.data.PonyManager;
|
import com.minelittlepony.pony.data.IPonyManager;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||||
|
@ -23,7 +23,7 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public class GuiSkinsMineLP extends GuiSkins {
|
public class GuiSkinsMineLP extends GuiSkins {
|
||||||
|
|
||||||
private PonyManager ponyManager = MineLittlePony.getInstance().getManager();
|
private IPonyManager ponyManager = MineLittlePony.getInstance().getManager();
|
||||||
|
|
||||||
private boolean isWet = false;
|
private boolean isWet = false;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package com.minelittlepony.mixin;
|
package com.minelittlepony.mixin;
|
||||||
|
|
||||||
import com.minelittlepony.MineLittlePony;
|
import com.minelittlepony.MineLittlePony;
|
||||||
|
import com.minelittlepony.pony.data.IPonyManager;
|
||||||
import com.minelittlepony.pony.data.PonyLevel;
|
import com.minelittlepony.pony.data.PonyLevel;
|
||||||
import com.minelittlepony.pony.data.PonyManager;
|
|
||||||
|
|
||||||
import net.minecraft.client.resources.DefaultPlayerSkin;
|
import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
@ -18,27 +18,27 @@ public abstract class MixinDefaultPlayerSkin {
|
||||||
|
|
||||||
@Inject(method = "getDefaultSkinLegacy", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "getDefaultSkinLegacy", at = @At("HEAD"), cancellable = true)
|
||||||
private static void legacySkin(CallbackInfoReturnable<ResourceLocation> cir) {
|
private static void legacySkin(CallbackInfoReturnable<ResourceLocation> cir) {
|
||||||
if (MineLittlePony.getConfig().getPonyLevel() == PonyLevel.PONIES) {
|
if (MineLittlePony.getInstance().getConfig().getPonyLevel() == PonyLevel.PONIES) {
|
||||||
cir.setReturnValue(PonyManager.STEVE);
|
cir.setReturnValue(IPonyManager.STEVE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "getDefaultSkin", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "getDefaultSkin", at = @At("HEAD"), cancellable = true)
|
||||||
private static void defaultSkin(UUID uuid, CallbackInfoReturnable<ResourceLocation> cir) {
|
private static void defaultSkin(UUID uuid, CallbackInfoReturnable<ResourceLocation> cir) {
|
||||||
if (MineLittlePony.getConfig().getPonyLevel() == PonyLevel.PONIES) {
|
if (MineLittlePony.getInstance().getConfig().getPonyLevel() == PonyLevel.PONIES) {
|
||||||
cir.setReturnValue(PonyManager.getDefaultSkin(uuid));
|
cir.setReturnValue(IPonyManager.getDefaultSkin(uuid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "getSkinType", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "getSkinType", at = @At("HEAD"), cancellable = true)
|
||||||
private static void skinType(UUID uuid, CallbackInfoReturnable<String> cir) {
|
private static void skinType(UUID uuid, CallbackInfoReturnable<String> cir) {
|
||||||
if (MineLittlePony.getConfig().getPonyLevel() == PonyLevel.PONIES) {
|
if (MineLittlePony.getInstance().getConfig().getPonyLevel() == PonyLevel.PONIES) {
|
||||||
|
|
||||||
cir.setReturnValue(MineLittlePony.getInstance().getManager()
|
cir.setReturnValue(MineLittlePony.getInstance().getManager()
|
||||||
.getPony(PonyManager.getDefaultSkin(uuid), uuid)
|
.getPony(IPonyManager.getDefaultSkin(uuid), uuid)
|
||||||
.getRace(false)
|
.getRace(false)
|
||||||
.getModel()
|
.getModel()
|
||||||
.getId(PonyManager.isSlimSkin(uuid)));
|
.getId(IPonyManager.isSlimSkin(uuid)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
import com.minelittlepony.MineLittlePony;
|
import com.minelittlepony.PonyRenderManager;
|
||||||
|
|
||||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||||
import net.minecraft.client.renderer.ItemRenderer;
|
import net.minecraft.client.renderer.ItemRenderer;
|
||||||
|
@ -27,6 +27,6 @@ public class MixinItemRenderer {
|
||||||
at = @At(value = "INVOKE",
|
at = @At(value = "INVOKE",
|
||||||
target = "Lnet/minecraft/client/renderer/ItemRenderer;renderItemSide(" + EntityLivingBase + ItemStack + TransformType + "Z)V"))
|
target = "Lnet/minecraft/client/renderer/ItemRenderer;renderItemSide(" + EntityLivingBase + ItemStack + TransformType + "Z)V"))
|
||||||
private void redirectRenderItemSide(ItemRenderer self, EntityLivingBase entity, ItemStack stack, TransformType transform, boolean left) {
|
private void redirectRenderItemSide(ItemRenderer self, EntityLivingBase entity, ItemStack stack, TransformType transform, boolean left) {
|
||||||
MineLittlePony.getInstance().getRenderManager().getMagicRenderer().renderItemInFirstPerson(self, (AbstractClientPlayer)entity, stack, transform, left);
|
PonyRenderManager.getInstance().getMagicRenderer().renderItemInFirstPerson(self, (AbstractClientPlayer)entity, stack, transform, left);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class ModelWrapper implements IModelWrapper {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply(IPonyData meta) {
|
public void apply(IPonyData meta) {
|
||||||
int modelRevision = MineLittlePony.getModelRevisionNumber();
|
int modelRevision = MineLittlePony.getInstance().getModelRevisionNumber();
|
||||||
|
|
||||||
if (modelRevision != lastModelUpdate) {
|
if (modelRevision != lastModelUpdate) {
|
||||||
lastModelUpdate = modelRevision;
|
lastModelUpdate = modelRevision;
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class PonySnout {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGender(PonyGender gender) {
|
public void setGender(PonyGender gender) {
|
||||||
boolean show = !head.hasHeadGear() && !isHidden && MineLittlePony.getConfig().snuzzles;
|
boolean show = !head.hasHeadGear() && !isHidden && MineLittlePony.getInstance().getConfig().snuzzles;
|
||||||
|
|
||||||
mare.isHidden = !(show && gender.isMare());
|
mare.isHidden = !(show && gender.isMare());
|
||||||
stallion.isHidden = !(show && gender.isStallion());
|
stallion.isHidden = !(show && gender.isStallion());
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.minelittlepony.pony.data;
|
||||||
|
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
import com.minelittlepony.MineLittlePony;
|
import com.minelittlepony.MineLittlePony;
|
||||||
|
import com.minelittlepony.PonyRenderManager;
|
||||||
import com.minelittlepony.ducks.IRenderPony;
|
import com.minelittlepony.ducks.IRenderPony;
|
||||||
import com.minelittlepony.util.chron.Touchable;
|
import com.minelittlepony.util.chron.Touchable;
|
||||||
import com.voxelmodpack.hdskins.resources.texture.DynamicTextureImage;
|
import com.voxelmodpack.hdskins.resources.texture.DynamicTextureImage;
|
||||||
|
@ -190,14 +191,14 @@ public class Pony extends Touchable<Pony> implements IPony {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRidingInteractive(EntityLivingBase entity) {
|
public boolean isRidingInteractive(EntityLivingBase entity) {
|
||||||
return MineLittlePony.getInstance().getRenderManager().getPonyRenderer(entity.getRidingEntity()) != null;
|
return PonyRenderManager.getInstance().getPonyRenderer(entity.getRidingEntity()) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPony getMountedPony(EntityLivingBase entity) {
|
public IPony getMountedPony(EntityLivingBase entity) {
|
||||||
Entity mount = entity.getRidingEntity();
|
Entity mount = entity.getRidingEntity();
|
||||||
|
|
||||||
IRenderPony<EntityLivingBase> render = MineLittlePony.getInstance().getRenderManager().getPonyRenderer(mount);
|
IRenderPony<EntityLivingBase> render = PonyRenderManager.getInstance().getPonyRenderer(mount);
|
||||||
|
|
||||||
return render == null ? null : render.getEntityPony((EntityLivingBase)mount);
|
return render == null ? null : render.getEntityPony((EntityLivingBase)mount);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,8 @@ import com.minelittlepony.util.math.MathUtil;
|
||||||
import com.voxelmodpack.hdskins.ISkinCacheClearListener;
|
import com.voxelmodpack.hdskins.ISkinCacheClearListener;
|
||||||
import com.voxelmodpack.hdskins.util.MoreStreams;
|
import com.voxelmodpack.hdskins.util.MoreStreams;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||||
import net.minecraft.client.network.NetworkPlayerInfo;
|
import net.minecraft.client.network.NetworkPlayerInfo;
|
||||||
|
@ -17,6 +19,7 @@ import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||||
import net.minecraft.client.resources.IResource;
|
import net.minecraft.client.resources.IResource;
|
||||||
import net.minecraft.client.resources.IResourceManager;
|
import net.minecraft.client.resources.IResourceManager;
|
||||||
import net.minecraft.client.resources.IResourceManagerReloadListener;
|
import net.minecraft.client.resources.IResourceManagerReloadListener;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -32,12 +35,7 @@ import java.util.UUID;
|
||||||
* The PonyManager is responsible for reading and recoding all the pony data associated with an entity of skin.
|
* The PonyManager is responsible for reading and recoding all the pony data associated with an entity of skin.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class PonyManager implements IResourceManagerReloadListener, ISkinCacheClearListener {
|
public class PonyManager implements IPonyManager, IResourceManagerReloadListener, ISkinCacheClearListener {
|
||||||
|
|
||||||
public static final ResourceLocation STEVE = new ResourceLocation("minelittlepony", "textures/entity/steve_pony.png");
|
|
||||||
public static final ResourceLocation ALEX = new ResourceLocation("minelittlepony", "textures/entity/alex_pony.png");
|
|
||||||
|
|
||||||
public static final String BGPONIES_JSON = "textures/entity/pony/bgponies.json";
|
|
||||||
|
|
||||||
private static final Gson GSON = new Gson();
|
private static final Gson GSON = new Gson();
|
||||||
|
|
||||||
|
@ -54,23 +52,14 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl
|
||||||
this.config = config;
|
this.config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Gets or creates a pony for the given skin resource and vanilla model type.
|
|
||||||
*
|
|
||||||
* @param resource A texture resource
|
|
||||||
*/
|
|
||||||
public IPony getPony(ResourceLocation resource) {
|
public IPony getPony(ResourceLocation resource) {
|
||||||
return poniesCache.retrieve(resource, Pony::new);
|
return poniesCache.retrieve(resource, Pony::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Gets or creates a pony for the given player.
|
public IPony getPony(EntityPlayer player) {
|
||||||
* Delegates to the background-ponies registry if no pony skins were available and client settings allows it.
|
ResourceLocation skin = getSkin(player);
|
||||||
*
|
|
||||||
* @param player the player
|
|
||||||
*/
|
|
||||||
public IPony getPony(AbstractClientPlayer player) {
|
|
||||||
ResourceLocation skin = player.getLocationSkin();
|
|
||||||
UUID uuid = player.getGameProfile().getId();
|
UUID uuid = player.getGameProfile().getId();
|
||||||
|
|
||||||
if (Pony.getBufferedImage(skin) == null) {
|
if (Pony.getBufferedImage(skin) == null) {
|
||||||
|
@ -80,6 +69,15 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl
|
||||||
return getPony(skin, uuid);
|
return getPony(skin, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
ResourceLocation getSkin(EntityPlayer player) {
|
||||||
|
if (player instanceof AbstractClientPlayer) {
|
||||||
|
return ((AbstractClientPlayer)player).getLocationSkin();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public IPony getPony(NetworkPlayerInfo playerInfo) {
|
public IPony getPony(NetworkPlayerInfo playerInfo) {
|
||||||
ResourceLocation skin = playerInfo.getLocationSkin();
|
ResourceLocation skin = playerInfo.getLocationSkin();
|
||||||
UUID uuid = playerInfo.getGameProfile().getId();
|
UUID uuid = playerInfo.getGameProfile().getId();
|
||||||
|
@ -91,16 +89,7 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl
|
||||||
return getPony(skin, uuid);
|
return getPony(skin, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* 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 IPony getPony(ResourceLocation resource, UUID uuid) {
|
public IPony getPony(ResourceLocation resource, UUID uuid) {
|
||||||
IPony pony = getPony(resource);
|
IPony pony = getPony(resource);
|
||||||
|
|
||||||
|
@ -111,11 +100,7 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl
|
||||||
return pony;
|
return pony;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Gets the default pony. Either STEVE/ALEX, or a background pony based on client settings.
|
|
||||||
*
|
|
||||||
* @param uuid id of a player or entity
|
|
||||||
*/
|
|
||||||
public IPony getDefaultPony(UUID uuid) {
|
public IPony getDefaultPony(UUID uuid) {
|
||||||
if (config.getPonyLevel() != PonyLevel.PONIES) {
|
if (config.getPonyLevel() != PonyLevel.PONIES) {
|
||||||
return getPony(DefaultPlayerSkin.getDefaultSkin(uuid));
|
return getPony(DefaultPlayerSkin.getDefaultSkin(uuid));
|
||||||
|
@ -124,16 +109,10 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl
|
||||||
return getBackgroundPony(uuid);
|
return getBackgroundPony(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Gets a random background pony determined by the given uuid.
|
|
||||||
*
|
|
||||||
* Useful for mods that offer customisation, especially ones that have a whole lot of NPCs.
|
|
||||||
*
|
|
||||||
* @param uuid A UUID. Either a user or an entity.
|
|
||||||
*/
|
|
||||||
public IPony getBackgroundPony(UUID uuid) {
|
public IPony getBackgroundPony(UUID uuid) {
|
||||||
if (getNumberOfPonies() == 0 || isUser(uuid)) {
|
if (getNumberOfPonies() == 0 || isUser(uuid)) {
|
||||||
return getPony(getDefaultSkin(uuid));
|
return getPony(IPonyManager.getDefaultSkin(uuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
int bgi = MathUtil.mod(uuid.hashCode(), getNumberOfPonies());
|
int bgi = MathUtil.mod(uuid.hashCode(), getNumberOfPonies());
|
||||||
|
@ -145,9 +124,7 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl
|
||||||
return Minecraft.getMinecraft().player != null && Minecraft.getMinecraft().player.getUniqueID().equals(uuid);
|
return Minecraft.getMinecraft().player != null && Minecraft.getMinecraft().player.getUniqueID().equals(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* De-registers a pony from the cache.
|
|
||||||
*/
|
|
||||||
public IPony removePony(ResourceLocation resource) {
|
public IPony removePony(ResourceLocation resource) {
|
||||||
return poniesCache.remove(resource);
|
return poniesCache.remove(resource);
|
||||||
}
|
}
|
||||||
|
@ -216,17 +193,6 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl
|
||||||
return collectedPonies;
|
return collectedPonies;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ResourceLocation getDefaultSkin(UUID uuid) {
|
|
||||||
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) {
|
|
||||||
return (uuid.hashCode() & 1) == 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getNumberOfPonies() {
|
private int getNumberOfPonies() {
|
||||||
return backgroundPonyList.size();
|
return backgroundPonyList.size();
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,10 @@ public enum PonyRace implements ITriggerPixelMapped<PonyRace> {
|
||||||
* PonyLevel.PONIES (should) return a pony if this is a human. Don't be fooled, though. It doesn't.
|
* PonyLevel.PONIES (should) return a pony if this is a human. Don't be fooled, though. It doesn't.
|
||||||
*/
|
*/
|
||||||
public PonyRace getEffectiveRace(boolean ignorePony) {
|
public PonyRace getEffectiveRace(boolean ignorePony) {
|
||||||
if (MineLittlePony.getConfig().getEffectivePonyLevel(ignorePony) == PonyLevel.HUMANS) return HUMAN;
|
if (MineLittlePony.getInstance().getConfig().getEffectivePonyLevel(ignorePony) == PonyLevel.HUMANS) {
|
||||||
|
return HUMAN;
|
||||||
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class LevitatingItemRenderer {
|
||||||
|
|
||||||
pushMatrix();
|
pushMatrix();
|
||||||
|
|
||||||
boolean doMagic = MineLittlePony.getConfig().fpsmagic && pony.getMetadata().hasMagic();
|
boolean doMagic = MineLittlePony.getInstance().getConfig().fpsmagic && pony.getMetadata().hasMagic();
|
||||||
|
|
||||||
if (doMagic) {
|
if (doMagic) {
|
||||||
setupPerspective(entity, stack, left);
|
setupPerspective(entity, stack, left);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.minelittlepony.render;
|
package com.minelittlepony.render;
|
||||||
|
|
||||||
import com.minelittlepony.MineLittlePony;
|
import com.minelittlepony.MineLittlePony;
|
||||||
|
import com.minelittlepony.PonyRenderManager;
|
||||||
import com.minelittlepony.ducks.IRenderPony;
|
import com.minelittlepony.ducks.IRenderPony;
|
||||||
import com.minelittlepony.model.AbstractPonyModel;
|
import com.minelittlepony.model.AbstractPonyModel;
|
||||||
import com.minelittlepony.model.ModelWrapper;
|
import com.minelittlepony.model.ModelWrapper;
|
||||||
|
@ -40,7 +41,7 @@ public class RenderPony<T extends EntityLivingBase> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICamera getFrustrum(T entity, ICamera vanilla) {
|
public ICamera getFrustrum(T entity, ICamera vanilla) {
|
||||||
if (entity.isPlayerSleeping() || !MineLittlePony.getConfig().frustrum) {
|
if (entity.isPlayerSleeping() || !MineLittlePony.getInstance().getConfig().frustrum) {
|
||||||
return vanilla;
|
return vanilla;
|
||||||
}
|
}
|
||||||
return frustrum.withCamera(entity, vanilla);
|
return frustrum.withCamera(entity, vanilla);
|
||||||
|
@ -74,7 +75,7 @@ public class RenderPony<T extends EntityLivingBase> {
|
||||||
Entity ridingEntity = entity.getRidingEntity();
|
Entity ridingEntity = entity.getRidingEntity();
|
||||||
|
|
||||||
if (ridingEntity instanceof EntityLivingBase) {
|
if (ridingEntity instanceof EntityLivingBase) {
|
||||||
IRenderPony<EntityLivingBase> renderer = MineLittlePony.getInstance().getRenderManager().getPonyRenderer((EntityLivingBase)ridingEntity);
|
IRenderPony<EntityLivingBase> renderer = PonyRenderManager.getInstance().getPonyRenderer((EntityLivingBase)ridingEntity);
|
||||||
|
|
||||||
if (renderer != null) {
|
if (renderer != null) {
|
||||||
// negate vanilla translations so the rider begins at the ridees feet.
|
// negate vanilla translations so the rider begins at the ridees feet.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.minelittlepony.render.layer;
|
package com.minelittlepony.render.layer;
|
||||||
|
|
||||||
import com.minelittlepony.MineLittlePony;
|
import com.minelittlepony.PonyRenderManager;
|
||||||
import com.minelittlepony.model.capabilities.IModelUnicorn;
|
import com.minelittlepony.model.capabilities.IModelUnicorn;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||||
|
@ -31,7 +31,7 @@ public class LayerHeldPonyItemMagical<T extends EntityLivingBase> extends LayerH
|
||||||
@Override
|
@Override
|
||||||
protected void postItemRender(T entity, ItemStack drop, TransformType transform, EnumHandSide hand) {
|
protected void postItemRender(T entity, ItemStack drop, TransformType transform, EnumHandSide hand) {
|
||||||
if (isUnicorn()) {
|
if (isUnicorn()) {
|
||||||
MineLittlePony.getInstance().getRenderManager().getMagicRenderer().renderItemGlow(entity, drop, transform, hand, this.<IModelUnicorn>getPonyModel().getMagicColor());
|
PonyRenderManager.getInstance().getMagicRenderer().renderItemGlow(entity, drop, transform, hand, this.<IModelUnicorn>getPonyModel().getMagicColor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ public enum MobRenderers implements Setting {
|
||||||
@Override
|
@Override
|
||||||
public void set(boolean value) {
|
public void set(boolean value) {
|
||||||
Setting.super.set(value);
|
Setting.super.set(value);
|
||||||
apply(MineLittlePony.getInstance().getRenderManager(), Minecraft.getMinecraft().getRenderManager());
|
apply(PonyRenderManager.getInstance(), Minecraft.getMinecraft().getRenderManager());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void apply(PonyRenderManager pony, RenderManager manager) {
|
public void apply(PonyRenderManager pony, RenderManager manager) {
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class PonySkullRenderer extends TileEntitySkullRenderer implements IRende
|
||||||
* Original/Existing renderer is stored to a backup variable as a fallback in case of mods.
|
* Original/Existing renderer is stored to a backup variable as a fallback in case of mods.
|
||||||
*/
|
*/
|
||||||
public static TileEntitySkullRenderer resolve() {
|
public static TileEntitySkullRenderer resolve() {
|
||||||
if (MineLittlePony.getConfig().ponyskulls) {
|
if (MineLittlePony.getInstance().getConfig().ponyskulls) {
|
||||||
if (!(instance instanceof PonySkullRenderer)) {
|
if (!(instance instanceof PonySkullRenderer)) {
|
||||||
backup = instance;
|
backup = instance;
|
||||||
ModUtilities.addRenderer(TileEntitySkull.class, ponyInstance);
|
ModUtilities.addRenderer(TileEntitySkull.class, ponyInstance);
|
||||||
|
@ -75,7 +75,7 @@ public class PonySkullRenderer extends TileEntitySkullRenderer implements IRende
|
||||||
|
|
||||||
ISkull skull = skullMap.get(skullType);
|
ISkull skull = skullMap.get(skullType);
|
||||||
|
|
||||||
if (skull == null || !skull.canRender(MineLittlePony.getConfig())) {
|
if (skull == null || !skull.canRender(MineLittlePony.getInstance().getConfig())) {
|
||||||
if (backup != null) {
|
if (backup != null) {
|
||||||
backup.renderSkull(x, y, z, facing, rotation, skullType, profile, destroyStage, animateTicks);
|
backup.renderSkull(x, y, z, facing, rotation, skullType, profile, destroyStage, animateTicks);
|
||||||
} else {
|
} else {
|
||||||
|
|
43
src/common/java/com/minelittlepony/MineLittlePony.java
Normal file
43
src/common/java/com/minelittlepony/MineLittlePony.java
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
package com.minelittlepony;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import com.minelittlepony.pony.data.IPonyManager;
|
||||||
|
|
||||||
|
public abstract class MineLittlePony {
|
||||||
|
|
||||||
|
private static MineLittlePony instance;
|
||||||
|
|
||||||
|
public static final Logger logger = LogManager.getLogger("MineLittlePony");
|
||||||
|
|
||||||
|
public static final String MOD_NAME = "Mine Little Pony";
|
||||||
|
public static final String MOD_VERSION = "@VERSION@";
|
||||||
|
|
||||||
|
MineLittlePony() {
|
||||||
|
instance = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the global MineLP instance.
|
||||||
|
*/
|
||||||
|
public static MineLittlePony getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the global MineLP client configuration.
|
||||||
|
*/
|
||||||
|
public abstract PonyConfig getConfig();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the static pony manager instance.
|
||||||
|
*/
|
||||||
|
public abstract IPonyManager getManager();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the global revision number, used for reloading models on demand.
|
||||||
|
*/
|
||||||
|
public abstract int getModelRevisionNumber();
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
package com.minelittlepony.pony.data;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The PonyManager is responsible for reading and recoding all the pony data associated with an entity of skin.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface IPonyManager {
|
||||||
|
|
||||||
|
public static final ResourceLocation STEVE = new ResourceLocation("minelittlepony", "textures/entity/steve_pony.png");
|
||||||
|
public static final ResourceLocation ALEX = new ResourceLocation("minelittlepony", "textures/entity/alex_pony.png");
|
||||||
|
|
||||||
|
public static final String BGPONIES_JSON = "textures/entity/pony/bgponies.json";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 IPony getPony(EntityPlayer player);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets or creates a pony for the given skin resource and vanilla model type.
|
||||||
|
*
|
||||||
|
* @param resource A texture resource
|
||||||
|
*/
|
||||||
|
public IPony getPony(ResourceLocation resource);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
IPony getPony(ResourceLocation resource, UUID uuid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the default pony. Either STEVE/ALEX, or a background pony based on client settings.
|
||||||
|
*
|
||||||
|
* @param uuid id of a player or entity
|
||||||
|
*/
|
||||||
|
IPony getDefaultPony(UUID uuid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a random background pony determined by the given uuid.
|
||||||
|
*
|
||||||
|
* Useful for mods that offer customisation, especially ones that have a whole lot of NPCs.
|
||||||
|
*
|
||||||
|
* @param uuid A UUID. Either a user or an entity.
|
||||||
|
*/
|
||||||
|
IPony getBackgroundPony(UUID uuid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* De-registers a pony from the cache.
|
||||||
|
*/
|
||||||
|
IPony removePony(ResourceLocation resource);
|
||||||
|
|
||||||
|
public static ResourceLocation getDefaultSkin(UUID uuid) {
|
||||||
|
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) {
|
||||||
|
return (uuid.hashCode() & 1) == 1;
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,11 +26,11 @@ public enum PonySize implements ITriggerPixelMapped<PonySize> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getShadowSize() {
|
public float getShadowSize() {
|
||||||
return shadowSize * MineLittlePony.getConfig().getGlobalScaleFactor();
|
return shadowSize * MineLittlePony.getInstance().getConfig().getGlobalScaleFactor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getScaleFactor() {
|
public float getScaleFactor() {
|
||||||
return scale * MineLittlePony.getConfig().getGlobalScaleFactor();
|
return scale * MineLittlePony.getInstance().getConfig().getGlobalScaleFactor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PonyTransformation getTranformation() {
|
public PonyTransformation getTranformation() {
|
||||||
|
@ -43,6 +43,6 @@ public enum PonySize implements ITriggerPixelMapped<PonySize> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PonySize getEffectiveSize() {
|
public PonySize getEffectiveSize() {
|
||||||
return MineLittlePony.getConfig().sizes ? this : PonySize.NORMAL;
|
return MineLittlePony.getInstance().getConfig().sizes ? this : PonySize.NORMAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue