From 8477c98d83645ac81554abdb0ad4f681cc8d1c17 Mon Sep 17 00:00:00 2001 From: Hikari_Nova <3044344887@qq.com> Date: Wed, 30 Oct 2024 17:56:27 +0800 Subject: [PATCH] - Add outsideBuildHeight check for auto assembly. - Performance improvements. --- .../mmce/common/upgrade/registry/RegistryUpgrade.java | 3 ++- .../java/ink/ikx/mmce/common/assembly/MachineAssembly.java | 7 +++++++ src/main/resources/assets/modularmachinery/lang/en_US.lang | 1 + src/main/resources/assets/modularmachinery/lang/zh_CN.lang | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/github/kasuminova/mmce/common/upgrade/registry/RegistryUpgrade.java b/src/main/java/github/kasuminova/mmce/common/upgrade/registry/RegistryUpgrade.java index 89ceb0f3..d8f2eedf 100644 --- a/src/main/java/github/kasuminova/mmce/common/upgrade/registry/RegistryUpgrade.java +++ b/src/main/java/github/kasuminova/mmce/common/upgrade/registry/RegistryUpgrade.java @@ -2,6 +2,7 @@ import crafttweaker.annotations.ZenRegister; import github.kasuminova.mmce.common.upgrade.MachineUpgrade; +import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import stanhebben.zenscript.annotations.ZenClass; @@ -17,7 +18,7 @@ public class RegistryUpgrade { public static final HashMap UPGRADES = new HashMap<>(); - public static final Map ITEM_UPGRADES = new HashMap<>(); + public static final Map ITEM_UPGRADES = new Reference2ObjectOpenHashMap<>(); public static void clearAll() { RegistryUpgrade.UPGRADES.clear(); diff --git a/src/main/java/ink/ikx/mmce/common/assembly/MachineAssembly.java b/src/main/java/ink/ikx/mmce/common/assembly/MachineAssembly.java index f344d427..85df1db8 100644 --- a/src/main/java/ink/ikx/mmce/common/assembly/MachineAssembly.java +++ b/src/main/java/ink/ikx/mmce/common/assembly/MachineAssembly.java @@ -483,6 +483,13 @@ public static boolean consumeInventoryFluid(final FluidStack required, final Lis } public static boolean replaceCheck(final BlockPos realPos, final World world, final EntityPlayer player) { + if (world.isOutsideBuildHeight(realPos)) { + String posToString = hellfirepvp.modularmachinery.common.util.MiscUtils.posToString(realPos); + player.sendMessage(new TextComponentTranslation("message.assembly.tip.too_high", posToString)); + player.sendMessage(new TextComponentTranslation("message.assembly.tip.skipped", posToString)); + return false; + } + IBlockState blockState = world.getBlockState(realPos); Block block = blockState.getBlock(); if (world.isAirBlock(realPos) || diff --git a/src/main/resources/assets/modularmachinery/lang/en_US.lang b/src/main/resources/assets/modularmachinery/lang/en_US.lang index db89e9ad..a435e271 100644 --- a/src/main/resources/assets/modularmachinery/lang/en_US.lang +++ b/src/main/resources/assets/modularmachinery/lang/en_US.lang @@ -177,6 +177,7 @@ message.assembly.tip.already_assembly=Modular Assembly: The machine is in the as message.assembly.tip.success=Modular Assembly: Assembled successfully! message.assembly.tip.cancelled=Modular Assembly: Assembled cancelled! message.assembly.tip.cannot_replace=Modular Assembly: Cannot place a block at %s, please check if a block exists at the target position! +message.assembly.tip.too_high=Modular Assembly: Cannot place a block at %s, because building height limit is exceeded! message.assembly.tip.skipped=Modular Assembly: Placement of block that have skipped %s. message.assembly.tip.missing=Modular Assembly: %s Needs item assembly, but inventory is missing block or bucket! message.assembly.tip.required=Modular assembly: Missing ingredients, the following ingredients are required: diff --git a/src/main/resources/assets/modularmachinery/lang/zh_CN.lang b/src/main/resources/assets/modularmachinery/lang/zh_CN.lang index 610b5ccf..06a23b3c 100644 --- a/src/main/resources/assets/modularmachinery/lang/zh_CN.lang +++ b/src/main/resources/assets/modularmachinery/lang/zh_CN.lang @@ -176,6 +176,7 @@ message.assembly.tip.already_assembly=模块化组装:机器已在组装队列 message.assembly.tip.success=模块化组装:组装完成! message.assembly.tip.cancelled=模块化组装:组装已取消! message.assembly.tip.cannot_replace=模块化组装: 无法在 %s 放置方块,请检查目标坐标是否存在方块! +message.assembly.tip.too_high=模块化组装: 无法在 %s 放置方块,因为超过建筑高度限制! message.assembly.tip.skipped=模块化组装:已跳过 %s 的方块放置。 message.assembly.tip.missing=模块化组装:%s 需要物品组装,但是物品栏中缺少方块或桶! message.assembly.tip.required=模块化组装:缺失材料,需要以下材料: