From 91a741e7f57e59fb167115b6f5ebe6ab454044a7 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Sun, 16 Jun 2024 22:00:12 +0200 Subject: [PATCH] chore: move Trinkets integration to addon mod --- CHANGELOG.md | 4 ++ gradle.properties | 2 - .../common/AbstractModInitializer.java | 4 +- .../assets/refinedstorage2/lang/en_us.json | 1 - refinedstorage2-platform-fabric/build.gradle | 9 ---- .../platform/fabric/ModInitializerImpl.java | 14 ----- .../bounditem/TrinketsSlotReference.java | 48 ------------------ .../TrinketsSlotReferenceFactory.java | 18 ------- .../TrinketsSlotReferenceProvider.java | 47 ----------------- .../network/bounditem/package-info.java | 7 --- .../textures/slot/trinkets.png | Bin 173 -> 0 bytes .../trinkets/entities/refinedstorage2.json | 8 --- .../slots/refinedstorage2/wireless.json | 5 -- .../tags/items/refinedstorage2/wireless.json | 7 --- 14 files changed, 6 insertions(+), 168 deletions(-) delete mode 100644 refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/support/network/bounditem/TrinketsSlotReference.java delete mode 100644 refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/support/network/bounditem/TrinketsSlotReferenceFactory.java delete mode 100644 refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/support/network/bounditem/TrinketsSlotReferenceProvider.java delete mode 100644 refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/support/network/bounditem/package-info.java delete mode 100644 refinedstorage2-platform-fabric/src/main/resources/assets/refinedstorage2/textures/slot/trinkets.png delete mode 100644 refinedstorage2-platform-fabric/src/main/resources/data/trinkets/entities/refinedstorage2.json delete mode 100644 refinedstorage2-platform-fabric/src/main/resources/data/trinkets/slots/refinedstorage2/wireless.json delete mode 100644 refinedstorage2-platform-fabric/src/main/resources/data/trinkets/tags/items/refinedstorage2/wireless.json diff --git a/CHANGELOG.md b/CHANGELOG.md index c065417c9..01426a92b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Removed + +- The Trinkets integration has been removed and will be moved to an addon mod. + ## [2.0.0-milestone.3.11] - 2024-06-16 ### Removed diff --git a/gradle.properties b/gradle.properties index a130241d3..1e6a9cb58 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,3 @@ noIndiumVersion=1.1.0+1.20.4 -trinketsVersion=3.8.0 -cardinalComponentsVersion=5.4.0 # Gradle org.gradle.jvmargs=-Xmx1G diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/AbstractModInitializer.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/AbstractModInitializer.java index 82f97c96d..3ecce5d2d 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/AbstractModInitializer.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/AbstractModInitializer.java @@ -197,7 +197,7 @@ protected final void initializePlatformApi() { registerNetworkComponents(); registerWirelessTransmitterRangeModifiers(); registerPermissions(); - registerSlotReferenceProviders(); + registerSlotReferenceProvider(); } private void registerStorageTypes() { @@ -787,7 +787,7 @@ protected final void registerRecipeSerializers(final RegistryCallback ServerEventQueue.runQueuedActions()); } - @Override - protected void registerSlotReferenceProviders() { - super.registerSlotReferenceProviders(); - TrinketsSlotReferenceProvider.create().ifPresent(slotReferenceProvider -> { - PlatformApi.INSTANCE.getSlotReferenceFactoryRegistry().register( - createIdentifier("trinkets"), - TrinketsSlotReferenceFactory.INSTANCE - ); - PlatformApi.INSTANCE.addSlotReferenceProvider(slotReferenceProvider); - }); - } - private void registerWrenchingEvent() { UseBlockCallback.EVENT.register((player, level, hand, hitResult) -> { final BlockState state = level.getBlockState(hitResult.getBlockPos()); diff --git a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/support/network/bounditem/TrinketsSlotReference.java b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/support/network/bounditem/TrinketsSlotReference.java deleted file mode 100644 index dfdf8fe4e..000000000 --- a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/support/network/bounditem/TrinketsSlotReference.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.fabric.support.network.bounditem; - -import com.refinedmods.refinedstorage2.platform.api.support.network.bounditem.SlotReference; -import com.refinedmods.refinedstorage2.platform.api.support.network.bounditem.SlotReferenceFactory; - -import java.util.Optional; - -import dev.emi.trinkets.api.TrinketsApi; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; - -class TrinketsSlotReference implements SlotReference { - private final String groupName; - private final String slotName; - private final int index; - - TrinketsSlotReference(final String groupName, final String slotName, final int index) { - this.groupName = groupName; - this.slotName = slotName; - this.index = index; - } - - @Override - public boolean isDisabledSlot(final int playerSlotIndex) { - return false; - } - - @Override - public void writeToBuffer(final FriendlyByteBuf buf) { - buf.writeUtf(groupName); - buf.writeUtf(slotName); - buf.writeInt(index); - } - - @Override - public Optional resolve(final Player player) { - return TrinketsApi.getTrinketComponent(player) - .map(trinkets -> trinkets.getInventory().get(groupName)) - .map(groupMap -> groupMap.get(slotName)) - .map(trinketInventory -> trinketInventory.getItem(index)); - } - - @Override - public SlotReferenceFactory getFactory() { - return TrinketsSlotReferenceFactory.INSTANCE; - } -} diff --git a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/support/network/bounditem/TrinketsSlotReferenceFactory.java b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/support/network/bounditem/TrinketsSlotReferenceFactory.java deleted file mode 100644 index 074058223..000000000 --- a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/support/network/bounditem/TrinketsSlotReferenceFactory.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.fabric.support.network.bounditem; - -import com.refinedmods.refinedstorage2.platform.api.support.network.bounditem.SlotReference; -import com.refinedmods.refinedstorage2.platform.api.support.network.bounditem.SlotReferenceFactory; - -import net.minecraft.network.FriendlyByteBuf; - -public class TrinketsSlotReferenceFactory implements SlotReferenceFactory { - public static final SlotReferenceFactory INSTANCE = new TrinketsSlotReferenceFactory(); - - private TrinketsSlotReferenceFactory() { - } - - @Override - public SlotReference create(final FriendlyByteBuf buf) { - return new TrinketsSlotReference(buf.readUtf(), buf.readUtf(), buf.readInt()); - } -} diff --git a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/support/network/bounditem/TrinketsSlotReferenceProvider.java b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/support/network/bounditem/TrinketsSlotReferenceProvider.java deleted file mode 100644 index 8e8f27cac..000000000 --- a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/support/network/bounditem/TrinketsSlotReferenceProvider.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.fabric.support.network.bounditem; - -import com.refinedmods.refinedstorage2.platform.api.support.network.bounditem.SlotReference; -import com.refinedmods.refinedstorage2.platform.api.support.network.bounditem.SlotReferenceProvider; - -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import java.util.Set; - -import dev.emi.trinkets.api.TrinketsApi; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.Item; - -public class TrinketsSlotReferenceProvider implements SlotReferenceProvider { - @Override - public List find(final Player player, final Set validItems) { - return TrinketsApi.getTrinketComponent(player) - .map(trinkets -> trinkets.getEquipped(s -> validItems.contains(s.getItem()))) - .orElse(Collections.emptyList()) - .stream() - .map(Tuple::getA) - .map(trinketsSlotReference -> (SlotReference) new TrinketsSlotReference( - trinketsSlotReference.inventory().getSlotType().getGroup(), - trinketsSlotReference.inventory().getSlotType().getName(), - trinketsSlotReference.index() - )) - .toList(); - } - - public static Optional create() { - if (!isTrinketsLoaded()) { - return Optional.empty(); - } - return Optional.of(new TrinketsSlotReferenceProvider()); - } - - private static boolean isTrinketsLoaded() { - try { - Class.forName("dev.emi.trinkets.api.TrinketsApi"); - return true; - } catch (ClassNotFoundException e) { - return false; - } - } -} diff --git a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/support/network/bounditem/package-info.java b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/support/network/bounditem/package-info.java deleted file mode 100644 index 557bcaf20..000000000 --- a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/support/network/bounditem/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -@ParametersAreNonnullByDefault -@FieldsAndMethodsAreNonnullByDefault -package com.refinedmods.refinedstorage2.platform.fabric.support.network.bounditem; - -import com.refinedmods.refinedstorage2.api.core.FieldsAndMethodsAreNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/refinedstorage2-platform-fabric/src/main/resources/assets/refinedstorage2/textures/slot/trinkets.png b/refinedstorage2-platform-fabric/src/main/resources/assets/refinedstorage2/textures/slot/trinkets.png deleted file mode 100644 index 2d0f73a53d75815c628ba03d8f25950de7c2888b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 173 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPF