diff --git a/CHANGELOG.md b/CHANGELOG.md index e8b229e26..3799f1e1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Curios integration on Forge. - Trinkets integration on Fabric. - Storage Monitor +- Configuration Card. It copies device configurations and can transfer upgrades. ### Changed diff --git a/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/blockentity/ConfigurationCardTarget.java b/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/blockentity/ConfigurationCardTarget.java index 09f7ebc5d..1d5dd88bf 100644 --- a/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/blockentity/ConfigurationCardTarget.java +++ b/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/blockentity/ConfigurationCardTarget.java @@ -1,12 +1,18 @@ package com.refinedmods.refinedstorage2.platform.api.blockentity; +import java.util.List; + import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.item.Item; +import org.apiguardian.api.API; +@API(status = API.Status.STABLE, since = "2.0.0-milestone.3.2") public interface ConfigurationCardTarget { - BlockEntityType getBlockEntityType(); - void writeConfiguration(CompoundTag tag); void readConfiguration(CompoundTag tag); + + List getUpgradeItems(); + + boolean addUpgradeItem(Item upgradeItem); } diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/AbstractModInitializer.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/AbstractModInitializer.java index 161c294ef..2b343c38d 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/AbstractModInitializer.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/AbstractModInitializer.java @@ -77,6 +77,7 @@ import com.refinedmods.refinedstorage2.platform.common.internal.storage.type.ItemStorageType; import com.refinedmods.refinedstorage2.platform.common.internal.storage.type.StorageTypes; import com.refinedmods.refinedstorage2.platform.common.internal.upgrade.UpgradeDestinations; +import com.refinedmods.refinedstorage2.platform.common.item.ConfigurationCardItem; import com.refinedmods.refinedstorage2.platform.common.item.FluidStorageDiskItem; import com.refinedmods.refinedstorage2.platform.common.item.FortuneUpgradeItem; import com.refinedmods.refinedstorage2.platform.common.item.ItemStorageDiskItem; @@ -321,6 +322,10 @@ private void registerSimpleItems(final RegistryCallback callback) { for (final ProcessorItem.Type type : ProcessorItem.Type.values()) { registerProcessor(callback, type); } + Items.INSTANCE.setConfigurationCard(callback.register( + ContentIds.CONFIGURATION_CARD, + ConfigurationCardItem::new + )); } private void registerProcessor(final RegistryCallback callback, final ProcessorItem.Type type) { diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/block/entity/AbstractInternalNetworkNodeContainerBlockEntity.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/block/entity/AbstractInternalNetworkNodeContainerBlockEntity.java index 474cd4c8c..1fd6f3861 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/block/entity/AbstractInternalNetworkNodeContainerBlockEntity.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/block/entity/AbstractInternalNetworkNodeContainerBlockEntity.java @@ -9,6 +9,8 @@ import com.refinedmods.refinedstorage2.platform.common.block.ColorableBlock; import com.refinedmods.refinedstorage2.platform.common.util.RedstoneMode; +import java.util.Collections; +import java.util.List; import java.util.UUID; import javax.annotation.Nullable; @@ -18,6 +20,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BooleanProperty; @@ -85,8 +88,13 @@ public void readConfiguration(final CompoundTag tag) { } @Override - public BlockEntityType getBlockEntityType() { - return getType(); + public List getUpgradeItems() { + return Collections.emptyList(); + } + + @Override + public boolean addUpgradeItem(final Item upgradeItem) { + return false; } public void updateActiveness(final BlockState state, diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/block/entity/AbstractUpgradeableNetworkNodeContainerBlockEntity.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/block/entity/AbstractUpgradeableNetworkNodeContainerBlockEntity.java index c1a725fe3..030524f05 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/block/entity/AbstractUpgradeableNetworkNodeContainerBlockEntity.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/block/entity/AbstractUpgradeableNetworkNodeContainerBlockEntity.java @@ -5,12 +5,16 @@ import com.refinedmods.refinedstorage2.platform.common.content.Items; import com.refinedmods.refinedstorage2.platform.common.internal.upgrade.UpgradeDestinations; +import java.util.ArrayList; +import java.util.List; + import com.google.common.util.concurrent.RateLimiter; import net.minecraft.core.BlockPos; import net.minecraft.core.NonNullList; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.Tag; import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; @@ -63,6 +67,24 @@ private void upgradeContainerChanged() { } } + @Override + public List getUpgradeItems() { + final List upgradeItems = new ArrayList<>(); + for (int i = 0; i < upgradeContainer.getContainerSize(); ++i) { + final ItemStack itemStack = upgradeContainer.getItem(i); + if (itemStack.isEmpty()) { + continue; + } + upgradeItems.add(itemStack.getItem()); + } + return upgradeItems; + } + + @Override + public boolean addUpgradeItem(final Item upgradeItem) { + return upgradeContainer.addItem(new ItemStack(upgradeItem)).isEmpty(); + } + @Override public void saveAdditional(final CompoundTag tag) { super.saveAdditional(tag); diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/block/entity/detector/DetectorBlockEntity.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/block/entity/detector/DetectorBlockEntity.java index 696c62b01..4391e381e 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/block/entity/detector/DetectorBlockEntity.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/block/entity/detector/DetectorBlockEntity.java @@ -72,13 +72,6 @@ public void writeConfiguration(final CompoundTag tag) { tag.putInt(TAG_MODE, DetectorModeSettings.getDetectorMode(getNode().getMode())); } - @Override - public void load(final CompoundTag tag) { - super.load(tag); - initialize(); - propagateAmount(); - } - @Override public void readConfiguration(final CompoundTag tag) { super.readConfiguration(tag); @@ -89,6 +82,8 @@ public void readConfiguration(final CompoundTag tag) { if (tag.contains(TAG_MODE)) { getNode().setMode(DetectorModeSettings.getDetectorMode(tag.getInt(TAG_MODE))); } + initialize(); + propagateAmount(); } public void setAmount(final double amount) { diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/content/ContentIds.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/content/ContentIds.java index cd3f251c8..2ca3bd93a 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/content/ContentIds.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/content/ContentIds.java @@ -48,6 +48,7 @@ public final class ContentIds { public static final ResourceLocation RANGE_UPGRADE = createIdentifier("range_upgrade"); public static final ResourceLocation CREATIVE_RANGE_UPGRADE = createIdentifier("creative_range_upgrade"); public static final ResourceLocation STORAGE_MONITOR = createIdentifier("storage_monitor"); + public static final ResourceLocation CONFIGURATION_CARD = createIdentifier("configuration_card"); private ContentIds() { } diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/content/CreativeModeTabItems.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/content/CreativeModeTabItems.java index 5af4cd217..002b99b20 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/content/CreativeModeTabItems.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/content/CreativeModeTabItems.java @@ -95,5 +95,6 @@ private static void appendItems(final Consumer consumer) { itemConsumer.accept(Items.INSTANCE.getWirelessGrid()); consumer.accept(Items.INSTANCE.getWirelessGrid().createAtEnergyCapacity()); itemConsumer.accept(Items.INSTANCE.getCreativeWirelessGrid()); + itemConsumer.accept(Items.INSTANCE.getConfigurationCard()); } } diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/content/Items.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/content/Items.java index 6734b231a..fdfcdc5f3 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/content/Items.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/content/Items.java @@ -78,6 +78,8 @@ public final class Items { private Supplier wirelessGrid; @Nullable private Supplier creativeWirelessGrid; + @Nullable + private Supplier configurationCard; private Items() { } @@ -353,4 +355,12 @@ public WirelessGridItem getCreativeWirelessGrid() { public void setCreativeWirelessGrid(final Supplier supplier) { this.creativeWirelessGrid = supplier; } + + public Item getConfigurationCard() { + return Objects.requireNonNull(configurationCard).get(); + } + + public void setConfigurationCard(final Supplier supplier) { + this.configurationCard = supplier; + } } diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/item/ConfigurationCardItem.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/item/ConfigurationCardItem.java new file mode 100644 index 000000000..045bf8b18 --- /dev/null +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/item/ConfigurationCardItem.java @@ -0,0 +1,205 @@ +package com.refinedmods.refinedstorage2.platform.common.item; + +import com.refinedmods.refinedstorage2.platform.api.blockentity.ConfigurationCardTarget; +import com.refinedmods.refinedstorage2.platform.api.item.HelpTooltipComponent; + +import java.util.List; +import java.util.Optional; +import javax.annotation.Nullable; + +import net.minecraft.ChatFormatting; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.StringTag; +import net.minecraft.nbt.Tag; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.tooltip.TooltipComponent; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.TooltipFlag; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; + +import static com.refinedmods.refinedstorage2.platform.common.util.IdentifierUtil.createTranslation; +import static java.util.Objects.requireNonNull; + +// TODO: textures +public class ConfigurationCardItem extends Item { + private static final Component EMPTY_HELP = createTranslation("item", "configuration_card.empty_help"); + private static final Component CONFIGURED_HELP = createTranslation("item", "configuration_card.configured_help"); + + private static final Component EMPTY = createTranslation("item", "configuration_card.empty") + .withStyle(ChatFormatting.GRAY); + + private static final String TAG_TYPE = "type"; + private static final String TAG_CONFIG = "config"; + private static final String TAG_UPGRADES = "upgrades"; + + public ConfigurationCardItem() { + super(new Item.Properties().stacksTo(1)); + } + + @Override + public InteractionResult useOn(final UseOnContext ctx) { + if (ctx.getLevel().isClientSide() || ctx.getPlayer() == null) { + return InteractionResult.CONSUME; + } + final BlockEntity blockEntity = ctx.getLevel().getBlockEntity(ctx.getClickedPos()); + if (!(blockEntity instanceof ConfigurationCardTarget target)) { + return InteractionResult.CONSUME; + } + final ItemStack stack = ctx.getItemInHand(); + if (stack.getTag() == null) { + writeConfiguration(stack, ctx.getPlayer(), target, blockEntity.getType()); + return InteractionResult.CONSUME; + } + return applyConfiguration(ctx.getPlayer(), blockEntity, target, stack.getTag()); + } + + private InteractionResult applyConfiguration( + final Player player, + final BlockEntity targetBlockEntity, + final ConfigurationCardTarget target, + final CompoundTag tag + ) { + final BlockEntityType existingConfiguredType = getConfiguredType(tag); + if (existingConfiguredType != targetBlockEntity.getType()) { + return configurationCardIsConfiguredForDifferentType(player, existingConfiguredType); + } + target.readConfiguration(tag.getCompound(TAG_CONFIG)); + tryTransferUpgrades(player, target, tag); + targetBlockEntity.setChanged(); + player.sendSystemMessage(createTranslation("item", "configuration_card.applied_configuration")); + return InteractionResult.SUCCESS; + } + + private void tryTransferUpgrades(final Player player, final ConfigurationCardTarget target, final CompoundTag tag) { + final ListTag upgradesTag = tag.getList(TAG_UPGRADES, Tag.TAG_STRING); + for (final Tag upgradeItemTag : upgradesTag) { + final ResourceLocation upgradeItemKey = new ResourceLocation(upgradeItemTag.getAsString()); + final Item upgradeItem = BuiltInRegistries.ITEM.get(upgradeItemKey); + final int upgradeIndexInPlayerInventory = player.getInventory().findSlotMatchingItem( + new ItemStack(upgradeItem) + ); + if (upgradeIndexInPlayerInventory >= 0 && target.addUpgradeItem(upgradeItem)) { + player.getInventory().removeItem(upgradeIndexInPlayerInventory, 1); + } + } + } + + private InteractionResult configurationCardIsConfiguredForDifferentType( + final Player player, + @Nullable final BlockEntityType existingConfiguredType + ) { + if (existingConfiguredType != null) { + player.sendSystemMessage(createTranslation( + "item", + "configuration_card.cannot_apply_configuration", + getConfiguredTypeTranslation(existingConfiguredType).withStyle(ChatFormatting.YELLOW) + )); + } + return InteractionResult.CONSUME; + } + + private void writeConfiguration(final ItemStack stack, + final Player player, + final ConfigurationCardTarget target, + final BlockEntityType type) { + final CompoundTag tag = new CompoundTag(); + tag.putString(TAG_TYPE, requireNonNull(BuiltInRegistries.BLOCK_ENTITY_TYPE.getKey(type)).toString()); + tag.put(TAG_CONFIG, createConfigTag(target)); + tag.put(TAG_UPGRADES, createUpgradesTag(target)); + stack.setTag(tag); + sendCopiedConfigurationMessage(player, type); + } + + private CompoundTag createConfigTag(final ConfigurationCardTarget target) { + final CompoundTag tag = new CompoundTag(); + target.writeConfiguration(tag); + return tag; + } + + private ListTag createUpgradesTag(final ConfigurationCardTarget target) { + final ListTag tag = new ListTag(); + target.getUpgradeItems().forEach(item -> { + final ResourceLocation itemKey = BuiltInRegistries.ITEM.getKey(item); + tag.add(StringTag.valueOf(itemKey.toString())); + }); + return tag; + } + + private void sendCopiedConfigurationMessage(final Player player, final BlockEntityType configuredType) { + if (player.level().isClientSide()) { + return; + } + player.sendSystemMessage(createTranslation( + "item", + "configuration_card.copied_configuration", + getConfiguredTypeTranslation(configuredType).withStyle(ChatFormatting.YELLOW) + )); + } + + @Override + public InteractionResultHolder use(final Level level, final Player player, final InteractionHand hand) { + if (player.isCrouching()) { + if (!level.isClientSide()) { + player.sendSystemMessage(createTranslation("item", "configuration_card.cleared_configuration")); + } + return new InteractionResultHolder<>(InteractionResult.CONSUME, new ItemStack(this)); + } + return super.use(level, player, hand); + } + + @Override + public void appendHoverText(final ItemStack stack, + @Nullable final Level level, + final List lines, + final TooltipFlag flag) { + super.appendHoverText(stack, level, lines, flag); + if (stack.getTag() == null) { + lines.add(EMPTY); + return; + } + final BlockEntityType configuredType = getConfiguredType(stack.getTag()); + if (configuredType == null) { + return; + } + lines.add(createTranslation( + "item", + "configuration_card.configured", + getConfiguredTypeTranslation(configuredType).withStyle(ChatFormatting.WHITE) + ).withStyle(ChatFormatting.GRAY)); + } + + @Nullable + private BlockEntityType getConfiguredType(final CompoundTag tag) { + final ResourceLocation type = new ResourceLocation(tag.getString(TAG_TYPE)); + return BuiltInRegistries.BLOCK_ENTITY_TYPE.get(type); + } + + private MutableComponent getConfiguredTypeTranslation(final BlockEntityType type) { + final ResourceLocation typeId = BuiltInRegistries.BLOCK_ENTITY_TYPE.getKey(type); + if (typeId == null) { + return Component.empty(); + } + return Component.translatable("block." + typeId.getNamespace() + "." + typeId.getPath()); + } + + @Override + public Optional getTooltipImage(final ItemStack stack) { + return Optional.of(new HelpTooltipComponent(isActive(stack) ? CONFIGURED_HELP : EMPTY_HELP)); + } + + public boolean isActive(final ItemStack stack) { + return stack.getTag() != null && stack.getTag().contains(TAG_TYPE); + } +} diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/render/ConfigurationCardItemPropertyFunction.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/render/ConfigurationCardItemPropertyFunction.java new file mode 100644 index 000000000..e60ee181e --- /dev/null +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/render/ConfigurationCardItemPropertyFunction.java @@ -0,0 +1,26 @@ +package com.refinedmods.refinedstorage2.platform.common.render; + +import com.refinedmods.refinedstorage2.platform.common.item.ConfigurationCardItem; + +import javax.annotation.Nullable; + +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.renderer.item.ClampedItemPropertyFunction; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.ItemStack; + +public class ConfigurationCardItemPropertyFunction implements ClampedItemPropertyFunction { + public static final ResourceLocation NAME = new ResourceLocation("active"); + + @Override + public float unclampedCall(final ItemStack itemStack, + @Nullable final ClientLevel clientLevel, + @Nullable final LivingEntity livingEntity, + final int i) { + if (itemStack.getItem() instanceof ConfigurationCardItem cardItem) { + return cardItem.isActive(itemStack) ? 1 : 0; + } + return 0; + } +} diff --git a/refinedstorage2-platform-common/src/main/resources/assets/refinedstorage2/lang/en_us.json b/refinedstorage2-platform-common/src/main/resources/assets/refinedstorage2/lang/en_us.json index 59ef8d0bb..f2fc84abb 100644 --- a/refinedstorage2-platform-common/src/main/resources/assets/refinedstorage2/lang/en_us.json +++ b/refinedstorage2-platform-common/src/main/resources/assets/refinedstorage2/lang/en_us.json @@ -194,6 +194,15 @@ "item.refinedstorage2.network_item.bound_to": "Bound to %d, %d, %d.", "item.refinedstorage2.network_item.cannot_open_with_shortcut_due_to_duplicate": "There is more than one %s in your inventory.", "item.refinedstorage2.network_item.cannot_open_because_not_found": "There isn't any %s in your inventory.", + "item.refinedstorage2.configuration_card": "Configuration Card", + "item.refinedstorage2.configuration_card.empty": "Empty.", + "item.refinedstorage2.configuration_card.configured": "Contains configuration for %s.", + "item.refinedstorage2.configuration_card.copied_configuration": "Copied configuration for %s.", + "item.refinedstorage2.configuration_card.cleared_configuration": "Cleared configuration.", + "item.refinedstorage2.configuration_card.cannot_apply_configuration": "Cannot apply configuration card to different type of device. It is configured for %s.", + "item.refinedstorage2.configuration_card.applied_configuration": "Applied configuration.", + "item.refinedstorage2.configuration_card.empty_help": "Use on a storage network device while crouching to copy its configuration and upgrades to the card.", + "item.refinedstorage2.configuration_card.configured_help": "Use on the destination storage network device while crouching to transfer the configuration and upgrades. Use while crouching to clear.", "misc.refinedstorage2.stored": "Stored: %s", "misc.refinedstorage2.stored_with_capacity": "Stored: %s / %s (%d%%)", "misc.refinedstorage2.total": "%d total", @@ -225,7 +234,7 @@ "text.autoconfig.refinedstorage2.option.grid": "Grid", "text.autoconfig.refinedstorage2.option.grid.largeFont": "Large font", "text.autoconfig.refinedstorage2.option.grid.maxRowsStretch": "Maximum amount of rows when stretched", - "text.autoconfig.refinedstorage2.option.grid.preventSortingWhileShiftIsDown": "Prevent sorting while shift is down", + "text.autoconfig.refinedstorage2.option.grid.preventSortingWhileShiftIsDown": "Prevent sorting while SHIFT is down", "text.autoconfig.refinedstorage2.option.grid.detailedTooltip": "Detailed tooltip", "text.autoconfig.refinedstorage2.option.grid.rememberSearchQuery": "Remember search query", "text.autoconfig.refinedstorage2.option.grid.energyUsage": "Energy usage", diff --git a/refinedstorage2-platform-common/src/main/resources/assets/refinedstorage2/models/item/configuration_card.json b/refinedstorage2-platform-common/src/main/resources/assets/refinedstorage2/models/item/configuration_card.json new file mode 100644 index 000000000..d0e58b52d --- /dev/null +++ b/refinedstorage2-platform-common/src/main/resources/assets/refinedstorage2/models/item/configuration_card.json @@ -0,0 +1,17 @@ +{ + "parent": "item/generated", + "overrides": [ + { + "predicate": { + "active": 0 + }, + "model": "refinedstorage2:item/configuration_card/inactive" + }, + { + "predicate": { + "active": 1 + }, + "model": "refinedstorage2:item/configuration_card/active" + } + ] +} diff --git a/refinedstorage2-platform-common/src/main/resources/assets/refinedstorage2/models/item/configuration_card/active.json b/refinedstorage2-platform-common/src/main/resources/assets/refinedstorage2/models/item/configuration_card/active.json new file mode 100644 index 000000000..d59df8a1f --- /dev/null +++ b/refinedstorage2-platform-common/src/main/resources/assets/refinedstorage2/models/item/configuration_card/active.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "refinedstorage2:item/configuration_card/active" + } +} diff --git a/refinedstorage2-platform-common/src/main/resources/assets/refinedstorage2/models/item/configuration_card/inactive.json b/refinedstorage2-platform-common/src/main/resources/assets/refinedstorage2/models/item/configuration_card/inactive.json new file mode 100644 index 000000000..211dd1de5 --- /dev/null +++ b/refinedstorage2-platform-common/src/main/resources/assets/refinedstorage2/models/item/configuration_card/inactive.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "refinedstorage2:item/configuration_card/inactive" + } +} diff --git a/refinedstorage2-platform-common/src/main/resources/assets/refinedstorage2/textures/item/configuration_card/active.png b/refinedstorage2-platform-common/src/main/resources/assets/refinedstorage2/textures/item/configuration_card/active.png new file mode 100644 index 000000000..a4d8387d7 Binary files /dev/null and b/refinedstorage2-platform-common/src/main/resources/assets/refinedstorage2/textures/item/configuration_card/active.png differ diff --git a/refinedstorage2-platform-common/src/main/resources/assets/refinedstorage2/textures/item/configuration_card/inactive.png b/refinedstorage2-platform-common/src/main/resources/assets/refinedstorage2/textures/item/configuration_card/inactive.png new file mode 100644 index 000000000..3ef77e19c Binary files /dev/null and b/refinedstorage2-platform-common/src/main/resources/assets/refinedstorage2/textures/item/configuration_card/inactive.png differ diff --git a/refinedstorage2-platform-common/src/main/resources/data/refinedstorage2/recipes/configuration_card.json b/refinedstorage2-platform-common/src/main/resources/data/refinedstorage2/recipes/configuration_card.json new file mode 100644 index 000000000..553f5a645 --- /dev/null +++ b/refinedstorage2-platform-common/src/main/resources/data/refinedstorage2/recipes/configuration_card.json @@ -0,0 +1,22 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "EEE", + "PAP", + "EEE" + ], + "key": { + "E": { + "item": "refinedstorage2:quartz_enriched_iron" + }, + "P": { + "item": "minecraft:paper" + }, + "A": { + "item": "refinedstorage2:improved_processor" + } + }, + "result": { + "item": "refinedstorage2:configuration_card" + } +} \ No newline at end of file diff --git a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/ClientModInitializerImpl.java b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/ClientModInitializerImpl.java index 1073aec9e..338e5269d 100644 --- a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/ClientModInitializerImpl.java +++ b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/ClientModInitializerImpl.java @@ -11,6 +11,7 @@ import com.refinedmods.refinedstorage2.platform.common.content.Items; import com.refinedmods.refinedstorage2.platform.common.content.KeyMappings; import com.refinedmods.refinedstorage2.platform.common.item.RegulatorUpgradeItem; +import com.refinedmods.refinedstorage2.platform.common.render.ConfigurationCardItemPropertyFunction; import com.refinedmods.refinedstorage2.platform.common.render.NetworkItemItemPropertyFunction; import com.refinedmods.refinedstorage2.platform.common.render.entity.StorageMonitorBlockEntityRenderer; import com.refinedmods.refinedstorage2.platform.common.render.model.ControllerModelPredicateProvider; @@ -344,5 +345,10 @@ private void registerItemProperties() { NetworkItemItemPropertyFunction.NAME, new NetworkItemItemPropertyFunction() ); + ItemProperties.register( + Items.INSTANCE.getConfigurationCard(), + ConfigurationCardItemPropertyFunction.NAME, + new ConfigurationCardItemPropertyFunction() + ); } } diff --git a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/ClientModInitializer.java b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/ClientModInitializer.java index 49d796b16..860151376 100644 --- a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/ClientModInitializer.java +++ b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/ClientModInitializer.java @@ -9,6 +9,7 @@ import com.refinedmods.refinedstorage2.platform.common.content.Items; import com.refinedmods.refinedstorage2.platform.common.content.KeyMappings; import com.refinedmods.refinedstorage2.platform.common.item.RegulatorUpgradeItem; +import com.refinedmods.refinedstorage2.platform.common.render.ConfigurationCardItemPropertyFunction; import com.refinedmods.refinedstorage2.platform.common.render.NetworkItemItemPropertyFunction; import com.refinedmods.refinedstorage2.platform.common.render.entity.StorageMonitorBlockEntityRenderer; import com.refinedmods.refinedstorage2.platform.common.render.model.ControllerModelPredicateProvider; @@ -216,5 +217,10 @@ private static void registerItemProperties() { NetworkItemItemPropertyFunction.NAME, new NetworkItemItemPropertyFunction() ); + ItemProperties.register( + Items.INSTANCE.getConfigurationCard(), + ConfigurationCardItemPropertyFunction.NAME, + new ConfigurationCardItemPropertyFunction() + ); } }