Skip to content

Commit

Permalink
we: fix brush 4
Browse files Browse the repository at this point in the history
  • Loading branch information
leaftail1880 committed Nov 1, 2024
1 parent 8d2729e commit 704cd19
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 34 deletions.
14 changes: 0 additions & 14 deletions src/lib/roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,3 @@ if (!__VITEST__) {
}
})
}

if (!__VITEST__) {
system.delay(() => {
const lastVersionId = 'lastVersion'
if (world.getDynamicProperty(lastVersionId) !== __GIT__) {
world
.getAllPlayers()
.filter(e => is(e.id, 'techAdmin'))
.forEach(e => e.sendMessage(`§9>§f ${__GIT__}`))

world.setDynamicProperty(lastVersionId, __GIT__)
}
})
}
2 changes: 2 additions & 0 deletions src/modules/world-edit/lib/world-edit-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type StorageKey =
| 'radius'
| 'blending'
| 'factor'
| 'useInterval'

const LORE_SEPARATOR = '\u00a0'

Expand Down Expand Up @@ -133,6 +134,7 @@ export abstract class WorldEditTool<Storage extends StorageType = any> {
type: 'Тип',
blending: 'Смешивание',
factor: 'Фактор смешивания',
useInterval: 'Использовать интервал',
}

getStorage(slot: ContainerSlot | ItemStack, returnUndefined?: false): Storage
Expand Down
14 changes: 14 additions & 0 deletions src/modules/world-edit/tools/multi-shovel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ class MultiShovelTool extends WorldEditMultiTool {
storage.tools,
)
}

constructor() {
super()
this.onInterval(10, (player, storage, slot, settings) => {
this.forEachTool(
slot,
(proxiedItem, tool, toolStorage) => {
if (!tool.onUse) return
tool.interval10?.(player, toolStorage, proxiedItem, settings)
},
storage.tools,
)
})
}
}

new MultiShovelTool()
57 changes: 37 additions & 20 deletions src/modules/world-edit/tools/shovel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ interface Storage {
offset: number
blending: number
factor: number
useInterval: boolean
}

class ShovelTool extends WorldEditTool<Storage> {
id = 'shovel'
name = 'лопата'
typeId = Items.WeShovel
storageSchema = {
version: 4,
version: 5,

blocksSet: ['', ''] as BlocksSetRef,
replaceBlocksSet: ['', ''] as BlocksSetRef,
Expand All @@ -46,6 +47,7 @@ class ShovelTool extends WorldEditTool<Storage> {
offset: -1,
blending: -1,
factor: 20,
useInterval: true,
}

getMenuButtonName(player: Player) {
Expand All @@ -70,25 +72,30 @@ class ShovelTool extends WorldEditTool<Storage> {
storage.blending,
)
.addSlider('Сила смешивания', 0, 100, 1, storage.factor)
.show(player, (_, radius, height, offset, blocksSet, replaceBlocksSet, replaceMode, blending, factor) => {
slot.nameTag = `§r§3Лопата §f${radius} §6${blocksSet}`
storage.radius = radius
storage.height = height
storage.offset = offset
storage.replaceMode = replaceMode ?? ''
storage.blending = Math.min(radius, blending)
storage.factor = factor

storage.blocksSet = [player.id, blocksSet]

if (replaceBlocksSet) storage.replaceBlocksSet = [player.id, replaceBlocksSet]
else storage.replaceBlocksSet = ['', '']

this.saveStorage(slot, storage)
player.success(
t`${storage.blocksSet[0] ? 'Отредактирована' : 'Создана'} лопата с ${blocksSet} набором блоков и радиусом ${radius}`,
)
})
.addToggle('Использовать интервал для активации', storage.useInterval)
.show(
player,
(_, radius, height, offset, blocksSet, replaceBlocksSet, replaceMode, blending, factor, useInterval) => {
slot.nameTag = `§r§3Лопата §f${radius} §6${blocksSet}`
storage.radius = radius
storage.height = height
storage.offset = offset
storage.replaceMode = replaceMode ?? ''
storage.blending = Math.min(radius, blending)
storage.factor = factor
storage.useInterval = useInterval

storage.blocksSet = [player.id, blocksSet]

if (replaceBlocksSet) storage.replaceBlocksSet = [player.id, replaceBlocksSet]
else storage.replaceBlocksSet = ['', '']

this.saveStorage(slot, storage)
player.success(
t`${storage.blocksSet[0] ? 'Отредактирована' : 'Создана'} лопата с ${blocksSet} набором блоков и радиусом ${radius}`,
)
},
)
}

constructor() {
Expand All @@ -107,9 +114,19 @@ class ShovelTool extends WorldEditTool<Storage> {
}
}
})

this.onInterval(10, (player, storage) => {
if (!storage.useInterval) return
this.run(player, storage)
})
}

onUse(player: Player, _: ItemStack, storage: Storage) {
if (storage.useInterval) return
this.run(player, storage)
}

run(player: Player, storage: Storage) {
if (this.isLookingUp(player)) return

const permutations = getBlocksInSet(storage.blocksSet)
Expand Down

0 comments on commit 704cd19

Please sign in to comment.