Skip to content

Commit

Permalink
Merge pull request #48 from cxtch/master
Browse files Browse the repository at this point in the history
Read from defaults.json
  • Loading branch information
Heath123 authored Dec 13, 2021
2 parents 9ef9c6e + b7a2921 commit 94e01c8
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
7 changes: 0 additions & 7 deletions html/mainPage/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,6 @@ <h3>Filtering</h3>
</button>
</div>
<div id="extendedPresets">
<!-- TODO: Read from defaults.json -->
<button onclick="sharedVars.hiddenPackets = {
serverbound: ['query_block_nbt','set_difficulty','client_command','settings','tab_complete','transaction','enchant_item','window_click','close_window','custom_payload','edit_book','query_entity_nbt','use_entity','generate_structure','keep_alive','lock_difficulty','pick_item','craft_recipe_request','block_dig','entity_action','steer_vehicle','displayed_recipe','recipe_book','name_item','resource_pack_receive','advancement_tab','select_trade','set_beacon_effect','held_item_slot','update_command_block','update_command_block_minecart','set_creative_slot','update_jigsaw_block','update_structure_block','update_sign','arm_animation','spectate','block_place','use_item'],
clientbound: ['spawn_entity','spawn_entity_experience_orb','spawn_entity_living','spawn_entity_painting','named_entity_spawn','animation','statistics','acknowledge_player_digging','block_break_animation','tile_entity_data','block_action','block_change','boss_bar','difficulty','tab_complete','declare_commands','transaction','close_window','window_items','craft_progress_bar','set_slot','set_cooldown','custom_payload','named_sound_effect','kick_disconnect','entity_status','explosion','unload_chunk','game_state_change','open_horse_window','keep_alive','map_chunk','world_event','world_particles','update_light','login','map','trade_list','rel_entity_move','entity_move_look','entity_look','entity','open_book','open_window','open_sign_entity','craft_recipe_response','abilities','combat_event','unlock_recipes','entity_destroy','remove_entity_effect','resource_pack_send','entity_head_rotation','multi_block_change','select_advancement_tab','world_border','camera','held_item_slot','update_view_position','update_view_distance','scoreboard_display_objective','entity_metadata','attach_entity','entity_velocity','entity_equipment','experience','update_health','scoreboard_objective','set_passengers','teams','scoreboard_score','update_time','title','entity_sound_effect','sound_effect','stop_sound','playerlist_header','nbt_query_response','collect','entity_teleport','advancements','entity_update_attributes','declare_recipes','tags','entity_effect']
}
updateFilteringTab()" style="margin-left: 8px;">Preset: Player movement
</button>
</div>
<br><br>
<div class="box" style="height: calc(100% - 118px);">
Expand Down
16 changes: 14 additions & 2 deletions html/mainPage/js/defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,17 @@
"clientbound": ["keep_alive", "update_time", "rel_entity_move", "entity_teleport", "map_chunk", "update_light", "update_view_position", "entity_metadata", "entity_update_attributes", "unload_chunk", "entity_velocity", "entity_move_look", "entity_head_rotation"]
},
"useExtendedPresets": true
}
}
},
"extended_presets": [
{
"Player_movement": {
"serverbound":[
"query_block_nbt","set_difficulty","client_command","settings","tab_complete","transaction","enchant_item","window_click","close_window","custom_payload","edit_book","query_entity_nbt","use_entity","generate_structure","keep_alive","lock_difficulty","pick_item","craft_recipe_request","block_dig","entity_action","steer_vehicle","displayed_recipe","recipe_book","name_item","resource_pack_receive","advancement_tab","select_trade","set_beacon_effect","held_item_slot","update_command_block","update_command_block_minecart","set_creative_slot","update_jigsaw_block","update_structure_block","update_sign","arm_animation","spectate","block_place","use_item"
],
"clientbound": [
"spawn_entity","spawn_entity_experience_orb","spawn_entity_living","spawn_entity_painting","named_entity_spawn","animation","statistics","acknowledge_player_digging","block_break_animation","tile_entity_data","block_action","block_change","boss_bar","difficulty","tab_complete","declare_commands","transaction","close_window","window_items","craft_progress_bar","set_slot","set_cooldown","custom_payload","named_sound_effect","kick_disconnect","entity_status","explosion","unload_chunk","game_state_change","open_horse_window","keep_alive","map_chunk","world_event","world_particles","update_light","login","map","trade_list","rel_entity_move","entity_move_look","entity_look","entity","open_book","open_window","open_sign_entity","craft_recipe_response","abilities","combat_event","unlock_recipes","entity_destroy","remove_entity_effect","resource_pack_send","entity_head_rotation","multi_block_change","select_advancement_tab","world_border","camera","held_item_slot","update_view_position","update_view_distance","scoreboard_display_objective","entity_metadata","attach_entity","entity_velocity","entity_equipment","experience","update_health","scoreboard_objective","set_passengers","teams","scoreboard_score","update_time","title","entity_sound_effect","sound_effect","stop_sound","playerlist_header","nbt_query_response","collect","entity_teleport","advancements","entity_update_attributes","declare_recipes","tags","entity_effect"
]
}
}
]
}
18 changes: 17 additions & 1 deletion html/mainPage/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,22 @@ function findDefault(setting) {
}
}
}
// TODO: saving and loading custom presets
function findPreset(elem) {
const name = elem.innerText.match(/Preset: ([\w|\s]+)/i)[1].replace(/\s/g, '_')
defaultsJson.extended_presets.forEach((value) => {
if (value.hasOwnProperty(name)) {
sharedVars.hiddenPackets = value[name]
}
})
}
defaultsJson.extended_presets.forEach((value) => {
const e = document.createElement('button')
e.setAttribute('onclick', 'findPreset(this); updateFilteringTab()')
e.setAttribute('style', 'margin-left: 8px;');
e.innerText = `Preset: ${Object.keys(value)[0].replace(/_/g, ' ')}`;
document.getElementById('extendedPresets').appendChild(e)
})

if (!findDefault('useExtendedPresets')) {
document.getElementById('extendedPresets').style.display = 'none'
Expand Down Expand Up @@ -232,7 +248,7 @@ function updateFilteringStorage () {
function updateFilteringTab () {
for (const item of filteringPackets.children) {
const name = item.children[0].children[2].textContent
console.log(name);
//console.log(name);

const checkbox = item.children[0].firstElementChild
checkbox.readOnly = false
Expand Down
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 94e01c8

Please sign in to comment.