![JAR search and dependency download from the Maven repository](/logo.png)
dev.thomasglasser.sherdsapi.impl.mixin.DecoratedPotPatternsMixin Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sherdsapi-common-1.20.4 Show documentation
Show all versions of sherdsapi-common-1.20.4 Show documentation
Makes adding new pottery sherds easier
The newest version!
package dev.thomasglasser.sherdsapi.impl.mixin;
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import dev.thomasglasser.sherdsapi.impl.Sherd;
import dev.thomasglasser.sherdsapi.impl.SherdsApiRegistries;
import dev.thomasglasser.tommylib.api.client.ClientUtils;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.DecoratedPotPatterns;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@Mixin(DecoratedPotPatterns.class)
public class DecoratedPotPatternsMixin
{
@ModifyReturnValue(method = "getResourceKey", at = @At("RETURN"))
private static ResourceKey getResourceKey(ResourceKey original, Item item)
{
Level level = ClientUtils.getLevel();
if (original == null && level != null)
{
Registry registry = level.registryAccess().registry(SherdsApiRegistries.SHERD).orElseThrow();
for (Sherd sherd : registry.stream().toList())
{
if (sherd.ingredient().test(item.getDefaultInstance()))
{
if (sherd.pattern().isPresent())
{
return sherd.pattern().get();
}
else
{
return ResourceKey.create(Registries.DECORATED_POT_PATTERNS, registry.getResourceKey(sherd).orElseThrow().location());
}
}
}
}
return original;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy