Skip to content

Commit

Permalink
Merge pull request #19 from refinedmods/feat/GH-4/storage-blocks
Browse files Browse the repository at this point in the history
feat: chemical storage block
  • Loading branch information
raoulvdberge authored Dec 8, 2024
2 parents 4c485ab + 80cca6e commit 83ff962
Show file tree
Hide file tree
Showing 52 changed files with 948 additions and 33 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Added

- Chemical Storage Disk
- Chemical Storage blocks
- Chemical support in the Grid.
- Chemical support in the Storage Monitor.
- Chemical support in the Importer.
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ val emiVersion: String by project

dependencies {
api("com.refinedmods.refinedstorage:refinedstorage-neoforge:${refinedstorageVersion}")
runtimeOnly("com.refinedmods.refinedstorage:refinedstorage-jei-integration-neoforge:${refinedstorageJeiIntegrationVersion}")
// runtimeOnly("com.refinedmods.refinedstorage:refinedstorage-jei-integration-neoforge:${refinedstorageJeiIntegrationVersion}")
// runtimeOnly("com.refinedmods.refinedstorage:refinedstorage-emi-integration-neoforge:0.5.0")
compileOnlyApi("mekanism:Mekanism:${minecraftVersion}-${mekanismVersion}:api")
runtimeOnly("mekanism:Mekanism:${minecraftVersion}-${mekanismVersion}:all") {
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
refinedarchitectVersion=0.20.0
refinedstorageVersion=2.0.0-milestone.4.10
refinedstorageJeiIntegrationVersion=0.6.0
refinedstorageVersion=2.0.0-milestone.4.11
refinedstorageJeiIntegrationVersion=0.7.0
# https://www.curseforge.com/minecraft/mc-mods/mekanism/files/all
mekanismVersion=10.7.7.64
jeiVersion=19.20.0.241
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

import static com.refinedmods.refinedstorage.mekanism.ChemicalResource.ofChemicalStack;

class ChemicalResourceFactory implements ResourceFactory {
public enum ChemicalResourceFactory implements ResourceFactory {
INSTANCE;

@Override
public Optional<ResourceAmount> create(final ItemStack stack) {
return Optional.ofNullable(stack.getCapability(ChemicalUtil.ITEM_CAPABILITY))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
package com.refinedmods.refinedstorage.mekanism;

import com.refinedmods.refinedstorage.common.api.RefinedStorageApi;
import com.refinedmods.refinedstorage.common.api.RefinedStorageClientApi;
import com.refinedmods.refinedstorage.mekanism.content.Items;
import com.refinedmods.refinedstorage.mekanism.content.Menus;
import com.refinedmods.refinedstorage.mekanism.grid.ChemicalGridInsertionHint;
import com.refinedmods.refinedstorage.mekanism.storage.ChemicalStorageVariant;

import net.minecraft.client.gui.screens.MenuScreens;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent;

import static com.refinedmods.refinedstorage.mekanism.MekanismIntegrationIdentifierUtil.createMekanismIntegrationIdentifier;

Expand All @@ -16,17 +24,33 @@ private ClientModInitializer() {

@SubscribeEvent
public static void onClientSetup(final FMLClientSetupEvent e) {
RefinedStorageApi.INSTANCE.registerResourceRendering(
RefinedStorageClientApi.INSTANCE.registerResourceRendering(
ChemicalResource.class,
new ChemicalResourceRendering()
);
RefinedStorageApi.INSTANCE.addAlternativeGridInsertionHint(new ChemicalGridInsertionHint());
RefinedStorageClientApi.INSTANCE.addAlternativeGridInsertionHint(new ChemicalGridInsertionHint());
final ResourceLocation diskModel = createMekanismIntegrationIdentifier("block/disk/chemical_disk");
for (final ChemicalStorageVariant variant : ChemicalStorageVariant.values()) {
RefinedStorageApi.INSTANCE.getStorageContainerItemHelper().registerDiskModel(
RefinedStorageClientApi.INSTANCE.registerDiskModel(
Items.getChemicalStorageDisk(variant),
diskModel
);
}
}

@SubscribeEvent
public static void onRegisterMenuScreens(final RegisterMenuScreensEvent e) {
e.register(
Menus.getChemicalStorage(),
new MenuScreens.ScreenConstructor<AbstractContainerMenu, AbstractContainerScreen<AbstractContainerMenu>>() {
@Override
public AbstractContainerScreen<AbstractContainerMenu> create(final AbstractContainerMenu menu,
final Inventory inventory,
final Component title) {
return RefinedStorageClientApi.INSTANCE.createStorageBlockScreen(menu, inventory, title,
ChemicalResource.class);
}
}
);
}
}
102 changes: 102 additions & 0 deletions src/main/java/com/refinedmods/refinedstorage/mekanism/Config.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package com.refinedmods.refinedstorage.mekanism;

import net.neoforged.neoforge.common.ModConfigSpec;

import static com.refinedmods.refinedstorage.mekanism.MekanismIntegrationIdentifierUtil.createMekanismIntegrationTranslationKey;

public final class Config {
private final ModConfigSpec.Builder builder = new ModConfigSpec.Builder();
private final ModConfigSpec spec;

private final ChemicalStorageBlockEntry chemicalStorageBlock;

public Config() {
chemicalStorageBlock = new ChemicalStorageBlockEntry();
spec = builder.build();
}

private static String translationKey(final String value) {
return createMekanismIntegrationTranslationKey("config", "option." + value);
}

public ChemicalStorageBlockEntry getChemicalStorageBlock() {
return chemicalStorageBlock;
}

public ModConfigSpec getSpec() {
return spec;
}

public class ChemicalStorageBlockEntry {
private final ModConfigSpec.LongValue sixtyFourBEnergyUsage;
private final ModConfigSpec.LongValue twoHundredFiftySixBEnergyUsage;
private final ModConfigSpec.LongValue thousandTwentyFourBEnergyUsage;
private final ModConfigSpec.LongValue eightThousandHundredNinetyTwoBEnergyUsage;
private final ModConfigSpec.LongValue creativeEnergyUsage;

ChemicalStorageBlockEntry() {
builder.translation(translationKey("chemicalStorageBlock")).push("chemicalStorageBlock");
sixtyFourBEnergyUsage = builder
.translation(translationKey("chemicalStorageBlock.sixtyFourBEnergyUsage"))
.defineInRange(
"64bEnergyUsage",
2,
0,
Long.MAX_VALUE
);
twoHundredFiftySixBEnergyUsage = builder
.translation(translationKey("chemicalStorageBlock.twoHundredFiftySixBEnergyUsage"))
.defineInRange(
"256bEnergyUsage",
4,
0,
Long.MAX_VALUE
);
thousandTwentyFourBEnergyUsage = builder
.translation(translationKey("chemicalStorageBlock.thousandTwentyFourBEnergyUsage"))
.defineInRange(
"1024bEnergyUsage",
6,
0,
Long.MAX_VALUE
);
eightThousandHundredNinetyTwoBEnergyUsage = builder
.translation(translationKey("chemicalStorageBlock.eightThousandHundredNinetyTwoBEnergyUsage"))
.defineInRange(
"8192bEnergyUsage",
8,
0,
Long.MAX_VALUE
);
creativeEnergyUsage = builder
.translation(translationKey("chemicalStorageBlock.creativeEnergyUsage"))
.defineInRange(
"creativeEnergyUsage",
16,
0,
Long.MAX_VALUE
);
builder.pop();
}

public long get64bEnergyUsage() {
return sixtyFourBEnergyUsage.get();
}

public long get256bEnergyUsage() {
return twoHundredFiftySixBEnergyUsage.get();
}

public long get1024bEnergyUsage() {
return thousandTwentyFourBEnergyUsage.get();
}

public long get8192bEnergyUsage() {
return eightThousandHundredNinetyTwoBEnergyUsage.get();
}

public long getCreativeEnergyUsage() {
return creativeEnergyUsage.get();
}
}
}
Loading

0 comments on commit 83ff962

Please sign in to comment.