Unicopia/src/main/java/com/minelittlepony/unicopia/WorldConvertable.java

24 lines
593 B
Java
Raw Normal View History

package com.minelittlepony.unicopia;
2024-09-28 23:27:46 +02:00
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.world.World;
public interface WorldConvertable {
/**
* Gets the minecraft world
*/
World asWorld();
2022-12-19 19:50:15 +01:00
/**
* Returns true if we're executing on the client.
*/
default boolean isClient() {
return asWorld().isClient();
}
2024-09-28 23:27:46 +02:00
default <T> RegistryEntry<T> entryFor(RegistryKey<T> key) {
return asWorld().getRegistryManager().get(key.getRegistryRef()).getEntry(key).orElseThrow();
}
}