Search in sources :

Example 1 with IMixinPotion

use of org.spongepowered.common.interfaces.potion.IMixinPotion in project SpongeCommon by SpongePowered.

the class MixinPotion method onPotionRegister.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Redirect(method = "registerPotions", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/registry/RegistryNamespaced;register(ILjava/lang/Object;Ljava/lang/Object;)V"))
private static void onPotionRegister(RegistryNamespaced registry, int id, Object location, Object potion) {
    final ResourceLocation resource = (ResourceLocation) location;
    final Potion mcPotion = (Potion) potion;
    ((IMixinPotion) mcPotion).setId(resource.toString().toLowerCase(Locale.ENGLISH));
    PotionEffectTypeRegistryModule.getInstance().registerFromGameData(resource.toString(), (PotionEffectType) mcPotion);
    registry.register(id, location, potion);
}
Also used : IMixinPotion(org.spongepowered.common.interfaces.potion.IMixinPotion) Potion(net.minecraft.potion.Potion) ResourceLocation(net.minecraft.util.ResourceLocation) IMixinPotion(org.spongepowered.common.interfaces.potion.IMixinPotion) Redirect(org.spongepowered.asm.mixin.injection.Redirect)

Aggregations

Potion (net.minecraft.potion.Potion)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 Redirect (org.spongepowered.asm.mixin.injection.Redirect)1 IMixinPotion (org.spongepowered.common.interfaces.potion.IMixinPotion)1