Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small typo fixes + move eslint step to lint job (CI) #231

Merged
merged 13 commits into from
Feb 22, 2024
Merged
12 changes: 8 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ jobs:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

# Install python
# Install python and npm
- uses: actions/setup-python@v3
with:
python-version: '3.x'
- uses: bahmutov/npm-install@v1
with:
node-version: 16

# Install isort and black for linting
- name: Install isort and black
Expand All @@ -41,6 +44,10 @@ jobs:
# Run black
- name: Run black
run: black --check --color --diff .

# Run eslint
- name: Test eslint
run: npm run lint

# This workflow contains a single job called "build"
build:
Expand All @@ -67,9 +74,6 @@ jobs:
- name: Install polib
run: pip install polib

- name: Test eslint
run: npm run lint

- name: Run build script (${{ matrix.target }})
run: python build.py --clean --target ${{ matrix.target }}

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ BP/scripts/*
RP/manifest.json
BP/manifest.json
node_modules
.venv
.vscode
app/.import
__pycache__
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ To properly add this addon to the server, you first need to upload an already ex
WorldEdit currently has the following features.
- Clipboard manipulation (Cut, Copy, Paste)
- Masking blocks from certain actions
- Maniuplating region selections
- Manipulating region selections
- Navigation commands and the Navigation Wand
- Generating shapes
- Multiblock patterns
Expand All @@ -38,7 +38,7 @@ These features will be added in the near future.
- More brushes and tools
- More selection shapes
- More selection operations
- Palletes
- Palettes
- Basically, Java Parity

## Documentation
Expand Down
70 changes: 35 additions & 35 deletions app/biome_height_data.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var height_limit: int
var _is_valid = false
var _height_data = []
var _biome_data = []
# var _biome_pallete_data = []
# var _biome_palette_data = []

# warning-ignore:shadowed_variable
func _init(x: int, z: int, dimension = 0) -> void:
Expand Down Expand Up @@ -50,7 +50,7 @@ func load_from_db(leveldb: LevelDB, mutex: Mutex = null) -> void:
var header = buffer.get_u8()
if header == 0xff:
_biome_data.append(null)
# _biome_pallete_data.append(null)
# _biome_palette_data.append(null)
continue

# warning-ignore:unused_variable
Expand All @@ -72,26 +72,26 @@ func load_from_db(leveldb: LevelDB, mutex: Mutex = null) -> void:
else:
ids = _get_packed_bits(buffer, bits_per_entry, 4096)

var palletes = []
var pallete_count = buffer.get_u8()
var palettes = []
var palette_count = buffer.get_u8()
buffer.big_endian = true
for i in pallete_count:
for i in palette_count:
var biome = buffer.get_32()
palletes.append(biome)
palettes.append(biome)
buffer.big_endian = false

buffer.seek(buffer.get_position() + 3) # strangely three bytes of padding seem to be added to the pallete
buffer.seek(buffer.get_position() + 3) # strangely three bytes of padding seem to be added to the palette

var biome_ids = []
for id in ids:
biome_ids.append(palletes[id] if id < pallete_count else 0)
biome_ids.append(palettes[id] if id < palette_count else 0)
_biome_data.append(biome_ids)
# _biome_pallete_data.append(palletes)
# _biome_palette_data.append(palettes)

else:
var id = buffer.get_32()
_biome_data.append(id)
# _biome_pallete_data.append([id])
# _biome_palette_data.append([id])

height_limit = min_height + _biome_data.size() * 16
_is_valid = true
Expand Down Expand Up @@ -119,27 +119,27 @@ func save_to_db(leveldb: LevelDB, mutex: Mutex = null) -> int:
buffer.put_u8(0xff)
continue

var pallete: Array
var palette: Array
if typeof(biomes) == TYPE_ARRAY:
var new_pallete := {}
var new_palette := {}
for b in biomes:
new_pallete[b] = 0
pallete = new_pallete.keys()
new_palette[b] = 0
palette = new_palette.keys()
else:
pallete = [biomes]
palette = [biomes]

if pallete.size() > 1:
if palette.size() > 1:
# warning-ignore:narrowing_conversion
var bits_per_entry: int = nearest_po2(log(nearest_po2(pallete.size())) / log(2))
var bits_per_entry: int = nearest_po2(log(nearest_po2(palette.size())) / log(2))
buffer.put_u8((bits_per_entry << 1) + 1)

var reverse_pallete = {}
for j in pallete.size():
reverse_pallete[pallete[j]] = j
var reverse_palette = {}
for j in palette.size():
reverse_palette[palette[j]] = j

var ids = []
for biome in biomes:
ids.append(reverse_pallete[biome])
ids.append(reverse_palette[biome])

if bits_per_entry > 2:
var height_buffer = StreamPeerBuffer.new()
Expand All @@ -153,16 +153,16 @@ func save_to_db(leveldb: LevelDB, mutex: Mutex = null) -> int:
else:
_put_packed_bits(buffer, bits_per_entry, ids)

buffer.put_u8(pallete.size())
buffer.put_u8(palette.size())
buffer.big_endian = true
for p in pallete:
for p in palette:
buffer.put_32(p)
buffer.big_endian = false

buffer.put_data([0x00, 0x00, 0x00])
else:
buffer.put_u8(0x01)
buffer.put_32(pallete[0])
buffer.put_32(palette[0])

if mutex:
mutex.lock()
Expand Down Expand Up @@ -336,29 +336,29 @@ func _put_packed_bits(buffer: StreamPeer, size: int, input: Array) -> void:
# var new_biomes = _biome_changes[y_idx]
#
# var biomes = _biome_data[y_idx]
# var pallete = _biome_pallete_data[y_idx]
# var palette = _biome_palette_data[y_idx]
#
# for change in new_biomes:
# var biome: int = new_biomes[change]
#
# if pallete.size() == 1:
# if pallete[0] == biome:
# if palette.size() == 1:
# if palette[0] == biome:
# continue
#
# pallete.append(biome)
# palette.append(biome)
# var new_data = []
# for i in 4096:
# new_data.append(pallete[0])
# new_data.append(palette[0])
# _biome_data[y_idx] = new_data
# biomes = new_data
#
# var subchunk_idx = xyz_to_idx(change.x, change.y, change.z)
#
# if pallete.size() > 1:
# var new_pallete = {}
# if palette.size() > 1:
# var new_palette = {}
# for b in biomes:
# new_pallete[b] = 0
# new_palette[b] = 0
#
# _biome_pallete_data[y_idx] = new_pallete.keys()
# if new_pallete.size() == 1:
# _biome_data[y_idx] = new_pallete.keys()[0]
# _biome_palette_data[y_idx] = new_palette.keys()
# if new_palette.size() == 1:
# _biome_data[y_idx] = new_palette.keys()[0]
6 changes: 3 additions & 3 deletions app/nbt_parser.gd
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ class BaseTag extends Reference:
tag_id = id

func to_json() -> Dictionary:
printerr("to_json() needs to be overriden!")
printerr("to_json() needs to be overridden!")
return { "type": tag_id }

# warning-ignore:unused_argument
func write(stream: StreamPeer) -> void:
printerr("write() needs to be overriden!")
printerr("write() needs to be overridden!")

func duplicate() -> BaseTag:
printerr("duplicate() needs to be overriden!")
printerr("duplicate() needs to be overridden!")
return null

static func _read_string(stream: StreamPeer) -> String:
Expand Down
10 changes: 5 additions & 5 deletions app/world_processor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@ func check_for_changes(world: MCWorld) -> Dictionary:

var change := {}
var biomes: Array = result.biomes
var pallete: Array = result.pallete
var palette: Array = result.palette

var palleteMap := { 0: -1 }
for i in pallete.size():
palleteMap[i + 1] = pallete[i]
var paletteMap := { 0: -1 }
for i in palette.size():
paletteMap[i + 1] = palette[i]

for loc in 4096:
loc = int(loc)
var idx: int = biomes[loc]
var biome: int = palleteMap[idx]
var biome: int = paletteMap[idx]
if biome >= 0:
var loc_array := Vector3(loc % 16, int(floor(loc / 16)) % 16, int(floor(loc / 256)) % 16)
change[loc_array] = biome
Expand Down
2 changes: 1 addition & 1 deletion src/library/classes/commandBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class CommandBuilder {
return commands;
}
/**
* Get all the registered informations
* Get a list of all registered information
* @returns {Array<storedRegisterInformation>}
* @example getAllRegistration();
*/
Expand Down
8 changes: 4 additions & 4 deletions src/library/classes/eventEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ export const EventEmitter: EventEmitterConstructor = class Class implements Even
* @private
* @param {string} eventName Event type to listen for
* @param {Function} listener Function to callback on fire
* @param {boolean} [once] Wheather to listen for the event only ONCE or not
* @param {boolean} [prepand] Insert the Event in the beginning of the Array, so it executes first
* @param {boolean} [once] Whether to listen for the event only ONCE or not
* @param {boolean} [prepend] Insert the Event in the beginning of the Array, so it executes first
*/
private _addListener(eventName: string, listener: (...args: any[]) => void, once?: boolean, prepand?: boolean): void {
private _addListener(eventName: string, listener: (...args: any[]) => void, once?: boolean, prepend?: boolean): void {
const listenerCount = this.listenerCount(eventName);
if(listenerCount >= this._configurations.maxListeners) throw `Warning: Possible EventEmitter memory leak detected. ${listenerCount + 1} ${eventName} listeners added. Use emitter.setMaxListeners(n) to increase limit`;
const data = {
Expand All @@ -24,7 +24,7 @@ export const EventEmitter: EventEmitterConstructor = class Class implements Even
once,
executed: false
};
if(prepand) this._listeners.unshift(data);
if(prepend) this._listeners.unshift(data);
else this._listeners.push(data);
}

Expand Down
2 changes: 1 addition & 1 deletion src/library/utils/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function MS(value: StringValue | number, { compactDuration, fullDuration,
} catch(err) {
const message = isError(err)
? `${err.message}. Value = ${JSON.stringify(value)}`
: "An unknown error has occured.";
: "An unknown error has occurred.";
throw new Error(message);
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/server/modules/biome_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,27 +95,27 @@ class BiomeChanges {
biomes.length = 4096;
biomes = biomes.fill(-1);
} else {
const pallete: number[] = database.get("pallete");
biomes = (database.get("biomes") as number[]).map(idx => idx ? pallete[idx - 1] : -1);
const palette: number[] = database.get("palette");
biomes = (database.get("biomes") as number[]).map(idx => idx ? palette[idx - 1] : -1);
}

for (const [loc, biome] of data.entries()) {
biomes[loc] = biome;
}

const palleteMap = new Map<number, number>();
const paletteMap = new Map<number, number>();
for (const biome of biomes) {
if (biome >= 0) {
palleteMap.set(biome, null);
paletteMap.set(biome, null);
}
}
const newPallete = Array.from(palleteMap.keys());
palleteMap.clear();
newPallete.forEach((val, idx) => palleteMap.set(val, idx + 1));
palleteMap.set(-1, 0);
const newPalette = Array.from(paletteMap.keys());
paletteMap.clear();
newPalette.forEach((val, idx) => paletteMap.set(val, idx + 1));
paletteMap.set(-1, 0);

database.set("biomes", biomes.map(biome => palleteMap.get(biome)));
database.set("pallete", newPallete);
database.set("biomes", biomes.map(biome => paletteMap.get(biome)));
database.set("palette", newPalette);

database.save();
}
Expand Down
6 changes: 3 additions & 3 deletions src/server/modules/extern/resource_pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { TicksPerSecond } from "@minecraft/server";
import { setTickTimeout, clearTickTimeout } from "@notbeer-api";
import { EventEmitterTypes } from "library/@types/classes/eventEmitter";

// Auxilary declarations
// Auxiliary declarations

function* idGenerator(): Generator<number, number> {
let id = 0;
Expand Down Expand Up @@ -134,7 +134,7 @@ class ResourcePool<T extends PooledResource> {
try {
obj.close();
} catch (err) {
this.log(0, "error calling resourse close method:", err);
this.log(0, "error calling resource close method:", err);
}

this.deleteFromBusy(obj);
Expand Down Expand Up @@ -167,7 +167,7 @@ class ResourcePool<T extends PooledResource> {
try {
obj.close();
} catch (err) {
this.log(0, "error calling resourse close method:", err);
this.log(0, "error calling resource close method:", err);
}

this.deleteFromBusy(obj);
Expand Down
10 changes: 5 additions & 5 deletions src/server/modules/region_buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export class RegionBuffer {
if (shouldTransform) {
transform = block => {
const blockName = block.type.id;
const attachement = block.getState("attachement") as string;
const attachment = block.getState("attachment") as string;
const direction = block.getState("direction") as number;
const doorHingeBit = block.getState("door_hinge_bit") as boolean;
const facingDir = block.getState("facing_direction") as number;
Expand Down Expand Up @@ -168,9 +168,9 @@ export class RegionBuffer {
} else if (doorHingeBit != null && direction != null) {
const states = (this.transformMapping(mappings.doorMap, `${doorHingeBit}_${direction}`, ...rotFlip) as string).split("_");
block = withProperties({ "door_hinge_bit": states[0] == "true", "direction": parseInt(states[1]) });
} else if (attachement != null && direction != null) {
const states = (this.transformMapping(mappings.bellMap, `${attachement}_${direction}`, ...rotFlip) as string).split("_");
block = withProperties({ "attachement": states[0], "direction": parseInt(states[1]) });
} else if (attachment != null && direction != null) {
const states = (this.transformMapping(mappings.bellMap, `${attachment}_${direction}`, ...rotFlip) as string).split("_");
block = withProperties({ "attachment": states[0], "direction": parseInt(states[1]) });
} else if (cardinalDir != null) {
const state = this.transformMapping(mappings.cardinalDirectionMap, cardinalDir, ...rotFlip);
block = block.withState("minecraft:cardinal_direction", state);
Expand Down Expand Up @@ -545,7 +545,7 @@ const mappings = {
true_2: new Vector(-1, 0, 0.5),
true_3: new Vector(-0.5, 0,-1)
},
bellMap: { // attachement - direction
bellMap: { // attachment - direction
standing_0: new Vector( 1, 0.5, 0),
standing_1: new Vector( 0, 0.5, 1),
standing_2: new Vector(-1, 0.5, 0),
Expand Down
Loading
Loading