Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/generated/resources/assets/anvilcraft/lang/en_ud.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@
"anvilcraft.configuration.induction_light_block_ripening_cooldown.tooltip": "uʍopꞁooɔ ᵷuᴉuǝdᴉɹ ʞɔoꞁq ʇɥᵷᴉꞁ uoᴉʇɔnpuI",
"anvilcraft.configuration.induction_light_block_ripening_range": "ǝᵷuɐᴚ ᵷuᴉuǝdᴉᴚ ʞɔoꞁᗺ ʇɥᵷᴉꞀ uoᴉʇɔnpuI",
"anvilcraft.configuration.induction_light_block_ripening_range.tooltip": "ǝᵷuɐɹ ᵷuᴉuǝdᴉɹ ʞɔoꞁq ʇɥᵷᴉꞁ uoᴉʇɔnpuI",
"anvilcraft.configuration.invert_container_collect_click": "ʞɔᴉꞁƆ ʇɔǝꞁꞁoƆ ɹǝuᴉɐʇuoƆ ʇɹǝʌuI",
"anvilcraft.configuration.invert_container_collect_click.tooltip": "sI∩⅁ uᴉ xoq ꞁꞁᴉd puɐ xoq ʇǝꞁnɯɐ 'ꞁɐuᴉɯɹǝʇ uoᴉsuǝɯᴉpɹǝdʎɥ ǝɥʇ oʇuᴉ sɯǝʇᴉ sʇɔǝꞁꞁoɔ ʇɐɥʇ uoʇʇnq ʞɔᴉꞁɔ ǝɥʇ ʇɹǝʌuI",
"anvilcraft.configuration.ionocraft_backpack_exhaust_particles_enabled": "sǝꞁɔᴉʇɹɐԀ ʇsnɐɥxƎ ʞɔɐdʞɔɐᗺ ʇɟɐɹɔouoI ʍoɥS",
"anvilcraft.configuration.ionocraft_backpack_exhaust_particles_enabled.tooltip": "ʞɔɐdʞɔɐᗺ ʇɟɐɹɔouoI ɥʇᴉʍ ᵷuᴉʎꞁɟ uǝɥʍ sǝꞁɔᴉʇɹɐd ʇsnɐɥxǝ ǝꞁqɐuƎ",
"anvilcraft.configuration.ionocraft_backpack_hud": "ᗡ∩H ʞɔɐdʞɔɐᗺ ʇɟɐɹɔouoI",
Expand Down Expand Up @@ -841,7 +843,7 @@
"gui.anvilcraft.category.charger_charging.time": "puoɔǝs %s :ǝɯᴉ⟘",
"gui.anvilcraft.category.container_upgrade": "ǝpɐɹᵷd∩ ɹǝuᴉɐʇuoƆ",
"gui.anvilcraft.category.container_upgrade.drop_on_top": "ɹǝuᴉɐʇuoɔ ǝɥʇ oʇuo sɯǝʇᴉ ǝsǝɥʇ doɹᗡ",
"gui.anvilcraft.category.container_upgrade.requires_expansion": "suoᴉsuɐdxƎ ɹossǝɹdɯoɔ-ɹǝʌO ǝɔɐdS ߈ sǝɹᴉnbǝᴚ",
"gui.anvilcraft.category.container_upgrade.requires_expansion": "sǝpɐɹᵷd∩ ɹossǝɹdɯoɔɹǝʌO ǝɔɐdS ߈ sǝɹᴉnbǝᴚ",
"gui.anvilcraft.category.container_upgrade.strike": "ɹǝuᴉɐʇuoɔ ǝɥʇ ǝpɐɹᵷdn oʇ ꞁᴉʌuɐ uɐ ɥʇᴉʍ ǝʞᴉɹʇS",
"gui.anvilcraft.category.decay": "ʎɐɔǝᗡ",
"gui.anvilcraft.category.decay.around": "uʍoɥs sɐ ɹǝʇuǝɔ ǝɥʇ punoɹɐ sʞɔoꞁq ǝsǝɥʇ ǝɔɐꞁԀ",
Expand Down
4 changes: 3 additions & 1 deletion src/generated/resources/assets/anvilcraft/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@
"anvilcraft.configuration.induction_light_block_ripening_cooldown.tooltip": "Induction light block ripening cooldown",
"anvilcraft.configuration.induction_light_block_ripening_range": "Induction Light Block Ripening Range",
"anvilcraft.configuration.induction_light_block_ripening_range.tooltip": "Induction light block ripening range",
"anvilcraft.configuration.invert_container_collect_click": "Invert Container Collect Click",
"anvilcraft.configuration.invert_container_collect_click.tooltip": "Invert the click button that collects items into the hyperdimension terminal, amulet box and pill box in GUIs",
"anvilcraft.configuration.ionocraft_backpack_exhaust_particles_enabled": "Show Ionocraft Backpack Exhaust Particles",
"anvilcraft.configuration.ionocraft_backpack_exhaust_particles_enabled.tooltip": "Enable exhaust particles when flying with Ionocraft Backpack",
"anvilcraft.configuration.ionocraft_backpack_hud": "Ionocraft Backpack HUD",
Expand Down Expand Up @@ -841,7 +843,7 @@
"gui.anvilcraft.category.charger_charging.time": "Time: %s second",
"gui.anvilcraft.category.container_upgrade": "Container Upgrade",
"gui.anvilcraft.category.container_upgrade.drop_on_top": "Drop these items onto the container",
"gui.anvilcraft.category.container_upgrade.requires_expansion": "Requires 4 Space Over-compressor Expansions",
"gui.anvilcraft.category.container_upgrade.requires_expansion": "Requires 4 Space Overcompressor Upgrades",
"gui.anvilcraft.category.container_upgrade.strike": "Strike with an anvil to upgrade the container",
"gui.anvilcraft.category.decay": "Decay",
"gui.anvilcraft.category.decay.around": "Place these blocks around the center as shown",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ public static void onScreenMousePressedTerminal(ScreenEvent.MouseButtonPressed.P
event.setCanceled(true);
}
return;
} else if (!carriedEmpty && minecraft.options.keyUse.matchesMouse(event.getButton())) {
// 捏着物品右键:把整组放入对应存储站
} else if (!carriedEmpty && ClientEventListener.isCollectMouseButton(event.getButton())) {
// 捏着物品按收纳键(默认右键,可配置反转成左键):把整组放入对应存储站
TerminalBinding binding = slot.getItem().get(ModComponents.TERMINAL_BINDING);
if (binding != null && binding.id().isPresent()) {
// 服务端 terminalInsert 会修改 carried 并经 broadcastChanges 广播同步到
Expand All @@ -267,11 +267,11 @@ public static void onScreenMousePressedTerminal(ScreenEvent.MouseButtonPressed.P
TerminalRemoteOverlay.applyCarriedIfCreative(result.carried());
}));
}
// 捏着物品左键:阻止交换(不把终端捏起,也不放入),保持终端不动
// 阻止交换(不把终端捏起,也不放入),保持终端不动
event.setCanceled(true);
return;
}
// 捏着物品左键:阻止交换(不把终端捏起,也不放入),保持终端不动
// 非收纳键点击(或空手但已屏蔽浮窗):阻止交换(不把终端捏起,也不放入),保持终端不动
event.setCanceled(true);
return;
}
Expand All @@ -288,6 +288,17 @@ public static void onScreenMousePressedTerminal(ScreenEvent.MouseButtonPressed.P
}
}

/**
* 当前配置下用于把物品收纳进超维终端/护符盒/药盒的鼠标按键
* (默认右键,配置 invertContainerCollectClick 后为左键)。
*/
private static boolean isCollectMouseButton(int button) {
Minecraft minecraft = Minecraft.getInstance();
return AnvilCraft.CLIENT_CONFIG.invertContainerCollectClick
? minecraft.options.keyAttack.matchesMouse(button)
: minecraft.options.keyUse.matchesMouse(button);
}

/**
* 根据 GUI 坐标在容器菜单槽位中查找鼠标悬停的槽位,复刻
* {@link AbstractContainerScreen#isHovering} 的判定,不依赖渲染帧的 hoveredSlot。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public class AnvilCraftClientConfig {
@Comment("Add a tooltip line that shows storage stored ID")
public boolean showStorageStoredId = false;

@Comment("Invert the click button that collects items into the hyperdimension terminal, amulet box and pill box in GUIs")
public boolean invertContainerCollectClick = false;

@Comment("Enable ground heave shockwave particles and sound when giant anvil triggers shock mechanism")
public boolean groundHeaveParticlesEnabled = true;

Expand Down
5 changes: 1 addition & 4 deletions src/main/java/dev/dubhe/anvilcraft/data/lang/JeiLang.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,7 @@ public static void init(RegistrumLangProvider provider) {
provider.add("gui.anvilcraft.category.container_upgrade", "Container Upgrade");
provider.add("gui.anvilcraft.category.container_upgrade.drop_on_top", "Drop these items onto the container");
provider.add("gui.anvilcraft.category.container_upgrade.strike", "Strike with an anvil to upgrade the container");
provider.add(
"gui.anvilcraft.category.container_upgrade.requires_expansion",
"Requires 4 Space Over-compressor Expansions"
);
provider.add("gui.anvilcraft.category.container_upgrade.requires_expansion", "Requires 4 Space Overcompressor Upgrades");

provider.add("gui.anvilcraft.category.decay", "Decay");
provider.add("gui.anvilcraft.category.decay.random_tick", "The block at center will decay on a random tick");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package dev.dubhe.anvilcraft.item;

import dev.dubhe.anvilcraft.AnvilCraft;
import net.minecraft.world.inventory.ClickAction;

/**
* 超维终端/护符盒/药盒在容器界面中共用的「收纳/取出」交互:默认使用右键(与护符盒一致),
* 可通过客户端配置 invertContainerCollectClick 反转成左键。
* 收纳与取出共用同一个按键:点击物品收纳、点击空位取出。
*/
public final class ContainerCollectInteraction {
private ContainerCollectInteraction() {
}

/** 当前配置下用于收纳/取出的点击动作。 */
public static ClickAction collectAction() {
return AnvilCraft.CLIENT_CONFIG.invertContainerCollectClick ? ClickAction.PRIMARY : ClickAction.SECONDARY;
}

/** 判断一次点击是否为当前配置下的收纳/取出动作。 */
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public static boolean isCollectAction(ClickAction action) {
return action == ContainerCollectInteraction.collectAction();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import dev.dubhe.anvilcraft.client.rpc.StorageTerminalClientStub;
import dev.dubhe.anvilcraft.init.item.ModComponents;
import dev.dubhe.anvilcraft.item.property.component.TerminalBinding;
import dev.dubhe.anvilcraft.rpc.StorageServerStub;
import net.minecraft.client.Minecraft;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
Expand All @@ -13,6 +14,8 @@
import net.minecraft.world.InteractionResult;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.ClickAction;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
Expand All @@ -38,10 +41,37 @@ public InteractionResultHolder<ItemStack> use(Level level, Player player, Intera
}

@Override
public boolean canFitInsideContainerItems() {
public boolean canFitInsideContainerItems(ItemStack stack) {
return false;
}

/**
* 在容器界面中拿着超维终端点击物品槽位:按收纳键(默认右键,可配置反转)把槽位物品
* 整组收进绑定存储站,与护符盒/药盒的收纳交互保持一致。仅服务端执行,客户端交给
* vanilla 预测并在服务端广播后校正。
*/
@Override
public boolean overrideStackedOnOther(ItemStack stack, Slot slot, ClickAction action, Player player) {
if (!(player instanceof ServerPlayer) || !ContainerCollectInteraction.isCollectAction(action)) {
return false;
}
if (!slot.allowModification(player)) {
return false;
}
TerminalBinding binding = stack.get(ModComponents.TERMINAL_BINDING);
if (binding == null || binding.id().isEmpty()) {
return false;
}
ItemStack other = slot.getItem();
int inserted = StorageServerStub.insertIntoStorage(binding.id().get(), other);
if (inserted <= 0) {
return false;
}
other.shrink(inserted);
slot.set(other.isEmpty() ? ItemStack.EMPTY : other);
return true;
}

@Override
public void appendHoverText(ItemStack stack, TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
super.appendHoverText(stack, context, tooltipComponents, tooltipFlag);
Expand Down
68 changes: 30 additions & 38 deletions src/main/java/dev/dubhe/anvilcraft/item/PillBoxItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,63 +50,55 @@ public boolean overrideOtherStackedOnMe(
Player player,
SlotAccess access
) {
final PillBocContents contents = stack.getOrDefault(ModComponents.PILL_BOC_CONTENTS, PillBocContents.EMPTY);
final PillBocContents.Mutable mutable = contents.mutable();
if (!slot.allowModification(player)) {
if (!ContainerCollectInteraction.isCollectAction(action) || !slot.allowModification(player)) {
return false;
}
if (action == ClickAction.PRIMARY) {
if (!other.isEmpty()) {
if (mutable.insert(other)) {
final PillBocContents contents = stack.getOrDefault(ModComponents.PILL_BOC_CONTENTS, PillBocContents.EMPTY);
final PillBocContents.Mutable mutable = contents.mutable();
if (!other.isEmpty()) {
if (mutable.insert(other)) {
stack.set(ModComponents.PILL_BOC_CONTENTS, mutable.immutable());
access.set(ItemStack.EMPTY);
return true;
}
} else {
Optional<ItemStack> stackOptional = mutable.get();
if (stackOptional.isPresent()) {
ItemStack itemStack = stackOptional.get();
if (!itemStack.isEmpty()) {
access.set(itemStack);
stack.set(ModComponents.PILL_BOC_CONTENTS, mutable.immutable());
access.set(ItemStack.EMPTY);
return true;
}
}
} else if (action == ClickAction.SECONDARY) {
if (other.isEmpty()) {
Optional<ItemStack> stackOptional = mutable.get();
if (stackOptional.isPresent()) {
ItemStack itemStack = stackOptional.get();
if (!itemStack.isEmpty()) {
access.set(itemStack);
stack.set(ModComponents.PILL_BOC_CONTENTS, mutable.immutable());
return true;
}
}
}
}
return false;
}

@Override
public boolean overrideStackedOnOther(ItemStack stack, Slot slot, ClickAction action, Player player) {
if (!ContainerCollectInteraction.isCollectAction(action) || !slot.allowModification(player)) {
return false;
}
final PillBocContents contents = stack.getOrDefault(ModComponents.PILL_BOC_CONTENTS, PillBocContents.EMPTY);
final PillBocContents.Mutable mutable = contents.mutable();
final ItemStack other = slot.getItem();
if (!slot.allowModification(player)) {
return false;
}
if (action == ClickAction.PRIMARY) {
if (!other.isEmpty()) {
if (mutable.insert(other)) {
if (!other.isEmpty()) {
if (mutable.insert(other)) {
stack.set(ModComponents.PILL_BOC_CONTENTS, mutable.immutable());
slot.set(ItemStack.EMPTY);
return true;
}
} else {
Optional<ItemStack> stackOptional = mutable.get();
if (stackOptional.isPresent()) {
ItemStack itemStack = stackOptional.get();
if (!itemStack.isEmpty()) {
slot.set(itemStack);
stack.set(ModComponents.PILL_BOC_CONTENTS, mutable.immutable());
slot.set(ItemStack.EMPTY);
return true;
}
}
} else if (action == ClickAction.SECONDARY) {
if (other.isEmpty()) {
Optional<ItemStack> stackOptional = mutable.get();
if (stackOptional.isPresent()) {
ItemStack itemStack = stackOptional.get();
if (!itemStack.isEmpty()) {
slot.set(itemStack);
stack.set(ModComponents.PILL_BOC_CONTENTS, mutable.immutable());
return true;
}
}
}
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import dev.dubhe.anvilcraft.AnvilCraft;
import dev.dubhe.anvilcraft.init.item.ModComponents;
import dev.dubhe.anvilcraft.init.item.ModItemTags;
import dev.dubhe.anvilcraft.item.ContainerCollectInteraction;
import dev.dubhe.anvilcraft.item.property.component.BoxContents;
import dev.dubhe.anvilcraft.util.ColorUtil;
import net.minecraft.sounds.SoundEvents;
Expand Down Expand Up @@ -37,7 +38,7 @@ public AmuletBoxItem(Properties properties) {

@Override
public boolean overrideStackedOnOther(ItemStack itemStack, Slot slot, ClickAction clickAction, Player player) {
if (clickAction != ClickAction.SECONDARY || !slot.allowModification(player)) return false;
if (!ContainerCollectInteraction.isCollectAction(clickAction) || !slot.allowModification(player)) return false;
BoxContents contents = itemStack.getOrDefault(ModComponents.BOX_CONTENTS, BoxContents.EMPTY);
BoxContents.Mutable mutable = contents.mutable();
ItemStack other = slot.getItem();
Expand Down Expand Up @@ -65,7 +66,7 @@ public boolean overrideOtherStackedOnMe(
Player player,
SlotAccess slotAccess
) {
if (clickAction != ClickAction.SECONDARY || !slot.allowModification(player)) return false;
if (!ContainerCollectInteraction.isCollectAction(clickAction) || !slot.allowModification(player)) return false;
BoxContents.Mutable contents = box.getOrDefault(ModComponents.BOX_CONTENTS, BoxContents.EMPTY).mutable();
if (other.isEmpty()) {
ItemStack itemStack = contents.pop();
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/dev/dubhe/anvilcraft/rpc/StorageServerStub.java
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,23 @@ public static InteractionResult terminalInsert(
return new InteractionResult(carried, true);
}

/**
* 把物品堆直接放入指定存储(超维终端在界面中收纳物品用),返回实际放入数量。
* 与 {@link #terminalInsert} 的远程路径一致,直接写入存储并触发版本刷新;
* 被存储拒绝(如嵌套容器)时返回 0,物品保留原位。
*/
public static int insertIntoStorage(UUID storageId, ItemStack stack) {
if (stack.isEmpty()) {
return 0;
}
HyperdimensionStorage storage = Storages.get().getOrCreate(storageId, HyperdimensionStorage.class);
if (!StorageServerStub.canStore(storage, stack)) {
return 0;
}
ItemStack leftover = storage.getItems().insertItem(stack.copy(), false);
return stack.getCount() - leftover.getCount();
}

/**
* JEI 快速合成补库:终端持有者把合成缺少的物品从绑定存储站取出补入背包。
* 仅当玩家确实持有指向该 storageId 的已绑定终端时生效。
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading