mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-29 07:27:59 +01:00
Added fillycam
This commit is contained in:
parent
8157655434
commit
f3f980d6c3
9 changed files with 120 additions and 9 deletions
|
@ -0,0 +1,36 @@
|
|||
package com.minelittlepony.client.mixin;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import com.minelittlepony.MineLittlePony;
|
||||
import com.minelittlepony.pony.IPony;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.Camera;
|
||||
|
||||
@Mixin(Camera.class)
|
||||
public abstract class MixinCamera {
|
||||
|
||||
// cameraDistance;
|
||||
// float field_18721;
|
||||
// prevCameraDistance;
|
||||
// float field_18722;
|
||||
|
||||
@Inject(method = "method_19318(D)D",
|
||||
at = @At("RETURN"),
|
||||
cancellable = true)
|
||||
private void redirectCameraDistance(double initial, CallbackInfoReturnable<Double> info) {
|
||||
double value = info.getReturnValueD();
|
||||
|
||||
IPony pony = MineLittlePony.getInstance().getManager().getPony(MinecraftClient.getInstance().player);
|
||||
|
||||
if (!pony.getRace(false).isHuman()) {
|
||||
value *= pony.getMetadata().getSize().getEyeDistanceFactor();
|
||||
}
|
||||
|
||||
info.setReturnValue(value);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.minelittlepony.client.mixin;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import com.minelittlepony.MineLittlePony;
|
||||
import com.minelittlepony.pony.IPony;
|
||||
|
||||
import net.minecraft.entity.EntityPose;
|
||||
import net.minecraft.entity.EntitySize;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
||||
@Mixin(PlayerEntity.class)
|
||||
public abstract class MixinPlayerEntity extends LivingEntity {
|
||||
|
||||
private MixinPlayerEntity() {super(null, null);}
|
||||
|
||||
@Inject(method = "getActiveEyeHeight(Lnet/minecraft/entity/EntityPose;Lnet/minecraft/entity/EntitySize;)F",
|
||||
at = @At("RETURN"),
|
||||
cancellable = true)
|
||||
protected void redirectGetActiveEyeHeight(EntityPose pose, EntitySize size, CallbackInfoReturnable<Float> info) {
|
||||
float value = info.getReturnValueF();
|
||||
|
||||
IPony pony = MineLittlePony.getInstance().getManager().getPony((PlayerEntity)(Object)this);
|
||||
|
||||
if (!pony.getRace(false).isHuman()) {
|
||||
value *= pony.getMetadata().getSize().getEyeHeightFactor();
|
||||
}
|
||||
|
||||
info.setReturnValue(value);
|
||||
}
|
||||
}
|
|
@ -35,7 +35,6 @@ import net.minecraft.util.math.Vec3d;
|
|||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
|
@ -91,7 +90,12 @@ public class Pony extends Touchable<Pony> implements IPony {
|
|||
}
|
||||
|
||||
@Nullable
|
||||
public static NativeImage getBufferedImage(@Nonnull Identifier resource) {
|
||||
public static NativeImage getBufferedImage(@Nullable Identifier resource) {
|
||||
|
||||
if (resource == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
Resource skin = MinecraftClient.getInstance().getResourceManager().getResource(resource);
|
||||
NativeImage skinImage = NativeImage.fromInputStream(skin.getInputStream());
|
||||
|
|
|
@ -65,6 +65,10 @@ public class PonyManager implements IPonyManager, ResourceReloadListener, ISkinC
|
|||
|
||||
@Override
|
||||
public IPony getPony(PlayerEntity player) {
|
||||
if (player == null || player.getGameProfile() == null) {
|
||||
return getDefaultPony(player.getUuid());
|
||||
}
|
||||
|
||||
Identifier skin = getSkin(player);
|
||||
UUID uuid = player.getGameProfile().getId();
|
||||
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package com.minelittlepony.client.settings;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
||||
import com.minelittlepony.client.render.entities.MobRenderers;
|
||||
import com.minelittlepony.hdskins.HDSkins;
|
||||
import com.minelittlepony.settings.PonyConfig;
|
||||
|
@ -20,4 +23,13 @@ public class ClientPonyConfig extends PonyConfig {
|
|||
|
||||
super.setPonyLevel(ponylevel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
super.save();
|
||||
PlayerEntity player = MinecraftClient.getInstance().player;
|
||||
if (player != null) {
|
||||
player.refreshSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,22 +5,24 @@ import com.minelittlepony.pony.ITriggerPixelMapped;
|
|||
import com.minelittlepony.settings.PonySettings;
|
||||
|
||||
public enum Size implements ITriggerPixelMapped<Size> {
|
||||
TALL (0x764b53, 0.45f, 1.1F),
|
||||
BULKY (0x5432ce, 0.5f, 1),
|
||||
LANKY (0xce5432, 0.45F, 0.85F),
|
||||
NORMAL (0x000000, 0.4f, 0.8F),
|
||||
YEARLING(0xffbe53, 0.4F, 0.6F),
|
||||
FOAL (0x53beff, 0.25f, 0.6F);
|
||||
TALL (0x764b53, 0.45f, 1.1F, 1.15F),
|
||||
BULKY (0x5432ce, 0.5f, 1, 1.05F),
|
||||
LANKY (0xce5432, 0.45F, 0.85F, 0.9F),
|
||||
NORMAL (0x000000, 0.4f, 0.8F, 0.8F),
|
||||
YEARLING(0xffbe53, 0.4F, 0.6F, 0.65F),
|
||||
FOAL (0x53beff, 0.25f, 0.6F, 0.5F);
|
||||
|
||||
private int triggerValue;
|
||||
|
||||
private float shadowSize;
|
||||
private float scale;
|
||||
private float camera;
|
||||
|
||||
Size(int pixel, float shadowSz, float scaleF) {
|
||||
Size(int pixel, float shadowSz, float scaleF, float cameraF) {
|
||||
triggerValue = pixel;
|
||||
shadowSize = shadowSz;
|
||||
scale = scaleF;
|
||||
camera = cameraF;
|
||||
}
|
||||
|
||||
public float getShadowSize() {
|
||||
|
@ -31,6 +33,20 @@ public enum Size implements ITriggerPixelMapped<Size> {
|
|||
return scale * MineLittlePony.getInstance().getConfig().getGlobalScaleFactor();
|
||||
}
|
||||
|
||||
public float getEyeHeightFactor() {
|
||||
if (!PonySettings.FILLYCAM.get()) {
|
||||
return 1;
|
||||
}
|
||||
return camera * MineLittlePony.getInstance().getConfig().getGlobalScaleFactor();
|
||||
}
|
||||
|
||||
public float getEyeDistanceFactor() {
|
||||
if (!PonySettings.FILLYCAM.get()) {
|
||||
return 1;
|
||||
}
|
||||
return camera * MineLittlePony.getInstance().getConfig().getGlobalScaleFactor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTriggerPixel() {
|
||||
return triggerValue;
|
||||
|
|
|
@ -10,6 +10,7 @@ public enum PonySettings implements Setting<Boolean> {
|
|||
SIZES,
|
||||
SNUZZLES,
|
||||
HD,
|
||||
FILLYCAM,
|
||||
SHOWSCALE,
|
||||
FPSMAGIC,
|
||||
PONYSKULLS,
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
"minelp.options.hd": "Enable MineLP skin server",
|
||||
"minelp.options.sizes": "Allow all different sizes of pony",
|
||||
"minelp.options.snuzzles": "Display snuzzles on ponies",
|
||||
"minelp.options.fillycam": "Enable Filly Cam",
|
||||
"minelp.options.showscale": "Use show-accurate scaling",
|
||||
"minelp.options.fpsmagic": "Ponies use magic in first-person",
|
||||
"minelp.options.ponyskulls": "Render mob heads as ponies",
|
||||
|
|
|
@ -6,10 +6,12 @@
|
|||
"compatibilityLevel": "JAVA_8",
|
||||
"client": [
|
||||
"IResizeable",
|
||||
"MixinCamera",
|
||||
"MixinDefaultPlayerSkin",
|
||||
"MixinFirstPersonRenderer",
|
||||
"MixinGlStateManager",
|
||||
"MixinItemRenderer",
|
||||
"MixinPlayerEntity",
|
||||
"MixinThreadDownloadImageData"
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue