Skip to content

Commit

Permalink
Version 1.5 - 1.19.60 Patch
Browse files Browse the repository at this point in the history
  • Loading branch information
PavelDobCZ23 authored Feb 8, 2023
1 parent 7f1b4f9 commit 505d3af
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 36 deletions.
12 changes: 3 additions & 9 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,16 @@
"description": "Make sure to move or else... you'll die! §9Made by PavelDobCZ23",
"name": "Don't Stop Moving",
"uuid": "e8720e7a-a0ba-4f1f-a085-1e3f1bef6ec4",
"version": [ 1, 4, 0 ],
"min_engine_version": [ 1, 19, 50 ]
"version": [ 1, 5, 0 ],
"min_engine_version": [ 1, 19, 60 ]
},
"modules": [
{
"description": "Don't Stop Moving [BP] - data module",
"type": "data",
"uuid": "7023c32d-c8e3-47d4-b14e-15dc01bf155e",
"version": [1, 4, 0]
},
{
"description": "Don't Stop Moving [BP] - script module",
"type": "script",
"language": "javascript",
"uuid": "039ce6f0-df97-488d-8633-f231b5ea234a",
"version": [1, 4, 0],
"version": [1, 5, 0],
"entry": "scripts/main.js"
}
],
Expand Down
56 changes: 29 additions & 27 deletions scripts/main.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
import {world,system} from "@minecraft/server";
import {timer} from "./modules/addon_options.js";
var playerMovement = {};
const playerMovement = {};

function randInt(min, max) {
max++;
return Math.floor(Math.random() * (max - min)) + min;
return Math.floor(Math.random() * (max - min + 1)) + min;
}

async function tickEvent(eventData) {
system.run(tickEvent);
if (eventData.currentTick % 5 === 0) {
for (const player of world.getPlayers()) {
if (player.id in playerMovement) {
const velocity = player.velocity.x + player.velocity.z;
if ((-0.001 < velocity) && (velocity < 0.001) || playerMovement[player.id] < 0) {
if (playerMovement[player.id] === timer && eventData.currentTick % 20 === 0) {
try {
await player.runCommandAsync('damage @s 2');
} catch {}
}
playerMovement[player.id] = Math.min(timer, playerMovement[player.id] + randInt(2,10));
} else if (playerMovement[player.id] >= 0) {
playerMovement[player.id] = Math.max(0, playerMovement[player.id] - randInt(1,5));
}
if (player.getComponent('minecraft:health').current === 0) {
playerMovement[player.id] = -20;
}
} else {
playerMovement[player.id] = -275;
}
}
//Calculate movement:
system.runSchedule(playerMovementTick,5);

//Deal Damage:
system.runSchedule(playerDamageTick,20);

function playerDamageTick() {
for (const player of world.getPlayers()) {
console.warn(`${player.name} [${playerMovement[player.id]}] - Damage`);
if (playerMovement[player.id] === timer) player.applyDamage(2);
}
}

system.run(tickEvent);
function playerMovementTick() {
for (const player of world.getPlayers()) {
if (player.id in playerMovement) {
const velocity = player.velocity.x + player.velocity.z;
if ((-0.001 < velocity) && (velocity < 0.001) || playerMovement[player.id] < 0) {
playerMovement[player.id] = Math.min(timer, playerMovement[player.id] + randInt(2,10));
} else if (playerMovement[player.id] >= 0) {
playerMovement[player.id] = Math.max(0, playerMovement[player.id] - randInt(1,5));
}
if (player.getComponent('minecraft:health').current === 0) {
playerMovement[player.id] = -45;
}
} else {
playerMovement[player.id] = -275;
}
}
}

0 comments on commit 505d3af

Please sign in to comment.