Skip to content
This repository was archived by the owner on Dec 27, 2023. It is now read-only.

Commit 40a4b5b

Browse files
committed
Initial commit
0 parents  commit 40a4b5b

File tree

10 files changed

+270
-0
lines changed

10 files changed

+270
-0
lines changed

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.gitattributes
2+
.vscode
3+
.beet_cache
4+
__pycache__
5+
build
6+
releases
7+
*.pdn

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 PuckiSilver
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# lib-FakeEnderEye
2+
Mimic the vanilla ender eye behavior, allowing for click detection in survival

beet.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: FakeEnderEye
2+
author: PuckiSilver
3+
version: v2.0.0
4+
output: build
5+
require:
6+
- bolt
7+
8+
data_pack:
9+
load:
10+
- libs/lantern-load.zip
11+
- src
12+
name: FakeEnderEye
13+
description: Mimic the vanilla ender eye behavior, allowing for click detection in survival
14+
filter:
15+
block:
16+
- namespace: minecraft
17+
path: tags/worldgen/structure/eye_of_ender_located.json
18+
19+
pipeline:
20+
- mecha
21+
- beet.contrib.minify_json
22+
- plugins.credit
23+
- plugins.credit_dom
24+
meta:
25+
bolt:
26+
entrypoint: fee:main
27+
credit: [fee]

libs/lantern-load.zip

5.45 KB
Binary file not shown.

plugins/credit.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from beet import Context
2+
3+
def beet_default(ctx: Context):
4+
5+
comment = f'# {ctx.project_name} {ctx.project_version} by {ctx.project_author}'
6+
namespace = ctx.meta.get("credit")
7+
8+
for name, function in ctx.data.functions.items():
9+
if namespace and name.split(':')[0] not in namespace:
10+
continue
11+
function.prepend(comment)
12+
function.append(comment)

plugins/credit_dom.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from beet import Context
2+
3+
def beet_default(ctx: Context):
4+
5+
comment = """# Credit to Dominexis (Dominexis#3010)
6+
# they shared this function in the MCC Discord (https://discord.gg/QAFXFtZ)
7+
# https://discord.com/channels/154777837382008833/157097006500806656/846088771493036072
8+
"""
9+
ctx.data.functions['fee:locate'].prepend(comment)
+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Set position values
2+
scoreboard players set #point_1_x fee 0
3+
scoreboard players set #point_1_z fee 0
4+
scoreboard players set #point_2_x fee 100
5+
scoreboard players set #point_2_z fee 0
6+
scoreboard players set #point_3_x fee 0
7+
scoreboard players set #point_3_z fee 100
8+
# Get structure distances
9+
execute store result score #point_1_distance fee positioned ~000 ~ ~000 run locate structure stronghold
10+
execute store result score #point_2_distance fee positioned ~100 ~ ~000 run locate structure stronghold
11+
execute store result score #point_3_distance fee positioned ~000 ~ ~100 run locate structure stronghold
12+
# Compute cramer terms
13+
scoreboard players operation #cramer_1 fee = #point_1_x fee
14+
scoreboard players operation #cramer_1 fee -= #point_2_x fee
15+
scoreboard players operation #cramer_2 fee = #point_1_z fee
16+
scoreboard players operation #cramer_2 fee -= #point_2_z fee
17+
scoreboard players operation #cramer_3 fee = #point_1_x fee
18+
scoreboard players operation #cramer_3 fee -= #point_3_x fee
19+
scoreboard players operation #cramer_4 fee = #point_1_z fee
20+
scoreboard players operation #cramer_4 fee -= #point_3_z fee
21+
scoreboard players operation #math_00 fee = #point_1_x fee
22+
scoreboard players operation #math_00 fee *= #point_1_x fee
23+
scoreboard players operation #cramer_5 fee = #math_00 fee
24+
scoreboard players operation #math_00 fee = #point_2_x fee
25+
scoreboard players operation #math_00 fee *= #point_2_x fee
26+
scoreboard players operation #cramer_5 fee -= #math_00 fee
27+
scoreboard players operation #math_00 fee = #point_1_z fee
28+
scoreboard players operation #math_00 fee *= #point_1_z fee
29+
scoreboard players operation #cramer_5 fee += #math_00 fee
30+
scoreboard players operation #math_00 fee = #point_2_z fee
31+
scoreboard players operation #math_00 fee *= #point_2_z fee
32+
scoreboard players operation #cramer_5 fee -= #math_00 fee
33+
scoreboard players operation #math_00 fee = #point_1_distance fee
34+
scoreboard players operation #math_00 fee *= #point_1_distance fee
35+
scoreboard players operation #cramer_5 fee -= #math_00 fee
36+
scoreboard players operation #math_00 fee = #point_2_distance fee
37+
scoreboard players operation #math_00 fee *= #point_2_distance fee
38+
scoreboard players operation #cramer_5 fee += #math_00 fee
39+
scoreboard players operation #math_00 fee = #point_1_x fee
40+
scoreboard players operation #math_00 fee *= #point_1_x fee
41+
scoreboard players operation #cramer_6 fee = #math_00 fee
42+
scoreboard players operation #math_00 fee = #point_3_x fee
43+
scoreboard players operation #math_00 fee *= #point_3_x fee
44+
scoreboard players operation #cramer_6 fee -= #math_00 fee
45+
scoreboard players operation #math_00 fee = #point_1_z fee
46+
scoreboard players operation #math_00 fee *= #point_1_z fee
47+
scoreboard players operation #cramer_6 fee += #math_00 fee
48+
scoreboard players operation #math_00 fee = #point_3_z fee
49+
scoreboard players operation #math_00 fee *= #point_3_z fee
50+
scoreboard players operation #cramer_6 fee -= #math_00 fee
51+
scoreboard players operation #math_00 fee = #point_1_distance fee
52+
scoreboard players operation #math_00 fee *= #point_1_distance fee
53+
scoreboard players operation #cramer_6 fee -= #math_00 fee
54+
scoreboard players operation #math_00 fee = #point_3_distance fee
55+
scoreboard players operation #math_00 fee *= #point_3_distance fee
56+
scoreboard players operation #cramer_6 fee += #math_00 fee
57+
# Compute denominator
58+
scoreboard players operation #math_00 fee = #cramer_1 fee
59+
scoreboard players operation #math_00 fee *= #cramer_4 fee
60+
scoreboard players operation #math_01 fee = #cramer_2 fee
61+
scoreboard players operation #math_01 fee *= #cramer_3 fee
62+
scoreboard players operation #math_00 fee -= #math_01 fee
63+
scoreboard players operation #math_00 fee *= #2 fee
64+
scoreboard players operation #denominator fee = #math_00 fee
65+
# Compute X numerator
66+
scoreboard players operation #math_00 fee = #cramer_5 fee
67+
scoreboard players operation #math_00 fee *= #cramer_4 fee
68+
scoreboard players operation #math_01 fee = #cramer_2 fee
69+
scoreboard players operation #math_01 fee *= #cramer_6 fee
70+
scoreboard players operation #math_00 fee -= #math_01 fee
71+
scoreboard players operation #numerator_x fee = #math_00 fee
72+
# Compute Z numerator
73+
scoreboard players operation #math_00 fee = #cramer_1 fee
74+
scoreboard players operation #math_00 fee *= #cramer_6 fee
75+
scoreboard players operation #math_01 fee = #cramer_5 fee
76+
scoreboard players operation #math_01 fee *= #cramer_3 fee
77+
scoreboard players operation #math_00 fee -= #math_01 fee
78+
scoreboard players operation #numerator_z fee = #math_00 fee
79+
# Compute final position
80+
scoreboard players operation #location_x fee = #numerator_x fee
81+
scoreboard players operation #location_z fee = #numerator_z fee

src/data/fee/modules/main.bolt

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
2+
from ./particles import circle
3+
4+
append function_tag load:load {"values":["fee:load"]}
5+
function fee:load:
6+
scoreboard objectives add fee dummy
7+
scoreboard players set #2 fee 2
8+
9+
advancement fee:throw_eye {
10+
"criteria": {
11+
"mainhand": { "trigger": "minecraft:using_item", "conditions": {
12+
"item": { "items": [ "minecraft:ender_eye" ]},
13+
"player": [
14+
{ "condition": "minecraft:value_check",
15+
"value": { "type": "minecraft:score", "target": { "type": "minecraft:fixed", "name": ".gametime" }, "score": "fee" }, "range": {
16+
"min": { "type": "minecraft:score", "target": "this", "score": "fee" },
17+
"max": 2147483647 }},
18+
{ "condition": "minecraft:entity_properties", "entity": "this", "predicate": {
19+
"equipment": { "mainhand": { "items": [ "minecraft:ender_eye" ]}}}},
20+
{ "condition": "minecraft:inverted", "term": {
21+
"condition": "minecraft:entity_properties", "entity": "this", "predicate": {
22+
"equipment": { "mainhand": { "nbt": "{}" }}}}}]
23+
}},
24+
"offhand": { "trigger": "minecraft:using_item", "conditions": {
25+
"item": { "items": [ "minecraft:ender_eye" ]},
26+
"player": [
27+
{ "condition": "minecraft:value_check",
28+
"value": { "type": "minecraft:score", "target": { "type": "minecraft:fixed", "name": ".gametime" }, "score": "fee" }, "range": {
29+
"min": { "type": "minecraft:score", "target": "this", "score": "fee" },
30+
"max": 2147483647 }},
31+
{ "condition": "minecraft:entity_properties", "entity": "this", "predicate": {
32+
"equipment": { "offhand": { "items": [ "minecraft:ender_eye" ]}}}},
33+
{ "condition": "minecraft:inverted", "term": {
34+
"condition": "minecraft:entity_properties", "entity": "this", "predicate": {
35+
"equipment": { "mainhand": { "items": [ "minecraft:ender_eye" ]}}}}},
36+
{ "condition": "minecraft:inverted", "term": {
37+
"condition": "minecraft:entity_properties", "entity": "this", "predicate": {
38+
"equipment": { "offhand": { "nbt": "{}" }}}}}]
39+
}}
40+
},
41+
"requirements": [[ "mainhand", "offhand" ]],
42+
"rewards": { "function": "fee:throw_eye" }}
43+
function fee:throw_eye:
44+
execute anchored eyes positioned ^ ^ ^ summon snowball function fee:setup/snowball
45+
if entity @s[advancements={fee:throw_eye={mainhand=true}},gamemode=!creative] item modify entity @s weapon.mainhand fee:remove_one
46+
if entity @s[advancements={fee:throw_eye={offhand=true}},gamemode=!creative] item modify entity @s weapon.offhand fee:remove_one
47+
playsound minecraft:entity.ender_eye.launch neutral @a ~ ~ ~ 0.5 0.42
48+
advancement revoke @s only fee:throw_eye
49+
store result score @s fee schedule function fee:refresh_gametime 4t append:
50+
store result score .gametime fee time query gametime
51+
52+
function fee:setup/snowball:
53+
data modify entity @s NoGravity set value 1b
54+
data modify entity @s Item set value {id:"minecraft:ender_eye",Count:1b}
55+
function fee:locate
56+
store result entity @s Pos[0] double 1 scoreboard players operation #location_x fee /= #denominator fee
57+
store result entity @s Pos[2] double 1 scoreboard players operation #location_z fee /= #denominator fee
58+
positioned 0 ~ 0 facing entity @s feet run tp @s ^ ^ ^10
59+
store result entity @s Motion[0] double 0.028 run data get entity @s Pos[0]
60+
store result entity @s Motion[2] double 0.028 run data get entity @s Pos[2]
61+
tp @s ~ ~ ~
62+
data modify entity @s Motion[1] set value 0.16d
63+
tag @s add fee.snowball
64+
execute summon marker function fee:setup/marker:
65+
ride @s mount @e[type=snowball,tag=fee.snowball,dx=0,limit=1]
66+
tag @s add fee.marker
67+
store result score @s fee schedule function fee:clean_up/ 81t append
68+
69+
function fee:clean_up/:
70+
store result score .gametime fee time query gametime
71+
as @e[type=marker,tag=fee.marker] if score @s fee <= .gametime fee at @s function fee:clean_up/marker:
72+
scoreboard players set .should_drop fee 0
73+
if predicate fee:should_drop scoreboard players set .should_drop fee 1
74+
if score .should_drop fee matches 1 function fee:clean_up/drop:
75+
summon item ~ ~ ~ {Item:{"id":"minecraft:ender_eye",Count:1b}}
76+
if score .should_drop fee matches 0 function fee:clean_up/dont_drop:
77+
circle(2, 20, "reverse_portal", "in", 1, mode="normal")
78+
particle item ender_eye ~ ~ ~ 0.2 0.2 0.2 0.1 5
79+
particle minecraft:portal ~ ~ ~ 0.2 0.2 0.2 0 20
80+
playsound minecraft:entity.ender_eye.death neutral @a
81+
on vehicle kill @s
82+
kill @s
83+
84+
item_modifier fee:remove_one {
85+
"function": "minecraft:set_count",
86+
"count": -1,
87+
"add": true }
88+
89+
predicate fee:should_drop {
90+
"condition": "minecraft:random_chance",
91+
"chance": 0.8 }

src/data/fee/modules/particles.bolt

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
import math
3+
import numpy
4+
5+
def circle(radius, points, particle="dust 1 0 0 0.5", movement=(0, 0, 0), speed=0, offset=(0, 0, 0), movement_offset=(0, 0, 0), mode="force"):
6+
if type(movement) == tuple:
7+
move = f'{movement[0]} {movement[1]} {movement[2]}'
8+
else:
9+
move = "0 0 0"
10+
moveOut = movement == "out"
11+
moveIn = movement == "in"
12+
13+
for a in numpy.arange(0, 2*math.pi, (2*math.pi)/points):
14+
x = radius * math.cos(a)
15+
y = radius * math.sin(a)
16+
if moveOut:
17+
move = f'{round(x, 5) + movement_offset[0]} {movement_offset[1]} {round(y, 5) + movement_offset[2]}'
18+
elif moveIn:
19+
move = f'{-round(x, 5)} 0 {-round(y, 5)}'
20+
particle f'{particle} ~{round(x, 5) + offset[0]} ~{offset[1]} ~{round(y, 5) + offset[2]} {move} {speed} 0 {mode}'

0 commit comments

Comments
 (0)