Skip to content

Commit

Permalink
Merge pull request #8 from refinedmods/feat/GH-1/wireless-crafting-grid
Browse files Browse the repository at this point in the history
feat: wireless crafting grid
  • Loading branch information
raoulvdberge authored Nov 24, 2024
2 parents 8233c46 + eb01b65 commit 17fbf2a
Show file tree
Hide file tree
Showing 51 changed files with 1,644 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .github/SUPPORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ Questions can be asked on [Discord](https://discordapp.com/invite/VYzsydb).

## I have found a bug

If you have found a bug, please report it on [GitHub issues](https://github.com/refinedmods/refinedarchitect-template/issues).
If you have found a bug, please report it on [GitHub issues](https://github.com/refinedmods/refinedstorage-quartz-arsenal/issues).
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,12 @@ 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

- Wireless Crafting Grid

### Changed

- You can now configure the energy usage of the Wireless Crafting Grid's recipe transfer and autocrafting.
- You can now use the Wireless Crafting Grid without being connected to a network.
2 changes: 1 addition & 1 deletion crowdin.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project_identifier: change-me
project_identifier: refined-storage-quartz-arsenal
commit_message: "chore: update translation %language% from crowdin"
append_commit_message: false
api_key_env: CROWDIN_API_KEY
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
refinedarchitectVersion=0.19.1
refinedstorageVersion=2.0.0-milestone.4.10
# Gradle
org.gradle.jvmargs=-Xmx1G
org.gradle.configureondemand=true
Expand Down
11 changes: 0 additions & 11 deletions refinedstorage-quartz-arsenal-common/build.gradle

This file was deleted.

27 changes: 27 additions & 0 deletions refinedstorage-quartz-arsenal-common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
plugins {
id("refinedarchitect.common")
}

repositories {
maven {
url = uri("https://maven.pkg.github.com/refinedmods/refinedstorage2")
credentials {
username = "anything"
password = "\u0067hp_oGjcDFCn8jeTzIj4Ke9pLoEVtpnZMP4VQgaX"
}
}
}

refinedarchitect {
common()
}

base {
archivesName.set("refinedstorage-quartz-arsenal-common")
}

val refinedstorageVersion: String by project

dependencies {
api("com.refinedmods.refinedstorage:refinedstorage-common:${refinedstorageVersion}")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.refinedmods.refinedstorage.quartzarsenal.common;

import com.refinedmods.refinedstorage.common.api.RefinedStorageApi;

import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
import net.minecraft.world.entity.player.Player;

public abstract class AbstractClientModInitializer {
protected static void handleInputEvents() {
final Player player = Minecraft.getInstance().player;
if (player == null) {
return;
}
final KeyMapping openWirelessCraftingGrid = KeyMappings.INSTANCE.getOpenWirelessCraftingGrid();
while (openWirelessCraftingGrid != null && openWirelessCraftingGrid.consumeClick()) {
RefinedStorageApi.INSTANCE.useSlotReferencedItem(
player,
Items.INSTANCE.getWirelessCraftingGrid(),
Items.INSTANCE.getCreativeWirelessCraftingGrid()
);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.refinedmods.refinedstorage.quartzarsenal.common;

import com.refinedmods.refinedstorage.common.content.ExtendedMenuTypeFactory;
import com.refinedmods.refinedstorage.common.content.RegistryCallback;
import com.refinedmods.refinedstorage.quartzarsenal.common.wirelesscraftinggrid.WirelessCraftingGridContainerMenu;
import com.refinedmods.refinedstorage.quartzarsenal.common.wirelesscraftinggrid.WirelessCraftingGridData;
import com.refinedmods.refinedstorage.quartzarsenal.common.wirelesscraftinggrid.WirelessCraftingGridState;

import net.minecraft.core.component.DataComponentType;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.ItemStack;

import static com.refinedmods.refinedstorage.quartzarsenal.common.QuartzArsenalIdentifierUtil.createQuartzArsenalIdentifier;

public abstract class AbstractModInitializer {
protected static boolean allowComponentsUpdateAnimation(final ItemStack oldStack, final ItemStack newStack) {
return oldStack.getItem() != newStack.getItem();
}

protected final void registerMenus(final RegistryCallback<MenuType<?>> callback,
final ExtendedMenuTypeFactory extendedMenuTypeFactory) {
Menus.INSTANCE.setWirelessCraftingGrid(callback.register(
ContentIds.WIRELESS_CRAFTING_GRID,
() -> extendedMenuTypeFactory.create(
WirelessCraftingGridContainerMenu::new,
WirelessCraftingGridData.STREAM_CODEC
)
));
}

protected final void registerDataComponents(final RegistryCallback<DataComponentType<?>> callback) {
DataComponents.INSTANCE.setWirelessCraftingGridState(callback.register(
createQuartzArsenalIdentifier("wireless_crafting_grid_state"),
() -> DataComponentType.<WirelessCraftingGridState>builder()
.persistent(WirelessCraftingGridState.CODEC)
.networkSynchronized(WirelessCraftingGridState.STREAM_CODEC)
.build()));
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.refinedmods.refinedstorage.quartzarsenal.common;

public interface Config {
WirelessCraftingGridEntry getWirelessCraftingGrid();

interface WirelessCraftingGridEntry {
long getEnergyCapacity();

long getOpenEnergyUsage();

long getCraftingEnergyUsage();

long getAutocraftingEnergyUsage();

long getClearMatrixEnergyUsage();

long getRecipeTransferEnergyUsage();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.refinedmods.refinedstorage.quartzarsenal.common;

import net.minecraft.resources.ResourceLocation;

import static com.refinedmods.refinedstorage.quartzarsenal.common.QuartzArsenalIdentifierUtil.createQuartzArsenalIdentifier;

public final class ContentIds {
public static final ResourceLocation WIRELESS_CRAFTING_GRID =
createQuartzArsenalIdentifier("wireless_crafting_grid");
public static final ResourceLocation CREATIVE_WIRELESS_CRAFTING_GRID =
createQuartzArsenalIdentifier("creative_wireless_crafting_grid");

private ContentIds() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.refinedmods.refinedstorage.quartzarsenal.common;

import net.minecraft.network.chat.MutableComponent;

import static com.refinedmods.refinedstorage.quartzarsenal.common.QuartzArsenalIdentifierUtil.QUARTZ_ARSENAL_MOD_ID;
import static com.refinedmods.refinedstorage.quartzarsenal.common.QuartzArsenalIdentifierUtil.createQuartzArsenalTranslation;
import static com.refinedmods.refinedstorage.quartzarsenal.common.QuartzArsenalIdentifierUtil.createQuartzArsenalTranslationKey;

public final class ContentNames {
public static final String MOD_TRANSLATION_KEY = "mod." + QUARTZ_ARSENAL_MOD_ID;
public static final String OPEN_WIRELESS_CRAFTING_GRID_TRANSLATION_KEY = createQuartzArsenalTranslationKey(
"key", "open_wireless_crafting_grid"
);
public static final MutableComponent WIRELESS_CRAFTING_GRID = createQuartzArsenalTranslation(
"item", "wireless_crafting_grid"
);
public static final MutableComponent CREATIVE_WIRELESS_CRAFTING_GRID = createQuartzArsenalTranslation(
"item", "creative_wireless_crafting_grid"
);

private ContentNames() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.refinedmods.refinedstorage.quartzarsenal.common;

import java.util.function.Consumer;

import net.minecraft.world.item.ItemStack;

public final class CreativeModeTabItems {
private CreativeModeTabItems() {
}

public static void addItems(final Consumer<ItemStack> consumer) {
consumer.accept(Items.INSTANCE.getWirelessCraftingGrid().getDefaultInstance());
consumer.accept(Items.INSTANCE.getWirelessCraftingGrid().createAtEnergyCapacity());
consumer.accept(Items.INSTANCE.getCreativeWirelessCraftingGrid().getDefaultInstance());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.refinedmods.refinedstorage.quartzarsenal.common;

import com.refinedmods.refinedstorage.quartzarsenal.common.wirelesscraftinggrid.WirelessCraftingGridState;

import java.util.function.Supplier;
import javax.annotation.Nullable;

import net.minecraft.core.component.DataComponentType;

import static java.util.Objects.requireNonNull;

public final class DataComponents {
public static final DataComponents INSTANCE = new DataComponents();

@Nullable
private Supplier<DataComponentType<WirelessCraftingGridState>> wirelessCraftingGridState;

private DataComponents() {
}

public DataComponentType<WirelessCraftingGridState> getWirelessCraftingGridState() {
return requireNonNull(wirelessCraftingGridState).get();
}

public void setWirelessCraftingGridState(
@Nullable final Supplier<DataComponentType<WirelessCraftingGridState>> supplier
) {
this.wirelessCraftingGridState = supplier;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.refinedmods.refinedstorage.quartzarsenal.common;

public final class DefaultEnergyUsage {
public static final long WIRELESS_CRAFTING_GRID_CAPACITY = 1000;
public static final long WIRELESS_CRAFTING_GRID_OPEN = 5;
public static final long WIRELESS_CRAFTING_GRID_CRAFTING = 5;
public static final long WIRELESS_CRAFTING_GRID_AUTOCRAFTING = 10;
public static final long WIRELESS_CRAFTING_GRID_CLEAR_MATRIX = 5;
public static final long WIRELESS_CRAFTING_GRID_RECIPE_TRANSFER = 5;

private DefaultEnergyUsage() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.refinedmods.refinedstorage.quartzarsenal.common;

import com.refinedmods.refinedstorage.quartzarsenal.common.wirelesscraftinggrid.WirelessCraftingGridItem;

import java.util.function.Supplier;
import javax.annotation.Nullable;

import static java.util.Objects.requireNonNull;

public final class Items {
public static final Items INSTANCE = new Items();

@Nullable
private Supplier<WirelessCraftingGridItem> wirelessCraftingGrid;
@Nullable
private Supplier<WirelessCraftingGridItem> creativeWirelessCraftingGrid;

private Items() {
}

public WirelessCraftingGridItem getWirelessCraftingGrid() {
return requireNonNull(wirelessCraftingGrid).get();
}

public void setWirelessCraftingGrid(final Supplier<WirelessCraftingGridItem> supplier) {
this.wirelessCraftingGrid = supplier;
}

public WirelessCraftingGridItem getCreativeWirelessCraftingGrid() {
return requireNonNull(creativeWirelessCraftingGrid).get();
}

public void setCreativeWirelessCraftingGrid(final Supplier<WirelessCraftingGridItem> supplier) {
this.creativeWirelessCraftingGrid = supplier;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.refinedmods.refinedstorage.quartzarsenal.common;

import javax.annotation.Nullable;

import net.minecraft.client.KeyMapping;

public final class KeyMappings {
public static final KeyMappings INSTANCE = new KeyMappings();

@Nullable
private KeyMapping openWirelessCraftingGrid;

private KeyMappings() {
}

public void setOpenWirelessCraftingGrid(final KeyMapping openWirelessCraftingGrid) {
this.openWirelessCraftingGrid = openWirelessCraftingGrid;
}

@Nullable
public KeyMapping getOpenWirelessCraftingGrid() {
return openWirelessCraftingGrid;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.refinedmods.refinedstorage.quartzarsenal.common;

import com.refinedmods.refinedstorage.quartzarsenal.common.wirelesscraftinggrid.WirelessCraftingGridContainerMenu;

import java.util.function.Supplier;
import javax.annotation.Nullable;

import net.minecraft.world.inventory.MenuType;

import static java.util.Objects.requireNonNull;

public final class Menus {
public static final Menus INSTANCE = new Menus();

@Nullable
private Supplier<MenuType<WirelessCraftingGridContainerMenu>> wirelessCraftingGrid;

private Menus() {
}

public void setWirelessCraftingGrid(final Supplier<MenuType<WirelessCraftingGridContainerMenu>> supplier) {
this.wirelessCraftingGrid = supplier;
}

public MenuType<WirelessCraftingGridContainerMenu> getWirelessCraftingGrid() {
return requireNonNull(wirelessCraftingGrid).get();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.refinedmods.refinedstorage.quartzarsenal.common;

import java.util.function.Supplier;
import javax.annotation.Nullable;

import static java.util.Objects.requireNonNull;

public final class Platform {
@Nullable
private static Supplier<Config> configProvider = null;

private Platform() {
}

public static void setConfigProvider(final Supplier<Config> configProvider) {
Platform.configProvider = configProvider;
}

public static Config getConfig() {
return requireNonNull(configProvider, "Config isn't loaded yet").get();
}
}
Loading

0 comments on commit 17fbf2a

Please sign in to comment.