Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compat with latest malilib #146

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ mod.version=4.0
## Annotation processor
dependencies.lombok_version=1.18.34
## MagicLib
dependencies.magiclib_dependency=0.8.635
dependencies.magiclib_version=0.8.635-beta
dependencies.magiclib_dependency=0.8.655
dependencies.magiclib_version=0.8.655-beta

# Gradle Plugins
architectury_loom_version=1.7-SNAPSHOT
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.plusls.MasaGadget.api.fake.mod_tweak.malilib.favoritesSupport;

import org.jetbrains.annotations.ApiStatus;

@ApiStatus.Internal
public interface GuiBaseInjector {
default void masa_gadget_mod$addFastSwitcherWidget() {
}

default void masa_gadget_mod$addFavoritesWidget() {
}
}
1 change: 1 addition & 0 deletions src/main/java/com/plusls/MasaGadget/game/Configs.java
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ public static void init() {
});

// Malilib
Configs.fastSwitchMasaConfigGui.setValueChangeCallback(Configs::redrawConfigGui);
Configs.favoritesSupport.setValueChangeCallback(Configs::redrawConfigGui);
Configs.showOriginalConfigName.setValueChangeCallback(Configs::redrawConfigGui);
Configs.showOriginalConfigNameScale.setValueChangeCallback(Configs::redrawConfigGui);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.plusls.MasaGadget.mixin.mod_tweak.common;

import com.plusls.MasaGadget.api.fake.mod_tweak.malilib.favoritesSupport.GuiBaseInjector;
import fi.dy.masa.malilib.gui.GuiBase;
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;

@Mixin(value = GuiBase.class, remap = false)
public abstract class MixinGuiBase implements GuiBaseInjector {
@Inject(method = "initGui", at = @At("RETURN"))
private void handleInitGui(CallbackInfo ci) {
this.masa_gadget_mod$addFastSwitcherWidget();
this.masa_gadget_mod$addFavoritesWidget();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.plusls.MasaGadget.mixin.mod_tweak.malilib.fastSwitchMasaConfigGui;

import com.plusls.MasaGadget.api.fake.mod_tweak.malilib.favoritesSupport.GuiBaseInjector;
import com.plusls.MasaGadget.game.Configs;
import com.plusls.MasaGadget.api.gui.MasaGadgetDropdownList;
import com.plusls.MasaGadget.impl.mod_tweak.malilib.fastSwitchMasaConfigGui.FastMasaGuiSwitcher;
Expand All @@ -12,17 +13,16 @@
import fi.dy.masa.malilib.interfaces.IStringValue;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import top.hendrixshen.magiclib.api.dependency.DependencyType;
import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies;
import top.hendrixshen.magiclib.api.dependency.annotation.Dependency;
import top.hendrixshen.magiclib.api.platform.PlatformType;
import top.hendrixshen.magiclib.impl.malilib.config.gui.SelectorDropDownList;

//#if MC > 11902
//$$ import org.spongepowered.asm.mixin.Intrinsic;
//#if MC > 12006
//$$ import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
//$$ import fi.dy.masa.malilib.gui.widgets.WidgetBase;
//$$ import org.spongepowered.asm.mixin.injection.At;
//#endif

//#if MC > 11904
Expand All @@ -40,25 +40,16 @@
)
@Dependencies(require = @Dependency(dependencyType = DependencyType.PLATFORM, platformType = PlatformType.FORGE_LIKE))
@Mixin(value = GuiConfigsBase.class, remap = false)
public abstract class MixinGuiConfigBase extends GuiListBase<GuiConfigsBase.ConfigOptionWrapper, WidgetConfigOption, WidgetListConfigOptions> implements MasaGadgetDropdownList {
public abstract class MixinGuiConfigBase extends GuiListBase<GuiConfigsBase.ConfigOptionWrapper, WidgetConfigOption, WidgetListConfigOptions> implements MasaGadgetDropdownList, GuiBaseInjector {
protected MixinGuiConfigBase(int listX, int listY) {
super(listX, listY);
}

@Unique
private SelectorDropDownList<IStringValue> masa_gadget$masaModGuiList;

//#if MC > 11902
//$$ //@Intrinsic
//$$ //@Override
//$$ //public void initGui() {
//$$ // super.initGui();
//$$ //}
//$$
//$$ @SuppressWarnings({"MixinAnnotationTarget", "UnresolvedMixinReference"})
//#endif
@Inject(method = "initGui", at = @At("RETURN"))
public void postInitGui(CallbackInfo ci) {
@Override
public void masa_gadget_mod$addFastSwitcherWidget() {
if (Configs.fastSwitchMasaConfigGui.getBooleanValue()) {
this.masa_gadget$masaModGuiList = new SelectorDropDownList<>(
this.width - 111, 10, 100, 16, 200, 5,
Expand Down Expand Up @@ -105,4 +96,18 @@ public void postInitGui(CallbackInfo ci) {
//#endif
);
}

//#if MC > 12006
//$$ // Force blocking malilib's intrinsic dropdown list
//$$ @WrapWithCondition(
//$$ method = "initGui",
//$$ at = @At(
//$$ value = "INVOKE",
//$$ target = "Lfi/dy/masa/malilib/gui/GuiConfigsBase;addWidget(Lfi/dy/masa/malilib/gui/widgets/WidgetBase;)Lfi/dy/masa/malilib/gui/widgets/WidgetBase;"
//$$ )
//$$ )
//$$ private boolean blockInherentDropdownList(GuiConfigsBase instance, WidgetBase widgetBase) {
//$$ return !Configs.fastSwitchMasaConfigGui.getBooleanValue();
//$$ }
//#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package com.plusls.MasaGadget.mixin.mod_tweak.malilib.fastSwitchMasaConfigGui;

import com.plusls.MasaGadget.api.gui.MasaGadgetDropdownList;
import com.plusls.MasaGadget.game.Configs;
import com.plusls.MasaGadget.util.ModId;
import fi.dy.masa.malilib.gui.GuiConfigsBase;
import fi.dy.masa.malilib.gui.widgets.WidgetListBase;
Expand Down Expand Up @@ -93,7 +94,9 @@ public abstract class MixinWidgetListBase<TYPE, WIDGET extends WidgetListEntryBa

@Inject(method = "drawContents", at = @At("HEAD"))
private void drawMagicConfigGuiDropDownListSetFlag(CallbackInfo ci) {
this.masa_gadget_mod$shouldRenderMagicConfigGuiDropDownList = true;
if (Configs.fastSwitchMasaConfigGui.getBooleanValue()) {
this.masa_gadget_mod$shouldRenderMagicConfigGuiDropDownList = true;
}
}

//#if MC < 11904
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.plusls.MasaGadget.mixin.mod_tweak.malilib.favoritesSupport;

import com.plusls.MasaGadget.SharedConstants;
import com.plusls.MasaGadget.api.fake.mod_tweak.malilib.favoritesSupport.GuiBaseInjector;
import com.plusls.MasaGadget.game.Configs;
import com.plusls.MasaGadget.impl.mod_tweak.malilib.favoritesSupport.MalilibFavoritesButton;
import com.plusls.MasaGadget.impl.mod_tweak.malilib.favoritesSupport.MalilibFavoritesData;
Expand All @@ -9,39 +10,24 @@
import fi.dy.masa.malilib.gui.widgets.WidgetConfigOption;
import fi.dy.masa.malilib.gui.widgets.WidgetListConfigOptions;
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 top.hendrixshen.magiclib.api.i18n.I18n;
import top.hendrixshen.magiclib.util.collect.ValueContainer;

//#if MC > 11902
//$$ import org.spongepowered.asm.mixin.Intrinsic;
//#endif

@Mixin(value = GuiConfigsBase.class, remap = false, priority = 1100)
public abstract class MixinGuiConfigBase extends GuiListBase<GuiConfigsBase.ConfigOptionWrapper, WidgetConfigOption, WidgetListConfigOptions> {
public abstract class MixinGuiConfigBase extends GuiListBase<GuiConfigsBase.ConfigOptionWrapper, WidgetConfigOption, WidgetListConfigOptions> implements GuiBaseInjector {
protected MixinGuiConfigBase(int listX, int listY) {
super(listX, listY);
}

//#if MC > 11902
//$$ @Intrinsic
//$$ @Override
//$$ public void initGui() {
//$$ super.initGui();
//$$ }
//$$
//$$ @SuppressWarnings({"MixinAnnotationTarget", "UnresolvedMixinReference"})
//#endif
@Inject(method = "initGui", at = @At("RETURN"))
public void postInitGui(CallbackInfo ci) {
@Override
public void masa_gadget_mod$addFavoritesWidget() {
if (!Configs.favoritesSupport.getBooleanValue()) {
return;
}

int xOffset = Configs.fastSwitchMasaConfigGui.getBooleanValue() ? 132 : 28;
MalilibFavoritesButton favoritesButton = MalilibFavoritesButton.create(
this.width - 132, 10, MalilibFavoritesData.getInstance().isFilterSwitch(),
this.width - xOffset, 10, MalilibFavoritesData.getInstance().isFilterSwitch(),
status -> {
MalilibFavoritesData.getInstance().setFilterSwitch(status);
ValueContainer.ofNullable(this.getListWidget()).ifPresent(w -> {
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/masa_gadget_mod.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"feature.cacheContainerMenu.MixinClientPacketListener",
"feature.cacheContainerMenu.MixinLocalPlayer",
"feature.cacheContainerMenu.MixinMultiPlayerGameMode",
"mod_tweak.common.MixinGuiBase",
"mod_tweak.litematica.betterEasyPlaceMode.MixinWorldUtils",
"mod_tweak.litematica.disableLitematicaEasyPlaceFailTip.MixinWorldUtils",
"mod_tweak.litematica.fixCarpetAccurateProtocol.MixinBlockItem",
Expand Down
31 changes: 18 additions & 13 deletions versions/1.14.4-fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,26 @@ repositories {
mavenCentral()
}

String itemscroller_fabric_ga = project.getProperties().getOrDefault("dependencies.api.itemscroller_version.use_sakura_fork", false) ?
"com.github.sakura-ryoko:itemscroller" : "maven.modrinth:item-scroller"
String litematica_fabric_ga = project.getProperties().getOrDefault("dependencies.api.litematica_version.use_sakura_fork", false) ?
"com.github.sakura-ryoko:litematica" : "maven.modrinth:litematica"
String minihud_fabric_ga = project.getProperties().getOrDefault("dependencies.api.minihud_version.use_sakura_fork", false) ?
"com.github.sakura-ryoko:minihud" : "maven.modrinth:minihud"
String tweakeroo_fabric_ga = project.getProperties().getOrDefault("dependencies.api.tweakeroo_version.use_sakura_fork", false) ?
"com.github.sakura-ryoko:tweakeroo" : "maven.modrinth:tweakeroo"

// Module, Property prefix, Resolve condition, Transitive dependencies.
def apiDependencies = [
["maven.modrinth:rocknroller" , "itemscroller", forgeLike , false],
["maven.modrinth:forgematica" , "litematica" , forgeLike , false],
["maven.modrinth:bocchud" , "minihud" , forgeLike , false],
["maven.modrinth:tweakerge" , "tweakeroo" , forgeLike , false],
["com.github.sakura-ryoko:itemscroller" , "itemscroller", fabricLike && mcVersion > 12101, false],
["com.github.sakura-ryoko:litematica" , "litematica" , fabricLike && mcVersion > 12101, false],
["com.github.sakura-ryoko:minihud" , "minihud" , fabricLike && mcVersion > 12101, false],
["com.github.sakura-ryoko:tweakeroo" , "tweakeroo" , fabricLike && mcVersion > 12101, false],
["maven.modrinth:item-scroller" , "itemscroller", fabricLike && mcVersion < 12102, false],
["maven.modrinth:litematica" , "litematica" , fabricLike && mcVersion < 12102, false],
["maven.modrinth:minihud" , "minihud" , fabricLike && mcVersion < 12102, false],
["maven.modrinth:tweakeroo" , "tweakeroo" , fabricLike && mcVersion < 12102, false],
["org.sinytra.forgified-fabric-api:forgified-fabric-api", "fabric_api" , forgeLike , true]
["maven.modrinth:rocknroller" , "itemscroller", forgeLike , false],
["maven.modrinth:forgematica" , "litematica" , forgeLike , false],
["maven.modrinth:bocchud" , "minihud" , forgeLike , false],
["maven.modrinth:tweakerge" , "tweakeroo" , forgeLike , false],
[itemscroller_fabric_ga , "itemscroller", fabricLike, false],
[litematica_fabric_ga , "litematica" , fabricLike, false],
[minihud_fabric_ga , "minihud" , fabricLike, false],
[tweakeroo_fabric_ga , "tweakeroo" , fabricLike, false],
["org.sinytra.forgified-fabric-api:forgified-fabric-api", "fabric_api" , forgeLike , true]
]

// Module, Property prefix, Resolve condition, Transitive dependencies.
Expand Down
8 changes: 4 additions & 4 deletions versions/1.21.1-fabric/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ dependencies.minecraft_dependency=>=1.21- <1.21.2-
dependencies.minecraft_version=1.21.1

# Compatible Libraries
dependencies.api.itemscroller_version=0.24.50
dependencies.api.litematica_version=0.19.50
dependencies.api.minihud_version=0.32.50
dependencies.api.tweakeroo_version=0.21.50
dependencies.api.itemscroller_version=0.24.55
dependencies.api.litematica_version=0.19.54
dependencies.api.minihud_version=0.32.56
dependencies.api.tweakeroo_version=0.21.56

# Publish properties
publish.game_version=1.21,1.21.1
Expand Down
8 changes: 4 additions & 4 deletions versions/1.21.1-neoforge/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ dependencies.minecraft_version=1.21.1
dependencies.api.fabric_api_version=0.104.0+2.0.14+1.21.1

# Compatible Libraries
dependencies.api.itemscroller_version=0.1.8-mc1.21.1
dependencies.api.litematica_version=0.1.11-mc1.21.1
dependencies.api.minihud_version=0.1.8-mc1.21.1
dependencies.api.tweakeroo_version=0.1.7-mc1.21.1
dependencies.api.itemscroller_version=0.1.9-mc1.21.1
dependencies.api.litematica_version=0.1.14-mc1.21.1
dependencies.api.minihud_version=0.1.11-mc1.21.1
dependencies.api.tweakeroo_version=0.1.9-mc1.21.1

# Loom Properties
loom.platform=neoforge
Expand Down
8 changes: 4 additions & 4 deletions versions/1.21.3-fabric/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ dependencies.minecraft_dependency=>=1.21.2- <1.21.4-
dependencies.minecraft_version=1.21.3

# Compatible Libraries
dependencies.api.itemscroller_version=1.21.3-0.25.0-sakura.2
dependencies.api.litematica_version=1.21.3-0.20.0-sakura.2
dependencies.api.minihud_version=1.21.3-0.33.0-sakura.2
dependencies.api.tweakeroo_version=b105ff1
dependencies.api.itemscroller_version=0.25.2
dependencies.api.litematica_version=0.20.3
dependencies.api.minihud_version=0.33.5
dependencies.api.tweakeroo_version=0.22.3

# Publish properties
publish.game_version=1.21.2,1.21.3
Expand Down