Fixed build issues in RecipeManagerMixin
This commit is contained in:
parent
3d4245331a
commit
ec94517c91
1 changed files with 23 additions and 14 deletions
|
@ -7,6 +7,7 @@ import net.minecraft.server.packs.resources.ResourceManager;
|
|||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||
import net.minecraft.world.item.crafting.RecipeManager;
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
@ -24,8 +25,11 @@ import java.util.Optional;
|
|||
|
||||
@Mixin(RecipeManager.class)
|
||||
public abstract class RecipeManagerMixin {
|
||||
|
||||
@Shadow
|
||||
protected abstract <C extends Container, T extends Recipe<C>> Map<ResourceLocation, T> byType(RecipeType<T> recipeType);
|
||||
protected abstract <C extends Container, T extends Recipe<C>> Map<ResourceLocation, RecipeHolder<T>> byType(
|
||||
RecipeType<T> recipeType
|
||||
);
|
||||
|
||||
@Inject(method = "apply(Ljava/util/Map;Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/util/profiling/ProfilerFiller;)V", at = @At("HEAD"))
|
||||
public void bcl_interceptApply(
|
||||
|
@ -42,21 +46,26 @@ public abstract class RecipeManagerMixin {
|
|||
RecipeType<T> recipeType,
|
||||
C container,
|
||||
Level level,
|
||||
CallbackInfoReturnable<Optional<T>> cir
|
||||
CallbackInfoReturnable<Optional<RecipeHolder<T>>> cir
|
||||
) {
|
||||
var inter = this.byType(recipeType);
|
||||
var all = inter.values().stream().filter((recipe) -> recipe.matches(container, level)).sorted((a, b) -> {
|
||||
if (a.getId().getNamespace().equals(b.getId().getNamespace())) {
|
||||
return a.getId().getPath().compareTo(b.getId().getPath());
|
||||
}
|
||||
if (a.getId().getNamespace().equals("minecraft") && !b.getId().getNamespace().equals("minecraft")) {
|
||||
return 1;
|
||||
} else if (!a.getId().getNamespace().equals("minecraft") && b.getId().getNamespace().equals("minecraft")) {
|
||||
return -1;
|
||||
} else {
|
||||
return a.getId().getNamespace().compareTo(b.getId().getNamespace());
|
||||
}
|
||||
}).toList();
|
||||
var all = inter
|
||||
.values()
|
||||
.stream()
|
||||
.filter((recipe) -> recipe.value().matches(container, level)).sorted((a, b) -> {
|
||||
if (a.id().getNamespace().equals(b.id().getNamespace())) {
|
||||
return a.id().getPath().compareTo(b.id().getPath());
|
||||
}
|
||||
if (a.id().getNamespace().equals("minecraft") && !b.id().getNamespace().equals("minecraft")) {
|
||||
return 1;
|
||||
} else if (!a.id().getNamespace().equals("minecraft") && b.id()
|
||||
.getNamespace()
|
||||
.equals("minecraft")) {
|
||||
return -1;
|
||||
} else {
|
||||
return a.id().getNamespace().compareTo(b.id().getNamespace());
|
||||
}
|
||||
}).toList();
|
||||
|
||||
if (all.size() > 1) {
|
||||
cir.setReturnValue(Optional.of(all.get(0)));
|
||||
|
|
Loading…
Reference in a new issue