mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-22 12:37:59 +01:00
Refactoring phase 1
This commit is contained in:
parent
8442a75495
commit
d73736edce
28 changed files with 226 additions and 207 deletions
|
@ -1,56 +0,0 @@
|
|||
package com.minelittlepony.client;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.minelittlepony.client.settings.ClientPonyConfig;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
class Config extends ClientPonyConfig {
|
||||
static final Gson gson = new GsonBuilder()
|
||||
.setPrettyPrinting()
|
||||
.excludeFieldsWithoutExposeAnnotation()
|
||||
.create();
|
||||
|
||||
private final Path configFile;
|
||||
|
||||
Config(Path file) {
|
||||
configFile = file;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
|
||||
try (JsonWriter writer = new JsonWriter(Files.newBufferedWriter(configFile))) {
|
||||
writer.setIndent(" ");
|
||||
|
||||
gson.toJson(this, Config.class, writer);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
static Config of(Path file) {
|
||||
Config result = null;
|
||||
|
||||
if (Files.exists(file)) {
|
||||
try (BufferedReader s = Files.newBufferedReader(file)) {
|
||||
result = gson.fromJson(s, Config.class);
|
||||
} catch (IOException ignored) {
|
||||
result = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (result == null) {
|
||||
result = new Config(file);
|
||||
}
|
||||
|
||||
result.save();
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -9,7 +9,9 @@ import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
|||
import net.minecraft.client.render.entity.EntityRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
import com.minelittlepony.client.settings.ClientPonyConfig;
|
||||
import com.minelittlepony.hdskins.mixin.MixinEntityRenderDispatcher;
|
||||
import com.minelittlepony.settings.SensibleJsonConfig;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.function.Function;
|
||||
|
@ -20,7 +22,7 @@ public class FabMod implements ClientModInitializer, IModUtilities {
|
|||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
mlp.init(Config.of(getConfigDirectory()));
|
||||
mlp.init(SensibleJsonConfig.of(getConfigDirectory(), ClientPonyConfig::new));
|
||||
mlp.postInit(MinecraftClient.getInstance());
|
||||
}
|
||||
|
||||
|
@ -34,10 +36,6 @@ public class FabMod implements ClientModInitializer, IModUtilities {
|
|||
((MixinEntityRenderDispatcher)mx).getRenderers().put(type, renderer.apply(mx));
|
||||
}
|
||||
|
||||
public float getRenderPartialTicks() {
|
||||
return MinecraftClient.getInstance().getTickDelta();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getConfigDirectory() {
|
||||
return FabricLoader.getInstance().getConfigDirectory().toPath();
|
||||
|
|
|
@ -18,8 +18,6 @@ public interface IModUtilities {
|
|||
return false;
|
||||
}
|
||||
|
||||
float getRenderPartialTicks();
|
||||
|
||||
Path getConfigDirectory();
|
||||
|
||||
Path getAssetsDirectory();
|
||||
|
|
|
@ -89,6 +89,7 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
|||
motionLerp = MathUtil.clampLimit(zMotion * 30, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLivingState(T entity, IPony pony) {
|
||||
isChild = entity.isBaby();
|
||||
isSneaking = entity.isSneaking();
|
||||
|
|
|
@ -24,11 +24,15 @@ public class ModelSeapony<T extends LivingEntity> extends ModelUnicorn<T> {
|
|||
PlaneRenderer centerFin;
|
||||
PlaneRenderer rightFin;
|
||||
|
||||
public ModelSeapony() {
|
||||
super(false);
|
||||
public ModelSeapony(boolean smallArms) {
|
||||
super(smallArms);
|
||||
textureHeight = 64;
|
||||
}
|
||||
|
||||
public ModelSeapony() {
|
||||
this(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEquestrianArmour<?> createArmour() {
|
||||
return new PonyArmor<>(new Armour(), new Armour());
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package com.minelittlepony.client.model.races;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.minelittlepony.client.model.AbstractPonyModel;
|
||||
import com.minelittlepony.client.model.ModelWrapper;
|
||||
import com.minelittlepony.client.model.entities.ModelSeapony;
|
||||
import com.minelittlepony.client.render.entities.player.RenderPonyPlayer;
|
||||
import com.minelittlepony.client.render.entities.player.RenderSeaponyPlayer;
|
||||
|
@ -10,31 +8,34 @@ import com.minelittlepony.hdskins.VanillaModels;
|
|||
import com.minelittlepony.model.IModel;
|
||||
import com.minelittlepony.pony.meta.Race;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
public enum PlayerModels {
|
||||
/**
|
||||
* The default non-pony model. This is typically handled my the vanilla renderer.
|
||||
*/
|
||||
HUMAN(VanillaModels.DEFAULT, Race.HUMAN, ModelEarthPony::new),
|
||||
EARTH("earthpony", Race.EARTH, ModelEarthPony::new),
|
||||
PEGASUS("pegasus", Race.PEGASUS, ModelPegasus::new),
|
||||
BATPONY("batpony", Race.BATPONY, ModelBatpony::new),
|
||||
UNICORN("unicorn", Race.UNICORN, ModelUnicorn::new),
|
||||
ALICORN("alicorn", Race.ALICORN, ModelAlicorn::new),
|
||||
CHANGELING("changeling", Race.CHANGELING, ModelChangeling::new),
|
||||
ZEBRA("zebra", Race.ZEBRA, ModelZebra::new),
|
||||
SEAPONY("seapony", Race.SEAPONY, a -> new ModelSeapony<>()) {
|
||||
DEFAULT(VanillaModels.DEFAULT, VanillaModels.SLIM, Race.HUMAN, ModelEarthPony::new),
|
||||
EARTHPONY(Race.EARTH, ModelEarthPony::new),
|
||||
PEGASUS(Race.PEGASUS, ModelPegasus::new),
|
||||
BATPONY(Race.BATPONY, ModelBatpony::new),
|
||||
UNICORN(Race.UNICORN, ModelUnicorn::new),
|
||||
ALICORN(Race.ALICORN, ModelAlicorn::new),
|
||||
CHANGELING(Race.CHANGELING, ModelChangeling::new),
|
||||
ZEBRA(Race.ZEBRA, ModelZebra::new),
|
||||
SEAPONY(Race.SEAPONY, ModelSeapony::new) {
|
||||
@Override
|
||||
public RenderPonyPlayer createRenderer(EntityRenderDispatcher manager, boolean slimArms) {
|
||||
return new RenderSeaponyPlayer(manager, slimArms, PlayerModels.UNICORN.getModel(slimArms), getModel(slimArms));
|
||||
}
|
||||
};
|
||||
|
||||
private static Map<Race, PlayerModels> raceModelsMap = Maps.newEnumMap(Race.class);
|
||||
private static final Map<Race, PlayerModels> raceModelsMap = Maps.newEnumMap(Race.class);
|
||||
|
||||
static {
|
||||
for (PlayerModels i : values()) {
|
||||
|
@ -42,48 +43,41 @@ public enum PlayerModels {
|
|||
}
|
||||
}
|
||||
|
||||
private final ModelResolver resolver;
|
||||
private final Function<Boolean, IModel> resolver;
|
||||
|
||||
private ModelWrapper<?, ?> normal;
|
||||
private ModelWrapper<?, ?> slim;
|
||||
|
||||
private final String normalKey, slimKey;
|
||||
private final PendingModel normal;
|
||||
private final PendingModel slim;
|
||||
|
||||
private final Race race;
|
||||
|
||||
PlayerModels(String key, Race race, ModelResolver resolver) {
|
||||
this(key, VanillaModels.SLIM + key, race, resolver);
|
||||
}
|
||||
|
||||
PlayerModels(String normalKey, String slimKey, Race race, ModelResolver resolver) {
|
||||
this.normalKey = normalKey;
|
||||
this.slimKey = slimKey;
|
||||
PlayerModels(Race race, Function<Boolean, IModel> resolver) {
|
||||
normal = new PendingModel(name().toLowerCase());
|
||||
slim = new PendingModel(VanillaModels.SLIM + normal.key);
|
||||
|
||||
this.resolver = resolver;
|
||||
|
||||
this.race = race;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends LivingEntity, M extends IModel> ModelWrapper<T, M> getModel(boolean isSlim) {
|
||||
PlayerModels(String normalKey, String slimKey, Race race, Function<Boolean, IModel> resolver) {
|
||||
normal = new PendingModel(normalKey);
|
||||
slim = new PendingModel(slimKey);
|
||||
|
||||
if (isSlim) {
|
||||
if (slim == null) {
|
||||
slim = new ModelWrapper<>(resolver.resolve(isSlim));
|
||||
}
|
||||
this.resolver = resolver;
|
||||
|
||||
return (ModelWrapper<T, M>)slim;
|
||||
}
|
||||
|
||||
if (normal == null) {
|
||||
normal = new ModelWrapper<>(resolver.resolve(isSlim));
|
||||
}
|
||||
|
||||
return (ModelWrapper<T, M>)normal;
|
||||
this.race = race;
|
||||
}
|
||||
|
||||
public String getId(boolean useSlimArms) {
|
||||
return useSlimArms ? slimKey : normalKey;
|
||||
public PendingModel getPendingModel(boolean isSlim) {
|
||||
return isSlim ? slim : normal;
|
||||
}
|
||||
|
||||
public <T extends LivingEntity, M extends IModel> M getModel(boolean isSlim) {
|
||||
return getPendingModel(isSlim).getModel(isSlim);
|
||||
}
|
||||
|
||||
public String getId(boolean isSlim) {
|
||||
return getPendingModel(isSlim).key;
|
||||
}
|
||||
|
||||
public RenderPonyPlayer createRenderer(EntityRenderDispatcher manager, boolean slimArms) {
|
||||
|
@ -91,14 +85,26 @@ public enum PlayerModels {
|
|||
}
|
||||
|
||||
public static PlayerModels forRace(Race race) {
|
||||
return raceModelsMap.getOrDefault(race.getAlias(), HUMAN);
|
||||
return raceModelsMap.getOrDefault(race.getAlias(), DEFAULT);
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME: PMAPI fields are null when the game starts.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
static interface ModelResolver {
|
||||
AbstractPonyModel<?> resolve(boolean slim);
|
||||
private final class PendingModel {
|
||||
@Nullable
|
||||
private IModel model;
|
||||
|
||||
private final String key;
|
||||
|
||||
PendingModel(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends LivingEntity, M extends IModel> M getModel(boolean isSlim) {
|
||||
if (model == null) {
|
||||
model = resolver.apply(isSlim);
|
||||
}
|
||||
|
||||
return (M)model;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.minelittlepony.client.render;
|
|||
import org.lwjgl.opengl.GL14;
|
||||
|
||||
import com.minelittlepony.MineLittlePony;
|
||||
import com.minelittlepony.client.MineLPClient;
|
||||
import com.minelittlepony.client.ducks.IRenderItem;
|
||||
import com.minelittlepony.client.render.tileentities.skull.PonySkullRenderer;
|
||||
import com.minelittlepony.client.util.render.Color;
|
||||
|
@ -20,7 +19,6 @@ import net.minecraft.util.UseAction;
|
|||
|
||||
import static com.mojang.blaze3d.platform.GlStateManager.*;
|
||||
|
||||
@SuppressWarnings("deprecation") // ItemCameraTransforms is deprecated by forge but we still need it.
|
||||
public class LevitatingItemRenderer {
|
||||
|
||||
public static void enableItemGlowRenderProfile() {
|
||||
|
@ -118,7 +116,7 @@ public class LevitatingItemRenderer {
|
|||
boolean doNormal = entity.getItemUseTime() <= 0 || action == UseAction.NONE;
|
||||
|
||||
if (doNormal) { // eating, blocking, and drinking are not transformed. Only held items.
|
||||
float ticks = MineLPClient.getInstance().getModUtilities().getRenderPartialTicks() - entity.age;
|
||||
float ticks = MinecraftClient.getInstance().getTickDelta() - entity.age;
|
||||
|
||||
float floatAmount = (float)Math.sin(ticks / 9) / 40;
|
||||
float driftAmount = (float)Math.cos(ticks / 6) / 40;
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.minelittlepony.client.render;
|
|||
|
||||
import com.minelittlepony.MineLittlePony;
|
||||
import com.minelittlepony.client.PonyRenderManager;
|
||||
import com.minelittlepony.client.model.AbstractPonyModel;
|
||||
import com.minelittlepony.client.model.ModelWrapper;
|
||||
import com.minelittlepony.client.transform.PonyPosture;
|
||||
import com.minelittlepony.model.IPonyModel;
|
||||
|
@ -10,7 +9,7 @@ import com.minelittlepony.pony.IPony;
|
|||
import com.minelittlepony.util.math.MathUtil;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.client.render.VisibleRegion;
|
||||
import net.minecraft.client.render.entity.model.EntityModel;
|
||||
|
@ -21,13 +20,13 @@ public class RenderPony<T extends LivingEntity, M extends EntityModel<T> & IPony
|
|||
|
||||
public ModelWrapper<T, M> playerModel;
|
||||
|
||||
protected AbstractPonyModel<T> ponyModel;
|
||||
private M ponyModel;
|
||||
|
||||
private IPony pony;
|
||||
|
||||
private IPonyRender<T, M> renderer;
|
||||
private final IPonyRender<T, M> renderer;
|
||||
|
||||
private FrustrumCheck<T> frustrum = new FrustrumCheck<>(this);
|
||||
private final FrustrumCheck<T> frustrum = new FrustrumCheck<>(this);
|
||||
|
||||
public static void enableModelRenderProfile() {
|
||||
GlStateManager.enableBlend();
|
||||
|
@ -95,54 +94,44 @@ public class RenderPony<T extends LivingEntity, M extends EntityModel<T> & IPony
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void applyPostureTransform(T player, float yaw, float ticks) {
|
||||
PonyPosture<?> posture = getPosture(player);
|
||||
if (posture != null && posture.applies(player)) {
|
||||
double motionX = player.x - player.prevX;
|
||||
double motionY = player.onGround ? 0 : player.y - player.prevY;
|
||||
double motionZ = player.x - player.prevZ;
|
||||
((PonyPosture<LivingEntity>)posture).transform(ponyModel, player, motionX, motionY, motionZ, yaw, ticks);
|
||||
}
|
||||
((PonyPosture<T>)getPosture(player)).apply(player, ponyModel, yaw, ticks, 1);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void applyPostureRiding(T player, float yaw, float ticks) {
|
||||
PonyPosture<?> posture = getPosture(player);
|
||||
if (posture != null && posture.applies(player)) {
|
||||
double motionX = player.x - player.prevX;
|
||||
double motionY = player.onGround ? 0 : player.y - player.prevY;
|
||||
double motionZ = player.z - player.prevZ;
|
||||
|
||||
((PonyPosture<LivingEntity>)posture).transform(ponyModel, player, motionX, -motionY, motionZ, yaw, ticks);
|
||||
}
|
||||
((PonyPosture<T>)getPosture(player)).apply(player, ponyModel, yaw, ticks, -1);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Nonnull
|
||||
private PonyPosture<?> getPosture(T entity) {
|
||||
if (entity.isFallFlying()) {
|
||||
return PonyPosture.ELYTRA;
|
||||
}
|
||||
|
||||
if (entity.isAlive() && entity.isSleeping()) {
|
||||
return null;
|
||||
return PonyPosture.DEFAULT;
|
||||
}
|
||||
|
||||
if (ponyModel.isSwimming()) {
|
||||
if (getModel().isSwimming()) {
|
||||
return PonyPosture.SWIMMING;
|
||||
}
|
||||
|
||||
if (ponyModel.isGoingFast()) {
|
||||
if (getModel().isGoingFast()) {
|
||||
return PonyPosture.FLIGHT;
|
||||
}
|
||||
|
||||
return PonyPosture.FALLING;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public M getModel() {
|
||||
return playerModel.getBody();
|
||||
}
|
||||
|
||||
public M setPonyModel(ModelWrapper<T, M> model) {
|
||||
playerModel = model;
|
||||
ponyModel = (AbstractPonyModel<T>)playerModel.getBody();
|
||||
ponyModel = playerModel.getBody();
|
||||
|
||||
return (M)ponyModel;
|
||||
return ponyModel;
|
||||
}
|
||||
|
||||
public void updateModel(T entity) {
|
||||
|
@ -156,11 +145,11 @@ public class RenderPony<T extends LivingEntity, M extends EntityModel<T> & IPony
|
|||
}
|
||||
|
||||
public float getShadowScale() {
|
||||
return ponyModel.getSize().getShadowSize();
|
||||
return getModel().getSize().getShadowSize();
|
||||
}
|
||||
|
||||
public float getScaleFactor() {
|
||||
return ponyModel.getSize().getScaleFactor();
|
||||
return getModel().getSize().getScaleFactor();
|
||||
}
|
||||
|
||||
public double getNamePlateYOffset(T entity, double initial) {
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package com.minelittlepony.client.render.entities;
|
||||
|
||||
import com.minelittlepony.client.model.ModelWrapper;
|
||||
import com.minelittlepony.client.model.entities.ModelEnderStallion;
|
||||
import com.minelittlepony.client.render.RenderPonyMob;
|
||||
import com.minelittlepony.client.render.layer.LayerEyeGlow;
|
||||
import com.minelittlepony.client.render.layer.LayerHeldPonyItem;
|
||||
import com.minelittlepony.client.render.layer.LayerHeldPonyItemMagical;
|
||||
|
@ -24,10 +22,8 @@ public class RenderEnderStallion extends RenderPonyMob<EndermanEntity, ModelEnde
|
|||
|
||||
private final Random rnd = new Random();
|
||||
|
||||
private static final ModelWrapper<EndermanEntity, ModelEnderStallion> MODEL_WRAPPER = new ModelWrapper<>(new ModelEnderStallion());
|
||||
|
||||
public RenderEnderStallion(EntityRenderDispatcher manager) {
|
||||
super(manager, MODEL_WRAPPER);
|
||||
super(manager, new ModelEnderStallion());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,9 +3,8 @@ package com.minelittlepony.client.render.entities;
|
|||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.minelittlepony.client.mixin.IResizeable;
|
||||
import com.minelittlepony.client.model.ModelWrapper;
|
||||
import com.minelittlepony.client.model.entities.ModelGuardianPony;
|
||||
import com.minelittlepony.client.render.RenderPonyMob.Proxy;
|
||||
import com.minelittlepony.client.render.entities.RenderPonyMob.Proxy;
|
||||
import com.minelittlepony.client.render.layer.LayerHeldPonyItem;
|
||||
import com.minelittlepony.client.render.layer.LayerHeldPonyItemMagical;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
@ -27,7 +26,7 @@ public class RenderPonyGuardian extends GuardianEntityRenderer {
|
|||
super(manager);
|
||||
|
||||
features.clear();
|
||||
ponyRenderer = new Proxy<GuardianEntity, ModelGuardianPony>(features, manager, new ModelWrapper<>(new ModelGuardianPony())) {
|
||||
ponyRenderer = new Proxy<GuardianEntity, ModelGuardianPony>(features, manager, new ModelGuardianPony()) {
|
||||
@Override
|
||||
public Identifier findTexture(GuardianEntity entity) {
|
||||
return SEAPONY;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package com.minelittlepony.client.render.entities;
|
||||
|
||||
import com.minelittlepony.client.model.ModelWrapper;
|
||||
import com.minelittlepony.client.model.entities.ModelIllagerPony;
|
||||
import com.minelittlepony.client.render.RenderPonyMob;
|
||||
import com.minelittlepony.client.render.layer.LayerHeldItemIllager;
|
||||
import com.minelittlepony.client.render.layer.LayerHeldPonyItem;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
@ -23,7 +21,7 @@ public abstract class RenderPonyIllager<T extends IllagerEntity> extends RenderP
|
|||
public static final Identifier VINDICATOR = new Identifier("minelittlepony", "textures/entity/illager/vindicator_pony.png");
|
||||
|
||||
public RenderPonyIllager(EntityRenderDispatcher manager) {
|
||||
super(manager, new ModelWrapper<>(new ModelIllagerPony<>()));
|
||||
super(manager, new ModelIllagerPony<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package com.minelittlepony.client.render;
|
||||
package com.minelittlepony.client.render.entities;
|
||||
|
||||
import com.minelittlepony.MineLittlePony;
|
||||
import com.minelittlepony.client.model.ClientPonyModel;
|
||||
import com.minelittlepony.client.model.ModelWrapper;
|
||||
import com.minelittlepony.client.render.DebugBoundingBoxRenderer;
|
||||
import com.minelittlepony.client.render.IPonyRender;
|
||||
import com.minelittlepony.client.render.RenderPony;
|
||||
import com.minelittlepony.client.render.layer.LayerGear;
|
||||
import com.minelittlepony.client.render.layer.LayerHeldPonyItem;
|
||||
import com.minelittlepony.client.render.layer.LayerHeldPonyItemMagical;
|
||||
|
@ -31,10 +34,10 @@ public abstract class RenderPonyMob<T extends LivingEntity, M extends EntityMode
|
|||
|
||||
protected RenderPony<T, M> renderPony = new RenderPony<T, M>(this);
|
||||
|
||||
public RenderPonyMob(EntityRenderDispatcher manager, ModelWrapper<T, M> model) {
|
||||
super(manager, model.getBody(), 0.5F);
|
||||
public RenderPonyMob(EntityRenderDispatcher manager, M model) {
|
||||
super(manager, model, 0.5F);
|
||||
|
||||
renderPony.setPonyModel(model);
|
||||
this.model = renderPony.setPonyModel(new ModelWrapper<>(model));
|
||||
|
||||
addLayers();
|
||||
}
|
||||
|
@ -94,11 +97,6 @@ public abstract class RenderPonyMob<T extends LivingEntity, M extends EntityMode
|
|||
return renderPony.playerModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPony getEntityPony(T entity) {
|
||||
return MineLittlePony.getInstance().getManager().getPony(findTexture(entity));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderLabel(T entity, String name, double x, double y, double z, int maxDistance) {
|
||||
super.renderLabel(entity, name, x, renderPony.getNamePlateYOffset(entity, y), z, maxDistance);
|
||||
|
@ -116,9 +114,14 @@ public abstract class RenderPonyMob<T extends LivingEntity, M extends EntityMode
|
|||
return renderPony;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPony getEntityPony(T entity) {
|
||||
return MineLittlePony.getInstance().getManager().getPony(findTexture(entity));
|
||||
}
|
||||
|
||||
public abstract static class Caster<T extends LivingEntity, M extends ClientPonyModel<T> & IUnicorn<PonyRenderer>> extends RenderPonyMob<T, M> {
|
||||
|
||||
public Caster(EntityRenderDispatcher manager, ModelWrapper<T, M> model) {
|
||||
public Caster(EntityRenderDispatcher manager, M model) {
|
||||
super(manager, model);
|
||||
}
|
||||
|
||||
|
@ -131,7 +134,7 @@ public abstract class RenderPonyMob<T extends LivingEntity, M extends EntityMode
|
|||
public abstract static class Proxy<T extends LivingEntity, M extends EntityModel<T> & IPonyModel<T>> extends RenderPonyMob<T, M> {
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public Proxy(List exportedLayers, EntityRenderDispatcher manager, ModelWrapper<T, M> model) {
|
||||
public Proxy(List exportedLayers, EntityRenderDispatcher manager, M model) {
|
||||
super(manager, model);
|
||||
|
||||
exportedLayers.addAll(features);
|
|
@ -1,8 +1,6 @@
|
|||
package com.minelittlepony.client.render.entities;
|
||||
|
||||
import com.minelittlepony.client.model.ModelWrapper;
|
||||
import com.minelittlepony.client.model.entities.ModelSkeletonPony;
|
||||
import com.minelittlepony.client.render.RenderPonyMob;
|
||||
import com.minelittlepony.client.render.layer.LayerHeldPonyItem;
|
||||
import com.minelittlepony.client.render.layer.LayerHeldPonyItemMagical;
|
||||
import com.minelittlepony.client.render.layer.LayerPonyStrayOverlay;
|
||||
|
@ -21,7 +19,7 @@ public class RenderPonySkeleton<Skeleton extends AbstractSkeletonEntity> extends
|
|||
public static final Identifier STRAY = new Identifier("minelittlepony", "textures/entity/skeleton/stray_pony.png");
|
||||
|
||||
public RenderPonySkeleton(EntityRenderDispatcher manager) {
|
||||
super(manager, new ModelWrapper<>(new ModelSkeletonPony<>()));
|
||||
super(manager, new ModelSkeletonPony<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package com.minelittlepony.client.render.entities;
|
||||
|
||||
import com.minelittlepony.client.model.ModelWrapper;
|
||||
import com.minelittlepony.client.model.entities.ModelVillagerPony;
|
||||
import com.minelittlepony.client.render.RenderPonyMob;
|
||||
import com.minelittlepony.util.resources.FormattedTextureSupplier;
|
||||
import com.minelittlepony.util.resources.ITextureSupplier;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
@ -23,7 +21,7 @@ public class RenderPonyVillager extends RenderPonyMob.Caster<VillagerEntity, Mod
|
|||
private static final ITextureSupplier<VillagerData> PROFESSIONS = new VillagerProfessionTextureCache(FORMATTER, DEFAULT);
|
||||
|
||||
public RenderPonyVillager(EntityRenderDispatcher manager) {
|
||||
super(manager, new ModelWrapper<>(new ModelVillagerPony<>()));
|
||||
super(manager, new ModelVillagerPony<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package com.minelittlepony.client.render.entities;
|
||||
|
||||
import com.minelittlepony.client.model.ModelWrapper;
|
||||
import com.minelittlepony.client.model.entities.ModelWitchPony;
|
||||
import com.minelittlepony.client.render.RenderPonyMob;
|
||||
import com.minelittlepony.client.render.layer.LayerHeldPonyItem;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
|
@ -18,7 +16,7 @@ public class RenderPonyWitch extends RenderPonyMob<WitchEntity, ModelWitchPony>
|
|||
private static final Identifier WITCH_TEXTURES = new Identifier("minelittlepony", "textures/entity/witch_pony.png");
|
||||
|
||||
public RenderPonyWitch(EntityRenderDispatcher manager) {
|
||||
super(manager, new ModelWrapper<>(new ModelWitchPony()));
|
||||
super(manager, new ModelWitchPony());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package com.minelittlepony.client.render.entities;
|
||||
|
||||
import com.minelittlepony.client.model.ModelWrapper;
|
||||
import com.minelittlepony.client.model.entities.ModelZombiePony;
|
||||
import com.minelittlepony.client.render.RenderPonyMob;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
|
@ -19,7 +17,7 @@ public class RenderPonyZombie<Zombie extends ZombieEntity> extends RenderPonyMob
|
|||
public static final Identifier PIGMAN = new Identifier("minelittlepony", "textures/entity/zombie/zombie_pigman_pony.png");
|
||||
|
||||
public RenderPonyZombie(EntityRenderDispatcher manager) {
|
||||
super(manager, new ModelWrapper<>(new ModelZombiePony<>()));
|
||||
super(manager, new ModelZombiePony<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -61,7 +59,7 @@ public class RenderPonyZombie<Zombie extends ZombieEntity> extends RenderPonyMob
|
|||
public static class Giant extends RenderPonyMob.Caster<GiantEntity, ModelZombiePony<GiantEntity>> {
|
||||
|
||||
public Giant(EntityRenderDispatcher manager) {
|
||||
super(manager, new ModelWrapper<>(new ModelZombiePony<>()));
|
||||
super(manager, new ModelZombiePony<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package com.minelittlepony.client.render.entities;
|
||||
|
||||
import com.minelittlepony.client.model.ModelWrapper;
|
||||
import com.minelittlepony.client.model.entities.ModelZombieVillagerPony;
|
||||
import com.minelittlepony.client.render.RenderPonyMob;
|
||||
import com.minelittlepony.util.resources.FormattedTextureSupplier;
|
||||
import com.minelittlepony.util.resources.ITextureSupplier;
|
||||
|
||||
|
@ -22,7 +20,7 @@ public class RenderPonyZombieVillager extends RenderPonyMob.Caster<ZombieVillage
|
|||
private static final ITextureSupplier<VillagerData> PROFESSIONS = new VillagerProfessionTextureCache(FORMATTER, DEFAULT);
|
||||
|
||||
public RenderPonyZombieVillager(EntityRenderDispatcher manager) {
|
||||
super(manager, new ModelWrapper<>(new ModelZombieVillagerPony()));
|
||||
super(manager, new ModelZombieVillagerPony());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -36,10 +36,10 @@ public class RenderPonyPlayer extends PlayerEntityRenderer implements IPonyRende
|
|||
|
||||
protected final RenderPony<AbstractClientPlayerEntity, ClientPonyModel<AbstractClientPlayerEntity>> renderPony = new RenderPony<>(this);
|
||||
|
||||
public RenderPonyPlayer(EntityRenderDispatcher manager, boolean useSmallArms, ModelWrapper<AbstractClientPlayerEntity, ClientPonyModel<AbstractClientPlayerEntity>> model) {
|
||||
public RenderPonyPlayer(EntityRenderDispatcher manager, boolean useSmallArms, ClientPonyModel<AbstractClientPlayerEntity> model) {
|
||||
super(manager, useSmallArms);
|
||||
|
||||
this.model = renderPony.setPonyModel(model);
|
||||
this.model = renderPony.setPonyModel(new ModelWrapper<>(model));
|
||||
|
||||
addLayers();
|
||||
}
|
||||
|
@ -170,11 +170,6 @@ public class RenderPonyPlayer extends PlayerEntityRenderer implements IPonyRende
|
|||
return renderPony.playerModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPony getEntityPony(AbstractClientPlayerEntity player) {
|
||||
return MineLittlePony.getInstance().getManager().getPony(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderPony<AbstractClientPlayerEntity, ClientPonyModel<AbstractClientPlayerEntity>> getInternalRenderer() {
|
||||
return renderPony;
|
||||
|
@ -185,4 +180,9 @@ public class RenderPonyPlayer extends PlayerEntityRenderer implements IPonyRende
|
|||
return getTexture(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPony getEntityPony(AbstractClientPlayerEntity entity) {
|
||||
return MineLittlePony.getInstance().getManager().getPony(entity);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,16 +11,16 @@ import net.minecraft.particle.ParticleTypes;
|
|||
|
||||
public class RenderSeaponyPlayer extends RenderPonyPlayer {
|
||||
|
||||
protected ModelWrapper<AbstractClientPlayerEntity, ClientPonyModel<AbstractClientPlayerEntity>> seapony;
|
||||
protected ModelWrapper<AbstractClientPlayerEntity, ClientPonyModel<AbstractClientPlayerEntity>> normalPony;
|
||||
protected final ModelWrapper<AbstractClientPlayerEntity, ClientPonyModel<AbstractClientPlayerEntity>> seapony;
|
||||
protected final ModelWrapper<AbstractClientPlayerEntity, ClientPonyModel<AbstractClientPlayerEntity>> normalPony;
|
||||
|
||||
public RenderSeaponyPlayer(EntityRenderDispatcher manager, boolean useSmallArms,
|
||||
ModelWrapper<AbstractClientPlayerEntity, ClientPonyModel<AbstractClientPlayerEntity>> model,
|
||||
ModelWrapper<AbstractClientPlayerEntity, ClientPonyModel<AbstractClientPlayerEntity>> alternate) {
|
||||
ClientPonyModel<AbstractClientPlayerEntity> model,
|
||||
ClientPonyModel<AbstractClientPlayerEntity> alternate) {
|
||||
super(manager, useSmallArms, model);
|
||||
|
||||
seapony = alternate;
|
||||
normalPony = model;
|
||||
seapony = new ModelWrapper<>(alternate);
|
||||
normalPony = new ModelWrapper<>(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.minelittlepony.hdskins.HDSkins;
|
|||
import com.minelittlepony.settings.PonyConfig;
|
||||
import com.minelittlepony.settings.PonyLevel;
|
||||
|
||||
public abstract class ClientPonyConfig extends PonyConfig {
|
||||
public class ClientPonyConfig extends PonyConfig {
|
||||
|
||||
@Override
|
||||
public void setPonyLevel(PonyLevel ponylevel) {
|
||||
|
|
|
@ -3,9 +3,11 @@ package com.minelittlepony.client.transform;
|
|||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
||||
import com.minelittlepony.client.model.ClientPonyModel;
|
||||
import com.minelittlepony.model.IModel;
|
||||
|
||||
public interface PonyPosture<T extends LivingEntity> {
|
||||
|
||||
PonyPosture<LivingEntity> DEFAULT = new PostureStanding();;
|
||||
PonyPosture<LivingEntity> ELYTRA = new PostureElytra();
|
||||
PonyPosture<PlayerEntity> FLIGHT = new PostureFlight();
|
||||
PonyPosture<PlayerEntity> SWIMMING = new PostureSwimming();
|
||||
|
@ -15,5 +17,15 @@ public interface PonyPosture<T extends LivingEntity> {
|
|||
return true;
|
||||
}
|
||||
|
||||
void transform(ClientPonyModel<?> model, T entity, double motionX, double motionY, double motionZ, float yaw, float ticks);
|
||||
default void apply(T player, IModel model, float yaw, float ticks, int invert) {
|
||||
if (applies(player)) {
|
||||
double motionX = player.x - player.prevX;
|
||||
double motionY = player.onGround ? 0 : player.y - player.prevY;
|
||||
double motionZ = player.z - player.prevZ;
|
||||
|
||||
transform(model, player, motionX, invert * motionY, motionZ, yaw, ticks);
|
||||
}
|
||||
}
|
||||
|
||||
void transform(IModel model, T entity, double motionX, double motionY, double motionZ, float yaw, float ticks);
|
||||
}
|
||||
|
|
|
@ -2,12 +2,12 @@ package com.minelittlepony.client.transform;
|
|||
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
|
||||
import com.minelittlepony.client.model.ClientPonyModel;
|
||||
import com.minelittlepony.model.IModel;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
public class PostureElytra implements PonyPosture<LivingEntity> {
|
||||
@Override
|
||||
public void transform(ClientPonyModel<?> model, LivingEntity entity, double motionX, double motionY, double motionZ, float yaw, float ticks) {
|
||||
public void transform(IModel model, LivingEntity entity, double motionX, double motionY, double motionZ, float yaw, float ticks) {
|
||||
GlStateManager.rotatef(90, 1, 0, 0);
|
||||
GlStateManager.translatef(0, entity.isSneaking() ? 0.2F : -1, 0);
|
||||
}
|
||||
|
|
|
@ -2,11 +2,11 @@ package com.minelittlepony.client.transform;
|
|||
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
|
||||
import com.minelittlepony.client.model.ClientPonyModel;
|
||||
import com.minelittlepony.model.IModel;
|
||||
|
||||
public class PostureFalling implements PonyPosture<LivingEntity> {
|
||||
@Override
|
||||
public void transform(ClientPonyModel<?> model, LivingEntity entity, double motionX, double motionY, double motionZ, float yaw, float ticks) {
|
||||
public void transform(IModel model, LivingEntity entity, double motionX, double motionY, double motionZ, float yaw, float ticks) {
|
||||
model.setPitch(0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.minelittlepony.client.transform;
|
||||
|
||||
import com.minelittlepony.client.model.ClientPonyModel;
|
||||
import com.minelittlepony.model.IModel;
|
||||
import com.minelittlepony.util.transform.MotionCompositor;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
|
@ -14,7 +14,7 @@ public class PostureFlight extends MotionCompositor implements PonyPosture<Playe
|
|||
}
|
||||
|
||||
@Override
|
||||
public void transform(ClientPonyModel<?> model, PlayerEntity player, double motionX, double motionY, double motionZ, float yaw, float ticks) {
|
||||
public void transform(IModel model, PlayerEntity player, double motionX, double motionY, double motionZ, float yaw, float ticks) {
|
||||
model.setPitch((float) calculateIncline(player, motionX, motionY, motionZ));
|
||||
|
||||
GlStateManager.rotatef(model.getPitch(), 1, 0, 0);
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package com.minelittlepony.client.transform;
|
||||
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
|
||||
import com.minelittlepony.model.IModel;
|
||||
|
||||
public class PostureStanding implements PonyPosture<LivingEntity> {
|
||||
@Override
|
||||
public boolean applies(LivingEntity entity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transform(IModel model, LivingEntity entity, double motionX, double motionY, double motionZ, float yaw, float ticks) {
|
||||
}
|
||||
}
|
|
@ -3,6 +3,10 @@ package com.minelittlepony.model;
|
|||
import net.minecraft.client.model.Cuboid;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
|
||||
public interface IPonyModel<T extends LivingEntity> extends PonyModelConstants, IModel, ICapitated<Cuboid>, ICompartmented<Cuboid> {
|
||||
import com.minelittlepony.pony.IPony;
|
||||
|
||||
public interface IPonyModel<T extends LivingEntity> extends PonyModelConstants, IModel, ICapitated<Cuboid>, ICompartmented<Cuboid> {
|
||||
default void updateLivingState(T entity, IPony pony) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,12 +3,11 @@ package com.minelittlepony.settings;
|
|||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.minelittlepony.common.SensibleConfig;
|
||||
|
||||
/**
|
||||
* Storage container for MineLP client settings.
|
||||
*/
|
||||
public abstract class PonyConfig extends SensibleConfig {
|
||||
public abstract class PonyConfig extends SensibleJsonConfig {
|
||||
|
||||
@Expose private PonyLevel ponylevel = PonyLevel.PONIES;
|
||||
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
package com.minelittlepony.settings;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.minelittlepony.client.settings.ClientPonyConfig;
|
||||
import com.minelittlepony.common.SensibleConfig;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class SensibleJsonConfig extends SensibleConfig {
|
||||
|
||||
static final Gson gson = new GsonBuilder()
|
||||
.setPrettyPrinting()
|
||||
.excludeFieldsWithoutExposeAnnotation()
|
||||
.create();
|
||||
|
||||
private Path configFile;
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
|
||||
try (JsonWriter writer = new JsonWriter(Files.newBufferedWriter(configFile))) {
|
||||
writer.setIndent(" ");
|
||||
|
||||
gson.toJson(this, ClientPonyConfig.class, writer);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T extends SensibleJsonConfig> T load(Path file) {
|
||||
SensibleJsonConfig result = this;
|
||||
|
||||
try {
|
||||
if (Files.exists(file)) {
|
||||
try (BufferedReader s = Files.newBufferedReader(file)) {
|
||||
result = gson.fromJson(s, getClass());
|
||||
} catch (IOException ignored) {
|
||||
result = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (result == null) {
|
||||
result = this;
|
||||
}
|
||||
|
||||
result.configFile = file;
|
||||
} finally {
|
||||
result.save();
|
||||
}
|
||||
|
||||
return (T)result;
|
||||
}
|
||||
|
||||
public static <T extends SensibleJsonConfig> T of(Path file, Supplier<T> creator) {
|
||||
return creator.get().load(file);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue