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
|
# Fabric Properties
|
||||||
# check https://fabricmc.net/develop/
|
# check https://fabricmc.net/develop/
|
||||||
minecraft_version=1.20.5-pre1
|
minecraft_version=1.20.5-pre2
|
||||||
loader_version=0.15.9
|
loader_version=0.15.9
|
||||||
jsr305_version=3.0.2
|
jsr305_version=3.0.2
|
||||||
fabric_version=0.96.14+1.20.5
|
fabric_version=0.96.14+1.20.5
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package carpet.mixins;
|
package carpet.mixins;
|
||||||
|
|
||||||
import carpet.fakes.RecipeManagerInterface;
|
import carpet.fakes.RecipeManagerInterface;
|
||||||
|
import com.google.common.collect.Multimap;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.core.RegistryAccess;
|
import net.minecraft.core.RegistryAccess;
|
||||||
import net.minecraft.core.registries.Registries;
|
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.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
@@ -19,22 +21,28 @@ import net.minecraft.world.item.crafting.RecipeType;
|
|||||||
@Mixin(RecipeManager.class)
|
@Mixin(RecipeManager.class)
|
||||||
public class RecipeManager_scarpetMixin implements RecipeManagerInterface
|
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
|
@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);
|
// quiq cheq
|
||||||
// happens when mods add recipe to the registry without updating recipe manager
|
RecipeHolder<?> recipe = byName.get(itemId);
|
||||||
if (typeRecipes == null) return List.of();
|
if (recipe != null && recipe.value().getType().equals(type))
|
||||||
RecipeHolder<?> recipeFromMap = typeRecipes.get(itemId);
|
{
|
||||||
if (recipeFromMap != null)
|
return List.of(recipe.value());
|
||||||
return List.of(recipeFromMap.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);
|
Registry<Item> regs = registryAccess.registryOrThrow(Registries.ITEM);
|
||||||
Item item = regs.get(itemId);
|
Item item = regs.get(itemId);
|
||||||
return typeRecipes.values()
|
return typeRecipes.stream()
|
||||||
.stream()
|
|
||||||
.<Recipe<?>>map(RecipeHolder::value)
|
.<Recipe<?>>map(RecipeHolder::value)
|
||||||
.filter(r -> r.getResultItem(registryAccess).getItem() == item)
|
.filter(r -> r.getResultItem(registryAccess).getItem() == item)
|
||||||
.toList();
|
.toList();
|
||||||
|
|||||||
Reference in new issue
Block a user