diff --git a/CHANGELOG.md b/CHANGELOG.md index 89e18ec..3560b59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,3 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Unreleased + +## Added + +- Chemical Storage Disk +- Chemical support in the Grid. +- Chemical support in the Storage Monitor. diff --git a/build.gradle.kts b/build.gradle.kts index 6db3797..06a3c73 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -18,6 +18,10 @@ repositories { includeGroup("mekanism") } } + maven { + name = "JEI" + url = uri("https://maven.blamejared.com/") + } } refinedarchitect { @@ -38,6 +42,7 @@ base { val refinedstorageVersion: String by project val minecraftVersion: String by project val mekanismVersion: String by project +val jeiVersion: String by project dependencies { api("com.refinedmods.refinedstorage:refinedstorage-neoforge:${refinedstorageVersion}") @@ -45,5 +50,9 @@ dependencies { runtimeOnly("mekanism:Mekanism:${minecraftVersion}-${mekanismVersion}:all") { exclude(group = "com.blamejared.crafttweaker") } + runtimeOnly("mezz.jei:jei-${minecraftVersion}-neoforge:${jeiVersion}") + compileOnlyApi("mezz.jei:jei-${minecraftVersion}-common-api:${jeiVersion}") + testCompileOnly("mezz.jei:jei-${minecraftVersion}-common:${jeiVersion}") + compileOnlyApi("mezz.jei:jei-${minecraftVersion}-neoforge-api:${jeiVersion}") } diff --git a/gradle.properties b/gradle.properties index 3e79821..87129a5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,6 +2,7 @@ refinedarchitectVersion=0.20.0 refinedstorageVersion=2.0.0-milestone.4.10 # https://www.curseforge.com/minecraft/mc-mods/mekanism/files/all mekanismVersion=10.7.7.64 +jeiVersion=19.20.0.241 minecraftVersion=1.21.1 # Gradle org.gradle.jvmargs=-Xmx1G diff --git a/src/main/java/com/refinedmods/refinedstorage/mekanism/ClientModInitializer.java b/src/main/java/com/refinedmods/refinedstorage/mekanism/ClientModInitializer.java new file mode 100644 index 0000000..c1f5280 --- /dev/null +++ b/src/main/java/com/refinedmods/refinedstorage/mekanism/ClientModInitializer.java @@ -0,0 +1,23 @@ +package com.refinedmods.refinedstorage.mekanism; + +import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.mekanism.chemical.ChemicalGridInsertionHint; +import com.refinedmods.refinedstorage.mekanism.chemical.ChemicalResource; +import com.refinedmods.refinedstorage.mekanism.chemical.ChemicalResourceRendering; + +import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; + +public final class ClientModInitializer { + private ClientModInitializer() { + } + + @SubscribeEvent + public static void onClientSetup(final FMLClientSetupEvent e) { + RefinedStorageApi.INSTANCE.registerResourceRendering( + ChemicalResource.class, + new ChemicalResourceRendering() + ); + RefinedStorageApi.INSTANCE.addAlternativeGridInsertionHint(new ChemicalGridInsertionHint()); + } +} diff --git a/src/main/java/com/refinedmods/refinedstorage/mekanism/Items.java b/src/main/java/com/refinedmods/refinedstorage/mekanism/Items.java new file mode 100644 index 0000000..4f910e7 --- /dev/null +++ b/src/main/java/com/refinedmods/refinedstorage/mekanism/Items.java @@ -0,0 +1,37 @@ +package com.refinedmods.refinedstorage.mekanism; + +import com.refinedmods.refinedstorage.mekanism.chemical.ChemicalStorageVariant; + +import java.util.EnumMap; +import java.util.Map; +import java.util.function.Supplier; + +import net.minecraft.world.item.Item; + +public final class Items { + public static final Items INSTANCE = new Items(); + + private final Map> chemicalStorageParts = + new EnumMap<>(ChemicalStorageVariant.class); + private final Map> chemicalStorageDisks = + new EnumMap<>(ChemicalStorageVariant.class); + + private Items() { + } + + public Item getChemicalStoragePart(final ChemicalStorageVariant variant) { + return chemicalStorageParts.get(variant).get(); + } + + public void setChemicalStoragePart(final ChemicalStorageVariant variant, final Supplier supplier) { + chemicalStorageParts.put(variant, supplier); + } + + public Item getChemicalStorageDisk(final ChemicalStorageVariant variant) { + return chemicalStorageDisks.get(variant).get(); + } + + public void setChemicalStorageDisk(final ChemicalStorageVariant variant, final Supplier supplier) { + chemicalStorageDisks.put(variant, supplier); + } +} diff --git a/src/main/java/com/refinedmods/refinedstorage/mekanism/MekanismIntegrationIdentifierUtil.java b/src/main/java/com/refinedmods/refinedstorage/mekanism/MekanismIntegrationIdentifierUtil.java new file mode 100644 index 0000000..45f3da5 --- /dev/null +++ b/src/main/java/com/refinedmods/refinedstorage/mekanism/MekanismIntegrationIdentifierUtil.java @@ -0,0 +1,30 @@ +package com.refinedmods.refinedstorage.mekanism; + +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.resources.ResourceLocation; + +public final class MekanismIntegrationIdentifierUtil { + public static final String MOD_ID = "refinedstorage_mekanism_integration"; + + private MekanismIntegrationIdentifierUtil() { + } + + public static ResourceLocation createMekanismIntegrationIdentifier(final String value) { + return ResourceLocation.fromNamespaceAndPath(MOD_ID, value); + } + + public static String createMekanismIntegrationTranslationKey(final String category, final String value) { + return String.format("%s.%s.%s", category, MOD_ID, value); + } + + public static MutableComponent createMekanismIntegrationTranslation(final String category, final String value) { + return Component.translatable(createMekanismIntegrationTranslationKey(category, value)); + } + + public static MutableComponent createMekanismIntegrationTranslation(final String category, + final String value, + final Object... args) { + return Component.translatable(createMekanismIntegrationTranslationKey(category, value), args); + } +} diff --git a/src/main/java/com/refinedmods/refinedstorage/mekanism/MekanismUtil.java b/src/main/java/com/refinedmods/refinedstorage/mekanism/MekanismUtil.java new file mode 100644 index 0000000..071c58b --- /dev/null +++ b/src/main/java/com/refinedmods/refinedstorage/mekanism/MekanismUtil.java @@ -0,0 +1,15 @@ +package com.refinedmods.refinedstorage.mekanism; + +import com.refinedmods.refinedstorage.api.core.Action; + +public final class MekanismUtil { + private MekanismUtil() { + } + + public static mekanism.api.Action toMekanismAction(final Action action) { + return switch (action) { + case EXECUTE -> mekanism.api.Action.EXECUTE; + case SIMULATE -> mekanism.api.Action.SIMULATE; + }; + } +} diff --git a/src/main/java/com/refinedmods/refinedstorage/mekanism/ModInitializer.java b/src/main/java/com/refinedmods/refinedstorage/mekanism/ModInitializer.java index 3106b19..e7aaa20 100644 --- a/src/main/java/com/refinedmods/refinedstorage/mekanism/ModInitializer.java +++ b/src/main/java/com/refinedmods/refinedstorage/mekanism/ModInitializer.java @@ -1,24 +1,111 @@ package com.refinedmods.refinedstorage.mekanism; -import com.refinedmods.refinedstorage.common.util.IdentifierUtil; +import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.storage.StorageContainerUpgradeRecipe; +import com.refinedmods.refinedstorage.common.storage.StorageContainerUpgradeRecipeSerializer; +import com.refinedmods.refinedstorage.common.support.SimpleItem; +import com.refinedmods.refinedstorage.mekanism.chemical.ChemicalGridExtractionStrategy; +import com.refinedmods.refinedstorage.mekanism.chemical.ChemicalGridInsertionStrategy; +import com.refinedmods.refinedstorage.mekanism.chemical.ChemicalResourceContainerInsertStrategy; +import com.refinedmods.refinedstorage.mekanism.chemical.ChemicalResourceFactory; +import com.refinedmods.refinedstorage.mekanism.chemical.ChemicalResourceType; +import com.refinedmods.refinedstorage.mekanism.chemical.ChemicalStorageDiskItem; +import com.refinedmods.refinedstorage.mekanism.chemical.ChemicalStorageMonitorInsertionStrategy; +import com.refinedmods.refinedstorage.mekanism.chemical.ChemicalStorageVariant; -import mekanism.api.MekanismAPI; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.neoforged.api.distmarker.Dist; import net.neoforged.bus.api.IEventBus; import net.neoforged.fml.common.Mod; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; +import net.neoforged.fml.loading.FMLEnvironment; +import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent; +import net.neoforged.neoforge.registries.DeferredRegister; -@Mod(ModInitializer.ID) +import static com.refinedmods.refinedstorage.mekanism.MekanismIntegrationIdentifierUtil.createMekanismIntegrationIdentifier; + +@Mod(MekanismIntegrationIdentifierUtil.MOD_ID) public final class ModInitializer { - public static final String ID = "refinedstorage_mekanism_integration"; + public ModInitializer(final IEventBus eventBus) { + if (FMLEnvironment.dist == Dist.CLIENT) { + eventBus.addListener(ClientModInitializer::onClientSetup); + } + eventBus.addListener(this::setup); + eventBus.addListener(this::registerCreativeModeTabListener); - private static final Logger LOGGER = LoggerFactory.getLogger(ModInitializer.class); + final DeferredRegister itemRegistry = DeferredRegister.create( + BuiltInRegistries.ITEM, + MekanismIntegrationIdentifierUtil.MOD_ID + ); + for (final ChemicalStorageVariant variant : ChemicalStorageVariant.values()) { + if (variant.getStoragePartId() != null) { + Items.INSTANCE.setChemicalStoragePart( + variant, + itemRegistry.register(variant.getStoragePartId().getPath(), SimpleItem::new) + ); + } + Items.INSTANCE.setChemicalStorageDisk( + variant, + itemRegistry.register(variant.getStorageDiskId().getPath(), () -> new ChemicalStorageDiskItem( + RefinedStorageApi.INSTANCE.getStorageContainerItemHelper(), + variant + )) + ); + } + itemRegistry.register(eventBus); - public ModInitializer(final IEventBus eventBus) { - LOGGER.info( - "Refined Storage - Mekanism Integration has loaded. RS2 ModId: {}, Mekanism API version: {}", - IdentifierUtil.MOD_ID, - MekanismAPI.API_VERSION + final DeferredRegister> recipeSerializerRegistry = DeferredRegister.create( + BuiltInRegistries.RECIPE_SERIALIZER, + MekanismIntegrationIdentifierUtil.MOD_ID + ); + recipeSerializerRegistry.register( + "chemical_storage_disk_upgrade", + () -> new StorageContainerUpgradeRecipeSerializer<>( + ChemicalStorageVariant.values(), + to -> new StorageContainerUpgradeRecipe<>( + ChemicalStorageVariant.values(), to, Items.INSTANCE::getChemicalStorageDisk + ) + ) + ); + recipeSerializerRegistry.register(eventBus); + } + + private void setup(final FMLCommonSetupEvent e) { + RefinedStorageApi.INSTANCE.getResourceTypeRegistry().register( + createMekanismIntegrationIdentifier("chemical"), + ChemicalResourceType.INSTANCE + ); + RefinedStorageApi.INSTANCE.getAlternativeResourceFactories().add(new ChemicalResourceFactory()); + RefinedStorageApi.INSTANCE.getStorageTypeRegistry().register( + createMekanismIntegrationIdentifier("chemical"), + ChemicalResourceType.STORAGE_TYPE + ); + RefinedStorageApi.INSTANCE.addGridInsertionStrategyFactory(ChemicalGridInsertionStrategy::new); + RefinedStorageApi.INSTANCE.addGridExtractionStrategyFactory(ChemicalGridExtractionStrategy::new); + RefinedStorageApi.INSTANCE.addStorageMonitorInsertionStrategy(new ChemicalStorageMonitorInsertionStrategy()); + RefinedStorageApi.INSTANCE.addResourceContainerInsertStrategy(new ChemicalResourceContainerInsertStrategy()); + } + + private void registerCreativeModeTabListener(final BuildCreativeModeTabContentsEvent e) { + final ResourceKey creativeModeTab = ResourceKey.create( + Registries.CREATIVE_MODE_TAB, + RefinedStorageApi.INSTANCE.getCreativeModeTabId() ); + if (!e.getTabKey().equals(creativeModeTab)) { + return; + } + for (final ChemicalStorageVariant variant : ChemicalStorageVariant.values()) { + if (variant.getStoragePartId() != null) { + e.accept(Items.INSTANCE.getChemicalStoragePart(variant)); + } + } + for (final ChemicalStorageVariant variant : ChemicalStorageVariant.values()) { + e.accept(Items.INSTANCE.getChemicalStorageDisk(variant)); + } } } diff --git a/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalGridExtractionStrategy.java b/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalGridExtractionStrategy.java new file mode 100644 index 0000000..dafb1fb --- /dev/null +++ b/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalGridExtractionStrategy.java @@ -0,0 +1,66 @@ +package com.refinedmods.refinedstorage.mekanism.chemical; + +import com.refinedmods.refinedstorage.api.grid.operations.GridExtractMode; +import com.refinedmods.refinedstorage.api.grid.operations.GridOperations; +import com.refinedmods.refinedstorage.common.api.grid.Grid; +import com.refinedmods.refinedstorage.common.api.grid.strategy.GridExtractionStrategy; +import com.refinedmods.refinedstorage.common.api.support.resource.PlatformResourceKey; + +import javax.annotation.Nullable; + +import mekanism.api.chemical.Chemical; +import mekanism.api.chemical.ChemicalStack; +import mekanism.api.chemical.IChemicalHandler; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.item.ItemStack; + +import static com.refinedmods.refinedstorage.mekanism.MekanismUtil.toMekanismAction; + +public class ChemicalGridExtractionStrategy implements GridExtractionStrategy { + private final AbstractContainerMenu menu; + private final GridOperations gridOperations; + + public ChemicalGridExtractionStrategy(final AbstractContainerMenu containerMenu, + final ServerPlayer player, + final Grid grid) { + this.menu = containerMenu; + this.gridOperations = grid.createOperations(ChemicalResourceType.INSTANCE, player); + } + + @Override + public boolean onExtract(final PlatformResourceKey resource, + final GridExtractMode extractMode, + final boolean cursor) { + if (resource instanceof ChemicalResource chemicalResource && isChemicalContainerOnCursor()) { + extractWithContainerOnCursor(chemicalResource, extractMode); + return true; + } + return false; + } + + @Nullable + private IChemicalHandler getChemicalStorage(final ItemStack stack) { + return stack.getCapability(ChemicalResourceType.ITEM_CAPABILITY); + } + + private void extractWithContainerOnCursor(final ChemicalResource chemicalResource, + final GridExtractMode mode) { + gridOperations.extract(chemicalResource, mode, (resource, amount, action, source) -> { + if (!(resource instanceof ChemicalResource(Chemical chemical))) { + return 0; + } + final IChemicalHandler destination = getChemicalStorage(menu.getCarried()); + if (destination == null) { + return 0; + } + final ChemicalStack toInsert = new ChemicalStack(chemical, amount); + final ChemicalStack remainder = destination.insertChemical(toInsert, toMekanismAction(action)); + return amount - remainder.getAmount(); + }); + } + + private boolean isChemicalContainerOnCursor() { + return getChemicalStorage(menu.getCarried()) != null; + } +} diff --git a/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalGridInsertionHint.java b/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalGridInsertionHint.java new file mode 100644 index 0000000..d893769 --- /dev/null +++ b/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalGridInsertionHint.java @@ -0,0 +1,33 @@ +package com.refinedmods.refinedstorage.mekanism.chemical; + +import com.refinedmods.refinedstorage.common.Platform; +import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.grid.GridInsertionHint; +import com.refinedmods.refinedstorage.common.support.tooltip.MouseClientTooltipComponent; + +import java.util.Optional; + +import mekanism.api.Action; +import mekanism.api.chemical.ChemicalStack; +import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; +import net.minecraft.world.item.ItemStack; + +import static com.refinedmods.refinedstorage.mekanism.chemical.ChemicalResource.ofChemicalStack; + +public class ChemicalGridInsertionHint implements GridInsertionHint { + @Override + public Optional getHint(final ItemStack stack) { + return Optional.ofNullable(stack.getCapability(ChemicalResourceType.ITEM_CAPABILITY)) + .map(handler -> handler.extractChemical(Long.MAX_VALUE, Action.SIMULATE)) + .filter(result -> !result.isEmpty()) + .map(this::createComponent); + } + + private ClientTooltipComponent createComponent(final ChemicalStack result) { + final ChemicalResource chemicalResource = ofChemicalStack(result); + final String amount = result.getAmount() == Platform.INSTANCE.getBucketAmount() + ? null + : RefinedStorageApi.INSTANCE.getResourceRendering(ChemicalResource.class).formatAmount(result.getAmount()); + return MouseClientTooltipComponent.resource(MouseClientTooltipComponent.Type.RIGHT, chemicalResource, amount); + } +} diff --git a/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalGridInsertionStrategy.java b/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalGridInsertionStrategy.java new file mode 100644 index 0000000..c5156b9 --- /dev/null +++ b/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalGridInsertionStrategy.java @@ -0,0 +1,70 @@ +package com.refinedmods.refinedstorage.mekanism.chemical; + +import com.refinedmods.refinedstorage.api.grid.operations.GridInsertMode; +import com.refinedmods.refinedstorage.api.grid.operations.GridOperations; +import com.refinedmods.refinedstorage.common.api.grid.Grid; +import com.refinedmods.refinedstorage.common.api.grid.strategy.GridInsertionStrategy; + +import javax.annotation.Nullable; + +import mekanism.api.chemical.Chemical; +import mekanism.api.chemical.ChemicalStack; +import mekanism.api.chemical.IChemicalHandler; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.item.ItemStack; + +import static com.refinedmods.refinedstorage.mekanism.MekanismUtil.toMekanismAction; +import static com.refinedmods.refinedstorage.mekanism.chemical.ChemicalResource.ofChemicalStack; + +public class ChemicalGridInsertionStrategy implements GridInsertionStrategy { + private final AbstractContainerMenu menu; + private final GridOperations gridOperations; + + public ChemicalGridInsertionStrategy(final AbstractContainerMenu menu, + final ServerPlayer player, + final Grid grid) { + this.menu = menu; + this.gridOperations = grid.createOperations(ChemicalResourceType.INSTANCE, player); + } + + @Override + public boolean onInsert(final GridInsertMode insertMode, final boolean tryAlternatives) { + final IChemicalHandler cursorStorage = getChemicalCursorStorage(); + if (cursorStorage == null) { + return false; + } + if (cursorStorage.getChemicalTanks() == 0) { + return false; + } + final ChemicalStack extractableResource = cursorStorage.getChemicalInTank(0); + if (extractableResource.isEmpty()) { + return false; + } + final ChemicalResource chemicalResource = ofChemicalStack(extractableResource); + gridOperations.insert(chemicalResource, insertMode, (resource, amount, action, source) -> { + if (!(resource instanceof ChemicalResource(Chemical chemical))) { + return 0; + } + final ChemicalStack toDrain = new ChemicalStack(chemical, amount); + final ChemicalStack drained = cursorStorage.extractChemical(toDrain, toMekanismAction(action)); + return drained.getAmount(); + }); + return true; + } + + @Nullable + private IChemicalHandler getChemicalCursorStorage() { + return getChemicalStorage(menu.getCarried()); + } + + @Nullable + private IChemicalHandler getChemicalStorage(final ItemStack stack) { + return stack.getCapability(ChemicalResourceType.ITEM_CAPABILITY); + } + + @Override + public boolean onTransfer(final int slotIndex) { + throw new UnsupportedOperationException(); + } +} diff --git a/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalGridResource.java b/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalGridResource.java new file mode 100644 index 0000000..ea5194a --- /dev/null +++ b/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalGridResource.java @@ -0,0 +1,130 @@ +package com.refinedmods.refinedstorage.mekanism.chemical; + +import com.refinedmods.refinedstorage.api.grid.operations.GridExtractMode; +import com.refinedmods.refinedstorage.api.grid.view.GridResourceAttributeKey; +import com.refinedmods.refinedstorage.api.grid.view.GridView; +import com.refinedmods.refinedstorage.api.resource.ResourceAmount; +import com.refinedmods.refinedstorage.common.Platform; +import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.grid.GridScrollMode; +import com.refinedmods.refinedstorage.common.api.grid.strategy.GridExtractionStrategy; +import com.refinedmods.refinedstorage.common.api.grid.strategy.GridScrollingStrategy; +import com.refinedmods.refinedstorage.common.api.grid.view.AbstractPlatformGridResource; +import com.refinedmods.refinedstorage.common.api.support.resource.ResourceRendering; +import com.refinedmods.refinedstorage.common.api.support.resource.ResourceType; +import com.refinedmods.refinedstorage.common.support.tooltip.MouseClientTooltipComponent; + +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import javax.annotation.Nullable; + +import mekanism.api.Action; +import mekanism.api.MekanismAPI; +import mekanism.api.chemical.ChemicalStack; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; +import net.minecraft.network.chat.Component; +import net.minecraft.world.inventory.tooltip.TooltipComponent; +import net.minecraft.world.item.ItemStack; + +public class ChemicalGridResource extends AbstractPlatformGridResource { + private final int id; + private final ResourceRendering rendering; + private final List tooltip; + + public ChemicalGridResource(final ChemicalResource resource, + final String name, + final Map> attributes, + final boolean autocraftable) { + super(resource, name, attributes, autocraftable); + this.id = MekanismAPI.CHEMICAL_REGISTRY.getId(resource.chemical()); + this.rendering = RefinedStorageApi.INSTANCE.getResourceRendering(ChemicalResource.class); + this.tooltip = List.of(resource.chemical().getTextComponent()); + } + + @Override + public int getRegistryId() { + return id; + } + + @Override + public List getExtractionHints(final ItemStack carriedStack, final GridView view) { + final ItemStack modifiedStack = carriedStack.copy(); + return Optional.ofNullable(modifiedStack.getCapability(ChemicalResourceType.ITEM_CAPABILITY)) + .map(handler -> handler.insertChemical( + new ChemicalStack(resource.chemical(), Platform.INSTANCE.getBucketAmount()), + Action.EXECUTE + )) + .filter(remainder -> remainder.getAmount() != Platform.INSTANCE.getBucketAmount()) + .map(remainder -> MouseClientTooltipComponent.item( + MouseClientTooltipComponent.Type.LEFT, + modifiedStack, + null + )).stream().toList(); + } + + @Nullable + @Override + public ResourceAmount getAutocraftingRequest() { + return new ResourceAmount(resource, Platform.INSTANCE.getBucketAmount()); + } + + @Override + public boolean canExtract(final ItemStack carriedStack, final GridView view) { + if (getAmount(view) == 0) { + return false; + } + if (carriedStack.isEmpty()) { + return true; + } + final ChemicalStack toFill = new ChemicalStack(resource.chemical(), view.getAmount(resource)); + return Optional.ofNullable(carriedStack.getCapability(ChemicalResourceType.ITEM_CAPABILITY)) + .map(handler -> handler.insertChemical(toFill, Action.SIMULATE)) + .map(remainder -> remainder.getAmount() != toFill.getAmount()) + .orElse(false); + } + + @Override + public void onExtract(final GridExtractMode extractMode, + final boolean cursor, + final GridExtractionStrategy extractionStrategy) { + extractionStrategy.onExtract(resource, extractMode, cursor); + } + + @Override + public void onScroll(final GridScrollMode scrollMode, final GridScrollingStrategy scrollingStrategy) { + // no-op + } + + @Override + public void render(final GuiGraphics graphics, final int x, final int y) { + ChemicalRenderer.render(graphics.pose(), x, y, resource.chemical()); + } + + @Override + public String getDisplayedAmount(final GridView view) { + return rendering.formatAmount(getAmount(view), true); + } + + @Override + public String getAmountInTooltip(final GridView view) { + return rendering.formatAmount(getAmount(view)); + } + + @Override + public boolean belongsToResourceType(final ResourceType resourceType) { + return resourceType == ChemicalResourceType.INSTANCE; + } + + @Override + public List getTooltip() { + return tooltip; + } + + @Override + public Optional getTooltipImage() { + return Optional.empty(); + } +} diff --git a/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalGridResourceFactory.java b/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalGridResourceFactory.java new file mode 100644 index 0000000..0fb446d --- /dev/null +++ b/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalGridResourceFactory.java @@ -0,0 +1,75 @@ +package com.refinedmods.refinedstorage.mekanism.chemical; + +import com.refinedmods.refinedstorage.api.grid.view.GridResource; +import com.refinedmods.refinedstorage.api.grid.view.GridResourceFactory; +import com.refinedmods.refinedstorage.api.resource.ResourceKey; +import com.refinedmods.refinedstorage.common.api.grid.GridResourceAttributeKeys; + +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +import mekanism.api.MekanismAPI; +import mekanism.api.chemical.Chemical; +import net.minecraft.core.Holder; +import net.neoforged.fml.ModList; + +public class ChemicalGridResourceFactory implements GridResourceFactory { + public static final ChemicalGridResourceFactory INSTANCE = new ChemicalGridResourceFactory(); + + private ChemicalGridResourceFactory() { + } + + @Override + public Optional apply(final ResourceKey resource, final boolean autocraftable) { + if (!(resource instanceof ChemicalResource chemicalResource)) { + return Optional.empty(); + } + final String name = getName(chemicalResource); + final String modId = getModId(chemicalResource); + final String modName = getModName(modId); + final Set tags = getTags(chemicalResource.chemical()); + final String tooltip = getTooltip(chemicalResource); + return Optional.of(new ChemicalGridResource( + chemicalResource, + name, + Map.of( + GridResourceAttributeKeys.MOD_ID, Set.of(modId), + GridResourceAttributeKeys.MOD_NAME, Set.of(modName), + GridResourceAttributeKeys.TAGS, tags, + GridResourceAttributeKeys.TOOLTIP, Set.of(tooltip) + ), + autocraftable + )); + } + + private Set getTags(final Chemical chemical) { + return MekanismAPI.CHEMICAL_REGISTRY.getResourceKey(chemical) + .flatMap(MekanismAPI.CHEMICAL_REGISTRY::getHolder) + .stream() + .flatMap(Holder::tags) + .map(tagKey -> tagKey.location().getPath()) + .collect(Collectors.toSet()); + } + + private String getModId(final ChemicalResource chemical) { + return MekanismAPI.CHEMICAL_REGISTRY.getKey(chemical.chemical()).getNamespace(); + } + + private String getTooltip(final ChemicalResource resource) { + return getName(resource); + } + + private String getModName(final String modId) { + return ModList + .get() + .getModContainerById(modId) + .map(container -> container.getModInfo().getDisplayName()) + .orElse(""); + } + + private String getName(final ChemicalResource chemical) { + return chemical.chemical().getTextComponent().getString(); + } +} diff --git a/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalRenderer.java b/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalRenderer.java new file mode 100644 index 0000000..5477f93 --- /dev/null +++ b/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalRenderer.java @@ -0,0 +1,110 @@ +package com.refinedmods.refinedstorage.mekanism.chemical; + +import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.BufferBuilder; +import com.mojang.blaze3d.vertex.BufferUploader; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.Tesselator; +import com.mojang.blaze3d.vertex.VertexConsumer; +import com.mojang.blaze3d.vertex.VertexFormat; +import mekanism.api.chemical.Chemical; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.texture.OverlayTexture; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.inventory.InventoryMenu; + +public final class ChemicalRenderer { + private ChemicalRenderer() { + } + + public static void render(final PoseStack poseStack, final int x, final int y, final Chemical chemical) { + final int packedRgb = chemical.getTint(); + final Minecraft minecraft = Minecraft.getInstance(); + final ResourceLocation icon = chemical.getIcon(); + final TextureAtlasSprite sprite = minecraft.getTextureAtlas(InventoryMenu.BLOCK_ATLAS).apply(icon); + render(poseStack, x, y, packedRgb, sprite); + } + + public static void render(final PoseStack poseStack, + final MultiBufferSource renderTypeBuffer, + final int light, + final Chemical chemical) { + final int packedRgb = chemical.getTint(); + final Minecraft minecraft = Minecraft.getInstance(); + final ResourceLocation icon = chemical.getIcon(); + final TextureAtlasSprite sprite = minecraft.getTextureAtlas(InventoryMenu.BLOCK_ATLAS).apply(icon); + render(poseStack, renderTypeBuffer, light, packedRgb, sprite); + } + + private static void render(final PoseStack poseStack, + final int x, + final int y, + final int packedRgb, + final TextureAtlasSprite sprite) { + RenderSystem.setShaderTexture(0, sprite.atlasLocation()); + final int r = packedRgb >> 16 & 255; + final int g = packedRgb >> 8 & 255; + final int b = packedRgb & 255; + final int slotXEnd = x + 16; + final int slotYEnd = y + 16; + RenderSystem.setShader(GameRenderer::getPositionTexColorShader); + final Tesselator tesselator = Tesselator.getInstance(); + final BufferBuilder bufferBuilder = tesselator.begin( + VertexFormat.Mode.QUADS, + DefaultVertexFormat.POSITION_TEX_COLOR + ); + bufferBuilder.addVertex(poseStack.last().pose(), (float) x, (float) slotYEnd, 0.0F) + .setUv(sprite.getU0(), sprite.getV1()).setColor(r, g, b, 255); + bufferBuilder.addVertex(poseStack.last().pose(), (float) slotXEnd, (float) slotYEnd, 0.0F) + .setUv(sprite.getU1(), sprite.getV1()).setColor(r, g, b, 255); + bufferBuilder.addVertex(poseStack.last().pose(), (float) slotXEnd, (float) y, 0.0F) + .setUv(sprite.getU1(), sprite.getV0()).setColor(r, g, b, 255); + bufferBuilder.addVertex(poseStack.last().pose(), (float) x, (float) y, 0.0F) + .setUv(sprite.getU0(), sprite.getV0()).setColor(r, g, b, 255); + BufferUploader.drawWithShader(bufferBuilder.buildOrThrow()); + } + + private static void render(final PoseStack poseStack, + final MultiBufferSource buffers, + final int light, + final int packedRgb, + final TextureAtlasSprite sprite) { + final VertexConsumer buffer = buffers.getBuffer(RenderType.solid()); + final float scale = 0.3F; + // y is flipped here + final var x0 = -scale / 2; + final var y0 = scale / 2; + final var x1 = scale / 2; + final var y1 = -scale / 2; + final var transform = poseStack.last().pose(); + buffer.addVertex(transform, x0, y1, 0) + .setColor(packedRgb) + .setUv(sprite.getU0(), sprite.getV1()) + .setOverlay(OverlayTexture.NO_OVERLAY) + .setLight(light) + .setNormal(0, 0, 1); + buffer.addVertex(transform, x1, y1, 0) + .setColor(packedRgb) + .setUv(sprite.getU1(), sprite.getV1()) + .setOverlay(OverlayTexture.NO_OVERLAY) + .setLight(light) + .setNormal(0, 0, 1); + buffer.addVertex(transform, x1, y0, 0) + .setColor(packedRgb) + .setUv(sprite.getU1(), sprite.getV0()) + .setOverlay(OverlayTexture.NO_OVERLAY) + .setLight(light) + .setNormal(0, 0, 1); + buffer.addVertex(transform, x0, y0, 0) + .setColor(packedRgb) + .setUv(sprite.getU0(), sprite.getV0()) + .setOverlay(OverlayTexture.NO_OVERLAY) + .setLight(light) + .setNormal(0, 0, 1); + } +} diff --git a/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalResource.java b/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalResource.java new file mode 100644 index 0000000..4c0827d --- /dev/null +++ b/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalResource.java @@ -0,0 +1,45 @@ +package com.refinedmods.refinedstorage.mekanism.chemical; + +import com.refinedmods.refinedstorage.common.Platform; +import com.refinedmods.refinedstorage.common.api.support.resource.PlatformResourceKey; +import com.refinedmods.refinedstorage.common.api.support.resource.ResourceTag; +import com.refinedmods.refinedstorage.common.api.support.resource.ResourceType; +import com.refinedmods.refinedstorage.common.support.resource.ResourceTypes; + +import java.util.List; + +import mekanism.api.MekanismAPI; +import mekanism.api.chemical.Chemical; +import mekanism.api.chemical.ChemicalStack; + +public record ChemicalResource(Chemical chemical) implements PlatformResourceKey { + public static ChemicalResource ofChemicalStack(final ChemicalStack stack) { + return new ChemicalResource(stack.getChemical()); + } + + @Override + public long getInterfaceExportLimit() { + return ResourceTypes.FLUID.getInterfaceExportLimit(); + } + + @Override + public long getProcessingPatternLimit() { + return Platform.INSTANCE.getBucketAmount() * 16; + } + + @Override + public List getTags() { + return MekanismAPI.CHEMICAL_REGISTRY.wrapAsHolder(chemical) + .tags() + .flatMap(tagKey -> MekanismAPI.CHEMICAL_REGISTRY.getTag(tagKey).stream()) + .map(tag -> new ResourceTag( + tag.key(), + tag.stream().map(holder -> (PlatformResourceKey) new ChemicalResource(holder.value())).toList() + )).toList(); + } + + @Override + public ResourceType getResourceType() { + return ChemicalResourceType.INSTANCE; + } +} diff --git a/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalResourceContainerInsertStrategy.java b/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalResourceContainerInsertStrategy.java new file mode 100644 index 0000000..38fdb2b --- /dev/null +++ b/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalResourceContainerInsertStrategy.java @@ -0,0 +1,46 @@ +package com.refinedmods.refinedstorage.mekanism.chemical; + +import com.refinedmods.refinedstorage.api.resource.ResourceAmount; +import com.refinedmods.refinedstorage.api.resource.ResourceKey; +import com.refinedmods.refinedstorage.common.Platform; +import com.refinedmods.refinedstorage.common.api.support.resource.ResourceContainerInsertStrategy; + +import java.util.Optional; + +import mekanism.api.Action; +import mekanism.api.chemical.Chemical; +import mekanism.api.chemical.ChemicalStack; +import net.minecraft.world.item.ItemStack; + +public class ChemicalResourceContainerInsertStrategy implements ResourceContainerInsertStrategy { + @Override + public Optional insert(final ItemStack container, final ResourceAmount resourceAmount) { + if (!(resourceAmount.resource() instanceof ChemicalResource(Chemical chemical))) { + return Optional.empty(); + } + final ItemStack modifiedContainer = container.copy(); + return Optional.ofNullable(modifiedContainer.getCapability(ChemicalResourceType.ITEM_CAPABILITY)) + .map(handler -> handler.insertChemical( + new ChemicalStack(chemical, resourceAmount.amount()), + Action.EXECUTE + )) + .map(remainder -> resourceAmount.amount() - remainder.getAmount()) + .map(inserted -> new InsertResult(modifiedContainer, inserted)); + } + + // TODO: IFace max is wrong! + @Override + public Optional getConversionInfo(final ResourceKey resource, final ItemStack carriedStack) { + if (!(resource instanceof ChemicalResource(Chemical chemical))) { + return Optional.empty(); + } + final ItemStack modifiedStack = carriedStack.copy(); + return Optional.ofNullable(modifiedStack.getCapability(ChemicalResourceType.ITEM_CAPABILITY)) + .map(handler -> handler.insertChemical( + new ChemicalStack(chemical, Platform.INSTANCE.getBucketAmount()), + Action.EXECUTE + )) + .filter(ChemicalStack::isEmpty) + .map(result -> new ConversionInfo(carriedStack, modifiedStack)); + } +} diff --git a/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalResourceFactory.java b/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalResourceFactory.java new file mode 100644 index 0000000..b235e10 --- /dev/null +++ b/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalResourceFactory.java @@ -0,0 +1,26 @@ +package com.refinedmods.refinedstorage.mekanism.chemical; + +import com.refinedmods.refinedstorage.api.resource.ResourceAmount; +import com.refinedmods.refinedstorage.api.resource.ResourceKey; +import com.refinedmods.refinedstorage.common.api.support.resource.ResourceFactory; + +import java.util.Optional; + +import mekanism.api.Action; +import net.minecraft.world.item.ItemStack; + +import static com.refinedmods.refinedstorage.mekanism.chemical.ChemicalResource.ofChemicalStack; + +public class ChemicalResourceFactory implements ResourceFactory { + @Override + public Optional create(final ItemStack stack) { + return Optional.ofNullable(stack.getCapability(ChemicalResourceType.ITEM_CAPABILITY)) + .map(handler -> handler.extractChemical(Long.MAX_VALUE, Action.SIMULATE)) + .map(chemicalStack -> new ResourceAmount(ofChemicalStack(chemicalStack), chemicalStack.getAmount())); + } + + @Override + public boolean isValid(final ResourceKey resourceKey) { + return resourceKey instanceof ChemicalResource; + } +} diff --git a/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalResourceRendering.java b/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalResourceRendering.java new file mode 100644 index 0000000..701949b --- /dev/null +++ b/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalResourceRendering.java @@ -0,0 +1,86 @@ +package com.refinedmods.refinedstorage.mekanism.chemical; + +import com.refinedmods.refinedstorage.api.resource.ResourceKey; +import com.refinedmods.refinedstorage.common.api.support.resource.ResourceRendering; +import com.refinedmods.refinedstorage.common.util.IdentifierUtil; + +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.util.Collections; +import java.util.List; +import java.util.Locale; + +import com.mojang.blaze3d.vertex.PoseStack; +import mekanism.api.chemical.Chemical; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.network.chat.Component; +import net.minecraft.world.level.Level; +import net.neoforged.neoforge.fluids.FluidType; + +public class ChemicalResourceRendering implements ResourceRendering { + private static final DecimalFormat LESS_THAN_1_BUCKET_FORMATTER; + private static final DecimalFormat FORMATTER; + + @Override + public String formatAmount(final long amount, final boolean withUnits) { + return !withUnits ? format(amount) : formatWithUnits(amount); + } + + @Override + public Component getDisplayName(final ResourceKey resourceKey) { + if (resourceKey instanceof ChemicalResource(Chemical chemical)) { + return chemical.getTextComponent(); + } + return Component.empty(); + } + + @Override + public List getTooltip(final ResourceKey resourceKey) { + if (resourceKey instanceof ChemicalResource(Chemical chemical)) { + return List.of(chemical.getTextComponent()); + } + return Collections.emptyList(); + } + + @Override + public void render(final ResourceKey resourceKey, final GuiGraphics graphics, final int x, final int y) { + if (resourceKey instanceof ChemicalResource(Chemical chemical)) { + ChemicalRenderer.render(graphics.pose(), x, y, chemical); + } + } + + @Override + public void render(final ResourceKey resourceKey, + final PoseStack poseStack, + final MultiBufferSource multiBufferSource, + final int light, + final Level level) { + if (resourceKey instanceof ChemicalResource(Chemical chemical)) { + ChemicalRenderer.render(poseStack, multiBufferSource, light, chemical); + } + } + + private static String formatWithUnits(final long mb) { + final double buckets = convertToBuckets(mb); + if (buckets >= 1) { + return IdentifierUtil.formatWithUnits((long) Math.floor(buckets)); + } else { + return LESS_THAN_1_BUCKET_FORMATTER.format(buckets); + } + } + + public static String format(final long mb) { + final double buckets = convertToBuckets(mb); + return FORMATTER.format(buckets); + } + + private static double convertToBuckets(final long mb) { + return mb / (double) FluidType.BUCKET_VOLUME; + } + + static { + LESS_THAN_1_BUCKET_FORMATTER = new DecimalFormat("0.#", DecimalFormatSymbols.getInstance(Locale.US)); + FORMATTER = new DecimalFormat("#,###.#", DecimalFormatSymbols.getInstance(Locale.US)); + } +} diff --git a/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalResourceType.java b/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalResourceType.java new file mode 100644 index 0000000..6e341d5 --- /dev/null +++ b/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalResourceType.java @@ -0,0 +1,116 @@ +package com.refinedmods.refinedstorage.mekanism.chemical; + +import com.refinedmods.refinedstorage.api.grid.operations.GridOperations; +import com.refinedmods.refinedstorage.api.grid.operations.GridOperationsImpl; +import com.refinedmods.refinedstorage.api.grid.view.GridResource; +import com.refinedmods.refinedstorage.api.resource.ResourceKey; +import com.refinedmods.refinedstorage.api.storage.Actor; +import com.refinedmods.refinedstorage.api.storage.root.RootStorage; +import com.refinedmods.refinedstorage.common.Platform; +import com.refinedmods.refinedstorage.common.api.storage.StorageType; +import com.refinedmods.refinedstorage.common.api.support.resource.PlatformResourceKey; +import com.refinedmods.refinedstorage.common.api.support.resource.ResourceType; +import com.refinedmods.refinedstorage.common.storage.SameTypeStorageType; + +import java.util.Optional; + +import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import mekanism.api.MekanismAPI; +import mekanism.api.chemical.Chemical; +import mekanism.api.chemical.IChemicalHandler; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.resources.ResourceLocation; +import net.neoforged.neoforge.capabilities.ItemCapability; + +import static com.refinedmods.refinedstorage.mekanism.MekanismIntegrationIdentifierUtil.createMekanismIntegrationIdentifier; +import static com.refinedmods.refinedstorage.mekanism.MekanismIntegrationIdentifierUtil.createMekanismIntegrationTranslation; + +public class ChemicalResourceType implements ResourceType { + public static final ChemicalResourceType INSTANCE = new ChemicalResourceType(); + + public static final MapCodec MAP_CODEC = RecordCodecBuilder.mapCodec(ins -> ins.group( + Chemical.CODEC.fieldOf("chemical").forGetter(ChemicalResource::chemical) + ).apply(ins, ChemicalResource::new)); + public static final Codec CODEC = MAP_CODEC.codec(); + public static final StreamCodec STREAM_CODEC = StreamCodec.composite( + Chemical.STREAM_CODEC, ChemicalResource::chemical, + ChemicalResource::new + ); + public static final ItemCapability ITEM_CAPABILITY = ItemCapability.createVoid( + ResourceLocation.fromNamespaceAndPath(MekanismAPI.MEKANISM_MODID, "chemical_handler"), + IChemicalHandler.class + ); + public static final StorageType STORAGE_TYPE = new SameTypeStorageType<>( + CODEC, + resource -> resource instanceof ChemicalResource(Chemical chemical) + && !chemical.hasAttributesWithValidation(), + ChemicalResource.class::cast, + Platform.INSTANCE.getBucketAmount(), + Platform.INSTANCE.getBucketAmount() * 16 + ); + + private static final MutableComponent TITLE = createMekanismIntegrationTranslation( + "misc", + "resource_type.chemical" + ); + private static final ResourceLocation SPRITE = createMekanismIntegrationIdentifier("chemical_resource_type"); + + private ChemicalResourceType() { + } + + @Override + @SuppressWarnings({"unchecked", "rawtypes"}) + public MapCodec getMapCodec() { + return (MapCodec) MAP_CODEC; + } + + @Override + @SuppressWarnings({"unchecked", "rawtypes"}) + public StreamCodec getStreamCodec() { + return (StreamCodec) STREAM_CODEC; + } + + @Override + public MutableComponent getTitle() { + return TITLE; + } + + @Override + public ResourceLocation getSprite() { + return SPRITE; + } + + @Override + public long normalizeAmount(final double amount) { + return (long) (amount * Platform.INSTANCE.getBucketAmount()); + } + + @Override + public double getDisplayAmount(final long amount) { + return amount / (double) Platform.INSTANCE.getBucketAmount(); + } + + @Override + public Optional toGridResource(final ResourceKey resourceKey, final boolean autocraftable) { + return ChemicalGridResourceFactory.INSTANCE.apply(resourceKey, autocraftable); + } + + @Override + public long getInterfaceExportLimit() { + return Platform.INSTANCE.getBucketAmount() * 16; + } + + @Override + public GridOperations createGridOperations(final RootStorage rootStorage, final Actor actor) { + return new GridOperationsImpl( + rootStorage, + actor, + resource -> Long.MAX_VALUE, + Platform.INSTANCE.getBucketAmount() + ); + } +} diff --git a/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalStorageDiskItem.java b/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalStorageDiskItem.java new file mode 100644 index 0000000..af4d1f7 --- /dev/null +++ b/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalStorageDiskItem.java @@ -0,0 +1,95 @@ +package com.refinedmods.refinedstorage.mekanism.chemical; + +import com.refinedmods.refinedstorage.common.api.storage.AbstractStorageContainerItem; +import com.refinedmods.refinedstorage.common.api.storage.SerializableStorage; +import com.refinedmods.refinedstorage.common.api.storage.StorageContainerItemHelper; +import com.refinedmods.refinedstorage.common.api.storage.StorageRepository; +import com.refinedmods.refinedstorage.common.api.support.HelpTooltipComponent; +import com.refinedmods.refinedstorage.common.storage.StorageVariant; +import com.refinedmods.refinedstorage.common.storage.UpgradeableStorageContainer; +import com.refinedmods.refinedstorage.mekanism.Items; + +import java.util.Optional; +import javax.annotation.Nullable; + +import net.minecraft.network.chat.Component; +import net.minecraft.world.inventory.tooltip.TooltipComponent; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; + +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.format; +import static com.refinedmods.refinedstorage.mekanism.MekanismIntegrationIdentifierUtil.createMekanismIntegrationTranslation; + +public class ChemicalStorageDiskItem extends AbstractStorageContainerItem implements UpgradeableStorageContainer { + private static final Component CREATIVE_HELP = createMekanismIntegrationTranslation( + "item", + "creative_chemical_storage_disk.help" + ); + + private final ChemicalStorageVariant variant; + private final Component helpText; + + public ChemicalStorageDiskItem(final StorageContainerItemHelper helper, + final ChemicalStorageVariant variant) { + super(new Item.Properties().stacksTo(1).fireResistant(), helper); + this.variant = variant; + this.helpText = getHelpText(variant); + } + + private static Component getHelpText(final ChemicalStorageVariant variant) { + if (variant.getCapacityInBuckets() == null) { + return CREATIVE_HELP; + } + return createMekanismIntegrationTranslation( + "item", + "chemical_storage_disk.help", + format(variant.getCapacityInBuckets()) + ); + } + + + @Override + @Nullable + protected Long getCapacity() { + return variant.getCapacity(); + } + + @Override + protected String formatAmount(final long amount) { + return ChemicalResourceRendering.format(amount); + } + + @Override + protected SerializableStorage createStorage(final StorageRepository storageRepository) { + return ChemicalResourceType.STORAGE_TYPE.create(getCapacity(), storageRepository::markAsChanged); + } + + @Override + protected ItemStack createPrimaryDisassemblyByproduct(final int count) { + return new ItemStack(com.refinedmods.refinedstorage.common.content.Items.INSTANCE.getStorageHousing(), count); + } + + @Override + @Nullable + protected ItemStack createSecondaryDisassemblyByproduct(final int count) { + if (variant == ChemicalStorageVariant.CREATIVE) { + return null; + } + return new ItemStack(Items.INSTANCE.getChemicalStoragePart(variant), count); + } + + @Override + public Optional getTooltipImage(final ItemStack stack) { + return Optional.of(new HelpTooltipComponent(helpText)); + } + + @Override + public StorageVariant getVariant() { + return variant; + } + + @Override + public void transferTo(final ItemStack from, final ItemStack to) { + helper.markAsToTransfer(from, to); + } +} diff --git a/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalStorageMonitorInsertionStrategy.java b/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalStorageMonitorInsertionStrategy.java new file mode 100644 index 0000000..3276917 --- /dev/null +++ b/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalStorageMonitorInsertionStrategy.java @@ -0,0 +1,82 @@ +package com.refinedmods.refinedstorage.mekanism.chemical; + +import com.refinedmods.refinedstorage.api.core.Action; +import com.refinedmods.refinedstorage.api.network.Network; +import com.refinedmods.refinedstorage.api.network.storage.StorageNetworkComponent; +import com.refinedmods.refinedstorage.api.resource.ResourceKey; +import com.refinedmods.refinedstorage.api.storage.Actor; +import com.refinedmods.refinedstorage.api.storage.root.RootStorage; +import com.refinedmods.refinedstorage.common.api.storagemonitor.StorageMonitorInsertionStrategy; + +import java.util.Optional; +import javax.annotation.Nullable; + +import mekanism.api.chemical.ChemicalStack; +import mekanism.api.chemical.IChemicalHandler; +import net.minecraft.world.item.ItemStack; + +import static com.refinedmods.refinedstorage.mekanism.chemical.ChemicalResource.ofChemicalStack; + +public class ChemicalStorageMonitorInsertionStrategy implements StorageMonitorInsertionStrategy { + @Override + public Optional insert( + final ResourceKey configuredResource, + final ItemStack stack, + final Actor actor, + final Network network + ) { + if (!(configuredResource instanceof ChemicalResource configuredChemicalResource)) { + return Optional.empty(); + } + final RootStorage rootStorage = network.getComponent(StorageNetworkComponent.class); + final ItemStack modifiedStack = stack.copy(); + return Optional.ofNullable(modifiedStack.getCapability(ChemicalResourceType.ITEM_CAPABILITY)) + .map(handler -> handleInsert(actor, configuredChemicalResource, handler, rootStorage, modifiedStack)); + } + + @Nullable + private ItemStack handleInsert(final Actor actor, + final ChemicalResource configuredChemicalResource, + final IChemicalHandler handler, + final RootStorage rootStorage, + final ItemStack modifiedStack) { + final ChemicalStack extractedSimulated = handler.extractChemical(Long.MAX_VALUE, mekanism.api.Action.SIMULATE); + if (extractedSimulated.isEmpty()) { + return null; + } + final long insertedSimulated = tryInsert(actor, configuredChemicalResource, extractedSimulated, rootStorage); + if (insertedSimulated == 0) { + return null; + } + final ChemicalStack extracted = handler.extractChemical(insertedSimulated, mekanism.api.Action.EXECUTE); + if (extracted.isEmpty()) { + return null; + } + doInsert(actor, extracted, rootStorage); + return modifiedStack; + } + + private long tryInsert(final Actor actor, + final ChemicalResource configuredResource, + final ChemicalStack result, + final RootStorage rootStorage) { + if (!result.getChemical().equals(configuredResource.chemical())) { + return 0; + } + return rootStorage.insert( + ofChemicalStack(result), + result.getAmount(), + Action.SIMULATE, + actor + ); + } + + private void doInsert(final Actor actor, final ChemicalStack result, final RootStorage rootStorage) { + rootStorage.insert( + ofChemicalStack(result), + result.getAmount(), + Action.EXECUTE, + actor + ); + } +} diff --git a/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalStorageVariant.java b/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalStorageVariant.java new file mode 100644 index 0000000..91715cf --- /dev/null +++ b/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/ChemicalStorageVariant.java @@ -0,0 +1,74 @@ +package com.refinedmods.refinedstorage.mekanism.chemical; + +import com.refinedmods.refinedstorage.common.Platform; +import com.refinedmods.refinedstorage.common.storage.StorageVariant; +import com.refinedmods.refinedstorage.mekanism.Items; + +import javax.annotation.Nullable; + +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.StringRepresentable; +import net.minecraft.world.item.Item; + +import static com.refinedmods.refinedstorage.mekanism.MekanismIntegrationIdentifierUtil.createMekanismIntegrationIdentifier; + +public enum ChemicalStorageVariant implements StringRepresentable, StorageVariant { + SIXTY_FOUR_B("64b", 64L), + TWO_HUNDRED_FIFTY_SIX_B("256b", 256L), + THOUSAND_TWENTY_FOUR_B("1024b", 1024L), + EIGHT_THOUSAND_NINETY_TWO_B("8192b", 8192L), + CREATIVE("creative", null); + + private final String name; + private final ResourceLocation storageDiskId; + @Nullable + private final ResourceLocation storagePartId; + @Nullable + private final Long capacityInBuckets; + + ChemicalStorageVariant(final String name, @Nullable final Long capacityInBuckets) { + this.name = name; + this.storagePartId = capacityInBuckets != null + ? createMekanismIntegrationIdentifier(name + "_chemical_storage_part") + : null; + this.storageDiskId = createMekanismIntegrationIdentifier(name + "_chemical_storage_disk"); + this.capacityInBuckets = capacityInBuckets; + } + + @Nullable + public Long getCapacityInBuckets() { + return capacityInBuckets; + } + + @Override + @Nullable + public Long getCapacity() { + if (capacityInBuckets == null) { + return null; + } + return capacityInBuckets * Platform.INSTANCE.getBucketAmount(); + } + + @Nullable + @Override + public Item getStoragePart() { + if (this == CREATIVE) { + return null; + } + return Items.INSTANCE.getChemicalStoragePart(this); + } + + public ResourceLocation getStorageDiskId() { + return storageDiskId; + } + + @Nullable + public ResourceLocation getStoragePartId() { + return storagePartId; + } + + @Override + public String getSerializedName() { + return name; + } +} diff --git a/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/package-info.java b/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/package-info.java new file mode 100644 index 0000000..24b2a8b --- /dev/null +++ b/src/main/java/com/refinedmods/refinedstorage/mekanism/chemical/package-info.java @@ -0,0 +1,7 @@ +@ParametersAreNonnullByDefault +@FieldsAndMethodsAreNonnullByDefault +package com.refinedmods.refinedstorage.mekanism.chemical; + +import com.refinedmods.refinedstorage.api.core.FieldsAndMethodsAreNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/resources/assets/refinedstorage_mekanism_integration/lang/en_us.json b/src/main/resources/assets/refinedstorage_mekanism_integration/lang/en_us.json index 7a73a41..59a357e 100644 --- a/src/main/resources/assets/refinedstorage_mekanism_integration/lang/en_us.json +++ b/src/main/resources/assets/refinedstorage_mekanism_integration/lang/en_us.json @@ -1,2 +1,16 @@ { + "misc.refinedstorage_mekanism_integration.resource_type.chemical": "Chemical", + "item.refinedstorage_mekanism_integration.64b_chemical_storage_part": "64B Chemical Storage Part", + "item.refinedstorage_mekanism_integration.256b_chemical_storage_part": "256B Chemical Storage Part", + "item.refinedstorage_mekanism_integration.1024b_chemical_storage_part": "1024B Chemical Storage Part", + "item.refinedstorage_mekanism_integration.8192b_chemical_storage_part": "8192B Chemical Storage Part", + "item.refinedstorage_mekanism_integration.64b_chemical_storage_disk": "64B Chemical Storage Disk", + "item.refinedstorage_mekanism_integration.256b_chemical_storage_disk": "256B Chemical Storage Disk", + "item.refinedstorage_mekanism_integration.1024b_chemical_storage_disk": "1024B Chemical Storage Disk", + "item.refinedstorage_mekanism_integration.8192b_chemical_storage_disk": "8192B Chemical Storage Disk", + "item.refinedstorage_mekanism_integration.creative_chemical_storage_disk": "Creative Chemical Storage Disk", + "item.refinedstorage_mekanism_integration.chemical_storage_disk.help": "Stores %s buckets.", + "item.refinedstorage_mekanism_integration.creative_chemical_storage_disk.help": "Stores an infinite amount of buckets.", + "advancements.refinedstorage_mekanism_integration.storing_chemicals": "Storing chemicals", + "advancements.refinedstorage_mekanism_integration.storing_chemicals.description": "Craft a Chemical Storage Disk and put it in your Disk Drive" } \ No newline at end of file diff --git a/src/main/resources/assets/refinedstorage_mekanism_integration/models/item/1024b_chemical_storage_disk.json b/src/main/resources/assets/refinedstorage_mekanism_integration/models/item/1024b_chemical_storage_disk.json new file mode 100644 index 0000000..0a14888 --- /dev/null +++ b/src/main/resources/assets/refinedstorage_mekanism_integration/models/item/1024b_chemical_storage_disk.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "refinedstorage_mekanism_integration:item/1024b_chemical_storage_disk" + } +} diff --git a/src/main/resources/assets/refinedstorage_mekanism_integration/models/item/1024b_chemical_storage_part.json b/src/main/resources/assets/refinedstorage_mekanism_integration/models/item/1024b_chemical_storage_part.json new file mode 100644 index 0000000..43c56fc --- /dev/null +++ b/src/main/resources/assets/refinedstorage_mekanism_integration/models/item/1024b_chemical_storage_part.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "refinedstorage_mekanism_integration:item/1024b_chemical_storage_part" + } +} diff --git a/src/main/resources/assets/refinedstorage_mekanism_integration/models/item/256b_chemical_storage_disk.json b/src/main/resources/assets/refinedstorage_mekanism_integration/models/item/256b_chemical_storage_disk.json new file mode 100644 index 0000000..33d936a --- /dev/null +++ b/src/main/resources/assets/refinedstorage_mekanism_integration/models/item/256b_chemical_storage_disk.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "refinedstorage_mekanism_integration:item/256b_chemical_storage_disk" + } +} diff --git a/src/main/resources/assets/refinedstorage_mekanism_integration/models/item/256b_chemical_storage_part.json b/src/main/resources/assets/refinedstorage_mekanism_integration/models/item/256b_chemical_storage_part.json new file mode 100644 index 0000000..81a5b1b --- /dev/null +++ b/src/main/resources/assets/refinedstorage_mekanism_integration/models/item/256b_chemical_storage_part.json @@ -0,0 +1 @@ +{ "parent": "item/generated", "textures": { "layer0": "refinedstorage_mekanism_integration:item/256b_chemical_storage_part" } } \ No newline at end of file diff --git a/src/main/resources/assets/refinedstorage_mekanism_integration/models/item/64b_chemical_storage_disk.json b/src/main/resources/assets/refinedstorage_mekanism_integration/models/item/64b_chemical_storage_disk.json new file mode 100644 index 0000000..798bc93 --- /dev/null +++ b/src/main/resources/assets/refinedstorage_mekanism_integration/models/item/64b_chemical_storage_disk.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "refinedstorage_mekanism_integration:item/64b_chemical_storage_disk" + } +} diff --git a/src/main/resources/assets/refinedstorage_mekanism_integration/models/item/64b_chemical_storage_part.json b/src/main/resources/assets/refinedstorage_mekanism_integration/models/item/64b_chemical_storage_part.json new file mode 100644 index 0000000..c4eced1 --- /dev/null +++ b/src/main/resources/assets/refinedstorage_mekanism_integration/models/item/64b_chemical_storage_part.json @@ -0,0 +1 @@ +{ "parent": "item/generated", "textures": { "layer0": "refinedstorage_mekanism_integration:item/64b_chemical_storage_part" } } \ No newline at end of file diff --git a/src/main/resources/assets/refinedstorage_mekanism_integration/models/item/8192b_chemical_storage_disk.json b/src/main/resources/assets/refinedstorage_mekanism_integration/models/item/8192b_chemical_storage_disk.json new file mode 100644 index 0000000..a76fdc8 --- /dev/null +++ b/src/main/resources/assets/refinedstorage_mekanism_integration/models/item/8192b_chemical_storage_disk.json @@ -0,0 +1 @@ +{ "parent": "item/generated", "textures": { "layer0": "refinedstorage_mekanism_integration:item/8192b_chemical_storage_disk" } } \ No newline at end of file diff --git a/src/main/resources/assets/refinedstorage_mekanism_integration/models/item/8192b_chemical_storage_part.json b/src/main/resources/assets/refinedstorage_mekanism_integration/models/item/8192b_chemical_storage_part.json new file mode 100644 index 0000000..400b2e7 --- /dev/null +++ b/src/main/resources/assets/refinedstorage_mekanism_integration/models/item/8192b_chemical_storage_part.json @@ -0,0 +1 @@ +{ "parent": "item/generated", "textures": { "layer0": "refinedstorage_mekanism_integration:item/8192b_chemical_storage_part" } } \ No newline at end of file diff --git a/src/main/resources/assets/refinedstorage_mekanism_integration/models/item/creative_chemical_storage_disk.json b/src/main/resources/assets/refinedstorage_mekanism_integration/models/item/creative_chemical_storage_disk.json new file mode 100644 index 0000000..d7c807d --- /dev/null +++ b/src/main/resources/assets/refinedstorage_mekanism_integration/models/item/creative_chemical_storage_disk.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "refinedstorage_mekanism_integration:item/creative_chemical_storage_disk" + } +} diff --git a/src/main/resources/assets/refinedstorage_mekanism_integration/textures/gui/sprites/chemical_resource_type.png b/src/main/resources/assets/refinedstorage_mekanism_integration/textures/gui/sprites/chemical_resource_type.png new file mode 100644 index 0000000..32227a3 Binary files /dev/null and b/src/main/resources/assets/refinedstorage_mekanism_integration/textures/gui/sprites/chemical_resource_type.png differ diff --git a/src/main/resources/assets/refinedstorage_mekanism_integration/textures/item/1024b_chemical_storage_disk.png b/src/main/resources/assets/refinedstorage_mekanism_integration/textures/item/1024b_chemical_storage_disk.png new file mode 100644 index 0000000..d7bf7d4 Binary files /dev/null and b/src/main/resources/assets/refinedstorage_mekanism_integration/textures/item/1024b_chemical_storage_disk.png differ diff --git a/src/main/resources/assets/refinedstorage_mekanism_integration/textures/item/1024b_chemical_storage_part.png b/src/main/resources/assets/refinedstorage_mekanism_integration/textures/item/1024b_chemical_storage_part.png new file mode 100644 index 0000000..a05f867 Binary files /dev/null and b/src/main/resources/assets/refinedstorage_mekanism_integration/textures/item/1024b_chemical_storage_part.png differ diff --git a/src/main/resources/assets/refinedstorage_mekanism_integration/textures/item/256b_chemical_storage_disk.png b/src/main/resources/assets/refinedstorage_mekanism_integration/textures/item/256b_chemical_storage_disk.png new file mode 100644 index 0000000..65eccd1 Binary files /dev/null and b/src/main/resources/assets/refinedstorage_mekanism_integration/textures/item/256b_chemical_storage_disk.png differ diff --git a/src/main/resources/assets/refinedstorage_mekanism_integration/textures/item/256b_chemical_storage_part.png b/src/main/resources/assets/refinedstorage_mekanism_integration/textures/item/256b_chemical_storage_part.png new file mode 100644 index 0000000..cda47fb Binary files /dev/null and b/src/main/resources/assets/refinedstorage_mekanism_integration/textures/item/256b_chemical_storage_part.png differ diff --git a/src/main/resources/assets/refinedstorage_mekanism_integration/textures/item/64b_chemical_storage_disk.png b/src/main/resources/assets/refinedstorage_mekanism_integration/textures/item/64b_chemical_storage_disk.png new file mode 100644 index 0000000..187b7ef Binary files /dev/null and b/src/main/resources/assets/refinedstorage_mekanism_integration/textures/item/64b_chemical_storage_disk.png differ diff --git a/src/main/resources/assets/refinedstorage_mekanism_integration/textures/item/64b_chemical_storage_part.png b/src/main/resources/assets/refinedstorage_mekanism_integration/textures/item/64b_chemical_storage_part.png new file mode 100644 index 0000000..419ffca Binary files /dev/null and b/src/main/resources/assets/refinedstorage_mekanism_integration/textures/item/64b_chemical_storage_part.png differ diff --git a/src/main/resources/assets/refinedstorage_mekanism_integration/textures/item/8192b_chemical_storage_disk.png b/src/main/resources/assets/refinedstorage_mekanism_integration/textures/item/8192b_chemical_storage_disk.png new file mode 100644 index 0000000..bc2e709 Binary files /dev/null and b/src/main/resources/assets/refinedstorage_mekanism_integration/textures/item/8192b_chemical_storage_disk.png differ diff --git a/src/main/resources/assets/refinedstorage_mekanism_integration/textures/item/8192b_chemical_storage_part.png b/src/main/resources/assets/refinedstorage_mekanism_integration/textures/item/8192b_chemical_storage_part.png new file mode 100644 index 0000000..02624fe Binary files /dev/null and b/src/main/resources/assets/refinedstorage_mekanism_integration/textures/item/8192b_chemical_storage_part.png differ diff --git a/src/main/resources/assets/refinedstorage_mekanism_integration/textures/item/creative_chemical_storage_disk.png b/src/main/resources/assets/refinedstorage_mekanism_integration/textures/item/creative_chemical_storage_disk.png new file mode 100644 index 0000000..2910291 Binary files /dev/null and b/src/main/resources/assets/refinedstorage_mekanism_integration/textures/item/creative_chemical_storage_disk.png differ diff --git a/src/main/resources/data/refinedstorage_mekanism_integration/advancement/storing_chemicals.json b/src/main/resources/data/refinedstorage_mekanism_integration/advancement/storing_chemicals.json new file mode 100644 index 0000000..31f54f5 --- /dev/null +++ b/src/main/resources/data/refinedstorage_mekanism_integration/advancement/storing_chemicals.json @@ -0,0 +1,26 @@ +{ + "display": { + "icon": { + "id": "refinedstorage_mekanism_integration:64b_chemical_storage_disk" + }, + "title": { + "translate": "advancements.refinedstorage_mekanism_integration.storing_chemicals" + }, + "description": { + "translate": "advancements.refinedstorage_mekanism_integration.storing_chemicals.description" + } + }, + "parent": "refinedstorage:drives", + "criteria": { + "chemical_storage_disk_in_inventory": { + "trigger": "minecraft:inventory_changed", + "conditions": { + "items": [ + { + "items": "#refinedstorage_mekanism_integration:chemical_storage_disks" + } + ] + } + } + } +} diff --git a/src/main/resources/data/refinedstorage_mekanism_integration/recipe/1024b_chemical_storage_disk.json b/src/main/resources/data/refinedstorage_mekanism_integration/recipe/1024b_chemical_storage_disk.json new file mode 100644 index 0000000..3969052 --- /dev/null +++ b/src/main/resources/data/refinedstorage_mekanism_integration/recipe/1024b_chemical_storage_disk.json @@ -0,0 +1,25 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "GRG", + "RPR", + "EEE" + ], + "key": { + "G": { + "tag": "c:glass_blocks" + }, + "R": { + "tag": "c:dusts/redstone" + }, + "P": { + "item": "refinedstorage_mekanism_integration:1024b_chemical_storage_part" + }, + "E": { + "item": "mekanism:ingot_osmium" + } + }, + "result": { + "id": "refinedstorage_mekanism_integration:1024b_chemical_storage_disk" + } +} diff --git a/src/main/resources/data/refinedstorage_mekanism_integration/recipe/1024b_chemical_storage_disk_from_storage_housing.json b/src/main/resources/data/refinedstorage_mekanism_integration/recipe/1024b_chemical_storage_disk_from_storage_housing.json new file mode 100644 index 0000000..d6cde0a --- /dev/null +++ b/src/main/resources/data/refinedstorage_mekanism_integration/recipe/1024b_chemical_storage_disk_from_storage_housing.json @@ -0,0 +1,14 @@ +{ + "type": "minecraft:crafting_shapeless", + "ingredients": [ + { + "item": "refinedstorage:storage_housing" + }, + { + "item": "refinedstorage_mekanism_integration:1024b_chemical_storage_part" + } + ], + "result": { + "id": "refinedstorage_mekanism_integration:1024b_chemical_storage_disk" + } +} diff --git a/src/main/resources/data/refinedstorage_mekanism_integration/recipe/1024b_chemical_storage_disk_upgrade.json b/src/main/resources/data/refinedstorage_mekanism_integration/recipe/1024b_chemical_storage_disk_upgrade.json new file mode 100644 index 0000000..a7bc851 --- /dev/null +++ b/src/main/resources/data/refinedstorage_mekanism_integration/recipe/1024b_chemical_storage_disk_upgrade.json @@ -0,0 +1,4 @@ +{ + "type": "refinedstorage_mekanism_integration:chemical_storage_disk_upgrade", + "to": "1024b" +} \ No newline at end of file diff --git a/src/main/resources/data/refinedstorage_mekanism_integration/recipe/1024b_chemical_storage_part.json b/src/main/resources/data/refinedstorage_mekanism_integration/recipe/1024b_chemical_storage_part.json new file mode 100644 index 0000000..a103fa8 --- /dev/null +++ b/src/main/resources/data/refinedstorage_mekanism_integration/recipe/1024b_chemical_storage_part.json @@ -0,0 +1,25 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "PEP", + "SRS", + "PSP" + ], + "key": { + "P": { + "item": "refinedstorage:improved_processor" + }, + "E": { + "item": "mekanism:ingot_osmium" + }, + "S": { + "item": "refinedstorage_mekanism_integration:256b_chemical_storage_part" + }, + "R": { + "item": "mekanism:alloy_reinforced" + } + }, + "result": { + "id": "refinedstorage_mekanism_integration:1024b_chemical_storage_part" + } +} diff --git a/src/main/resources/data/refinedstorage_mekanism_integration/recipe/256b_chemical_storage_disk.json b/src/main/resources/data/refinedstorage_mekanism_integration/recipe/256b_chemical_storage_disk.json new file mode 100644 index 0000000..bf214f9 --- /dev/null +++ b/src/main/resources/data/refinedstorage_mekanism_integration/recipe/256b_chemical_storage_disk.json @@ -0,0 +1,25 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "GRG", + "RPR", + "EEE" + ], + "key": { + "G": { + "tag": "c:glass_blocks" + }, + "R": { + "tag": "c:dusts/redstone" + }, + "P": { + "item": "refinedstorage_mekanism_integration:256b_chemical_storage_part" + }, + "E": { + "item": "mekanism:ingot_osmium" + } + }, + "result": { + "id": "refinedstorage_mekanism_integration:256b_chemical_storage_disk" + } +} diff --git a/src/main/resources/data/refinedstorage_mekanism_integration/recipe/256b_chemical_storage_disk_from_storage_housing.json b/src/main/resources/data/refinedstorage_mekanism_integration/recipe/256b_chemical_storage_disk_from_storage_housing.json new file mode 100644 index 0000000..44e6e04 --- /dev/null +++ b/src/main/resources/data/refinedstorage_mekanism_integration/recipe/256b_chemical_storage_disk_from_storage_housing.json @@ -0,0 +1,14 @@ +{ + "type": "minecraft:crafting_shapeless", + "ingredients": [ + { + "item": "refinedstorage:storage_housing" + }, + { + "item": "refinedstorage_mekanism_integration:256b_chemical_storage_part" + } + ], + "result": { + "id": "refinedstorage_mekanism_integration:256b_chemical_storage_disk" + } +} diff --git a/src/main/resources/data/refinedstorage_mekanism_integration/recipe/256b_chemical_storage_disk_upgrade.json b/src/main/resources/data/refinedstorage_mekanism_integration/recipe/256b_chemical_storage_disk_upgrade.json new file mode 100644 index 0000000..2319b71 --- /dev/null +++ b/src/main/resources/data/refinedstorage_mekanism_integration/recipe/256b_chemical_storage_disk_upgrade.json @@ -0,0 +1,4 @@ +{ + "type": "refinedstorage_mekanism_integration:chemical_storage_disk_upgrade", + "to": "256b" +} \ No newline at end of file diff --git a/src/main/resources/data/refinedstorage_mekanism_integration/recipe/256b_chemical_storage_part.json b/src/main/resources/data/refinedstorage_mekanism_integration/recipe/256b_chemical_storage_part.json new file mode 100644 index 0000000..f71d05a --- /dev/null +++ b/src/main/resources/data/refinedstorage_mekanism_integration/recipe/256b_chemical_storage_part.json @@ -0,0 +1,25 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "PEP", + "SRS", + "PSP" + ], + "key": { + "P": { + "item": "refinedstorage:basic_processor" + }, + "E": { + "item": "mekanism:ingot_osmium" + }, + "S": { + "item": "refinedstorage_mekanism_integration:64b_chemical_storage_part" + }, + "R": { + "item": "mekanism:alloy_infused" + } + }, + "result": { + "id": "refinedstorage_mekanism_integration:256b_chemical_storage_part" + } +} diff --git a/src/main/resources/data/refinedstorage_mekanism_integration/recipe/64b_chemical_storage_disk.json b/src/main/resources/data/refinedstorage_mekanism_integration/recipe/64b_chemical_storage_disk.json new file mode 100644 index 0000000..15e60f1 --- /dev/null +++ b/src/main/resources/data/refinedstorage_mekanism_integration/recipe/64b_chemical_storage_disk.json @@ -0,0 +1,25 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "GRG", + "RPR", + "EEE" + ], + "key": { + "G": { + "tag": "c:glass_blocks" + }, + "R": { + "tag": "c:dusts/redstone" + }, + "P": { + "item": "refinedstorage_mekanism_integration:64b_chemical_storage_part" + }, + "E": { + "item": "mekanism:ingot_osmium" + } + }, + "result": { + "id": "refinedstorage_mekanism_integration:64b_chemical_storage_disk" + } +} diff --git a/src/main/resources/data/refinedstorage_mekanism_integration/recipe/64b_chemical_storage_disk_from_storage_housing.json b/src/main/resources/data/refinedstorage_mekanism_integration/recipe/64b_chemical_storage_disk_from_storage_housing.json new file mode 100644 index 0000000..f32cc35 --- /dev/null +++ b/src/main/resources/data/refinedstorage_mekanism_integration/recipe/64b_chemical_storage_disk_from_storage_housing.json @@ -0,0 +1,14 @@ +{ + "type": "minecraft:crafting_shapeless", + "ingredients": [ + { + "item": "refinedstorage:storage_housing" + }, + { + "item": "refinedstorage_mekanism_integration:64b_chemical_storage_part" + } + ], + "result": { + "id": "refinedstorage_mekanism_integration:64b_chemical_storage_disk" + } +} diff --git a/src/main/resources/data/refinedstorage_mekanism_integration/recipe/64b_chemical_storage_part.json b/src/main/resources/data/refinedstorage_mekanism_integration/recipe/64b_chemical_storage_part.json new file mode 100644 index 0000000..669ae13 --- /dev/null +++ b/src/main/resources/data/refinedstorage_mekanism_integration/recipe/64b_chemical_storage_part.json @@ -0,0 +1,25 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "SES", + "GRG", + "SGS" + ], + "key": { + "S": { + "tag": "c:silicon" + }, + "E": { + "item": "mekanism:ingot_osmium" + }, + "G": { + "tag": "c:glass_blocks" + }, + "R": { + "tag": "c:dusts/redstone" + } + }, + "result": { + "id": "refinedstorage_mekanism_integration:64b_chemical_storage_part" + } +} diff --git a/src/main/resources/data/refinedstorage_mekanism_integration/recipe/8192b_chemical_storage_disk.json b/src/main/resources/data/refinedstorage_mekanism_integration/recipe/8192b_chemical_storage_disk.json new file mode 100644 index 0000000..17d57ac --- /dev/null +++ b/src/main/resources/data/refinedstorage_mekanism_integration/recipe/8192b_chemical_storage_disk.json @@ -0,0 +1,25 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "GRG", + "RPR", + "EEE" + ], + "key": { + "G": { + "tag": "c:glass_blocks" + }, + "R": { + "tag": "c:dusts/redstone" + }, + "P": { + "item": "refinedstorage_mekanism_integration:8192b_chemical_storage_part" + }, + "E": { + "item": "mekanism:ingot_osmium" + } + }, + "result": { + "id": "refinedstorage_mekanism_integration:8192b_chemical_storage_disk" + } +} diff --git a/src/main/resources/data/refinedstorage_mekanism_integration/recipe/8192b_chemical_storage_disk_from_storage_housing.json b/src/main/resources/data/refinedstorage_mekanism_integration/recipe/8192b_chemical_storage_disk_from_storage_housing.json new file mode 100644 index 0000000..3665faa --- /dev/null +++ b/src/main/resources/data/refinedstorage_mekanism_integration/recipe/8192b_chemical_storage_disk_from_storage_housing.json @@ -0,0 +1,14 @@ +{ + "type": "minecraft:crafting_shapeless", + "ingredients": [ + { + "item": "refinedstorage:storage_housing" + }, + { + "item": "refinedstorage_mekanism_integration:8192b_chemical_storage_part" + } + ], + "result": { + "id": "refinedstorage_mekanism_integration:8192b_chemical_storage_disk" + } +} diff --git a/src/main/resources/data/refinedstorage_mekanism_integration/recipe/8192b_chemical_storage_disk_upgrade.json b/src/main/resources/data/refinedstorage_mekanism_integration/recipe/8192b_chemical_storage_disk_upgrade.json new file mode 100644 index 0000000..6d879f5 --- /dev/null +++ b/src/main/resources/data/refinedstorage_mekanism_integration/recipe/8192b_chemical_storage_disk_upgrade.json @@ -0,0 +1,4 @@ +{ + "type": "refinedstorage_mekanism_integration:chemical_storage_disk_upgrade", + "to": "8192b" +} \ No newline at end of file diff --git a/src/main/resources/data/refinedstorage_mekanism_integration/recipe/8192b_chemical_storage_part.json b/src/main/resources/data/refinedstorage_mekanism_integration/recipe/8192b_chemical_storage_part.json new file mode 100644 index 0000000..a684a40 --- /dev/null +++ b/src/main/resources/data/refinedstorage_mekanism_integration/recipe/8192b_chemical_storage_part.json @@ -0,0 +1,25 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "PEP", + "SRS", + "PSP" + ], + "key": { + "P": { + "item": "refinedstorage:advanced_processor" + }, + "E": { + "item": "mekanism:ingot_osmium" + }, + "S": { + "item": "refinedstorage_mekanism_integration:1024b_chemical_storage_part" + }, + "R": { + "item": "mekanism:alloy_atomic" + } + }, + "result": { + "id": "refinedstorage_mekanism_integration:8192b_chemical_storage_part" + } +} diff --git a/src/main/resources/data/refinedstorage_mekanism_integration/tags/item/chemical_storage_disks.json b/src/main/resources/data/refinedstorage_mekanism_integration/tags/item/chemical_storage_disks.json new file mode 100644 index 0000000..d737c9f --- /dev/null +++ b/src/main/resources/data/refinedstorage_mekanism_integration/tags/item/chemical_storage_disks.json @@ -0,0 +1,9 @@ +{ + "replace": false, + "values": [ + "refinedstorage_mekanism_integration:64b_chemical_storage_disk", + "refinedstorage_mekanism_integration:256b_chemical_storage_disk", + "refinedstorage_mekanism_integration:1024b_chemical_storage_disk", + "refinedstorage_mekanism_integration:8192b_chemical_storage_disk" + ] +}