Merge pull request #23 from saschabuehrle/fix-issue-18

fix: guard fast easy place ticks against invalid entity/block lookups
This commit is contained in:
Forest
2026-04-21 21:55:56 -07:00
committed by GitHub
Unverified
+9 -3
View File
@@ -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) {
const mainhandItemStack = player.getComponent(EntityComponentTypes.Equippable).getEquipment(EquipmentSlot.Mainhand); try {
if (!mainhandItemStack) const mainhandItemStack = player.getComponent(EntityComponentTypes.Equippable).getEquipment(EquipmentSlot.Mainhand);
if (!mainhandItemStack)
return false;
return mainhandItemStack.typeId === ACTION_ITEM;
} catch {
return false; return false;
return mainhandItemStack.typeId === ACTION_ITEM; }
} }
function tryPlaceBlock(player, worldBlock, structureBlock) { function tryPlaceBlock(player, worldBlock, structureBlock) {