Conversation
…es require annotations in these modules
|
I will wait for @sylv256 review before merging. There is no rush with this. |
LlamaLad7
left a comment
There was a problem hiding this comment.
Gave up individually commenting but you get the idea. I know these were problems before but it we're changing them may as well fix them.
Additionally:
- Using names for argsOnly locals seems to me less stable than using ordinals / implicits, since it seems more likely for the internal code to change than the external api
- Implicit mode seems potentially more stable than names when possible for normal locals, though I feel less strongly about this
|
|
||
| @Mixin(LivingEntity.class) | ||
| abstract class LivingEntityMixin { | ||
| @Definition(id = "getBlockState", method = "Lnet/minecraft/world/level/Level;getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;") |
There was a problem hiding this comment.
Either define the local or switch to MEV
|
|
||
| @Inject(method = "createRegion", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/chunk/RenderRegionCache;getSectionDataCopy(Lnet/minecraft/world/level/Level;III)Lnet/minecraft/client/renderer/chunk/SectionCopy;")) | ||
| private void copyDataForChunk(Level level, long packedChunkPos, CallbackInfoReturnable<RenderSectionRegion> cir, @Share("dataMap") LocalRef<Long2ObjectOpenHashMap<Object>> mapRef, @Local(ordinal = 11) int x, @Local(ordinal = 10) int y, @Local(ordinal = 9) int z) { | ||
| private void copyDataForChunk(Level level, long sectionNode, CallbackInfoReturnable<RenderSectionRegion> cir, @Share("dataMap") LocalRef<Long2ObjectOpenHashMap<Object>> mapRef, @Local(name = "regionSectionX") int regionSectionX, @Local(name = "regionSectionY") int regionSectionY, @Local(name = "regionSectionZ") int regionSectionZ) { |
There was a problem hiding this comment.
Can any of these locals be avoided by switching injectors, if they're involved in the call?
| @Inject(method = "getPathTypeFromState", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/core/BlockPos$MutableBlockPos;set(III)Lnet/minecraft/core/BlockPos$MutableBlockPos;"), cancellable = true) | ||
| private void onGetNodeType(int x, int y, int z, CallbackInfoReturnable<PathType> cir, @Local BlockPos pos) { | ||
| @Definition(id = "set", method = "Lnet/minecraft/core/BlockPos$MutableBlockPos;set(III)Lnet/minecraft/core/BlockPos$MutableBlockPos;") | ||
| @Expression("? = ?.set(?, ?, ?)") |
There was a problem hiding this comment.
Again either define local or use another injector
| @Inject(method = "getPathTypeFromState", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;getBlock()Lnet/minecraft/world/level/block/Block;"), cancellable = true) | ||
| private static void getCommonNodeType(BlockGetter level, BlockPos pos, CallbackInfoReturnable<PathType> cir, @Local BlockState state) { | ||
| PathType pathType = LandPathTypeRegistry.getPathType(state, level, pos, false); | ||
| private static void getCommonNodeType(BlockGetter level, BlockPos pos, CallbackInfoReturnable<PathType> cir, @Local(name = "blockState") BlockState blockState) { |
There was a problem hiding this comment.
Is the local avoidable with ModifyReceiver?
| @ModifyVariable(method = {"lambda$stopSleeping$0", "startSleeping"}, at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/world/level/Level;getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;")) | ||
| private BlockState modifyBedForOccupiedState(BlockState state, BlockPos sleepingPos) { | ||
| InteractionResult result = EntitySleepEvents.ALLOW_BED.invoker().allowBed((LivingEntity) (Object) this, sleepingPos, state, state.getBlock() instanceof BedBlock); | ||
| @ModifyVariable(method = {"lambda$stopSleeping$0", "startSleeping"}, at = @At(value = "MIXINEXTRAS:EXPRESSION", shift = At.Shift.AFTER)) |
| ) | ||
| private void injectUseEntityCallback(CallbackInfo ci, @Local InteractionHand hand, @Local EntityHitResult hitResult, @Local Entity entity) { | ||
| InteractionResult result = UseEntityCallback.EVENT.invoker().interact(player, player.level(), hand, entity, hitResult); | ||
| private void injectUseEntityCallback(CallbackInfo ci, @Local(name = "hand") InteractionHand hand, @Local(name = "entityHit") EntityHitResult entityHit, @Local(name = "entity") Entity entity) { |
| @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/Block;playerWillDestroy(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/entity/player/Player;)Lnet/minecraft/world/level/block/state/BlockState;"), method = "destroyBlock", cancellable = true) | ||
| private void breakBlock(BlockPos pos, CallbackInfoReturnable<Boolean> cir, @Local BlockEntity entity, @Local BlockState state) { | ||
| boolean result = PlayerBlockBreakEvents.BEFORE.invoker().beforeBlockBreak(this.level, this.player, pos, state, entity); | ||
| private void breakBlock(BlockPos pos, CallbackInfoReturnable<Boolean> cir, @Local(name = "blockEntity") BlockEntity blockEntity, @Local(name = "state") BlockState state) { |
There was a problem hiding this comment.
Some locals here seem avoidable, same below
|
|
||
| @Inject(method = "<init>", at = @At(value = "INVOKE", target = "Lcom/google/common/collect/ImmutableList$Builder;add(Ljava/lang/Object;)Lcom/google/common/collect/ImmutableList$Builder;", ordinal = 2, shift = At.Shift.AFTER)) | ||
| private void addFabricTemplateProvider(ResourceManager resourceManager, LevelStorageSource.LevelStorageAccess storageAccess, DataFixer dataFixer, HolderGetter<Block> blockLookup, CallbackInfo ci, @Local ImmutableList.Builder<StructureTemplateManager.Source> builder) { | ||
| private void addFabricTemplateProvider(ResourceManager resourceManager, LevelStorageSource.LevelStorageAccess storage, DataFixer fixerUpper, HolderGetter<Block> blockLookup, CallbackInfo ci, @Local(name = "builder") ImmutableList.Builder<StructureTemplateManager.Source> builder) { |
|
Cleaning up the unnecessary locals was honestly more work than I signed up for |
|
There is no need to get them all perfect as part of this PR, as long as its not making things worse. |
|
|
||
| @Inject(method = "getDataPackSelectionSettings", | ||
| at = @At(value = "INVOKE", target = "Lnet/minecraft/server/packs/repository/PackRepository;reload()V", shift = At.Shift.BEFORE)) | ||
| at = @At(value = "INVOKE", target = "Lnet/minecraft/server/packs/repository/PackRepository;reload()V")) |
There was a problem hiding this comment.
the before wasn't needed, so removing it aligns with mixin best practices
There was a problem hiding this comment.
It's worse than not needed. Shifting before shifted 1 instruction too early. For each of these changes I manually verified that removing the brittle shift didn't affect behaviour
|
Leave this with me, I think I will likely split out some of the changes in this PR into smaller more targgeted PRs that can be merged quickly without causing many conflicts. |
Todo:
(not all of them will need fixing)