gnembon / fabric-carpet

Fabric Carpet
MIT License
1.72k stars 275 forks source link

Prevent unloading existing app when reloading app fails #727

Open James103 opened 3 years ago

James103 commented 3 years ago

As of Minecraft 1.16, when /reload is used and a data pack fails to load due to invalid data, changes are not applied and the game continues using previous data (Minecraft Wiki).

However, using /script load <script> to reload an existing script will unload the script (as if you did script unload <script>) if the new version fails to compile or load, which is inconsistent with existing scripts:

Expected result: When you use /script load <script> to reload an existing script, and the new version of the script fails to compile, the old version of the script is kept loaded and running, instead of being unloaded.

Steps to reproduce:

  1. Load a script. For example, write the following to a file and load that as a script: __on_tick() -> if(tick_time() % 20 == 0, print(1));
  2. Notice that the script does something, such as printing a number to chat every second.
  3. Edit the script such that it no longer compiles correctly.
  4. Load the script again (you can use /reload or /script load to do this; it doesn't matter).
  5. Notice that a compilation error is given, which is expected after performing step 3.
  6. Notice that the script has been unloaded, which is inconsistent with data pack loading failure behavior.
System Details from /debug report ``` -- System Details -- Minecraft Version: 1.16.4 Minecraft Version ID: 1.16.4 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_265, AdoptOpenJDK Java VM Version: OpenJDK 64-Bit Server VM (mixed mode), AdoptOpenJDK Memory: 2322069488 bytes (2214 MB) / 4831838208 bytes (4608 MB) up to 4831838208 bytes (4608 MB) CPUs: 6 JVM Flags: 9 total; -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xms4608m -Xmx4608m Suspected Mods: Unknown Fabric Mods: attributefix: Attribute Fix {FABRIC} 1.0.0 autoconfig1u: Auto Config v1 Updated 3.3.1 carpet: Carpet Mod in Fabric 1.4.21 carpet-extra: Carpet Extra 1.4.16 clientcommands: Client Commands 2.4.9 cloth-basic-math: Cloth Basic Math 0.5.1 cloth-config2: Cloth Config v4 4.8.2 fabric: Fabric API 0.26.0+1.16 fabric-api-base: Fabric API Base 0.2.0+ba858fb83a fabric-biome-api-v1: Fabric Biome API (v1) 3.1.0+2e23b97c3a fabric-blockrenderlayer-v1: Fabric BlockRenderLayer Registration (v1) 1.1.4+6a2618f53a fabric-command-api-v1: Fabric Command API (v1) 1.0.9+6a2618f53a fabric-commands-v0: Fabric Commands (v0) 0.2.0+6a2618f53a fabric-containers-v0: Fabric Containers (v0) 0.1.8+6a2618f53a fabric-content-registries-v0: Fabric Content Registries (v0) 0.1.9+6a2618f53a fabric-crash-report-info-v1: Fabric Crash Report Info (v1) 0.1.2+b7f9825d3a fabric-events-interaction-v0: Fabric Events Interaction (v0) 0.4.1+6a2618f53a fabric-events-lifecycle-v0: Fabric Events Lifecycle (v0) 0.2.0+6a2618f53a fabric-game-rule-api-v1: Fabric Game Rule API (v1) 1.0.3+a4467d2a3a fabric-item-api-v1: Fabric Item API (v1) 1.2.0+6a2618f53a fabric-item-groups-v0: Fabric Item Groups (v0) 0.2.1+6a2618f53a fabric-key-binding-api-v1: Fabric Key Binding API (v1) 1.0.1+730711c63a fabric-keybindings-v0: Fabric Key Bindings (v0) 0.2.0+6a2618f53a fabric-lifecycle-events-v1: Fabric Lifecycle Events (v1) 1.2.0+6a2618f53a fabric-loot-tables-v1: Fabric Loot Tables (v1) 1.0.1+6a2618f53a fabric-mining-levels-v0: Fabric Mining Levels (v0) 0.1.2+6a2618f53a fabric-models-v0: Fabric Models (v0) 0.1.1+6a2618f53a fabric-networking-blockentity-v0: Fabric Networking Block Entity (v0) 0.2.5+6a2618f53a fabric-networking-v0: Fabric Networking (v0) 0.1.10+6a2618f53a fabric-object-builder-api-v1: Fabric Object Builder API (v1) 1.9.2+6a2618f53a fabric-object-builders-v0: Fabric Object Builders (v0) 0.7.1+6a2618f53a fabric-particles-v1: fabric-particles-v1 0.2.2+6a2618f53a fabric-registry-sync-v0: Fabric Registry Sync (v0) 0.6.1+6a2618f53a fabric-renderer-api-v1: Fabric Renderer API (v1) 0.3.3+6a2618f53a fabric-renderer-indigo: Fabric Renderer - Indigo 0.4.3+6a2618f53a fabric-renderer-registries-v1: Fabric Renderer Registries (v1) 2.2.0+6a2618f53a fabric-rendering-data-attachment-v1: Fabric Rendering Data Attachment (v1) 0.1.4+6a2618f53a fabric-rendering-fluids-v1: Fabric Rendering Fluids (v1) 0.1.12+6a2618f53a fabric-rendering-v0: Fabric Rendering (v0) 1.1.1+6a2618f53a fabric-rendering-v1: Fabric Rendering (v1) 1.4.0+6a2618f53a fabric-resource-loader-v0: Fabric Resource Loader (v0) 0.3.2+1944f3e03a fabric-screen-handler-api-v1: Fabric Screen Handler API (v1) 1.1.0+6a2618f53a fabric-structure-api-v1: Fabric Structure API (v1) 1.1.0+f8ac1db23a fabric-tag-extensions-v0: Fabric Tag Extensions (v0) 1.0.3+6a2618f53a fabric-textures-v0: Fabric Textures (v0) 1.0.5+6a2618f53a fabric-tool-attribute-api-v1: Fabric Tool Attribute API (v1) 1.2.5+6a2618f53a fabricloader: Fabric Loader 0.10.8 itemscroller: Item Scroller 0.15.0-dev.20201103.183933 litematica: Litematica 0.0.0-dev.20201103.184101 lithium: Lithium 0.6.1 loadcatcher: Entrypoint Catcher 2.0.0 malilib: MaLiLib 0.10.0-dev.21+arne.2 minecraft: Minecraft 1.16.4 minihud: MiniHUD 0.19.0-dev.20201103.184029 modmenu: Mod Menu unspecified multiconnect-api: MultiConnect API 1.3.9 no_fog: No Fog 1.0.2-beta.1+1.16.2 notenoughcrashes: Not Enough Crashes 2.1.4+1.16.4 shulkerboxtooltip: Shulker Box Tooltip 2.3.3+1.16.4 tweakeroo: Tweakeroo 0.10.0-dev.20210202.142511 xaerominimap: Xaero's Minimap 20.27.2 xaeroworldmap: Xaero's World Map 1.11.0 Player Count: 1 / 8; [class_3222['James3221'/184026, l='ServerLevel[Seed Zero Survival]', x=974.47, y=66.00, z=-726.20]] Data Packs: vanilla (incompatible), file/bac_advancements (incompatible), file/double shulker shells v1.2.0.zip (incompatible), file/armour statues v2.7.0.zip (incompatible), file/dragon drops v1.2.0.zip (incompatible), file/more mob heads v2.6.1.zip (incompatible), file/silence mobs v1.0.0.zip (incompatible), file/VanillaTweaks_c512455.zip (incompatible), file/Time and Date v1 (incompatible), fabric/fabric-tool-attribute-api-v1, file/classic fishing loot v1.0.0.zip (incompatible) Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fabric' ```
altrisi commented 3 years ago

Reasonable I think.

gnembon commented 3 years ago

could relocate unloading current apps to after vanilla reload is done. That would solve it.