Upload files to "/"

This commit is contained in:
2026-05-31 20:12:28 +00:00
commit 30b3ef72a4
2 changed files with 361 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
package xyz.nodrop.farmingtools.mixin.client;
import net.minecraft.block.Block;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerInteractionManager;
import net.minecraft.util.math.BlockPos;
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.callback.CallbackInfoReturnable;
import xyz.nodrop.farmingtools.client.hud.FarmingTrackerModule;
@Mixin(ClientPlayerInteractionManager.class)
public class MixinPlayerInteractionManager {
private Block pendingBrokenBlock = null; // tymczasowe przechowanie
@Inject(method = "breakBlock", at = @At("HEAD"))
private void beforeBreakBlock(BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
MinecraftClient client = MinecraftClient.getInstance();
if (client.world != null) {
pendingBrokenBlock = client.world.getBlockState(pos).getBlock();
}
}
@Inject(method = "breakBlock", at = @At("RETURN"))
private void onBreakBlock(BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
if (Boolean.TRUE.equals(cir.getReturnValue()) && pendingBrokenBlock != null) {
FarmingTrackerModule.INSTANCE.onBlockBroken(pendingBrokenBlock);
}
pendingBrokenBlock = null;
}
}