Skip to content

Commit 2efbe7b

Browse files
committed
fix: avoid invalid entity errors in fast easy place tick handling
1 parent 7c7c0c2 commit 2efbe7b

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

packs/BP/scripts/options/fastEasyPlace.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ function processEasyPlace(player) {
8686
if (!structureBlock)
8787
return;
8888
const worldBlock = player.dimension.getBlock(structureBlock.location);
89+
if (!worldBlock)
90+
return;
8991
if (locationsPlacedLastTick.has(JSON.stringify(worldBlock.location)))
9092
return;
9193
locationsPlacedLastTick.add(JSON.stringify(worldBlock.location));
@@ -103,10 +105,14 @@ function preventAction(event, player) {
103105
}
104106

105107
function isHoldingActionItem(player) {
106-
const mainhandItemStack = player.getComponent(EntityComponentTypes.Equippable).getEquipment(EquipmentSlot.Mainhand);
107-
if (!mainhandItemStack)
108+
try {
109+
const mainhandItemStack = player.getComponent(EntityComponentTypes.Equippable).getEquipment(EquipmentSlot.Mainhand);
110+
if (!mainhandItemStack)
111+
return false;
112+
return mainhandItemStack.typeId === ACTION_ITEM;
113+
} catch {
108114
return false;
109-
return mainhandItemStack.typeId === ACTION_ITEM;
115+
}
110116
}
111117

112118
function tryPlaceBlock(player, worldBlock, structureBlock) {

0 commit comments

Comments
 (0)