Skip to content

Commit

Permalink
- Add outsideBuildHeight check for auto assembly.
Browse files Browse the repository at this point in the history
- Performance improvements.
  • Loading branch information
KasumiNova committed Oct 30, 2024
1 parent f20623c commit 8477c98
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -17,7 +18,7 @@
public class RegistryUpgrade {

public static final HashMap<String, MachineUpgrade> UPGRADES = new HashMap<>();
public static final Map<Item, UpgradeInfo> ITEM_UPGRADES = new HashMap<>();
public static final Map<Item, UpgradeInfo> ITEM_UPGRADES = new Reference2ObjectOpenHashMap<>();

public static void clearAll() {
RegistryUpgrade.UPGRADES.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) ||
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/modularmachinery/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/modularmachinery/lang/zh_CN.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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=模块化组装:缺失材料,需要以下材料:
Expand Down

0 comments on commit 8477c98

Please sign in to comment.