[1.12] Performance improvements, bug fixes and clean up#1020
[1.12] Performance improvements, bug fixes and clean up#1020Meldexun wants to merge 116 commits into
Conversation
|
Alright this is it. Currently doing the final testing round. Below I will explain the new commits.
|
authvin
left a comment
There was a problem hiding this comment.
I haven't combed through every change in detail, but everything looks good to me. There's quite a few things I might want to port forward to the 1.20 version, when I have time. Leaving it as approved now, in case there's anything else that needs adding, but I'm fine with making a new release with these changes - assuming they've been tested, like you mentioned
|
Eagle found some rotation issues that need fixing and I also have a few small performance tweaks to finish up. But no big changes are planned now. |
8bdc1e2 to
3d99d5a
Compare
This PR is a collection of a lot of performance improvements, bug fixes and a bit of code clean up. Due to the huge amount of changes I recommend checking every commit individually. This should be doable because every commit only changes a single thing and the individual changes are (currently) not split among multiple commits.
Currently all changes are untested. I will try to do some testing in the next days and report back.
Here is a list of the reasoning behind each commit:
Improve LocalWorld#isStructureInRadius implementations
Performance: Iterate whole area directly instead of going in circles (usually done to find the nearest structure but that isn't needed here)
Bug Fix:
MapGenStructure#canSpawnStructureAtCoordsmay crash due toMapGenBase#worldbeing nullClean up
Improve EntityNames#toInternalName
Performance: Very slow, iterates map + a lot of regex. Not exactly the same functionality as before. Previously it removed all occurances of "minecraft:", "entity" and "_". This means something like
z_ominecraft:mbentityi_e__would be a valid alias forzombie. Now only the "minecraft:" prefix is removed and the aliases specified byEntityNamesare supported.Fix captureBlockSnapshots corruption when setBlockState errors
Bug Fix: When
Chunk#setBlockStatethrows an exception thecaptureBlockStatesfield might get corrupted which creates a massive memory leakClean up BlockPos2D
Clean up
Fix missing BlockPos2D#hashCode implementation
Bug Fix: This class is used as a
HashMapkey inOTGChunkGeneratorbut is missing ahashCodeimplementationClean up BlockPos3D
Clean up
Fix BlockPos3D#equals
Bug Fix: y coordinate is not compared
Fix missing BlockPos3D#hashCode implementation
Bug Fix: Didn't find any hash map usage but doesn't hurt to implement this as well
Replace FifoMap with LRUCache
Performance: Use access order instead of write order to determine which entry to remove (LRU instead of FIFO). Also, initialize map with sufficient size so that no resizing is ever needed,
Improve DimensionConfigBase constructor
Performance: Avoid creating
ArrayListjust to calltoArrayin the endImprove DefaultMaterial lookups
Performance: Use
HashMapinstead ofTreeMapforlookupNameClean up
Improve PlantType lookup
Performance: Use
HashMapinstead ofTreeMapforLOOKUP_MAPImprove ChunkGenerator#getChunk
Performance: Caching like this only hurts performance. Calling
getLoadedChunkis unnecessary if just callinggetChunkwhen the result is null.Clean up BiomeGroup
Clean up
Fix unnecessary ArrayList creation
Performance: Iterate list directly instead of creating
ArrayListfrom sub listImprove BiomeGroup depth map cache
Performance:
BiomeGroupManager#isBiomeDepthMapEmptyonly checks if any depth map is non-empty but this can be done without creating a depth map.Remove unnecessary initGroupSeed call
Clean up:
LayerLandRandomdoesn't callnextGroupIntwhich makes this uselessRename getRandomOf4 to mostCommonOrRandom
Clean up: Confusing name
Improve mostCommonOrRandom
Performance: Less comparisons
Add InvalidConfigException constructor with cause argumnet
Feature: Adds option to create
InvalidConfigExceptionwith a cause. Stacktrace won't be truncated when throwing aInvalidConfigExceptionusing the new constructor this way.Clean up StringHelper
Performance: Avoid
Collection#toArrayinjoin. UseInvalidConfigExceptionconstructor with cause.Clean up
Improve StringHelper.readCommaSeperatedString
Performance: Use
ArrayListinstead ofLinkedList. ReturnListinstead of callingList#toArrayat the end.Clean up
Clean up Resource.hashCode
Clean up
Improve FileSettingsReaderOTGPlus.readSettings
Performance: Only use up to 3 calls to
indexOforlastIndexOfper line.Clean up
Improve NBT reading
Performance: Use
BufferedInputStreamFix silver shulker box id
Bug Fix: Wrong id (228 is cyan shulker box)
Add glazed terracotta
Bug Fix: Add missing glazed terracotta entries
Remove "UNKNOWN_BLOCK"
Bug Fix: IDs not used by vanilla will used by mods
Add fastutil dependency
Feature: Make FastUtil 7.1.0 available in common package as it is used by Minecraft already
Improve layer random number generator
Implement custom RNG (similar to
java.util.SplittableRandom) to generate good random numbers.LayerRNGserves as an abstraction layer to support legacy RNG implementation for old worlds. StoreWorldSaveDatainServerConfigProviderto be able to determine the OTG which was used to create a world.~~NOTE: Currently the new RNG is unused because it expects the world creation version to be
>=9but I didn't change the world creation version yet (see here)~~FixedCreate WeightedList to replace TreeMap iteration
Performance: Implement
WeightedListto avoidTreeMapiteration.WeightedList#getRandomreturns a random element based on the weight by traversing a AVL tree.Format LocalMaterialData
Clean up
Format ReplacedBlocksMatrix
Clean up
Reimplement LocalMaterialData
Reimplementation of
LocalMaterialDataand its subclasses for various performance improvements and bug fixes. The most important changes are:Use enum +
Reference2IntMapto greatly speed upMaterialSet#containsMake
LocalMaterialDataimmutableReplace
LocalMaterialData#canSnowFallOnwithLocalWorld#canPlaceSnowAtto allow correct checking if snow is placeableAvoid all
DefaultMaterialmethods because most are just approximations and don't work for modded blocks anyway