@orusteam/solariscore 2.5.5 → 2.5.7

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,EAAS,MAAM,mBAAmB,CAAC;AAoB1H,qBAAa,iBAAkB,YAAW,oBAAoB;;IAK1D,YAAY,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,6BAA6B,EAAE,EAAE,MAAM,EAAE,EAAE,yBAAyB;CAmB1G"}
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
@@ -576,11 +576,7 @@ var ColorUtil = class {
576
576
  return this.hexToRgb(color);
577
577
  }
578
578
  if (Array.isArray(color)) {
579
- return {
580
- red: color[0],
581
- green: color[1],
582
- blue: color[2]
583
- };
579
+ return this.tupleToRgb(color);
584
580
  }
585
581
  return color;
586
582
  }
@@ -4123,7 +4119,7 @@ function applyGrowthEffects(block) {
4123
4119
  }
4124
4120
  function setGrowthStage(block, value, maxStage) {
4125
4121
  const newGrowthStage = clampNumber(value, 0, maxStage);
4126
- const newPermutation = block.permutation.withState("dbe:growth", newGrowthStage);
4122
+ const newPermutation = block.permutation.withState("solariscore:growth", newGrowthStage);
4127
4123
  block.setPermutation(newPermutation);
4128
4124
  }
4129
4125
  function forceGrowth(block, growthStage, maxStage) {
@@ -4140,7 +4136,7 @@ var CropBlockComponent = class {
4140
4136
  if (!mainhand) return;
4141
4137
  const { permutation } = block;
4142
4138
  const { accumulable, bone_meal_multiplication, max_stage } = params;
4143
- const growthStage = Number(permutation.getState("dbe:growth"));
4139
+ const growthStage = Number(permutation.getState("solariscore:growth"));
4144
4140
  const location = block.center();
4145
4141
  const { typeId } = mainhand;
4146
4142
  if (accumulable && typeId === block.typeId && growthStage < max_stage) {
@@ -4173,7 +4169,7 @@ var CropBlockComponent = class {
4173
4169
  const { natural_growth } = params;
4174
4170
  if (natural_growth) {
4175
4171
  const { permutation } = block;
4176
- const growthStage = Number(permutation.getState("dbe:growth"));
4172
+ const growthStage = Number(permutation.getState("solariscore:growth"));
4177
4173
  const { max_stage } = params;
4178
4174
  setGrowthStage(block, growthStage + 1, max_stage);
4179
4175
  }
@@ -4184,16 +4180,16 @@ var CropBlockComponent = class {
4184
4180
  import { BlockPermutation, system as system3 } from "@minecraft/server";
4185
4181
  function doorIsOpen(block) {
4186
4182
  const allStates = block.permutation.getAllStates();
4187
- return Boolean(allStates["dbe:open_bit"]);
4183
+ return Boolean(allStates["solariscore:open_bit"]);
4188
4184
  }
4189
4185
  function tryToggleDoor(block) {
4190
4186
  const allStates = block.permutation.getAllStates();
4191
- const isUpper = allStates["dbe:upper_block_bit"];
4192
- const isOpen = allStates["dbe:open_bit"];
4187
+ const isUpper = allStates["solariscore:upper_block_bit"];
4188
+ const isOpen = allStates["solariscore:open_bit"];
4193
4189
  const otherPart = isUpper ? block.below() : block.above();
4194
4190
  if (otherPart?.typeId === block.typeId) {
4195
- block.setPermutation(block.permutation.withState("dbe:open_bit", !isOpen));
4196
- otherPart.setPermutation(otherPart.permutation.withState("dbe:open_bit", !isOpen));
4191
+ block.setPermutation(block.permutation.withState("solariscore:open_bit", !isOpen));
4192
+ otherPart.setPermutation(otherPart.permutation.withState("solariscore:open_bit", !isOpen));
4197
4193
  const interactSoundId = isOpen ? "close.wooden_door" : "open.wooden_door";
4198
4194
  block.dimension.playSound(interactSoundId, block.location);
4199
4195
  }
@@ -4241,12 +4237,12 @@ var DoorBlockComponent = class {
4241
4237
  if (leftBlock && rightBlock) {
4242
4238
  const { left, right } = getSolidBlocksCount(leftBlock, rightBlock);
4243
4239
  if (left > right || rightBlock?.typeId === permutationToPlace.type.id) {
4244
- allStates["dbe:door_hinge_bit"] = true;
4240
+ allStates["solariscore:door_hinge_bit"] = true;
4245
4241
  }
4246
4242
  }
4247
4243
  if (!block.below()?.isAir && block.typeId === aboveBlock?.typeId) {
4248
4244
  const upperBlockStates = { ...allStates };
4249
- upperBlockStates["dbe:upper_block_bit"] = true;
4245
+ upperBlockStates["solariscore:upper_block_bit"] = true;
4250
4246
  const upperBlockPermutation = BlockPermutation.resolve(permutationToPlace.type.id, upperBlockStates);
4251
4247
  event.permutationToPlace = BlockPermutation.resolve(permutationToPlace.type.id, allStates);
4252
4248
  system3.run(() => {
@@ -4264,7 +4260,7 @@ var DoorBlockComponent = class {
4264
4260
  }
4265
4261
  }
4266
4262
  onPlayerBreak({ block, brokenBlockPermutation }) {
4267
- const isUpper = brokenBlockPermutation.getState("dbe:upper_block_bit");
4263
+ const isUpper = brokenBlockPermutation.getState("solariscore:upper_block_bit");
4268
4264
  const otherPart = isUpper ? block.below() : block.above();
4269
4265
  if (otherPart?.typeId === brokenBlockPermutation.type.id) {
4270
4266
  otherPart.setType("minecraft:air");
@@ -4276,31 +4272,125 @@ var DoorBlockComponent = class {
4276
4272
  };
4277
4273
 
4278
4274
  // src/block/components/EggBlockComponent.ts
4279
- import { world as world2 } from "@minecraft/server";
4280
- function canCrack() {
4281
- const timeOfDay = world2.getTimeOfDay();
4282
- if (timeOfDay >= 21600 && timeOfDay <= 22550) return true;
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
+ }
4283
4289
  return Math.random() < 2e-3;
4284
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("solariscore: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("solariscore:egg_count", eggCount - 1);
4301
+ block.setPermutation(newPermutation);
4302
+ block.dimension.playSound(eggBlockParams.break_sound ?? "dig.stone", location);
4303
+ }
4304
+ }
4285
4305
  var EggBlockComponent = class {
4286
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);
4287
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("solariscore: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("solariscore:egg_count"));
4356
+ if (++eggCount >= (max_eggs_per_block ?? 1)) {
4357
+ return;
4358
+ }
4359
+ const newPermutation = permutation.withState("solariscore: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
+ }
4288
4366
  }
4289
4367
  onRandomTick({ block, dimension }, { params }) {
4290
- const { crack_sound, drop_sound, entity_id } = params;
4291
- if (canCrack()) {
4368
+ const eggBlockParams = params;
4369
+ const { crack_sound, drop_sound, entity_id } = eggBlockParams;
4370
+ if (canCrack(block, eggBlockParams)) {
4292
4371
  const { permutation } = block;
4293
4372
  const location = block.center();
4294
- const stage = String(permutation.getState("cracked_state"));
4295
- if (stage === "max_cracked") {
4296
- dimension.spawnEntity(entity_id, location);
4297
- dimension.playSound(drop_sound ?? "block.turtle_egg.drop", location);
4373
+ const crackedState = String(permutation.getState("solariscore:cracked_state"));
4374
+ if (crackedState === "max_cracked") {
4375
+ const eggCount = Number(permutation.getState("solariscore:egg_count"));
4376
+ dimension.playSound(drop_sound ?? "", location);
4298
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
+ }
4299
4381
  return;
4300
4382
  }
4301
- const newPermutation = permutation.withState("cracked_state", stage === "no_cracks" ? "cracked" : "max_cracked");
4383
+ const newPermutation = permutation.withState("solariscore:cracked_state", crackedState === "no_cracks" ? "cracked" : "max_cracked");
4302
4384
  block.setPermutation(newPermutation);
4303
- dimension.playSound(crack_sound ?? "block.turtle_egg.crack", location);
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
+ }
4304
4394
  }
4305
4395
  }
4306
4396
  };
@@ -4390,7 +4480,7 @@ var ParticleEmitterBlockComponent = class {
4390
4480
  };
4391
4481
 
4392
4482
  // src/block/components/SaplingBlockComponent.ts
4393
- import { EquipmentSlot as EquipmentSlot3, GameMode as GameMode3 } from "@minecraft/server";
4483
+ import { EquipmentSlot as EquipmentSlot4, GameMode as GameMode4 } from "@minecraft/server";
4394
4484
  function tryPlaceFeature(blockSapling, params) {
4395
4485
  const { feature } = params;
4396
4486
  const featurePlaced = blockSapling.dimension.placeFeature(feature, blockSapling.location);
@@ -4405,19 +4495,19 @@ var SaplingBlockComponent = class {
4405
4495
  }
4406
4496
  onPlayerInteract({ block, player }, { params }) {
4407
4497
  if (player) {
4408
- const mainhand = EntityUtil.getEquippedItem(player, EquipmentSlot3.Mainhand);
4498
+ const mainhand = EntityUtil.getEquippedItem(player, EquipmentSlot4.Mainhand);
4409
4499
  if (!mainhand || mainhand.typeId !== "minecraft:bone_meal") return;
4410
4500
  const { permutation } = block;
4411
- const ageBit = Number(permutation.getState("dbe:age_bit"));
4501
+ const ageBit = Number(permutation.getState("solariscore:age_bit"));
4412
4502
  applyGrowthEffects(block);
4413
4503
  ItemUtil.decrementStack(player);
4414
- if (player.getGameMode() === GameMode3.Creative) {
4504
+ if (player.getGameMode() === GameMode4.Creative) {
4415
4505
  tryPlaceFeature(block, params);
4416
4506
  return;
4417
4507
  }
4418
4508
  if (Math.random() < 0.45) {
4419
4509
  const newAgeBit = Math.min(1, ageBit + 1);
4420
- const newPermutation = permutation.withState("dbe:age_bit", newAgeBit);
4510
+ const newPermutation = permutation.withState("solariscore:age_bit", newAgeBit);
4421
4511
  block.setPermutation(newPermutation);
4422
4512
  if (newAgeBit === 1) {
4423
4513
  tryPlaceFeature(block, params);
@@ -4427,11 +4517,11 @@ var SaplingBlockComponent = class {
4427
4517
  }
4428
4518
  onRandomTick({ block }, { params }) {
4429
4519
  const { permutation } = block;
4430
- const ageBit = Number(permutation.getState("dbe:age_bit"));
4520
+ const ageBit = Number(permutation.getState("solariscore:age_bit"));
4431
4521
  if (ageBit === 1) {
4432
4522
  tryPlaceFeature(block, params);
4433
4523
  } else {
4434
- const newPermutation = permutation.withState("dbe:age_bit", ageBit + 1);
4524
+ const newPermutation = permutation.withState("solariscore:age_bit", ageBit + 1);
4435
4525
  block.setPermutation(newPermutation);
4436
4526
  }
4437
4527
  }
@@ -4452,7 +4542,7 @@ var DurabilitySensorItemComponent = class {
4452
4542
  };
4453
4543
 
4454
4544
  // src/misc/DynamicDatabase.ts
4455
- import { Entity as Entity3, system as system4, World as World2 } from "@minecraft/server";
4545
+ import { Entity as Entity3, system as system5, World as World2 } from "@minecraft/server";
4456
4546
  var DynamicDatabase = class _DynamicDatabase {
4457
4547
  constructor(provider, dataId) {
4458
4548
  this.provider = provider;
@@ -4532,7 +4622,7 @@ var DynamicDatabase = class _DynamicDatabase {
4532
4622
  saveOnNextTick() {
4533
4623
  if (!this.isSaving) {
4534
4624
  this.isSaving = true;
4535
- system4.runTimeout(() => {
4625
+ system5.runTimeout(() => {
4536
4626
  this.save();
4537
4627
  this.isSaving = false;
4538
4628
  }, 2);
@@ -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,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;IAgBpC,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"}
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orusteam/solariscore",
3
- "version": "2.5.5",
3
+ "version": "2.5.7",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",