Skip to content

Commit 73d297a

Browse files
committed
Use expressions to workaround CONSTANT classValue not being remapped. Closes #757
1 parent 9cad41d commit 73d297a

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/main/java/net/earthcomputer/clientcommands/mixin/rngevents/MushroomCowSheepAndSnowGolemMixin.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package net.earthcomputer.clientcommands.mixin.rngevents;
22

3+
import com.llamalad7.mixinextras.expression.Definition;
4+
import com.llamalad7.mixinextras.expression.Expression;
35
import net.earthcomputer.clientcommands.features.PlayerRandCracker;
6+
import net.minecraft.server.level.ServerLevel;
47
import net.minecraft.world.InteractionHand;
58
import net.minecraft.world.entity.animal.MushroomCow;
69
import net.minecraft.world.entity.animal.SnowGolem;
@@ -13,7 +16,9 @@
1316

1417
@Mixin({MushroomCow.class, Sheep.class, SnowGolem.class})
1518
public class MushroomCowSheepAndSnowGolemMixin {
16-
@Inject(method = "mobInteract", at = @At(value = "CONSTANT", args = "classValue=net/minecraft/server/level/ServerLevel"))
19+
@Definition(id = "ServerLevel", type = ServerLevel.class)
20+
@Expression("? instanceof ServerLevel")
21+
@Inject(method = "mobInteract", at = @At("MIXINEXTRAS:EXPRESSION"))
1722
public void onInteract(Player player, InteractionHand hand, CallbackInfoReturnable<Boolean> ci) {
1823
PlayerRandCracker.onItemDamage(1, player, player.getItemInHand(hand));
1924
}

src/main/java/net/earthcomputer/clientcommands/mixin/rngevents/PumpkinBlockMixin.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package net.earthcomputer.clientcommands.mixin.rngevents;
22

3+
import com.llamalad7.mixinextras.expression.Definition;
4+
import com.llamalad7.mixinextras.expression.Expression;
35
import net.earthcomputer.clientcommands.features.PlayerRandCracker;
46
import net.minecraft.core.BlockPos;
7+
import net.minecraft.server.level.ServerLevel;
58
import net.minecraft.world.InteractionHand;
69
import net.minecraft.world.InteractionResult;
710
import net.minecraft.world.entity.player.Player;
@@ -17,8 +20,9 @@
1720

1821
@Mixin(PumpkinBlock.class)
1922
public class PumpkinBlockMixin {
20-
21-
@Inject(method = "useItemOn", at = @At(value = "CONSTANT", args = "classValue=net/minecraft/server/level/ServerLevel"))
23+
@Definition(id = "ServerLevel", type = ServerLevel.class)
24+
@Expression("? instanceof ServerLevel")
25+
@Inject(method = "useItemOn", at = @At("MIXINEXTRAS:EXPRESSION"))
2226
public void onShear(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult, CallbackInfoReturnable<InteractionResult> cir) {
2327
PlayerRandCracker.onItemDamage(1, player, stack);
2428
}

0 commit comments

Comments
 (0)