Creators-of-Create / Create

[Forge Mod] Building Tools and Aesthetic Technology
MIT License
2.93k stars 907 forks source link

Contraption/Schematic rail placement below y=0 hard crashes #2493

Closed MrLar closed 2 years ago

MrLar commented 2 years ago

Describe the Bug

This may be a duplicate of a bunch of other issues I saw flying around however at the risk of that, and this being a known bug, I would like to provide some additional info I noticed: Using a Schematiccannon (or likely any other contraption), to place a rail below y=0 hard crashes the server/game with an Index out of bound error (index is negative). This is due to how create handles placing a rail without an update. The method BlockHelper#placeRailWithoutUpdate in BlockHelper.java#L196 sets the variable J to the Y value of that the target, however due to that value being negative the bit shift in L205 also results in a negative value. example: a Y value of -59 would result in a shift to -4, which is the correct chunk section. However as LevelChunk#getSections returns an array this is an invalid index. I unfortunately do not know how Minecraft indexes these chunk sections, all I know that this is likely the cause.

Reproduction Steps

  1. Place a schematic cannon, fuel it & have it place a schematic of a rail/something containing a rail (was a powered rail for us if this matters) at a Y value below 0
  2. Start the print (non creative)
  3. Game/Server will crash as soon as it attempts to place the rail
  4. Game/Server will continue to crash every time the chunk is loaded (even if flywheel backend is turned off). The only work around is to load the world without create or purposely corrupt the chunk to have it regenerate.

Expected Result

The rail should be placed as expected and the game/server should not crash, much less should it make the chunk unusable.

Screenshots and Videos

N/A

Crash Report or Log

N/A

Operating System

W10 (Client), Linux (Server, Ubuntu)

Mod Version

0.4.0a

Minecraft Version

1.18.1

Forge Version

39.0.5

Other Mods

Should not be relevant but: jei-1.18.1-9.1.1.48 Jade-1.18-4.0.2 StorageDrawers-1.18.1-10.0.0 ExtraStorage-1.18.1-2.0.0 refinedstorageaddons-0.8.0 time-in-a-bottle-2.1.0-mc1.18.1 voicechat-forge-1.18.1-2.1.22 architectury-3.2.52 BuildingWands-2.3_mc1.18-forge refinedstorage-1.10.0-beta.3 curiouselytra-forge-1.18.1-5.0.0.1 flywheel-forge-1.18-0.4.2-rc pipez-1.18.1-1.0.1 veinmining-forge-1.18.1-0.15 MouseTweaks-forge-mc1.18-2.18 curios-forge-1.18.1-5.0.3.0 caelus-forge-1.18-3.0.0.1 curioofundying-forge-1.18-5.3.0.0 easy_villagers-1.18.1-1.0.0 easy_piglins-1.18.1-1.0.0 Compressed-1.4.1-Forge-1.8.1 mcw-bridges-2.0.1-mc1.18.1 mcw-trapdoors-1.0.4-mc1.18.1 mcw-lights-1.0.2-mc1.18.1 mcw-fences-1.0.2-mc1.18.1 mcw-windows-2.0.2-mc1.18.1 mcw-doors-1.0.5-mc1.18.1 sophisticatedbackpacks-1.18-3.12.1.433 InventorySorter-1.8.1-1.18 comforts-forge-1.18-5.0.0.1 appleskin-forge-mc1.18-2.2.0 ironchest-1.18-13.0.5 2 other private mods made by myself (ensured that they are not the cause)

Additional Context

No response

reidbhuntley commented 2 years ago

Thanks for the detailed report, this has been fixed for the next patch