mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-22 04:27:59 +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 {
|
||||
|
||||
private final MineLPClient mlp = new MineLPClient();
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MineLittlePony.MOD_NAME;
|
||||
|
@ -34,20 +36,20 @@ public class LiteModMineLittlePony implements InitCompleteListener, Tickable, Co
|
|||
public void init(File configPath) {
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitCompleted(Minecraft minecraft, LiteLoader loader) {
|
||||
MineLittlePony.getInstance().postInit(minecraft);
|
||||
mlp.postInit(minecraft);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick(Minecraft minecraft, float partialTicks, boolean inGame, boolean clock) {
|
||||
MineLittlePony.getInstance().onTick(minecraft, inGame);
|
||||
mlp.onTick(minecraft, inGame);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,19 +21,12 @@ import net.minecraft.util.text.TextComponentString;
|
|||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
/**
|
||||
* Static MineLittlePony singleton class. Everything's controlled from up here.
|
||||
*/
|
||||
public class 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@";
|
||||
public class MineLPClient extends MineLittlePony {
|
||||
|
||||
private static final String MINELP_VALHALLA_SERVER = "http://skins.minelittlepony-mod.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");
|
||||
|
||||
private static final MineLittlePony instance = new MineLittlePony();
|
||||
|
||||
private static int modelUpdateCounter = 0;
|
||||
private static boolean reloadingModels = false;
|
||||
|
||||
private PonyConfig config;
|
||||
private PonyManager ponyManager;
|
||||
|
||||
private final PonyRenderManager renderManager = new PonyRenderManager();
|
||||
private final PonyRenderManager renderManager = PonyRenderManager.getInstance();
|
||||
|
||||
void init(PonyConfig newConfig) {
|
||||
config = newConfig;
|
||||
|
@ -82,6 +73,7 @@ public class MineLittlePony {
|
|||
manager.setSkinsGui(GuiSkinsMineLP::new);
|
||||
|
||||
RenderManager rm = minecraft.getRenderManager();
|
||||
|
||||
renderManager.initialisePlayerRenderers(rm);
|
||||
renderManager.initializeMobRenderers(rm, config);
|
||||
}
|
||||
|
@ -115,36 +107,21 @@ public class MineLittlePony {
|
|||
PonySkullRenderer.resolve();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the global MineLP instance.
|
||||
*/
|
||||
public static MineLittlePony getInstance() {
|
||||
return MineLittlePony.instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the static pony manager instance.
|
||||
*/
|
||||
@Override
|
||||
public PonyManager getManager() {
|
||||
return ponyManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the static pony render manager responsible for all entity renderers.
|
||||
*/
|
||||
public PonyRenderManager getRenderManager() {
|
||||
return renderManager;
|
||||
}
|
||||
|
||||
public static int getModelRevisionNumber() {
|
||||
@Override
|
||||
public int getModelRevisionNumber() {
|
||||
return modelUpdateCounter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the global MineLP client configuration.
|
||||
*/
|
||||
public static PonyConfig getConfig() {
|
||||
return getInstance().config;
|
||||
@Override
|
||||
public PonyConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
}
|
|
@ -28,6 +28,15 @@ import net.minecraft.entity.EntityLivingBase;
|
|||
*/
|
||||
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();
|
||||
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ public class GuiPonySettings extends SettingsPanel {
|
|||
private PonyConfig config;
|
||||
|
||||
public GuiPonySettings() {
|
||||
config = MineLittlePony.getConfig();
|
||||
config = MineLittlePony.getInstance().getConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.minelittlepony.hdskins.gui;
|
|||
import com.minelittlepony.MineLittlePony;
|
||||
import com.minelittlepony.gui.IconicToggle;
|
||||
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.minecraft.MinecraftProfileTexture;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||
|
@ -23,7 +23,7 @@ import java.util.List;
|
|||
*/
|
||||
public class GuiSkinsMineLP extends GuiSkins {
|
||||
|
||||
private PonyManager ponyManager = MineLittlePony.getInstance().getManager();
|
||||
private IPonyManager ponyManager = MineLittlePony.getInstance().getManager();
|
||||
|
||||
private boolean isWet = false;
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.minelittlepony.mixin;
|
||||
|
||||
import com.minelittlepony.MineLittlePony;
|
||||
import com.minelittlepony.pony.data.IPonyManager;
|
||||
import com.minelittlepony.pony.data.PonyLevel;
|
||||
import com.minelittlepony.pony.data.PonyManager;
|
||||
|
||||
import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
@ -18,27 +18,27 @@ public abstract class MixinDefaultPlayerSkin {
|
|||
|
||||
@Inject(method = "getDefaultSkinLegacy", at = @At("HEAD"), cancellable = true)
|
||||
private static void legacySkin(CallbackInfoReturnable<ResourceLocation> cir) {
|
||||
if (MineLittlePony.getConfig().getPonyLevel() == PonyLevel.PONIES) {
|
||||
cir.setReturnValue(PonyManager.STEVE);
|
||||
if (MineLittlePony.getInstance().getConfig().getPonyLevel() == PonyLevel.PONIES) {
|
||||
cir.setReturnValue(IPonyManager.STEVE);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getDefaultSkin", at = @At("HEAD"), cancellable = true)
|
||||
private static void defaultSkin(UUID uuid, CallbackInfoReturnable<ResourceLocation> cir) {
|
||||
if (MineLittlePony.getConfig().getPonyLevel() == PonyLevel.PONIES) {
|
||||
cir.setReturnValue(PonyManager.getDefaultSkin(uuid));
|
||||
if (MineLittlePony.getInstance().getConfig().getPonyLevel() == PonyLevel.PONIES) {
|
||||
cir.setReturnValue(IPonyManager.getDefaultSkin(uuid));
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getSkinType", at = @At("HEAD"), cancellable = true)
|
||||
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()
|
||||
.getPony(PonyManager.getDefaultSkin(uuid), uuid)
|
||||
.getPony(IPonyManager.getDefaultSkin(uuid), uuid)
|
||||
.getRace(false)
|
||||
.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.Redirect;
|
||||
|
||||
import com.minelittlepony.MineLittlePony;
|
||||
import com.minelittlepony.PonyRenderManager;
|
||||
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
|
@ -27,6 +27,6 @@ public class MixinItemRenderer {
|
|||
at = @At(value = "INVOKE",
|
||||
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) {
|
||||
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
|
||||
public void apply(IPonyData meta) {
|
||||
int modelRevision = MineLittlePony.getModelRevisionNumber();
|
||||
int modelRevision = MineLittlePony.getInstance().getModelRevisionNumber();
|
||||
|
||||
if (modelRevision != lastModelUpdate) {
|
||||
lastModelUpdate = modelRevision;
|
||||
|
|
|
@ -59,7 +59,7 @@ public class PonySnout {
|
|||
}
|
||||
|
||||
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());
|
||||
stallion.isHidden = !(show && gender.isStallion());
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.minelittlepony.pony.data;
|
|||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.minelittlepony.MineLittlePony;
|
||||
import com.minelittlepony.PonyRenderManager;
|
||||
import com.minelittlepony.ducks.IRenderPony;
|
||||
import com.minelittlepony.util.chron.Touchable;
|
||||
import com.voxelmodpack.hdskins.resources.texture.DynamicTextureImage;
|
||||
|
@ -190,14 +191,14 @@ public class Pony extends Touchable<Pony> implements IPony {
|
|||
|
||||
@Override
|
||||
public boolean isRidingInteractive(EntityLivingBase entity) {
|
||||
return MineLittlePony.getInstance().getRenderManager().getPonyRenderer(entity.getRidingEntity()) != null;
|
||||
return PonyRenderManager.getInstance().getPonyRenderer(entity.getRidingEntity()) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPony getMountedPony(EntityLivingBase entity) {
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ import com.minelittlepony.util.math.MathUtil;
|
|||
import com.voxelmodpack.hdskins.ISkinCacheClearListener;
|
||||
import com.voxelmodpack.hdskins.util.MoreStreams;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
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.IResourceManager;
|
||||
import net.minecraft.client.resources.IResourceManagerReloadListener;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
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.
|
||||
*
|
||||
*/
|
||||
public class PonyManager implements 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";
|
||||
public class PonyManager implements IPonyManager, IResourceManagerReloadListener, ISkinCacheClearListener {
|
||||
|
||||
private static final Gson GSON = new Gson();
|
||||
|
||||
|
@ -54,23 +52,14 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl
|
|||
this.config = config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets or creates a pony for the given skin resource and vanilla model type.
|
||||
*
|
||||
* @param resource A texture resource
|
||||
*/
|
||||
@Override
|
||||
public IPony getPony(ResourceLocation resource) {
|
||||
return poniesCache.retrieve(resource, Pony::new);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(AbstractClientPlayer player) {
|
||||
ResourceLocation skin = player.getLocationSkin();
|
||||
@Override
|
||||
public IPony getPony(EntityPlayer player) {
|
||||
ResourceLocation skin = getSkin(player);
|
||||
UUID uuid = player.getGameProfile().getId();
|
||||
|
||||
if (Pony.getBufferedImage(skin) == null) {
|
||||
|
@ -80,6 +69,15 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl
|
|||
return getPony(skin, uuid);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
ResourceLocation getSkin(EntityPlayer player) {
|
||||
if (player instanceof AbstractClientPlayer) {
|
||||
return ((AbstractClientPlayer)player).getLocationSkin();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public IPony getPony(NetworkPlayerInfo playerInfo) {
|
||||
ResourceLocation skin = playerInfo.getLocationSkin();
|
||||
UUID uuid = playerInfo.getGameProfile().getId();
|
||||
|
@ -91,16 +89,7 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl
|
|||
return getPony(skin, uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
@Override
|
||||
public IPony getPony(ResourceLocation resource, UUID uuid) {
|
||||
IPony pony = getPony(resource);
|
||||
|
||||
|
@ -111,11 +100,7 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl
|
|||
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
|
||||
*/
|
||||
@Override
|
||||
public IPony getDefaultPony(UUID uuid) {
|
||||
if (config.getPonyLevel() != PonyLevel.PONIES) {
|
||||
return getPony(DefaultPlayerSkin.getDefaultSkin(uuid));
|
||||
|
@ -124,16 +109,10 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl
|
|||
return getBackgroundPony(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.
|
||||
*/
|
||||
@Override
|
||||
public IPony getBackgroundPony(UUID uuid) {
|
||||
if (getNumberOfPonies() == 0 || isUser(uuid)) {
|
||||
return getPony(getDefaultSkin(uuid));
|
||||
return getPony(IPonyManager.getDefaultSkin(uuid));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* De-registers a pony from the cache.
|
||||
*/
|
||||
@Override
|
||||
public IPony removePony(ResourceLocation resource) {
|
||||
return poniesCache.remove(resource);
|
||||
}
|
||||
|
@ -216,17 +193,6 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl
|
|||
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() {
|
||||
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.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ public class LevitatingItemRenderer {
|
|||
|
||||
pushMatrix();
|
||||
|
||||
boolean doMagic = MineLittlePony.getConfig().fpsmagic && pony.getMetadata().hasMagic();
|
||||
boolean doMagic = MineLittlePony.getInstance().getConfig().fpsmagic && pony.getMetadata().hasMagic();
|
||||
|
||||
if (doMagic) {
|
||||
setupPerspective(entity, stack, left);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.minelittlepony.render;
|
||||
|
||||
import com.minelittlepony.MineLittlePony;
|
||||
import com.minelittlepony.PonyRenderManager;
|
||||
import com.minelittlepony.ducks.IRenderPony;
|
||||
import com.minelittlepony.model.AbstractPonyModel;
|
||||
import com.minelittlepony.model.ModelWrapper;
|
||||
|
@ -40,7 +41,7 @@ public class RenderPony<T extends EntityLivingBase> {
|
|||
}
|
||||
|
||||
public ICamera getFrustrum(T entity, ICamera vanilla) {
|
||||
if (entity.isPlayerSleeping() || !MineLittlePony.getConfig().frustrum) {
|
||||
if (entity.isPlayerSleeping() || !MineLittlePony.getInstance().getConfig().frustrum) {
|
||||
return vanilla;
|
||||
}
|
||||
return frustrum.withCamera(entity, vanilla);
|
||||
|
@ -74,7 +75,7 @@ public class RenderPony<T extends EntityLivingBase> {
|
|||
Entity ridingEntity = entity.getRidingEntity();
|
||||
|
||||
if (ridingEntity instanceof EntityLivingBase) {
|
||||
IRenderPony<EntityLivingBase> renderer = MineLittlePony.getInstance().getRenderManager().getPonyRenderer((EntityLivingBase)ridingEntity);
|
||||
IRenderPony<EntityLivingBase> renderer = PonyRenderManager.getInstance().getPonyRenderer((EntityLivingBase)ridingEntity);
|
||||
|
||||
if (renderer != null) {
|
||||
// negate vanilla translations so the rider begins at the ridees feet.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.minelittlepony.render.layer;
|
||||
|
||||
import com.minelittlepony.MineLittlePony;
|
||||
import com.minelittlepony.PonyRenderManager;
|
||||
import com.minelittlepony.model.capabilities.IModelUnicorn;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||
|
@ -31,7 +31,7 @@ public class LayerHeldPonyItemMagical<T extends EntityLivingBase> extends LayerH
|
|||
@Override
|
||||
protected void postItemRender(T entity, ItemStack drop, TransformType transform, EnumHandSide hand) {
|
||||
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
|
||||
public void set(boolean 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) {
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
public static TileEntitySkullRenderer resolve() {
|
||||
if (MineLittlePony.getConfig().ponyskulls) {
|
||||
if (MineLittlePony.getInstance().getConfig().ponyskulls) {
|
||||
if (!(instance instanceof PonySkullRenderer)) {
|
||||
backup = instance;
|
||||
ModUtilities.addRenderer(TileEntitySkull.class, ponyInstance);
|
||||
|
@ -75,7 +75,7 @@ public class PonySkullRenderer extends TileEntitySkullRenderer implements IRende
|
|||
|
||||
ISkull skull = skullMap.get(skullType);
|
||||
|
||||
if (skull == null || !skull.canRender(MineLittlePony.getConfig())) {
|
||||
if (skull == null || !skull.canRender(MineLittlePony.getInstance().getConfig())) {
|
||||
if (backup != null) {
|
||||
backup.renderSkull(x, y, z, facing, rotation, skullType, profile, destroyStage, animateTicks);
|
||||
} 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() {
|
||||
return shadowSize * MineLittlePony.getConfig().getGlobalScaleFactor();
|
||||
return shadowSize * MineLittlePony.getInstance().getConfig().getGlobalScaleFactor();
|
||||
}
|
||||
|
||||
public float getScaleFactor() {
|
||||
return scale * MineLittlePony.getConfig().getGlobalScaleFactor();
|
||||
return scale * MineLittlePony.getInstance().getConfig().getGlobalScaleFactor();
|
||||
}
|
||||
|
||||
public PonyTransformation getTranformation() {
|
||||
|
@ -43,6 +43,6 @@ public enum PonySize implements ITriggerPixelMapped<PonySize> {
|
|||
}
|
||||
|
||||
public PonySize getEffectiveSize() {
|
||||
return MineLittlePony.getConfig().sizes ? this : PonySize.NORMAL;
|
||||
return MineLittlePony.getInstance().getConfig().sizes ? this : PonySize.NORMAL;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue