From e7d7d7da89dc2c0dbddb1acd07e10cba229ef8b9 Mon Sep 17 00:00:00 2001 From: xkball <45330674+xkball@users.noreply.github.com> Date: Mon, 11 Nov 2024 13:25:00 +0800 Subject: [PATCH] allow force enable display mode. Took 32 minutes --- gradle.properties | 2 +- .../java/org/teacon/powertool/block/PowerSupplyBlock.java | 4 +++- .../java/org/teacon/powertool/item/DisplayModeToolItem.java | 2 +- src/main/resources/assets/powertool/lang/en_us.json | 2 +- src/main/resources/assets/powertool/lang/zh_cn.json | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/gradle.properties b/gradle.properties index a64a0f3..c39585d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -34,7 +34,7 @@ mod_name=Power Tool # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=GPL-3.0 # The mod version. See https://semver.org/ -mod_version=1.4.24 +mod_version=1.4.25 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/src/main/java/org/teacon/powertool/block/PowerSupplyBlock.java b/src/main/java/org/teacon/powertool/block/PowerSupplyBlock.java index f7444cd..92da1a4 100644 --- a/src/main/java/org/teacon/powertool/block/PowerSupplyBlock.java +++ b/src/main/java/org/teacon/powertool/block/PowerSupplyBlock.java @@ -6,6 +6,7 @@ import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.ItemInteractionResult; +import net.minecraft.world.MenuProvider; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; @@ -37,11 +38,12 @@ protected MapCodec codec() { } @Override - @SuppressWarnings("deprecation") public RenderShape getRenderShape(BlockState pState) { return RenderShape.MODEL; } + + @Override protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { return use(level, pos, player); diff --git a/src/main/java/org/teacon/powertool/item/DisplayModeToolItem.java b/src/main/java/org/teacon/powertool/item/DisplayModeToolItem.java index 0396385..697de02 100644 --- a/src/main/java/org/teacon/powertool/item/DisplayModeToolItem.java +++ b/src/main/java/org/teacon/powertool/item/DisplayModeToolItem.java @@ -59,7 +59,7 @@ public InteractionResult useOn(UseOnContext context) { BlockState blockState = level.getBlockState(pos); MenuProvider menuProvider = blockState.getMenuProvider(level, pos); Component blockName = VanillaUtils.getName(blockState.getBlock()); - if (menuProvider == null) { + if (menuProvider == null && !player.isShiftKeyDown()) { player.displayClientMessage( Component.translatable("powertool.gui.display_mode_error", blockName) .withStyle(ChatFormatting.RED), diff --git a/src/main/resources/assets/powertool/lang/en_us.json b/src/main/resources/assets/powertool/lang/en_us.json index 2c959fa..f83c7b8 100644 --- a/src/main/resources/assets/powertool/lang/en_us.json +++ b/src/main/resources/assets/powertool/lang/en_us.json @@ -138,5 +138,5 @@ "tooltip.powertool.display_tool": "Use on block to toggle Display Mode", "powertool.gui.display_mode_enabled": "Enabled display mode on %s", "powertool.gui.display_mode_disabled": "Disabled display mode on %s", - "powertool.gui.display_mode_error": "Could not enable display mode on %s because it has no ability to open any screen." + "powertool.gui.display_mode_error": "Could not enable display mode on %s because it has no ability to open any screen. Or press shift key and click again to force enable display mode." } \ No newline at end of file diff --git a/src/main/resources/assets/powertool/lang/zh_cn.json b/src/main/resources/assets/powertool/lang/zh_cn.json index 93e5d12..d51d085 100644 --- a/src/main/resources/assets/powertool/lang/zh_cn.json +++ b/src/main/resources/assets/powertool/lang/zh_cn.json @@ -139,6 +139,6 @@ "tooltip.powertool.display_tool": "在方块上使用以切换展示模式", "powertool.gui.display_mode_enabled": "已在%s上启用展示模式", "powertool.gui.display_mode_disabled": "已在%s上禁用展示模式", - "powertool.gui.display_mode_error": "无法在%s上启用展示模式,因为它无法打开任何可交互界面" + "powertool.gui.display_mode_error": "无法在%s上启用展示模式,因为它无法打开任何可交互界面.按下shift键强制启用展示模式." } \ No newline at end of file