Skip to content

Commit 48233fc

Browse files
Merge pull request #46 from ForestOfLight/dev
v1.4.1
2 parents 90b73b3 + 3daee56 commit 48233fc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1792
-390
lines changed

Canopy [BP]/manifest.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"format_version": 2,
33
"header": {
4-
"name": "Canopy [BP] v1.4.0",
4+
"name": "Canopy [BP] v1.4.1",
55
"description": "Technical informatics & features addon by §aForestOfLight§r.",
66
"uuid": "7f6b23df-a583-476b-b0e4-87457e65f7c0",
7-
"min_engine_version": [1, 21, 90],
8-
"version": [1, 4, 0]
7+
"min_engine_version": [1, 21, 100],
8+
"version": [1, 4, 1]
99
},
1010
"modules": [
1111
{
@@ -26,7 +26,7 @@
2626
"dependencies": [
2727
{
2828
"module_name": "@minecraft/server",
29-
"version": "2.1.0-beta"
29+
"version": "2.2.0-beta"
3030
},
3131
{
3232
"module_name": "@minecraft/server-ui",
@@ -38,7 +38,7 @@
3838
},
3939
{
4040
"uuid": "bcf34368-ed0c-4cf7-938e-582cccf9950d",
41-
"version": [1, 4, 0]
41+
"version": [1, 4, 1]
4242
}
4343
],
4444
"metadata": {

Canopy [BP]/scripts/constants.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const PACK_VERSION = '1.4.0';
2-
const MC_VERSION = '1.21.90.3';
1+
const PACK_VERSION = '1.4.1';
2+
const MC_VERSION = '1.21.100.6';
33

44
export { PACK_VERSION, MC_VERSION };

Canopy [BP]/scripts/include/data.js

Lines changed: 125 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export const intToBiomeMap = {
106106
4: 'Birch Forest',
107107
5: 'Birch Forest Hills',
108108
6: 'Birch Forest Hills M',
109-
7: 'Birch Forest M',
109+
7: 'Birch Forest (Old Growth)',
110110
8: 'Cherry Grove',
111111
9: 'Cold Beach',
112112
10: 'Cold Ocean',
@@ -124,11 +124,11 @@ export const intToBiomeMap = {
124124
22: 'Desert Hills',
125125
23: 'Desert M',
126126
24: 'Dripstone Caves',
127-
25: 'Extreme Hills',
128-
26: 'Extreme Hills Edge',
129-
27: 'Extreme Hills M',
130-
28: 'Extreme Hills Plus Trees',
131-
29: 'Extreme Hills Plus Trees M',
127+
25: 'Windswept Hills',
128+
26: 'Windswept Hills Edge',
129+
27: 'Windswept Hills (Gravelly)',
130+
28: 'Windswept Forest',
131+
29: 'Windswept Forest M',
132132
30: 'Flower Forest',
133133
31: 'Forest',
134134
32: 'Forest Hills',
@@ -137,9 +137,9 @@ export const intToBiomeMap = {
137137
35: 'Frozen River',
138138
36: 'Grove',
139139
37: 'Hell',
140-
38: 'Ice Mountains',
141-
39: 'Ice Plains',
142-
40: 'Ice Plains Spikes',
140+
38: 'Snowy Mountains',
141+
39: 'Snowy Plains',
142+
40: 'Ice Spikes',
143143
41: 'Jagged Peaks',
144144
42: 'Jungle',
145145
43: 'Jungle Edge',
@@ -153,12 +153,12 @@ export const intToBiomeMap = {
153153
51: 'Meadow',
154154
52: 'Mega Taiga',
155155
53: 'Mega Taiga Hills',
156-
54: 'Mesa',
157-
55: 'Mesa Bryce',
158-
56: 'Mesa Plateau',
159-
57: 'Mesa Plateau M',
160-
58: 'Mesa Plateau Stone',
161-
59: 'Mesa Plateau Stone M',
156+
54: 'Badlands',
157+
55: 'Badlands (Eroded)',
158+
56: 'Badlands Plateau',
159+
57: 'Badlands Plateau M',
160+
58: 'Badlands (Wooded)',
161+
59: 'Badlands (Wooded) M',
162162
60: 'Mushroom Island',
163163
61: 'Mushroom Island Shore',
164164
62: 'Ocean',
@@ -169,7 +169,7 @@ export const intToBiomeMap = {
169169
67: 'Roofed Forest',
170170
68: 'Roofed Forest M',
171171
69: 'Savanna',
172-
70: 'Savanna M',
172+
70: 'Savanna (Windswept)',
173173
71: 'Savanna Plateau',
174174
72: 'Savanna Plateau M',
175175
73: 'Snowy Slopes',
@@ -186,4 +186,112 @@ export const intToBiomeMap = {
186186
84: 'Warm Ocean',
187187
85: 'Warped Forest',
188188
86: 'Pale Garden'
189-
};
189+
};
190+
191+
export const biomeToHexColorMap = {
192+
"Bamboo Jungle": '#768E14',
193+
"Bamboo Jungle Hills": '#3B470A',
194+
"Basalt Deltas": '#403636',
195+
"Beach": '#FADE55',
196+
"Birch Forest": '#307444',
197+
"Birch Forest Hills": '#1F5F32',
198+
"Birch Forest Hills M": void 0,
199+
"Birch Forest (Old Growth)": '#5a9c6d',
200+
"Cherry Grove": '#f6b9dc',
201+
"Cold Beach": '#faf0c2',
202+
"Cold Ocean": '#202070',
203+
"Cold Taiga": '#32554a',
204+
"Cold Taiga Hills": '#253f36',
205+
"Cold Taiga M": void 0,
206+
"Crimson Forest": '#DD0808',
207+
"Deep Cold Ocean": '#202038',
208+
"Deep Dark": '#000000',
209+
"Deep Frozen Ocean": '#404090',
210+
"Deep Lukewarm Ocean": '#000040',
211+
"Deep Ocean": '#000030',
212+
"Deep Warm Ocean": '#000050',
213+
"Desert": '#FA9418',
214+
"Desert Hills": '#D25F12',
215+
"Desert M": void 0,
216+
"Dripstone Caves": '#c0a590',
217+
"Windswept Hills": '#606060',
218+
"Windswept Hills Edge": void 0,
219+
"Windswept Hills (Gravelly)": '#888888',
220+
"Windswept Forest": '#24551f',
221+
"Windswept Forest M": void 0,
222+
"Flower Forest": '#2D8E49',
223+
"Forest": '#056621',
224+
"Forest Hills": void 0,
225+
"Frozen Ocean": '#7070D6',
226+
"Frozen Peaks": '#eafbfb',
227+
"Frozen River": '#A0A0FF',
228+
"Grove": '#dfece5',
229+
"Hell": '#BF3B3B',
230+
"Snowy Mountains": void 0,
231+
"Snowy Plains": '#ffffff',
232+
"Ice Spikes": '#B4DCDC',
233+
"Jagged Peaks": '#e3eced',
234+
"Jungle": '#537B09',
235+
"Jungle Edge": '#628B17',
236+
"Jungle Edge M": '#8AB33F',
237+
"Jungle Hills": '#2C4205',
238+
"Jungle M": '#7BA331',
239+
"Legacy Frozen Ocean": void 0,
240+
"Lukewarm Ocean": '#000090',
241+
"Lush Caves": '#de953d',
242+
"Mangrove Swamp": '#2ec48f',
243+
"Meadow": '#8ca472',
244+
"Mega Taiga": '#596652',
245+
"Mega Taiga Hills": void 0,
246+
"Badlands": '#D94515',
247+
"Badlands (Eroded)": '#fd6c44',
248+
"Badlands Plateau": void 0,
249+
"Badlands Plateau M": void 0,
250+
"Badlands (Wooded)": '#af9767',
251+
"Badlands (Wooded) M": void 0,
252+
"Mushroom Island": '#FF00FF',
253+
"Mushroom Island Shore": '#A000FF',
254+
"Ocean": '#000070',
255+
"Plains": '#8DB360',
256+
"Redwood Taiga Hills M": void 0,
257+
"Redwood Taiga M": '#818e7a',
258+
"River": '#0000FF',
259+
"Roofed Forest": '#40511d',
260+
"Roofed Forest M": void 0,
261+
"Savanna": '#BDB25F',
262+
"Savanna (Windswept)": '#E5DA87',
263+
"Savanna Plateau": '#A79D64',
264+
"Savanna Plateau M": '#CFC58C',
265+
"Snowy Slopes": '#dbf1f1',
266+
"Soulsand Valley": '#5E3830',
267+
"Stone Beach": '#A2A284',
268+
"Stony Peaks": '#d1d1d1',
269+
"Sunflower Plains": '#B5DB88',
270+
"Swampland": '#07F9B2',
271+
"Swampland M": '#2FFFDA',
272+
"Taiga": '#0B6659',
273+
"Taiga Hills": '#163933',
274+
"Taiga M": '#338E81',
275+
"The End": '#8080FF',
276+
"Warm Ocean": '#0000AC',
277+
"Warped Forest": '#49907B',
278+
"Pale Garden": '#6c6f95'
279+
};
280+
281+
export const HSSTypes = Object.freeze({
282+
Fortress: 'fortress',
283+
OceanMonument: 'ocean_monument',
284+
Outpost: 'outpost',
285+
WitchHut: 'witch_hut'
286+
});
287+
288+
export const mobTypeToHSSMap = {
289+
'minecraft:blaze': HSSTypes.Fortress,
290+
'minecraft:guardian': HSSTypes.OceanMonument,
291+
'minecraft:magma_cube': HSSTypes.Fortress,
292+
'minecraft:pillager': HSSTypes.Outpost,
293+
'minecraft:skeleton': HSSTypes.Fortress,
294+
'minecraft:witch': HSSTypes.WitchHut,
295+
'minecraft:wither_skeleton': HSSTypes.Fortress,
296+
'minecraft:zombie_pigman': HSSTypes.Fortress
297+
}

Canopy [BP]/scripts/include/utils.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,4 +271,14 @@ export function getNameFromEntityId(id) {
271271
throw error;
272272
}
273273
return entityName;
274+
}
275+
276+
export function hexToRGB(hex) {
277+
hex = hex.replace(/^#/, '');
278+
const num = parseInt(hex, 16);
279+
return {
280+
red: ((num >> 16) & 0xFF) / 255,
281+
green: ((num >> 8) & 0xFF) / 255,
282+
blue: (num & 0xFF) / 255
283+
};
274284
}

Canopy [BP]/scripts/lib/SRCItemDatabase/ItemDatabase.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class SRCItemDatabase {
8383
const newId = this.table + key, existingStructure = world.structureManager.get(newId), location = SRCItemDatabase.location;
8484
if (existingStructure) {
8585
world.structureManager.delete(newId);
86-
itemMemory.delete(newId)
86+
itemMemory.delete(newId);
8787
const structureIds = Array.from(Databases.structureIds.get(this.table) ?? []);
8888
Databases.structureIds.set(this.table, structureIds.filter(id => id !== newId));
8989
};

Canopy [BP]/scripts/lib/Vector.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ Vector.multiply = function multiply(vec, num) {
2121
if (typeof num == "number") return { x: vec.x * num, y: vec.y * num, z: vec.z * num, __proto__: Vector.prototype };
2222
return { x: vec.x * num.x, y: vec.y * num.y, z: vec.z * num.z, __proto__: Vector.prototype };
2323
}
24+
Vector.divide = function divide(vec, num) {
25+
if (typeof num == "number") return { x: vec.x / num, y: vec.y / num, z: vec.z / num, __proto__: Vector.prototype };
26+
return { x: vec.x / num.x, y: vec.y / num.y, z: vec.z / num.z, __proto__: Vector.prototype };
27+
}
2428
Vector.isVec3 = function isVec3(vec) { return vec[isVec3Symbol] === true; }
2529
Vector.floor = function floor(vec) { return { x: Math.floor(vec.x), y: Math.floor(vec.y), z: Math.floor(vec.z), __proto__: Vector.prototype }; }
2630
Vector.projection = function projection(a, b) { return Vector.multiply(b, Vector.dot(a, b) / ((b.x * b.x + b.y * b.y + b.z * b.z) ** 2)); }
@@ -59,6 +63,7 @@ Vector.prototype = {
5963
add(vec) { return Vector.add(this, vec); },
6064
subtract(vec) { return Vector.subtract(this, vec); },
6165
multiply(num) { return Vector.multiply(this, num); },
66+
divide(num) { return Vector.divide(this, num); },
6267
get length() { return Vector.magnitude(this); },
6368
get normalized() { return Vector.normalize(this); },
6469
x: 0,

Canopy [BP]/scripts/lib/canopy/AbilityRule.js

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { GlobalRule } from "./GlobalRule";
2-
import { EntityComponentTypes, world } from "@minecraft/server";
2+
import { EntityComponentTypes, system, world } from "@minecraft/server";
33

44
const DEFAULT_ACTION_ITEM = "minecraft:arrow";
55

66
export class AbilityRule extends GlobalRule {
77
activePlayerIds = new Set();
8+
playerJoinTick = {};
89

910
constructor(ruleOptions, { slotNumber, actionItem = DEFAULT_ACTION_ITEM, onPlayerEnableCallback = () => {}, onPlayerDisableCallback = () => {} } = {}) {
1011
super({ ...ruleOptions });
@@ -20,29 +21,37 @@ export class AbilityRule extends GlobalRule {
2021
onActionSlotItemChange(event) {
2122
if (!event.player)
2223
return;
24+
const player = event.player;
25+
const options = { isSilent: false };
26+
if (this.playerJoinTick[player.id] === system.currentTick)
27+
options.isSilent = true;
2328
if (event.itemStack?.typeId === this.actionItemId)
24-
this.enableForPlayer(event.player);
29+
this.enableForPlayer(player, options);
2530
else if (event.beforeItemStack?.typeId === this.actionItemId)
26-
this.disableForPlayer(event.player);
31+
this.disableForPlayer(player, options);
2732
}
2833

29-
enableForPlayer(player) {
34+
enableForPlayer(player, { isSilent = true } = {}) {
3035
this.activePlayerIds.add(player?.id);
31-
player.onScreenDisplay.setActionBar({ rawtext: [
32-
{ translate: 'rules.generic.ability' },
33-
{ translate: 'rules.generic.enabled' },
34-
{ text: `§7: ${this.getID()}` }
35-
]});
36+
if (!isSilent) {
37+
player.onScreenDisplay.setActionBar({ rawtext: [
38+
{ translate: 'rules.generic.ability' },
39+
{ translate: 'rules.generic.enabled' },
40+
{ text: `§7: ${this.getID()}` }
41+
]});
42+
}
3643
this.onPlayerEnable(player);
3744
}
3845

39-
disableForPlayer(player) {
46+
disableForPlayer(player, { isSilent = true } = {}) {
4047
this.activePlayerIds.delete(player?.id);
41-
player.onScreenDisplay.setActionBar({ rawtext: [
42-
{ translate: 'rules.generic.ability' },
43-
{ translate: 'rules.generic.disabled' },
44-
{ text: `§7: ${this.getID()}` }
45-
]});
48+
if (!isSilent) {
49+
player.onScreenDisplay.setActionBar({ rawtext: [
50+
{ translate: 'rules.generic.ability' },
51+
{ translate: 'rules.generic.disabled' },
52+
{ text: `§7: ${this.getID()}` }
53+
]});
54+
}
4655
this.onPlayerDisable(player);
4756
}
4857

@@ -64,7 +73,7 @@ export class AbilityRule extends GlobalRule {
6473
world.getAllPlayers().forEach((player) => {
6574
if (!player)
6675
return;
67-
if (this.isActionItemInActionSlot(player))
76+
if (this.isActionItemInActionSlot(player) && this.getNativeValue() === true)
6877
this.enableForPlayer(player);
6978
else
7079
this.disableForPlayer(player);
@@ -73,11 +82,11 @@ export class AbilityRule extends GlobalRule {
7382

7483
onEnableWithAdditions(ruleOptions) {
7584
return () => {
76-
this.refreshOnlinePlayers();
77-
world.afterEvents.playerInventoryItemChange.subscribe(
78-
this.onActionSlotItemChangeBound,
79-
{ allowedSlots: [this.slotNumber], ignoreQuantityChange: true }
80-
);
85+
this.refreshOnlinePlayers();
86+
const itemChangeOptions = { allowedSlots: [this.slotNumber], ignoreQuantityChange: true };
87+
world.afterEvents.playerInventoryItemChange.subscribe(this.onActionSlotItemChangeBound, itemChangeOptions);
88+
world.afterEvents.playerJoin.subscribe(this.onPlayerJoin.bind(this));
89+
world.beforeEvents.playerLeave.subscribe(this.onPlayerLeave.bind(this));
8190
ruleOptions.onEnableCallback();
8291
}
8392
}
@@ -86,7 +95,21 @@ export class AbilityRule extends GlobalRule {
8695
return () => {
8796
this.refreshOnlinePlayers();
8897
world.afterEvents.playerInventoryItemChange.unsubscribe(this.onActionSlotItemChangeBound);
98+
world.afterEvents.playerJoin.unsubscribe(this.onPlayerJoin.bind(this));
99+
world.beforeEvents.playerLeave.unsubscribe(this.onPlayerLeave.bind(this));
89100
ruleOptions.onDisableCallback();
90101
}
91102
}
103+
104+
onPlayerJoin(event) {
105+
this.playerJoinTick[event.playerId] = system.currentTick;
106+
}
107+
108+
onPlayerLeave(event) {
109+
if (!event.player)
110+
return;
111+
system.run(() => {
112+
this.disableForPlayer(event.player);
113+
});
114+
}
92115
}

Canopy [BP]/scripts/lib/canopy/Rule.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ class Rule {
6969
if (this.#extension) {
7070
this.#extension.setRuleValue(this.#identifier, value);
7171
} else {
72+
world.setDynamicProperty(this.#identifier, value);
7273
if (value === true)
7374
this.onEnable();
7475
else if (value === false)
7576
this.onDisable();
76-
world.setDynamicProperty(this.#identifier, value);
7777
}
7878
}
7979

0 commit comments

Comments
 (0)