-
-
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
base: master-1.19-lts
Are you sure you want to change the base?
Changes from 2 commits
0be3b4e
942234d
1674895
86227d9
a93613d
0212260
ac0c549
05977df
d4f2d5b
4b7c0b8
2f301ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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.IntegratedTerminals; | ||
| 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(IntegratedTerminals.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()); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,185 @@ | ||
| package org.cyclops.integratedterminals.core.terminalstorage; | ||
|
|
||
| import com.google.common.collect.Lists; | ||
| import com.mojang.blaze3d.vertex.PoseStack; | ||
| import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; | ||
| 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.api.terminalstorage.ITerminalStorageTabCommon; | ||
| import org.cyclops.integratedterminals.client.gui.container.ContainerScreenTerminalStorage; | ||
| 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; | ||
| private final ITerminalRowColumnProvider rowColumnProvider; | ||
|
|
||
| public TerminalStorageTabEnderChestClient(ContainerTerminalStorageBase container, ResourceLocation name) { | ||
| this.name = name; | ||
| this.icon = new ItemStack(Blocks.ENDER_CHEST); | ||
| this.container = container; | ||
| this.rowColumnProvider = () -> new ITerminalRowColumnProvider.RowsColumns(5, 9); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Introducing
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed in 1674895 - now using direct overrides of |
||
| } | ||
|
|
||
| @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 rowColumnProvider; | ||
| } | ||
|
|
||
| @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 int getSlotVisibleRows() { | ||
| return 3; // Ender Chest has 3 rows | ||
| } | ||
|
|
||
| @Override | ||
| public int getSlotRowLength() { | ||
| return 9; // 9 columns | ||
| } | ||
|
|
||
| @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; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| 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.IntegratedTerminals; | ||
| 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 | ||
| } | ||
| } |
| 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 | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |||||
| "gui.integratedterminals.terminal_storage.tooltip.fluid.amount": "%s mB", | ||||||
| "gui.integratedterminals.terminal_storage.storage_name": "%s Storage", | ||||||
| "gui.integratedterminals.terminal_storage.crafting_name": "%s Crafting", | ||||||
| "gui.integratedterminals.terminal_storage.ender_chest": "Ender Chest", | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in a93613d - changed to "Ender Storage" |
||||||
| "gui.integratedterminals.terminal_storage.channel": "Chan:", | ||||||
| "gui.integratedterminals.terminal_storage.craft": "craft", | ||||||
| "gui.integratedterminals.terminal_storage.tooltip.requirements": "Crafting Requirements:", | ||||||
|
|
||||||
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 1674895 - changed to use
Reference.MOD_ID