Skip to content

Commit

Permalink
Beta 1.7.10.2502.0
Browse files Browse the repository at this point in the history
-Added Legacy Title Screen client mixin option
-Added Legacy4J Settings key mapping, with `Y` as default key
-Now, multiline edit boxes will have a LE-style and allow using the keyboard
-Now, the Add Album screen will allow description changes
-Fixed Loading Overlay screen not rendering correctly in versions +1.21.2
-Fixed Firework with incorrect texture format in versions +1.21.2
-Fixed mixin crash in versions forge/neoforge <=1.20.4
-Fixed Sword blocking being applied to the shield, and to the bow in versions +1.21.4
-Fixed `render_enchanted_book` UI Element Type not having an initial opening animation
  • Loading branch information
Wilyicaro committed Jan 14, 2025
1 parent 22c5499 commit 42b05a8
Show file tree
Hide file tree
Showing 19 changed files with 180 additions and 38 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx3072M
enabled_platforms=fabric,forge,neoforge

archives_base_name=Legacy4J
mod_version=1.7.10.2501.3
mod_version=1.7.10.2502.0
mod_id=legacy
mod_license=MIT
mod_name=Legacy4J
Expand All @@ -21,7 +21,7 @@ fabric_api_version=[VERSIONED]
forge_version=[VERSIONED]
neoforge_version=[VERSIONED]

factory_api_version=2.2.2501.23
factory_api_version=2.2.2501.24

sodium_version=mc1.21-0.6.0-beta.2-fabric
iris_version=1.8.0-beta.4+1.21-fabric
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/wily/legacy/Legacy4JClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ public static void displayEffectActivationAnimation(/*? if <1.20.5 {*//*MobEffec
}, Optional.of(WorldPresets.SINGLE_BIOME_SURFACE), (createWorldScreen, settings) -> new LegacyBuffetWorldScreen(createWorldScreen, settings.worldgenLoadContext().lookupOrThrow(Registries.BIOME), holder -> createWorldScreen.getUiState().updateDimensions(PresetEditor.fixedBiomeConfigurator(holder)))));

public static Screen getReplacementScreen(Screen screen){
if (!LegacyMixinOptions.legacyTitleScreen.get()) return screen;
if (screen instanceof JoinMultiplayerScreen)
return new PlayGameScreen(new TitleScreen(),2);
else if (screen instanceof DisconnectedScreen s)
Expand Down Expand Up @@ -321,6 +322,9 @@ public static void preTick(Minecraft minecraft){
while (keyHostOptions.consumeClick()) {
minecraft.setScreen(new HostOptionsScreen());
}
while (keyLegacy4JSettings.consumeClick()) {
minecraft.setScreen(new Legacy4JSettingsScreen(Minecraft.getInstance().screen));
}
boolean left;
while ((left=keyCycleHeldLeft.consumeClick()) || keyCycleHeldRight.consumeClick()){
if (minecraft.player != null) {
Expand Down Expand Up @@ -531,11 +535,13 @@ else if (minecraft.screen instanceof LeaderboardsScreen s){
public static final KeyMapping keyCycleHeldRight = new KeyMapping("legacy.key.cycleHeldRight", InputConstants.KEY_PAGEUP, "key.categories.inventory");
public static final KeyMapping keyToggleCursor = new KeyMapping("legacy.key.toggleCursor", -1, "key.categories.misc");
public static KeyMapping keyHostOptions = new KeyMapping( MOD_ID +".key.host_options", InputConstants.KEY_H, "key.categories.misc");
public static KeyMapping keyLegacy4JSettings = new KeyMapping( MOD_ID +".key.legacy4JSettings", InputConstants.KEY_Y, "key.categories.misc");
public static KeyMapping keyFlyUp = new KeyMapping( MOD_ID +".key.flyUp", InputConstants.KEY_UP, "key.categories.movement");
public static KeyMapping keyFlyDown = new KeyMapping( MOD_ID +".key.flyDown", InputConstants.KEY_DOWN, "key.categories.movement");
public static KeyMapping keyFlyLeft = new KeyMapping( MOD_ID +".key.flyLeft", InputConstants.KEY_LEFT, "key.categories.movement");
public static KeyMapping keyFlyRight = new KeyMapping( MOD_ID +".key.flyRight", InputConstants.KEY_RIGHT, "key.categories.movement");


public static void resetOptions(Minecraft minecraft){
whenResetOptions.forEach(Runnable::run);
for (KeyMapping keyMapping : minecraft.options.keyMappings) {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/wily/legacy/client/LegacyMixinOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class LegacyMixinOptions {
public static final LegacyConfig<Boolean> legacyBrewingStandScreen = CLIENT_MIXIN_STORAGE.register(LegacyConfig.createBoolean("legacy.mixin.base.client.brewing", ()-> new LegacyConfigDisplay<>("legacyBrewingStandScreen", b-> LegacyComponents.NEEDS_RESTART), true, b->{}, CLIENT_MIXIN_STORAGE));
public static final LegacyConfig<Boolean> legacyBookScreen = CLIENT_MIXIN_STORAGE.register(LegacyConfig.createBoolean("legacy.mixin.base.client.book", ()-> new LegacyConfigDisplay<>("legacyBookScreen", b-> LegacyComponents.NEEDS_RESTART), true, b->{}, CLIENT_MIXIN_STORAGE));
public static final LegacyConfig<Boolean> legacyCreateWorldScreen = CLIENT_MIXIN_STORAGE.register(LegacyConfig.createBoolean("legacy.mixin.base.client.create_world", ()-> new LegacyConfigDisplay<>("legacyCreateWorldScreen", b-> LegacyComponents.NEEDS_RESTART), true, b->{}, CLIENT_MIXIN_STORAGE));
public static final LegacyConfig<Boolean> legacyTitleScreen = CLIENT_MIXIN_STORAGE.register(LegacyConfig.createBoolean("legacy.mixin.base.client.title", ()-> new LegacyConfigDisplay<>("legacyTitleScreen", b-> LegacyComponents.NEEDS_RESTART), true, b->{}, CLIENT_MIXIN_STORAGE));
public static final LegacyConfig<Boolean> legacyGui = CLIENT_MIXIN_STORAGE.register(LegacyConfig.createBoolean("legacy.mixin.base.client.gui", ()-> new LegacyConfigDisplay<>("legacyGui", b-> LegacyComponents.NEEDS_RESTART), true, b->{}, CLIENT_MIXIN_STORAGE));
public static final LegacyConfig<Boolean> legacyChat = CLIENT_MIXIN_STORAGE.register(LegacyConfig.createBoolean("legacy.mixin.base.client.chat", ()-> new LegacyConfigDisplay<>("legacyChat", b-> LegacyComponents.NEEDS_RESTART), true, b->{}, CLIENT_MIXIN_STORAGE));
public static final LegacyConfig<Boolean> legacyBossHealth = CLIENT_MIXIN_STORAGE.register(LegacyConfig.createBoolean("legacy.mixin.base.client.bosshealth", ()-> new LegacyConfigDisplay<>("legacyBossHealth", b-> LegacyComponents.NEEDS_RESTART), true, b->{}, CLIENT_MIXIN_STORAGE));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/wily/legacy/client/LegacyOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public static <T> Function<T,Component> staticComponent(Component component){
public static final LegacyConfig<Integer> hudScale = CLIENT_STORAGE.register(createInteger("hudScale", Options::genericValueLabel, 1, ()->3, 2));
public static final LegacyConfig<Double> hudOpacity = CLIENT_STORAGE.register(createDouble("hudOpacity", LegacyOptions::percentValueLabel, 0.8));
public static final LegacyConfig<Double> hudDistance = CLIENT_STORAGE.register(createDouble("hudDistance", LegacyOptions::percentValueLabel, 1.0));
public static final LegacyConfig<Double> interfaceResolution = CLIENT_STORAGE.register(createDouble("interfaceResolution", (c, d)-> percentValueLabel(c, 0.25 + d * 1.5), 0.5, d -> Minecraft.getInstance().resizeDisplay()));
public static final LegacyConfig<Double> interfaceResolution = CLIENT_STORAGE.register(createDouble("interfaceResolution", (c, d)-> percentValueLabel(c, 0.25 + d * 1.5), 0.5, d -> Minecraft.getInstance().execute(Minecraft.getInstance()::resizeDisplay)));
public static final LegacyConfig<Double> interfaceSensitivity = CLIENT_STORAGE.register(createDouble("interfaceSensitivity", (c, d)-> percentValueLabel(c, d*2), 0.5, d -> {}));
public static final LegacyConfig<Double> controllerSensitivity = CLIENT_STORAGE.register(LegacyConfig.createDouble("controllerSensitivity", ArbitrarySupplier.of(new LegacyConfigDisplay<>(Component.translatable("options.sensitivity"))), (c, d)-> percentValueLabel(c, d*2), 0.5, d -> {}, CLIENT_STORAGE));
public static final LegacyConfig<Boolean> overrideTerrainFogStart = CLIENT_STORAGE.register(createBoolean("overrideTerrainFogStart", true));
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/wily/legacy/client/PackAlbum.java
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,15 @@ protected void addButtons() {
repeat++;
String id = TEMPLATE_ALBUM +(repeat > 0 ? "_" + repeat : "");
setSelectedIndex(albums.size());
EditBox nameBox = new EditBox(minecraft.font, width / 2 - 100,0,200, 20, Component.translatable("legacy.menu.album_name"));
EditBox nameBox = new EditBox(minecraft.font, width / 2 - 100,0,200, 20, Component.translatable("legacy.menu.album_info"));
Component description = Component.translatable("legacy.menu.albums.resource.template.description");
MultiLineEditBox descriptionBox = new MultiLineEditBox(minecraft.font, width / 2 - 100,0,200, 60, description, nameBox.getMessage());

Component name = Component.translatable("legacy.menu.albums.resource.template",repeat);
nameBox.setHint(name);
minecraft.setScreen(new ConfirmationScreen(parent, 230, 120, ADD_ALBUM, Component.translatable("legacy.menu.album_name"), p -> {
minecraft.setScreen(new ConfirmationScreen(parent, 230, 184, ADD_ALBUM, nameBox.getMessage(), p -> {
minecraft.setScreen(new PackSelectionScreen(packRepository, r -> {
PackAlbum.resourceAlbums.put(id,new PackAlbum(id, 0,nameBox.getValue().isBlank() ? name : Component.literal(nameBox.getValue()),Component.translatable("legacy.menu.albums.resource.template.description"),Optional.empty(),Optional.empty(), getSelectableIds(packRepository), Optional.empty()));
PackAlbum.resourceAlbums.put(id,new PackAlbum(id, 0,nameBox.getValue().isBlank() ? name : Component.literal(nameBox.getValue()), descriptionBox.getValue().isBlank() ? description : Component.literal(descriptionBox.getValue()),Optional.empty(),Optional.empty(), getSelectableIds(packRepository), Optional.empty()));
save();
updateSavedAlbum();
minecraft.setScreen(screen);
Expand All @@ -368,11 +371,13 @@ protected void init() {
super.init();
nameBox.setPosition(panel.x + 15, panel.y + 45);
addRenderableWidget(nameBox);
descriptionBox.setPosition(panel.x + 15, panel.y + 69);
addRenderableWidget(descriptionBox);
}
});
}).build());
AbstractButton removeButton;
renderableVList.addRenderable(removeButton= Button.builder(REMOVE_ALBUM, b-> {
renderableVList.addRenderable(removeButton = Button.builder(REMOVE_ALBUM, b-> {
albums.remove(getSelectedAlbum().id());
save();
updateSavedAlbum();
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/wily/legacy/init/LegacyUIElementTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.client.gui.components.Renderable;
import net.minecraft.client.gui.layouts.LayoutElement;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.gui.screens.inventory.EnchantmentScreen;
import net.minecraft.client.model.BookModel;
import net.minecraft.client.model.geom.ModelLayers;
import net.minecraft.client.model.geom.ModelPart;
Expand Down Expand Up @@ -148,7 +149,8 @@ public ArbitrarySupplier<ResourceLocation> getIconHolderOverride() {
a.getElement(elementName + ".component", Component.class).ifPresent((c) -> ScreenUtil.drawOutlinedString(guiGraphics ,Minecraft.getInstance().font, c, a.getInteger(elementName + ".x", 0), a.getInteger(elementName + ".y", 0), a.getInteger(elementName + ".color", 16777215), a.getInteger(elementName + ".outlineColor", 0), a.getFloat(elementName + ".outline", 0.5f)));
}))));
}));
public static final UIDefinitionManager.ElementType RENDER_ENCHANTMENT_BOOK = UIDefinitionManager.ElementType.registerConditional("render_enchanted_book", UIDefinitionManager.ElementType.createIndexable(slots->(uiDefinition, accessorFunction, elementName, element) -> {

public static final UIDefinitionManager.ElementType RENDER_ENCHANTED_BOOK = UIDefinitionManager.ElementType.registerConditional("render_enchanted_book", UIDefinitionManager.ElementType.createIndexable(slots->(uiDefinition, accessorFunction, elementName, element) -> {
Bearer<BookModel> bookModel = Bearer.of(null);
Bearer<Float> flip = Bearer.of(0f);
Bearer<Float> oFlip = Bearer.of(0f);
Expand Down Expand Up @@ -177,14 +179,15 @@ public ArbitrarySupplier<ResourceLocation> getIconHolderOverride() {
flipT.set(flipT.get() + (float)(random.nextInt(4) - random.nextInt(4)));
} while(flip.get() <= flipT.get() + 1.0F && flip.get() >= flipT.get() - 1.0F);
}

oFlip.set(flip.get());
oOpen.set(open.get());
open.set(open.get() - 0.2F);
open.set(open.get() + 0.2F);

open.set(Mth.clamp(open.get(), 0.0F, 1.0F));
float f1 = (flipT.get() - flip.get()) * 0.4F;
f1 = Mth.clamp(f1, -0.2F, 0.2F);
flipA.set(flipA.get()+ (f1 - flipA.get()) * 0.9F);
flipA.set(flipA.get() + (f1 - flipA.get()) * 0.9F);
flip.set(flip.get() + flipA.get());
}));
UIDefinitionManager.ElementType.parseTranslationElements(uiDefinition, elementName, element);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package wily.legacy.mixin.base;

import net.minecraft.client.gui.GuiGraphics;
//? if <1.21.4 {
import net.minecraft.client.gui.components.AbstractScrollWidget;
//?} else {
/*import net.minecraft.client.gui.components.AbstractTextAreaWidget;
*///?}
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.network.chat.Component;
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.CallbackInfo;
import wily.factoryapi.base.client.FactoryGuiGraphics;
import wily.legacy.util.LegacySprites;

@Mixin(/*? if <1.21.4 {*/AbstractScrollWidget/*?} else {*//*AbstractTextAreaWidget*//*?}*/.class)
public abstract class AbstractScrollWidgetMixin extends AbstractWidget {

public AbstractScrollWidgetMixin(int i, int j, int k, int l, Component component) {
super(i, j, k, l, component);
}

@Inject(method = "renderBorder", at = @At("HEAD"), cancellable = true)
private void renderBorder(GuiGraphics guiGraphics, int i, int j, int k, int l, CallbackInfo ci){
FactoryGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.TEXT_FIELD, i, j, k, l);
if (isHoveredOrFocused())
FactoryGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.HIGHLIGHTED_TEXT_FIELD, i - 1, j - 1, k + 2, l + 2);
ci.cancel();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,19 @@ private void applyItemTransforms(PoseStack poseStack, float h, HumanoidArm human
this.applyItemArmAttackTransform(poseStack, humanoidArm, h);
}

//? if <1.21.4 {
@Inject(method = "renderArmWithItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/ItemInHandRenderer;applyItemArmTransform(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/world/entity/HumanoidArm;F)V", shift = At.Shift.AFTER, ordinal = 4))
private void renderArmWithItemBlockAnim(AbstractClientPlayer abstractClientPlayer, float f, float g, InteractionHand interactionHand, float h, ItemStack itemStack, float i, PoseStack poseStack, MultiBufferSource multiBufferSource, int j, CallbackInfo ci) {
if (LegacyConfig.hasCommonConfigEnabled(LegacyConfig.legacySwordBlocking)) {
if (LegacyConfig.hasCommonConfigEnabled(LegacyConfig.legacySwordBlocking) && !(itemStack.getItem() instanceof ShieldItem)) {
boolean bl = interactionHand == InteractionHand.MAIN_HAND;
HumanoidArm humanoidArm = bl ? abstractClientPlayer.getMainArm() : abstractClientPlayer.getMainArm().getOpposite();
int q = humanoidArm == HumanoidArm.RIGHT ? 1 : -1;
this.applyItemArmAttackTransform(poseStack, humanoidArm, h);
poseStack.translate(-0.14142136F, 0.08F, 0.14142136F);
poseStack.mulPose(Axis.XP.rotationDegrees(-102.25F));
poseStack.mulPose(Axis.YP.rotationDegrees(13.365F));
poseStack.mulPose(Axis.ZP.rotationDegrees(78.05F));

poseStack.mulPose(Axis.YP.rotationDegrees((float)q * 13.365F));
poseStack.mulPose(Axis.ZP.rotationDegrees((float)q * 78.05F));
}
}
//?}
}
7 changes: 2 additions & 5 deletions src/main/java/wily/legacy/mixin/base/LoadingOverlayMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,14 @@ public void render(GuiGraphics guiGraphics, int i, int j, float f, CallbackInfo
if (timer % INTROS.size() >= INTROS.size() - 0.01f) finishedIntro = true;

guiGraphics.fill(RenderType.guiOverlay(), 0, 0, guiGraphics.guiWidth(), guiGraphics.guiHeight(), 0xFFFFFFFF);
//? if <1.21.2 {

FactoryGuiGraphics.of(guiGraphics).blit(BACKGROUND, 0, 0,0,0, guiGraphics.guiWidth(), guiGraphics.guiHeight(),guiGraphics.guiWidth(), guiGraphics.guiHeight());
//?}

RenderSystem.enableBlend();
float last = (float) Math.ceil(timer) - timer;
FactoryGuiGraphics.of(guiGraphics).setColor(1.0f, 1.0f, 1.0f, last <= 0.4f ? last * 2.5f : last > 0.6f ? (1 - last) * 2.5f : 1.0f);
FactoryGuiGraphics.of(guiGraphics).blit(INTROS.get((int) (timer % INTROS.size())), (guiGraphics.guiWidth() - guiGraphics.guiHeight() * 320 / 180) / 2, 0, 0, 0, guiGraphics.guiHeight() * 320 / 180, guiGraphics.guiHeight(), guiGraphics.guiHeight() * 320 / 180, guiGraphics.guiHeight());
FactoryGuiGraphics.of(guiGraphics).clearColor();
//? if >=1.21.2 {
/*FactoryGuiGraphics.of(guiGraphics).blit(BACKGROUND, 0, 0,0,0, guiGraphics.guiWidth(), guiGraphics.guiHeight(),guiGraphics.guiWidth(), guiGraphics.guiHeight());
*///?}
RenderSystem.disableBlend();
}

Expand Down
Loading

0 comments on commit 42b05a8

Please sign in to comment.