fix: avoid invalid entity errors in fast easy place tick handling

This commit is contained in:
saschabuehrle
2026-04-12 10:48:32 +02:00
Unverified
parent 7c7c0c2d0d
commit 2efbe7be0c
@@ -86,6 +86,8 @@ function processEasyPlace(player) {
if (!structureBlock) if (!structureBlock)
return; return;
const worldBlock = player.dimension.getBlock(structureBlock.location); const worldBlock = player.dimension.getBlock(structureBlock.location);
if (!worldBlock)
return;
if (locationsPlacedLastTick.has(JSON.stringify(worldBlock.location))) if (locationsPlacedLastTick.has(JSON.stringify(worldBlock.location)))
return; return;
locationsPlacedLastTick.add(JSON.stringify(worldBlock.location)); locationsPlacedLastTick.add(JSON.stringify(worldBlock.location));
@@ -103,10 +105,14 @@ function preventAction(event, player) {
} }
function isHoldingActionItem(player) { function isHoldingActionItem(player) {
try {
const mainhandItemStack = player.getComponent(EntityComponentTypes.Equippable).getEquipment(EquipmentSlot.Mainhand); const mainhandItemStack = player.getComponent(EntityComponentTypes.Equippable).getEquipment(EquipmentSlot.Mainhand);
if (!mainhandItemStack) if (!mainhandItemStack)
return false; return false;
return mainhandItemStack.typeId === ACTION_ITEM; return mainhandItemStack.typeId === ACTION_ITEM;
} catch {
return false;
}
} }
function tryPlaceBlock(player, worldBlock, structureBlock) { function tryPlaceBlock(player, worldBlock, structureBlock) {