Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/TheMrZZ/sandstone
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMrZZ committed Jun 11, 2021
2 parents 6496221 + f71d210 commit 593a027
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 71 deletions.
2 changes: 2 additions & 0 deletions src/arguments/gamerules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ export type GAMERULES = (
'fallDamage' |
'fireDamage' |
'forgiveDeadPlayers' |
'freezeDamage' |
'keepInventory' |
'logAdminCommands' |
'maxCommandChainLength' |
'maxEntityCramming' |
'mobGriefing' |
'naturalRegeneration' |
'playersSleepingPercentage' |
'randomTickSpeed' |
'reducedDebugInfo' |
'sendCommandFeedback' |
Expand Down
8 changes: 4 additions & 4 deletions src/commands/CommandsRoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
Experience,
Fill,
Forceload,
FunctionCommand, GameruleCommand, Loot, Particle, RecipeCommand, ReplaceItem, Schedule, Scoreboard, SpreadPlayers, TagCommand, Team, Teleport, Time, Title, Trigger, Weather, WorldBorder,
FunctionCommand, GameruleCommand, Loot, Particle, RecipeCommand, Item, Schedule, Scoreboard, SpreadPlayers, TagCommand, Team, Teleport, Time, Title, Trigger, Weather, WorldBorder,
} from './implementations'

import type {
Expand Down Expand Up @@ -346,10 +346,10 @@ export class CommandsRoot {
* raw('mount', self, nearestSkeleton)
*/
@command([], { isRoot: true })
raw = (...args: unknown[]) => {}
raw = (...args: unknown[]) => { }

// replaceitem command //
replaceitem = new ReplaceItem(this)
// item command //
item = new Item(this)

// say command //
/**
Expand Down
2 changes: 2 additions & 0 deletions src/commands/implementations/Gamerule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class GameruleCommand extends Command {
* - `fallDamage `: Whether the player should take fall damage
* - `fireDamage `: Whether the player should take fire damage
* - `forgiveDeadPlayers `: Makes angered neutral mobs stop being angry when the targeted player dies nearby
* - `freezeDamage `: Whether entities take damage from freezing inside of powder snow.
* - `keepInventory `: Whether the player should keep items and experience in their inventory after death
* - `logAdminCommands `: Whether to log admin commands to server log
* - `maxCommandChainLength `: Determines the number at which the chain command block acts as a "chain".
Expand All @@ -41,6 +42,7 @@ export class GameruleCommand extends Command {
* should be able to change blocks and whether mobs can pick up items, which also disables bartering.
* This also affects the capability of zombie-like creatures like zombie pigmen and drowned to pathfind to turtle eggs.
* - `naturalRegeneration `: Whether the player can regenerate health naturally if their hunger is full enough (doesn't affect external healing, such as golden apples, the Regeneration effect, etc.)
* - `playersSleepingPercentage `: Controls what percentage of players must sleep to skip the night. When set to 0 or a negative value, a single player is sufficient to skip the night. The sleeping animation occurs as normal. When set over 100, the night cannot be skipped.
* - `randomTickSpeed `: How often a random block tick occurs (such as plant growth, leaf decay, etc.) per chunk section per game tick.
* 0 disables random ticks, higher numbers increase random ticks. Setting to a high integer results in high speeds of decay and growth
* - `reducedDebugInfo `: Whether the debug screen shows all or reduced information; and whether the effects of F3+B (entity hitboxes) and F3+G (chunk boundaries) are shown.
Expand Down
96 changes: 96 additions & 0 deletions src/commands/implementations/Item.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import { Command } from '@commands/Command'
import { command } from '@commands/decorators'
import { coordinatesParser, } from '@variables'

import type {
CONTAINER_SLOTS, Coordinates, ENTITY_SLOTS, ITEMS, MultipleEntitiesArgument,
} from 'src/arguments'


export class ItemSource extends Command {
/**
* Replace the slot with a specific item.
* @param item The item to replace the slot with.
* @param count The amount of items.
*/
@command('with')
with = (item: ITEMS, count: number) => { }

/**
* Replace the slot with a specific item.
* @param item The item to replace the slot with.
* @param count The amount of items.
*/
@command(['from', 'block'])
private fromBlock = (...args: unknown[]) => { }

@command(['from', 'entity'])
private fromEntity = (...args: unknown[]) => { }

/**
* Replace the slot with a block or an entity's item
*/
from: {
/**
* @param pos The coordinates of the container to copy items from.
* @param slot The slot to copy the items from.
* @param [modifier] An optional modifier to apply.
*/
block: (pos: Coordinates, slot: CONTAINER_SLOTS, modifier?: string) => void

/**
* @param targets The entity to copy items from.
* @param slot The slot to copy the items from.
* @param [modifier] An optional modifier to apply.
*/
entity: (targets: MultipleEntitiesArgument, slot: ENTITY_SLOTS, modifier?: string) => void
} = {
block: this.fromBlock,
entity: this.fromEntity
}
}

export class ModifyItem extends Command {

/**
* @param pos The position of the container containing the slot to apply the modifier to.
* @param slot The slot to apply the modifier to.
* @param modifier The name of the modifier.
*/
@command(['item', 'modify', 'block'], { isRoot: true, parsers: { '0': coordinatesParser } })
block = (pos: Coordinates, slot: CONTAINER_SLOTS, modifier: string) => { }

/**
* @param targets The entity/entities containing the slot to apply the modifier to.
* @param slot The slot to apply the modifier to.
* @param modifier The name of the modifier.
*/
@command(['item', 'modify', 'entity'], { isRoot: true })
entity = (targets: MultipleEntitiesArgument, slot: ENTITY_SLOTS, modifier: string) => { }
}

export class ReplaceItem extends Command {
/**
* @param pos The position of the container containing the slot to be replaced.
* @param slot The slot to be replaced.
*/
@command(['item', 'replace', 'block'], { isRoot: true, hasSubcommands: true, executable: false, parsers: { '0': coordinatesParser } })
block = (pos: Coordinates, slot: CONTAINER_SLOTS) => new ItemSource(this.commandsRoot)

/**
* @param targets one or more entities to modify.
.
* @param slot The slot to be replaced.
*/
@command(['item', 'replace', 'entity'], { isRoot: true, hasSubcommands: true, executable: false })
entity = (targets: MultipleEntitiesArgument, slot: ENTITY_SLOTS) => new ItemSource(this.commandsRoot)
}

/** Replaces or modifies items in inventories */
export class Item extends Command {
/** Applies a modifier to a slot in an inventory. */
modify = new ModifyItem(this.commandsRoot)

/** Replaces the content of a specific slot of an inventory with another. */
replace = new ReplaceItem(this.commandsRoot)
}
65 changes: 0 additions & 65 deletions src/commands/implementations/ReplaceItem.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/commands/implementations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export * from './Gamerule'
export * from './Loot'
export * from './Particle'
export * from './Recipe'
export * from './ReplaceItem'
export * from './Item'
export * from './Schedule'
export * from './Scoreboard'
export * from './SpreadPlayers'
Expand Down
2 changes: 1 addition & 1 deletion src/commandsOnly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const {
raw,
recipe,
reload,
replaceitem,
item,
say,
schedule,
scoreboard,
Expand Down

0 comments on commit 593a027

Please sign in to comment.