Removed overwrite
This commit is contained in:
parent
b9307183d7
commit
dfd72b9f1d
1 changed files with 7 additions and 17 deletions
|
@ -8,8 +8,10 @@ import net.minecraft.world.item.crafting.RecipeManager;
|
||||||
import net.minecraft.world.item.crafting.RecipeType;
|
import net.minecraft.world.item.crafting.RecipeType;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Overwrite;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -19,32 +21,20 @@ import java.util.Optional;
|
||||||
|
|
||||||
@Mixin(RecipeManager.class)
|
@Mixin(RecipeManager.class)
|
||||||
public abstract class RecipeManagerMixin {
|
public abstract class RecipeManagerMixin {
|
||||||
@Shadow
|
|
||||||
private Map<RecipeType<?>, Map<ResourceLocation, Recipe<?>>> recipes;
|
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
private <C extends Container, T extends Recipe<C>> Map<ResourceLocation, Recipe<C>> byType(RecipeType<T> type) {
|
private <C extends Container, T extends Recipe<C>> Map<ResourceLocation, Recipe<C>> byType(RecipeType<T> type) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Inject(method = "getRecipeFor", at = @At(value = "HEAD"), cancellable = true)
|
||||||
* @author paulevs
|
private <C extends Container, T extends Recipe<C>> void bclib_getRecipeFor(RecipeType<T> type, C inventory, Level world, CallbackInfoReturnable<Optional<T>> info) {
|
||||||
* @reason Remove conflicts with vanilla tags
|
|
||||||
* Change recipe order to show mod recipes first, helps when block have vanilla tag
|
|
||||||
* (example - mod stone with vanilla tags and furnace from that stone)
|
|
||||||
*/
|
|
||||||
@Overwrite
|
|
||||||
public <C extends Container, T extends Recipe<C>> Optional<T> getRecipeFor(RecipeType<T> type, C inventory, Level world) {
|
|
||||||
Collection<Recipe<C>> values = byType(type).values();
|
Collection<Recipe<C>> values = byType(type).values();
|
||||||
List<Recipe<C>> list = new ArrayList<Recipe<C>>(values);
|
List<Recipe<C>> list = new ArrayList<>(values);
|
||||||
list.sort((v1, v2) -> {
|
list.sort((v1, v2) -> {
|
||||||
boolean b1 = v1.getId().getNamespace().equals("minecraft");
|
boolean b1 = v1.getId().getNamespace().equals("minecraft");
|
||||||
boolean b2 = v2.getId().getNamespace().equals("minecraft");
|
boolean b2 = v2.getId().getNamespace().equals("minecraft");
|
||||||
return b1 ^ b2 ? (b1 ? 1 : -1) : 0;
|
return b1 ^ b2 ? (b1 ? 1 : -1) : 0;
|
||||||
});
|
});
|
||||||
|
info.setReturnValue(list.stream().flatMap((recipe) -> Util.toStream(type.tryMatch(recipe, world, inventory))).findFirst());
|
||||||
return list.stream().flatMap((recipe) -> {
|
|
||||||
return Util.toStream(type.tryMatch(recipe, world, inventory));
|
|
||||||
}).findFirst();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue