1.20-5-pre2
This commit is contained in:
1 parent
b6b58ef727
commit
dbe14b2b13
2 files changed
+19
-11
No files matched your search
+1
-1
@@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx1G
|
||||
|
||||
# Fabric Properties
|
||||
# check https://fabricmc.net/develop/
|
||||
minecraft_version=1.20.5-pre1
|
||||
minecraft_version=1.20.5-pre2
|
||||
loader_version=0.15.9
|
||||
jsr305_version=3.0.2
|
||||
fabric_version=0.96.14+1.20.5
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.RecipeManagerInterface;
|
||||
import com.google.common.collect.Multimap;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
@@ -8,6 +9,7 @@ import net.minecraft.world.item.Item;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
@@ -19,22 +21,28 @@ import net.minecraft.world.item.crafting.RecipeType;
|
||||
@Mixin(RecipeManager.class)
|
||||
public class RecipeManager_scarpetMixin implements RecipeManagerInterface
|
||||
{
|
||||
@Shadow private Multimap<RecipeType<?>, RecipeHolder<?>> byType;
|
||||
|
||||
@Shadow private Map<RecipeType<?>, Map<ResourceLocation, RecipeHolder<?>>> recipes;
|
||||
@Shadow private Map<ResourceLocation, RecipeHolder<?>> byName;
|
||||
|
||||
@Override
|
||||
public List<Recipe<?>> getAllMatching(RecipeType<?> type, ResourceLocation itemId, final RegistryAccess registryAccess)
|
||||
public List<Recipe<?>> getAllMatching(RecipeType<?> type, ResourceLocation itemId, RegistryAccess registryAccess)
|
||||
{
|
||||
Map<ResourceLocation, RecipeHolder<?>> typeRecipes = recipes.get(type);
|
||||
// happens when mods add recipe to the registry without updating recipe manager
|
||||
if (typeRecipes == null) return List.of();
|
||||
RecipeHolder<?> recipeFromMap = typeRecipes.get(itemId);
|
||||
if (recipeFromMap != null)
|
||||
return List.of(recipeFromMap.value());
|
||||
// quiq cheq
|
||||
RecipeHolder<?> recipe = byName.get(itemId);
|
||||
if (recipe != null && recipe.value().getType().equals(type))
|
||||
{
|
||||
return List.of(recipe.value());
|
||||
}
|
||||
if (!byType.containsKey(type))
|
||||
{
|
||||
// happens when mods add recipe to the registry without updating recipe manager
|
||||
return List.of();
|
||||
}
|
||||
Collection<RecipeHolder<?>> typeRecipes = byType.get(type);
|
||||
Registry<Item> regs = registryAccess.registryOrThrow(Registries.ITEM);
|
||||
Item item = regs.get(itemId);
|
||||
return typeRecipes.values()
|
||||
.stream()
|
||||
return typeRecipes.stream()
|
||||
.<Recipe<?>>map(RecipeHolder::value)
|
||||
.filter(r -> r.getResultItem(registryAccess).getItem() == item)
|
||||
.toList();
|
||||
|
||||
Reference in new issue
Block a user