Skip to content

Commit

Permalink
Add Storage Cover (#1990)
Browse files Browse the repository at this point in the history
Co-authored-by: Spicierspace153 <[email protected]>
Co-authored-by: JuiceyBeans <[email protected]>
Co-authored-by: YoungOnion <[email protected]>
  • Loading branch information
4 people authored and krossgg committed Oct 13, 2024
1 parent 77b8d3d commit a49c77e
Show file tree
Hide file tree
Showing 15 changed files with 191 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"button_texture": {
"type": "item",
"res": "gtceu:storage_cover"
},
"items": [
"gtceu:storage_cover"
],
"page": "gtceu:covers/storage_cover",
"position": [
-300,
150
],
"pre_nodes": [
"gtceu:covers/cover"
],
"section": "gtceu:covers"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"res": "gtceu:aluminium_frame"
},
"items": [
"#minecraft:climbable",
"#forge:frames"
],
"page": "gtceu:materials/frame",
Expand Down
4 changes: 4 additions & 0 deletions src/generated/resources/assets/gtceu/lang/en_ud.json
Original file line number Diff line number Diff line change
Expand Up @@ -1836,6 +1836,7 @@
"compass.node.gtceu.covers/robot_arm": "ɯɹⱯ ʇoqoᴚ",
"compass.node.gtceu.covers/shutter_module_cover": "ɹǝʌoƆ ǝןnpoW ɹǝʇʇnɥS",
"compass.node.gtceu.covers/solar_panel": "ןǝuɐԀ ɹɐןoS",
"compass.node.gtceu.covers/storage_cover": "ɹǝʌoƆ ǝbɐɹoʇS",
"compass.node.gtceu.ev/cracker": "ɹǝʞɔɐɹƆ",
"compass.node.gtceu.ev/distillation_tower": "ɹǝʍo⟘ uoıʇɐןןıʇsıᗡ",
"compass.node.gtceu.ev/large_combustion": "uoıʇsnqɯoƆ ǝbɹɐꞀ",
Expand Down Expand Up @@ -2265,6 +2266,7 @@
"config.gtceu.option.hardGlassRecipes": "sǝdıɔǝᴚssɐן⅁pɹɐɥ",
"config.gtceu.option.hardIronRecipes": "sǝdıɔǝᴚuoɹIpɹɐɥ",
"config.gtceu.option.hardMiscRecipes": "sǝdıɔǝᴚɔsıWpɹɐɥ",
"config.gtceu.option.hardMultiRecipes": "sǝdıɔǝᴚıʇןnWpɹɐɥ",
"config.gtceu.option.hardRedstoneRecipes": "sǝdıɔǝᴚǝuoʇspǝᴚpɹɐɥ",
"config.gtceu.option.hardToolArmorRecipes": "sǝdıɔǝᴚɹoɯɹⱯןoo⟘pɹɐɥ",
"config.gtceu.option.hardWoodRecipes": "sǝdıɔǝᴚpooMpɹɐɥ",
Expand Down Expand Up @@ -2519,6 +2521,7 @@
"cover.smart_item_filter.filtering_mode.electrolyzer": "ɹǝzʎןoɹʇɔǝןƎ",
"cover.smart_item_filter.filtering_mode.sifter": "ɹǝʇɟıS",
"cover.smart_item_filter.title": "ɹǝʇןıℲ ɯǝʇI ʇɹɐɯS",
"cover.storage.title": "ɹǝʌoƆ ǝbɐɹoʇS",
"cover.universal.manual_import_export.mode.description.0": " ˙ɹǝʇןıɟ sʇı puɐ ɹǝʌoɔ ǝɥʇ ʎq pǝıɟıɔǝds sɐ ǝʌoɯ ʎןuo ןןıʍ spınןɟ/sɯǝʇI - ɹ§pǝןqɐsıᗡǝ§",
"cover.universal.manual_import_export.mode.description.1": " ˙)ʎuɐ ɟı( sǝɥɔʇɐɯ ɹǝʇןıɟ sʇı sɐ buoן sɐ 'ǝpoɯ ɹǝʌoɔ ǝɥʇ ɟo ʎןʇuǝpuǝdǝpuı pǝʇɹǝsuı puɐ pǝʇɔɐɹʇxǝ ǝq uɐɔ spınןɟ/sɯǝʇI - ɹ§pǝɹǝʇןıℲ ʍoןןⱯǝ§",
"cover.universal.manual_import_export.mode.description.2": "ɹǝʌoɔ sıɥʇ ʎq pǝʇɔɐɹʇxǝ ɹo pǝʇɹǝsuı sɯǝʇı ǝɥʇ oʇ sǝıןddɐ ɹǝʇןıℲ ˙ǝpoɯ ɹǝʌoɔ ǝɥʇ ɟo ʎןʇuǝpuǝdǝpuı pǝʌoɯ ǝq uɐɔ spınןɟ/sɯǝʇI - ɹ§pǝɹǝʇןıɟu∩ ʍoןןⱯǝ§",
Expand Down Expand Up @@ -4743,6 +4746,7 @@
"item.gtceu.stem_cells": "sןןǝƆ ɯǝʇS",
"item.gtceu.stem_cells.tooltip": "ǝɔuǝbıןןǝʇuI ʍɐᴚㄥ§",
"item.gtceu.sticky_resin": "uısǝᴚ ʎʞɔıʇS",
"item.gtceu.storage_cover": "ɹǝʌoƆ ǝbɐɹoʇS",
"item.gtceu.sugar_gem": "ǝqnƆ ɹɐbnS",
"item.gtceu.sus_record": "ɔsıᗡ ɔısnW",
"item.gtceu.sus_record.desc": "¡ʎssns",
Expand Down
4 changes: 4 additions & 0 deletions src/generated/resources/assets/gtceu/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -1836,6 +1836,7 @@
"compass.node.gtceu.covers/robot_arm": "Robot Arm",
"compass.node.gtceu.covers/shutter_module_cover": "Shutter Module Cover",
"compass.node.gtceu.covers/solar_panel": "Solar Panel",
"compass.node.gtceu.covers/storage_cover": "Storage Cover",
"compass.node.gtceu.ev/cracker": "Cracker",
"compass.node.gtceu.ev/distillation_tower": "Distillation Tower",
"compass.node.gtceu.ev/large_combustion": "Large Combustion",
Expand Down Expand Up @@ -2265,6 +2266,7 @@
"config.gtceu.option.hardGlassRecipes": "hardGlassRecipes",
"config.gtceu.option.hardIronRecipes": "hardIronRecipes",
"config.gtceu.option.hardMiscRecipes": "hardMiscRecipes",
"config.gtceu.option.hardMultiRecipes": "hardMultiRecipes",
"config.gtceu.option.hardRedstoneRecipes": "hardRedstoneRecipes",
"config.gtceu.option.hardToolArmorRecipes": "hardToolArmorRecipes",
"config.gtceu.option.hardWoodRecipes": "hardWoodRecipes",
Expand Down Expand Up @@ -2519,6 +2521,7 @@
"cover.smart_item_filter.filtering_mode.electrolyzer": "Electrolyzer",
"cover.smart_item_filter.filtering_mode.sifter": "Sifter",
"cover.smart_item_filter.title": "Smart Item Filter",
"cover.storage.title": "Storage Cover",
"cover.universal.manual_import_export.mode.description.0": "§eDisabled§r - Items/fluids will only move as specified by the cover and its filter. ",
"cover.universal.manual_import_export.mode.description.1": "§eAllow Filtered§r - Items/fluids can be extracted and inserted independently of the cover mode, as long as its filter matches (if any). ",
"cover.universal.manual_import_export.mode.description.2": "§eAllow Unfiltered§r - Items/fluids can be moved independently of the cover mode. Filter applies to the items inserted or extracted by this cover",
Expand Down Expand Up @@ -4743,6 +4746,7 @@
"item.gtceu.stem_cells": "Stem Cells",
"item.gtceu.stem_cells.tooltip": "§7Raw Intelligence",
"item.gtceu.sticky_resin": "Sticky Resin",
"item.gtceu.storage_cover": "Storage Cover",
"item.gtceu.sugar_gem": "Sugar Cube",
"item.gtceu.sus_record": "Music Disc",
"item.gtceu.sus_record.desc": "sussy!",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "gtceu:item/storage_cover"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.gregtechceu.gtceu.api.capability.ICoverable;
import com.gregtechceu.gtceu.api.gui.GuiTextures;
import com.gregtechceu.gtceu.api.gui.factory.CoverUIFactory;
import com.gregtechceu.gtceu.api.gui.fancy.IFancyConfigurator;
import com.gregtechceu.gtceu.api.item.tool.GTToolType;
import com.gregtechceu.gtceu.api.item.tool.IToolGridHighLight;
import com.gregtechceu.gtceu.client.renderer.cover.ICoverRenderer;
Expand Down Expand Up @@ -180,6 +181,10 @@ public ICoverRenderer getCoverRenderer() {
return coverDefinition.getCoverRenderer();
}

public @Nullable IFancyConfigurator getConfigurator() {
return null;
}

@Override
public boolean shouldRenderGrid(Player player, BlockPos pos, BlockState state, ItemStack held,
Set<GTToolType> toolTypes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.gregtechceu.gtceu.api.capability.IControllable;
import com.gregtechceu.gtceu.api.gui.GuiTextures;
import com.gregtechceu.gtceu.api.gui.fancy.*;
import com.gregtechceu.gtceu.api.machine.MetaMachine;
import com.gregtechceu.gtceu.api.machine.fancyconfigurator.CombinedDirectionalFancyConfigurator;
import com.gregtechceu.gtceu.api.machine.fancyconfigurator.MachineModeFancyConfigurator;
import com.gregtechceu.gtceu.api.machine.fancyconfigurator.OverclockFancyConfigurator;
Expand All @@ -19,6 +20,7 @@

import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.player.Player;
import net.neoforged.api.distmarker.Dist;
Expand Down Expand Up @@ -126,6 +128,15 @@ default void attachConfigurators(ConfiguratorPanel configuratorPanel) {
if (this instanceof IOverclockMachine overclockMachine) {
configuratorPanel.attachConfigurators(new OverclockFancyConfigurator(overclockMachine));
}
if (this instanceof MetaMachine machine) {
for (var direction : Direction.values()) {
if (machine.getCoverContainer().hasCover(direction)) {
var configurator = machine.getCoverContainer().getCoverAtSide(direction).getConfigurator();
if (configurator != null)
configuratorPanel.attachConfigurators(configurator);
}
}
}
}

@Override
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/gregtechceu/gtceu/api/tag/TagPrefix.java
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,6 @@ public static TagPrefix get(String name) {
public static final TagPrefix frameGt = new TagPrefix("frame")
.defaultTagPath("frames/%s")
.unformattedTagPath("frames")
.unformattedTagPath("climbable", true)
.langValue("%s Frame")
.materialAmount(GTValues.M * 2)
.materialIconType(MaterialIconType.frameGt)
Expand Down
124 changes: 124 additions & 0 deletions src/main/java/com/gregtechceu/gtceu/common/cover/StorageCover.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package com.gregtechceu.gtceu.common.cover;

import com.gregtechceu.gtceu.api.capability.ICoverable;
import com.gregtechceu.gtceu.api.cover.CoverBehavior;
import com.gregtechceu.gtceu.api.cover.CoverDefinition;
import com.gregtechceu.gtceu.api.cover.IUICover;
import com.gregtechceu.gtceu.api.gui.GuiTextures;
import com.gregtechceu.gtceu.api.gui.fancy.IFancyConfigurator;

import com.gregtechceu.gtceu.api.transfer.item.CustomItemStackHandler;
import com.lowdragmc.lowdraglib.gui.texture.IGuiTexture;
import com.lowdragmc.lowdraglib.gui.widget.LabelWidget;
import com.lowdragmc.lowdraglib.gui.widget.SlotWidget;
import com.lowdragmc.lowdraglib.gui.widget.Widget;
import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup;
import com.lowdragmc.lowdraglib.syncdata.annotation.DescSynced;
import com.lowdragmc.lowdraglib.syncdata.annotation.Persisted;
import com.lowdragmc.lowdraglib.syncdata.field.ManagedFieldHolder;
import com.lowdragmc.lowdraglib.utils.LocalizationUtils;

import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.annotation.ParametersAreNonnullByDefault;
import java.util.List;

@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class StorageCover extends CoverBehavior implements IUICover {

@Persisted
@DescSynced
public final CustomItemStackHandler inventory;
private final int SIZE = 18;

public static final ManagedFieldHolder MANAGED_FIELD_HOLDER = new ManagedFieldHolder(StorageCover.class,
CoverBehavior.MANAGED_FIELD_HOLDER);

public StorageCover(@NotNull CoverDefinition definition, @NotNull ICoverable coverableView,
@NotNull Direction attachedSide) {
super(definition, coverableView, attachedSide);
inventory = new CustomItemStackHandler(SIZE) {

@Override
public int getSlotLimit(int slot) {
return 1;
}
};
}

@Override
public ManagedFieldHolder getFieldHolder() {
return MANAGED_FIELD_HOLDER;
}

@Override
public List<ItemStack> getAdditionalDrops() {
var list = super.getAdditionalDrops();
for (int slot = 0; slot < SIZE; slot++) {
list.add(inventory.getStackInSlot(slot));
}
return list;
}

@Override
public boolean canAttach() {
for (var dir : Direction.values()) {
if (coverHolder.hasCover(dir) && coverHolder.getCoverAtSide(dir) instanceof StorageCover)
return false;
}
return super.canAttach();
}

@Override
public Widget createUIWidget() {
final var group = new WidgetGroup(0, 0, 126, 87);

group.addWidget(new LabelWidget(10, 5, LocalizationUtils.format(getUITitle())));

for (int slot = 0; slot < SIZE; slot++) {
group.addWidget(new SlotWidget(inventory, slot, 7 + (slot % 6) * 18, 21 + (slot / 6) * 18));
}

return group;
}

private String getUITitle() {
return "cover.storage.title";
}

@Override
public @Nullable IFancyConfigurator getConfigurator() {
return new StorageCoverConfigurator();
}

private class StorageCoverConfigurator implements IFancyConfigurator {

@Override
public Component getTitle() {
return Component.translatable("cover.storage.title");
}

@Override
public IGuiTexture getIcon() {
return GuiTextures.MAINTENANCE_ICON;
}

@Override
public Widget createConfigurator() {
final var group = new WidgetGroup(0, 0, 126, 87);

for (int slot = 0; slot < SIZE; slot++) {
group.addWidget(new SlotWidget(inventory, slot, 7 + (slot % 6) * 18, 21 + (slot / 6) * 18));
}

return group;
}
}
}
3 changes: 3 additions & 0 deletions src/main/java/com/gregtechceu/gtceu/data/cover/GTCovers.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public class GTCovers {
public final static CoverDefinition SHUTTER = register(
"shutter", ShutterCover::new,
new SimpleCoverRenderer(GTCEu.id("block/cover/overlay_shutter")));
public final static CoverDefinition COVER_STORAGE = register(
"storage", StorageCover::new,
new SimpleCoverRenderer(GTCEu.id("block/cover/storage_cover")));

public final static CoverDefinition[] CONVEYORS = registerTiered(
"conveyor", ConveyorCover::new,
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/gregtechceu/gtceu/data/item/GTItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -2265,6 +2265,12 @@ public Component getItemName(ItemStack stack) {
.onRegister(attach(new CoverPlaceBehavior(GTCovers.COMPUTER_MONITOR)))
.onRegister(compassNode(GTCompassSections.COVERS, GTCompassNodes.COVER))
.register();
public static ItemEntry<ComponentItem> COVER_STORAGE = REGISTRATE
.item("storage_cover", ComponentItem::create)
.lang("Storage Cover")
.onRegister(compassNode(GTCompassSections.COVERS, GTCompassNodes.COVER))
.onRegister(attach(new CoverPlaceBehavior(GTCovers.COVER_STORAGE)))
.register();
public static ItemEntry<ComponentItem> COVER_SHUTTER = REGISTRATE
.item("shutter_module_cover", ComponentItem::create)
.lang("Shutter Module")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ public static void init(RegistrateLangProvider provider) {
provider.add("cover.fluid_filter.mode.filter_drain", "Filter Drain");
provider.add("cover.fluid_filter.mode.filter_both", "Filter Fill & Drain");
provider.add("cover.item_filter.title", "Item Filter");
provider.add("cover.storage.title", "Storage Cover");
provider.add("cover.filter.mode.filter_insert", "Filter Insert");
provider.add("cover.filter.mode.filter_extract", "Filter Extract");
provider.add("cover.filter.mode.filter_both", "Filter Insert/Extract");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,14 +506,6 @@ private static void registerAssemblerRecipes(RecipeOutput provider) {
.EUt(16).duration(100)
.save(provider);

// TODO Crafting station, crafting cover
// ASSEMBLER_RECIPES.recipeBuilder("cover_crafting")
// .inputItems(WORKBENCH)
// .inputItems(plate, material)
// .outputItems(COVER_CRAFTING)
// .EUt(16).duration(100)
// .save(provider);

FluidStack solder = SolderingAlloy.getFluid(L / 2);

ASSEMBLER_RECIPES.recipeBuilder("cover_machine_controller")
Expand Down Expand Up @@ -626,16 +618,15 @@ private static void registerAssemblerRecipes(RecipeOutput provider) {
.EUt(VA[HV]).duration(320)
.save(provider);

// TODO Storage cover
// ASSEMBLER_RECIPES.recipeBuilder()
// .inputItems(OreDictNames.chestWood.toString())
// .inputItems(ELECTRIC_PISTON_LV)
// .inputItems(plate, Iron)
// .inputFluids(SolderingAlloy.getFluid(72))
// .outputItems(COVER_STORAGE)
// .EUt(16)
// .duration(100)
// .save(provider);
ASSEMBLER_RECIPES.recipeBuilder("cover_storage")
.inputItems(Tags.Blocks.CHESTS_WOODEN)
.inputItems(ELECTRIC_PISTON_LV)
.inputItems(plate, Iron)
.inputFluids(SolderingAlloy.getFluid(72))
.outputItems(COVER_STORAGE)
.EUt(16)
.duration(100)
.save(provider);

ASSEMBLER_RECIPES.recipeBuilder("casing_ulv").EUt(16).inputItems(plate, WroughtIron, 8)
.outputItems(GTBlocks.MACHINE_CASING_ULV.asStack()).circuitMeta(8).duration(25).save(provider);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a49c77e

Please sign in to comment.