@@ -2,6 +2,7 @@ import { ItemStack, system } from '@minecraft/server'
22
33import { MinecraftBlockTypes , MinecraftEffectTypes , MinecraftItemTypes } from '@minecraft/vanilla-data'
44import { isKeyof , ms } from 'lib'
5+ import { RegionEvents } from 'lib/region/events'
56import { actionGuard , ActionGuardOrder , disableAdventureNear , Region , RegionPermissions } from 'lib/region/index'
67import { ScheduleBlockPlace } from 'lib/scheduled-block-place'
78import { TechCity } from '../tech-city/tech-city'
@@ -42,29 +43,28 @@ system.runPlayerInterval(
4243 player => {
4344 const { typeId } = player . mainhand ( )
4445
45- // TODO Maybe check for region or inv type
4646 if ( typeId && isKeyof ( typeId , HoeEffectLevels ) ) {
47- player . addEffect ( MinecraftEffectTypes . Haste , 2 , {
48- amplifier : HoeEffectLevels [ typeId ] ,
49- showParticles : false ,
50- } )
47+ const inQuartzMine = RegionEvents . playerInRegionsCache
48+ . get ( player )
49+ ?. some ( e => e === TechCity . safeArea || e instanceof QuartzMineRegion )
50+
51+ if ( inQuartzMine ) {
52+ player . addEffect ( MinecraftEffectTypes . Haste , 2 , {
53+ amplifier : HoeEffectLevels [ typeId ] ,
54+ showParticles : false ,
55+ } )
56+ }
5157 }
5258 } ,
5359 'quartz feature, hoe haste effect' ,
5460 2 ,
5561)
5662
57- actionGuard ( ( player , region , ctx ) => {
58- if (
59- ctx . type !== 'break' ||
60- ( region !== TechCity . safeArea && ! ( region instanceof QuartzMineRegion ) ) ||
61- // Check block
62- ctx . event . block . typeId !== quartzTypeId ||
63- // Check item
64- ! ctx . event . itemStack ?. typeId ||
65- ! ( ctx . event . itemStack . typeId in HoeEffectLevels )
66- )
67- return
63+ actionGuard ( ( _ , region , ctx ) => {
64+ if ( ctx . type !== 'break' ) return
65+ if ( region !== TechCity . safeArea && ! ( region instanceof QuartzMineRegion ) ) return
66+ if ( ctx . event . block . typeId !== quartzTypeId ) return
67+ if ( ! ctx . event . itemStack ?. typeId || ! ( ctx . event . itemStack . typeId in HoeEffectLevels ) ) return
6868
6969 ScheduleBlockPlace . setBlock ( ctx . event . block , ms . from ( 'min' , 2 ) )
7070
0 commit comments