Yarn: NoiseChunkGenerator should be in net.minecraft.world.gen

Created on 13 Feb 2021  ·  16Comments  ·  Source: FabricMC/yarn

java.lang.IllegalAccessError: class net.minecraft.world.gen.chunk.NoiseChunkGenerator tried to access protected method 'double net.minecraft.world.gen.StructureWeightSampler.getWeight(int, int, int)' (net.minecraft.world.gen.chunk.NoiseChunkGenerator and net.minecraft.world.gen.StructureWeightSampler are in unnamed module of loader 'app')

While I think the package for NoiseChunkGenerator is currently better, running Minecraft in a development environment causes this crash.

bug discussion refactor toolchain

Most helpful comment

I would argue the opposite, given we fix the behaviour either way there's no advantage to worse mappings just because Mojang happen to use a particular package structure. Not least that you don't even need Loader's make everything public at dev runtime hack anymore, Tiny Remapper can do it directly in the places where it is needed.

All 16 comments

Hmm, seems the package visibility index from enigma has stopped working for long

I doubt that the index works but the command line interface broke. Need to check.

I did start looking at improving and fixing the mappings validator. Would be nice to try and get rid of these issues. But we cannot guarantee it

Turns out check mappings was never broke. It was this that broke:
https://github.com/FabricMC/yarn/blame/21w06a/build.gradle#L396
Should be using intermediary jar

And this check mappings never worked since the intermediary update 2 years ago!



Look at the current results:

ERROR: Must be in one package:
net/minecraft/client/gui/screen/ConnectScreen
net/minecraft/client/gui/screen/ConnectScreen$1
net/minecraft/client/gui/screen/CustomizeBuffetLevelScreen
net/minecraft/client/gui/screen/CustomizeBuffetLevelScreen$1
net/minecraft/client/gui/screen/CustomizeBuffetLevelScreen$BuffetBiomesListWidget
net/minecraft/client/gui/screen/CustomizeBuffetLevelScreen$BuffetBiomesListWidget$BuffetBiomeItem
net/minecraft/client/gui/screen/CustomizeFlatLevelScreen
net/minecraft/client/gui/screen/CustomizeFlatLevelScreen$1
net/minecraft/client/gui/screen/CustomizeFlatLevelScreen$SuperflatLayersListWidget
net/minecraft/client/gui/screen/CustomizeFlatLevelScreen$SuperflatLayersListWidget$SuperflatLayerItem
net/minecraft/client/gui/screen/DialogScreen
net/minecraft/client/gui/screen/DialogScreen$ChoiceButton
net/minecraft/client/gui/screen/PresetsScreen
net/minecraft/client/gui/screen/PresetsScreen$SuperflatPreset
net/minecraft/client/gui/screen/PresetsScreen$SuperflatPresetsListWidget
net/minecraft/client/gui/screen/PresetsScreen$SuperflatPresetsListWidget$SuperflatPresetEntry
net/minecraft/client/gui/screen/Screen
net/minecraft/client/gui/screen/option/LanguageOptionsScreen
net/minecraft/client/gui/screen/option/LanguageOptionsScreen$LanguageSelectionListWidget
net/minecraft/client/gui/screen/option/LanguageOptionsScreen$LanguageSelectionListWidget$LanguageEntry
net/minecraft/client/gui/screen/option/VideoOptionsScreen
ERROR: Must be in one package:
net/minecraft/world/gen/feature/DripstoneClusterFeature
net/minecraft/world/gen/feature/LargeDripstoneFeature
net/minecraft/world/gen/feature/LargeDripstoneFeature$1
net/minecraft/world/gen/feature/LargeDripstoneFeature$DripstoneGenerator
net/minecraft/world/gen/feature/LargeDripstoneFeature$WindModifier
net/minecraft/world/gen/feature/SmallDripstoneFeature
net/minecraft/world/gen/feature/util/DripstoneHelper
ERROR: Must be in one package:
net/minecraft/client/util/math/AffineTransformation
net/minecraft/client/util/math/Vector4f
net/minecraft/util/math/DirectionTransformation
net/minecraft/util/math/DirectionTransformation$1
net/minecraft/util/math/Matrix3f
net/minecraft/util/math/Matrix4f
net/minecraft/util/math/Vec3f
ERROR: Must be in one package:
net/minecraft/util/dynamic/RegistryElementCodec
net/minecraft/util/dynamic/RegistryOps
net/minecraft/util/dynamic/RegistryOps$1
net/minecraft/util/dynamic/RegistryOps$EntryLoader
net/minecraft/util/dynamic/RegistryOps$EntryLoader$1
net/minecraft/util/dynamic/RegistryOps$EntryLoader$Impl
net/minecraft/util/dynamic/RegistryOps$ValueHolder
net/minecraft/util/dynamic/RegistryReadingOps
net/minecraft/util/registry/RegistryLookupCodec
ERROR: Must be in one package:
net/minecraft/world/gen/AquiferSampler
net/minecraft/world/gen/StructureWeightSampler
net/minecraft/world/gen/chunk/ChunkGeneratorSettings
net/minecraft/world/gen/chunk/NoiseChunkGenerator
ERROR: Must be in one package:
net/minecraft/world/chunk/EntityChunkDataAccess
net/minecraft/world/storage/RegionBasedStorage
net/minecraft/world/storage/SerializingRegionBasedStorage
net/minecraft/world/storage/StorageIoWorker
net/minecraft/world/storage/StorageIoWorker$Priority
net/minecraft/world/storage/StorageIoWorker$Result
net/minecraft/world/storage/VersionedChunkStorage
ERROR: Must be in one package:
net/minecraft/entity/EyeOfEnderEntity
net/minecraft/entity/projectile/ExplosiveProjectileEntity
net/minecraft/entity/projectile/FireworkRocketEntity
net/minecraft/entity/projectile/FishingBobberEntity
net/minecraft/entity/projectile/FishingBobberEntity$1
net/minecraft/entity/projectile/FishingBobberEntity$PositionType
net/minecraft/entity/projectile/FishingBobberEntity$State
net/minecraft/entity/projectile/LlamaSpitEntity
net/minecraft/entity/projectile/PersistentProjectileEntity
net/minecraft/entity/projectile/PersistentProjectileEntity$PickupPermission
net/minecraft/entity/projectile/ProjectileEntity
net/minecraft/entity/projectile/ShulkerBulletEntity
net/minecraft/entity/projectile/thrown/ThrownEntity
ERROR: Must be in one package:
net/minecraft/client/Keyboard
net/minecraft/client/Keyboard$1
net/minecraft/client/MinecraftClient
net/minecraft/client/MinecraftClient$1
net/minecraft/client/MinecraftClient$IntegratedResourceManager
net/minecraft/client/MinecraftClient$WorldLoadAction
net/minecraft/client/Mouse
net/minecraft/client/option/FullscreenOption
net/minecraft/client/option/Option
net/minecraft/client/option/Option$1
ERROR: Must be in one package:
net/minecraft/entity/ai/brain/task/AdmireItemTask
net/minecraft/entity/ai/brain/task/HuntFinishTask
net/minecraft/entity/ai/brain/task/HuntHoglinTask
net/minecraft/entity/ai/brain/task/RemoveOffHandItemTask
net/minecraft/entity/mob/AbstractPiglinEntity
net/minecraft/entity/mob/PiglinBrain
net/minecraft/entity/mob/PiglinBruteBrain
net/minecraft/entity/mob/PiglinBruteEntity
net/minecraft/entity/mob/PiglinEntity
ERROR: Must be in one package:
net/minecraft/client/gui/screen/world/CreateWorldScreen
net/minecraft/client/gui/screen/world/CreateWorldScreen$1
net/minecraft/client/gui/screen/world/CreateWorldScreen$Mode
net/minecraft/client/gui/screen/world/CreateWorldScreen$WorldCreationException
net/minecraft/client/gui/screen/world/MoreOptionsDialog
net/minecraft/client/world/GeneratorType
net/minecraft/client/world/GeneratorType$1
net/minecraft/client/world/GeneratorType$2
net/minecraft/client/world/GeneratorType$3
net/minecraft/client/world/GeneratorType$4
net/minecraft/client/world/GeneratorType$5
net/minecraft/client/world/GeneratorType$6
net/minecraft/client/world/GeneratorType$7
net/minecraft/client/world/GeneratorType$8
net/minecraft/client/world/GeneratorType$ScreenProvider
ERROR: Must be in one package:
net/minecraft/client/model/ModelCuboidData
net/minecraft/client/model/ModelPartBuilder
net/minecraft/client/util/math/Dilation
ERROR: Must be in one package:
net/minecraft/screen/ScreenHandler
net/minecraft/screen/slot/Slot
ERROR: Must be in one package:
net/minecraft/screen/AbstractFurnaceScreenHandler
net/minecraft/screen/slot/FurnaceFuelSlot

Ouch, thats quite a lot there. We could just take the stance of not caring in favor of better mappings? Worth discussing

Imo we will just fix it. But I will probably patch this task to work like javadoc (our javadoc does not fail if the doclint errors). So we can probably catch that illegal state exception thrown and just print the error message, or only fail when we are not on ci

Related snippet:

ERROR: Must be in one package:
net/minecraft/world/gen/AquiferSampler
net/minecraft/world/gen/StructureWeightSampler
net/minecraft/world/gen/chunk/ChunkGeneratorSettings
net/minecraft/world/gen/chunk/NoiseChunkGenerator

Looking back, some stuff probably had better be exposed than left package private or protected.

From https://github.com/FabricMC/yarn/issues/128#issuecomment-254043872:

They're a hint, sure, but compatibility with Mojang's internal mappings was never a goal.

If classes like Screen, ProjectileEntity etc (high traffic public api-like classes) do have package private stuff reserved for their peers, I guess either way mods will seek to open up access because their api-like nature. But in most other cases we see here, I'd say keeping them in same package is somehow more beneficial.

IMO we should keep the package-private friends together in the same packages. It might result in worse mappings in some places, but they're also more correct behaviour-wise.

A few interesting things stand out. For example, in that message above it says ThrownEntity must be in same package as ProjectileEntity, yet I don't see why; ThrownEntity though uses one protected method from ProjectileEntity in its lambda construction (which javac afaik usually generates a bridge method for) even if jdk's lambda meta factory can totally handle that. Just putting a reminder for myself to check if package visibility index from enigma needs an update.

Turns out that brainfart enough, ProjectileEntity's constructor is package private. That's why...
So the warnings from visibility index look to be all valid, such as when javac doesn't generate bridge methods. Now we need to move on to fix those problems...

I would argue the opposite, given we fix the behaviour either way there's no advantage to worse mappings just because Mojang happen to use a particular package structure. Not least that you don't even need Loader's make everything public at dev runtime hack anymore, Tiny Remapper can do it directly in the places where it is needed.

I agree with Chocohead, I'm not in favor of moving classes around just to respect Mojang's package structure. We need to fix the issues elsewhere in the toolchain

I would argue the opposite, given we fix the behaviour either way there's no advantage to worse mappings just because Mojang happen to use a particular package structure. Not least that you don't even need Loader's make everything public at dev runtime hack anymore, Tiny Remapper can do it directly in the places where it is needed.

Hmm, so we need to declare that we want to fix access instead at https://github.com/FabricMC/fabric-loom/blob/57c9a8f3209121f22e84b8b01b64f1093256f1d3/src/main/java/net/fabricmc/loom/configuration/providers/minecraft/MinecraftMappedProvider.java#L129-L136 and https://github.com/FabricMC/yarn/blob/629b96e84a8c7fcd44f87c63cbcf923000bfdf38/build.gradle#L826-L830

The loom refactor proposal is good that we can actually utilize split loom to reduce duplicate code between yarn and loom

Closing this now.

For people wondering, the solution is always to run the named (yarn) mapped jar/bytecode through fabric loader. This includes calling data generators from your mods' dev env!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

darkevilmac picture darkevilmac  ·  14Comments

Runemoro picture Runemoro  ·  44Comments

i509VCB picture i509VCB  ·  11Comments

sfPlayer1 picture sfPlayer1  ·  11Comments

Earthcomputer picture Earthcomputer  ·  24Comments