-
-
Notifications
You must be signed in to change notification settings - Fork 9
Implement Eye of Ender upgrade system for Storage Terminal ender chest access #191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Copilot
wants to merge
11
commits into
master-1.19-lts
Choose a base branch
from
copilot/add-ender-chest-support
base: master-1.19-lts
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0be3b4e
Initial plan
Copilot 942234d
Add Ender Chest tab implementation
Copilot 1674895
Fix compilation issues: use Reference.MOD_ID and remove RowsColumns o…
Copilot 86227d9
Fix CI build failure: add getRowColumnProvider() implementation
Copilot a93613d
Fix slot alignment, add config option, and update translation
Copilot 0212260
Implement shift-click support for Ender Chest slots
Copilot ac0c549
Implement ender upgrade system for terminal storage
Copilot 05977df
Fix slot positioning
rubensworks d4f2d5b
Hide search field, channel label/field on ender chest tab
Copilot 4b7c0b8
Changes before error encountered
Copilot 2f301ac
Add portable terminal ender upgrade support
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
...va/org/cyclops/integratedterminals/core/terminalstorage/TerminalStorageTabEnderChest.java
This file contains hidden or 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,44 @@ | ||
| package org.cyclops.integratedterminals.core.terminalstorage; | ||
|
|
||
| import net.minecraft.resources.ResourceLocation; | ||
| import net.minecraft.server.level.ServerPlayer; | ||
| import net.minecraft.world.entity.player.Player; | ||
| import org.cyclops.integrateddynamics.api.network.INetwork; | ||
| import org.cyclops.integratedterminals.Reference; | ||
| import org.cyclops.integratedterminals.api.terminalstorage.ITerminalStorageTab; | ||
| import org.cyclops.integratedterminals.api.terminalstorage.ITerminalStorageTabClient; | ||
| import org.cyclops.integratedterminals.api.terminalstorage.ITerminalStorageTabCommon; | ||
| import org.cyclops.integratedterminals.api.terminalstorage.ITerminalStorageTabServer; | ||
| import org.cyclops.integratedterminals.inventory.container.ContainerTerminalStorageBase; | ||
|
|
||
| import javax.annotation.Nullable; | ||
|
|
||
| /** | ||
| * Terminal storage tab for Ender Chest. | ||
| * @author rubensworks | ||
| */ | ||
| public class TerminalStorageTabEnderChest implements ITerminalStorageTab { | ||
|
|
||
| public static ResourceLocation NAME = new ResourceLocation(Reference.MOD_ID, "ender_chest"); | ||
|
|
||
| @Override | ||
| public ResourceLocation getName() { | ||
| return NAME; | ||
| } | ||
|
|
||
| @Override | ||
| public ITerminalStorageTabClient<?> createClientTab(ContainerTerminalStorageBase container, Player player) { | ||
| return new TerminalStorageTabEnderChestClient(container, getName()); | ||
| } | ||
|
|
||
| @Override | ||
| public ITerminalStorageTabServer createServerTab(ContainerTerminalStorageBase container, Player player, INetwork network) { | ||
| return new TerminalStorageTabEnderChestServer(getName(), (ServerPlayer) player); | ||
| } | ||
|
|
||
| @Nullable | ||
| @Override | ||
| public ITerminalStorageTabCommon createCommonTab(ContainerTerminalStorageBase container, Player player) { | ||
| return new TerminalStorageTabEnderChestCommon(container, getName()); | ||
| } | ||
| } |
169 changes: 169 additions & 0 deletions
169
.../cyclops/integratedterminals/core/terminalstorage/TerminalStorageTabEnderChestClient.java
This file contains hidden or 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,169 @@ | ||
| package org.cyclops.integratedterminals.core.terminalstorage; | ||
|
|
||
| import com.google.common.collect.Lists; | ||
| import net.minecraft.network.chat.Component; | ||
| import net.minecraft.resources.ResourceLocation; | ||
| import net.minecraft.world.inventory.AbstractContainerMenu; | ||
| import net.minecraft.world.inventory.Slot; | ||
| import net.minecraft.world.item.ItemStack; | ||
| import net.minecraft.world.level.block.Blocks; | ||
| import org.cyclops.integratedterminals.api.terminalstorage.ITerminalButton; | ||
| import org.cyclops.integratedterminals.api.terminalstorage.ITerminalRowColumnProvider; | ||
| import org.cyclops.integratedterminals.api.terminalstorage.ITerminalStorageSlot; | ||
| import org.cyclops.integratedterminals.api.terminalstorage.ITerminalStorageTabClient; | ||
| import org.cyclops.integratedterminals.inventory.container.ContainerTerminalStorageBase; | ||
|
|
||
| import java.util.Collections; | ||
| import java.util.List; | ||
| import java.util.Set; | ||
|
|
||
| /** | ||
| * A client-side storage terminal tab for Ender Chest. | ||
| * @author rubensworks | ||
| */ | ||
| public class TerminalStorageTabEnderChestClient implements ITerminalStorageTabClient<ITerminalStorageSlot> { | ||
|
|
||
| private final ResourceLocation name; | ||
| private final ItemStack icon; | ||
| protected final ContainerTerminalStorageBase container; | ||
|
|
||
| public TerminalStorageTabEnderChestClient(ContainerTerminalStorageBase container, ResourceLocation name) { | ||
| this.name = name; | ||
| this.icon = new ItemStack(Blocks.ENDER_CHEST); | ||
| this.container = container; | ||
| } | ||
|
|
||
| @Override | ||
| public void onSelect(int channel) { | ||
| // No action needed on select | ||
| } | ||
|
|
||
| @Override | ||
| public void onDeselect(int channel) { | ||
| // No action needed on deselect | ||
| } | ||
|
|
||
| @Override | ||
| public ResourceLocation getName() { | ||
| return this.name; | ||
| } | ||
|
|
||
| @Override | ||
| public ItemStack getIcon() { | ||
| return this.icon; | ||
| } | ||
|
|
||
| @Override | ||
| public List<Component> getTooltip() { | ||
| return Lists.newArrayList(Component.translatable("gui.integratedterminals.terminal_storage.ender_chest")); | ||
| } | ||
|
|
||
| @Override | ||
| public String getInstanceFilter(int channel) { | ||
| return ""; | ||
| } | ||
|
|
||
| @Override | ||
| public void setInstanceFilter(int channel, String filter) { | ||
| // Ender Chest doesn't support filtering | ||
| } | ||
|
|
||
| @Override | ||
| public List<ITerminalStorageSlot> getSlots(int channel, int offset, int limit) { | ||
| // Ender Chest inventory is handled by regular container slots | ||
| return Collections.emptyList(); | ||
| } | ||
|
|
||
| @Override | ||
| public ITerminalRowColumnProvider getRowColumnProvider() { | ||
| return () -> new ITerminalRowColumnProvider.RowsAndColumns(3, 9); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isEnabled() { | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| public int getSlotCount(int channel) { | ||
| return 27; // Ender Chest has 27 slots | ||
| } | ||
|
|
||
| @Override | ||
| public String getStatus(int channel) { | ||
| return ""; | ||
| } | ||
|
|
||
| @Override | ||
| public int[] getChannels() { | ||
| return new int[]{0}; // Single channel | ||
| } | ||
|
|
||
| @Override | ||
| public void resetActiveSlot() { | ||
| // No active slot for Ender Chest | ||
| } | ||
|
|
||
| @Override | ||
| public boolean handleClick(AbstractContainerMenu container, int channel, int hoveringStorageSlot, int mouseButton, | ||
| boolean hasClickedOutside, boolean hasClickedInStorage, int hoveredContainerSlot, | ||
| boolean isQuickMove) { | ||
| // Let default container handling take care of clicks | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean handleScroll(AbstractContainerMenu container, int channel, int hoveringStorageSlot, double delta, | ||
| boolean hasClickedOutside, boolean hasClickedInStorage, int hoveredContainerSlot) { | ||
| // No scroll handling needed | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public int getActiveSlotId() { | ||
| return -1; | ||
| } | ||
|
|
||
| @Override | ||
| public int getActiveSlotQuantity() { | ||
| return 0; | ||
| } | ||
|
|
||
| @Override | ||
| public void setActiveSlotQuantity(int quantity) { | ||
| // No active slot for Ender Chest | ||
| } | ||
|
|
||
| @Override | ||
| public List<ITerminalButton<?, ?, ?>> getButtons() { | ||
| return Collections.emptyList(); | ||
| } | ||
|
|
||
| @Override | ||
| public int getSlotOffsetX() { | ||
| return 32; | ||
| } | ||
|
|
||
| @Override | ||
| public int getSlotOffsetY() { | ||
| return 58; // Adjusted to position the Ender Chest slots properly | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isSlotValidForDraggingInto(int channel, Slot slot) { | ||
| // Allow dragging into Ender Chest slots | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| public int computeDraggingQuantity(Set<Slot> dragSlots, int dragMode, ItemStack stack, int quantity) { | ||
| // Use default dragging behavior | ||
| return quantity / Math.max(1, dragSlots.size()); | ||
| } | ||
|
|
||
| @Override | ||
| public int dragIntoSlot(AbstractContainerMenu container, int channel, Slot slot, int quantity, boolean simulate) { | ||
| // Use default container behavior | ||
| return 0; | ||
| } | ||
| } |
66 changes: 66 additions & 0 deletions
66
.../cyclops/integratedterminals/core/terminalstorage/TerminalStorageTabEnderChestCommon.java
This file contains hidden or 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,66 @@ | ||
| package org.cyclops.integratedterminals.core.terminalstorage; | ||
|
|
||
| import com.google.common.collect.Lists; | ||
| import net.minecraft.resources.ResourceLocation; | ||
| import net.minecraft.world.entity.player.Player; | ||
| import net.minecraft.world.inventory.AbstractContainerMenu; | ||
| import net.minecraft.world.inventory.Slot; | ||
| import org.apache.commons.lang3.tuple.Pair; | ||
| import org.cyclops.integratedterminals.api.terminalstorage.ITerminalStorageTabCommon; | ||
| import org.cyclops.integratedterminals.inventory.container.ContainerTerminalStorageBase; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Optional; | ||
|
|
||
| /** | ||
| * A common storage terminal tab for Ender Chest. | ||
| * @author rubensworks | ||
| */ | ||
| public class TerminalStorageTabEnderChestCommon implements ITerminalStorageTabCommon { | ||
|
|
||
| private final ContainerTerminalStorageBase containerTerminalStorage; | ||
| private final ResourceLocation name; | ||
|
|
||
| public TerminalStorageTabEnderChestCommon(ContainerTerminalStorageBase containerTerminalStorage, | ||
| ResourceLocation name) { | ||
| this.containerTerminalStorage = containerTerminalStorage; | ||
| this.name = name; | ||
| } | ||
|
|
||
| @Override | ||
| public ResourceLocation getName() { | ||
| return this.name; | ||
| } | ||
|
|
||
| @Override | ||
| public List<Pair<Slot, ISlotPositionCallback>> loadSlots(AbstractContainerMenu container, int startIndex, Player player, | ||
| Optional<IVariableInventory> variableInventoryOptional) { | ||
| List<Pair<Slot, ISlotPositionCallback>> slots = Lists.newArrayList(); | ||
|
|
||
| // Add Ender Chest slots (27 slots in 3 rows of 9) | ||
| for (int row = 0; row < 3; row++) { | ||
| for (int col = 0; col < 9; col++) { | ||
| int slotIndex = col + row * 9; | ||
| int finalRow = row; | ||
| int finalCol = col; | ||
|
|
||
| Slot slot = new Slot(player.getEnderChestInventory(), slotIndex, 0, 0); | ||
| ISlotPositionCallback positionCallback = (factors) -> { | ||
| int x = factors.offsetX() + finalCol * 18; | ||
| int y = factors.offsetY() + finalRow * 18 + 18; // Add offset to position below tab area | ||
| return Pair.of(x, y); | ||
| }; | ||
|
|
||
| slots.add(Pair.of(slot, positionCallback)); | ||
| } | ||
| } | ||
|
|
||
| return slots; | ||
| } | ||
|
|
||
| @Override | ||
| public void onUpdate(AbstractContainerMenu container, Player player, | ||
| Optional<IVariableInventory> variableInventory) { | ||
| // No special update logic needed for Ender Chest | ||
| } | ||
| } |
40 changes: 40 additions & 0 deletions
40
.../cyclops/integratedterminals/core/terminalstorage/TerminalStorageTabEnderChestServer.java
This file contains hidden or 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,40 @@ | ||
| package org.cyclops.integratedterminals.core.terminalstorage; | ||
|
|
||
| import net.minecraft.resources.ResourceLocation; | ||
| import net.minecraft.server.level.ServerPlayer; | ||
| import org.cyclops.integratedterminals.api.terminalstorage.ITerminalStorageTabServer; | ||
|
|
||
| /** | ||
| * A server-side storage terminal tab for Ender Chest. | ||
| * @author rubensworks | ||
| */ | ||
| public class TerminalStorageTabEnderChestServer implements ITerminalStorageTabServer { | ||
|
|
||
| private final ResourceLocation name; | ||
| private final ServerPlayer player; | ||
|
|
||
| public TerminalStorageTabEnderChestServer(ResourceLocation name, ServerPlayer player) { | ||
| this.name = name; | ||
| this.player = player; | ||
| } | ||
|
|
||
| @Override | ||
| public ResourceLocation getName() { | ||
| return this.name; | ||
| } | ||
|
|
||
| @Override | ||
| public void init() { | ||
| // No initialization needed | ||
| } | ||
|
|
||
| @Override | ||
| public void deInit() { | ||
| // No cleanup needed | ||
| } | ||
|
|
||
| @Override | ||
| public void updateActive() { | ||
| // No active updates needed - Minecraft handles Ender Chest inventory updates automatically | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in a93613d - changed to "Ender Storage"