Skip to content

Commit

Permalink
0.9 (#226)
Browse files Browse the repository at this point in the history
* Improved line tool

* Condensed selection tools into one with a menu

* Added more gen tools and a gen menu

* Corrected permission string

* Added pyramid shape

* Made particles only seen by those using them

* Bumbed version
  • Loading branch information
SIsilicon authored Jan 6, 2024
1 parent d45436b commit 017125c
Show file tree
Hide file tree
Showing 40 changed files with 790 additions and 242 deletions.
16 changes: 16 additions & 0 deletions BP/items/buttons/draw_cylinder.item.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"format_version": "1.20.10",
"minecraft:item": {
"description": {
"identifier": "wedit:draw_cylinder",
"category": "commands"
},
"components": {
"minecraft:icon": {
"texture": "draw_cylinder"
},
"minecraft:max_stack_size": 1,
"minecraft:throwable": {}
}
}
}
16 changes: 16 additions & 0 deletions BP/items/buttons/draw_pyramid.item.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"format_version": "1.20.10",
"minecraft:item": {
"description": {
"identifier": "wedit:draw_pyramid",
"category": "commands"
},
"components": {
"minecraft:icon": {
"texture": "draw_pyramid"
},
"minecraft:max_stack_size": 1,
"minecraft:throwable": {}
}
}
}
16 changes: 16 additions & 0 deletions BP/items/buttons/draw_sphere.item.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"format_version": "1.20.10",
"minecraft:item": {
"description": {
"identifier": "wedit:draw_sphere",
"category": "commands"
},
"components": {
"minecraft:icon": {
"texture": "draw_sphere"
},
"minecraft:max_stack_size": 1,
"minecraft:throwable": {}
}
}
}
16 changes: 16 additions & 0 deletions BP/items/buttons/selection_hollow.item.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"format_version": "1.20.10",
"minecraft:item": {
"description": {
"identifier": "wedit:selection_hollow",
"category": "commands"
},
"components": {
"minecraft:icon": {
"texture": "selection_hollow"
},
"minecraft:max_stack_size": 1,
"minecraft:throwable": {}
}
}
}
9 changes: 9 additions & 0 deletions RP/textures/item_texture.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@
"draw_line": {
"textures": "textures/items/draw_line"
},
"draw_sphere": {
"textures": "textures/items/draw_sphere"
},
"draw_cylinder": {
"textures": "textures/items/draw_cylinder"
},
"draw_pyramid": {
"textures": "textures/items/draw_pyramid"
},
"config": {
"textures": "textures/ui/gear"
},
Expand Down
Binary file added RP/textures/items/draw_cylinder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added RP/textures/items/draw_pyramid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added RP/textures/items/draw_sphere.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 6 additions & 5 deletions mc_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
"bp_name": "WorldEdit Bedrock Edition",
"rp_name": "WorldEdit Bedrock Edition [RES]",

"description": "pack.description",
"description": "pack.description",

"bp_uuid": "3cdb2ddf-662e-4f8f-a0a1-1293b91ccb2f",
"bp_uuid": "3cdb2ddf-662e-4f8f-a0a1-1293b91ccb2f",
"rp_uuid": "e304a4eb-f0a0-4979-ac17-7b0f46a555c8",
"version": [0, 8, 4],
"min_engine_version": [ 1, 20, 50 ]

"version": [0, 9, 0, 1],
"min_engine_version": [ 1, 20, 60 ]
},
"bp_modules": [
{
Expand Down Expand Up @@ -38,7 +39,7 @@
"bp_dependencies": [
{
"module_name": "@minecraft/server",
"version": "1.8.0-beta"
"version": "1.9.0-beta"
},
{
"module_name": "@minecraft/server-ui",
Expand Down
76 changes: 41 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"typescript": "^4.7.4"
},
"dependencies": {
"@minecraft/server": "^1.8.0-beta.1.20.50-preview.23",
"@minecraft/server": "^1.9.0-beta.1.20.60-preview.22",
"@minecraft/server-admin": "^1.0.0-beta.1.19.80-stable",
"@minecraft/server-ui": "^1.2.0-beta.1.20.50-preview.23"
"@minecraft/server-ui": "^1.2.0-beta.1.20.60-preview.22"
}
}
2 changes: 0 additions & 2 deletions src/library/@types/Events.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
ChatSendBeforeEvent,
ExplosionBeforeEvent,
PistonActivateBeforeEvent,
BlockExplodeAfterEvent,
ItemUseBeforeEvent,
ItemUseOnBeforeEvent,
Expand All @@ -23,7 +22,6 @@ import { registerInformation } from "./classes/CommandBuilder";
export interface EventList {
beforeMessage: [ChatSendBeforeEvent],
beforeExplosion: [ExplosionBeforeEvent],
beforePistonActivate: [PistonActivateBeforeEvent],
blockExplode: [BlockExplodeAfterEvent],
messageCreate: [ChatSendAfterEvent],
itemUseBefore: [ItemUseBeforeEvent],
Expand Down
2 changes: 1 addition & 1 deletion src/library/@types/classes/uiFormBuilder.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ interface BaseForm<T extends {}> {
/** The title of the UI form */
title: DynamicElem<T, string>,
/** Action to perform when the user exits or cancels the form */
cancel: UIAction<T, void>
cancel?: UIAction<T, void>
}

/** A form with a message and one or two options */
Expand Down
7 changes: 1 addition & 6 deletions src/library/Minecraft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ class ServerBuild extends ServerBuilder {
* Emit to 'beforeExplosion' event listener
*/
beforeEvents.explosion.subscribe(data => this.emit("beforeExplosion", data));
/**
* Emit to 'beforePistonActivate' event listener
*/
beforeEvents.pistonActivate.subscribe(data => this.emit("beforePistonActivate", data));
/**
* Emit to 'blockExplode' event listener
*/
Expand All @@ -95,8 +91,7 @@ class ServerBuild extends ServerBuilder {
/**
* Emit to 'pistonActivate' event listener
*/
beforeEvents.pistonActivate.subscribe(data => this.emit("pistonActivate", data));

afterEvents.pistonActivate.subscribe(data => this.emit("pistonActivate", data));
/**
* Emit to 'itemUse' event listener
*/
Expand Down
8 changes: 8 additions & 0 deletions src/library/classes/playerBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ export class PlayerBuilder {
getInventory(player: Player) {
return (player.getComponent("minecraft:inventory") as Minecraft.EntityInventoryComponent).container;
}
/**
* Get the player's equipment component
* @param {Player} [player] Player of interest
* @returns {Minecraft.EntityEquippableComponent}
*/
getEquipment(player: Player) {
return (player.getComponent("minecraft:equippable") as Minecraft.EntityEquippableComponent);
}
/**
* Get the amount on a specific items player(s) has
* @param {Player} [player] Player you are searching
Expand Down
6 changes: 3 additions & 3 deletions src/library/classes/uiFormBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { setTickTimeout, contentLog } from "@notbeer-api";

abstract class UIForm<T extends {}> {
private readonly form: Form<T>;
protected readonly cancelAction: UIAction<T, void>;
protected readonly cancelAction?: UIAction<T, void>;

constructor(form: Form<T>) {
this.form = form;
Expand All @@ -26,7 +26,7 @@ abstract class UIForm<T extends {}> {
setTickTimeout(() => this.enter(player, ctx));
} else {
ctx.goto(null);
this.cancelAction(ctx, player);
this.cancelAction?.(ctx, player);
}
return true;
}
Expand Down Expand Up @@ -247,7 +247,7 @@ class UIFormBuilder {
return true;
}
const ctx = new MenuContext<T>(player);
Object.entries(data).forEach(e => ctx.setData(e[0] as keyof T, e[1] as typeof data[keyof T]));
Object.entries(data ?? {}).forEach(e => ctx.setData(e[0] as keyof T, e[1] as typeof data[keyof T]));
ctx.goto(name);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/library/utils/vector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class Vector {
}

get length() {
return Math.sqrt(this.x*this.x + this.y*this.y + this.z*this.z);
return Math.hypot(this.x, this.y, this.z);
}

set length(val: number) {
Expand Down
5 changes: 1 addition & 4 deletions src/server/commands/region/hollow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,8 @@ function* hollow(session: PlayerSession, pattern: Pattern, thickness: number): G
registerCommand(registerInformation, function* (session, builder, args) {
assertSelection(session);
assertCanBuildWithin(builder, ...session.selection.getRange());
if (args.get("_using_item") && session.globalPattern.empty()) {
throw RawText.translate("worldEdit.selectionFill.noPattern");
}

const pattern: Pattern = args.get("_using_item") ? session.globalPattern : args.get("pattern");
const pattern: Pattern = args.get("pattern");
const thickness = args.get("thickness") as number;

const job = Jobs.startJob(session, 3, session.selection.getRange());
Expand Down
4 changes: 2 additions & 2 deletions src/server/commands/region/line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const registerInformation = {
]
};

function* bresenham3d(p1: Vector, p2: Vector): Generator<void, Vector[]> {
export function* generateLine(p1: Vector, p2: Vector): Generator<void, Vector[]> {
const pointList: Vector[] = [];
pointList.push(p1.clone());
const d = p2.sub(p1).abs();
Expand Down Expand Up @@ -118,7 +118,7 @@ registerCommand(registerInformation, function* (session, builder, args) {
const record = history.record();
let count: number;
try {
const points = (yield* bresenham3d(Vector.from(pos1), Vector.from(pos2))).map(p => p.floor());
const points = (yield* generateLine(Vector.from(pos1), Vector.from(pos2))).map(p => p.floor());
history.addUndoStructure(record, start, end);
count = 0;
for (const point of points) {
Expand Down
2 changes: 1 addition & 1 deletion src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { PlayerUtil } from "@modules/player_util.js";
import config from "config.js";

import "./commands/command_list.js";
import "./tools/register_tools.js";
import "./tools/tool_list.js";
import "./ui/index.js";

Server.setMaxListeners(256);
Expand Down
4 changes: 2 additions & 2 deletions src/server/modules/biome_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,10 @@ class BiomeDetector extends EventEmitter implements PooledResource {
this.emit(errorEventSym);
reject(err);
} finally {
world.afterEvents.dataDrivenEntityTriggerEvent.unsubscribe(onEvent);
world.afterEvents.dataDrivenEntityTrigger.unsubscribe(onEvent);
}
};
world.afterEvents.dataDrivenEntityTriggerEvent.subscribe(onEvent, {
world.afterEvents.dataDrivenEntityTrigger.subscribe(onEvent, {
entities: [this.entity],
eventTypes: ["wedit:biome_update"]
});
Expand Down
Loading

0 comments on commit 017125c

Please sign in to comment.