diff --git a/build.gradle.kts b/build.gradle.kts index 5ade07876..28ff89ddf 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,6 +8,7 @@ val loaderVersion: String by properties val javaVersion: String by properties val fabricApiVersion: String by properties +val fabricAsmVersion: String by properties val customportalapiVersion: String by properties val cardinalComponentsVersion: String by properties val trinketsVersion: String by properties @@ -120,6 +121,12 @@ dependencies { version = customportalapiVersion, ).also(::include).exclude(module = "sodium") + modImplementation( + group = "com.github.Chocohead", + name = "Fabric-ASM", + version = fabricAsmVersion, + ).also(::include) + modImplementation( group = "net.fabricmc.fabric-api", name = "fabric-api", @@ -149,12 +156,6 @@ dependencies { version = cardinalComponentsVersion, ) - modRuntimeOnly( - group = "com.terraformersmc", - name = "modmenu", - version = modmenuVersion, - ) - } diff --git a/gradle.properties b/gradle.properties index 03ec37c24..a333843fb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,5 +14,5 @@ cardinalComponentsVersion=5.1.0 trinketsVersion=3.6.0 crowdinTranslateVersion=1.19.4 entityAttributesVersion=2.3.2 -modmenuVersion=6.3.1 clothConfigVersion=10.1.117 +fabricAsmVersion=2.3 diff --git a/src/main/java/net/id/paradiselost/items/ParadiseLostItems.java b/src/main/java/net/id/paradiselost/items/ParadiseLostItems.java index c36ae5f2e..534f5393e 100644 --- a/src/main/java/net/id/paradiselost/items/ParadiseLostItems.java +++ b/src/main/java/net/id/paradiselost/items/ParadiseLostItems.java @@ -1,10 +1,9 @@ package net.id.paradiselost.items; +import com.chocohead.mm.api.ClassTinkerers; import com.google.common.collect.ImmutableList; import dev.emi.trinkets.api.TrinketItem; import net.fabricmc.fabric.api.item.v1.FabricItemSettings; -import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; -import net.id.paradiselost.ParadiseLost; import net.id.paradiselost.blocks.ParadiseLostBlocks; import net.id.paradiselost.entities.ParadiseLostEntityTypes; import net.id.paradiselost.items.accessories.ParachuteTrinketItem; @@ -18,7 +17,6 @@ import net.id.paradiselost.items.tools.bloodstone.CherineBloodstoneItem; import net.id.paradiselost.items.tools.bloodstone.SurtrumBloodstoneItem; import net.id.paradiselost.items.tools.bloodstone.OlviteBloodstoneItem; -import net.id.paradiselost.util.EnumExtender; import net.minecraft.block.Block; import net.minecraft.block.DoorBlock; import net.minecraft.block.TallPlantBlock; @@ -37,7 +35,6 @@ import java.util.Arrays; import java.util.Iterator; -import java.util.Locale; import java.util.function.Consumer; import static net.id.paradiselost.ParadiseLost.MOD_ID; @@ -432,10 +429,10 @@ private static FabricItemSettings decoration() { public static final BlockItem ORANGE_PRESSURE_PLATE = add("orange_pressure_plate", ParadiseLostBlocks.ORANGE_WOODSTUFF.pressurePlate(), decoration); public static final BlockItem WISTERIA_PRESSURE_PLATE = add("wisteria_pressure_plate", ParadiseLostBlocks.WISTERIA_WOODSTUFF.pressurePlate(), decoration); - public static final BoatSet AUREL_BOATS = addBoatItems("aurel", ParadiseLostBlocks.AUREL_WOODSTUFF.plank()); - public static final BoatSet MOTHER_AUREL_BOATS = addBoatItems("mother_aurel", ParadiseLostBlocks.MOTHER_AUREL_WOODSTUFF.plank()); - public static final BoatSet ORANGE_BOATS = addBoatItems("orange", ParadiseLostBlocks.ORANGE_WOODSTUFF.plank()); - public static final BoatSet WISTERIA_BOATS = addBoatItems("wisteria", ParadiseLostBlocks.WISTERIA_WOODSTUFF.plank()); + public static final BoatSet AUREL_BOATS = addBoatItems("aurel", "PARADISE_LOST_AUREL"); + public static final BoatSet MOTHER_AUREL_BOATS = addBoatItems("mother_aurel", "PARADISE_LOST_MOTHER_AUREL"); + public static final BoatSet ORANGE_BOATS = addBoatItems("orange", "PARADISE_LOST_ORANGE"); + public static final BoatSet WISTERIA_BOATS = addBoatItems("wisteria", "PARADISE_LOST_WISTERIA"); public static final BoatSet[] BOAT_SETS = new BoatSet[] {AUREL_BOATS, MOTHER_AUREL_BOATS, ORANGE_BOATS, WISTERIA_BOATS}; @@ -461,10 +458,10 @@ private static BlockItem add(String id, Block block, Settings settings, Consumer additionalActions); } - private static BoatSet addBoatItems(String woodId, Block plankBlock) { + private static BoatSet addBoatItems(String woodId, String boatTypeId) { String boatId = (MOD_ID + "_" + woodId); - BoatEntity.Type boatType = EnumExtender.add(BoatEntity.Type.class, boatId, plankBlock, boatId); + BoatEntity.Type boatType = ClassTinkerers.getEnum(BoatEntity.Type.class, boatTypeId); BoatItem boat = add(woodId + "_boat", new BoatItem(false, boatType, decoration().maxCount(1))); BoatItem chestBoat = add(woodId + "_chest_boat", new BoatItem(true, boatType, decoration().maxCount(1))); diff --git a/src/main/java/net/id/paradiselost/mixin/earlyrisers/CustomBoatEarlyRiser.java b/src/main/java/net/id/paradiselost/mixin/earlyrisers/CustomBoatEarlyRiser.java new file mode 100644 index 000000000..96de2b7c4 --- /dev/null +++ b/src/main/java/net/id/paradiselost/mixin/earlyrisers/CustomBoatEarlyRiser.java @@ -0,0 +1,23 @@ +package net.id.paradiselost.mixin.earlyrisers; + +import com.chocohead.mm.api.ClassTinkerers; +import net.fabricmc.loader.api.FabricLoader; +import net.fabricmc.loader.api.MappingResolver; + +public class CustomBoatEarlyRiser implements Runnable { + + @Override + public void run() { + MappingResolver remapper = FabricLoader.getInstance().getMappingResolver(); + + String boatType = remapper.mapClassName("intermediary", "net.minecraft.class_1690$class_1692"); + String block = 'L' + remapper.mapClassName("intermediary", "net.minecraft.class_2248") + ';'; + ClassTinkerers.enumBuilder(boatType, block, "Ljava/lang/String;") + .addEnum("PARADISE_LOST_AUREL", () -> new Object[] {null, "paradise_lost_aurel"}) + .addEnum("PARADISE_LOST_MOTHER_AUREL", () -> new Object[] {null, "paradise_lost_mother_aurel"}) + .addEnum("PARADISE_LOST_ORANGE", () -> new Object[] {null, "paradise_lost_orange"}) + .addEnum("PARADISE_LOST_WISTERIA", () -> new Object[] {null, "paradise_lost_wisteria"}) + .build(); + } + +} diff --git a/src/main/java/net/id/paradiselost/mixin/entity/BoatEntityTypeMixin.java b/src/main/java/net/id/paradiselost/mixin/entity/BoatEntityTypeMixin.java deleted file mode 100644 index 352959a62..000000000 --- a/src/main/java/net/id/paradiselost/mixin/entity/BoatEntityTypeMixin.java +++ /dev/null @@ -1,32 +0,0 @@ -package net.id.paradiselost.mixin.entity; - -import net.id.paradiselost.util.EnumExtender; -import net.minecraft.block.Block; -import net.minecraft.entity.vehicle.BoatEntity; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Mutable; -import org.spongepowered.asm.mixin.Shadow; - -import java.util.Arrays; - -@Mixin(BoatEntity.Type.class) -public class BoatEntityTypeMixin { - @SuppressWarnings("ShadowTarget") - @Shadow - @Mutable - @Final - private static BoatEntity.Type[] field_7724; - - static { - EnumExtender.register(BoatEntity.Type.class, (name, args) -> { - BoatEntity.Type entry = (BoatEntity.Type) (Object) new BoatEntityTypeMixin(name, field_7724.length, (Block) args[0], (String) args[1]); - field_7724 = Arrays.copyOf(field_7724, field_7724.length + 1); - return field_7724[field_7724.length - 1] = entry; - }); - } - - private BoatEntityTypeMixin(String valueName, int ordinal, Block baseBlock, String name) { - throw new AssertionError(); - } -} diff --git a/src/main/java/net/id/paradiselost/util/EnumExtender.java b/src/main/java/net/id/paradiselost/util/EnumExtender.java deleted file mode 100644 index 7668b587f..000000000 --- a/src/main/java/net/id/paradiselost/util/EnumExtender.java +++ /dev/null @@ -1,26 +0,0 @@ -package net.id.paradiselost.util; - -import java.util.HashMap; -import java.util.Map; -import java.util.function.BiFunction; - -public class EnumExtender { - private static final Map>, BiFunction>> extensibles = new HashMap<>(); - - public static > void register(Class extensible, BiFunction callback) { - extensibles.put(extensible, callback); - } - - @SuppressWarnings("unchecked") - public static > T add(Class to, String name, Object... arguments) { - if (extensibles.containsKey(to)) { - try { - return (T) extensibles.get(to).apply(name, arguments); - } catch (ClassCastException | IndexOutOfBoundsException e) { - throw new IllegalArgumentException("Invalid arguments for entry " + name + " of enum " + to + ". Arguments must match the enum constructor."); - } - } else { - throw new UnsupportedOperationException("Attempted to extend inextensible enum " + to + ". Create a mixin for it from the template in EnumExtender."); - } - } -} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 1c557d10e..1e7cdac8f 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -48,8 +48,8 @@ "cardinal-components": [ "net.id.paradiselost.component.ParadiseLostComponents" ], - "modmenu": [ - "net.id.paradiselost.config.ModMenuConfig" + "mm:early_risers": [ + "net.id.paradiselost.mixin.earlyrisers.CustomBoatEarlyRiser" ] }, "custom": { diff --git a/src/main/resources/paradise_lost.mixins.json b/src/main/resources/paradise_lost.mixins.json index 791aa4252..be6673613 100644 --- a/src/main/resources/paradise_lost.mixins.json +++ b/src/main/resources/paradise_lost.mixins.json @@ -11,7 +11,6 @@ "block.FarmlandBlockMixin", "enchantment.EnchantmentHelperMixin", "entity.BoatEntityMixin", - "entity.BoatEntityTypeMixin", "entity.ChestBoatEntityMixin", "entity.CowEntityMixin", "entity.EntityMixin",