Skip to content

Commit

Permalink
Add "punch to activate" subpack
Browse files Browse the repository at this point in the history
- In this subpack, armour stands won't show anything unless punched, posed, or given an item.
- Made pack name untranslatable
- Add creaking heart texture variants for a future update
  • Loading branch information
SuperLlama88888 committed Jan 8, 2025
1 parent b977363 commit 635d793
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 10 deletions.
35 changes: 29 additions & 6 deletions HoloPrint.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export async function makePack(structureFiles, config = {}, resourcePackStack, p
resources: {
entityFile: "entity/armor_stand.entity.json",
defaultPlayerRenderControllers: "render_controllers/player.render_controllers.json",
armorStandGeo: "models/entity/armor_stand.geo.json", // for visible bounds. I don't think we need this
armorStandGeo: "models/entity/armor_stand.geo.json", // for visible bounds. we need this even though the hologram geometry has a different identifier.
translationFile: `texts/${config.MATERIAL_LIST_LANGUAGE}.lang`
},
otherFiles: {
Expand Down Expand Up @@ -430,20 +430,22 @@ export async function makePack(structureFiles, config = {}, resourcePackStack, p
entityDescription["animations"]["hologram.offset"] = "animation.armor_stand.hologram.offset";
entityDescription["animations"]["hologram.spawn"] = "animation.armor_stand.hologram.spawn";
entityDescription["animations"]["hologram.wrong_block_overlay"] = "animation.armor_stand.hologram.wrong_block_overlay";
entityDescription["animations"]["controller.hologram.spawn_animation"] = "controller.animation.armor_stand.hologram.spawn_animation";
entityDescription["animations"]["controller.hologram.layers"] = "controller.animation.armor_stand.hologram.layers";
entityDescription["animations"]["controller.hologram.bounding_box"] = "controller.animation.armor_stand.hologram.bounding_box";
entityDescription["animations"]["controller.hologram.block_validation"] = "controller.animation.armor_stand.hologram.block_validation";
entityDescription["scripts"]["animate"] ??= [];
entityDescription["scripts"]["animate"].push("hologram.align", "hologram.offset", "hologram.spawn", "hologram.wrong_block_overlay", "controller.hologram.layers", "controller.hologram.bounding_box", "controller.hologram.block_validation");
entityDescription["scripts"]["animate"].push("hologram.align", "hologram.offset", "hologram.wrong_block_overlay", "controller.hologram.spawn_animation", "controller.hologram.layers", "controller.hologram.bounding_box", "controller.hologram.block_validation");
entityDescription["scripts"]["initialize"] ??= [];
entityDescription["scripts"]["initialize"].push(functionToMolang((v, structureSize, singleLayerMode, structureCount) => {
entityDescription["scripts"]["initialize"].push(functionToMolang((v, structureSize, singleLayerMode, structureCount, HOLOGRAM_INITIAL_ACTIVATION) => {
v.hologram_activated = HOLOGRAM_INITIAL_ACTIVATION; // true/false are substituted in here for the different subpacks
v.hologram_offset_x = 0;
v.hologram_offset_y = 0;
v.hologram_offset_z = 0;
v.structure_w = $[structureSize[0]];
v.structure_h = $[structureSize[1]];
v.structure_d = $[structureSize[2]];
v.render_hologram = true;
v.render_hologram = HOLOGRAM_INITIAL_ACTIVATION;
v.hologram_texture_index = $[defaultTextureIndex];
v.show_tint = false;
v.hologram_layer = -1;
Expand Down Expand Up @@ -471,7 +473,27 @@ export async function makePack(structureFiles, config = {}, resourcePackStack, p
}));
entityDescription["scripts"]["pre_animation"] ??= [];
entityDescription["scripts"]["pre_animation"].push(functionToMolang((v, q, t, textureBlobsCount, totalBlocksToValidate, toggleRendering, changeOpacity, toggleTint, toggleValidating, changeLayer, decreaseLayer, changeLayerMode, disablePlayerControls, singleLayerMode) => {
v.last_pose ??= v.armor_stand.pose_index;
v.hologram_dir = Math.floor(q.body_y_rotation / 90) + 2; // [south, west, north, east] (since it goes from -180 to 180)
if(!v.hologram_activated) { // even though the subpack is called "punch to activate", changing the pose or giving an item will work as well
t.activate_hologram = false;
if(v.last_hurt_direction != q.hurt_direction) {
v.last_hurt_direction = q.hurt_direction;
t.activate_hologram = true;
} else if(v.last_pose != v.armor_stand.pose_index) {
v.last_pose = v.armor_stand.pose_index;
t.activate_hologram = true;
} else if(v.last_held_item != q.get_equipped_item_name) {
v.last_held_item = q.get_equipped_item_name;
t.activate_hologram = true;
}
if(t.activate_hologram) {
v.hologram_activated = true;
v.render_hologram = true;
} else {
return 0;
}
}

t.process_action = false; // this is the only place I'm using temp variables for their intended purpose
t.action = "";
Expand All @@ -489,7 +511,6 @@ export async function makePack(structureFiles, config = {}, resourcePackStack, p
}
}

v.last_pose ??= v.armor_stand.pose_index;
if(v.last_pose != v.armor_stand.pose_index) {
v.last_pose = v.armor_stand.pose_index;
if(v.render_hologram) {
Expand Down Expand Up @@ -711,6 +732,7 @@ export async function makePack(structureFiles, config = {}, resourcePackStack, p
})));
hudScreenUI["material_list"]["size"][1] = finalisedMaterialList.length * 12 + 12; // 12px for each item + 12px for the heading

manifest["header"]["name"] = packName;
manifest["header"]["uuid"] = crypto.randomUUID();
manifest["modules"][0]["uuid"] = crypto.randomUUID();
if(config.AUTHORS.length) {
Expand Down Expand Up @@ -767,7 +789,8 @@ export async function makePack(structureFiles, config = {}, resourcePackStack, p
}
pack.file("manifest.json", JSON.stringify(manifest));
pack.file("pack_icon.png", packIcon);
pack.file("entity/armor_stand.entity.json", JSON.stringify(entityFile));
pack.file("entity/armor_stand.entity.json", JSON.stringify(entityFile).replaceAll("HOLOGRAM_INITIAL_ACTIVATION", true));
pack.file("subpacks/punch_to_activate/entity/armor_stand.entity.json", JSON.stringify(entityFile).replaceAll("HOLOGRAM_INITIAL_ACTIVATION", false));
pack.file("render_controllers/armor_stand.hologram.render_controllers.json", JSON.stringify(hologramRenderControllers));
pack.file("render_controllers/player.render_controllers.json", JSON.stringify(playerRenderControllers));
pack.file("models/entity/armor_stand.geo.json", JSON.stringify(armorStandGeo));
Expand Down
7 changes: 6 additions & 1 deletion data/blockStateDefinitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@
"age": [0, 1, 2, 3]
},
"creaking_heart": {
"active": [0, 1]
"active": [0, 1],
"creaking_heart_state": { // added in 1.21.60.25 to replace active
"uprooted": 0,
"dormant": 1,
"awake": 2
}
},
"vault": {
"#exclusive_add": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
{
"format_version": "1.10.0",
"animation_controllers": {
"controller.animation.armor_stand.hologram.spawn_animation": {
"initial_state": "default",
"states": {
"default": {
"transitions": [
{
"animate": "v.hologram_activated"
}
]
},
"animate": {
"animations": ["hologram.spawn"]
}
}
},
"controller.animation.armor_stand.hologram.layers": {
"initial_state": "default",
"states": {
Expand Down
13 changes: 12 additions & 1 deletion packTemplate/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"format_version": 2,
"header": {
"name": "pack.name",
"description": "pack.description",
"version": [1, 0, 0],
"min_engine_version": [1, 16, 0]
Expand All @@ -12,6 +11,18 @@
"version": [1, 0, 0]
}
],
"subpacks": [
{
"folder_name": "punch_to_activate",
"name": "Punch to activate", // like below, translations for these won't be loaded until after the pack is enabled...
"memory_tier": 0
},
{
"folder_name": "default",
"name": "Default",
"memory_tier": 0
}
],
"settings": [
{
"type": "input",
Expand Down
1 change: 0 additions & 1 deletion packTemplate/texts/en_US.lang
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pack.name={PACK_NAME}
pack.description=§u★HoloPrint§r resource pack generated on §o{PACK_GENERATION_TIME}§r\nDeveloped by §l§6SuperLlama88888§r{AUTHORS_SECTION}{DESCRIPTION_SECTION}{CONTROLS_SECTION}\n\n§lTotal block count: {TOTAL_MATERIAL_COUNT}\n§r{MATERIAL_LIST} ## ★ at the start forces unicode font which makes it smaller so more text fits in
pack.description.authors=\nStructure made by {STRUCTURE_AUTHORS[ and ]} ## Authors/Description/Controls will be substituted into the actual description by the JS
pack.description.description=\n{DESCRIPTION}
Expand Down
1 change: 0 additions & 1 deletion packTemplate/texts/zh_CN.lang
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pack.name={PACK_NAME}
pack.description=§u★全息打印§r 资源包生成于 §o{PACK_GENERATION_TIME}§r\n开发者: §l§6SuperLlama88888§r{AUTHORS_SECTION}{DESCRIPTION_SECTION}{CONTROLS_SECTION}\n\n§l总方块数: {TOTAL_MATERIAL_COUNT}\n§r{MATERIAL_LIST} ## ★ at the start forces unicode font which makes it smaller so more text fits in
pack.description.authors=\n结构作者: {STRUCTURE_AUTHORS[ and ]} ## Authors/Description/Controls will be substituted into the actual description by the JS
pack.description.description=\n{DESCRIPTION}
Expand Down

0 comments on commit 635d793

Please sign in to comment.