refactor limit access to built-in registries
This commit is contained in:
1 parent
8dd08d5cb1
commit
bd5dfdbf9f
25 files changed
+243
-176
No files matched your search
@@ -80,7 +80,7 @@ public abstract class Explosion_optimizedTntMixin
|
||||
{
|
||||
if (LoggerRegistry.__explosions && ! world.isClientSide)
|
||||
{
|
||||
eLogger = new ExplosionLogHelper(x, y, z, power, createFire, destructionType);
|
||||
eLogger = new ExplosionLogHelper(x, y, z, power, createFire, destructionType, level.registryAccess());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,11 @@ package carpet.mixins;
|
||||
|
||||
import carpet.fakes.RecipeManagerInterface;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.world.item.Item;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@@ -22,13 +26,14 @@ public class RecipeManager_scarpetMixin implements RecipeManagerInterface
|
||||
@Shadow private Map<RecipeType<?>, Map<ResourceLocation, Recipe<?>>> recipes;
|
||||
|
||||
@Override
|
||||
public List<Recipe<?>> getAllMatching(RecipeType<?> type, ResourceLocation output)
|
||||
public List<Recipe<?>> getAllMatching(RecipeType<?> type, ResourceLocation output, final RegistryAccess registryAccess)
|
||||
{
|
||||
Map<ResourceLocation, Recipe<?>> typeRecipes = recipes.get(type);
|
||||
// happens when mods add recipe to the registry without updating recipe manager
|
||||
if (typeRecipes == null) return Collections.emptyList();
|
||||
if (typeRecipes.containsKey(output)) return Collections.singletonList(typeRecipes.get(output));
|
||||
final Registry<Item> regs = registryAccess.registryOrThrow(Registries.ITEM);
|
||||
return Lists.newArrayList(typeRecipes.values().stream().filter(
|
||||
r -> BuiltInRegistries.ITEM.getKey(r.getResultItem().getItem()).equals(output)).collect(Collectors.toList()));
|
||||
r -> regs.getKey(r.getResultItem().getItem()).equals(output)).collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user