mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-12 16:04:21 +01:00
Improved separation between client-fabric and server-unknown and add Size(details) and Wearables to what's sent
This commit is contained in:
parent
08cfb35520
commit
edfdcacae1
19 changed files with 340 additions and 186 deletions
|
@ -48,6 +48,11 @@ public interface IPonyData {
|
|||
*/
|
||||
boolean hasMagic();
|
||||
|
||||
/**
|
||||
* Returns an array of wearables that this pony is carrying.
|
||||
*/
|
||||
Wearable[] getGear();
|
||||
|
||||
/**
|
||||
* Checks it this pony is wearing the given accessory.
|
||||
*/
|
||||
|
|
|
@ -2,9 +2,6 @@ package com.minelittlepony.api.pony;
|
|||
|
||||
/**
|
||||
* Interface for enums that can be parsed from an image trigger pixel value.
|
||||
* @author Chris Albers
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
public interface ITriggerPixelMapped<T extends Enum<T> & ITriggerPixelMapped<T>> {
|
||||
/**
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package com.minelittlepony.api.pony.meta;
|
||||
|
||||
import com.minelittlepony.api.pony.ITriggerPixelMapped;
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.settings.PonyLevel;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
@ -94,20 +92,6 @@ public enum Race implements ITriggerPixelMapped<Race> {
|
|||
return getAlias() == other.getAlias();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the actual race determined by the given pony level.
|
||||
* PonyLevel.HUMANS would force all races to be humans.
|
||||
* PonyLevel.BOTH is no change.
|
||||
* PonyLevel.PONIES (should) return a pony if this is a human. Don't be fooled, though. It doesn't.
|
||||
*/
|
||||
public Race getEffectiveRace(boolean ignorePony) {
|
||||
if (MineLittlePony.getInstance().getConfig().getEffectivePonyLevel(ignorePony) == PonyLevel.HUMANS) {
|
||||
return HUMAN;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTriggerPixel() {
|
||||
return triggerPixel;
|
||||
|
|
|
@ -1,70 +1,45 @@
|
|||
package com.minelittlepony.api.pony.meta;
|
||||
|
||||
import com.minelittlepony.api.pony.ITriggerPixelMapped;
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
/**
|
||||
* Represents the different model sizes that are possible.
|
||||
*
|
||||
* For a list of possible presets, look at {@link Sizes}.
|
||||
* This interface exists for servers so they can work with this information even though they might not have access to the client config.
|
||||
*
|
||||
*/
|
||||
public interface Size {
|
||||
|
||||
public enum Size implements ITriggerPixelMapped<Size> {
|
||||
TALL (0x534b76, 0.45f, 1.1F, 1.15F),
|
||||
BULKY (0xce3254, 0.5f, 1, 1.05F),
|
||||
LANKY (0x3254ce, 0.45F, 0.85F, 0.9F),
|
||||
NORMAL (0x000000, 0.4f, 0.8F, 0.8F),
|
||||
YEARLING(0x53beff, 0.4F, 0.6F, 0.65F),
|
||||
FOAL (0xffbe53, 0.25f, 0.6F, 0.5F),
|
||||
UNSET (0x000000, 1, 1, 1);
|
||||
/**
|
||||
* The Enum index of this size. May be used on the client to convert to an instance of Sizes or use {@link Sizes#of}
|
||||
*
|
||||
* Made to be compatible with the enum variant.
|
||||
*/
|
||||
int ordinal();
|
||||
|
||||
public static final Size[] REGISTRY = values();
|
||||
/**
|
||||
* Name of the size.
|
||||
*
|
||||
* Made to be compatible with the enum variant.
|
||||
*/
|
||||
String name();
|
||||
|
||||
private int triggerValue;
|
||||
/**
|
||||
* A scale factor that controls the size of the shadow that appears under the entity.
|
||||
*/
|
||||
float getShadowSize();
|
||||
|
||||
private float shadowSize;
|
||||
private float scale;
|
||||
private float camera;
|
||||
/**
|
||||
* The global scale factor applied to all physical dimensions.
|
||||
*/
|
||||
float getScaleFactor();
|
||||
|
||||
Size(int pixel, float shadowSz, float scaleF, float cameraF) {
|
||||
triggerValue = pixel;
|
||||
shadowSize = shadowSz;
|
||||
scale = scaleF;
|
||||
camera = cameraF;
|
||||
}
|
||||
/**
|
||||
* A scale factor used to alter the vertical eye position.
|
||||
*/
|
||||
float getEyeHeightFactor();
|
||||
|
||||
public float getShadowSize() {
|
||||
return shadowSize * MineLittlePony.getInstance().getConfig().getGlobalScaleFactor();
|
||||
}
|
||||
|
||||
public float getScaleFactor() {
|
||||
return scale * MineLittlePony.getInstance().getConfig().getGlobalScaleFactor();
|
||||
}
|
||||
|
||||
public float getEyeHeightFactor() {
|
||||
if (!MineLittlePony.getInstance().getConfig().fillycam.get()) {
|
||||
return 1;
|
||||
}
|
||||
return camera * MineLittlePony.getInstance().getConfig().getGlobalScaleFactor();
|
||||
}
|
||||
|
||||
public float getEyeDistanceFactor() {
|
||||
if (!MineLittlePony.getInstance().getConfig().fillycam.get()) {
|
||||
return 1;
|
||||
}
|
||||
return camera * MineLittlePony.getInstance().getConfig().getGlobalScaleFactor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTriggerPixel() {
|
||||
return triggerValue;
|
||||
}
|
||||
|
||||
public Size getEffectiveSize() {
|
||||
Size sz = MineLittlePony.getInstance().getConfig().sizeOverride.get();
|
||||
|
||||
if (sz != UNSET) {
|
||||
return sz;
|
||||
}
|
||||
|
||||
if (this == UNSET || !MineLittlePony.getInstance().getConfig().sizes.get()) {
|
||||
return NORMAL;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* A scale factor used to alter the camera's distance.
|
||||
*/
|
||||
float getEyeDistanceFactor();
|
||||
}
|
||||
|
|
76
src/main/java/com/minelittlepony/api/pony/meta/Sizes.java
Normal file
76
src/main/java/com/minelittlepony/api/pony/meta/Sizes.java
Normal file
|
@ -0,0 +1,76 @@
|
|||
package com.minelittlepony.api.pony.meta;
|
||||
|
||||
import com.minelittlepony.api.pony.ITriggerPixelMapped;
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
|
||||
/**
|
||||
* Represents the different model sizes that are possible.
|
||||
*
|
||||
* This is the client-side version.
|
||||
*/
|
||||
public enum Sizes implements ITriggerPixelMapped<Sizes>, Size {
|
||||
TALL (0x534b76, 0.45f, 1.1F, 1.15F),
|
||||
BULKY (0xce3254, 0.5f, 1, 1.05F),
|
||||
LANKY (0x3254ce, 0.45F, 0.85F, 0.9F),
|
||||
NORMAL (0x000000, 0.4f, 0.8F, 0.8F),
|
||||
YEARLING(0x53beff, 0.4F, 0.6F, 0.65F),
|
||||
FOAL (0xffbe53, 0.25f, 0.6F, 0.5F),
|
||||
UNSET (0x000000, 1, 1, 1);
|
||||
|
||||
public static final Sizes[] REGISTRY = values();
|
||||
|
||||
private int triggerValue;
|
||||
|
||||
private float shadowSize;
|
||||
private float scale;
|
||||
private float camera;
|
||||
|
||||
Sizes(int pixel, float shadowSz, float scaleF, float cameraF) {
|
||||
triggerValue = pixel;
|
||||
shadowSize = shadowSz;
|
||||
scale = scaleF;
|
||||
camera = cameraF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getShadowSize() {
|
||||
return shadowSize * MineLittlePony.getInstance().getConfig().getGlobalScaleFactor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getScaleFactor() {
|
||||
return scale * MineLittlePony.getInstance().getConfig().getGlobalScaleFactor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEyeHeightFactor() {
|
||||
if (!MineLittlePony.getInstance().getConfig().fillycam.get()) {
|
||||
return 1;
|
||||
}
|
||||
return camera * MineLittlePony.getInstance().getConfig().getGlobalScaleFactor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEyeDistanceFactor() {
|
||||
if (!MineLittlePony.getInstance().getConfig().fillycam.get()) {
|
||||
return 1;
|
||||
}
|
||||
return camera * MineLittlePony.getInstance().getConfig().getGlobalScaleFactor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTriggerPixel() {
|
||||
return triggerValue;
|
||||
}
|
||||
|
||||
public static Sizes of(Size size) {
|
||||
if (size instanceof Sizes) {
|
||||
return (Sizes)size;
|
||||
}
|
||||
int i = size.ordinal();
|
||||
if (i < 0 || i >= REGISTRY.length) {
|
||||
return UNSET;
|
||||
}
|
||||
return REGISTRY[i];
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@ public enum TriggerPixels {
|
|||
RACE(Race.HUMAN, Channel.ALL, 0, 0),
|
||||
TAIL(TailLength.FULL, Channel.ALL, 1, 0),
|
||||
GENDER(Gender.MARE, Channel.ALL, 2, 0),
|
||||
SIZE(Size.NORMAL, Channel.ALL, 3, 0),
|
||||
SIZE(Sizes.NORMAL, Channel.ALL, 3, 0),
|
||||
GLOW(null, Channel.RAW, 0, 1),
|
||||
WEARABLES(Wearable.NONE, Channel.RAW, 1, 1);
|
||||
|
||||
|
|
|
@ -24,6 +24,14 @@ public enum Wearable implements ITriggerPixelMapped<Wearable> {
|
|||
return triggerValue;
|
||||
}
|
||||
|
||||
public static boolean[] flags(Wearable[] wears) {
|
||||
boolean[] flags = new boolean[values().length];
|
||||
for (int i = 0; i < wears.length; i++) {
|
||||
flags[wears[i].ordinal()] = true;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
public static Wearable[] flags(boolean[] flags) {
|
||||
List<Wearable> wears = new ArrayList<>();
|
||||
Wearable[] values = values();
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
package com.minelittlepony.api.pony.network;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.network.ClientSidePacketRegistry;
|
||||
import net.fabricmc.fabric.api.network.PacketContext;
|
||||
import net.fabricmc.fabric.api.network.ServerSidePacketRegistry;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public interface Channel {
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
SPacketType<MsgPonyData> CLIENT_PONY_DATA = clientToServer(new Identifier("minelittlepony", "pony_data"), MsgPonyData::new);
|
||||
|
||||
static void bootstrap() { }
|
||||
|
||||
static <T extends Packet> SPacketType<T> clientToServer(Identifier id, Function<PacketByteBuf, T> factory) {
|
||||
ServerSidePacketRegistry.INSTANCE.register(id, (context, buffer) -> factory.apply(buffer).handleOnMain(context));
|
||||
return () -> id;
|
||||
}
|
||||
|
||||
interface SPacketType<T extends Packet> {
|
||||
Identifier getId();
|
||||
|
||||
default void send(T packet) {
|
||||
if (FabricLoader.getInstance().getEnvironmentType() != EnvType.CLIENT) {
|
||||
throw new RuntimeException("Client packet send called by the server");
|
||||
}
|
||||
ClientSidePacketRegistry.INSTANCE.sendToServer(getId(), packet.toBuffer());
|
||||
}
|
||||
|
||||
default net.minecraft.network.Packet<?> toPacket(T packet) {
|
||||
if (FabricLoader.getInstance().getEnvironmentType() != EnvType.CLIENT) {
|
||||
throw new RuntimeException("Client packet send called by the server");
|
||||
}
|
||||
return ClientSidePacketRegistry.INSTANCE.toPacket(getId(), packet.toBuffer());
|
||||
}
|
||||
}
|
||||
|
||||
interface Packet {
|
||||
void handle(PacketContext context);
|
||||
|
||||
void toBuffer(PacketByteBuf buffer);
|
||||
|
||||
default void handleOnMain(PacketContext context) {
|
||||
context.getTaskQueue().execute(() -> handle(context));
|
||||
}
|
||||
|
||||
default PacketByteBuf toBuffer() {
|
||||
PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
|
||||
toBuffer(buf);
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
package com.minelittlepony.api.pony.network;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.fabric.api.network.PacketContext;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
|
||||
import com.minelittlepony.api.pony.IPonyData;
|
||||
|
@ -14,7 +12,7 @@ import com.minelittlepony.common.util.animation.Interpolator;
|
|||
|
||||
import java.util.UUID;
|
||||
|
||||
public class MsgPonyData implements Channel.Packet, IPonyData {
|
||||
public class MsgPonyData implements IPonyData {
|
||||
|
||||
private final Race race;
|
||||
private final TailLength tailLength;
|
||||
|
@ -26,15 +24,23 @@ public class MsgPonyData implements Channel.Packet, IPonyData {
|
|||
|
||||
private final boolean noSkin;
|
||||
|
||||
MsgPonyData(PacketByteBuf buffer) {
|
||||
private final boolean[] wearables;
|
||||
|
||||
public MsgPonyData(PacketByteBuf buffer) {
|
||||
race = Race.values()[buffer.readInt()];
|
||||
tailLength = TailLength.values()[buffer.readInt()];
|
||||
gender = Gender.values()[buffer.readInt()];
|
||||
size = Size.values()[buffer.readInt()];
|
||||
size = new MsgSize(buffer);
|
||||
glowColor = buffer.readInt();
|
||||
hasHorn = buffer.readBoolean();
|
||||
hasMagic = buffer.readBoolean();
|
||||
noSkin = buffer.readBoolean();
|
||||
Wearable[] gear = new Wearable[buffer.readInt()];
|
||||
Wearable[] all = Wearable.values();
|
||||
for (int i = 0; i < gear.length; i++) {
|
||||
gear[i] = all[buffer.readInt()];
|
||||
}
|
||||
wearables = Wearable.flags(gear);
|
||||
}
|
||||
|
||||
public MsgPonyData(IPonyData data, boolean noSkin) {
|
||||
|
@ -45,24 +51,29 @@ public class MsgPonyData implements Channel.Packet, IPonyData {
|
|||
glowColor = data.getGlowColor();
|
||||
hasHorn = data.hasHorn();
|
||||
hasMagic = data.hasMagic();
|
||||
wearables = Wearable.flags(data.getGear());
|
||||
this.noSkin = noSkin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketContext context) {
|
||||
PonyDataCallback.EVENT.invoker().onPonyDataAvailable(context.getPlayer(), this, noSkin, EnvType.SERVER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBuffer(PacketByteBuf buffer) {
|
||||
buffer.writeInt(race.ordinal());
|
||||
buffer.writeInt(tailLength.ordinal());
|
||||
buffer.writeInt(gender.ordinal());
|
||||
buffer.writeInt(size.ordinal());
|
||||
new MsgSize(size).toBuffer(buffer);
|
||||
buffer.writeInt(glowColor);
|
||||
buffer.writeBoolean(hasHorn);
|
||||
buffer.writeBoolean(hasMagic);
|
||||
buffer.writeBoolean(noSkin);
|
||||
|
||||
Wearable[] gear = getGear();
|
||||
buffer.writeInt(gear.length);
|
||||
for (int i = 0; i < gear.length; i++) {
|
||||
buffer.writeInt(gear[i].ordinal());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isNoSkin() {
|
||||
return noSkin;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -100,13 +111,90 @@ public class MsgPonyData implements Channel.Packet, IPonyData {
|
|||
return hasMagic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Wearable[] getGear() {
|
||||
return Wearable.flags(wearables);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWearing(Wearable wearable) {
|
||||
return false;
|
||||
return wearables[wearable.ordinal()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interpolator getInterpolator(UUID interpolatorId) {
|
||||
return Interpolator.linear(interpolatorId);
|
||||
}
|
||||
|
||||
private static final class MsgSize implements Size {
|
||||
|
||||
private final int ordinal;
|
||||
private final String name;
|
||||
private final float shadow;
|
||||
private final float scale;
|
||||
private final float eyeHeight;
|
||||
private final float eyeDistance;
|
||||
|
||||
MsgSize(Size size) {
|
||||
ordinal = size.ordinal();
|
||||
name = size.name();
|
||||
shadow = size.getShadowSize();
|
||||
scale = size.getScaleFactor();
|
||||
eyeHeight = size.getEyeHeightFactor();
|
||||
eyeDistance = size.getEyeDistanceFactor();
|
||||
}
|
||||
|
||||
MsgSize(PacketByteBuf buffer) {
|
||||
ordinal = buffer.readInt();
|
||||
name = buffer.readString(32767);
|
||||
shadow = buffer.readFloat();
|
||||
scale = buffer.readFloat();
|
||||
eyeHeight = buffer.readFloat();
|
||||
eyeDistance = buffer.readFloat();
|
||||
}
|
||||
|
||||
public void toBuffer(PacketByteBuf buffer) {
|
||||
buffer.writeInt(ordinal);
|
||||
buffer.writeString(name);
|
||||
buffer.writeFloat(shadow);
|
||||
buffer.writeFloat(scale);
|
||||
buffer.writeFloat(eyeHeight);
|
||||
buffer.writeFloat(eyeDistance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int ordinal() {
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getShadowSize() {
|
||||
return shadow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getScaleFactor() {
|
||||
return scale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEyeHeightFactor() {
|
||||
return eyeHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEyeDistanceFactor() {
|
||||
return eyeDistance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
package com.minelittlepony.api.pony.network.fabric;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.network.ClientSidePacketRegistry;
|
||||
import net.fabricmc.fabric.api.network.PacketContext;
|
||||
import net.fabricmc.fabric.api.network.ServerSidePacketRegistry;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import com.minelittlepony.api.pony.network.MsgPonyData;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public interface Channel {
|
||||
Consumer<MsgPonyData> CLIENT_PONY_DATA = clientToServer(new Identifier("minelittlepony", "pony_data"), MsgPonyData::new, MsgPonyData::toBuffer, (packet, context) -> {
|
||||
PonyDataCallback.EVENT.invoker().onPonyDataAvailable(context.getPlayer(), packet, packet.isNoSkin(), EnvType.SERVER);
|
||||
});
|
||||
|
||||
static void bootstrap() { }
|
||||
|
||||
static <T> Consumer<T> clientToServer(Identifier id, Function<PacketByteBuf, T> factory,
|
||||
BiConsumer<T, PacketByteBuf> bufferWriter,
|
||||
BiConsumer<T, PacketContext> handler) {
|
||||
ServerSidePacketRegistry.INSTANCE.register(id, (context, buffer) -> {
|
||||
T packet = factory.apply(buffer);
|
||||
context.getTaskQueue().execute(() -> {
|
||||
handler.accept(packet, context);
|
||||
});
|
||||
});
|
||||
return packet -> {
|
||||
if (FabricLoader.getInstance().getEnvironmentType() != EnvType.CLIENT) {
|
||||
throw new RuntimeException("Client packet send called by the server");
|
||||
}
|
||||
|
||||
PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
|
||||
bufferWriter.accept(packet, buf);
|
||||
|
||||
ClientSidePacketRegistry.INSTANCE.sendToServer(id, buf);
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.minelittlepony.api.pony.network;
|
||||
package com.minelittlepony.api.pony.network.fabric;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.fabric.api.event.Event;
|
|
@ -1,7 +1,7 @@
|
|||
package com.minelittlepony.client;
|
||||
|
||||
import com.minelittlepony.api.pony.IPonyManager;
|
||||
import com.minelittlepony.api.pony.network.Channel;
|
||||
import com.minelittlepony.api.pony.network.fabric.Channel;
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.client.pony.PonyManager;
|
||||
import com.minelittlepony.client.render.PonyRenderDispatcher;
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.minelittlepony.client.model.armour.PonyArmourModel;
|
|||
import com.minelittlepony.client.render.EquineRenderManager;
|
||||
import com.minelittlepony.model.capabilities.fabric.PonyModelPrepareCallback;
|
||||
import com.minelittlepony.api.pony.meta.Race;
|
||||
import com.minelittlepony.api.pony.meta.Size;
|
||||
import com.minelittlepony.api.pony.meta.Sizes;
|
||||
import com.minelittlepony.client.model.armour.ArmourWrapper;
|
||||
import com.minelittlepony.client.transform.PonyTransformation;
|
||||
import com.minelittlepony.model.BodyPart;
|
||||
|
@ -464,10 +464,10 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
|||
arm.pivotX -= 6 * sigma;
|
||||
arm.pivotZ -= 2;
|
||||
}
|
||||
if (getSize() == Size.TALL) {
|
||||
if (getSize() == Sizes.TALL) {
|
||||
arm.pivotY += 1;
|
||||
}
|
||||
if (getSize() == Size.FOAL) {
|
||||
if (getSize() == Sizes.FOAL) {
|
||||
arm.pivotY -= 2;
|
||||
}
|
||||
|
||||
|
@ -560,7 +560,7 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
|||
|
||||
@Override
|
||||
public float getRiderYOffset() {
|
||||
switch (getSize()) {
|
||||
switch ((Sizes)getSize()) {
|
||||
case NORMAL: return 0.4F;
|
||||
case FOAL:
|
||||
case TALL:
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.minelittlepony.model.capabilities.fabric.PonyModelPrepareCallback;
|
|||
import com.minelittlepony.api.pony.IPony;
|
||||
import com.minelittlepony.api.pony.IPonyData;
|
||||
import com.minelittlepony.api.pony.meta.Size;
|
||||
import com.minelittlepony.api.pony.meta.Sizes;
|
||||
import com.minelittlepony.client.pony.PonyData;
|
||||
import com.minelittlepony.client.render.EquineRenderManager;
|
||||
import com.minelittlepony.model.ModelAttributes;
|
||||
|
@ -69,7 +70,7 @@ public abstract class ClientPonyModel<T extends LivingEntity> extends MsonPlayer
|
|||
|
||||
@Override
|
||||
public Size getSize() {
|
||||
return child ? Size.FOAL : getMetadata().getSize();
|
||||
return child ? Sizes.FOAL : getMetadata().getSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,12 +5,15 @@ import com.minelittlepony.api.pony.IPony;
|
|||
import com.minelittlepony.api.pony.IPonyData;
|
||||
import com.minelittlepony.api.pony.meta.Race;
|
||||
import com.minelittlepony.api.pony.meta.Size;
|
||||
import com.minelittlepony.api.pony.network.Channel;
|
||||
import com.minelittlepony.api.pony.meta.Sizes;
|
||||
import com.minelittlepony.api.pony.network.MsgPonyData;
|
||||
import com.minelittlepony.api.pony.network.PonyDataCallback;
|
||||
import com.minelittlepony.api.pony.network.fabric.Channel;
|
||||
import com.minelittlepony.api.pony.network.fabric.PonyDataCallback;
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.client.render.IPonyRenderContext;
|
||||
import com.minelittlepony.client.render.PonyRenderDispatcher;
|
||||
import com.minelittlepony.client.transform.PonyTransformation;
|
||||
import com.minelittlepony.settings.PonyLevel;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
@ -61,7 +64,7 @@ public class Pony implements IPony {
|
|||
entity.calculateDimensions();
|
||||
|
||||
if (entity == MinecraftClient.getInstance().player) {
|
||||
Channel.CLIENT_PONY_DATA.send(new MsgPonyData(metadata, defaulted));
|
||||
Channel.CLIENT_PONY_DATA.accept(new MsgPonyData(metadata, defaulted));
|
||||
}
|
||||
if (entity instanceof PlayerEntity) {
|
||||
PonyDataCallback.EVENT.invoker().onPonyDataAvailable((PlayerEntity)entity, metadata, defaulted, EnvType.CLIENT);
|
||||
|
@ -138,7 +141,7 @@ public class Pony implements IPony {
|
|||
}
|
||||
|
||||
protected Vec3d getVisualEyePosition(LivingEntity entity) {
|
||||
Size size = entity.isBaby() ? Size.FOAL : metadata.getSize();
|
||||
Size size = entity.isBaby() ? Sizes.FOAL : metadata.getSize();
|
||||
|
||||
return new Vec3d(
|
||||
entity.getX(),
|
||||
|
@ -149,7 +152,7 @@ public class Pony implements IPony {
|
|||
|
||||
@Override
|
||||
public Race getRace(boolean ignorePony) {
|
||||
return metadata.getRace().getEffectiveRace(ignorePony);
|
||||
return getEffectiveRace(metadata.getRace(), ignorePony);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -238,4 +241,18 @@ public class Pony implements IPony {
|
|||
.add("metadata", metadata)
|
||||
.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the actual race determined by the given pony level.
|
||||
* PonyLevel.HUMANS would force all races to be humans.
|
||||
* PonyLevel.BOTH is no change.
|
||||
* PonyLevel.PONIES (should) return a pony if this is a human. Don't be fooled, though. It doesn't.
|
||||
*/
|
||||
public static Race getEffectiveRace(Race race, boolean ignorePony) {
|
||||
if (MineLittlePony.getInstance().getConfig().getEffectivePonyLevel(ignorePony) == PonyLevel.HUMANS) {
|
||||
return Race.HUMAN;
|
||||
}
|
||||
|
||||
return race;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import com.google.gson.annotations.Expose;
|
|||
import com.minelittlepony.api.pony.IPonyData;
|
||||
import com.minelittlepony.api.pony.meta.Gender;
|
||||
import com.minelittlepony.api.pony.meta.Race;
|
||||
import com.minelittlepony.api.pony.meta.Size;
|
||||
import com.minelittlepony.api.pony.meta.Sizes;
|
||||
import com.minelittlepony.api.pony.meta.TailLength;
|
||||
import com.minelittlepony.api.pony.meta.TriggerPixels;
|
||||
import com.minelittlepony.api.pony.meta.Wearable;
|
||||
|
@ -75,7 +75,7 @@ public class PonyData implements IPonyData {
|
|||
private final Gender gender;
|
||||
|
||||
@Expose
|
||||
private final Size size;
|
||||
private final Sizes size;
|
||||
|
||||
@Expose
|
||||
private final int glowColor;
|
||||
|
@ -87,7 +87,7 @@ public class PonyData implements IPonyData {
|
|||
this.race = race;
|
||||
tailSize = TailLength.FULL;
|
||||
gender = Gender.MARE;
|
||||
size = Size.NORMAL;
|
||||
size = Sizes.NORMAL;
|
||||
glowColor = 0x4444aa;
|
||||
|
||||
wearables = new boolean[Wearable.values().length];
|
||||
|
@ -119,8 +119,18 @@ public class PonyData implements IPonyData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Size getSize() {
|
||||
return size.getEffectiveSize();
|
||||
public Sizes getSize() {
|
||||
Sizes sz = MineLittlePony.getInstance().getConfig().sizeOverride.get();
|
||||
|
||||
if (sz != Sizes.UNSET) {
|
||||
return sz;
|
||||
}
|
||||
|
||||
if (size == Sizes.UNSET || !MineLittlePony.getInstance().getConfig().sizes.get()) {
|
||||
return Sizes.NORMAL;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -130,7 +140,7 @@ public class PonyData implements IPonyData {
|
|||
|
||||
@Override
|
||||
public boolean hasHorn() {
|
||||
return getRace() != null && getRace().getEffectiveRace(false).hasHorn();
|
||||
return getRace() != null && Pony.getEffectiveRace(getRace(), false).hasHorn();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -138,6 +148,11 @@ public class PonyData implements IPonyData {
|
|||
return hasHorn() && getGlowColor() != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Wearable[] getGear() {
|
||||
return Wearable.flags(wearables);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWearing(Wearable wearable) {
|
||||
return wearables[wearable.ordinal()];
|
||||
|
@ -155,7 +170,7 @@ public class PonyData implements IPonyData {
|
|||
.add("tailSize", tailSize)
|
||||
.add("gender", gender)
|
||||
.add("size", size)
|
||||
.add("wearables", Wearable.flags(wearables))
|
||||
.add("wearables", getGear())
|
||||
.add("glowColor", "#" + Integer.toHexString(glowColor))
|
||||
.toString();
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import net.minecraft.util.math.Vec3d;
|
|||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.minelittlepony.api.pony.meta.Size;
|
||||
import com.minelittlepony.api.pony.meta.Sizes;
|
||||
import com.minelittlepony.model.BodyPart;
|
||||
import com.minelittlepony.model.IModel;
|
||||
|
||||
|
@ -12,7 +13,7 @@ import java.util.Map;
|
|||
|
||||
public enum PonyTransformation {
|
||||
|
||||
NORMAL(Size.NORMAL, 0, 3F, 0.75F) {
|
||||
NORMAL(Sizes.NORMAL, 0, 3F, 0.75F) {
|
||||
@Override
|
||||
public void transform(IModel model, BodyPart part, MatrixStack stack) {
|
||||
if (model.getAttributes().isSwimming) stack.translate(0, -0.3F, 0);
|
||||
|
@ -35,7 +36,7 @@ public enum PonyTransformation {
|
|||
}
|
||||
}
|
||||
},
|
||||
LANKY(Size.LANKY, 0, 2.6F, 0.75F) {
|
||||
LANKY(Sizes.LANKY, 0, 2.6F, 0.75F) {
|
||||
@Override
|
||||
public void transform(IModel model, BodyPart part, MatrixStack stack) {
|
||||
if (model.getAttributes().isSwimming) stack.translate(0, -0.2F, 0);
|
||||
|
@ -73,7 +74,7 @@ public enum PonyTransformation {
|
|||
}
|
||||
}
|
||||
},
|
||||
BULKY(Size.BULKY, 0, 2.3F, 0.75F) {
|
||||
BULKY(Sizes.BULKY, 0, 2.3F, 0.75F) {
|
||||
@Override
|
||||
public void transform(IModel model, BodyPart part, MatrixStack stack) {
|
||||
if (model.getAttributes().isCrouching) stack.translate(0, -0.15F, 0);
|
||||
|
@ -110,7 +111,7 @@ public enum PonyTransformation {
|
|||
}
|
||||
}
|
||||
},
|
||||
FOAL(Size.FOAL, 0, 3.8F, 0.75F) {
|
||||
FOAL(Sizes.FOAL, 0, 3.8F, 0.75F) {
|
||||
@Override
|
||||
public void transform(IModel model, BodyPart part, MatrixStack stack) {
|
||||
if (model.getAttributes().isSwimming) stack.translate(0, -0.9F, 0);
|
||||
|
@ -141,7 +142,7 @@ public enum PonyTransformation {
|
|||
}
|
||||
}
|
||||
},
|
||||
TALL(Size.TALL, 0, 2.2F, 0.75F) {
|
||||
TALL(Sizes.TALL, 0, 2.2F, 0.75F) {
|
||||
@Override
|
||||
public void transform(IModel model, BodyPart part, MatrixStack stack) {
|
||||
if (model.getAttributes().isCrouching) stack.translate(0, -0.15F, 0);
|
||||
|
@ -175,7 +176,7 @@ public enum PonyTransformation {
|
|||
}
|
||||
}
|
||||
},
|
||||
YEARLING(Size.YEARLING, 0, 3.8F, 0.75F) {
|
||||
YEARLING(Sizes.YEARLING, 0, 3.8F, 0.75F) {
|
||||
@Override
|
||||
public void transform(IModel model, BodyPart part, MatrixStack stack) {
|
||||
if (model.getAttributes().isSwimming) stack.translate(0, -0.6F, 0);
|
||||
|
@ -211,7 +212,7 @@ public enum PonyTransformation {
|
|||
}
|
||||
};
|
||||
|
||||
private static final Map<Size, PonyTransformation> REGISTRY = Maps.newEnumMap(Size.class);
|
||||
private static final Map<Sizes, PonyTransformation> REGISTRY = Maps.newEnumMap(Sizes.class);
|
||||
|
||||
static {
|
||||
for (PonyTransformation i : values()) {
|
||||
|
@ -221,9 +222,9 @@ public enum PonyTransformation {
|
|||
|
||||
protected Vec3d riderOffset;
|
||||
|
||||
private final Size size;
|
||||
private final Sizes size;
|
||||
|
||||
PonyTransformation(Size size, float rX, float rY, float rZ) {
|
||||
PonyTransformation(Sizes size, float rX, float rY, float rZ) {
|
||||
this.size = size;
|
||||
riderOffset = new Vec3d(rX, rY, rZ);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import net.minecraft.util.math.MathHelper;
|
|||
|
||||
import com.minelittlepony.api.pony.IPonyData;
|
||||
import com.minelittlepony.api.pony.meta.Size;
|
||||
import com.minelittlepony.api.pony.meta.Sizes;
|
||||
import com.minelittlepony.api.pony.meta.Wearable;
|
||||
import com.minelittlepony.model.armour.IEquestrianArmour;
|
||||
|
||||
|
@ -64,7 +65,7 @@ public interface IModel extends ModelWithArms {
|
|||
* Returns true if the current model is a child or a child-like foal.
|
||||
*/
|
||||
default boolean isChild() {
|
||||
return getSize() == Size.FOAL;
|
||||
return getSize() == Sizes.FOAL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.minelittlepony.settings;
|
|||
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import com.minelittlepony.api.pony.meta.Size;
|
||||
import com.minelittlepony.api.pony.meta.Sizes;
|
||||
import com.minelittlepony.common.util.settings.JsonConfig;
|
||||
import com.minelittlepony.common.util.settings.Setting;
|
||||
|
||||
|
@ -12,7 +12,6 @@ import java.nio.file.Path;
|
|||
* Storage container for MineLP client settings.
|
||||
*/
|
||||
public class PonyConfig extends JsonConfig {
|
||||
|
||||
/**
|
||||
* Sets the pony level. Want MOAR PONEHS? Well here you go.
|
||||
*/
|
||||
|
@ -30,7 +29,7 @@ public class PonyConfig extends JsonConfig {
|
|||
/**
|
||||
* Debug override for pony sizes.
|
||||
*/
|
||||
public final Setting<Size> sizeOverride = value("sizeOverride", Size.UNSET);
|
||||
public final Setting<Sizes> sizeOverride = value("sizeOverride", Sizes.UNSET);
|
||||
|
||||
public PonyConfig(Path path) {
|
||||
super(path);
|
||||
|
|
Loading…
Reference in a new issue