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

Updates for Minecraft release 1.21.44 #83

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions dye-brush/dye-brush.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import {
ActionTypes,
ColorPickerPropertyItemVariant,
CursorProperties,
CursorTargetMode,
IDropdownItem,
IModalTool,
Expand Down Expand Up @@ -139,7 +138,6 @@ interface DyeBrushStorage {
currentColor: EntityColor;
brushColor: IObservable<RGBA>;
brushSize: number;
backedUpCursorProps: CursorProperties | undefined;
}

type DyeBrushSession = IPlayerUISession<DyeBrushStorage>;
Expand All @@ -164,11 +162,12 @@ function addDyeBrushPane(uiSession: DyeBrushSession, tool: IModalTool) {

const pane = uiSession.createPropertyPane({
title: 'sample.dyeBrush.pane.title',
infoTooltip: { description: ['sample.dyebrush.tool.tooltip'] },
});

const entityBrush = makeObservable(EntityColor.White);

onColorUpdated(brushColor.value, uiSession);

pane.addDropdown(entityBrush, {
title: 'Brush',
entries: Object.values(EntityColor).reduce<IDropdownItem[]>((list, dye, index) => {
Expand Down Expand Up @@ -313,15 +312,7 @@ function addDyeBrushPane(uiSession: DyeBrushSession, tool: IModalTool) {

tool.onModalToolActivation.subscribe((evt: ModalToolLifecycleEventPayload) => {
if (evt.isActiveTool) {
if (uiSession.scratchStorage && !uiSession.scratchStorage.backedUpCursorProps) {
uiSession.scratchStorage.backedUpCursorProps = uiSession.extensionContext.cursor.getProperties();
}
onColorUpdated(brushColor.value, uiSession);
} else {
if (uiSession.scratchStorage && uiSession.scratchStorage.backedUpCursorProps) {
uiSession.extensionContext.cursor.setProperties(uiSession.scratchStorage.backedUpCursorProps);
uiSession.scratchStorage.backedUpCursorProps = undefined;
}
}
uiSession.scratchStorage?.previewSelection?.clear();
});
Expand All @@ -330,7 +321,7 @@ function addDyeBrushPane(uiSession: DyeBrushSession, tool: IModalTool) {
}

export function addDyeBrushTool(uiSession: DyeBrushSession) {
const tool = uiSession.toolRail.addTool('editorSample:dyeBrushTool', {
const tool = uiSession.toolRail.addTool({
title: 'sample.dyebrush.tool.title',
tooltip: 'sample.dyebrush.tool.tooltip',
icon: 'pack://textures/dye-brush.png',
Expand All @@ -354,7 +345,6 @@ export function registerDyeBrushExtension() {
currentColor: EntityColor.White,
brushColor: makeObservable<RGBA>({ red: 1, green: 1, blue: 1, alpha: 0.5 }),
brushSize: 4,
backedUpCursorProps: undefined,
};
uiSession.scratchStorage = storage;

Expand Down
Binary file modified editor-samples.mceditoraddon
Binary file not shown.
22 changes: 10 additions & 12 deletions farm-generator/farm-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,6 @@ const buildFarm = (
function addFarmGeneratorSettingsPane(uiSession: IPlayerUISession, tool: IModalTool) {
const windowPane = uiSession.createPropertyPane({
title: 'sample.farmgenerator.pane.title',
infoTooltip: {
description: [
'sample.farmgenerator.tool.tooltip',
{ link: 'https://aka.ms/BedrockEditorFarmGenerator', text: 'resourcePack.editor.help.learnMore' },
],
},
});
const cropPane = windowPane.createSubPane({
title: 'sample.farmgenerator.pane.crops.title',
Expand Down Expand Up @@ -387,12 +381,16 @@ function addFarmGeneratorTool(uiSession: IPlayerUISession) {
},
});

const tool = uiSession.toolRail.addTool('editorSample:farmTool', {
title: 'sample.farmgenerator.tool.title',
icon: 'pack://textures/farm-generator.png',
tooltip: 'sample.farmgenerator.tool.tooltip',
action: toolToggleAction,
});
const tool = uiSession.toolRail.addTool(
{
title: 'sample.farmgenerator.tool.title',
icon: 'pack://textures/farm-generator.png',
tooltip: 'sample.farmgenerator.tool.tooltip',
inputContextId: 'editorSamples:farmGenerator',
inputContextLabel: 'sample.farmgenerator.tool.title',
},
toolToggleAction
);

// Register a global shortcut (CTRL + SHIFT + P) to select the tool
uiSession.inputManager.registerKeyBinding(
Expand Down
5 changes: 2 additions & 3 deletions goto-mark/goto-mark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
IObservable,
IPlayerUISession,
IPropertyPane,
IRootPropertyPane,
UserDefinedTransactionHandle,
bindDataSource,
makeObservable,
Expand Down Expand Up @@ -117,15 +116,15 @@ function teleportTo(uiSession: IPlayerUISession<ExtensionStorage>, destination:

// Add the extension to the tool rail and give it an icon
function addExtensionTool(uiSession: IPlayerUISession<ExtensionStorage>): IModalTool {
const tool = uiSession.toolRail.addTool('editorSample:goToMarkTool', {
const tool = uiSession.toolRail.addTool({
title: 'sample.gotomark.tool.title',
icon: 'pack://textures/goto-mark.png',
tooltip: 'Set or Jump to a stored location',
});
return tool;
}

function buildParentPane(uiSession: IPlayerUISession<ExtensionStorage>, storage: ExtensionStorage): IRootPropertyPane {
function buildParentPane(uiSession: IPlayerUISession<ExtensionStorage>, storage: ExtensionStorage): IPropertyPane {
const parentPane = uiSession.createPropertyPane({
title: 'sample.gotomark.pane.title',
});
Expand Down
19 changes: 10 additions & 9 deletions portal-generator/portal-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
IDisposable,
ImageResourceType,
IObservable,
IRootPropertyPane,
makeObservable,
NumberPropertyItemVariant,
Ray,
Expand Down Expand Up @@ -64,7 +63,7 @@ class PortalGenerator implements IDisposable {
private _endPortal: EndPortal;
private _activePortal?: IPortalGenerator;

private _pane?: IRootPropertyPane;
private _pane?: IPropertyPane;
private _settings: PaneSettingsType = {
portalType: makeObservable<number>(PortalType.Nether),
shouldReplaceFloor: makeObservable(true),
Expand All @@ -75,7 +74,7 @@ class PortalGenerator implements IDisposable {
this._endPortal = new EndPortal();
}

public toolPane(uiSession: PortalGeneratorSession): IRootPropertyPane | undefined {
public toolPane(uiSession: PortalGeneratorSession): IPropertyPane | undefined {
if (!this._pane) {
uiSession.log.error('Tool pane not initialized');
return undefined;
Expand All @@ -93,12 +92,14 @@ class PortalGenerator implements IDisposable {
});

// Add the extension to the tool rail and give it an icon
const tool = uiSession.toolRail.addTool('editorSample:portalTool', {
title: 'sample.portalgenerator.title',
icon: 'pack://textures/portal-generator.png',
tooltip: 'sample.portalgenerator.tooltip',
action: toolToggleAction,
});
const tool = uiSession.toolRail.addTool(
{
title: 'sample.portalgenerator.title',
icon: 'pack://textures/portal-generator.png',
tooltip: 'sample.portalgenerator.tooltip',
},
toolToggleAction
);

// Register a global shortcut (CTRL + SHIFT + P) to select the tool
uiSession.inputManager.registerKeyBinding(
Expand Down
1 change: 0 additions & 1 deletion simple-empty/SimpleEmptyTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ export class SimpleEmptyTool extends SimpleToolWrapper {
// additional components as needed (in this case, a status bar, a tool rail, and a property pane)
// YOu can also specify an activation key binding and some functions to be called during the lifecycle of the tool
const options: ISimpleToolOptions = {
id: 'sample:simpleEmptyTool',
name: 'Simple Empty Tool',
onFinalize: tool => {
tool.logDebug('onFinalize(ISimpleTool)');
Expand Down
1 change: 0 additions & 1 deletion simple-locate/SimpleLocateBiome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ export class SimpleLocate extends SimpleToolWrapper {
super();

const toolOptions: ISimpleToolOptions = {
id: 'editor:simpleLocateBiome',
name: 'Simple Locate Biome',
activationKeyBinding: {
binding: {
Expand Down
64 changes: 28 additions & 36 deletions tree-generator/tree-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,62 +220,50 @@ export class SimpleTree implements ITree {
}
}

function createLeaf1Block(leafType: string): BlockPermutation {
return BlockPermutation.resolve(MinecraftBlockTypes.Leaves, {
old_leaf_type: leafType,
});
}

function createLeaf2Block(leafType: string): BlockPermutation {
return BlockPermutation.resolve(MinecraftBlockTypes.Leaves2, {
new_leaf_type: leafType,
});
}

const TreeTypes = [
{
name: 'Oak',
type: new SimpleTree(
BlockPermutation.resolve(MinecraftBlockTypes.OakLog),
BlockPermutation.resolve(MinecraftBlockTypes.OakLeaves)
),
type: new SimpleTree(BlockPermutation.resolve(MinecraftBlockTypes.OakLog), createLeaf1Block('oak')),
},
{
name: 'Spruce',
type: new SimpleTree(
BlockPermutation.resolve(MinecraftBlockTypes.SpruceLog),
BlockPermutation.resolve(MinecraftBlockTypes.SpruceLeaves)
),
type: new SimpleTree(BlockPermutation.resolve(MinecraftBlockTypes.SpruceLog), createLeaf1Block('spruce')),
},
{
name: 'Birch',
type: new SimpleTree(
BlockPermutation.resolve(MinecraftBlockTypes.BirchLog),
BlockPermutation.resolve(MinecraftBlockTypes.BirchLeaves)
),
type: new SimpleTree(BlockPermutation.resolve(MinecraftBlockTypes.BirchLog), createLeaf1Block('birch')),
},
{
name: 'Jungle',
type: new SimpleTree(
BlockPermutation.resolve(MinecraftBlockTypes.JungleLog),
BlockPermutation.resolve(MinecraftBlockTypes.JungleLeaves)
),
type: new SimpleTree(BlockPermutation.resolve(MinecraftBlockTypes.JungleLog), createLeaf1Block('jungle')),
},

{
name: 'Acacia',
type: new SimpleTree(
BlockPermutation.resolve(MinecraftBlockTypes.AcaciaLog),
BlockPermutation.resolve(MinecraftBlockTypes.AcaciaLeaves)
),
type: new SimpleTree(BlockPermutation.resolve(MinecraftBlockTypes.AcaciaLog), createLeaf2Block('acacia')),
},
{
name: 'Dark Oak',
type: new SimpleTree(
BlockPermutation.resolve(MinecraftBlockTypes.DarkOakLog),
BlockPermutation.resolve(MinecraftBlockTypes.DarkOakLeaves)
),
type: new SimpleTree(BlockPermutation.resolve(MinecraftBlockTypes.DarkOakLog), createLeaf2Block('dark_oak')),
},
];

function addToolSettingsPane(uiSession: IPlayerUISession, tool: IModalTool) {
// Create a pane that will be shown when the tool is selected
const pane = uiSession.createPropertyPane({
title: 'sample.treegenerator.pane.title',
infoTooltip: {
description: [
'sample.treegenerator.tool.tooltip',
{ link: 'https://aka.ms/BedrockEditorTreeGenerator', text: 'resourcePack.editor.help.learnMore' },
],
},
});

// Settings
Expand Down Expand Up @@ -408,12 +396,16 @@ function addTool(uiSession: IPlayerUISession) {
},
});

const tool = uiSession.toolRail.addTool('editorSample:treeGeneratorTool', {
title: 'sample.treegenerator.tool.title',
icon: 'pack://textures/tree-generator.png',
tooltip: 'sample.treegenerator.tool.tooltip',
action: toolToggleAction,
});
const tool = uiSession.toolRail.addTool(
{
title: 'sample.treegenerator.tool.title',
icon: 'pack://textures/tree-generator.png',
tooltip: 'sample.treegenerator.tool.tooltip',
inputContextId: 'editorSamples:treeGenerator',
inputContextLabel: 'sample.treegenerator.tool.title',
},
toolToggleAction
);

// Register a global shortcut to select the tool
uiSession.inputManager.registerKeyBinding(
Expand Down