BlueGit

timfa questward

Add silk cocoon herbalism nodes for silk fibre.

Cocoons need adamantium-or-better plant clippers and drop raw silk; dragonweave stays a future dragon drop.

timfa Tim Falken · pushed by timfa

Authored 2026-08-31 · 2 months ago

Hash
c28781cbdb3d0756881c7c890192e34ec067ce7b
Parent
5d5a8ff5
7 files changed +74 −5
client/assets/blocks/silk-cocoon/silk-cocoon.png added Binary file +0 −0

The contents of this binary file are not shown.

server/src/gathering/service.js +6 −0
@@ -716,6 +716,10 @@ function completePlant (world, handle, entityId, character, gather, events, priv
716 716 {
717 717 itemId = rawClothItemId(ClothTier.linen);
718 718 }
719 else if (gather.plantKind === "silk")
720 {
721 itemId = rawClothItemId(ClothTier.silk);
722 }
719 723 else if (gather.plantKind === "herb")
720 724 {
721 725 const herb = herbDefinition(gather.herbId);
@@ -905,5 +909,7 @@ function defaultPlantState (typeId)
905 909 { return "mint"; }
906 910 if (typeId === BlockType.flaxPlant)
907 911 { return "flax-plant"; }
912 if (typeId === BlockType.silkCocoon)
913 { return "silk-cocoon"; }
908 914 return "cotton-plant";
909 915 }
@@ -716,6 +716,10 @@ function completePlant (world, handle, entityId, character, gather, events, priv
716 {
716 {
717 itemId = rawClothItemId(ClothTier.linen);
717 itemId = rawClothItemId(ClothTier.linen);
718 }
718 }
719 else if (gather.plantKind === "silk")
720 {
721 itemId = rawClothItemId(ClothTier.silk);
722 }
719 else if (gather.plantKind === "herb")
723 else if (gather.plantKind === "herb")
720 {
724 {
721 const herb = herbDefinition(gather.herbId);
725 const herb = herbDefinition(gather.herbId);
@@ -905,5 +909,7 @@ function defaultPlantState (typeId)
905 { return "mint"; }
909 { return "mint"; }
906 if (typeId === BlockType.flaxPlant)
910 if (typeId === BlockType.flaxPlant)
907 { return "flax-plant"; }
911 { return "flax-plant"; }
912 if (typeId === BlockType.silkCocoon)
913 { return "silk-cocoon"; }
908 return "cotton-plant";
914 return "cotton-plant";
909}
915}
server/tests/shearing.test.js +26 −0
@@ -149,6 +149,32 @@ test("flax needs steel-or-better clippers; linen fibre is named Flax", () =>
149 149 assert.equal(plant.minClothTier, "linen");
150 150 });
151 151
152 test("silk cocoons need adamantium-or-better clippers", () =>
153 {
154 assert.equal(metalTierForCloth(ClothTier.silk), MaterialTier.adamantium);
155 assert.match(itemDefinition(ClothItemId.silk).description, /cocoon/i);
156 const skills = normalizePlayerSkills(null);
157 skills.xp[SkillId.herbalism] = totalXpForLevel(50);
158 const mithril = resolvePlantClippers({
159 inventorySlots: [{ itemId: MetalItemId.mithrilPlantClippers, quantity: 1 }],
160 equipmentSlots: emptyEquipment().slots,
161 skills,
162 minClothTier: ClothTier.silk
163 });
164 assert.equal(mithril.ok, false);
165 const adamantium = resolvePlantClippers({
166 inventorySlots: [{ itemId: MetalItemId.adamantiumPlantClippers, quantity: 1 }],
167 equipmentSlots: emptyEquipment().slots,
168 skills,
169 minClothTier: ClothTier.silk
170 });
171 assert.equal(adamantium.ok, true);
172 const plant = plantGatherForBlock({ typeId: BlockType.silkCocoon, state: "silk-cocoon" });
173 assert.equal(plant.kind, "silk");
174 assert.equal(plant.requiresClippers, true);
175 assert.equal(plant.minClothTier, "silk");
176 });
177
152 178 test("shearing a sheep grants wool and sets shorn state", () =>
153 179 {
154 180 const harness = makeSimulation({ workerCount: 1 });
@@ -149,6 +149,32 @@ test("flax needs steel-or-better clippers; linen fibre is named Flax", () =>
149 assert.equal(plant.minClothTier, "linen");
149 assert.equal(plant.minClothTier, "linen");
150});
150});
151
151
152test("silk cocoons need adamantium-or-better clippers", () =>
153{
154 assert.equal(metalTierForCloth(ClothTier.silk), MaterialTier.adamantium);
155 assert.match(itemDefinition(ClothItemId.silk).description, /cocoon/i);
156 const skills = normalizePlayerSkills(null);
157 skills.xp[SkillId.herbalism] = totalXpForLevel(50);
158 const mithril = resolvePlantClippers({
159 inventorySlots: [{ itemId: MetalItemId.mithrilPlantClippers, quantity: 1 }],
160 equipmentSlots: emptyEquipment().slots,
161 skills,
162 minClothTier: ClothTier.silk
163 });
164 assert.equal(mithril.ok, false);
165 const adamantium = resolvePlantClippers({
166 inventorySlots: [{ itemId: MetalItemId.adamantiumPlantClippers, quantity: 1 }],
167 equipmentSlots: emptyEquipment().slots,
168 skills,
169 minClothTier: ClothTier.silk
170 });
171 assert.equal(adamantium.ok, true);
172 const plant = plantGatherForBlock({ typeId: BlockType.silkCocoon, state: "silk-cocoon" });
173 assert.equal(plant.kind, "silk");
174 assert.equal(plant.requiresClippers, true);
175 assert.equal(plant.minClothTier, "silk");
176});
177
152test("shearing a sheep grants wool and sets shorn state", () =>
178test("shearing a sheep grants wool and sets shorn state", () =>
153{
179{
154 const harness = makeSimulation({ workerCount: 1 });
180 const harness = makeSimulation({ workerCount: 1 });
shared/definitions/clothItems.js +10 −3
@@ -167,6 +167,8 @@ function rawLabel (tier)
167 167 { return "Cotton"; }
168 168 if (tier === ClothTier.linen)
169 169 { return "Flax"; }
170 if (tier === ClothTier.silk)
171 { return "Silk"; }
170 172 return CLOTH_DISPLAY_NAME[tier] ?? tier;
171 173 }
172 174
@@ -176,13 +178,18 @@ function fibreDef (itemId, tier, key)
176 178 const spinHint = tier === ClothTier.linen
177 179 ? "Spin into linen yarn at a spinning wheel."
178 180 : `Spin into yarn at a spinning wheel.`;
181 let description;
182 if (tier === ClothTier.linen)
183 { description = `Harvested flax stems. ${spinHint}`; }
184 else if (tier === ClothTier.silk)
185 { description = `Soft fibre drawn from a cocoon. ${spinHint}`; }
186 else
187 { description = `Raw ${name.toLowerCase()} fibre. ${spinHint}`; }
179 188 return Object.freeze({
180 189 itemId,
181 190 key,
182 191 displayName: name,
183 description: tier === ClothTier.linen
184 ? `Harvested flax stems. ${spinHint}`
185 : `Raw ${name.toLowerCase()} fibre. ${spinHint}`,
192 description,
186 193 seedValue: 2,
187 194 stackable: true,
188 195 maxStackSize: DEFAULT_STACK,
@@ -167,6 +167,8 @@ function rawLabel (tier)
167 { return "Cotton"; }
167 { return "Cotton"; }
168 if (tier === ClothTier.linen)
168 if (tier === ClothTier.linen)
169 { return "Flax"; }
169 { return "Flax"; }
170 if (tier === ClothTier.silk)
171 { return "Silk"; }
170 return CLOTH_DISPLAY_NAME[tier] ?? tier;
172 return CLOTH_DISPLAY_NAME[tier] ?? tier;
171}
173}
172
174
@@ -176,13 +178,18 @@ function fibreDef (itemId, tier, key)
176 const spinHint = tier === ClothTier.linen
178 const spinHint = tier === ClothTier.linen
177 ? "Spin into linen yarn at a spinning wheel."
179 ? "Spin into linen yarn at a spinning wheel."
178 : `Spin into yarn at a spinning wheel.`;
180 : `Spin into yarn at a spinning wheel.`;
181 let description;
182 if (tier === ClothTier.linen)
183 { description = `Harvested flax stems. ${spinHint}`; }
184 else if (tier === ClothTier.silk)
185 { description = `Soft fibre drawn from a cocoon. ${spinHint}`; }
186 else
187 { description = `Raw ${name.toLowerCase()} fibre. ${spinHint}`; }
179 return Object.freeze({
188 return Object.freeze({
180 itemId,
189 itemId,
181 key,
190 key,
182 displayName: name,
191 displayName: name,
183 description: tier === ClothTier.linen
192 description,
184 ? `Harvested flax stems. ${spinHint}`
185 : `Raw ${name.toLowerCase()} fibre. ${spinHint}`,
186 seedValue: 2,
193 seedValue: 2,
187 stackable: true,
194 stackable: true,
188 maxStackSize: DEFAULT_STACK,
195 maxStackSize: DEFAULT_STACK,
shared/definitions/gathering.js +7 −0
@@ -385,6 +385,11 @@ export function herbalismDurationMs (plantKind = null, toolTier = null, herbTier
385 385 const rank = toolTier ? tierRank(toolTier) : 1;
386 386 return Math.max(800, 2200 - (rank - 1) * 200);
387 387 }
388 if (plantKind === "silk")
389 {
390 const rank = toolTier ? tierRank(toolTier) : 1;
391 return Math.max(900, 2800 - (rank - 1) * 200);
392 }
388 393 const rank = toolTier ? tierRank(toolTier) : 1;
389 394 return Math.max(500, 2500 - (rank - 1) * 250);
390 395 }
@@ -397,6 +402,8 @@ export function herbalismXpForPick (kind, herbTier = null)
397 402 { return 4 + Math.max(1, herbTier | 0 || 1) * 2; }
398 403 if (kind === "flax")
399 404 { return 5; }
405 if (kind === "silk")
406 { return 8; }
400 407 return 3;
401 408 }
402 409
@@ -385,6 +385,11 @@ export function herbalismDurationMs (plantKind = null, toolTier = null, herbTier
385 const rank = toolTier ? tierRank(toolTier) : 1;
385 const rank = toolTier ? tierRank(toolTier) : 1;
386 return Math.max(800, 2200 - (rank - 1) * 200);
386 return Math.max(800, 2200 - (rank - 1) * 200);
387 }
387 }
388 if (plantKind === "silk")
389 {
390 const rank = toolTier ? tierRank(toolTier) : 1;
391 return Math.max(900, 2800 - (rank - 1) * 200);
392 }
388 const rank = toolTier ? tierRank(toolTier) : 1;
393 const rank = toolTier ? tierRank(toolTier) : 1;
389 return Math.max(500, 2500 - (rank - 1) * 250);
394 return Math.max(500, 2500 - (rank - 1) * 250);
390}
395}
@@ -397,6 +402,8 @@ export function herbalismXpForPick (kind, herbTier = null)
397 { return 4 + Math.max(1, herbTier | 0 || 1) * 2; }
402 { return 4 + Math.max(1, herbTier | 0 || 1) * 2; }
398 if (kind === "flax")
403 if (kind === "flax")
399 { return 5; }
404 { return 5; }
405 if (kind === "silk")
406 { return 8; }
400 return 3;
407 return 3;
401}
408}
402
409
shared/definitions/tierFamilies.js +1 −1
@@ -230,7 +230,7 @@ export const ITEM_FAMILIES = Object.freeze({
230 230 familyId: ItemFamilyId.plantClippers,
231 231 axis: TierAxis.metal,
232 232 label: "plant clippers",
233 description: () => "Sharp clippers for cutting herbs, flax, and blooms.",
233 description: () => "Sharp clippers for cutting herbs, flax, cocoons, and blooms.",
234 234 category: ItemCategory.tool,
235 235 iconKey: "plant-clippers",
236 236 defaultState: "plant-clippers",
@@ -230,7 +230,7 @@ export const ITEM_FAMILIES = Object.freeze({
230 familyId: ItemFamilyId.plantClippers,
230 familyId: ItemFamilyId.plantClippers,
231 axis: TierAxis.metal,
231 axis: TierAxis.metal,
232 label: "plant clippers",
232 label: "plant clippers",
233 description: () => "Sharp clippers for cutting herbs, flax, and blooms.",
233 description: () => "Sharp clippers for cutting herbs, flax, cocoons, and blooms.",
234 category: ItemCategory.tool,
234 category: ItemCategory.tool,
235 iconKey: "plant-clippers",
235 iconKey: "plant-clippers",
236 defaultState: "plant-clippers",
236 defaultState: "plant-clippers",
shared/definitions/tiles.js +24 −1
@@ -73,7 +73,8 @@ export const BlockType = Object.freeze({
73 73 oven: 32,
74 74 fishingSpot: 33,
75 75 jeweleringStation: 34,
76 flaxPlant: 35
76 flaxPlant: 35,
77 silkCocoon: 36
77 78 });
78 79
79 80 export const GROUND_DEFINITIONS = Object.freeze({
@@ -448,6 +449,26 @@ export const BLOCK_DEFINITIONS = Object.freeze({
448 449 skillId: "herbalism"
449 450 })
450 451 }),
452 [BlockType.silkCocoon]: Object.freeze({
453 id: BlockType.silkCocoon,
454 key: "silk-cocoon",
455 displayName: "Silk cocoon",
456 passable: true,
457 blocksLight: false,
458 lightRangeTiles: 0,
459 frames: 1,
460 framesPerRow: 1,
461 animationSpeed: 0,
462 outdoor: true,
463 gatherable: true,
464 plantGather: Object.freeze({
465 kind: "silk",
466 requiresClippers: true,
467 /** Silk-rank clippers or better (adamantium↔silk). */
468 minClothTier: "silk",
469 skillId: "herbalism"
470 })
471 }),
451 472 [BlockType.spinningWheel]: Object.freeze({
452 473 id: BlockType.spinningWheel,
453 474 key: "spinning-wheel",
@@ -613,6 +634,8 @@ export function resourceNodeDisplayName (block)
613 634 { return "Cotton plant"; }
614 635 if (block.typeId === BlockType.flaxPlant)
615 636 { return "Flax plant"; }
637 if (block.typeId === BlockType.silkCocoon)
638 { return "Silk cocoon"; }
616 639 if (block.typeId === BlockType.herbPlant)
617 640 {
618 641 const herb = herbDefinition(block.state);
@@ -73,7 +73,8 @@ export const BlockType = Object.freeze({
73 oven: 32,
73 oven: 32,
74 fishingSpot: 33,
74 fishingSpot: 33,
75 jeweleringStation: 34,
75 jeweleringStation: 34,
76 flaxPlant: 35
76 flaxPlant: 35,
77 silkCocoon: 36
77});
78});
78
79
79export const GROUND_DEFINITIONS = Object.freeze({
80export const GROUND_DEFINITIONS = Object.freeze({
@@ -448,6 +449,26 @@ export const BLOCK_DEFINITIONS = Object.freeze({
448 skillId: "herbalism"
449 skillId: "herbalism"
449 })
450 })
450 }),
451 }),
452 [BlockType.silkCocoon]: Object.freeze({
453 id: BlockType.silkCocoon,
454 key: "silk-cocoon",
455 displayName: "Silk cocoon",
456 passable: true,
457 blocksLight: false,
458 lightRangeTiles: 0,
459 frames: 1,
460 framesPerRow: 1,
461 animationSpeed: 0,
462 outdoor: true,
463 gatherable: true,
464 plantGather: Object.freeze({
465 kind: "silk",
466 requiresClippers: true,
467 /** Silk-rank clippers or better (adamantium↔silk). */
468 minClothTier: "silk",
469 skillId: "herbalism"
470 })
471 }),
451 [BlockType.spinningWheel]: Object.freeze({
472 [BlockType.spinningWheel]: Object.freeze({
452 id: BlockType.spinningWheel,
473 id: BlockType.spinningWheel,
453 key: "spinning-wheel",
474 key: "spinning-wheel",
@@ -613,6 +634,8 @@ export function resourceNodeDisplayName (block)
613 { return "Cotton plant"; }
634 { return "Cotton plant"; }
614 if (block.typeId === BlockType.flaxPlant)
635 if (block.typeId === BlockType.flaxPlant)
615 { return "Flax plant"; }
636 { return "Flax plant"; }
637 if (block.typeId === BlockType.silkCocoon)
638 { return "Silk cocoon"; }
616 if (block.typeId === BlockType.herbPlant)
639 if (block.typeId === BlockType.herbPlant)
617 {
640 {
618 const herb = herbDefinition(block.state);
641 const herb = herbDefinition(block.state);