Skip to content

Commit b72c316

Browse files
committed
Fixed piston name change from CamelCase to SnakeCase. #96
1 parent af710f2 commit b72c316

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

plugin.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: RedstoneCircuit
22
main: tedo0627\redstonecircuit\RedstoneCircuit
33
version: 3.0.4
4-
api: 4.0.0
4+
api: 4.3.0
55
author: tedo0627

src/tedo0627/redstonecircuit/block/BlockTable.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ class BlockTable {
2929
public function __construct() {
3030
$json = json_decode(file_get_contents(BEDROCK_DATA_PATH . "block_id_map.json"), true);
3131
foreach ($json as $name => $id) {
32+
// pistonArmCollision -> piston_arm_collision
33+
if (str_contains(strtolower($name), "piston")) {
34+
$name = ltrim(strtolower(preg_replace('/[A-Z]/', '_\0', $name)), '_');
35+
}
3236
$this->idToName[$id] = $name;
3337
$this->nameToId[$name] = $id;
3438
}
@@ -40,7 +44,13 @@ public function __construct() {
4044
);
4145
$nbtReader = new NetworkNbtSerializer();
4246
while(!$legacyStateMapReader->feof()){
43-
$id = $this->getId($legacyStateMapReader->getString());
47+
$name = $legacyStateMapReader->getString();
48+
// pistonArmCollision -> piston_arm_collision
49+
if (str_contains(strtolower($name), "piston")) {
50+
$name = ltrim(strtolower(preg_replace('/[A-Z]/', '_\0', $name)), '_');
51+
}
52+
53+
$id = $this->getId($name);
4454
$damage = $legacyStateMapReader->getLShort();
4555

4656
$offset = $legacyStateMapReader->getOffset();

0 commit comments

Comments
 (0)