58 lines
2.1 KiB
Java
58 lines
2.1 KiB
Java
package dev.pfaff.recipe_nope.mixin;
|
|
|
|
import dev.pfaff.recipe_nope.injector.UnconstrainedRedirect;
|
|
import net.minecraft.nbt.CompoundTag;
|
|
import net.minecraft.nbt.Tag;
|
|
import net.minecraft.resources.ResourceLocation;
|
|
import net.minecraft.server.MinecraftServer;
|
|
import net.minecraft.server.level.ServerPlayer;
|
|
import net.minecraft.stats.ServerRecipeBook;
|
|
import net.minecraft.world.item.crafting.Recipe;
|
|
import org.spongepowered.asm.mixin.Final;
|
|
import org.spongepowered.asm.mixin.Mixin;
|
|
import org.spongepowered.asm.mixin.Overwrite;
|
|
import org.spongepowered.asm.mixin.Shadow;
|
|
import org.spongepowered.asm.mixin.injection.At;
|
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
|
import org.spongepowered.asm.mixin.injection.Slice;
|
|
|
|
import java.util.Collection;
|
|
|
|
@Mixin(ServerPlayer.class)
|
|
public abstract class ServerPlayerEntityMixin {
|
|
@Shadow @Final private ServerRecipeBook recipeBook;
|
|
@Shadow @Final public MinecraftServer server;
|
|
|
|
@UnconstrainedRedirect(method = "<init>", at = @At(value = "NEW", target = "()Lnet/minecraft/stats/ServerRecipeBook;"))
|
|
private ServerRecipeBook init$noRecipeBook() {
|
|
return null;
|
|
}
|
|
|
|
@Overwrite
|
|
public int awardRecipes(Collection<Recipe<?>> recipes) {
|
|
return 0;
|
|
}
|
|
|
|
@Overwrite
|
|
public void awardRecipesByKey(ResourceLocation[] ids) {
|
|
}
|
|
|
|
@Overwrite
|
|
public int resetRecipes(Collection<Recipe<?>> recipes) {
|
|
return 0;
|
|
}
|
|
|
|
@Redirect(method = "addAdditionalSaveData", at = @At(value = "INVOKE", target = "Lnet/minecraft/stats/ServerRecipeBook;toNbt()Lnet/minecraft/nbt/CompoundTag;"))
|
|
private CompoundTag writeCustomDataToNbt$recipeBookToNbt(ServerRecipeBook instance) {
|
|
return new CompoundTag();
|
|
}
|
|
|
|
@Redirect(method = "addAdditionalSaveData", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/CompoundTag;put(Ljava/lang/String;Lnet/minecraft/nbt/Tag;)Lnet/minecraft/nbt/Tag;"), slice = @Slice(
|
|
from = @At(value = "INVOKE", target = "Lnet/minecraft/stats/ServerRecipeBook;toNbt()Lnet/minecraft/nbt/CompoundTag;"),
|
|
to = @At(value = "CONSTANT", args = "stringValue=Dimension")
|
|
))
|
|
private Tag writeCustomDataToNbt$putRecipeBookNbt(CompoundTag instance, String key, Tag element) {
|
|
return null;
|
|
}
|
|
}
|