Unicopia/src/main/java/com/minelittlepony/unicopia/WorldConvertable.java
2024-09-28 22:27:46 +01:00

23 lines
593 B
Java

package com.minelittlepony.unicopia;
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();
/**
* Returns true if we're executing on the client.
*/
default boolean isClient() {
return asWorld().isClient();
}
default <T> RegistryEntry<T> entryFor(RegistryKey<T> key) {
return asWorld().getRegistryManager().get(key.getRegistryRef()).getEntry(key).orElseThrow();
}
}