use of org.spongepowered.api.registry.util.DelayedRegistration in project SpongeCommon by SpongePowered.
the class RegistryModuleLoader method isDefaultProperPhase.
private static boolean isDefaultProperPhase(RegistryModule module) {
try {
Method method = module.getClass().getMethod("registerDefaults");
DelayedRegistration delay = method.getDeclaredAnnotation(DelayedRegistration.class);
if (delay == null) {
return SpongeImpl.getRegistry().getPhase() == RegistrationPhase.PRE_REGISTRY;
}
return SpongeImpl.getRegistry().getPhase() == delay.value();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
return false;
}
use of org.spongepowered.api.registry.util.DelayedRegistration in project LanternServer by LanternPowered.
the class LanternCraftingRecipeRegistryModule method registerDefaults.
@DelayedRegistration(RegistrationPhase.POST_INIT)
@Override
public void registerDefaults() {
try {
ReflectionHelper.setField(Ingredient.class.getField("NONE"), null, IIngredient.builder().with(ItemStack::isEmpty).withDisplay(ItemTypes.NONE).build());
} catch (Exception e) {
throw new RuntimeException(e);
}
PluginContainer plugin = Lantern.getMinecraftPlugin();
register(ICraftingRecipe.shapedBuilder().aisle("x", "x").where('x', Ingredient.of(ItemTypes.PLANKS)).result(ItemStack.of(ItemTypes.STICK, 4)).build("stick", plugin));
// Extra, testing stuff
plugin = Lantern.getImplementationPlugin();
ItemStack result = ItemStack.of(ItemTypes.GOLD_NUGGET, 4);
result.offer(Keys.DISPLAY_NAME, Text.of(TextColors.GOLD, "€1"));
register(ICraftingRecipe.shapedBuilder().aisle("x", "y").where('x', Ingredient.of(ItemTypes.GOLD_INGOT)).where('y', IIngredient.builder().with(ItemTypes.LAVA_BUCKET).withRemaining(ItemTypes.BUCKET).build()).result(result).build("one_euro", plugin));
// Two sticks?
register(ICraftingRecipe.shapelessBuilder().addIngredients(Ingredient.of(ItemTypes.STICK), 2).result(ItemStack.of(ItemTypes.STICK, 2)).build("two_sticks", plugin));
// Two buckets?
result = ItemStack.of(ItemTypes.LAVA_BUCKET, 1);
result.offer(Keys.DISPLAY_NAME, Text.of(TextColors.GOLD, "¿Compressed Lava?"));
register(ICraftingRecipe.shapelessBuilder().addIngredient(Ingredient.of(ItemTypes.LAVA_BUCKET)).addIngredient(IIngredient.builder().with(ItemTypes.LAVA_BUCKET).withRemaining(ItemTypes.BUCKET).build()).result(result).build("compressed_lava", plugin));
}
Aggregations