Skip to content

Commit

Permalink
fix mixins not working
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdElAziz333 committed May 24, 2023
1 parent 0a49698 commit bf8dc0c
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 120 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx2G
org.gradle.daemon=false
minecraft_version=1.19.2
forge_version=1.19.2-43.2.8
mod_version=0.2.3
mod_version=0.2.4
maven_group=com.abdelaziz.canary
archives_base_name=canary-mc1.19.2
mod_id=canary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ private CanaryConfig() {

this.addMixinRule("calc", true);
this.addMixinRule("calc.if_else", true);
this.addMixinRule("calc.if_else.ai", true);
this.addMixinRule("calc.if_else.ai.evaluator", true);
this.addMixinRule("calc.if_else.block_entity", true);
this.addMixinRule("calc.if_else.block_entity.can_place_item", true);
this.addMixinRule("calc.if_else.block_entity.can_place_item.brewing_stand", true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
return false;
}

//For now, disable calc.if_else.player_slot optimization when Inventorio is loaded, until i fix this issue
if (mixinClassName.startsWith(MIXIN_PACKAGE_ROOT + "calc.if_else.player_slot") && (FMLLoader.getLoadingModList().getModFileById("inventorio") != null)) {
return false;
}

//Fix: if Forge errors is not empty then disable shapes, math.sine_lut and alloc.blockstate optimizations. (Thanks for malte!)
if ((mixinClassName.startsWith(MIXIN_PACKAGE_ROOT + "shapes") && mixinClassName.startsWith(MIXIN_PACKAGE_ROOT + "math.sine_lut") && mixinClassName.startsWith(MIXIN_PACKAGE_ROOT + "alloc.blockstate")) && !LoadingModList.get().getErrors().isEmpty()) {
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.abdelaziz.canary.mixin.ai.pathing;

import com.abdelaziz.canary.common.ai.pathing.PathNodeCache;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.pathfinder.BlockPathTypes;
import net.minecraft.world.level.pathfinder.FlyNodeEvaluator;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(FlyNodeEvaluator.class)
public class FlyNodeEvaluatorMixin {
/**
* @reason Use optimized implementation which avoids scanning blocks for dangers where possible
* @author JellySquid, 2No2Name
*/
@Redirect(method = "getBlockPathType(Lnet/minecraft/world/level/BlockGetter;III)Lnet/minecraft/world/level/pathfinder/BlockPathTypes;", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/pathfinder/FlyNodeEvaluator;checkNeighbourBlocks(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos$MutableBlockPos;Lnet/minecraft/world/level/pathfinder/BlockPathTypes;)Lnet/minecraft/world/level/pathfinder/BlockPathTypes;"))
private BlockPathTypes getNodeTypeFromNeighbors(BlockGetter world, BlockPos.MutableBlockPos pos, BlockPathTypes type) {
return PathNodeCache.getNodeTypeFromNeighbors(world, pos, type);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

Expand Down Expand Up @@ -70,4 +71,13 @@ private static void doNotChangePositionIfCanarySinglePosCall(BlockGetter world,
}
}
}

/**
* @reason Use optimized implementation which avoids scanning blocks for dangers where possible
* @author JellySquid, 2No2Name
*/
@Redirect(method = "getBlockPathTypeStatic", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/pathfinder/WalkNodeEvaluator;checkNeighbourBlocks(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos$MutableBlockPos;Lnet/minecraft/world/level/pathfinder/BlockPathTypes;)Lnet/minecraft/world/level/pathfinder/BlockPathTypes;"))
private static BlockPathTypes getNodeTypeFromNeighbors(BlockGetter world, BlockPos.MutableBlockPos pos, BlockPathTypes type) {
return PathNodeCache.getNodeTypeFromNeighbors(world, pos, type);
}
}

This file was deleted.

This file was deleted.

3 changes: 1 addition & 2 deletions src/main/resources/canary.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"ai.nearby_entity_tracking.goals.AvoidEntityGoalMixin",
"ai.nearby_entity_tracking.goals.LookAtPlayerGoalMixin",
"ai.pathing.BlockStateBaseMixin",
"ai.pathing.FlyNodeEvaluatorMixin",
"ai.pathing.PathNavigationRegionMixin",
"ai.pathing.WalkNodeEvaluatorMixin",
"ai.poi.PoiManagerMixin",
Expand Down Expand Up @@ -84,8 +85,6 @@
"block.moving_block_shapes.VoxelShapeMixin",
"block.redstone_wire.RedStoneWireBlockMixin",
"cached_hashcode.BlockStatePairKeyMixin",
"calc.if_else.ai.evaluator.FlyNodeEvaluatorMixin",
"calc.if_else.ai.evaluator.WalkNodeEvaluatorMixin",
"calc.if_else.block_entity.can_place_item.brewing_stand.BrewingStandBlockEntityMixin",
"calc.if_else.block_entity.composter.ComposterBlockMixin",
"calc.if_else.block_entity.get_capability.brewing_stand.BrewingStandBlockEntityMixin",
Expand Down

0 comments on commit bf8dc0c

Please sign in to comment.