start flexible movement
This commit is contained in:
@@ -70,6 +70,7 @@ Need help, want to discuss technical Minecraft, or follow future updates? [**Joi
|
|||||||
- [x] Correct block placement checking
|
- [x] Correct block placement checking
|
||||||
- [x] Automatic material gathering from inventories
|
- [x] Automatic material gathering from inventories
|
||||||
- [x] Material list
|
- [x] Material list
|
||||||
|
- [ ] Flexible structure movement
|
||||||
- [ ] Block texture display
|
- [ ] Block texture display
|
||||||
|
|
||||||
## Issues & Suggestions
|
## Issues & Suggestions
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export const InstanceButtons = Object.freeze({
|
|||||||
NextLayer: 'Increase Layer',
|
NextLayer: 'Increase Layer',
|
||||||
PreviousLayer: 'Decrease Layer',
|
PreviousLayer: 'Decrease Layer',
|
||||||
Move: 'Move Here',
|
Move: 'Move Here',
|
||||||
|
FlexibleMove: 'Flexible Move',
|
||||||
Statistics: 'Statistics',
|
Statistics: 'Statistics',
|
||||||
Settings: 'Settings',
|
Settings: 'Settings',
|
||||||
Materials: 'Material List'
|
Materials: 'Material List'
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
export class FlexibleInstanceMove {
|
||||||
|
player;
|
||||||
|
instance;
|
||||||
|
|
||||||
|
constructor(instance, player) {
|
||||||
|
this.instance = instance;
|
||||||
|
this.player = player;
|
||||||
|
this.tryBeginFlexibleMove();
|
||||||
|
}
|
||||||
|
|
||||||
|
tryBeginFlexibleMove() {
|
||||||
|
if (this.instance.isFlexMoving) {
|
||||||
|
this.feedback('§cThis instance is already being moved.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.beginFlexibleMove();
|
||||||
|
}
|
||||||
|
|
||||||
|
beginFlexibleMove() {
|
||||||
|
// place structure in movement mode
|
||||||
|
this.instance.startFlexibleMove(this.player);
|
||||||
|
// lock player controls
|
||||||
|
// start handling player movement controls
|
||||||
|
}
|
||||||
|
|
||||||
|
endFlexibleMove() {
|
||||||
|
this.instance.stopFlexibleMove();
|
||||||
|
}
|
||||||
|
|
||||||
|
feedback(str) {
|
||||||
|
this.player.sendMessage(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if the player logs out, stop the move
|
||||||
@@ -4,6 +4,7 @@ import { forceShow } from '../../utils';
|
|||||||
import { InstanceButtons } from '../Enums/InstanceButtons';
|
import { InstanceButtons } from '../Enums/InstanceButtons';
|
||||||
import { InstanceFormBuilder } from './InstanceFormBuilder';
|
import { InstanceFormBuilder } from './InstanceFormBuilder';
|
||||||
import { FormCancelationReason } from '@minecraft/server-ui';
|
import { FormCancelationReason } from '@minecraft/server-ui';
|
||||||
|
import { FlexibleInstanceMove } from './FlexibleInstanceMove';
|
||||||
|
|
||||||
export class InstanceForm {
|
export class InstanceForm {
|
||||||
instanceName;
|
instanceName;
|
||||||
@@ -94,6 +95,9 @@ export class InstanceForm {
|
|||||||
case InstanceButtons.Move:
|
case InstanceButtons.Move:
|
||||||
this.instance.move(this.player.dimension.id, this.player.location);
|
this.instance.move(this.player.dimension.id, this.player.location);
|
||||||
break;
|
break;
|
||||||
|
case InstanceButtons.FlexibleMove:
|
||||||
|
new FlexibleInstanceMove(this.instance, this.player);
|
||||||
|
break;
|
||||||
case InstanceButtons.Settings:
|
case InstanceButtons.Settings:
|
||||||
this.settingsForm();
|
this.settingsForm();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ export class StructureInstance {
|
|||||||
verifier = void 0;
|
verifier = void 0;
|
||||||
verificationRenderer = void 0;
|
verificationRenderer = void 0;
|
||||||
materials = void 0;
|
materials = void 0;
|
||||||
|
flexMovingPlayerId = void 0;
|
||||||
|
|
||||||
constructor(instanceName, structureId) {
|
constructor(instanceName, structureId) {
|
||||||
this.structure = new Structure(structureId);
|
this.structure = new Structure(structureId);
|
||||||
@@ -245,6 +246,23 @@ export class StructureInstance {
|
|||||||
this.setLayer(this.options.currentLayer - 1);
|
this.setLayer(this.options.currentLayer - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
startFlexibleMove(player) {
|
||||||
|
this.flexMovingPlayerId = player.id;
|
||||||
|
this.disable();
|
||||||
|
// create flex movement outliner
|
||||||
|
}
|
||||||
|
|
||||||
|
stopFlexibleMove(finalLocation) {
|
||||||
|
// disable flex movement outliner
|
||||||
|
this.move(this.getDimension(), finalLocation);
|
||||||
|
this.enable();
|
||||||
|
this.flexMovingPlayerId = void 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
isFlexibleMoving() {
|
||||||
|
return this.flexMovingPlayerId !== void 0;
|
||||||
|
}
|
||||||
|
|
||||||
disableInstanceWhenNoPlayersOnline() {
|
disableInstanceWhenNoPlayersOnline() {
|
||||||
// This prevents a memory leak when no players are online.
|
// This prevents a memory leak when no players are online.
|
||||||
world.beforeEvents.playerLeave.subscribe(event => {
|
world.beforeEvents.playerLeave.subscribe(event => {
|
||||||
|
|||||||
Reference in New Issue
Block a user