Skip to content

Commit 60b917e

Browse files
Merge pull request #149 from Miniontoby/master
Updated Connectable and BlockRotateV2 to 1.21
2 parents b754bc8 + d60adca commit 60b917e

File tree

11 files changed

+338
-230
lines changed

11 files changed

+338
-230
lines changed

plugins/BlockRotationV2/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Simple Block Rotation
2+
3+
Simple Block Rotation automates common behaviour for rotating blocks.
4+
5+
## Installation
6+
7+
Simply install the extension to your project from bridge.'s extension library.
8+
9+
## Usage
10+
11+
Add either the `bridge:log_rotate_on_place`, `bridge:rotate_on_place`, or `bridge:rotate_y_on_place` block components to your block.

plugins/BlockRotationV2/components/block/logRotate.js

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,52 +10,49 @@ export default function defineComponent({ name, template, schema }) {
1010
})
1111

1212
template(({ rotation_from = 'player' }, { create }) => {
13-
const rotationLookup = [
14-
[0.0, 0.0, 0.0],
15-
[90.0, 0.0, 0.0],
16-
[0.0, 90.0, -90.0],
17-
]
18-
create(
19-
{
20-
'bridge:block_rotation': [0, 1, 2],
21-
},
22-
'minecraft:block/description/properties'
23-
)
13+
const state = rotation_from === 'player'
14+
? 'cardinal_facing'
15+
: 'block_face';
2416

2517
create(
2618
{
27-
permutations: rotationLookup.map((rotation, i) => ({
28-
condition: `query.block_property('bridge:block_rotation') == ${i}`,
29-
components: {
30-
'minecraft:rotation': rotation,
31-
},
32-
})),
33-
},
34-
'minecraft:block'
35-
)
36-
37-
create(
38-
{
39-
'minecraft:on_player_placing': {
40-
event: 'bridge:update_rotation',
19+
'minecraft:placement_direction': {
20+
enabled_states: [
21+
`minecraft:${state}`
22+
],
23+
...(state === 'cardinal_direction' ? { y_rotation_offset: 180 } : {})
4124
},
4225
},
43-
'minecraft:block/components'
44-
)
26+
'minecraft:block/description/traits'
27+
);
4528

4629
create(
4730
{
48-
'bridge:update_rotation': {
49-
set_block_property: {
50-
'bridge:block_rotation': `math.floor(${
51-
rotation_from === 'player'
52-
? 'query.cardinal_facing'
53-
: 'query.block_face'
54-
} / 2.0)`,
31+
permutations: [
32+
// X axis
33+
{
34+
condition: `q.block_state('minecraft:${state}') == 'west' || q.block_state('minecraft:${state}') == 'east'`,
35+
components: {
36+
"minecraft:transformation": { rotation: [0, 0, 90] }
37+
}
5538
},
56-
},
39+
// Y axis
40+
{
41+
condition: `q.block_state('minecraft:${state}') == 'down' || q.block_state('minecraft:${state}') == 'up'`,
42+
components: {
43+
"minecraft:transformation": { rotation: [0, 0, 0] }
44+
}
45+
},
46+
// Z axis
47+
{
48+
condition: `q.block_state('minecraft:${state}') == 'north' || q.block_state('minecraft:${state}') == 'south'`,
49+
components: {
50+
"minecraft:transformation": { rotation: [90, 0, 0] }
51+
}
52+
}
53+
]
5754
},
58-
'minecraft:block/events'
55+
'minecraft:block'
5956
)
6057
})
6158
}
Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
const rotationLookup = new Map([
2+
['down', [-90.0, 0.0, 0.0]],
3+
['up', [90.0, 0.0, 0.0]],
4+
['north', [0.0, 0.0, 0.0]],
5+
['west', [0.0, 90.0, 0.0]],
6+
['south', [0.0, 180.0, 0.0]],
7+
['east', [0.0, -90.0, 0.0]],
8+
]);
19
export default function defineComponent({ name, template, schema }) {
210
name('bridge:rotate_on_place')
311
schema({
@@ -10,53 +18,34 @@ export default function defineComponent({ name, template, schema }) {
1018
})
1119

1220
template(({ rotation_from = 'player' }, { create }) => {
13-
const rotationLookup = [
14-
[0.0, 0.0, 0.0],
15-
[0.0, 0.0, 180.0],
16-
[90.0, 0.0, 0.0],
17-
[-90.0, 0.0, 0.0],
18-
[0.0, 0.0, -90.0],
19-
]
21+
const state = rotation_from === 'player'
22+
? 'cardinal_direction'
23+
: 'block_face';
24+
2025
create(
2126
{
22-
'bridge:block_rotation': [0, 1, 2, 3, 4, 5],
27+
'minecraft:placement_direction': {
28+
enabled_states: [
29+
`minecraft:${state}`
30+
],
31+
...(state === 'cardinal_direction' ? { y_rotation_offset: 180 } : {})
32+
},
2333
},
24-
'minecraft:block/description/properties'
25-
)
34+
'minecraft:block/description/traits'
35+
);
2636

2737
create(
2838
{
29-
permutations: rotationLookup.map((rotation, i) => ({
30-
condition: `query.block_property('bridge:block_rotation') == ${i}`,
39+
permutations: Array.from(rotationLookup.entries()).map(([name, rotation]) => ({
40+
condition: `q.block_state('minecraft:${state}') == '${name}'`,
3141
components: {
32-
'minecraft:rotation': rotation,
42+
'minecraft:transformation': {
43+
rotation,
44+
},
3345
},
3446
})),
3547
},
3648
'minecraft:block'
37-
)
38-
39-
create(
40-
{
41-
'minecraft:on_player_placing': {
42-
event: 'bridge:update_rotation',
43-
},
44-
},
45-
'minecraft:block/components'
46-
)
47-
48-
create(
49-
{
50-
'bridge:update_rotation': {
51-
set_block_property: {
52-
'bridge:block_rotation':
53-
rotation_from === 'player'
54-
? 'query.cardinal_facing'
55-
: 'query.block_face',
56-
},
57-
},
58-
},
59-
'minecraft:block/events'
60-
)
49+
);
6150
})
6251
}
Lines changed: 26 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
const rotationLookup = new Map([
2+
['north', [0.0, 0.0, 0.0]],
3+
['south', [0.0, 180.0, 0.0]],
4+
['west', [0.0, 90.0, 0.0]],
5+
['east', [0.0, -90.0, 0.0]],
6+
]);
7+
const rotationLookupFlipped = new Map([
8+
['north', [0.0, 180.0, 0.0]],
9+
['south', [0.0, 0.0, 0.0]],
10+
['west', [0.0, -90.0, 0.0]],
11+
['east', [0.0, 90.0, 0.0]],
12+
]);
113
export default function defineComponent({ name, template, schema }) {
214
name('bridge:rotate_y_on_place')
315
schema({
@@ -9,58 +21,33 @@ export default function defineComponent({ name, template, schema }) {
921
})
1022

1123
template(({ flip = false }, { create }) => {
12-
const rotationLookup = [
13-
[0.0, 0.0, 0.0],
14-
[0.0, 180.0, 0.0],
15-
[0.0, 90.0, 0.0],
16-
[0.0, 270.0, 0.0],
17-
]
18-
const rotationLookupFlipped = [
19-
[0.0, 180.0, 0.0],
20-
[0.0, 0.0, 0.0],
21-
[0.0, 270.0, 0.0],
22-
[0.0, 90.0, 0.0],
23-
]
2424
create(
2525
{
26-
'bridge:block_rotation': [2, 3, 4, 5],
26+
'minecraft:placement_direction': {
27+
enabled_states: [
28+
'minecraft:cardinal_direction'
29+
],
30+
y_rotation_offset: 180 // Face towards player
31+
},
2732
},
28-
'minecraft:block/description/properties'
29-
)
33+
'minecraft:block/description/traits'
34+
);
3035

3136
create(
3237
{
33-
permutations: (flip
38+
permutations: Array.from((flip
3439
? rotationLookupFlipped
3540
: rotationLookup
36-
).map((rotation, i) => ({
37-
condition: `query.block_property('bridge:block_rotation') == ${i + 2}`,
41+
).entries).map(([name, rotation]) => ({
42+
condition: `q.block_state('minecraft:cardinal_direction') == '${name}'`,
3843
components: {
39-
'minecraft:rotation': rotation,
44+
'minecraft:transformation': {
45+
rotation
46+
}
4047
},
4148
})),
4249
},
4350
'minecraft:block'
4451
)
45-
46-
create(
47-
{
48-
'minecraft:on_player_placing': {
49-
event: 'bridge:update_rotation',
50-
},
51-
},
52-
'minecraft:block/components'
53-
)
54-
55-
create(
56-
{
57-
'bridge:update_rotation': {
58-
set_block_property: {
59-
'bridge:block_rotation': 'query.cardinal_facing_2d',
60-
},
61-
},
62-
},
63-
'minecraft:block/events'
64-
)
6552
})
6653
}

plugins/BlockRotationV2/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"author": "Joel ant 05",
33
"name": "Simple Block Rotation",
4-
"version": "1.0.3",
4+
"version": "1.0.4",
55
"id": "b05592ed-cc3e-437c-ae7c-3f51353051bd",
6-
"description": "Adding rotation to blocks is as easy as it should be: Adding a single component! (Deprecated in MC 1.21.20)",
6+
"description": "Adding rotation to blocks is as easy as it should be: Adding a single component!",
77
"api_version": 2,
88
"target": "v2",
99
"tags": [

plugins/BlockRotationV2/plugin.zip

-2 KB
Binary file not shown.

plugins/ConnectableBlock/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Connectable Block
2+
3+
Connectable Block automates common behaviour for connectable blocks.
4+
5+
## Installation
6+
7+
After installing the plugin from bridge.'s extension store, import the script to your main scripting entry point:
8+
9+
```js
10+
import * as Connectable from 'scripts/connectable.js'
11+
```
12+
13+
## Usage
14+
15+
Add the `bridge:connectable` block component to a block. Specify settings within the component. Your block should now connect.

0 commit comments

Comments
 (0)