├── .gitignore
├── LICENSE
├── README.md
├── README_zh-cn.md
├── img
└── tools.png
├── pom.xml
└── src
└── main
├── java
└── cn
│ └── powernukkitx
│ └── replaynk
│ ├── ReplayNK.java
│ ├── command
│ └── ReplayCommand.java
│ ├── entity
│ ├── MarkerEntity.java
│ └── ReplayNKEntity.java
│ ├── item
│ ├── AddMarkerItem.java
│ ├── ClearMarkerItem.java
│ ├── EditMarkerItem.java
│ ├── ExitItem.java
│ ├── MarkerPickerItem.java
│ ├── PauseItem.java
│ ├── PlayItem.java
│ ├── ReplayNKItem.java
│ └── SettingItem.java
│ └── trail
│ ├── Interpolator.java
│ ├── Marker.java
│ └── Trail.java
└── resources
├── assets
└── resource_pack
│ ├── entity
│ └── marker.json
│ ├── items
│ ├── add_marker.json
│ ├── clear_marker.json
│ ├── edit.json
│ ├── exit.json
│ ├── marker_picker.json
│ ├── pause.json
│ ├── play.json
│ └── setting.json
│ ├── manifest.json
│ ├── models
│ └── entity
│ │ └── marker.geo.json
│ ├── pack_icon.png
│ ├── particles
│ └── arrow.particle.json
│ ├── render_controllers
│ └── marker.json
│ ├── texts
│ ├── en_US.lang
│ ├── languages.json
│ └── zh_CN.lang
│ └── textures
│ ├── entity
│ └── marker.png
│ ├── item_texture.json
│ ├── items
│ ├── add_marker_item_texture.png
│ ├── clear_marker_item_texture.png
│ ├── edit_marker_item_texture.png
│ ├── exit_item_texture.png
│ ├── marker_picker_item_texture.png
│ ├── pause_item_texture.png
│ ├── play_item_texture.png
│ └── setting_item_texture.png
│ └── particles
│ └── arrow.png
├── language
├── en_US.lang
└── zh_CN.lang
└── plugin.yml
/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 | !**/src/main/**/target/
4 | !**/src/test/**/target/
5 |
6 | ### IntelliJ IDEA ###
7 | .idea/modules.xml
8 | .idea/jarRepositories.xml
9 | .idea/compiler.xml
10 | .idea/libraries/
11 | *.iws
12 | *.iml
13 | *.ipr
14 |
15 | ### Eclipse ###
16 | .apt_generated
17 | .classpath
18 | .factorypath
19 | .project
20 | .settings
21 | .springBeans
22 | .sts4-cache
23 |
24 | ### NetBeans ###
25 | /nbproject/private/
26 | /nbbuild/
27 | /dist/
28 | /nbdist/
29 | /.nb-gradle/
30 | build/
31 | !**/src/main/**/build/
32 | !**/src/test/**/build/
33 |
34 | ### VS Code ###
35 | .vscode/
36 |
37 | ### Mac OS ###
38 | .DS_Store
39 | /.idea/
40 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ReplayNK - MCBE PowerNukkitX camera plugin
2 |
3 | 
4 |
5 | ##### English | [简体中文](README_zh-cn.md)
6 |
7 | `ReplayNK` is a camera plugin developed for the Bedrock Edition server software `PowerNukkitX`, based on the latest Camera API of MCBE 1.20.0
8 |
9 | `ReplayNK` has made a lot of optimizations for camera movement, making its camera movement smoother and smoother than the traditional `/teleport`command plus command block to achieve camera movement
10 |
11 | `ReplayNK` perfectly supports all available parameters of the original `/camera` command, and adds a series of smoothing algorithms for path smoothing, such as Bézier curves.
12 |
13 | `ReplayNK` is simple and intuitive to use, with full visual operation, and most of the functions can be activated with one click of a button. At the same time, the plugin supports Chinese and English dual languages, and will automatically switch according to the user's language settings.
14 |
15 | ## Simple tutorial
16 |
17 | ### 1. Install plugin
18 |
19 | Download the latest plugin jar package from Github Release, put it into the plugin folder of PowerNukkitX, and restart the server. The resource packs required by the plugin are built into the plugin, and you don't need to install additional resource packs.
20 |
21 | After startup, the plugin will generate `plugins/ReplayNK/trails` directory and save trail files in this directory
22 |
23 | ### 2. Commands
24 |
25 | The list of available commands for the plugin is as follows, you can also enter `help replaynk` to get command help
26 |
27 | `/replaynk create ` - Create a new trail preset
28 |
29 | `/replaynk remove ` - Delete a new trail preset
30 |
31 | `/replaynk operate ` - Start operating a trail preset
32 |
33 | `/replaynk list` - List all trail presets
34 |
35 | ### 3. Operation Guide
36 |
37 | Here are some things that will appear in your inventory after entering the operation mode (`/replay operate`), we will introduce from left to right
38 |
39 | 
40 |
41 | `Add Marker` - Add a marker
42 |
43 | Add a marker, the marker is the basic unit of the track, you can set the camera position, orientation, camera speed and other parameters on the marker. The newly created marker will inherit the player's position and orientation
44 |
45 | `Remove Marker` - Remove a marker
46 |
47 | Use this tool to click on a marker to delete the marker point. After deleting a marker, the numbers of all subsequent markers will be reduced by one
48 |
49 | `Edit Marker` - Edit a marker
50 |
51 | Use this tool to click a marker to edit the parameters of this marker
52 |
53 | `Marker Picker` - Pick up a marker
54 |
55 | This tool is used to move markers quickly. Left click to select a marker and move to a new position right click, the marker you selected will be moved to your new position
56 |
57 | `Play` - Play the trail
58 |
59 | Right click to play the trail
60 |
61 | `Pause` - Stop playing
62 |
63 | Right click on this tool while playing to stop playing
64 |
65 | `Setting` - Trail settings
66 |
67 | Click this tool to open the trail setting interface, where you can set the smoothing type of the trail, the default camera speed, playback speed and other parameters
68 |
69 | `Exit` - Exit edit mode
70 |
71 | Right click this tool to exit the edit mode
72 |
73 | ## Troubleshooting
74 |
75 | Q: Why do I feel that the camera is still stuck?
76 |
77 | A: Due to the limitation of the client, when the speed of the mirror is too high and the distance between the markers is too small, there will be a freeze phenomenon. We have optimized it as much as possible. You can improve this problem by reducing the camera speed or increasing the marker spacing
78 |
79 | Q: Why doesn't my camera reset after playback ends?
80 |
81 | A: This may be caused by sending packets too fast. You can fix this by using the command `camera @s clear`
82 |
83 | ## Related projects
84 |
85 | - [PowerNukkitX](https://github.com/PowerNukkitX/PowerNukkitX)
--------------------------------------------------------------------------------
/README_zh-cn.md:
--------------------------------------------------------------------------------
1 | # ReplayNK - MCBE PowerNukkitX平台 平滑镜头插件
2 |
3 | 
4 |
5 | ##### [English](README.md) | 简体中文
6 |
7 | `ReplayNK`是为基岩版`PowerNukkitX`平台开发的平滑镜头模组,基于MCBE 1.20.0最新的Camera API开发
8 |
9 | `ReplayNK`针对镜头运动进行了大量的优化,使得其运镜的流畅度和平滑度远高于通过传统的`/teleport`指令加命令方块实现的镜头运动
10 |
11 | `ReplayNK`完美支持原版`/camera`命令的所有可用参数,并针对路径平滑添加了一系列平滑算法,例如贝塞尔曲线。
12 |
13 | `ReplayNK`使用上手简单直观,全可视化操作,大部分功能只需要点击一下按钮就能启用。同时,插件支持中文/英文双语言,会根据用户的语言设置自动切换。
14 |
15 | ## 简单使用教程
16 |
17 | ### 1. 安装插件
18 |
19 | 在Github Release下载最新的插件jar包,放入PowerNukkitX的插件文件夹内,重启服务器即可。插件所需资源包已内置到插件中,你不需要额外安装资源包。
20 |
21 | 启动后,插件将生成`plugins/ReplayNK/trails`目录并在此目录下保存轨迹文件
22 |
23 | ### 2. 命令
24 |
25 | 插件可用命令列表如下,你也可以输入`/help replaynk`来获取命令帮助
26 |
27 | `/replaynk create ` - 创建一个新的轨迹预设
28 |
29 | `/replaynk remove ` - 删除一个新的轨迹预设
30 |
31 | `/replaynk operate ` - 开始操作一个轨迹预设
32 |
33 | `/replaynk list` - 列出所有的轨迹预设
34 |
35 | ### 3. 操作指南
36 |
37 | 以下是进入操作模式(`/replay operate`)后你的物品栏将会出现的一些东西,我们将从左往右介绍
38 |
39 | 
40 |
41 | `Add Marker` - 添加标记点
42 |
43 | 添加一个标记点,标记点是轨迹的基本组成单位,你可以在标记点上设置镜头的位置、朝向、镜头速度等参数。刚创建的标记点会继承玩家的位置和朝向
44 |
45 | `Remove Marker` - 删除标记点
46 |
47 | 使用此工具点击一个标记点,可以删除这个标记点。删除标记点后,其后的所有标记点的编号将会减一
48 |
49 | `Edit Marker` - 编辑标记点
50 |
51 | 使用此工具点击一个标记点,可以编辑这个标记点的参数
52 |
53 | `Marker Picker` - 选取标记点
54 |
55 | 此工具用于快速移动标记点。左键选取标记点并移动到新位置右键,你选取的标记点将会被移动到你所处的新位置
56 |
57 | `Play` - 播放
58 |
59 | 右键开始播放轨迹
60 |
61 | `Pause` - 停止播放
62 |
63 | 在播放时右键此工具可停止播放
64 |
65 | `Setting` - 轨迹设置
66 |
67 | 点击此工具可打开轨迹设置界面,你可以在此界面设置轨迹的平滑类型,默认镜头速度,播放倍速等参数
68 |
69 | `Exit` - 退出操作模式
70 |
71 | 右键此工具可退出编辑模式
72 |
73 | ## 疑难解答
74 |
75 | Q: 为什么我感觉运镜还是很卡顿?
76 |
77 | A: 由于客户端限制,在运镜速度过高/标记点间距过小的情况下会出现卡顿现象,我们已经尽量优化了。你可以通过减小镜头速度或者增大标记点间距来改善这个问题
78 |
79 | Q: 为什么播放结束了我的镜头却没有复位?
80 |
81 | A: 这可能是由于发包过快导致的。你可以通过使用命令`/camera @s clear`来解决此问题
82 |
83 | ## 相关项目
84 |
85 | - [PowerNukkitX](https://github.com/PowerNukkitX/PowerNukkitX)
--------------------------------------------------------------------------------
/img/tools.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerNukkitX-Bundle/ReplayNK/8eab3889ba3a39c88a8c48299a1a36c9071166c7/img/tools.png
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | cn.powernukkitx
8 | ReplayNK
9 | 1.0.2
10 |
11 |
12 | 17
13 | 17
14 | UTF-8
15 |
16 |
17 |
18 |
19 | jitpack.io
20 | https://www.jitpack.io
21 |
22 |
23 |
24 |
25 |
26 | cn.powernukkitx
27 | powernukkitx
28 | 1.20.10-r1
29 |
30 |
31 | org.projectlombok
32 | lombok
33 | RELEASE
34 | compile
35 |
36 |
37 | org.apache.commons
38 | commons-math3
39 | 3.6.1
40 |
41 |
42 |
--------------------------------------------------------------------------------
/src/main/java/cn/powernukkitx/replaynk/ReplayNK.java:
--------------------------------------------------------------------------------
1 | package cn.powernukkitx.replaynk;
2 |
3 | import cn.nukkit.Player;
4 | import cn.nukkit.Server;
5 | import cn.nukkit.entity.Entity;
6 | import cn.nukkit.entity.provider.CustomClassEntityProvider;
7 | import cn.nukkit.event.EventHandler;
8 | import cn.nukkit.event.Listener;
9 | import cn.nukkit.event.entity.EntityDamageByEntityEvent;
10 | import cn.nukkit.event.entity.EntityDamageEvent;
11 | import cn.nukkit.event.player.PlayerInteractEvent;
12 | import cn.nukkit.event.player.PlayerQuitEvent;
13 | import cn.nukkit.item.Item;
14 | import cn.nukkit.lang.PluginI18n;
15 | import cn.nukkit.lang.PluginI18nManager;
16 | import cn.nukkit.plugin.PluginBase;
17 | import cn.powernukkitx.replaynk.command.ReplayCommand;
18 | import cn.powernukkitx.replaynk.entity.MarkerEntity;
19 | import cn.powernukkitx.replaynk.entity.ReplayNKEntity;
20 | import cn.powernukkitx.replaynk.item.*;
21 | import cn.powernukkitx.replaynk.trail.Trail;
22 | import lombok.Getter;
23 |
24 | import java.util.HashMap;
25 | import java.util.List;
26 | import java.util.Map;
27 |
28 | /**
29 | * @author daoge_cmd
30 | * @date 2023/6/11
31 | * ReplayNK Project
32 | */
33 | public final class ReplayNK extends PluginBase implements Listener {
34 |
35 | public static final int TRAIL_TICK_PERIOD = 10;
36 | public static final int TITLE_TASK_TICK_PERIOD = 5;
37 | private static final Map PLAYER_ACTION_TIMER = new HashMap<>();
38 | private static final int PLAYER_ACTION_COOL_DOWN = 1;
39 | @Getter
40 | private static ReplayNK instance;
41 | @Getter
42 | private static PluginI18n I18n;
43 |
44 | {
45 | instance = this;
46 | }
47 |
48 | @Override
49 | public void onLoad() {
50 | I18n = PluginI18nManager.register(this);
51 | var logger = getLogger();
52 | logger.info("Loading ReplayNK...");
53 | logger.info("Registering items...");
54 | registerItems();
55 | logger.info("Registered items.");
56 | logger.info("Registering entities...");
57 | registerEntities();
58 | logger.info("Registered entities.");
59 | }
60 |
61 | @Override
62 | public void onEnable() {
63 | Server.getInstance().getPluginManager().registerEvents(this, this);
64 | Server.getInstance().getCommandMap().register("", new ReplayCommand(this));
65 | Trail.readAllTrails();
66 |
67 | Server.getInstance().getScheduler().scheduleRepeatingTask(this, () -> {
68 | for (var trail : Trail.getTrails().values()) {
69 | trail.tick();
70 | }
71 | }, TRAIL_TICK_PERIOD, true);
72 | Server.getInstance().getScheduler().scheduleRepeatingTask(this, () -> {
73 | for (var player : Trail.getOperatingPlayers()) {
74 | if (player.getInventory().getItemInHand() instanceof MarkerPickerItem markerPickerItem) {
75 | var index = markerPickerItem.getHoldingMarkerIndex();
76 | if (index == -1) {
77 | player.sendActionBar(getI18n().tr(player.getLanguageCode(), "replaynk.markerpicker.unpick"));
78 | } else {
79 | player.sendActionBar(getI18n().tr(player.getLanguageCode(), "replaynk.markerpicker.picked", index));
80 | }
81 | }
82 | }
83 | }, TITLE_TASK_TICK_PERIOD);
84 | }
85 |
86 | @Override
87 | public void onDisable() {
88 | Trail.closeAndSave();
89 | }
90 |
91 | private void registerItems() {
92 | Item.registerCustomItem(List.of(
93 | AddMarkerItem.class,
94 | ClearMarkerItem.class,
95 | ExitItem.class,
96 | PauseItem.class,
97 | PlayItem.class,
98 | EditMarkerItem.class,
99 | SettingItem.class,
100 | MarkerPickerItem.class
101 | ));
102 | }
103 |
104 | private void registerEntities() {
105 | Entity.registerCustomEntity(new CustomClassEntityProvider(MarkerEntity.class));
106 | }
107 |
108 | @EventHandler
109 | @SuppressWarnings("unused")
110 | private void onClick(PlayerInteractEvent event) {
111 | if (event.getAction() == PlayerInteractEvent.Action.RIGHT_CLICK_AIR
112 | || event.getAction() == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
113 | var player = event.getPlayer();
114 | var currentTick = Server.getInstance().getTick();
115 | if (event.getItem() instanceof ReplayNKItem item) {
116 | if (!PLAYER_ACTION_TIMER.containsKey(player) || currentTick - PLAYER_ACTION_TIMER.get(player) > PLAYER_ACTION_COOL_DOWN) {
117 | PLAYER_ACTION_TIMER.put(player, currentTick);
118 | item.onInteract(player);
119 | }
120 | }
121 | }
122 | }
123 |
124 | @EventHandler
125 | @SuppressWarnings("unused")
126 | private void onClickEntity(EntityDamageByEntityEvent event) {
127 | if (event.getDamager() instanceof Player player) {
128 | var currentTick = Server.getInstance().getTick();
129 | if (player.getInventory().getItemInHand() instanceof ReplayNKItem item) {
130 | if (!PLAYER_ACTION_TIMER.containsKey(player) || currentTick - PLAYER_ACTION_TIMER.get(player) > PLAYER_ACTION_COOL_DOWN) {
131 | PLAYER_ACTION_TIMER.put(player, currentTick);
132 | item.onClickEntity(player, event.getEntity());
133 | }
134 | }
135 | }
136 | }
137 |
138 | @EventHandler
139 | @SuppressWarnings("unused")
140 | private void onPlayerQuit(PlayerQuitEvent event) {
141 | var player = event.getPlayer();
142 | if (Trail.isOperatingTrail(player)) {
143 | Trail.getOperatingTrail(player).stopOperating();
144 | }
145 | }
146 |
147 | @EventHandler
148 | @SuppressWarnings("unused")
149 | private void onEntityDamaged(EntityDamageEvent event) {
150 | if (event.getEntity() instanceof ReplayNKEntity) {
151 | event.setCancelled();
152 | }
153 | }
154 | }
155 |
--------------------------------------------------------------------------------
/src/main/java/cn/powernukkitx/replaynk/command/ReplayCommand.java:
--------------------------------------------------------------------------------
1 | package cn.powernukkitx.replaynk.command;
2 |
3 | import cn.nukkit.command.CommandSender;
4 | import cn.nukkit.command.PluginCommand;
5 | import cn.nukkit.command.data.CommandParamType;
6 | import cn.nukkit.command.data.CommandParameter;
7 | import cn.nukkit.command.tree.ParamList;
8 | import cn.nukkit.command.utils.CommandLogger;
9 | import cn.powernukkitx.replaynk.ReplayNK;
10 | import cn.powernukkitx.replaynk.trail.Trail;
11 |
12 | import java.util.Map;
13 |
14 | /**
15 | * @author daoge_cmd
16 | * @date 2023/6/16
17 | * ReplayNK Project
18 | */
19 | public class ReplayCommand extends PluginCommand {
20 | public ReplayCommand(ReplayNK plugin) {
21 | super("replaynk", "replaynk.command.replay.description", plugin);
22 | setAliases(new String[]{"replay", "rp", "rpnk"});
23 | setPermission("replaynk.command.replay");
24 | commandParameters.clear();
25 | commandParameters.put("operate", new CommandParameter[]{
26 | CommandParameter.newEnum("operate", new String[]{"operate"}),
27 | CommandParameter.newType("name", false, CommandParamType.STRING)
28 | });
29 | commandParameters.put("create", new CommandParameter[]{
30 | CommandParameter.newEnum("create", new String[]{"create"}),
31 | CommandParameter.newType("name", false, CommandParamType.STRING)
32 | });
33 | commandParameters.put("remove", new CommandParameter[]{
34 | CommandParameter.newEnum("remove", new String[]{"remove"}),
35 | CommandParameter.newType("name", false, CommandParamType.STRING)
36 | });
37 | commandParameters.put("list", new CommandParameter[]{
38 | CommandParameter.newEnum("list", new String[]{"list"}),
39 | });
40 | enableParamTree();
41 | }
42 |
43 | @Override
44 | public int execute(CommandSender sender, String commandLabel, Map.Entry result, CommandLogger log) {
45 | if (!sender.isPlayer()) {
46 | log.addMessage("replaynk.command.replay.onlyplayer").output();
47 | return 0;
48 | }
49 | var player = sender.asPlayer();
50 | switch (result.getKey()) {
51 | case "operate" -> {
52 | if (Trail.isOperatingTrail(player)) {
53 | log.addMessage("replaynk.trail.alreadyoperatingtrail").output();
54 | return 0;
55 | }
56 | String trailName = result.getValue().get(1).get();
57 | var trail = Trail.getTrail(trailName);
58 | if (trail == null) {
59 | log.addMessage("replaynk.trail.notfound", trailName).output();
60 | return 0;
61 | }
62 | trail.startOperating(player);
63 | log.addMessage("replaynk.trail.startoperating", trailName).output();
64 | return 1;
65 | }
66 | case "create" -> {
67 | String trailName = result.getValue().get(1).get();
68 | var trail = Trail.create(trailName);
69 | if (trail != null) {
70 | log.addMessage("replaynk.trail.created", trailName);
71 | if (!Trail.isOperatingTrail(player)) {
72 | trail.startOperating(player);
73 | log.addMessage("replaynk.trail.startoperating", trailName).output();
74 | }
75 | } else {
76 | log.addMessage("replaynk.trail.alreadyexist", trailName).output();
77 | }
78 | return 1;
79 | }
80 | case "remove" -> {
81 | String trailName = result.getValue().get(1).get();
82 | var trail = Trail.removeTrail(trailName);
83 | if (trail != null)
84 | log.addMessage("replaynk.trail.removed", trailName).output();
85 | else
86 | log.addMessage("replaynk.trail.notfound", trailName).output();
87 | return 1;
88 | }
89 | case "list" -> {
90 | var strBuilder = new StringBuilder();
91 | var trails = Trail.getTrails();
92 | for (var trail : trails.values()) {
93 | strBuilder.append(trail.getName()).append(" ");
94 | }
95 | log.addMessage("replaynk.command.replay.list", strBuilder.toString()).output();
96 | return 1;
97 | }
98 | default -> {
99 | return 0;
100 | }
101 | }
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/src/main/java/cn/powernukkitx/replaynk/entity/MarkerEntity.java:
--------------------------------------------------------------------------------
1 | package cn.powernukkitx.replaynk.entity;
2 |
3 | import cn.nukkit.entity.custom.CustomEntityDefinition;
4 | import cn.nukkit.level.format.FullChunk;
5 | import cn.nukkit.nbt.tag.CompoundTag;
6 |
7 | /**
8 | * @author daoge_cmd
9 | * @date 2023/6/11
10 | * ReplayNK Project
11 | */
12 | public class MarkerEntity extends ReplayNKEntity {
13 | private static final CustomEntityDefinition DEF =
14 | CustomEntityDefinition
15 | .builder()
16 | .identifier("replaynk:marker")
17 | .summonable(true)
18 | .spawnEgg(false)
19 | .build();
20 | private static final String MARKER_INDEX_KEY = "MarkerIndex";
21 |
22 | public MarkerEntity(FullChunk chunk, CompoundTag nbt) {
23 | super(chunk, nbt);
24 | }
25 |
26 | @Override
27 | public CustomEntityDefinition getDefinition() {
28 | return DEF;
29 | }
30 |
31 |
32 | @Override
33 | public float getHeight() {
34 | return 0.5F;
35 | }
36 |
37 | @Override
38 | public float getWidth() {
39 | return 0.5F;
40 | }
41 |
42 | @Override
43 | public float getLength() {
44 | return 0.5F;
45 | }
46 |
47 | @Override
48 | public String getOriginalName() {
49 | return "Marker";
50 | }
51 |
52 | public int getMarkerIndex() {
53 | return namedTag.getInt(MARKER_INDEX_KEY);
54 | }
55 |
56 | public void setMarkerIndex(int index) {
57 | namedTag.putInt(MARKER_INDEX_KEY, index);
58 | setNameTag("§a" + index);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/cn/powernukkitx/replaynk/entity/ReplayNKEntity.java:
--------------------------------------------------------------------------------
1 | package cn.powernukkitx.replaynk.entity;
2 |
3 | import cn.nukkit.entity.Entity;
4 | import cn.nukkit.entity.custom.CustomEntity;
5 | import cn.nukkit.level.format.FullChunk;
6 | import cn.nukkit.nbt.tag.CompoundTag;
7 |
8 | /**
9 | * @author daoge_cmd
10 | * @date 2023/6/11
11 | * ReplayNK Project
12 | */
13 | public abstract class ReplayNKEntity extends Entity implements CustomEntity {
14 | public ReplayNKEntity(FullChunk chunk, CompoundTag nbt) {
15 | super(chunk, nbt);
16 | }
17 |
18 | @Override
19 | public int getNetworkId() {
20 | return Entity.NETWORK_ID;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/cn/powernukkitx/replaynk/item/AddMarkerItem.java:
--------------------------------------------------------------------------------
1 | package cn.powernukkitx.replaynk.item;
2 |
3 | import cn.nukkit.Player;
4 | import cn.powernukkitx.replaynk.ReplayNK;
5 | import cn.powernukkitx.replaynk.trail.Marker;
6 | import cn.powernukkitx.replaynk.trail.Trail;
7 |
8 | /**
9 | * @author daoge_cmd
10 | * @date 2023/6/11
11 | * ReplayNK Project
12 | */
13 | public class AddMarkerItem extends ReplayNKItem {
14 | public AddMarkerItem() {
15 | super("replaynk:add_marker", "Add Marker", "replaynk_add_marker");
16 | }
17 |
18 | @Override
19 | public void onInteract(Player player) {
20 | if (!Trail.isOperatingTrail(player)) {
21 | player.sendMessage(ReplayNK.getI18n().tr(player.getLanguageCode(), "replaynk.trail.notoperatingtrail"));
22 | return;
23 | }
24 | var trail = Trail.getOperatingTrail(player);
25 | var loc = player.getLocation();
26 | var builder = new Marker(loc.x, loc.y + player.getEyeHeight(), loc.z, loc.pitch, loc.yaw, trail.getDefaultCameraSpeed());
27 | trail.addMarker(builder);
28 | player.sendMessage(ReplayNK.getI18n().tr(player.getLanguageCode(), "replaynk.mark.added"));
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/cn/powernukkitx/replaynk/item/ClearMarkerItem.java:
--------------------------------------------------------------------------------
1 | package cn.powernukkitx.replaynk.item;
2 |
3 | import cn.nukkit.Player;
4 | import cn.nukkit.entity.Entity;
5 | import cn.powernukkitx.replaynk.ReplayNK;
6 | import cn.powernukkitx.replaynk.entity.MarkerEntity;
7 | import cn.powernukkitx.replaynk.trail.Trail;
8 |
9 | /**
10 | * @author daoge_cmd
11 | * @date 2023/6/11
12 | * ReplayNK Project
13 | */
14 | public class ClearMarkerItem extends ReplayNKItem {
15 | public ClearMarkerItem() {
16 | super("replaynk:clear_marker", "Clear Marker", "replaynk_clear_marker");
17 | }
18 |
19 | @Override
20 | public void onClickEntity(Player player, Entity entity) {
21 | if (!Trail.isOperatingTrail(player)) {
22 | player.sendMessage(ReplayNK.getI18n().tr(player.getLanguageCode(), "replaynk.trail.notoperatingtrail"));
23 | return;
24 | }
25 | if (entity instanceof MarkerEntity markerEntity) {
26 | var trail = Trail.getOperatingTrail(player);
27 | var index = markerEntity.getMarkerIndex();
28 | trail.removeMarker(index);
29 | player.sendMessage(ReplayNK.getI18n().tr(player.getLanguageCode(), "replaynk.mark.removed"));
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/cn/powernukkitx/replaynk/item/EditMarkerItem.java:
--------------------------------------------------------------------------------
1 | package cn.powernukkitx.replaynk.item;
2 |
3 | import cn.nukkit.Player;
4 | import cn.nukkit.entity.Entity;
5 | import cn.powernukkitx.replaynk.ReplayNK;
6 | import cn.powernukkitx.replaynk.entity.MarkerEntity;
7 | import cn.powernukkitx.replaynk.trail.Trail;
8 |
9 | /**
10 | * @author daoge_cmd
11 | * @date 2023/6/16
12 | * ReplayNK Project
13 | */
14 | public class EditMarkerItem extends ReplayNKItem {
15 | public EditMarkerItem() {
16 | super("replaynk:edit_marker", "Edit Marker", "replaynk_edit_marker");
17 | }
18 |
19 | @Override
20 | public void onClickEntity(Player player, Entity entity) {
21 | if (!Trail.isOperatingTrail(player)) {
22 | player.sendMessage(ReplayNK.getI18n().tr(player.getLanguageCode(), "replaynk.trail.notoperatingtrail"));
23 | return;
24 | }
25 | if (entity instanceof MarkerEntity markerEntity) {
26 | var trail = Trail.getOperatingTrail(player);
27 | var index = markerEntity.getMarkerIndex();
28 | trail.getMarkers().get(index).showEditorForm(player, trail);
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/cn/powernukkitx/replaynk/item/ExitItem.java:
--------------------------------------------------------------------------------
1 | package cn.powernukkitx.replaynk.item;
2 |
3 | import cn.nukkit.Player;
4 | import cn.powernukkitx.replaynk.ReplayNK;
5 | import cn.powernukkitx.replaynk.trail.Trail;
6 |
7 | /**
8 | * @author daoge_cmd
9 | * @date 2023/6/11
10 | * ReplayNK Project
11 | */
12 | public class ExitItem extends ReplayNKItem {
13 | public ExitItem() {
14 | super("replaynk:exit", "Exit", "replaynk_exit");
15 | }
16 |
17 | @Override
18 | public void onInteract(Player player) {
19 | if (!Trail.isOperatingTrail(player)) {
20 | player.sendMessage(ReplayNK.getI18n().tr(player.getLanguageCode(), "replaynk.trail.notoperatingtrail"));
21 | return;
22 | }
23 | var trail = Trail.getOperatingTrail(player);
24 | trail.stopOperating();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/cn/powernukkitx/replaynk/item/MarkerPickerItem.java:
--------------------------------------------------------------------------------
1 | package cn.powernukkitx.replaynk.item;
2 |
3 | import cn.nukkit.Player;
4 | import cn.nukkit.entity.Entity;
5 | import cn.powernukkitx.replaynk.ReplayNK;
6 | import cn.powernukkitx.replaynk.entity.MarkerEntity;
7 | import cn.powernukkitx.replaynk.trail.Trail;
8 |
9 | /**
10 | * @author daoge_cmd
11 | * @date 2023/6/22
12 | * ReplayNK Project
13 | */
14 | public class MarkerPickerItem extends ReplayNKItem {
15 |
16 | private static final String MARKER_INDEX_KEY = "MarkerIndex";
17 |
18 | public MarkerPickerItem() {
19 | super("replaynk:marker_picker", "Marker Picker", "replaynk_marker_picker");
20 | }
21 |
22 | @Override
23 | public void onClickEntity(Player player, Entity entity) {
24 | if (!Trail.isOperatingTrail(player)) {
25 | player.sendMessage(ReplayNK.getI18n().tr(player.getLanguageCode(), "replaynk.trail.notoperatingtrail"));
26 | return;
27 | }
28 | if (entity instanceof MarkerEntity markerEntity) {
29 | var index = markerEntity.getMarkerIndex();
30 | setNamedTag(getNamedTag().putInt(MARKER_INDEX_KEY, index));
31 | player.getInventory().setItemInHand(this);
32 | player.sendMessage(ReplayNK.getI18n().tr(player.getLanguageCode(), "replaynk.markerpicker.pick.success", index));
33 | }
34 | }
35 |
36 | @Override
37 | public void onInteract(Player player) {
38 | var trail = Trail.getOperatingTrail(player);
39 | if (trail == null) {
40 | player.sendMessage(ReplayNK.getI18n().tr(player.getLanguageCode(), "replaynk.trail.notoperatingtrail"));
41 | return;
42 | }
43 | var index = getHoldingMarkerIndex();
44 | if (index == -1) {
45 | player.sendMessage(ReplayNK.getI18n().tr(player.getLanguageCode(), "replaynk.markerpicker.nopickedmarker"));
46 | return;
47 | }
48 | setNamedTag(getNamedTag().remove(MARKER_INDEX_KEY));
49 | player.getInventory().setItemInHand(this);
50 | var marker = trail.getMarkers().get(index);
51 | marker.setX(player.getX());
52 | marker.setY(player.getY() + player.getEyeHeight());
53 | marker.setZ(player.getZ());
54 | marker.setRotX(player.getPitch());
55 | marker.setRotY(player.getYaw());
56 | trail.recalculateLinearDistanceAt(index);
57 | marker.updateDisplayEntity(trail);
58 | trail.setChanged(true);
59 | player.sendMessage(ReplayNK.getI18n().tr(player.getLanguageCode(), "replaynk.markerpicker.move.success", index));
60 | }
61 |
62 | public int getHoldingMarkerIndex() {
63 | return getNamedTag().contains(MARKER_INDEX_KEY) ? getNamedTag().getInt(MARKER_INDEX_KEY) : -1;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/cn/powernukkitx/replaynk/item/PauseItem.java:
--------------------------------------------------------------------------------
1 | package cn.powernukkitx.replaynk.item;
2 |
3 | import cn.nukkit.Player;
4 | import cn.powernukkitx.replaynk.ReplayNK;
5 | import cn.powernukkitx.replaynk.trail.Trail;
6 |
7 | /**
8 | * @author daoge_cmd
9 | * @date 2023/6/11
10 | * ReplayNK Project
11 | */
12 | public class PauseItem extends ReplayNKItem {
13 | public PauseItem() {
14 | super("replaynk:pause", "Pause", "replaynk_pause");
15 | }
16 |
17 | @Override
18 | public void onInteract(Player player) {
19 | if (!Trail.isOperatingTrail(player)) {
20 | player.sendMessage(ReplayNK.getI18n().tr(player.getLanguageCode(), "replaynk.trail.notoperatingtrail"));
21 | return;
22 | }
23 | var trail = Trail.getOperatingTrail(player);
24 | if (trail.pause()) {
25 | player.sendMessage(ReplayNK.getI18n().tr(player.getLanguageCode(), "replaynk.trail.paused"));
26 | } else {
27 | player.sendMessage(ReplayNK.getI18n().tr(player.getLanguageCode(), "replaynk.trail.notplayingtrail"));
28 | }
29 | }
30 | }
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/main/java/cn/powernukkitx/replaynk/item/PlayItem.java:
--------------------------------------------------------------------------------
1 | package cn.powernukkitx.replaynk.item;
2 |
3 | import cn.nukkit.Player;
4 | import cn.powernukkitx.replaynk.ReplayNK;
5 | import cn.powernukkitx.replaynk.trail.Trail;
6 |
7 | /**
8 | * @author daoge_cmd
9 | * @date 2023/6/11
10 | * ReplayNK Project
11 | */
12 | public class PlayItem extends ReplayNKItem {
13 | public PlayItem() {
14 | super("replaynk:play", "Play", "replaynk_play");
15 | }
16 |
17 | @Override
18 | public void onInteract(Player player) {
19 | if (!Trail.isOperatingTrail(player)) {
20 | player.sendMessage(ReplayNK.getI18n().tr(player.getLanguageCode(), "replaynk.trail.notoperatingtrail"));
21 | return;
22 | }
23 | var trail = Trail.getOperatingTrail(player);
24 | trail.play(player, true);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/cn/powernukkitx/replaynk/item/ReplayNKItem.java:
--------------------------------------------------------------------------------
1 | package cn.powernukkitx.replaynk.item;
2 |
3 | import cn.nukkit.Player;
4 | import cn.nukkit.entity.Entity;
5 | import cn.nukkit.item.customitem.CustomItemDefinition;
6 | import cn.nukkit.item.customitem.ItemCustom;
7 | import cn.nukkit.item.customitem.data.ItemCreativeCategory;
8 | import org.jetbrains.annotations.NotNull;
9 | import org.jetbrains.annotations.Nullable;
10 |
11 | /**
12 | * @author daoge_cmd
13 | * @date 2023/6/11
14 | * ReplayNK Project
15 | */
16 | public abstract class ReplayNKItem extends ItemCustom {
17 |
18 | public ReplayNKItem(@NotNull String id, @Nullable String name) {
19 | super(id, name);
20 | }
21 |
22 | public ReplayNKItem(@NotNull String id, @Nullable String name, @NotNull String textureName) {
23 | super(id, name, textureName);
24 | }
25 |
26 | @Override
27 | public CustomItemDefinition getDefinition() {
28 | return CustomItemDefinition
29 | .simpleBuilder(this, ItemCreativeCategory.NATURE)
30 | .allowOffHand(false)
31 | .build();
32 | }
33 |
34 | @Override
35 | public int getMaxStackSize() {
36 | return 1;
37 | }
38 |
39 | public void onInteract(Player player) {
40 | //Do nothing
41 | }
42 |
43 | public void onClickEntity(Player player, Entity entity) {
44 | //Do nothing
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/cn/powernukkitx/replaynk/item/SettingItem.java:
--------------------------------------------------------------------------------
1 | package cn.powernukkitx.replaynk.item;
2 |
3 | import cn.nukkit.Player;
4 | import cn.powernukkitx.replaynk.ReplayNK;
5 | import cn.powernukkitx.replaynk.trail.Trail;
6 |
7 | /**
8 | * @author daoge_cmd
9 | * @date 2023/6/16
10 | * ReplayNK Project
11 | */
12 | public class SettingItem extends ReplayNKItem {
13 | public SettingItem() {
14 | super("replaynk:setting", "Setting", "replaynk_setting");
15 | }
16 |
17 | @Override
18 | public void onInteract(Player player) {
19 | if (!Trail.isOperatingTrail(player)) {
20 | player.sendMessage(ReplayNK.getI18n().tr(player.getLanguageCode(), "replaynk.trail.notoperatingtrail"));
21 | return;
22 | }
23 | var trail = Trail.getOperatingTrail(player);
24 | trail.showEditorForm(player);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/cn/powernukkitx/replaynk/trail/Interpolator.java:
--------------------------------------------------------------------------------
1 | package cn.powernukkitx.replaynk.trail;
2 |
3 | import cn.nukkit.level.Level;
4 | import cn.nukkit.level.ParticleEffect;
5 | import cn.nukkit.math.BVector3;
6 | import cn.nukkit.math.Vector3;
7 |
8 | import java.util.ArrayList;
9 | import java.util.Arrays;
10 | import java.util.List;
11 |
12 | /**
13 | * @author daoge_cmd
14 | * @date 2023/6/18
15 | * ReplayNK Project
16 | */
17 | public enum Interpolator {
18 | LINEAR {
19 | @Override
20 | public List interpolator(List markers, double minDistance) {
21 | var cloned = new ArrayList();
22 | for (var marker : markers) {
23 | cloned.add(new Marker(marker));
24 | }
25 | return cloned;
26 | }
27 |
28 | @Override
29 | public void showParticle(List markers, Level level, boolean showDirection) {
30 | for (int i = 0; i < markers.size() - 1; i++) {
31 | var startMarker = markers.get(i);
32 | var startVec = startMarker.getVector3();
33 | var endMarker = markers.get(i + 1);
34 | var endVec = endMarker.getVector3();
35 | var distance = (int) startVec.distance(endVec);
36 | for (double j = 0; j < distance; j += 0.5) {
37 | var vec = startVec.add(endVec.subtract(startVec).multiply(j / distance));
38 | level.addParticleEffect(vec, ParticleEffect.BALLOON_GAS);
39 | if (showDirection) {
40 | var rotX = startMarker.getRotX() + (endMarker.getRotX() - startMarker.getRotX()) * j / distance;
41 | var rotY = startMarker.getRotY() + (endMarker.getRotY() - startMarker.getRotY()) * j / distance;
42 | Marker.spawnDirectionParticle(vec, rotX, rotY, level);
43 | }
44 | }
45 | }
46 | }
47 | },
48 | BEZIER_CURVES {
49 | @Override
50 | public List interpolator(List markers, double minDistance) {
51 | var runtimeMarkers = Interpolator.bezier(markers, minDistance);
52 | Trail.computeAllLinearDistance(runtimeMarkers, true, minDistance);
53 | return runtimeMarkers;
54 | }
55 | },
56 | SEGMENTED_BEZIER_CURVES {
57 | @Override
58 | public List interpolator(List markers, double minDistance) {
59 | if (markers.size() <= 4)
60 | return BEZIER_CURVES.interpolator(markers, minDistance);
61 | var runtimeMarkers = new ArrayList();
62 | var start = markers.get(0);
63 | int i = 1;
64 | do {
65 | i += 2;
66 | Marker end;
67 | if (i < markers.size() - 1) {
68 | var left = markers.get(i - 1);
69 | var right = markers.get(i);
70 | end = new Marker((left.getX() + right.getX()) / 2d, (left.getY() + right.getY()) / 2d, (left.getZ() + right.getZ()) / 2d, (left.getRotX() + right.getRotX()) / 2d, (left.getRotY() + right.getRotY()) / 2d, right.getEaseType(), (left.getCameraSpeed() + right.getCameraSpeed()) / 2d);
71 | } else {
72 | end = markers.get(markers.size() - 1);
73 | }
74 | if (!runtimeMarkers.isEmpty())
75 | runtimeMarkers.remove(runtimeMarkers.size() - 1);
76 | runtimeMarkers.addAll(Interpolator.bezier(List.of(start, markers.get(i - 2), markers.get(i - 1), end), minDistance));
77 | start = end;
78 | } while (i < markers.size() - 1);
79 | Trail.computeAllLinearDistance(runtimeMarkers, true, minDistance);
80 | return runtimeMarkers;
81 | }
82 | };
83 |
84 | public static final List INTERPOLATOR_NAMES = Arrays.stream(values()).map(interpolator -> interpolator.name().toLowerCase()).toList();
85 | private static final double DEFAULT_BEZIER_CURVE_STEP = 0.001;
86 |
87 | private static List bezier(List markers, double minDistance) {
88 | if (markers.size() <= 1)
89 | return LINEAR.interpolator(markers, minDistance);
90 | var runtimeMarkers = new ArrayList();
91 | int n = markers.size() - 1;
92 |
93 | for (double u = 0; u <= 1; u += DEFAULT_BEZIER_CURVE_STEP) {
94 | Marker[] p = new Marker[n + 1];
95 | for (int i = 0; i <= n; i++) {
96 | p[i] = new Marker(markers.get(i));
97 | }
98 |
99 | for (int r = 1; r <= n; r++) {
100 | for (int i = 0; i <= n - r; i++) {
101 | p[i].setX((1 - u) * p[i].getX() + u * p[i + 1].getX());
102 | p[i].setY((1 - u) * p[i].getY() + u * p[i + 1].getY());
103 | p[i].setZ((1 - u) * p[i].getZ() + u * p[i + 1].getZ());
104 | p[i].setRotX((1 - u) * p[i].getRotX() + u * p[i + 1].getRotX());
105 | var startDirection = p[i].getDirectionVec().addToPos();
106 | var endDirection = p[i + 1].getDirectionVec().addToPos();
107 | var resultDirection = BVector3.fromPos(
108 | (1 - u) * startDirection.getX() + u * endDirection.getX(),
109 | (1 - u) * startDirection.getY() + u * endDirection.getY(),
110 | (1 - u) * startDirection.getZ() + u * endDirection.getZ());
111 | p[i].setRotY(resultDirection.getYaw());
112 | p[i].setCameraSpeed((1 - u) * p[i].getCameraSpeed() + u * p[i + 1].getCameraSpeed());
113 | }
114 | }
115 | runtimeMarkers.add(p[0]);
116 | }
117 | return runtimeMarkers;
118 | }
119 |
120 | /**
121 | * 调用此方法即已保证markers.size() >= 2
122 | */
123 | public List interpolator(List markers, double minDistance) {
124 | throw new UnsupportedOperationException();
125 | }
126 |
127 | public void showParticle(List markers, Level level, boolean showDirection) {
128 | markers.forEach(marker -> {
129 | level.addParticleEffect(new Vector3(marker.getX(), marker.getY(), marker.getZ()), ParticleEffect.BALLOON_GAS);
130 | if (showDirection)
131 | Marker.spawnDirectionParticle(marker.getVector3(), marker.getRotX(), marker.getRotY(), level);
132 | });
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/src/main/java/cn/powernukkitx/replaynk/trail/Marker.java:
--------------------------------------------------------------------------------
1 | package cn.powernukkitx.replaynk.trail;
2 |
3 | import cn.nukkit.Player;
4 | import cn.nukkit.camera.data.*;
5 | import cn.nukkit.camera.instruction.impl.ClearInstruction;
6 | import cn.nukkit.camera.instruction.impl.SetInstruction;
7 | import cn.nukkit.entity.Entity;
8 | import cn.nukkit.form.element.ElementDropdown;
9 | import cn.nukkit.form.element.ElementInput;
10 | import cn.nukkit.form.element.ElementLabel;
11 | import cn.nukkit.form.element.ElementToggle;
12 | import cn.nukkit.form.window.FormWindowCustom;
13 | import cn.nukkit.level.Level;
14 | import cn.nukkit.level.Position;
15 | import cn.nukkit.math.BVector3;
16 | import cn.nukkit.math.Vector3;
17 | import cn.nukkit.network.protocol.CameraInstructionPacket;
18 | import cn.nukkit.network.protocol.SpawnParticleEffectPacket;
19 | import cn.nukkit.potion.Effect;
20 | import cn.powernukkitx.replaynk.ReplayNK;
21 | import cn.powernukkitx.replaynk.entity.MarkerEntity;
22 | import lombok.Getter;
23 | import lombok.Setter;
24 | import lombok.SneakyThrows;
25 |
26 | import java.util.Arrays;
27 | import java.util.List;
28 |
29 | /**
30 | * @author daoge_cmd
31 | * @date 2023/6/18
32 | * ReplayNK Project
33 | */
34 | public final class Marker {
35 | @Getter
36 | @Setter
37 | private double x;
38 | @Getter
39 | @Setter
40 | private double y;
41 | @Getter
42 | @Setter
43 | private double z;
44 | @Getter
45 | @Setter
46 | private double rotX;
47 | @Getter
48 | @Setter
49 | private double rotY;
50 | @Getter
51 | @Setter
52 | private EaseType easeType;
53 | @Getter
54 | private double cameraSpeed = 1;
55 | @Getter
56 | private double distance = 1;
57 |
58 | @Getter
59 | private transient double easeTime = 1;
60 | private transient MarkerEntity markerEntity;
61 | //用于给RuntimeMark缓存index,防止运镜卡顿
62 | private transient int cachedIndex;
63 | @Getter
64 | @Setter
65 | private transient boolean runtimeMark = false;
66 |
67 | public Marker(double x, double y, double z, double rotX, double rotY, double cameraSpeed) {
68 | this(x, y, z, rotX, rotY, EaseType.LINEAR, cameraSpeed);
69 | }
70 |
71 | public Marker(double x, double y, double z, double rotX, double rotY, EaseType easeType, double cameraSpeed) {
72 | this.x = x;
73 | this.y = y;
74 | this.z = z;
75 | this.rotX = rotX;
76 | this.rotY = rotY;
77 | this.easeType = easeType;
78 | this.cameraSpeed = cameraSpeed;
79 | computeEaseTime();
80 | }
81 |
82 | public Marker(Marker marker) {
83 | this.x = marker.x;
84 | this.y = marker.y;
85 | this.z = marker.z;
86 | this.rotX = marker.rotX;
87 | this.rotY = marker.rotY;
88 | this.easeType = marker.easeType;
89 | this.cameraSpeed = marker.cameraSpeed;
90 | this.distance = marker.distance;
91 | this.easeTime = marker.easeTime;
92 | }
93 |
94 | public static void spawnDirectionParticle(Vector3 pos, double rotX, double rotY, Level level) {
95 | var pk = new SpawnParticleEffectPacket();
96 | pk.dimensionId = level.getDimensionData().getDimensionId();
97 | pk.uniqueEntityId = -1;
98 | pk.identifier = "replaynk:arrow";
99 | pk.position = pos.asVector3f();
100 | var facing = BVector3.fromAngle(rotY, rotX).add(pos).getDirectionVector();
101 | pk.molangVariablesJson = ("[{\"name\":\"variable.x\",\"value\":{\"type\":\"float\",\"value\":" +
102 | facing.x +
103 | "}},{\"name\":\"variable.y\",\"value\":{\"type\":\"float\",\"value\":" +
104 | facing.y +
105 | "}},{\"name\":\"variable.z\",\"value\":{\"type\":\"float\",\"value\":" +
106 | facing.z +
107 | "}}]").describeConstable();
108 | level.addChunkPacket((int) pos.x >> 4, (int) pos.z >> 4, pk);
109 | }
110 |
111 | public void cacheIndex(int cachedIndex) {
112 | if (!runtimeMark)
113 | throw new IllegalStateException("Only runtime mark can cache index!");
114 | this.cachedIndex = cachedIndex;
115 | }
116 |
117 | public void setCameraSpeedAndCalDistance(Marker lastMarker, double cameraSpeed) {
118 | setCameraSpeed(cameraSpeed);
119 | computeDistance(lastMarker);
120 | computeEaseTime();
121 | }
122 |
123 | public void computeDistance(Trail trail) {
124 | var index = trail.getMarkers().indexOf(this);
125 | if (index == 0) {
126 | distance = 1;
127 | cameraSpeed = 1;
128 | } else {
129 | computeDistance(trail.getMarkers().get(index - 1));
130 | }
131 | }
132 |
133 | public void computeDistance(Marker lastMarker) {
134 | distance = Math.sqrt(Math.pow(lastMarker.x - x, 2) + Math.pow(lastMarker.y - y, 2) + Math.pow(lastMarker.z - z, 2));
135 | computeEaseTime();
136 | }
137 |
138 | public void setDistance(double distance) {
139 | this.distance = distance;
140 | computeEaseTime();
141 | }
142 |
143 | public void setCameraSpeed(double cameraSpeed) {
144 | this.cameraSpeed = cameraSpeed;
145 | computeEaseTime();
146 | }
147 |
148 | public void computeEaseTime() {
149 | this.easeTime = distance / this.cameraSpeed;
150 | }
151 |
152 | public void spawnDisplayEntity(Level level, Trail trail) {
153 | if (markerEntity != null)
154 | throw new IllegalStateException("Marker entity already exists.");
155 | markerEntity = (MarkerEntity) Entity.createEntity("replaynk:marker", new Position(x, y, z, level));
156 | if (markerEntity == null)
157 | throw new IllegalStateException("Failed to create marker entity.");
158 | markerEntity.setNameTagAlwaysVisible(true);
159 | updateDisplayEntity(trail);
160 | if (trail.isShowMarkerEntityToAllPlayers()) {
161 | markerEntity.spawnToAll();
162 | } else {
163 | markerEntity.spawnTo(trail.getOperator());
164 | }
165 | }
166 |
167 | public void respawnDisplayEntity(Level level, Trail trail) {
168 | markerEntity.close();
169 | markerEntity = null;
170 | spawnDisplayEntity(level, trail);
171 | }
172 |
173 | public void updateDisplayEntity(Trail trail) {
174 | if (markerEntity != null) {
175 | var index = trail.getMarkers().indexOf(this);
176 | markerEntity.setPitch(rotX);
177 | markerEntity.setYaw(rotY);
178 | markerEntity.setPosition(new Vector3(x, y, z));
179 | markerEntity.setMarkerIndex(index);
180 | }
181 | }
182 |
183 | public void deleteDisplayEntity() {
184 | if (markerEntity != null) {
185 | markerEntity.close();
186 | markerEntity = null;
187 | }
188 | }
189 |
190 | public boolean isDisplayEntitySpawned() {
191 | return markerEntity != null;
192 | }
193 |
194 | public void showEditorForm(Player player, Trail trail) {
195 | var langCode = player.getLanguageCode();
196 | var markers = trail.getMarkers();
197 | var posElement = new ElementInput(ReplayNK.getI18n().tr(langCode, "replaynk.mark.editorform.pos"), "", x + ", " + y + ", " + z);
198 | var rotElement = new ElementInput(ReplayNK.getI18n().tr(langCode, "replaynk.mark.editorform.rot"), "", rotX + ", " + rotY);
199 | var easeTypeElement = new ElementDropdown(ReplayNK.getI18n().tr(langCode, "replaynk.mark.editorform.easetype"), Arrays.stream(EaseType.values()).map(EaseType::getType).toList(), 0);
200 | var easeTypeDetailsElement = new ElementLabel(ReplayNK.getI18n().tr(langCode, "replaynk.mark.editorform.easetype.details"));
201 | var indexElement = new ElementInput(ReplayNK.getI18n().tr(langCode, "replaynk.mark.editorform.index"), "", String.valueOf(markers.indexOf(this)));
202 | var indexDetailsElement = new ElementLabel(ReplayNK.getI18n().tr(langCode, "replaynk.mark.editorform.index.details"));
203 | var easeTimeElement = new ElementInput(ReplayNK.getI18n().tr(langCode, "replaynk.mark.editorform.easetime"), "", this.cameraSpeed + "m/s");
204 | var easeTimeDetailsElement = new ElementLabel(ReplayNK.getI18n().tr(langCode, "replaynk.mark.editorform.easetime.details"));
205 | var autoEaseTimeElement = new ElementToggle(ReplayNK.getI18n().tr(langCode, "replaynk.mark.editorform.autoeasetime"), true);
206 | var form = new FormWindowCustom("Marker - " + markers.indexOf(this), List.of(posElement, rotElement, easeTypeElement, easeTypeDetailsElement, indexElement, indexDetailsElement, easeTimeElement, easeTimeDetailsElement, autoEaseTimeElement));
207 | form.addHandler((p, id) -> {
208 | var response = form.getResponse();
209 | if (response == null) return;
210 | try {
211 | var pos = response.getInputResponse(0).split(",");
212 | if (pos.length != 3) {
213 | player.sendMessage(ReplayNK.getI18n().tr(langCode, "replaynk.mark.invalidpos"));
214 | return;
215 | }
216 | x = Double.parseDouble(pos[0]);
217 | y = Double.parseDouble(pos[1]);
218 | z = Double.parseDouble(pos[2]);
219 |
220 | var rot = response.getInputResponse(1).split(",");
221 | if (rot.length != 2) {
222 | player.sendMessage(ReplayNK.getI18n().tr(langCode, "replaynk.mark.invalidrot"));
223 | return;
224 | }
225 | rotX = Double.parseDouble(rot[0]);
226 | rotY = Double.parseDouble(rot[1]);
227 |
228 | easeType = EaseType.valueOf(response.getDropdownResponse(2).getElementContent().toUpperCase());
229 |
230 | var newIndex = Integer.parseInt(response.getInputResponse(4));
231 | if (newIndex < 0 || newIndex >= markers.size()) {
232 | player.sendMessage(ReplayNK.getI18n().tr(langCode, "replaynk.mark.invalidindex"));
233 | return;
234 | }
235 | int oldIndex = markers.indexOf(this);
236 | if (newIndex != oldIndex) {
237 | trail.moveMarker(oldIndex, newIndex);
238 | computeDistance(trail);
239 | }
240 | respawnDisplayEntity(player.getLevel(), trail);
241 |
242 | var easeTimeOrSpeed = response.getInputResponse(6);
243 | if (easeTimeOrSpeed.endsWith("m/s")) {
244 | cameraSpeed = Double.parseDouble(easeTimeOrSpeed.substring(0, easeTimeOrSpeed.length() - 3));
245 | } else if (easeTimeOrSpeed.endsWith("s")) {
246 | var time = Double.parseDouble(easeTimeOrSpeed.substring(0, easeTimeOrSpeed.length() - 1));
247 | cameraSpeed = distance / time;
248 | } else {
249 | player.sendMessage(ReplayNK.getI18n().tr(langCode, "replaynk.mark.invalideasetime"));
250 | return;
251 | }
252 |
253 | var autoEaseTime = response.getToggleResponse(8);
254 | if (autoEaseTime) {
255 | var index = markers.indexOf(this);
256 | if (index > 0) {
257 | var lastMarker = markers.get(index - 1);
258 | computeDistance(lastMarker);
259 | } else {
260 | easeTime = -1;
261 | }
262 | }
263 |
264 | trail.setChanged(true);
265 | } catch (Exception e) {
266 | player.sendMessage(ReplayNK.getI18n().tr(langCode, "replaynk.generic.invalidinput"));
267 | }
268 | });
269 | player.showFormWindow(form);
270 | }
271 |
272 | @SneakyThrows
273 | public void play(Player player, Trail trail) {
274 | //TODO: 会导致运镜卡顿,需要一个更好的方案解决区块加载问题
275 | // if (!player.hasEffect(Effect.INVISIBILITY))
276 | // player.addEffect(Effect.getEffect(Effect.INVISIBILITY).setDuration(999999).setVisible(false));
277 | // player.teleport(new Location(x, y, z, rotY, rotX));
278 | var pk = new CameraInstructionPacket();
279 | var preset = CameraPreset.FREE;
280 | if (cachedIndex == 0) {
281 | pk.setInstruction(SetInstruction.builder()
282 | .preset(preset)
283 | .pos(new Pos((float) x, (float) y, (float) z))
284 | .rot(new Rot((float) rotX, (float) rotY))
285 | .build());
286 | player.dataPacket(pk);
287 | //等待1s开始
288 | Thread.sleep(1000);
289 | } else {
290 | pk.setInstruction(SetInstruction.builder()
291 | .preset(preset)
292 | .pos(new Pos((float) x, (float) y, (float) z))
293 | .rot(new Rot((float) rotX, (float) rotY))
294 | .ease(new Ease((float) easeTime, easeType))
295 | .build());
296 | player.dataPacket(pk);
297 | //提前25ms以避免卡顿
298 | var sleepTime = (long) (easeTime * 1000) - 25;
299 | if (sleepTime > 0) {
300 | Thread.sleep(sleepTime);
301 | }
302 | }
303 | if (!trail.isPlaying() || cachedIndex == trail.getRuntimeMarkers().size() - 1) {
304 | trail.setPlaying(false);
305 | resetCamera(player);
306 | trail.getMarkers().forEach(Marker::visible);
307 | trail.clearRuntimeMarkers();
308 | //TODO 同上
309 | // player.removeEffect(Effect.INVISIBILITY);
310 | return;
311 | }
312 | trail.getRuntimeMarkers().get(cachedIndex + 1).play(player, trail);
313 | }
314 |
315 | public void invisible() {
316 | if (markerEntity != null) {
317 | markerEntity.addEffect(Effect.getEffect(Effect.INVISIBILITY).setDuration(999999).setVisible(false));
318 | }
319 | }
320 |
321 | public void visible() {
322 | if (markerEntity != null) {
323 | markerEntity.removeEffect(Effect.INVISIBILITY);
324 | }
325 | }
326 |
327 | public Vector3 getVector3() {
328 | return new Vector3(x, y, z);
329 | }
330 |
331 | public BVector3 getDirectionVec() {
332 | return BVector3.fromAngle(rotY, rotX);
333 | }
334 |
335 | public Vector3 getOffsettedDirectionVec() {
336 | return getDirectionVec().addToPos(getVector3());
337 | }
338 |
339 | private void resetCamera(Player player) {
340 | var pk = new CameraInstructionPacket();
341 | pk.setInstruction(ClearInstruction.get());
342 | player.dataPacket(pk);
343 | }
344 | }
345 |
--------------------------------------------------------------------------------
/src/main/java/cn/powernukkitx/replaynk/trail/Trail.java:
--------------------------------------------------------------------------------
1 | package cn.powernukkitx.replaynk.trail;
2 |
3 | import cn.nukkit.Player;
4 | import cn.nukkit.api.DoNotModify;
5 | import cn.nukkit.camera.instruction.impl.ClearInstruction;
6 | import cn.nukkit.form.element.ElementDropdown;
7 | import cn.nukkit.form.element.ElementInput;
8 | import cn.nukkit.form.element.ElementLabel;
9 | import cn.nukkit.form.element.ElementToggle;
10 | import cn.nukkit.form.window.FormWindowCustom;
11 | import cn.nukkit.item.Item;
12 | import cn.nukkit.network.protocol.CameraInstructionPacket;
13 | import cn.powernukkitx.replaynk.ReplayNK;
14 | import cn.powernukkitx.replaynk.item.*;
15 | import com.google.gson.Gson;
16 | import com.google.gson.GsonBuilder;
17 | import lombok.Getter;
18 | import lombok.Setter;
19 | import lombok.SneakyThrows;
20 | import lombok.extern.log4j.Log4j2;
21 |
22 | import javax.annotation.Nullable;
23 | import java.io.IOException;
24 | import java.nio.file.Files;
25 | import java.util.*;
26 |
27 | /**
28 | * @author daoge_cmd
29 | * @date 2023/6/16
30 | * ReplayNK Project
31 | */
32 | @Getter
33 | @Log4j2
34 | public final class Trail {
35 |
36 | public static final double DEFAULT_MIN_DISTANCE = 0.5;
37 | public static final double DEFAULT_CAMERA_SPEED = 2;
38 | public static final double DEFAULT_CAMERA_SPEED_MULTIPLE = 1;
39 | private static final Gson GSON = new GsonBuilder()
40 | .setPrettyPrinting()
41 | .create();
42 | private static final Map TRAILS = new HashMap<>();
43 | private static final Map OPERATING_TRAILS = new HashMap<>();
44 | private final List markers = new ArrayList<>();
45 | private final String name;
46 | private transient Player operator;
47 | @Setter
48 | private transient boolean playing;
49 | private transient List runtimeMarkers;
50 | @Setter
51 | private transient boolean changed;
52 | @Setter
53 | private boolean showTrail = true;
54 | @Setter
55 | private boolean showMarkerDirection = true;
56 | @Setter
57 | private boolean showMarkerEntityToAllPlayers = true;
58 | @Setter
59 | private double minDistance = DEFAULT_MIN_DISTANCE;
60 | @Setter
61 | private double defaultCameraSpeed = DEFAULT_CAMERA_SPEED;
62 | @Setter
63 | private double cameraSpeedMultiple = DEFAULT_CAMERA_SPEED_MULTIPLE;
64 | @Setter
65 | private Interpolator interpolator = Interpolator.BEZIER_CURVES;
66 |
67 | private Trail(String name) {
68 | this.name = name;
69 | }
70 |
71 | @DoNotModify
72 | public static Map getTrails() {
73 | return TRAILS;
74 | }
75 |
76 | public static Trail getTrail(String name) {
77 | return TRAILS.get(name);
78 | }
79 |
80 | public static void addTrail(Trail trail) {
81 | if (TRAILS.containsKey(trail.getName()))
82 | throw new IllegalArgumentException("Trail " + trail.getName() + " already exists.");
83 | TRAILS.put(trail.getName(), trail);
84 | }
85 |
86 | @Nullable
87 | public static Trail removeTrail(String name) {
88 | var removed = TRAILS.get(name);
89 | if (removed == null)
90 | return null;
91 | if (removed.getOperator() != null) {
92 | removed.stopOperating();
93 | }
94 | TRAILS.remove(name);
95 | return removed;
96 | }
97 |
98 | @SneakyThrows
99 | public static void readAllTrails() {
100 | var basePath = ReplayNK.getInstance().getDataFolder().toPath().resolve("trails");
101 | if (!Files.exists(basePath)) {
102 | Files.createDirectories(basePath);
103 | return;
104 | }
105 | try (var paths = Files.walk(basePath)) {
106 | paths.forEach(path -> {
107 | if (Files.isDirectory(path))
108 | return;
109 | String json;
110 | try {
111 | json = Files.readString(path);
112 | } catch (IOException e) {
113 | throw new RuntimeException(e);
114 | }
115 | var trail = fromJson(json);
116 | log.info("Loaded trail " + trail.getName() + " from " + path);
117 | });
118 | }
119 | }
120 |
121 | @SneakyThrows
122 | public static void saveAllTrails() {
123 | for (var trail : TRAILS.values()) {
124 | var basePath = ReplayNK.getInstance().getDataFolder().toPath().resolve("trails");
125 | if (!Files.exists(basePath))
126 | Files.createDirectory(basePath);
127 | var path = basePath.resolve(trail.getName() + ".json");
128 | log.info("Saving trail " + trail.getName() + " to " + path);
129 | if (!Files.exists(path))
130 | Files.createFile(path);
131 | var json = trail.toJson();
132 | Files.writeString(path, json);
133 | }
134 | }
135 |
136 | public static void closeAndSave() {
137 | for (var trail : OPERATING_TRAILS.values()) {
138 | trail.stopOperating();
139 | }
140 | saveAllTrails();
141 | }
142 |
143 | public static Trail getOperatingTrail(Player player) {
144 | return OPERATING_TRAILS.get(player);
145 | }
146 |
147 | public static Set getOperatingPlayers() {
148 | return OPERATING_TRAILS.keySet();
149 | }
150 |
151 | public static boolean isOperatingTrail(Player player) {
152 | return OPERATING_TRAILS.containsKey(player);
153 | }
154 |
155 | public static Trail create(String name) {
156 | if (TRAILS.containsKey(name))
157 | return null;
158 | var trail = new Trail(name);
159 | addTrail(trail);
160 | return trail;
161 | }
162 |
163 | public static Trail fromJson(String json) {
164 | var trail = GSON.fromJson(json, Trail.class);
165 | addTrail(trail);
166 | return trail;
167 | }
168 |
169 | public static void computeAllLinearDistance(List markers, boolean doRemoveTooCloseMarker, double minDistance) {
170 | boolean first = true;
171 | for (Iterator iterator = markers.iterator(); iterator.hasNext(); ) {
172 | var marker = iterator.next();
173 | if (first) {
174 | first = false;
175 | marker.setDistance(1);
176 | marker.setCameraSpeed(1);
177 | continue;
178 | }
179 | var lastMarker = markers.get(markers.indexOf(marker) - 1);
180 | var distance = Math.sqrt(Math.pow(lastMarker.getX() - marker.getX(), 2) + Math.pow(lastMarker.getY() - marker.getY(), 2) + Math.pow(lastMarker.getZ() - marker.getZ(), 2));
181 | if (distance < minDistance && doRemoveTooCloseMarker) {
182 | iterator.remove();
183 | } else {
184 | marker.setDistance(distance);
185 | }
186 | }
187 | }
188 |
189 | public void startOperating(Player player) {
190 | if (operator != null)
191 | throw new IllegalStateException("Trail " + name + " is already operating by " + operator.getName());
192 | operator = player;
193 | OPERATING_TRAILS.put(player, this);
194 | prepareHotBar(player);
195 | markers.forEach(marker -> marker.spawnDisplayEntity(player.getLevel(), this));
196 | }
197 |
198 | public void tick() {
199 | if (operator != null && !playing) {
200 | if (showTrail)
201 | interpolator.showParticle(getOrCalculateRuntimeMarkers(), operator.getLevel(), showMarkerDirection);
202 | if (showMarkerDirection)
203 | markers.forEach(marker -> Marker.spawnDirectionParticle(marker.getVector3(), marker.getRotX(), marker.getRotY(), operator.getLevel()));
204 | }
205 | }
206 |
207 | public void clearRuntimeMarkers() {
208 | if (runtimeMarkers == null) {
209 | runtimeMarkers = new ArrayList<>();
210 | return;
211 | }
212 | if (runtimeMarkers.isEmpty())
213 | return;
214 | runtimeMarkers.clear();
215 | }
216 |
217 | public List getOrCalculateRuntimeMarkers() {
218 | if (runtimeMarkers == null || runtimeMarkers.isEmpty() || isChanged()) {
219 | prepareRuntimeMarkers();
220 | setChanged(false);
221 | }
222 | return runtimeMarkers;
223 | }
224 |
225 | private void prepareHotBar(Player player) {
226 | var inventory = player.getInventory();
227 | inventory.clearAll();
228 |
229 | var addMarkerItem = new AddMarkerItem();
230 | var clearMarkerItem = new ClearMarkerItem();
231 | var editMarkerItem = new EditMarkerItem();
232 | var markerPickerItem = new MarkerPickerItem();
233 | var playItem = new PlayItem();
234 | var pauseItem = new PauseItem();
235 | var settingItem = new SettingItem();
236 | var exitItem = new ExitItem();
237 |
238 | addMarkerItem.setItemLockMode(Item.ItemLockMode.LOCK_IN_SLOT);
239 | clearMarkerItem.setItemLockMode(Item.ItemLockMode.LOCK_IN_SLOT);
240 | editMarkerItem.setItemLockMode(Item.ItemLockMode.LOCK_IN_SLOT);
241 | markerPickerItem.setItemLockMode(Item.ItemLockMode.LOCK_IN_SLOT);
242 | playItem.setItemLockMode(Item.ItemLockMode.LOCK_IN_SLOT);
243 | pauseItem.setItemLockMode(Item.ItemLockMode.LOCK_IN_SLOT);
244 | settingItem.setItemLockMode(Item.ItemLockMode.LOCK_IN_SLOT);
245 | exitItem.setItemLockMode(Item.ItemLockMode.LOCK_IN_SLOT);
246 |
247 | inventory.setItem(0, addMarkerItem);
248 | inventory.setItem(1, clearMarkerItem);
249 | inventory.setItem(2, editMarkerItem);
250 | inventory.setItem(3, markerPickerItem);
251 | inventory.setItem(4, playItem);
252 | inventory.setItem(5, pauseItem);
253 | inventory.setItem(6, settingItem);
254 | inventory.setItem(8, exitItem);
255 | }
256 |
257 | public void stopOperating() {
258 | if (operator == null)
259 | throw new IllegalStateException("Trail " + name + " is not operating.");
260 | playing = false;
261 | OPERATING_TRAILS.remove(operator);
262 | operator.getInventory().clearAll();
263 | markers.forEach(Marker::deleteDisplayEntity);
264 | operator.sendMessage(ReplayNK.getI18n().tr(operator.getLanguageCode(), "replaynk.trail.stopoperating", name));
265 | operator = null;
266 | }
267 |
268 | public void addMarker(Marker marker) {
269 | markers.add(marker);
270 | if (operator != null) {
271 | marker.spawnDisplayEntity(operator.getLevel(), this);
272 | }
273 | recalculateLinearDistanceAt(markers.size() - 1);
274 | }
275 |
276 | public void replaceMarker(int index, Marker marker) {
277 | var replacedMarker = markers.set(index, marker);
278 | replacedMarker.deleteDisplayEntity();
279 | if (operator != null) {
280 | marker.spawnDisplayEntity(operator.getLevel(), this);
281 | }
282 | recalculateLinearDistanceAt(index);
283 | }
284 |
285 | public void insertMarker(int index, Marker marker) {
286 | markers.add(index, marker);
287 | if (operator != null) {
288 | marker.spawnDisplayEntity(operator.getLevel(), this);
289 | }
290 | for (int i = index + 1; i < markers.size(); i++) {
291 | markers.get(i).updateDisplayEntity(this);
292 | }
293 | recalculateLinearDistanceAt(index);
294 | }
295 |
296 | public void removeMarker(int index) {
297 | var removedMarker = markers.remove(index);
298 | removedMarker.deleteDisplayEntity();
299 | for (int i = index; i < markers.size(); i++) {
300 | markers.get(i).updateDisplayEntity(this);
301 | }
302 | if (index < markers.size())
303 | recalculateLinearDistanceAt(index);
304 | else
305 | setChanged(true);
306 | }
307 |
308 | public void moveMarker(int oldIndex, int newIndex) {
309 | var marker = markers.remove(oldIndex);
310 | markers.add(newIndex, marker);
311 | for (int i = Math.min(oldIndex, newIndex); i < markers.size(); i++) {
312 | markers.get(i).updateDisplayEntity(this);
313 | }
314 | recalculateLinearDistanceAt(oldIndex);
315 | recalculateLinearDistanceAt(newIndex);
316 | }
317 |
318 | public void recalculateAllLinearDistance() {
319 | computeAllLinearDistance(markers, false, minDistance);
320 | setChanged(true);
321 | }
322 |
323 | public void recalculateLinearDistanceAt(int index) {
324 | if (index < 0 || index >= markers.size())
325 | throw new IndexOutOfBoundsException("Index out of bounds: " + index);
326 | var marker = markers.get(index);
327 | if (index == 0) {
328 | marker.setDistance(1);
329 | return;
330 | }
331 | var prevMarker = markers.get(index - 1);
332 | marker.computeDistance(prevMarker);
333 | if (index < markers.size() - 1) {
334 | var nextMarker = markers.get(index + 1);
335 | nextMarker.computeDistance(marker);
336 | }
337 | setChanged(true);
338 | }
339 |
340 | public String toJson() {
341 | return GSON.toJson(this);
342 | }
343 |
344 | public void play(Player player, boolean showMessage) {
345 | var langCode = player.getLanguageCode();
346 | if (playing) {
347 | if (showMessage) player.sendMessage(ReplayNK.getI18n().tr(langCode, "replaynk.trail.alreadyplaying", name));
348 | return;
349 | }
350 | if (markers.size() <= 1) {
351 | if (showMessage) player.sendMessage(ReplayNK.getI18n().tr(langCode, "replaynk.trail.toolittlemarks", name));
352 | return;
353 | }
354 | if (showMessage) player.sendMessage(ReplayNK.getI18n().tr(langCode, "replaynk.trail.startplaying", name));
355 | //TODO: 去掉这个playing标识,现在只能同时给一个玩家播放:(
356 | playing = true;
357 | markers.forEach(Marker::invisible);
358 | prepareRuntimeMarkers();
359 | new Thread(() -> runtimeMarkers.get(0).play(player, this)).start();
360 | }
361 |
362 | public void showEditorForm(Player player) {
363 | var langCode = player.getLanguageCode();
364 | var interpolatorElement = new ElementDropdown(ReplayNK.getI18n().tr(langCode, "replaynk.trail.editorform.interpolator"), Interpolator.INTERPOLATOR_NAMES, Interpolator.INTERPOLATOR_NAMES.indexOf(interpolator.name().toLowerCase()));
365 | var interpolatorDetailsElement = new ElementLabel(ReplayNK.getI18n().tr(langCode, "replaynk.trail.editorform.interpolator.details"));
366 | var showTrailElement = new ElementToggle(ReplayNK.getI18n().tr(langCode, "replaynk.trail.editorform.showtrail"), showTrail);
367 | var showTrailDetailsElement = new ElementLabel(ReplayNK.getI18n().tr(langCode, "replaynk.trail.editorform.showtrail.details"));
368 | var showMarkerDirectionElement = new ElementToggle(ReplayNK.getI18n().tr(langCode, "replaynk.trail.editorform.showmarkerdirection"), showMarkerDirection);
369 | var showMarkerDirectionDetailsElement = new ElementLabel(ReplayNK.getI18n().tr(langCode, "replaynk.trail.editorform.showmarkerdirection.details"));
370 | var minDistanceElement = new ElementInput(ReplayNK.getI18n().tr(langCode, "replaynk.trail.editorform.mindistance"), String.valueOf(DEFAULT_MIN_DISTANCE), String.valueOf(minDistance));
371 | var minDistanceDetailsElement = new ElementLabel(ReplayNK.getI18n().tr(langCode, "replaynk.trail.editorform.mindistance.details"));
372 | var defaultCameraSpeedElement = new ElementInput(ReplayNK.getI18n().tr(langCode, "replaynk.trail.editorform.defaultcameraspeed"), String.valueOf(DEFAULT_CAMERA_SPEED), String.valueOf(defaultCameraSpeed));
373 | var defaultCameraSpeedDetailsElement = new ElementLabel(ReplayNK.getI18n().tr(langCode, "replaynk.trail.editorform.defaultcameraspeed.details"));
374 | var doRecalculateEaseTimeElement = new ElementToggle(ReplayNK.getI18n().tr(langCode, "replaynk.trail.editorform.dorecalculateeasetime"), false);
375 | var doRecalculateEaseTimeDetailsElement = new ElementLabel(ReplayNK.getI18n().tr(langCode, "replaynk.trail.editorform.dorecalculateeasetime.details"));
376 | var cameraSpeedMultipleElement = new ElementInput(ReplayNK.getI18n().tr(langCode, "replaynk.trail.editorform.cameraspeedmultiple"), String.valueOf(DEFAULT_CAMERA_SPEED_MULTIPLE), String.valueOf(cameraSpeedMultiple));
377 | var cameraSpeedMultipleDetailsElement = new ElementLabel(ReplayNK.getI18n().tr(langCode, "replaynk.trail.editorform.cameraspeedmultiple.details"));
378 | var showMarkerEntityToAllPlayersElement = new ElementToggle(ReplayNK.getI18n().tr(langCode, "replaynk.trail.editorform.showmarkerentitytoallplayers"), showMarkerEntityToAllPlayers);
379 | var showMarkerEntityToAllPlayersDetailsElement = new ElementLabel(ReplayNK.getI18n().tr(langCode, "replaynk.trail.editorform.showmarkerentitytoallplayers.details"));
380 | var form = new FormWindowCustom(name, List.of(
381 | interpolatorElement,
382 | interpolatorDetailsElement,
383 | showTrailElement,
384 | showTrailDetailsElement,
385 | showMarkerDirectionElement,
386 | showMarkerDirectionDetailsElement,
387 | minDistanceElement,
388 | minDistanceDetailsElement,
389 | defaultCameraSpeedElement,
390 | defaultCameraSpeedDetailsElement,
391 | doRecalculateEaseTimeElement,
392 | doRecalculateEaseTimeDetailsElement,
393 | cameraSpeedMultipleElement,
394 | cameraSpeedMultipleDetailsElement,
395 | showMarkerEntityToAllPlayersElement,
396 | showMarkerEntityToAllPlayersDetailsElement));
397 | form.addHandler((p, id) -> {
398 | var response = form.getResponse();
399 | if (response == null) return;
400 | try {
401 | var newInterpolator = Interpolator.valueOf(response.getDropdownResponse(0).getElementContent().toUpperCase());
402 | if (interpolator != newInterpolator) {
403 | interpolator = newInterpolator;
404 | setChanged(true);
405 | }
406 | showTrail = response.getToggleResponse(2);
407 | showMarkerDirection = response.getToggleResponse(4);
408 | var newMinDistance = Double.parseDouble(response.getInputResponse(6));
409 | if (Math.abs(minDistance - newMinDistance) > 0.0001) {
410 | minDistance = newMinDistance;
411 | setChanged(true);
412 | }
413 | defaultCameraSpeed = Double.parseDouble(response.getInputResponse(8));
414 | if (response.getToggleResponse(10)) {
415 | resetAllMarkerSpeed();
416 | computeAllLinearDistance(markers, false, minDistance);
417 | }
418 | var multiple = Double.parseDouble(response.getInputResponse(12));
419 | if (multiple <= 0) {
420 | throw new IllegalArgumentException();
421 | }
422 | this.cameraSpeedMultiple = multiple;
423 | showMarkerEntityToAllPlayers = response.getToggleResponse(14);
424 | } catch (Exception e) {
425 | player.sendMessage(ReplayNK.getI18n().tr(langCode, "replaynk.generic.invalidinput"));
426 | }
427 | });
428 | player.showFormWindow(form);
429 | }
430 |
431 | public void prepareRuntimeMarkers() {
432 | clearRuntimeMarkers();
433 | if (markers.size() == 0) {
434 | return;
435 | } else if (markers.size() == 1) {
436 | runtimeMarkers.add(markers.get(0));
437 | return;
438 | }
439 | //将第一个点的cameraSpeed设置为第二个点的cameraSpeed,以保证第一个点的cameraSpeed不会影响到插值
440 | markers.get(0).setCameraSpeed(markers.get(1).getCameraSpeed());
441 | runtimeMarkers = interpolator.interpolator(new ArrayList<>(markers), minDistance);
442 | runtimeMarkers.forEach(marker -> {
443 | marker.setCameraSpeed(marker.getCameraSpeed() * cameraSpeedMultiple);
444 | marker.setRuntimeMark(true);
445 | });
446 | cacheIndexForRuntimeMarkers();
447 | }
448 |
449 | public void resetAllMarkerSpeed() {
450 | for (var marker : markers) {
451 | marker.setCameraSpeed(defaultCameraSpeed);
452 | }
453 | }
454 |
455 | private void cacheIndexForRuntimeMarkers() {
456 | //为runtime marker缓存index,提高运镜时流畅度
457 | for (int i = 0; i < runtimeMarkers.size(); i++) {
458 | runtimeMarkers.get(i).cacheIndex(i);
459 | }
460 | }
461 |
462 | public boolean pause() {
463 | if (!playing)
464 | return false;
465 | playing = false;
466 | //todo: 目前能播放trail的只能是operator,在未来会支持其他玩家播放trail,这边的代码就得修改
467 | if (operator != null) {
468 | var pk = new CameraInstructionPacket();
469 | pk.setInstruction(ClearInstruction.get());
470 | operator.dataPacket(pk);
471 | }
472 | return true;
473 | }
474 | }
475 |
--------------------------------------------------------------------------------
/src/main/resources/assets/resource_pack/entity/marker.json:
--------------------------------------------------------------------------------
1 | {
2 | "format_version": "1.10.0",
3 | "minecraft:client_entity": {
4 | "description": {
5 | "identifier": "replaynk:marker",
6 | "materials": {
7 | "default": "entity_alphatest"
8 | },
9 | "textures": {
10 | "default": "textures/entity/marker"
11 | },
12 | "geometry": {
13 | "default": "geometry.marker"
14 | },
15 | "render_controllers": [
16 | "controller.render.marker"
17 | ],
18 | "spawn_egg": {
19 | "base_color": "#000000",
20 | "overlay_color": "#FFFFFF"
21 | }
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/src/main/resources/assets/resource_pack/items/add_marker.json:
--------------------------------------------------------------------------------
1 | {
2 | "format_version": "1.10.0",
3 | "minecraft:item": {
4 | "description": {
5 | "identifier": "replaynk:add_marker",
6 | "category": "nature",
7 | "is_experimental": false
8 | },
9 | "components": {
10 | "minecraft:icon": "replaynk_add_marker",
11 | "minecraft:hover_text_color": "white",
12 | "minecraft:render_offsets": "apple",
13 | "minecraft:use_animation": "eat"
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/src/main/resources/assets/resource_pack/items/clear_marker.json:
--------------------------------------------------------------------------------
1 | {
2 | "format_version": "1.10.0",
3 | "minecraft:item": {
4 | "description": {
5 | "identifier": "replaynk:clear_marker",
6 | "category": "nature",
7 | "is_experimental": false
8 | },
9 | "components": {
10 | "minecraft:icon": "replaynk_clear_marker",
11 | "minecraft:hover_text_color": "red",
12 | "minecraft:render_offsets": "apple",
13 | "minecraft:use_animation": "eat"
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/src/main/resources/assets/resource_pack/items/edit.json:
--------------------------------------------------------------------------------
1 | {
2 | "format_version": "1.10.0",
3 | "minecraft:item": {
4 | "description": {
5 | "identifier": "replaynk:edit_marker",
6 | "category": "nature",
7 | "is_experimental": false
8 | },
9 | "components": {
10 | "minecraft:icon": "replaynk_edit_marker",
11 | "minecraft:hover_text_color": "white",
12 | "minecraft:render_offsets": "apple",
13 | "minecraft:use_animation": "eat"
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/src/main/resources/assets/resource_pack/items/exit.json:
--------------------------------------------------------------------------------
1 | {
2 | "format_version": "1.10.0",
3 | "minecraft:item": {
4 | "description": {
5 | "identifier": "replaynk:exit",
6 | "category": "nature",
7 | "is_experimental": false
8 | },
9 | "components": {
10 | "minecraft:icon": "replaynk_exit",
11 | "minecraft:hover_text_color": "red",
12 | "minecraft:render_offsets": "apple",
13 | "minecraft:use_animation": "eat"
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/src/main/resources/assets/resource_pack/items/marker_picker.json:
--------------------------------------------------------------------------------
1 | {
2 | "format_version": "1.10.0",
3 | "minecraft:item": {
4 | "description": {
5 | "identifier": "replaynk:marker_picker",
6 | "category": "nature",
7 | "is_experimental": false
8 | },
9 | "components": {
10 | "minecraft:icon": "replaynk_marker_picker",
11 | "minecraft:hover_text_color": "white",
12 | "minecraft:render_offsets": "apple",
13 | "minecraft:use_animation": "eat"
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/src/main/resources/assets/resource_pack/items/pause.json:
--------------------------------------------------------------------------------
1 | {
2 | "format_version": "1.10.0",
3 | "minecraft:item": {
4 | "description": {
5 | "identifier": "replaynk:pause",
6 | "category": "nature",
7 | "is_experimental": false
8 | },
9 | "components": {
10 | "minecraft:icon": "replaynk_pause",
11 | "minecraft:hover_text_color": "white",
12 | "minecraft:render_offsets": "apple",
13 | "minecraft:use_animation": "eat"
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/src/main/resources/assets/resource_pack/items/play.json:
--------------------------------------------------------------------------------
1 | {
2 | "format_version": "1.10.0",
3 | "minecraft:item": {
4 | "description": {
5 | "identifier": "replaynk:play",
6 | "category": "nature",
7 | "is_experimental": false
8 | },
9 | "components": {
10 | "minecraft:icon": "replaynk_play",
11 | "minecraft:hover_text_color": "white",
12 | "minecraft:render_offsets": "apple",
13 | "minecraft:use_animation": "eat"
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/src/main/resources/assets/resource_pack/items/setting.json:
--------------------------------------------------------------------------------
1 | {
2 | "format_version": "1.10.0",
3 | "minecraft:item": {
4 | "description": {
5 | "identifier": "replaynk:setting",
6 | "category": "nature",
7 | "is_experimental": false
8 | },
9 | "components": {
10 | "minecraft:icon": "replaynk_setting",
11 | "minecraft:hover_text_color": "white",
12 | "minecraft:render_offsets": "apple",
13 | "minecraft:use_animation": "eat"
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/src/main/resources/assets/resource_pack/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "format_version": 2,
3 | "metadata": {
4 | "generated_with": {
5 | "bridge": [
6 | "2.2.13"
7 | ],
8 | "dash": [
9 | "0.8.18"
10 | ]
11 | }
12 | },
13 | "header": {
14 | "name": "Resource Pack For ReplayNK",
15 | "description": "https://github.com/PowerNukkitX/ReplayNK",
16 | "min_engine_version": [
17 | 1,
18 | 19,
19 | 0
20 | ],
21 | "uuid": "d47de640-954b-41e7-8937-1b97cfdf08e1",
22 | "version": [
23 | 1,
24 | 0,
25 | 0
26 | ]
27 | },
28 | "modules": [
29 | {
30 | "type": "resources",
31 | "uuid": "ab09c50f-5860-4676-bad9-73bc93b80165",
32 | "version": [
33 | 1,
34 | 0,
35 | 0
36 | ]
37 | }
38 | ]
39 | }
--------------------------------------------------------------------------------
/src/main/resources/assets/resource_pack/models/entity/marker.geo.json:
--------------------------------------------------------------------------------
1 | {
2 | "format_version": "1.12.0",
3 | "minecraft:geometry": [
4 | {
5 | "description": {
6 | "identifier": "geometry.marker",
7 | "texture_width": 32,
8 | "texture_height": 32,
9 | "visible_bounds_width": 2,
10 | "visible_bounds_height": 1.5,
11 | "visible_bounds_offset": [
12 | 0,
13 | 0.25,
14 | 0
15 | ]
16 | },
17 | "bones": [
18 | {
19 | "name": "global",
20 | "pivot": [
21 | 0,
22 | 0,
23 | 0
24 | ]
25 | },
26 | {
27 | "name": "camera",
28 | "parent": "global",
29 | "pivot": [
30 | 0,
31 | 0,
32 | 0
33 | ],
34 | "cubes": [
35 | {
36 | "origin": [
37 | -4,
38 | 0,
39 | -4
40 | ],
41 | "size": [
42 | 8,
43 | 8,
44 | 8
45 | ],
46 | "uv": {
47 | "north": {
48 | "uv": [
49 | 0,
50 | 0
51 | ],
52 | "uv_size": [
53 | 8,
54 | 8
55 | ]
56 | },
57 | "east": {
58 | "uv": [
59 | 0,
60 | 8
61 | ],
62 | "uv_size": [
63 | 8,
64 | 8
65 | ]
66 | },
67 | "south": {
68 | "uv": [
69 | 8,
70 | 0
71 | ],
72 | "uv_size": [
73 | 8,
74 | 8
75 | ]
76 | },
77 | "west": {
78 | "uv": [
79 | 8,
80 | 8
81 | ],
82 | "uv_size": [
83 | 8,
84 | 8
85 | ]
86 | },
87 | "up": {
88 | "uv": [
89 | 0,
90 | 16
91 | ],
92 | "uv_size": [
93 | 8,
94 | 8
95 | ]
96 | },
97 | "down": {
98 | "uv": [
99 | 16,
100 | 8
101 | ],
102 | "uv_size": [
103 | 8,
104 | -8
105 | ]
106 | }
107 | }
108 | }
109 | ]
110 | }
111 | ]
112 | }
113 | ]
114 | }
--------------------------------------------------------------------------------
/src/main/resources/assets/resource_pack/pack_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerNukkitX-Bundle/ReplayNK/8eab3889ba3a39c88a8c48299a1a36c9071166c7/src/main/resources/assets/resource_pack/pack_icon.png
--------------------------------------------------------------------------------
/src/main/resources/assets/resource_pack/particles/arrow.particle.json:
--------------------------------------------------------------------------------
1 | {
2 | "format_version": "1.10.0",
3 | "particle_effect": {
4 | "description": {
5 | "identifier": "replaynk:arrow",
6 | "basic_render_parameters": {
7 | "material": "particles_alpha",
8 | "texture": "textures/particles/arrow"
9 | }
10 | },
11 | "components": {
12 | "minecraft:emitter_rate_instant": {
13 | "num_particles": 1
14 | },
15 | "minecraft:emitter_lifetime_once": {
16 | "active_time": 1
17 | },
18 | "minecraft:emitter_shape_point": {},
19 | "minecraft:particle_lifetime_expression": {
20 | "max_lifetime": 1
21 | },
22 | "minecraft:particle_appearance_billboard": {
23 | "size": [2, 0.5],
24 | "facing_camera_mode": "lookat_direction",
25 | "direction": {
26 | "mode": "custom",
27 | "custom_direction": ["variable.x", "variable.y", "variable.z"]
28 | },
29 | "uv": {
30 | "texture_width": 256,
31 | "texture_height": 32,
32 | "uv": [0, 0],
33 | "uv_size": [256, 32]
34 | }
35 | },
36 | "minecraft:particle_appearance_tinting": {
37 | "color": [1, 0.67059, 0.73725, 1]
38 | }
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/src/main/resources/assets/resource_pack/render_controllers/marker.json:
--------------------------------------------------------------------------------
1 | {
2 | "format_version": "1.8.0",
3 | "render_controllers": {
4 | "controller.render.marker": {
5 | "geometry": "geometry.default",
6 | "materials": [
7 | {
8 | "*": "material.default"
9 | }
10 | ],
11 | "textures": [
12 | "texture.default"
13 | ]
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/src/main/resources/assets/resource_pack/texts/en_US.lang:
--------------------------------------------------------------------------------
1 | entity.replaynk:marker=Marker
2 | item.replaynk:play=Start Trailer
3 | item.replaynk:pause=Stop Trailer
4 | item.replaynk:add_marker=Create Marker
5 | item.replaynk:exit=Exit
6 | item.replaynk:clear_marker=Clear Marker
7 | item.replaynk:edit_marker=Edit Marker
8 | item.replaynk:setting=Setting
9 | item.replaynk:marker_picker=Marker Picker
--------------------------------------------------------------------------------
/src/main/resources/assets/resource_pack/texts/languages.json:
--------------------------------------------------------------------------------
1 | [
2 | "zh_CN",
3 | "en_US"
4 | ]
--------------------------------------------------------------------------------
/src/main/resources/assets/resource_pack/texts/zh_CN.lang:
--------------------------------------------------------------------------------
1 | entity.replaynk:marker.name=路径点
2 | item.replaynk:play.name=开始播放
3 | item.replaynk:pause.name=暂停播放
4 | item.replaynk:add_marker.name=创建路径点
5 | item.replaynk:exit.name=退出
6 | item.replaynk:clear_marker.name=删除路径点
7 | item.replaynk:edit_marker.name=修改路径点
8 | item.replaynk:setting.name=设置
9 | item.replaynk:marker_picker=路径点选择器
--------------------------------------------------------------------------------
/src/main/resources/assets/resource_pack/textures/entity/marker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerNukkitX-Bundle/ReplayNK/8eab3889ba3a39c88a8c48299a1a36c9071166c7/src/main/resources/assets/resource_pack/textures/entity/marker.png
--------------------------------------------------------------------------------
/src/main/resources/assets/resource_pack/textures/item_texture.json:
--------------------------------------------------------------------------------
1 | {
2 | "resource_pack_name": "Resource Pack For ReplayNK",
3 | "texture_name": "atlas.items",
4 | "texture_data": {
5 | "replaynk_play": {
6 | "textures": "textures/items/play_item_texture"
7 | },
8 | "replaynk_pause": {
9 | "textures": "textures/items/pause_item_texture"
10 | },
11 | "replaynk_add_marker": {
12 | "textures": "textures/items/add_marker_item_texture"
13 | },
14 | "replaynk_exit": {
15 | "textures": "textures/items/exit_item_texture"
16 | },
17 | "replaynk_clear_marker": {
18 | "textures": "textures/items/clear_marker_item_texture"
19 | },
20 | "replaynk_edit_marker": {
21 | "textures": "textures/items/edit_marker_item_texture"
22 | },
23 | "replaynk_setting": {
24 | "textures": "textures/items/setting_item_texture"
25 | },
26 | "replaynk_marker_picker": {
27 | "textures": "textures/items/marker_picker_item_texture"
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/src/main/resources/assets/resource_pack/textures/items/add_marker_item_texture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerNukkitX-Bundle/ReplayNK/8eab3889ba3a39c88a8c48299a1a36c9071166c7/src/main/resources/assets/resource_pack/textures/items/add_marker_item_texture.png
--------------------------------------------------------------------------------
/src/main/resources/assets/resource_pack/textures/items/clear_marker_item_texture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerNukkitX-Bundle/ReplayNK/8eab3889ba3a39c88a8c48299a1a36c9071166c7/src/main/resources/assets/resource_pack/textures/items/clear_marker_item_texture.png
--------------------------------------------------------------------------------
/src/main/resources/assets/resource_pack/textures/items/edit_marker_item_texture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerNukkitX-Bundle/ReplayNK/8eab3889ba3a39c88a8c48299a1a36c9071166c7/src/main/resources/assets/resource_pack/textures/items/edit_marker_item_texture.png
--------------------------------------------------------------------------------
/src/main/resources/assets/resource_pack/textures/items/exit_item_texture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerNukkitX-Bundle/ReplayNK/8eab3889ba3a39c88a8c48299a1a36c9071166c7/src/main/resources/assets/resource_pack/textures/items/exit_item_texture.png
--------------------------------------------------------------------------------
/src/main/resources/assets/resource_pack/textures/items/marker_picker_item_texture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerNukkitX-Bundle/ReplayNK/8eab3889ba3a39c88a8c48299a1a36c9071166c7/src/main/resources/assets/resource_pack/textures/items/marker_picker_item_texture.png
--------------------------------------------------------------------------------
/src/main/resources/assets/resource_pack/textures/items/pause_item_texture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerNukkitX-Bundle/ReplayNK/8eab3889ba3a39c88a8c48299a1a36c9071166c7/src/main/resources/assets/resource_pack/textures/items/pause_item_texture.png
--------------------------------------------------------------------------------
/src/main/resources/assets/resource_pack/textures/items/play_item_texture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerNukkitX-Bundle/ReplayNK/8eab3889ba3a39c88a8c48299a1a36c9071166c7/src/main/resources/assets/resource_pack/textures/items/play_item_texture.png
--------------------------------------------------------------------------------
/src/main/resources/assets/resource_pack/textures/items/setting_item_texture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerNukkitX-Bundle/ReplayNK/8eab3889ba3a39c88a8c48299a1a36c9071166c7/src/main/resources/assets/resource_pack/textures/items/setting_item_texture.png
--------------------------------------------------------------------------------
/src/main/resources/assets/resource_pack/textures/particles/arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerNukkitX-Bundle/ReplayNK/8eab3889ba3a39c88a8c48299a1a36c9071166c7/src/main/resources/assets/resource_pack/textures/particles/arrow.png
--------------------------------------------------------------------------------
/src/main/resources/language/en_US.lang:
--------------------------------------------------------------------------------
1 | replaynk.command.replay.description=ReplayNK plugin main command
2 | replaynk.command.replay.onlyplayer=§cThis command can only be executed by player!
3 | replaynk.command.replay.list=§aTrails: §f{%0}
4 |
5 | replaynk.trail.notfound=§cCannot found trail §f{%0} §c!
6 | replaynk.trail.startoperating=§aStart operating trail §f{%0} §a!
7 | replaynk.trail.stopoperating=§aStop operating trail §f{%0} §a!
8 | replaynk.trail.created=§aTrail §f{%0} §acreated!
9 | replaynk.trail.alreadyexist=§cTrail §f{%0} §calready exist!
10 | replaynk.trail.removed=§aTrail §f{%0} §aremoved!
11 | replaynk.trail.alreadyplaying=§cTrail §f{%0} §calready playing!
12 | replaynk.trail.toolittlemarks=§cTrail §f{%0} §chas too little markers!
13 | replaynk.trail.startplaying=§aStart playing trail §f{%0} §a
14 | replaynk.trail.alreadyoperatingtrail=§cYou are already operating trail §f{%0} §c! Please stop operating it first!
15 | replaynk.trail.notoperatingtrail=§cYou are not operating any trail!
16 | replaynk.trail.notplayingtrail=§cYou are not playing any trail!
17 | replaynk.trail.paused=§aPlaying stopped!
18 |
19 | replaynk.trail.editorform.interpolator=§aInterpolator
20 | replaynk.trail.editorform.interpolator.details=§fSpecify an interpolator to use for smoothing the trail
21 | replaynk.trail.editorform.showtrail=§aShow trail
22 | replaynk.trail.editorform.showtrail.details=§fIf on, will display the calculated trail with particles
23 | replaynk.trail.editorform.showmarkerdirection=§aShow markers' direction
24 | replaynk.trail.editorform.showmarkerdirection.details=§fIf on, an arrow particle will be used to show the direction of each marker
25 | replaynk.trail.editorform.mindistance=§aMin distance between two marks
26 | replaynk.trail.editorform.mindistance.details=§fThis parameter specifies the minimum distance between two markers, and markers whose distance from the previous marker is less than this value will be deleted. §fIf the Bezier curve smoothing function is turned on, the calculated distance between marker points will be equal to this value
27 | replaynk.trail.editorform.defaultcameraspeed=§aDefault camera speed
28 | replaynk.trail.editorform.defaultcameraspeed.details=§fThis parameter specifies the default camera speed when creating markers.§fNote that independent camera speeds can be specified for each marker.
29 | replaynk.trail.editorform.dorecalculateeasetime=§aDo recalculate all marks' ease time
30 | replaynk.trail.editorform.dorecalculateeasetime.details=§fIf enabled, will reset the camera speed of all markers in this track preset to the default camera speed and use the default camera speed to calculate the camera time
31 | replaynk.trail.editorform.cameraspeedmultiple=§aDefault camera speed multiplier
32 | replaynk.trail.editorform.cameraspeedmultiple.details=§fThis parameter specifies the camera speed multiple. For example, when you set it to 2, the actual camera speed of all markers will be doubled.
33 | replaynk.trail.editorform.showmarkerentitytoallplayers=§aShow marker entities for all players
34 | replaynk.trail.editorform.showmarkerentitytoallplayers.details=§fIf on, will show marker entities for all players. If off, only marker entities will be displayed for the operator.
35 |
36 | replaynk.mark.added=§aSuccessfully added marker!
37 | replaynk.mark.removed=§aSuccessfully removed marker!
38 |
39 | replaynk.mark.editorform.pos=§aPosition(x, y, z)
40 | replaynk.mark.editorform.rot=§aRotation(rotX,rotZ)
41 | replaynk.mark.editorform.easetype=§aEase Type(Smoothing Type)
42 | replaynk.mark.editorform.easetype.details=§fThis option determines how the camera should move to the next marker. Normally, please use linear (LINEAR)
43 | replaynk.mark.editorform.easetime=§aMirroring Time/Speed
44 | replaynk.mark.editorform.easetime.details=§fHere you can fill in the time or speed of the mirror. If filling in the time, please add the unit 's' after the number, and if it is the speed, please add the unit 'm/s' after the number. Example: 1.5s(time), 3m/s(speed)
45 | replaynk.mark.editorform.autoeasetime=§aWhether to recalculate the linear camera time after a position change
46 | replaynk.mark.editorform.index=§aMarker Index
47 | replaynk.mark.editorform.index.details=§fThis sequence number specifies the position of the marker in the entire trail. The camera will move smoothly from the marker with a small serial number to the marker with a large serial number
48 |
49 | replaynk.mark.invalidpos=§cIllegal position format!
50 | replaynk.mark.invalidrot=§cIllegal rotation format!
51 | replaynk.mark.invalidindex=§cIllegal index!
52 | replaynk.mark.invalideasetime=§cIllegal camera time/speed!
53 |
54 | replaynk.generic.invalidinput=§cInvalid input! Please check your input and try again!
55 |
56 | replaynk.markerpicker.unpick=§eClick on a marker to select it
57 | replaynk.markerpicker.pick.success=§aSuccessfully selected marker §f{%0}§a!
58 | replaynk.markerpicker.picked=§aRight click to drop marker §f{%0}§a!
59 | replaynk.markerpicker.nopickedmarker=§cYou have not selected any markers!
60 | replaynk.markerpicker.move.success=§aSuccessfully moved marker §f{%0}§a!
--------------------------------------------------------------------------------
/src/main/resources/language/zh_CN.lang:
--------------------------------------------------------------------------------
1 | replaynk.command.replay.description=ReplayNK插件主命令
2 | replaynk.command.replay.onlyplayer=§c这个插件只能被玩家使用!
3 | replaynk.command.replay.list=§a轨迹: §f{%0}
4 |
5 | replaynk.trail.notfound=§c找不到轨迹预设 §f{%0} §c!
6 | replaynk.trail.startoperating=§a开始操作轨迹预设 §f{%0} §a!
7 | replaynk.trail.stopoperating=§a停止操作轨迹预设 §f{%0} §a!
8 | replaynk.trail.created=§a成功创建轨迹预设 §f{%0} §a!
9 | replaynk.trail.alreadyexist=§c轨迹预设 §f{%0} §c已经存在!
10 | replaynk.trail.removed=§a成功移除轨迹预设 §f{%0} §a!
11 | replaynk.trail.alreadyplaying=§c轨迹预设 §f{%0} §c已经在播放中!
12 | replaynk.trail.toolittlemarks=§c轨迹预设 §f{%0} §c的标记点太少!
13 | replaynk.trail.startplaying=§a开始播放轨迹预设 §f{%0}
14 | replaynk.trail.alreadyoperatingtrail=§c你正在操作一个轨迹!请退出后重试!
15 | replaynk.trail.notoperatingtrail=§c你没有在操作任何轨迹!
16 | replaynk.trail.notplayingtrail=§c你没有在播放任何轨迹!
17 | replaynk.trail.paused=§a播放已停止!
18 |
19 | replaynk.trail.editorform.interpolator=§a插值器
20 | replaynk.trail.editorform.interpolator.details=§f指定用于平滑轨迹的插值器
21 | replaynk.trail.editorform.showtrail=§a显示轨迹
22 | replaynk.trail.editorform.showtrail.details=§f若开启,将会用粒子显示计算出的轨迹
23 | replaynk.trail.editorform.showmarkerdirection=§a显示标记点方向
24 | replaynk.trail.editorform.showmarkerdirection.details=§f若开启,将会用一个箭头粒子显示标记点的方向
25 | replaynk.trail.editorform.mindistance=§a两点间最小距离
26 | replaynk.trail.editorform.mindistance.details=§f此参数指定了两个标记点间的最小距离,离上一个标记点距离小于此值的标记点将会被删除。§f若使用了非线性的插值器,计算出的标记点间距离将等于此值
27 | replaynk.trail.editorform.defaultcameraspeed=§a默认运镜速度
28 | replaynk.trail.editorform.defaultcameraspeed.details=§f此参数指定了创建标记点时的默认运镜速度。§f请注意,可以为每个标记点指定独立的运镜速度。
29 | replaynk.trail.editorform.dorecalculateeasetime=§a是否重新计算所有标记点的运镜时间
30 | replaynk.trail.editorform.dorecalculateeasetime.details=§f若启用,将会重置此轨迹预设中的所有标记点的运镜速度为默认运镜速度并使用默认运镜速度计算运镜时间
31 | replaynk.trail.editorform.cameraspeedmultiple=§a默认运镜速度倍数
32 | replaynk.trail.editorform.cameraspeedmultiple.details=§f此参数指定了轨迹播放的倍速。例如当你将其设置为2,所有标记点的实际运镜速度将会变为原来的2倍。
33 | replaynk.trail.editorform.showmarkerentitytoallplayers=§a为所有玩家显示标记点实体
34 | replaynk.trail.editorform.showmarkerentitytoallplayers.details=§f若开启,将会为所有玩家显示标记点实体。若关闭,将只为操作者显示标记点实体。
35 |
36 | replaynk.mark.added=§a成功添加标记点!
37 | replaynk.mark.removed=§a成功移除标记点!
38 |
39 | replaynk.mark.editorform.pos=§a坐标(x,y,z)
40 | replaynk.mark.editorform.rot=§a旋转(rotX,rotZ)
41 | replaynk.mark.editorform.easetype=§a平滑类型
42 | replaynk.mark.editorform.easetype.details=§f此选项决定镜头应该如何运动到下一个标记点。通常情况下请使用线性(LINEAR)
43 | replaynk.mark.editorform.easetime=§a运镜时间/速度
44 | replaynk.mark.editorform.easetime.details=§f这里可以填运镜的时间或者速度。若填写时间请在数字后加上单位's',若是速度请在数字后加上单位'm/s'。例如: 1.5s(时间), 3m/s(速度)
45 | replaynk.mark.editorform.autoeasetime=§a是否在坐标更改后重新计算线性运镜时间
46 | replaynk.mark.editorform.index=§a标记点序号
47 | replaynk.mark.editorform.index.details=§f此序号指定了该标记点在整个轨迹链中的位置。镜头会从序号小的标记点平滑运动到序号大的标记点
48 |
49 | replaynk.mark.invalidpos=§c非法的坐标格式!
50 | replaynk.mark.invalidrot=§c非法的旋转格式!
51 | replaynk.mark.invalidindex=§c非法的序号!
52 | replaynk.mark.invalideasetime=§c非法的运镜时间/速度!
53 |
54 | replaynk.generic.invalidinput=§c非法的输入!请检查你提供的值并重试!
55 |
56 | replaynk.markerpicker.unpick=§e点击一个标记点以选中它
57 | replaynk.markerpicker.pick.success=§a成功选中了标记点 §f{%0} §a!
58 | replaynk.markerpicker.picked=§a点击右键以放下标记点 §f{%0} §a!
59 | replaynk.markerpicker.nopickedmarker=§c你没有选中任何标记点!
60 | replaynk.markerpicker.move.success=§a成功移动了标记点 §f{%0} §a!
--------------------------------------------------------------------------------
/src/main/resources/plugin.yml:
--------------------------------------------------------------------------------
1 | name: ReplayNK
2 | main: cn.powernukkitx.replaynk.ReplayNK
3 | version: "1.0.2"
4 | api: ["1.0.14"]
5 | load: POSTWORLD
6 | author: daoge_cmd
7 | website: https://github.com/PowerNukkitX/ReplayNK
--------------------------------------------------------------------------------