Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package it.hurts.sskirillss.nerb.mixin;

import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.item.crafting.Recipe;
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.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.Collection;

@Mixin(ServerPlayer.class)
public class ServerPlayerMixin {
@Inject(method = "awardRecipes", at = @At("HEAD"), cancellable = true)
public void onAwardRecipes(Collection<Recipe<?>> holders, CallbackInfoReturnable<Integer> cir) {
cir.setReturnValue(0);
}

@Inject(method = "awardRecipesByKey", at = @At("HEAD"), cancellable = true)
public void onAwardRecipesByKey(ResourceLocation[] resourceLocations, CallbackInfo ci) {
ci.cancel();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,24 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.stats.ServerRecipeBook;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeManager;
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.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.Collection;
import java.util.List;

@Mixin(ServerRecipeBook.class)
public class ServerRecipeBookMixin {
public abstract class ServerRecipeBookMixin {
@Inject(method = "addRecipes", at = @At("HEAD"), cancellable = true)
public void denyAllRecipes(Collection<Recipe<?>> collection, ServerPlayer serverPlayer, CallbackInfoReturnable<Integer> cir) {
cir.setReturnValue(0);
}

@Inject(method = "toNbt", at = @At("HEAD"), cancellable = true)
public void onSave(CallbackInfoReturnable<CompoundTag> cir) {
cir.setReturnValue(new CompoundTag());
Expand Down
1 change: 1 addition & 0 deletions common/src/main/resources/nerb-common.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
],
"mixins": [
"RecipeBookMixin",
"ServerPlayerMixin",
"ServerRecipeBookMixin"
],
"injectors": {
Expand Down