-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Spicierspace153 <[email protected]> Co-authored-by: JuiceyBeans <[email protected]> Co-authored-by: YoungOnion <[email protected]>
- Loading branch information
Showing
15 changed files
with
191 additions
and
20 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
src/generated/resources/assets/gtceu/compass/nodes/covers/storage_cover.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/generated/resources/assets/gtceu/models/item/storage_cover.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"parent": "minecraft:item/generated", | ||
"textures": { | ||
"layer0": "gtceu:item/storage_cover" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
src/main/java/com/gregtechceu/gtceu/common/cover/StorageCover.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+821 Bytes
src/main/resources/assets/gtceu/textures/block/cover/storage_cover.png
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.