@orusteam/solariscore 2.5.4 → 2.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { BlockComponentRandomTickEvent, BlockCustomComponent, CustomComponentParameters } from "@minecraft/server";
|
|
1
|
+
import { BlockComponentEntityFallOnEvent, BlockComponentPlayerBreakEvent, BlockComponentPlayerInteractEvent, BlockComponentPlayerPlaceBeforeEvent, BlockComponentRandomTickEvent, BlockComponentStepOnEvent, BlockCustomComponent, CustomComponentParameters } from "@minecraft/server";
|
|
2
2
|
export declare class EggBlockComponent implements BlockCustomComponent {
|
|
3
3
|
constructor();
|
|
4
|
+
beforeOnPlayerPlace({ block, player }: BlockComponentPlayerPlaceBeforeEvent, { params }: CustomComponentParameters): void;
|
|
5
|
+
onEntityFallOn({ block, entity }: BlockComponentEntityFallOnEvent, { params }: CustomComponentParameters): void;
|
|
6
|
+
onPlayerBreak({ block, brokenBlockPermutation, player }: BlockComponentPlayerBreakEvent): void;
|
|
7
|
+
onPlayerInteract({ block, dimension, player }: BlockComponentPlayerInteractEvent, { params }: CustomComponentParameters): void;
|
|
4
8
|
onRandomTick({ block, dimension }: BlockComponentRandomTickEvent, { params }: CustomComponentParameters): void;
|
|
9
|
+
onStepOn({ block, entity }: BlockComponentStepOnEvent, { params }: CustomComponentParameters): void;
|
|
5
10
|
}
|
|
6
11
|
//# sourceMappingURL=EggBlockComponent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EggBlockComponent.d.ts","sourceRoot":"","sources":["../../../src/block/components/EggBlockComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,oBAAoB,EAAE,yBAAyB,
|
|
1
|
+
{"version":3,"file":"EggBlockComponent.d.ts","sourceRoot":"","sources":["../../../src/block/components/EggBlockComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,+BAA+B,EAAE,8BAA8B,EAAE,iCAAiC,EAAE,oCAAoC,EAAE,6BAA6B,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,yBAAyB,EAAqD,MAAM,mBAAmB,CAAC;AA+DlV,qBAAa,iBAAkB,YAAW,oBAAoB;;IAU1D,mBAAmB,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,oCAAoC,EAAE,EAAE,MAAM,EAAE,EAAE,yBAAyB;IAWlH,cAAc,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,+BAA+B,EAAE,EAAE,MAAM,EAAE,EAAE,yBAAyB;IASxG,aAAa,CAAC,EAAE,KAAK,EAAE,sBAAsB,EAAE,MAAM,EAAE,EAAE,8BAA8B;IAoBvF,gBAAgB,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,iCAAiC,EAAE,EAAE,MAAM,EAAE,EAAE,yBAAyB;IAsBvH,YAAY,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,6BAA6B,EAAE,EAAE,MAAM,EAAE,EAAE,yBAAyB;IAyBvG,QAAQ,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,yBAAyB,EAAE,EAAE,MAAM,EAAE,EAAE,yBAAyB;CAQ/F"}
|
package/dist/index.js
CHANGED
|
@@ -571,6 +571,15 @@ var ChunkUtil = class _ChunkUtil {
|
|
|
571
571
|
|
|
572
572
|
// src/utils/ColorUtil.ts
|
|
573
573
|
var ColorUtil = class {
|
|
574
|
+
static colorToRgb(color) {
|
|
575
|
+
if (typeof color === "string") {
|
|
576
|
+
return this.hexToRgb(color);
|
|
577
|
+
}
|
|
578
|
+
if (Array.isArray(color)) {
|
|
579
|
+
return this.tupleToRgb(color);
|
|
580
|
+
}
|
|
581
|
+
return color;
|
|
582
|
+
}
|
|
574
583
|
static hexToRgb(hex) {
|
|
575
584
|
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
576
585
|
return {
|
|
@@ -579,6 +588,16 @@ var ColorUtil = class {
|
|
|
579
588
|
blue: result ? parseInt(result[3], 16) / 255 : 0
|
|
580
589
|
};
|
|
581
590
|
}
|
|
591
|
+
static rgbToTuple(rgb) {
|
|
592
|
+
return [rgb.red, rgb.green, rgb.blue];
|
|
593
|
+
}
|
|
594
|
+
static tupleToRgb(tuple) {
|
|
595
|
+
return {
|
|
596
|
+
red: tuple[0],
|
|
597
|
+
green: tuple[1],
|
|
598
|
+
blue: tuple[2]
|
|
599
|
+
};
|
|
600
|
+
}
|
|
582
601
|
};
|
|
583
602
|
|
|
584
603
|
// src/utils/DateUtil.ts
|
|
@@ -4253,31 +4272,125 @@ var DoorBlockComponent = class {
|
|
|
4253
4272
|
};
|
|
4254
4273
|
|
|
4255
4274
|
// src/block/components/EggBlockComponent.ts
|
|
4256
|
-
import { world as world2 } from "@minecraft/server";
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4275
|
+
import { EquipmentSlot as EquipmentSlot3, GameMode as GameMode3, system as system4, world as world2 } from "@minecraft/server";
|
|
4276
|
+
var FALL_BREAK_CHANCE = 1 / 3;
|
|
4277
|
+
var STEP_BREAK_CHANCE = 1 / 100;
|
|
4278
|
+
function canCrack(block, eggBlockParams) {
|
|
4279
|
+
const { hatch_only_at_night, nest_block } = eggBlockParams;
|
|
4280
|
+
if (nest_block && block.below()?.typeId !== nest_block) {
|
|
4281
|
+
return false;
|
|
4282
|
+
}
|
|
4283
|
+
if (hatch_only_at_night) {
|
|
4284
|
+
const timeOfDay = world2.getTimeOfDay();
|
|
4285
|
+
if (timeOfDay >= 21600 && timeOfDay <= 22550) {
|
|
4286
|
+
return true;
|
|
4287
|
+
}
|
|
4288
|
+
}
|
|
4260
4289
|
return Math.random() < 2e-3;
|
|
4261
4290
|
}
|
|
4291
|
+
function tryBreakEgg(block, eggBlockParams) {
|
|
4292
|
+
if (eggBlockParams.sensitive) {
|
|
4293
|
+
const { permutation } = block;
|
|
4294
|
+
const location = block.center();
|
|
4295
|
+
const eggCount = Number(permutation.getState("orusteam:egg_count"));
|
|
4296
|
+
if (eggCount <= 0) {
|
|
4297
|
+
block.dimension.runCommand(`setblock ${location.x} ${location.y} ${location.z} air [] destroy`);
|
|
4298
|
+
return;
|
|
4299
|
+
}
|
|
4300
|
+
const newPermutation = permutation.withState("orusteam:egg_count", eggCount - 1);
|
|
4301
|
+
block.setPermutation(newPermutation);
|
|
4302
|
+
block.dimension.playSound(eggBlockParams.break_sound ?? "dig.stone", location);
|
|
4303
|
+
}
|
|
4304
|
+
}
|
|
4262
4305
|
var EggBlockComponent = class {
|
|
4263
4306
|
constructor() {
|
|
4307
|
+
this.beforeOnPlayerPlace = this.beforeOnPlayerPlace.bind(this);
|
|
4308
|
+
this.onEntityFallOn = this.onEntityFallOn.bind(this);
|
|
4309
|
+
this.onPlayerBreak = this.onPlayerBreak.bind(this);
|
|
4310
|
+
this.onPlayerInteract = this.onPlayerInteract.bind(this);
|
|
4264
4311
|
this.onRandomTick = this.onRandomTick.bind(this);
|
|
4312
|
+
this.onStepOn = this.onStepOn.bind(this);
|
|
4313
|
+
}
|
|
4314
|
+
beforeOnPlayerPlace({ block, player }, { params }) {
|
|
4315
|
+
if (player) {
|
|
4316
|
+
const { nest_block } = params;
|
|
4317
|
+
const bellowBlock = block.below();
|
|
4318
|
+
if (bellowBlock?.typeId === nest_block) {
|
|
4319
|
+
const location = block.center();
|
|
4320
|
+
system4.run(() => block.dimension.spawnParticle("minecraft:crop_growth_emitter", location));
|
|
4321
|
+
}
|
|
4322
|
+
}
|
|
4323
|
+
}
|
|
4324
|
+
onEntityFallOn({ block, entity }, { params }) {
|
|
4325
|
+
if (entity) {
|
|
4326
|
+
const eggBlockParams = params;
|
|
4327
|
+
if (!eggBlockParams.ignored_entities?.includes(entity?.typeId) && Math.random() < FALL_BREAK_CHANCE) {
|
|
4328
|
+
tryBreakEgg(block, eggBlockParams);
|
|
4329
|
+
}
|
|
4330
|
+
}
|
|
4331
|
+
}
|
|
4332
|
+
onPlayerBreak({ block, brokenBlockPermutation, player }) {
|
|
4333
|
+
if (player && player.getGameMode() === GameMode3.Survival) {
|
|
4334
|
+
const location = block.center();
|
|
4335
|
+
const eggCount = Number(brokenBlockPermutation.getState("orusteam:egg_count"));
|
|
4336
|
+
const mainHand = EntityUtil.getEquippedItem(player, EquipmentSlot3.Mainhand);
|
|
4337
|
+
const items = [];
|
|
4338
|
+
for (let i = 0; i < eggCount; i++) {
|
|
4339
|
+
const itemStack = world2.getLootTableManager().generateLootFromBlockPermutation(brokenBlockPermutation, mainHand);
|
|
4340
|
+
if (itemStack) {
|
|
4341
|
+
items.push(...itemStack);
|
|
4342
|
+
}
|
|
4343
|
+
}
|
|
4344
|
+
for (const itemStack of items) {
|
|
4345
|
+
block.dimension.spawnItem(itemStack, location);
|
|
4346
|
+
}
|
|
4347
|
+
}
|
|
4348
|
+
}
|
|
4349
|
+
onPlayerInteract({ block, dimension, player }, { params }) {
|
|
4350
|
+
if (player) {
|
|
4351
|
+
const mainHand = EntityUtil.getEquippedItem(player, EquipmentSlot3.Mainhand);
|
|
4352
|
+
if (mainHand?.typeId === block.typeId) {
|
|
4353
|
+
const { add_egg_sound, max_eggs_per_block } = params;
|
|
4354
|
+
const { permutation } = block;
|
|
4355
|
+
let eggCount = Number(permutation.getState("orusteam:egg_count"));
|
|
4356
|
+
if (++eggCount >= (max_eggs_per_block ?? 1)) {
|
|
4357
|
+
return;
|
|
4358
|
+
}
|
|
4359
|
+
const newPermutation = permutation.withState("orusteam:egg_count", eggCount);
|
|
4360
|
+
const location = block.center();
|
|
4361
|
+
block.setPermutation(newPermutation);
|
|
4362
|
+
dimension.playSound(add_egg_sound ?? "dig.stone", location);
|
|
4363
|
+
ItemUtil.decrementStack(player);
|
|
4364
|
+
}
|
|
4365
|
+
}
|
|
4265
4366
|
}
|
|
4266
4367
|
onRandomTick({ block, dimension }, { params }) {
|
|
4267
|
-
const
|
|
4268
|
-
|
|
4368
|
+
const eggBlockParams = params;
|
|
4369
|
+
const { crack_sound, drop_sound, entity_id } = eggBlockParams;
|
|
4370
|
+
if (canCrack(block, eggBlockParams)) {
|
|
4269
4371
|
const { permutation } = block;
|
|
4270
4372
|
const location = block.center();
|
|
4271
|
-
const
|
|
4272
|
-
if (
|
|
4273
|
-
|
|
4274
|
-
dimension.playSound(drop_sound ?? "
|
|
4373
|
+
const crackedState = String(permutation.getState("orusteam:cracked_state"));
|
|
4374
|
+
if (crackedState === "max_cracked") {
|
|
4375
|
+
const eggCount = Number(permutation.getState("orusteam:egg_count"));
|
|
4376
|
+
dimension.playSound(drop_sound ?? "", location);
|
|
4275
4377
|
dimension.runCommand(`setblock ${location.x} ${location.y} ${location.z} air [] destroy`);
|
|
4378
|
+
for (let i = 0; i <= eggCount; i++) {
|
|
4379
|
+
dimension.spawnEntity(entity_id, location);
|
|
4380
|
+
}
|
|
4276
4381
|
return;
|
|
4277
4382
|
}
|
|
4278
|
-
const newPermutation = permutation.withState("cracked_state",
|
|
4383
|
+
const newPermutation = permutation.withState("orusteam:cracked_state", crackedState === "no_cracks" ? "cracked" : "max_cracked");
|
|
4279
4384
|
block.setPermutation(newPermutation);
|
|
4280
|
-
dimension.playSound(crack_sound ?? "
|
|
4385
|
+
dimension.playSound(crack_sound ?? "", location);
|
|
4386
|
+
}
|
|
4387
|
+
}
|
|
4388
|
+
onStepOn({ block, entity }, { params }) {
|
|
4389
|
+
if (entity) {
|
|
4390
|
+
const eggBlockParams = params;
|
|
4391
|
+
if (!eggBlockParams.ignored_entities?.includes(entity?.typeId) && Math.random() < STEP_BREAK_CHANCE) {
|
|
4392
|
+
tryBreakEgg(block, eggBlockParams);
|
|
4393
|
+
}
|
|
4281
4394
|
}
|
|
4282
4395
|
}
|
|
4283
4396
|
};
|
|
@@ -4367,7 +4480,7 @@ var ParticleEmitterBlockComponent = class {
|
|
|
4367
4480
|
};
|
|
4368
4481
|
|
|
4369
4482
|
// src/block/components/SaplingBlockComponent.ts
|
|
4370
|
-
import { EquipmentSlot as
|
|
4483
|
+
import { EquipmentSlot as EquipmentSlot4, GameMode as GameMode4 } from "@minecraft/server";
|
|
4371
4484
|
function tryPlaceFeature(blockSapling, params) {
|
|
4372
4485
|
const { feature } = params;
|
|
4373
4486
|
const featurePlaced = blockSapling.dimension.placeFeature(feature, blockSapling.location);
|
|
@@ -4382,13 +4495,13 @@ var SaplingBlockComponent = class {
|
|
|
4382
4495
|
}
|
|
4383
4496
|
onPlayerInteract({ block, player }, { params }) {
|
|
4384
4497
|
if (player) {
|
|
4385
|
-
const mainhand = EntityUtil.getEquippedItem(player,
|
|
4498
|
+
const mainhand = EntityUtil.getEquippedItem(player, EquipmentSlot4.Mainhand);
|
|
4386
4499
|
if (!mainhand || mainhand.typeId !== "minecraft:bone_meal") return;
|
|
4387
4500
|
const { permutation } = block;
|
|
4388
4501
|
const ageBit = Number(permutation.getState("dbe:age_bit"));
|
|
4389
4502
|
applyGrowthEffects(block);
|
|
4390
4503
|
ItemUtil.decrementStack(player);
|
|
4391
|
-
if (player.getGameMode() ===
|
|
4504
|
+
if (player.getGameMode() === GameMode4.Creative) {
|
|
4392
4505
|
tryPlaceFeature(block, params);
|
|
4393
4506
|
return;
|
|
4394
4507
|
}
|
|
@@ -4429,7 +4542,7 @@ var DurabilitySensorItemComponent = class {
|
|
|
4429
4542
|
};
|
|
4430
4543
|
|
|
4431
4544
|
// src/misc/DynamicDatabase.ts
|
|
4432
|
-
import { Entity as Entity3, system as
|
|
4545
|
+
import { Entity as Entity3, system as system5, World as World2 } from "@minecraft/server";
|
|
4433
4546
|
var DynamicDatabase = class _DynamicDatabase {
|
|
4434
4547
|
constructor(provider, dataId) {
|
|
4435
4548
|
this.provider = provider;
|
|
@@ -4509,7 +4622,7 @@ var DynamicDatabase = class _DynamicDatabase {
|
|
|
4509
4622
|
saveOnNextTick() {
|
|
4510
4623
|
if (!this.isSaving) {
|
|
4511
4624
|
this.isSaving = true;
|
|
4512
|
-
|
|
4625
|
+
system5.runTimeout(() => {
|
|
4513
4626
|
this.save();
|
|
4514
4627
|
this.isSaving = false;
|
|
4515
4628
|
}, 2);
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { RGB } from "@minecraft/server";
|
|
2
|
-
|
|
2
|
+
type RGBTuple = [r: number, g: number, b: number];
|
|
3
|
+
type Color = RGB | RGBTuple | string;
|
|
4
|
+
declare class ColorUtil {
|
|
5
|
+
static colorToRgb(color: Color): RGB;
|
|
3
6
|
static hexToRgb(hex: string): RGB;
|
|
7
|
+
static rgbToTuple(rgb: RGB): RGBTuple;
|
|
8
|
+
static tupleToRgb(tuple: RGBTuple): RGB;
|
|
4
9
|
}
|
|
10
|
+
export { Color, ColorUtil, RGBTuple };
|
|
5
11
|
//# sourceMappingURL=ColorUtil.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorUtil.d.ts","sourceRoot":"","sources":["../../src/utils/ColorUtil.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAIxC,
|
|
1
|
+
{"version":3,"file":"ColorUtil.d.ts","sourceRoot":"","sources":["../../src/utils/ColorUtil.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAIxC,KAAK,QAAQ,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;AAClD,KAAK,KAAK,GAAG,GAAG,GAAG,QAAQ,GAAG,MAAM,CAAC;AAIrC,cAAM,SAAS;IACX,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,GAAG;IAYpC,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG;IASjC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,QAAQ;IAIrC,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,QAAQ,GAAG,GAAG;CAO1C;AAID,OAAO,EACH,KAAK,EACL,SAAS,EACT,QAAQ,EACX,CAAC"}
|