Skip to content

Commit 5cbbab7

Browse files
committed
Fix RNG events possibly being called on the server. Fixes #797
1 parent eae1639 commit 5cbbab7

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

‎src/main/java/net/earthcomputer/clientcommands/mixin/rngevents/AnvilMenuMixin.java‎

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

33
import net.earthcomputer.clientcommands.features.PlayerRandCracker;
4+
import net.minecraft.client.player.LocalPlayer;
45
import net.minecraft.world.entity.player.Player;
56
import net.minecraft.world.inventory.AnvilMenu;
67
import net.minecraft.world.item.ItemStack;
@@ -14,7 +15,7 @@ public class AnvilMenuMixin {
1415

1516
@Inject(method = "onTake", at = @At("HEAD"))
1617
public void onAnvilUse(Player player, ItemStack stack, CallbackInfo ci) {
17-
if (!player.getAbilities().instabuild) {
18+
if (player instanceof LocalPlayer && !player.getAbilities().instabuild) {
1819
PlayerRandCracker.onAnvilUse();
1920
}
2021
}
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package net.earthcomputer.clientcommands.mixin.rngevents;
22

3+
import com.llamalad7.mixinextras.sugar.Local;
34
import net.earthcomputer.clientcommands.features.PlayerRandCracker;
45
import net.minecraft.world.item.CrossbowItem;
6+
import net.minecraft.world.level.Level;
57
import org.spongepowered.asm.mixin.Mixin;
68
import org.spongepowered.asm.mixin.injection.At;
79
import org.spongepowered.asm.mixin.injection.Inject;
@@ -10,7 +12,9 @@
1012
@Mixin(CrossbowItem.class)
1113
public class CrossbowItemMixin {
1214
@Inject(method = "performShooting", at = @At("HEAD"))
13-
private void onPerformShooting(CallbackInfo ci) {
14-
PlayerRandCracker.onCrossbowUse();
15+
private void onPerformShooting(CallbackInfo ci, @Local(argsOnly = true, name = "level") Level level) {
16+
if (level.isClientSide()) {
17+
PlayerRandCracker.onCrossbowUse();
18+
}
1519
}
1620
}

0 commit comments

Comments
 (0)