-
Notifications
You must be signed in to change notification settings - Fork 0
/
petpet.lua.disabled
69 lines (60 loc) · 1.58 KB
/
petpet.lua.disabled
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
local delay = 3
local lastPet = -1
local scale = 0.75
local key = keybind:create("Patpat", "key.mouse.2", false)
local BLOCK_FIX = vec(0.5, 0, 0.5)
local BLOCK_BB = vec(0.7, 0.7, 0.7)
local function pat(pos, box)
-- pos
local box2 = box / 2
box:applyFunc(function(val) return val * math.random() end)
pos = pos + box.xyz - box2.x_z
-- ping
host:swingArm()
pings["fran.patpat.pat"](pos, scale)
scale = scale * 1.01
return true
end
local function patBlock()
-- get block
local block = player:getTargetedBlock()
if (block.id == "minecraft:player_head" or block.id == "minecraft:player_wall_head") then
-- pat
return pat(block:getPos() + BLOCK_FIX, BLOCK_BB:copy())
else
-- no pats :(
return false
end
end
local function patCheck()
-- get crosshair entity
local entity = player:getTargetedEntity()
if (entity ~= nil) then
-- pat
return pat(entity:getPos(), entity:getBoundingBox())
else
-- try pat heads
return patBlock()
end
end
function key.onPress()
-- only allow for pets when sneaking with empty hands
if (player:isSneaking() and player:getItem(1).id == "minecraft:air" and player:getItem(2).id == "minecraft:air" and patCheck()) then
lastPet = world.getTime() + delay - 1
return true
end
end
function key.onRelease()
-- disallow pats
lastPet = -1
scale = 1
end
function events.tick()
-- button holding = infinite pats ^^
if (lastPet > -1 and (lastPet - world.getTime()) % delay == 0) then
patCheck()
end
end
pings["fran.patpat.pat"] = function(pos, scale)
particles.heart:pos(pos):scale(scale):spawn()
end