Commit Graph
120 Commits
Author SHA1 Message Date
gnembon 07033af7dd 23w17a 2023-04-26 22:58:59 +02:00
altrisi 8cd60db5e4 Random cleanups to users of Level.OVERWORLD and reduce minecraft_server usage (#1697)
- Use `overworld()` instead of `getLevel(Level.OVERWORLD)` when convenient
- Remove now unnecessary `// OW` comments, from when it had no mappings
- Make spawn chunk size and light batches not depend on global server instance
- Merge all spawn chunk size logic into SpawnChunks instead of methods in the validator
- Remove unneeded `withWorld(OVERWORLD)` with just-created server `CommandSource`s
- Use enhanced for in light batch application
2023-04-08 20:01:30 +02:00
altrisi 0869cbb81c Move rule change event into a rule observer and outside the Java api
* Move rule change event into a rule observer, without exposing it

* Fix comment

* Fix formatting changes added by my IDE

Still trying to configure it to force correctly the new style

Also remove some finals
2023-03-08 21:31:34 +01:00
gnembon 277872b33c warning cleanup 2023-02-08 21:13:15 +01:00
gnembon 75d94b0570 cleanup of scarpet dependencies 2023-02-08 21:13:14 +01:00
gnembon 8f61271606 semi-auto cleanup 2023-02-04 13:26:21 +01:00
altrisi 3050a82b96 Replace one missed usage
It was also using the copy-constructor, so this way it should also be more efficient
2023-01-19 01:47:33 +01:00
gnembon bd5dfdbf9f refactor limit access to built-in registries 2023-01-18 04:07:55 +01:00
gnembon 8dd08d5cb1 refactor access to context data 2023-01-16 19:01:10 +01:00
Ghoulboy 43bb84437f Add event for commands and make __on_player_message not trigger for them (#1525)
* Restoring old behaviour of __on_player_message

Fixes #1511

* Changed to PLAYER_COMMAND

* Updated docs

* Updated event_test.sc

* Updated editor keywords

* Fixed issue
2022-12-26 15:30:50 +01:00
gnembon cda6994cae 45a great reg split 2022-11-10 20:51:10 +01:00
replaceitem 2b5e51b4df Fixed NPE when events are triggered within events (#1574) 2022-10-16 17:33:54 +02:00
replaceitem 24b9c386ec [Scarpet] Added ability to cancel events (#1497)
* Added ability to cancel events

* Made more events cancellable

* Added event_priority to __config

* Check for string values for performance

* Made player_finishes_using_item cancellable

* Made player_chooses_recipe cancellable

* Made player_swaps_hands cancellable

* Made player_message cancellable

* Added __on_player_placing_block (#1498)

* Added event to docs, keywords, event_test

* Added docs for event cancellation
2022-10-15 13:30:53 +02:00
altrisi 8e38619f61 Don't hold Context variables for the lifetime of scheduled calls
Fixes #1568
2022-10-15 12:34:55 +02:00
altrisi b1c29efa2b Expose origin-less constructors and methods (#1556) 2022-10-02 13:57:29 +02:00
altrisi 0a972d6c56 Settings rework and encapsulation (#1330)
* Settings rework and encapsulation

* Settings overhaul 3

Move everything in the new system to a new API package

Require rules using the new system to specify descriptions in their translation files

Implement temporary system on top of current translations to allow that to work properly

* Fix getRules fallback

* Final touches to settings refactor

* Mention that set shouldn't throw and remove comment

* Change translation keys to unify with translation PR

* Deprecate printAllRulesToLog to allow using any PrintStream

* Remove restriction of CarpetRules being Comparable

And fix overreaction in a deprecation message

* Bring back user input to rule observers

* Make Validator deprecation warning not spam on use

* Remove unneeded abstract methods in CarpetRule already inherited from CarpetRule

They literally do nothing, don't even force them to be implemented, and may be confusing as to why they're there or as if they are needed to be implemented

* Fix legacy SettingsManager field not being assigned correctly

* Finish fixing conflicts from future merge

* Actually fix remaining conflicts from future merge (missing imports)

* Import the newer rule in SettingsManager

* Refactor Validators

* Don't spam deprecation warnings on custom managers

* Get out the var

* Fix missing warning in old rule observers

* Update src/main/java/carpet/api/settings/Rule.java

* Remove `@ApiStatus.Experimental` annotations

* Fix incorrect `@deprecated` javadoc tags

By removing them given the class is deprecated anyway and else there's too much noise

* Add missing static import

* Remove TypedField and use a regular field

I liked that class tbh, but it's true that it wasn't really needed

* Move `field` assignment out of for removal

* Fix not following contract of `type()` returning boxed value

Previously handled by TypedField

* Fix few incorrect translation keys

* Remove resaving of comments when saving config files

Comments ignoring is still a thing when reading, so `locked` configs for example will keep comments

* Condense rule load messages in one

* Only print loaded settings message when at least one setting was changed

* Fix legacy validator detector

* Tweak and add more context to response to invalid values

* Fix strict validator not actually erroring on invalid input
2022-06-27 13:12:15 +02:00
Luca Bertozzi 8c7dfa133e Added __on_chunk_unloaded scarpet event (#1451)
* Fixes #1403

* Use concrete type
2022-05-27 20:24:25 +02:00
altrisi f18cfb09d2 Fix more warnings and do some small optimizations (#1356)
* Fix more warnings and do some small optimizations

* Fix more warnings in ValueConversions

* Clean up some decompiler names and fix an unnecessary transformation around commands

* Use (way) more compact data structure for slot map

* Minor tweaks
Such as map directly in the collector

* I hate vanilla javac
Revert map changes in latest commit
2022-05-27 19:43:45 +02:00
altrisi a60bc386cb Refactor Module into a single record type and fix system globals (#1383) 2022-05-17 20:11:49 +02:00
altrisi b1c934da28 Fix a few IDE warnings (#1345) 2022-02-20 19:16:12 +01:00
replaceitemandgnembon bf00051482 Added __on_player_message event (#1312)
* Added __on_player_sends_message event

* Docs for chat message event

* Rename to __on_player_message

* Editor support

* Added event to event_test app

* Update docs/scarpet/api/Events.md

Co-authored-by: gnembon <41132274+gnembon@users.noreply.github.com>
2022-02-16 00:07:53 +01:00
altrisi 06af9ce8b1 Migrate the Carpet codebase to Mojang Mappings 2022-01-24 20:33:16 +01:00
gnembon 5a55666f94 Merge branch 'master' into future 2021-12-11 22:30:54 +01:00
gnembon fe6018a43b allowing event callbacks be added concurrently (e.g. registered event while handling some other events), with safe event pruning. fixes #1193 fixes #889 2021-12-06 01:02:37 +01:00
gnembon 6a03675b4f Merge branch 'master' into future 2021-10-12 23:24:41 -03:00
altrisi 7486670918 Report stack traces through the logger (#1050) 2021-10-11 03:37:30 -03:00
gnembon 7b9e5e6feb mappings 2021-09-22 21:12:11 -03:00
gnembon bc175509a2 21w37a 2021-09-18 08:46:27 -03:00
gnembon 229d0b037b events handling is disabled now when potentially triggered from the scarpet script preventing from recursive callbacks. 2021-09-06 02:37:08 -03:00
altrisi 7fb5e47da5 Use newer Java features in places where it makes sense and more (#1009) 2021-08-03 07:32:40 -03:00
gnembon 0e9df3701f rework for events and other stored functions. Fixes #984 2021-07-22 22:22:38 -03:00
gnembon 41a34b52a3 Merge branch 'master' into 1.17 2021-07-10 23:26:38 -03:00
gnembon 0c5f828b3b unused 2021-07-10 02:18:55 -03:00
gnembon 092766b820 Merge branch 'master' into 1.17 2021-06-26 23:20:30 -03:00
gnembon b1b7956ea9 added chunk_loaded event and fixed handling these events on 1.17 2021-06-26 23:20:13 -03:00
gnembon ac24a67c00 changes to entity load handler keeping it backwards compatible. Fixes #929 2021-06-25 20:18:12 -03:00
gnembon 2127c3ac8e Merge branch 'master' into 1.17
# Conflicts:
#	src/main/java/carpet/mixins/ServerWorld_scarpetMixin.java
#	src/main/java/carpet/script/CarpetEventServer.java
2021-06-25 20:12:45 -03:00
gnembon 448fde1f36 changes to entity load handler keeping it backwards compatible 2021-06-25 20:09:15 -03:00
gnembon 481fc97545 changes to entity load handler / not backwards compatible 2021-06-25 18:38:49 -03:00
gnembon 83109eda9a Merge branch 'master' into 1.17 2021-05-28 13:51:09 -03:00
gnembon bd689b418a prevent events to be called when script server is gone. 2021-05-28 13:50:50 -03:00
gnembon c720c2c935 Merge branch 'master' into 1.17
# Conflicts:
#	src/main/java/carpet/script/api/Auxiliary.java
#	src/main/java/carpet/script/utils/ShapeDispatcher.java
#	src/main/java/carpet/script/value/EntityValue.java
#	src/main/java/carpet/script/value/ListValue.java
2021-05-25 01:08:32 -03:00
gnembon 7b4176f717 Merge pull request #882 from altrisi/not-fromItemStack
Replace usages of deprecated ListValue::fromItemStack and remove it
2021-05-25 00:50:53 -03:00
altrisi 2b3f376871 Replace usages of deprecated ListValue::fromItemStack and remove it 2021-05-24 12:00:55 +02:00
altrisi 9d9844fd5d Deprecate old boolean constructor and move existing usages 2021-05-24 11:41:24 +02:00
gnembon fc87053978 21w16a 2021-04-21 20:12:44 -03:00
gnembon f2721ab87a custom events backend, and entity attribute query. 2021-04-13 01:22:50 -03:00
gnembon e063748e83 added create_explosion and more event handlers. 2021-04-09 01:38:00 -03:00
7b00952653 Added onExplosion Scarpet Event (#620)
* Added onExplosion Scarpet Event

* Reverted changes to Full.md

* Grammar corrections by James103

Co-authored-by: James103 <37945304+James103@users.noreply.github.com>

* Separated Explosion Mixins

Applied Ghoulboy78 suggestion.
WARNING: 'blocks' list is now empty if 'explosionNoBlockDamage' carpet rule is set to 'true'

* List Value from Triple

Suggested by Gnembon

* Explosion Mixin priority

Suggestion by Gnembon

* Added affectedEntities parameter

* Updated docs

* Optimizing calls

* Update src/main/java/carpet/helpers/OptimizedExplosion.java

* Update docs/scarpet/api/Events.md

Co-authored-by: gnembon <41132274+gnembon@users.noreply.github.com>

* Update docs/scarpet/api/Events.md

Co-authored-by: gnembon <41132274+gnembon@users.noreply.github.com>

* Update src/main/java/carpet/mixins/Explosion_scarpetEventMixin.java

Co-authored-by: gnembon <41132274+gnembon@users.noreply.github.com>

Co-authored-by: James103 <37945304+James103@users.noreply.github.com>
Co-authored-by: gnembon <41132274+gnembon@users.noreply.github.com>
2021-04-08 18:05:13 -03:00
gnembon f0d044a49f added scarpet to the carpet profiler 2021-04-04 22:32:34 -03:00