prismarine-physics 1.9.0 → 1.10.0

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.
package/HISTORY.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## History
2
2
 
3
+ ### 1.10.0
4
+ * [Fix `.isOnLadder()` condition (#111)](https://github.com/PrismarineJS/prismarine-physics/commit/03b2e447b7f867257b8e50170439be8ca8e51743) (thanks @szdytom)
5
+ * [Bump mocha from 10.8.2 to 11.0.1 (#119)](https://github.com/PrismarineJS/prismarine-physics/commit/4a1d37c91915522d824b2d4170fce135926ce6e5) (thanks @dependabot[bot])
6
+ * [Use new block.isWaterlogged over reading block properties (#120)](https://github.com/PrismarineJS/prismarine-physics/commit/5cbba64ec457c6b5fa18002e57b87c8c584abb94) (thanks @extremeheat)
7
+
3
8
  ### 1.9.0
4
9
  * [add 1.21 to proportionalliquidgravity setting (#117)](https://github.com/PrismarineJS/prismarine-physics/commit/4986c8e395773e770d461db06bce38f9faed0757) (thanks @Madlykeanu)
5
10
 
package/index.js CHANGED
@@ -34,6 +34,21 @@ function Physics (mcData, world) {
34
34
  const lavaIds = [blocksByName.lava.id, blocksByName.flowing_lava ? blocksByName.flowing_lava.id : -1]
35
35
  const ladderId = blocksByName.ladder.id
36
36
  const vineId = blocksByName.vine.id
37
+
38
+ // NOTE: Copper trapdoors is coming in 1.21.
39
+ const trapdoorIds = new Set()
40
+ if (blocksByName.iron_trapdoor) { trapdoorIds.add(blocksByName.iron_trapdoor.id) } // 1.8+
41
+ if (blocksByName.acacia_trapdoor) { trapdoorIds.add(blocksByName.acacia_trapdoor.id) } // 1.13+
42
+ if (blocksByName.birch_trapdoor) { trapdoorIds.add(blocksByName.birch_trapdoor.id) } // 1.13+
43
+ if (blocksByName.jungle_trapdoor) { trapdoorIds.add(blocksByName.jungle_trapdoor.id) } // 1.13+
44
+ if (blocksByName.oak_trapdoor) { trapdoorIds.add(blocksByName.oak_trapdoor.id) } // 1.13+
45
+ if (blocksByName.dark_oak_trapdoor) { trapdoorIds.add(blocksByName.dark_oak_trapdoor.id) } // 1.13+
46
+ if (blocksByName.spruce_trapdoor) { trapdoorIds.add(blocksByName.spruce_trapdoor.id) } // 1.13+
47
+ if (blocksByName.crimson_trapdoor) { trapdoorIds.add(blocksByName.crimson_trapdoor.id) } // 1.16+
48
+ if (blocksByName.warped_trapdoor) { trapdoorIds.add(blocksByName.warped_trapdoor.id) } // 1.16+
49
+ if (blocksByName.mangrove_trapdoor) { trapdoorIds.add(blocksByName.mangrove_trapdoor.id) } // 1.19+
50
+ if (blocksByName.cherry_trapdoor) { trapdoorIds.add(blocksByName.cherry_trapdoor.id) } // 1.20+
51
+
37
52
  const waterLike = new Set()
38
53
  if (blocksByName.seagrass) waterLike.add(blocksByName.seagrass.id) // 1.13+
39
54
  if (blocksByName.tall_seagrass) waterLike.add(blocksByName.tall_seagrass.id) // 1.13+
@@ -419,9 +434,26 @@ function Physics (mcData, world) {
419
434
  vel.z += forward * cos - strafe * sin
420
435
  }
421
436
 
437
+ const climbableTrapdoorFeature = supportFeature('climbableTrapdoor')
422
438
  function isOnLadder (world, pos) {
423
439
  const block = world.getBlock(pos)
424
- return (block && (block.type === ladderId || block.type === vineId))
440
+ if (!block) { return false }
441
+ if (block.type === ladderId || block.type === vineId) { return true }
442
+
443
+ // Since 1.9, when a trapdoor satisfies the following conditions, it also becomes climbable:
444
+ // 1. The trapdoor is placed directly above a ladder.
445
+ // 2. The trapdoor is opened.
446
+ // 3. The trapdoor and the ladder directly below it face the same direction.
447
+ if (climbableTrapdoorFeature && trapdoorIds.has(block.type)) {
448
+ const blockBelow = world.getBlock(pos.offset(0, -1, 0))
449
+ if (blockBelow.type !== ladderId) { return false } // condition 1.
450
+ const blockProperties = block._properties
451
+ if (!blockProperties.open) { return false } // condition 2.
452
+ if (blockProperties.facing !== blockBelow.getProperties().facing) { return false } // condition 3
453
+ return true
454
+ }
455
+
456
+ return false
425
457
  }
426
458
 
427
459
  function doesNotCollide (world, pos) {
@@ -592,7 +624,7 @@ function Physics (mcData, world) {
592
624
  function getRenderedDepth (block) {
593
625
  if (!block) return -1
594
626
  if (waterLike.has(block.type)) return 0
595
- if (block.getProperties().waterlogged) return 0
627
+ if (block.isWaterlogged) return 0
596
628
  if (!waterIds.includes(block.type)) return -1
597
629
  const meta = block.metadata
598
630
  return meta >= 8 ? 0 : meta
@@ -640,7 +672,7 @@ function Physics (mcData, world) {
640
672
  for (cursor.z = Math.floor(bb.minZ); cursor.z <= Math.floor(bb.maxZ); cursor.z++) {
641
673
  for (cursor.x = Math.floor(bb.minX); cursor.x <= Math.floor(bb.maxX); cursor.x++) {
642
674
  const block = world.getBlock(cursor)
643
- if (block && (waterIds.includes(block.type) || waterLike.has(block.type) || block.getProperties().waterlogged)) {
675
+ if (block && (waterIds.includes(block.type) || waterLike.has(block.type) || block.isWaterlogged)) {
644
676
  const waterLevel = cursor.y + 1 - getLiquidHeightPcent(block)
645
677
  if (Math.ceil(bb.maxY) >= waterLevel) waterBlocks.push(block)
646
678
  }
package/lib/features.json CHANGED
@@ -17,11 +17,16 @@
17
17
  {
18
18
  "name": "velocityBlocksOnTop",
19
19
  "description": "Velocity changes are caused by the block the player is standing on",
20
- "versions": ["1.15", "1.17", "1.18"]
20
+ "versions": ["1.15", "1.16", "1.17", "1.18", "1.19", "1.20"]
21
21
  },
22
22
  {
23
23
  "name": "climbUsingJump",
24
24
  "description": "Entity can climb ladders and vines by pressing jump",
25
- "versions": ["1.14", "1.15", "1.17", "1.18"]
25
+ "versions": ["1.14", "1.15", "1.16", "1.17", "1.18", "1.19", "1.20"]
26
+ },
27
+ {
28
+ "name": "climbableTrapdoor",
29
+ "description": "Trapdoors placed directly above ladders become climbable",
30
+ "versions": ["1.9", "1.10", "1.11", "1.12", "1.13", "1.14", "1.15", "1.16", "1.17", "1.18", "1.19", "1.20"]
26
31
  }
27
32
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prismarine-physics",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "description": "Provide the physics engine for minecraft entities",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -29,7 +29,7 @@
29
29
  "homepage": "https://github.com/PrismarineJS/prismarine-physics#readme",
30
30
  "devDependencies": {
31
31
  "expect": "^27.3.1",
32
- "mocha": "^10.0.0",
32
+ "mocha": "^11.0.1",
33
33
  "prismarine-block": "^1.7.3",
34
34
  "prismarine-physics": "file:./",
35
35
  "standard": "^17.0.0"