-
Notifications
You must be signed in to change notification settings - Fork 0
/
phone.lua
125 lines (111 loc) · 3.58 KB
/
phone.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
models.FOS.phone.base.screen:setPrimaryRenderType("EMISSIVE_SOLID")
local config = {
portrait = {
third_person = {
pivot = vectors.vec3(4, 22, 0),
offset = vectors.vec3(3, 10, -6),
rotation = vectors.vec3(-80, 0, 0),
scale = vectors.vec3(0.4, 0.4, 0.4),
},
first_person = {
pivot = vectors.vec3(4, 22, 0),
offset = vectors.vec3(9, -1, -9),
rotation = vectors.vec3(-120, -60, 0),
scale = vectors.vec3(0.8, 0.8, 0.8),
}
},
landscape = {
third_person = {
pivot = vectors.vec3(4, 22, 0),
offset = vectors.vec3(1, 9, -4.4),
rotation = vectors.vec3(-90, 90, 0),
left_hand_rotation = vectors.vec3(-90, -90, 0),
scale = vectors.vec3(0.4, 0.4, 0.4),
},
first_person = {
pivot = vectors.vec3(4, 22, 0),
offset = vectors.vec3(5, 0, -14),
rotation = vectors.vec3(-90,28, -38),
left_hand_rotation = vectors.vec3(-90, 208, -38),
scale = vectors.vec3(1, 1, 1),
}
}
}
local function applyTransformPreset(preset)
models.FOS.phone:setScale(preset.scale)
if player:isLeftHanded() then
models.FOS:setParentType("LEFT_ARM")
models.FOS:setPivot(
-preset.pivot.x,
preset.pivot.y,
-preset.pivot.z)
models.FOS.phone:setPos(-preset.offset.x,preset.offset.y,preset.offset.z)
if preset.left_hand_rotation then
models.FOS.phone.base:setRot(preset.left_hand_rotation.x,-preset.left_hand_rotation.y,-preset.left_hand_rotation.z)
else
models.FOS.phone.base:setRot(preset.rotation.x,-preset.rotation.y,-preset.rotation.z)
end
else
models.FOS:setParentType("RIGHT_ARM")
models.FOS:setPivot(
preset.pivot.x,
preset.pivot.y,
preset.pivot.z)
models.FOS.phone:setPos(preset.offset.x,preset.offset.y,preset.offset.z)
models.FOS.phone.base:setRot(preset.rotation)
end
end
events.ENTITY_INIT:register(function()
applyTransformPreset(config.portrait.third_person)
end)
if not host:isHost() then return end
-- transform
events.RENDER:register(function(dt, context)
local orientation = APP and APP.landscapeMode() and "landscape" or "portrait"
local render_type = nil
if client.hasShaderPack() then
if context == "FIRST_PERSON" or context == "OTHER" then
render_type = 1
else
render_type = 0
end
else
if context == "FIRST_PERSON" then
render_type = 1
else
render_type = 0
end
end
if render_type then
applyTransformPreset(config[orientation][render_type == 1 and "first_person" or "third_person"])
end
end)
-- pocket
local in_pocket = false
events.TICK:register(function()
if not SYSTEM_REGISTRY then
return
end
SYSTEM_REGISTRY.disable_system = false
local hide_model = false
if in_pocket then
SYSTEM_REGISTRY.disable_system = true
hide_model = true
elseif player:getItem(1).id ~= "minecraft:air" then
SYSTEM_REGISTRY.disable_system = true
hide_model = true
elseif host:getScreen() then
SYSTEM_REGISTRY.disable_system = true
end
models.FOS:setVisible(not hide_model)
end)
local f3_key = keybinds:newKeybind("f3 key", "key.keyboard.f3")
keybinds:newKeybind("put in pocket", keybinds:getVanillaKey("figura.config.action_wheel_button")).press = function()
if not f3_key:isPressed() then
in_pocket = not in_pocket
print(in_pocket and "FOS is now in pocket" or "FOS in now in hand")
return true
end
end
-- load OS
local os = require("FOS.OS")