Blood-Asp / GT5-Unofficial

Decompiled and modified version of GT5.07.07
160 stars 97 forks source link

Oil drilling rig chunks in -X/-Z wrong #1488

Open richardhendricks opened 6 years ago

richardhendricks commented 6 years ago

This logic for negative chunks is wrong and not necessary. % is continuous across negative values and needs no special handling.

https://github.com/Blood-Asp/GT5-Unofficial/blob/unstable/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java#L117

Tested with

https://github.com/GTNewHorizons/GT5-Unofficial/commit/4c4c412769df240e4dfe949854c8750b7a91cc9f

Oil in negative chunks

Oil Oil Oil Oil Total in row
423 432 654 633 2142
630 499 563 476 2168
4766 602 560 444 2082
458 651 490 525 2124

Total oil in 4x4 = 8516 Base extraction per operation is .5 = 4258

For HV oil drill, each operation is 32 ticks

4258 * 20/32 = 2661L/s

80902L in 30s test = 2692L/s (roundoff error from LSB)

https://github.com/GTNewHorizons/NewHorizons/issues/3399

richardhendricks commented 6 years ago

Sample output from log mOilFieldChunks.size = 16 pump speed = 0.5 chunkX = -64 chunkZ = -64 Oil pumped = 211 chunkX = -64 chunkZ = -63 Oil pumped = 315 chunkX = -64 chunkZ = -62 Oil pumped = 238 chunkX = -64 chunkZ = -61 Oil pumped = 229 chunkX = -63 chunkZ = -64 Oil pumped = 216 chunkX = -63 chunkZ = -63 Oil pumped = 249 chunkX = -63 chunkZ = -62 Oil pumped = 301 chunkX = -63 chunkZ = -61 Oil pumped = 325 chunkX = -62 chunkZ = -64 Oil pumped = 327 chunkX = -62 chunkZ = -63 Oil pumped = 281 chunkX = -62 chunkZ = -62 Oil pumped = 280 chunkX = -62 chunkZ = -61 Oil pumped = 248 chunkX = -61 chunkZ = -64 Oil pumped = 316 chunkX = -61 chunkZ = -63 Oil pumped = 238 chunkX = -61 chunkZ = -62 Oil pumped = 222 chunkX = -61 chunkZ = -61 Oil pumped = 262

richardhendricks commented 6 years ago

Java is written by mathematical idiots. / is not handled properly on the negative side. Have to use Math.floorDiv() instead https://github.com/GTNewHorizons/GT5-Unofficial/commit/7e6fb0abeef22b80f16da5f63e7849525823579e

richardhendricks commented 6 years ago

https://github.com/GTNewHorizons/GT5-Unofficial/commit/7741a6b36a7a9f36cb38c49da35d2ac8c831d2b7