Skip to content

Commit

Permalink
More features!
Browse files Browse the repository at this point in the history
  • Loading branch information
Mixces committed Mar 10, 2024
1 parent cefb31a commit fce792a
Show file tree
Hide file tree
Showing 33 changed files with 936 additions and 216 deletions.
4 changes: 3 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ pluginManagement {
mavenCentral()
gradlePluginPortal()
}
}
}

rootProject.name = "LegacyAnimations"
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@

import com.mixces.legacyanimations.config.LegacyAnimationsSettings;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.client.MinecraftClient;

public class LegacyAnimations implements ModInitializer {

@Override
public void onInitialize() {
LegacyAnimationsSettings.CONFIG.load();
ClientTickEvents.END_WORLD_TICK.register(world -> {
if (MinecraftClient.getInstance().player != null) {
MinecraftClient.getInstance().player.calculateDimensions();
}
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,42 +20,34 @@ public class LegacyAnimationsSettings {
.build())
.build();

@SerialEntry
public boolean punchDuringUsage = true;
@SerialEntry
public boolean oldSwordBlock = true; // TODO: this prevents an item in offhand (e.g., bow) from being used. Also causes to walk slow despite not actually blocking, may trigger ACs
@SerialEntry
public boolean blockWithShieldOnly = true; // this fixes the aforementioned issue by requiring a shield in offhand
@SerialEntry
public boolean hideShields = true;
@SerialEntry
public boolean hideShieldHotbar = true;
@SerialEntry
public boolean noCooldown = true;
@SerialEntry
public boolean oldSneaking = true;
@SerialEntry
public boolean oldWalking = true;
@SerialEntry
public boolean oldDeath = true;
@SerialEntry
public boolean oldSwim = true;
@SerialEntry
public boolean oldHearts = true;
@SerialEntry
public boolean oldDebug = true;
@SerialEntry
public boolean perspectiveCrosshair = true;
@SerialEntry
public boolean oldProjectiles = true;
@SerialEntry public boolean punchDuringUsage = true;
@SerialEntry public boolean oldSwordBlock = true; // TODO: this prevents an item in offhand (e.g., bow) from being used. Also causes to walk slow despite not actually blocking, may trigger ACs
@SerialEntry public boolean blockWithShieldOnly = true; // this fixes the aforementioned issue by requiring a shield in offhand
@SerialEntry public boolean hideShields = true;
@SerialEntry public boolean hideShieldHotbar = true;
@SerialEntry public boolean noCooldown = true;
@SerialEntry public boolean oldSneaking = true;
@SerialEntry public boolean oldWalking = true;
@SerialEntry public boolean oldDeath = true;
@SerialEntry public boolean oldSwim = true;
@SerialEntry public boolean oldHearts = true;
@SerialEntry public boolean oldDebug = true;
@SerialEntry public boolean perspectiveCrosshair = true;
@SerialEntry public boolean oldProjectiles = true;
@SerialEntry public boolean oldViewBob = true;
@SerialEntry public boolean noDropSwing = true;
@SerialEntry public boolean fastItems = true;
@SerialEntry public boolean armorTint = true;


@SuppressWarnings("deprecation")
public static Screen configScreen(Screen parent) {
return YetAnotherConfigLib.create(CONFIG, ((defaults, config, builder) -> builder
.title(Text.literal("Old Animations"))

.category(ConfigCategory.createBuilder()
.name(Text.literal("Old Animations"))
.name(Text.literal("Block-Hitting"))

.option(Option.createBuilder(boolean.class)
.name(Text.literal("Punching Blocks Whilst Using Items Animation"))
.description(OptionDescription.of(Text.of("Brings back the old block-hitting animation to swords/bows/consumable/blocks!")))
Expand Down Expand Up @@ -86,18 +78,51 @@ public static Screen configScreen(Screen parent) {
.binding(defaults.hideShieldHotbar, () -> config.hideShieldHotbar, newVal -> config.hideShieldHotbar = newVal)
.controller(TickBoxControllerBuilder::create)
.build())
.option(Option.createBuilder(boolean.class)
.name(Text.literal("Remove Swing Cooldown Animation"))
.description(OptionDescription.of(Text.of("Visually removes the swing cooldown animation!")))
.binding(defaults.noCooldown, () -> config.noCooldown, newVal -> config.noCooldown = newVal)
.controller(TickBoxControllerBuilder::create)
.build())
.build())

.category(ConfigCategory.createBuilder()
.name(Text.literal("Sneaking Mechanics"))

.option(Option.createBuilder(boolean.class)
.name(Text.literal("Old Sneaking Animation Descent"))
.description(OptionDescription.of(Text.of("Makes the descent of the sneaking animation faster than it's ascent.")))
.binding(defaults.oldSneaking, () -> config.oldSneaking, newVal -> config.oldSneaking = newVal)
.controller(TickBoxControllerBuilder::create)
.build())
.build())

.category(ConfigCategory.createBuilder()
.name(Text.literal("GUI Tweaks"))

.option(Option.createBuilder(boolean.class)
.name(Text.literal("Old Debug Menu"))
.description(OptionDescription.of(Text.of("Removes the background of the F3 menu text and uses text shadow instead.")))
.binding(defaults.oldDebug, () -> config.oldDebug, newVal -> config.oldDebug = newVal)
.controller(TickBoxControllerBuilder::create)
.build())
.option(Option.createBuilder(boolean.class)
.name(Text.literal("Old Health Flashing"))
.description(OptionDescription.of(Text.of("Brings back the old hotbar health flashing appearance.")))
.binding(defaults.oldHearts, () -> config.oldHearts, newVal -> config.oldHearts = newVal)
.controller(TickBoxControllerBuilder::create)
.build())
.option(Option.createBuilder(boolean.class)
.name(Text.literal("Third Person Mode Crosshair"))
.description(OptionDescription.of(Text.of("Brings back the crosshair in third person mode.")))
.binding(defaults.perspectiveCrosshair, () -> config.perspectiveCrosshair, newVal -> config.perspectiveCrosshair = newVal)
.controller(TickBoxControllerBuilder::create)
.build())
.build())

.category(ConfigCategory.createBuilder()
.name(Text.literal("Entity Animations"))

.option(Option.createBuilder(boolean.class)
.name(Text.literal("Armor Damage Tint"))
.description(OptionDescription.of(Text.of("Tints the armor while taking damage.")))
.binding(defaults.armorTint, () -> config.armorTint, newVal -> config.armorTint = newVal)
.controller(TickBoxControllerBuilder::create)
.build())
.option(Option.createBuilder(boolean.class)
.name(Text.literal("Old Backwards Walking Animation"))
.description(OptionDescription.of(Text.of("Reverts the backwards walking animation to it's former glory.")))
Expand All @@ -116,22 +141,27 @@ public static Screen configScreen(Screen parent) {
.binding(defaults.oldSwim, () -> config.oldSwim, newVal -> config.oldSwim = newVal)
.controller(TickBoxControllerBuilder::create)
.build())
.build())

.category(ConfigCategory.createBuilder()
.name(Text.literal("Miscellaneous"))

.option(Option.createBuilder(boolean.class)
.name(Text.literal("Old Debug Menu"))
.description(OptionDescription.of(Text.of("Removes the background of the F3 menu text and uses text shadow instead.")))
.binding(defaults.oldDebug, () -> config.oldDebug, newVal -> config.oldDebug = newVal)
.name(Text.literal("Remove Swing Cooldown Animation"))
.description(OptionDescription.of(Text.of("Removes the swing animation played when dropping/throwing items!")))
.binding(defaults.noDropSwing, () -> config.noDropSwing, newVal -> config.noDropSwing = newVal)
.controller(TickBoxControllerBuilder::create)
.build())
.option(Option.createBuilder(boolean.class)
.name(Text.literal("Old Health Flashing"))
.description(OptionDescription.of(Text.of("Brings back the old hotbar health flashing appearance.")))
.binding(defaults.oldHearts, () -> config.oldHearts, newVal -> config.oldHearts = newVal)
.name(Text.literal("Remove Swing Animation on Throwing Items"))
.description(OptionDescription.of(Text.of("Visually removes the swing cooldown animation!")))
.binding(defaults.noCooldown, () -> config.noCooldown, newVal -> config.noCooldown = newVal)
.controller(TickBoxControllerBuilder::create)
.build())
.option(Option.createBuilder(boolean.class)
.name(Text.literal("Third Person Mode Crosshair"))
.description(OptionDescription.of(Text.of("Brings back the crosshair in third person mode.")))
.binding(defaults.perspectiveCrosshair, () -> config.perspectiveCrosshair, newVal -> config.perspectiveCrosshair = newVal)
.name(Text.literal("Old View Bobbing"))
.description(OptionDescription.of(Text.of("Changes the held item's position while moving based on the player's yaw")))
.binding(defaults.oldViewBob, () -> config.oldViewBob, newVal -> config.oldViewBob = newVal)
.controller(TickBoxControllerBuilder::create)
.build())
.option(Option.createBuilder(boolean.class)
Expand All @@ -140,7 +170,14 @@ public static Screen configScreen(Screen parent) {
.binding(defaults.oldProjectiles, () -> config.oldProjectiles, newVal -> config.oldProjectiles = newVal)
.controller(TickBoxControllerBuilder::create)
.build())
.option(Option.createBuilder(boolean.class)
.name(Text.literal("Fast/2D Items"))
.description(OptionDescription.of(Text.of("Reverts the projectile's positions back to the older style.")))
.binding(defaults.fastItems, () -> config.fastItems, newVal -> config.fastItems = newVal)
.controller(TickBoxControllerBuilder::create)
.build())
.build())

)).generateScreen(parent);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.mixces.legacyanimations.duck;

public interface PlayerPitchInterface {

float legacyAnimations$getPrevPlayerPitch();

float legacyAnimations$getPlayerPitch();

}
13 changes: 13 additions & 0 deletions src/main/java/com/mixces/legacyanimations/hook/EntityHook.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.mixces.legacyanimations.hook;

import net.minecraft.entity.LivingEntity;

public class EntityHook {

public static LivingEntity entity;

public static boolean isEntityDying() {
return entity.deathTime > 0 || entity.hurtTime > 0;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.mixces.legacyanimations.mixin;

import com.mixces.legacyanimations.config.LegacyAnimationsSettings;
import com.mixces.legacyanimations.hook.EntityHook;
import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.entity.feature.ArmorFeatureRenderer;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(ArmorFeatureRenderer.class)
public abstract class ArmorFeatureRendererMixin {

@Redirect(
method = "renderArmorParts",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/render/RenderLayer;getArmorCutoutNoCull(Lnet/minecraft/util/Identifier;)Lnet/minecraft/client/render/RenderLayer;"
)
)
private RenderLayer useEntityLayerRenderer(Identifier texture) {
if (LegacyAnimationsSettings.CONFIG.instance().armorTint) {
return RenderLayer.getEntityCutoutNoCullZOffset(texture);
}
return RenderLayer.getArmorCutoutNoCull(texture);
}

@ModifyArg(
method = "renderArmorParts",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/render/entity/model/BipedEntityModel;render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;IIFFFF)V"
),
index = 3
)
private int useDamageUVOverlay(int par3) {
if (LegacyAnimationsSettings.CONFIG.instance().armorTint) {
return OverlayTexture.packUv(OverlayTexture.getU(0.0F), OverlayTexture.getV(EntityHook.isEntityDying()));
}
return par3;
}

}
Loading

0 comments on commit fce792a

Please sign in to comment.