Search in sources :

Example 16 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project Witchworks by Um-Mitternacht.

the class CommonRegistration method registerItems.

@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event) {
    final IForgeRegistry<Item> registry = event.getRegistry();
    //Crops
    registerCrop(ACONITUM, new ItemAconitum(), LibItemName.SEED_ACONITUM);
    registerCrop(ASPHODEL, new ItemAsphodel(), LibItemName.SEED_ASPHODEL);
    registerCrop(BELLADONNA, new ItemBelladonna(), LibItemName.SEED_BELLADONNA);
    registerCrop(GINGER, new ItemGinger(), LibItemName.SEED_GINGER);
    registerCrop(KELP, new ItemKelp(), new ItemKelpSeed());
    registerCrop(MINT, new ItemCrop(LibItemName.MINT, 1, 2F, false), LibItemName.SEED_MINT);
    registerCrop(WHITE_SAGE, new ItemCrop(LibItemName.WHITE_SAGE, 1, 0.4F, false), LibItemName.SEED_WHITE_SAGE);
    registerCrop(MANDRAKE, new ItemCrop(LibItemName.MANDRAKE, 4, 6F, false), LibItemName.SEED_MANDRAKE);
    registerCrop(LAVENDER, new ItemLavender(), LibItemName.SEED_LAVENDER);
    registerCrop(THISTLE, new ItemThistle(), LibItemName.SEED_THISTLE);
    registerCrop(TULSI, new ItemCrop(LibItemName.TULSI, 1, 0.4F, false), LibItemName.SEED_TULSI);
    registerCrop(KENAF, new ItemCrop(LibItemName.KENAF, 4, 6F, false), LibItemName.SEED_KENAF);
    registerCrop(SILPHIUM, new ItemCrop(LibItemName.SILPHIUM, 4, 6F, false), LibItemName.SEED_SILPHIUM);
    registerCrop(GARLIC, new ItemCrop(LibItemName.GARLIC, 4, 6F, false), LibItemName.SEED_GARLIC);
    registerCrop(WORMWOOD, new ItemCrop(LibItemName.WORMWOOD, 4, 0.8F, false), LibItemName.SEED_WORMWOOD);
    CropRegistry.getFoods().forEach((crop, item) -> registry.register(item));
    CropRegistry.getSeeds().forEach((crop, item) -> registry.register(item));
    //Normal Items
    registry.registerAll(//Gems
    new ItemMod(LibItemName.GARNET), new ItemMod(LibItemName.MOLDAVITE), new ItemMod(LibItemName.NUUMMITE), new ItemMod(LibItemName.TIGERS_EYE), new ItemMod(LibItemName.TOURMALINE), new ItemMod(LibItemName.BLOODSTONE), new ItemMod(LibItemName.JASPER), new ItemMod(LibItemName.GEMSTONE_AMALGAM), new ItemMod(LibItemName.MALACHITE), new ItemMod(LibItemName.AMETHYST), new ItemMod(LibItemName.ALEXANDRITE), new ItemMod(LibItemName.SILVER_POWDER), new ItemMod(LibItemName.SILVER_INGOT), new ItemMod(LibItemName.SILVER_NUGGET), //Other
    new ItemHoney(), new ItemSalt(), new ItemMod(LibItemName.WAX), new ItemMod(LibItemName.BEE).setMaxDamage(35), new ItemMod(LibItemName.HONEYCOMB), new ItemMod(LibItemName.EMPTY_HONEYCOMB), new ItemMod(LibItemName.MORTAR_AND_PESTLE), new ItemMod(LibItemName.UNREFINED_CHALK), new ItemBrewDrink(), new ItemBrewSplash(), new ItemBrewLinger(), new ItemMod(LibItemName.GLASS_JAR), //Tools
    new ItemSilverPickaxe(), new ItemSilverAxe(), new ItemSilverSpade(), new ItemSilverHoe(), new ItemSilverSword(), new ItemAthame(), new ItemBoline(), new ItemTaglock(), new ItemMod(LibItemName.CHALK_ITEM), new ItemMod(LibItemName.NEEDLE_BONE), //Books
    new ItemShadowBook(), new ItemDustyGrimoire(), //Equipment
    new ItemSilverArmor(LibItemName.SILVER_HELMET, ModMaterials.ARMOR_SILVER, 1, EntityEquipmentSlot.HEAD), new ItemSilverArmor(LibItemName.SILVER_CHESTPLATE, ModMaterials.ARMOR_SILVER, 1, EntityEquipmentSlot.CHEST), new ItemSilverArmor(LibItemName.SILVER_LEGGINGS, ModMaterials.ARMOR_SILVER, 2, EntityEquipmentSlot.LEGS), new ItemSilverArmor(LibItemName.SILVER_BOOTS, ModMaterials.ARMOR_SILVER, 1, EntityEquipmentSlot.FEET));
    //Item Blocks
    registry.registerAll(itemBlock(ModBlocks.CROP_ACONITUM), itemBlock(ModBlocks.CROP_ASPHODEL), itemBlock(ModBlocks.CROP_BELLADONNA), itemBlock(ModBlocks.CROP_GINGER), itemBlock(ModBlocks.CROP_KELP), itemBlock(ModBlocks.CROP_MINT), itemBlock(ModBlocks.CROP_SILPHIUM), itemBlock(ModBlocks.CROP_WHITE_SAGE), itemBlock(ModBlocks.CROP_MANDRAKE), itemBlock(ModBlocks.CROP_LAVENDER), itemBlock(ModBlocks.CROP_THISTLE), itemBlock(ModBlocks.CROP_TULSI), itemBlock(ModBlocks.CROP_KENAF), itemBlock(ModBlocks.CROP_GARLIC), itemBlock(ModBlocks.CROP_WORMWOOD), itemBlock(ModBlocks.SILVER_BLOCK), itemBlock(ModBlocks.MOLDAVITE_BLOCK), itemBlock(ModBlocks.COQUINA), itemBlock(ModBlocks.BLOODSTONE_BLOCK), itemBlock(ModBlocks.KETTLE), itemBlock(ModBlocks.ALTAR), itemBlock(ModBlocks.APIARY), itemBlock(ModBlocks.BEEHIVE), itemBlock(ModBlocks.SILVER_ORE), itemBlock(ModBlocks.MOLDAVITE_ORE), itemBlock(ModBlocks.MALACHITE_ORE), itemBlock(ModBlocks.BLOODSTONE_ORE), itemBlock(ModBlocks.TIGERS_EYE_ORE), itemBlock(ModBlocks.NUUMMITE_ORE), itemBlock(ModBlocks.JASPER_ORE), itemBlock(ModBlocks.GARNET_ORE), itemBlock(ModBlocks.TOURMALINE_ORE), itemBlock(ModBlocks.TOURMALINE_BLOCK), itemBlock(ModBlocks.SALT_ORE), itemBlock(ModBlocks.AMETHYST_ORE), itemBlock(ModBlocks.ALEXANDRITE_ORE), itemBlock(ModBlocks.NETHERSTEEL), new ItemBlockColor(ModBlocks.CANDLE_LARGE), new ItemBlockColor(ModBlocks.CANDLE_MEDIUM), new ItemBlockColor(ModBlocks.CANDLE_SMALL), itemBlock(ModBlocks.SALT_BARRIER), itemBlock(ModBlocks.CHALK));
    for (final IFluidBlock fluidBlock : Fluids.MOD_FLUID_BLOCKS) {
        registry.register(itemBlock((Block) fluidBlock));
    }
}
Also used : ItemSilverArmor(com.witchworks.common.item.equipment.ItemSilverArmor) ItemBrewSplash(com.witchworks.common.item.magic.brew.ItemBrewSplash) Item(net.minecraft.item.Item) ItemKelpSeed(com.witchworks.common.item.food.seed.ItemKelpSeed) ItemMod(com.witchworks.common.item.ItemMod) ItemBrewDrink(com.witchworks.common.item.magic.brew.ItemBrewDrink) ItemBrewLinger(com.witchworks.common.item.magic.brew.ItemBrewLinger) ItemTaglock(com.witchworks.common.item.magic.ItemTaglock) ItemSalt(com.witchworks.common.item.block.ItemSalt) ItemDustyGrimoire(com.witchworks.common.item.magic.books.ItemDustyGrimoire) ItemBlockColor(com.witchworks.common.item.block.ItemBlockColor) ItemShadowBook(com.witchworks.common.item.magic.books.ItemShadowBook) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) Block(net.minecraft.block.Block) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) ItemBlock(net.minecraft.item.ItemBlock) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 17 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project Witchworks by Um-Mitternacht.

the class BrewEvents method onWorldJoin.

@SubscribeEvent
public void onWorldJoin(EntityJoinWorldEvent event) {
    if (event.getEntity() instanceof EntityPlayerMP) {
        EntityPlayerMP entity = (EntityPlayerMP) event.getEntity();
        Optional<IBrewStorage> optional = BrewStorageHandler.getBrewStorage(entity);
        if (optional.isPresent()) {
            PacketHandler.sendTo(entity, new PotionMessage(optional.get().getBrews().keySet(), entity.getUniqueID()));
        }
    }
}
Also used : IBrewStorage(com.witchworks.common.core.capability.potion.IBrewStorage) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) PotionMessage(com.witchworks.common.core.net.PotionMessage) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 18 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project Witchworks by Um-Mitternacht.

the class BrewEvents method onPlayerClone.

@SuppressWarnings("ConstantConditions")
@SubscribeEvent
public void onPlayerClone(net.minecraftforge.event.entity.player.PlayerEvent.Clone event) {
    final EntityPlayer oldPlayer = event.getOriginal();
    final EntityPlayer newPlayer = event.getEntityPlayer();
    if (event.isWasDeath() && oldPlayer.hasCapability(BrewStorageProvider.BREW_STORAGE_CAPABILITY, null) && newPlayer.hasCapability(BrewStorageProvider.BREW_STORAGE_CAPABILITY, null)) {
        final IBrewStorage oldCap = oldPlayer.getCapability(BrewStorageProvider.BREW_STORAGE_CAPABILITY, null);
        final IBrewStorage newCap = oldPlayer.getCapability(BrewStorageProvider.BREW_STORAGE_CAPABILITY, null);
        newCap.setBrews(oldCap.getBrews());
    }
}
Also used : IBrewStorage(com.witchworks.common.core.capability.potion.IBrewStorage) EntityPlayer(net.minecraft.entity.player.EntityPlayer) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 19 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project Witchworks by Um-Mitternacht.

the class EnergyEvents method onPlayerClone.

@SuppressWarnings("ConstantConditions")
@SubscribeEvent
public void onPlayerClone(net.minecraftforge.event.entity.player.PlayerEvent.Clone event) {
    final EntityPlayer oldPlayer = event.getOriginal();
    final EntityPlayer newPlayer = event.getEntityPlayer();
    if (event.isWasDeath() && oldPlayer.hasCapability(EnergyProvider.ENERGY_CAPABILITY, null) && newPlayer.hasCapability(EnergyProvider.ENERGY_CAPABILITY, null)) {
        final IEnergy oldCap = oldPlayer.getCapability(EnergyProvider.ENERGY_CAPABILITY, null);
        final IEnergy newCap = oldPlayer.getCapability(EnergyProvider.ENERGY_CAPABILITY, null);
        newCap.set(oldCap.get());
        newCap.setMax(oldCap.getMax());
        newCap.setRegen(oldCap.getRegen());
        newCap.setUses(oldCap.getUses());
    }
}
Also used : IEnergy(com.witchworks.common.core.capability.energy.IEnergy) EntityPlayer(net.minecraft.entity.player.EntityPlayer) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 20 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project Witchworks by Um-Mitternacht.

the class EnergyEvents method onWorldJoin.

@SubscribeEvent
public void onWorldJoin(EntityJoinWorldEvent event) {
    if (event.getEntity() instanceof EntityPlayerMP) {
        EntityPlayerMP entity = (EntityPlayerMP) event.getEntity();
        Optional<IEnergy> optional = EnergyHandler.getEnergy(entity);
        if (optional.isPresent()) {
            PacketHandler.sendTo(entity, new EnergyMessage(optional.get(), entity.getUniqueID()));
        }
    }
}
Also used : EnergyMessage(com.witchworks.common.core.net.EnergyMessage) IEnergy(com.witchworks.common.core.capability.energy.IEnergy) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1135 ItemStack (net.minecraft.item.ItemStack)316 EntityPlayer (net.minecraft.entity.player.EntityPlayer)314 World (net.minecraft.world.World)196 BlockPos (net.minecraft.util.math.BlockPos)179 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)136 IBlockState (net.minecraft.block.state.IBlockState)120 ResourceLocation (net.minecraft.util.ResourceLocation)102 Entity (net.minecraft.entity.Entity)93 Block (net.minecraft.block.Block)86 EntityLivingBase (net.minecraft.entity.EntityLivingBase)84 Minecraft (net.minecraft.client.Minecraft)72 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)66 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)64 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)55 Item (net.minecraft.item.Item)53 EntityItem (net.minecraft.entity.item.EntityItem)48 TileEntity (net.minecraft.tileentity.TileEntity)46 TextComponentString (net.minecraft.util.text.TextComponentString)42 Random (java.util.Random)37