Skip to content

Commit 462afb6

Browse files
authored
Updated the scripts to work in 1.20.10.20 (JaylyDev#246)
* Update index.ts * Update index.ts * Update index.ts * Update index.js * Update index.js * Update index.js * Update index.js * Update tests.js
1 parent 859e314 commit 462afb6

8 files changed

Lines changed: 13 additions & 13 deletions

File tree

scripts/entity-death-event/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ world.afterEvents.entityHurt.subscribe((event) => {
2424
// @ts-expect-error
2525
const health = hurtEntity.getComponent(EntityHealthComponent.componentId);
2626

27-
if (health.current > 0) return;
27+
if (health.currentValue > 0) return;
2828

2929
for (const callback of callbacks) {
3030
const { entities, entityTypes } = callback.options;

scripts/entity-hit/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ world.afterEvents.entityHit.subscribe((evd) => {
1515
// @ts-ignore
1616
const h = ent.getComponent('health');
1717
if (!h) return;
18-
h.setCurrent(h.current - 100);
19-
});
18+
h.setCurrentValue(h.currentValue - 100);
19+
});

scripts/health-display/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ import { EntityHealthComponent, system, world } from "@minecraft/server";
77
system.runInterval(() => {
88
for (const player of world.getPlayers()) {
99
const health = player.getComponent(EntityHealthComponent.componentId) as EntityHealthComponent;
10-
player.nameTag = `${player.name}\n§c❤️ ${health.current.toFixed(1)}`;
10+
player.nameTag = `${player.name}\n§c❤️ ${health.currentValue.toFixed(1)}`;
1111
}
1212
});

scripts/kill-death-counter/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ world.afterEvents.entityHurt.subscribe(
2020
/** @type {EntityHealthComponent} */
2121
// @ts-ignore
2222
const health = hurtEntity.getComponent("health");
23-
if (health.current > 0) return;
23+
if (health.currentValue > 0) return;
2424
hurtEntity.runCommandAsync("scoreboard players add @s deaths 1");
2525
if (!(damageSource.damagingEntity instanceof Player)) return;
2626
damageSource.damagingEntity.runCommandAsync("scoreboard players add @s kills 1");

scripts/player-death-event/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ export class PlayerDeathEventSignal {
4545
*/
4646
// @ts-ignore
4747
let health = player.getComponent("health");
48-
if (health.current === 0 && arg["playerDeath"] === true) {
48+
if (health.currentValue === 0 && arg["playerDeath"] === true) {
4949
const playerIndex = deadPlayers.findIndex(pl => pl.name === player.name);
5050
if (playerIndex < 0) {
5151
arg(new PlayerDeathEvent(player));
5252
deadPlayers.push(player);
5353
let playerDeathCallback = system.runInterval(() => {
54-
if (health.current > 0) {
54+
if (health.currentValue > 0) {
5555
deadPlayers.splice(playerIndex, 1);
5656
system.clearRun(playerDeathCallback);
5757
};
@@ -84,4 +84,4 @@ PlayerDeathEventSignal.prototype.subscribe = deprecate(
8484
PlayerDeathEventSignal.prototype.unsubscribe = deprecate(
8585
PlayerDeathEventSignal.prototype.unsubscribe,
8686
'PlayerDeathEvent.unsubscribe() is deprecated. Use EntityDeathEvent.unsubscribe() instead.'
87-
);
87+
);

scripts/player-leave-event/tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ let callback = playerLeave.subscribe(({player}) => {
1111
*/
1212
// @ts-ignore
1313
let health = player.getComponent("health");
14-
player.dimension.runCommandAsync(`say ${player.name} left the server with ${health.current} HP`);
14+
player.dimension.runCommandAsync(`say ${player.name} left the server with ${health.currentValue} HP`);
1515
player.dimension.runCommandAsync(`say ${player.name} Location: ${player.location.x} ${player.location.y} ${player.location.z}`);
1616

1717
// unsubscribe
1818
playerLeave.unsubscribe(callback);
19-
});
19+
});

scripts/player-velocity-fix/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export function setVelocity (velocity: Vector3, player: Player) {
5656
} else {
5757
// Force the player to ride the entity until the entity lands
5858
Commands.runAsync(`ride "${player.name}" start_riding @s teleport_rider`, entity);
59-
movement?.setCurrent(0);
59+
movement?.setCurrentValue(0);
6060
health?.resetToMaxValue();
6161
};
6262
} catch (error) {

scripts/simulated-player/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export class SimulatedPlayer {
121121
* @param showParticles
122122
* @throws This function can throw errors.
123123
*/
124-
addEffect(effectType: Minecraft.EffectType, duration: number, amplifier?: number, showParticles?: boolean): boolean {
124+
addEffect(effectType: Minecraft.EffectType, duration: number, amplifier?: number, showParticles?: boolean): void {
125125
return this.__player.addEffect(effectType, duration, {
126126
amplifier,
127127
showParticles
@@ -701,4 +701,4 @@ velocity * @param itemCategory
701701
this.__player = player;
702702
this.__test = test;
703703
};
704-
};
704+
};

0 commit comments

Comments
 (0)