Search in sources :

Example 1 with ModEntityMob

use of com.bewitchment.common.entity.util.ModEntityMob in project Bewitchment by Um-Mitternacht.

the class ItemBoxSealedEvil method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer player, EnumHand handIn) {
    Random rand = itemRand;
    if (!player.isSneaking() && !worldIn.isRemote) {
        switch(rand.nextInt(26)) {
            case 0:
                LootTable table = worldIn.getLootTableManager().getLootTableFromLocation(LootTableList.CHESTS_DESERT_PYRAMID);
                LootContext ctx = new LootContext.Builder((WorldServer) worldIn).withLuck(player.getLuck()).build();
                List<ItemStack> stacks = table.generateLootForPools(rand, ctx);
                for (ItemStack stack : stacks) Util.giveItem(player, stack);
                break;
            case 1:
                ItemStack bauble = getRandomBauble(rand);
                Util.giveItem(player, bauble);
                break;
            case 2:
                player.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, 24000, 1));
                player.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 24000, 0));
                break;
            case 3:
                player.addPotionEffect(new PotionEffect(MobEffects.SPEED, 24000, 1));
                player.addPotionEffect(new PotionEffect(MobEffects.JUMP_BOOST, 24000, 0));
                break;
            case 4:
                List<Block> ores = ForgeRegistries.BLOCKS.getValuesCollection().stream().filter(b -> b instanceof BlockOre).collect(Collectors.toList());
                for (Block ore : ores) InventoryHelper.spawnItemStack(worldIn, player.posX, player.posY + 0.5, player.posZ, new ItemStack(ore));
                break;
            case 5:
                Util.giveItem(player, new ItemStack(Items.NETHER_STAR));
                break;
            case 6:
                int amount = rand.nextInt(10) + 10;
                for (int i = 0; i < amount; i++) {
                    Entity bat = ForgeRegistries.ENTITIES.getValue(new ResourceLocation("minecraft", "bat")).newInstance(worldIn);
                    bat.setPosition(player.posX + rand.nextGaussian(), player.posY + 1, player.posZ + rand.nextGaussian());
                    worldIn.spawnEntity(bat);
                }
                for (int i = 0; i < amount - 10; i++) {
                    Entity raven = ModEntities.raven.newInstance(worldIn);
                    raven.setPosition(player.posX + rand.nextGaussian(), player.posY + 1, player.posZ + rand.nextGaussian());
                    worldIn.spawnEntity(raven);
                }
                break;
            case 7:
                Util.giveItem(player, new ItemStack(ModObjects.bottle_of_blood));
                Util.giveItem(player, new ItemStack(ModObjects.heart));
                Util.giveItem(player, Util.getRandomContract(rand));
                Util.giveItem(player, new ItemStack(Items.SKULL, 1, rand.nextInt(6)));
                break;
            case 8:
                final String[] demons = { "leonard", "baphomet", "lilith", "herne", "moloch" };
                String demon = demons[rand.nextInt(demons.length)];
                String mat = rand.nextBoolean() ? "nether_brick" : "scorned_brick";
                Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(Bewitchment.MODID, mat + "_" + demon + "_statue"));
                if (item != null)
                    Util.giveItem(player, new ItemStack(item));
                else
                    Util.giveItem(player, new ItemStack(ModObjects.nether_brick_leonard_statue));
                break;
            case 9:
                Util.giveItem(player, new ItemStack(ModObjects.stew_of_the_grotesque));
                Util.giveItem(player, new ItemStack(Items.CHICKEN, rand.nextInt(64) + 1));
                Util.giveItem(player, new ItemStack(Items.MUTTON, rand.nextInt(64) + 1));
                break;
            case 10:
                Util.giveItem(player, new ItemStack(ModObjects.embergrass));
                Util.giveItem(player, new ItemStack(ModObjects.blue_ink_cap));
                Util.giveItem(player, new ItemStack(ModObjects.spanish_moss));
                String[] type = { "allium", "azure_bluet", "blue_orchid", "dandelion", "oxeye_daisy", "poppy", "tulip_orange", "tulip_pink", "tulip_red", "tulip_white" };
                Block flower = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(Bewitchment.MODID, "flower_siphoning_" + type[rand.nextInt(10)]));
                if (flower != null)
                    Util.giveItem(player, new ItemStack(flower));
                else
                    Util.giveItem(player, new ItemStack(ModObjects.flower_siphoning_poppy));
                Util.giveItem(player, new ItemStack(ModObjects.dragons_blood_sapling));
                break;
            case 11:
                Util.giveItem(player, new ItemStack(Items.GHAST_TEAR, rand.nextInt(2) + 1));
                Util.giveItem(player, new ItemStack(Items.BLAZE_ROD, rand.nextInt(2) + 1));
                Util.giveItem(player, new ItemStack(ModObjects.hellhound_horn, rand.nextInt(2) + 1));
                Util.giveItem(player, new ItemStack(ModObjects.demon_heart, rand.nextInt(2) + 1));
                break;
            case 12:
                int random0 = rand.nextInt(3) + 1;
                for (int i = 0; i < random0; i++) {
                    ModEntityMob temp = (ModEntityMob) ModEntities.feuerwurm.newInstance(worldIn);
                    temp.getDataManager().set(ModEntityMob.SPECTRAL, true);
                    temp.lifeTimeTicks = 1200;
                    temp.setAttackTarget(player);
                    temp.setPosition(player.posX + rand.nextGaussian() * 2, player.posY + 0.5, player.posZ + rand.nextGaussian() * 2);
                    worldIn.spawnEntity(temp);
                }
                break;
            case 13:
                int random1 = rand.nextInt(3) + 1;
                for (int i = 0; i < random1; i++) {
                    ModEntityMob temp = (ModEntityMob) ModEntities.hellhound.newInstance(worldIn);
                    temp.setAttackTarget(player);
                    temp.setPosition(player.posX + rand.nextGaussian() * 2, player.posY + 0.5, player.posZ + rand.nextGaussian() * 2);
                    worldIn.spawnEntity(temp);
                }
                break;
            case 14:
                WorldInfo info = worldIn.getWorldInfo();
                int weatherTime = (300 + (new Random()).nextInt(600)) * 20;
                info.setCleanWeatherTime(0);
                info.setRainTime(weatherTime);
                info.setThunderTime(weatherTime);
                info.setRaining(true);
                info.setThundering(true);
                break;
            case 15:
                worldIn.setWorldTime(worldIn.getWorldTime() + (41600 - (worldIn.getWorldTime() % 24000)) % 24000);
                break;
            case 16:
                int random2 = rand.nextInt(3) + 1;
                for (int i = 0; i < random2; i++) {
                    ModEntityMob temp = (ModEntityMob) ModEntities.shadow_person.newInstance(worldIn);
                    temp.setAttackTarget(player);
                    temp.setPosition(player.posX + rand.nextGaussian() * 2, player.posY + 0.5, player.posZ + rand.nextGaussian() * 2);
                    worldIn.spawnEntity(temp);
                }
                break;
            case 17:
                int random3 = rand.nextInt(3) + 1;
                for (int i = 0; i < random3; i++) {
                    ModEntityMob temp = (ModEntityMob) ModEntities.ghost.newInstance(worldIn);
                    temp.setAttackTarget(player);
                    temp.setPosition(player.posX + rand.nextGaussian() * 2, player.posY + 0.5, player.posZ + rand.nextGaussian() * 2);
                    worldIn.spawnEntity(temp);
                }
                break;
            case 18:
                int random4 = rand.nextInt(2) + 1;
                for (int i = 0; i < random4; i++) {
                    ModEntityMob temp = (ModEntityMob) ModEntities.druden.newInstance(worldIn);
                    temp.setAttackTarget(player);
                    temp.setPosition(player.posX + rand.nextGaussian() * 2, player.posY + 0.5, player.posZ + rand.nextGaussian() * 2);
                    worldIn.spawnEntity(temp);
                }
                break;
            case 19:
                player.addPotionEffect(new PotionEffect(MobEffects.POISON, 1200));
                player.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, 24000));
                break;
            case 20:
                player.addPotionEffect(new PotionEffect(MobEffects.WITHER, 800));
                break;
            case 21:
                player.addPotionEffect(new PotionEffect(ModPotions.hellfire, 24000));
                // add insanity here
                break;
            case 22:
                worldIn.addWeatherEffect(new EntityLightningBolt(player.world, player.posX, player.posY, player.posZ, true));
                break;
            case 23:
                int random6 = rand.nextInt(2) + 1;
                for (int i = 0; i < random6; i++) {
                    ModEntityMob temp = (ModEntityMob) ModEntities.bafometyr.newInstance(worldIn);
                    temp.setAttackTarget(player);
                    temp.setPosition(player.posX + rand.nextGaussian() * 2, player.posY + 0.5, player.posZ + rand.nextGaussian() * 2);
                    worldIn.spawnEntity(temp);
                }
                break;
            case 24:
                int random7 = rand.nextInt(2) + 1;
                for (int i = 0; i < random7; i++) {
                    ModEntityMob temp = (ModEntityMob) ModEntities.cleaver.newInstance(worldIn);
                    temp.setAttackTarget(player);
                    temp.setPosition(player.posX + rand.nextGaussian() * 2, player.posY + 0.5, player.posZ + rand.nextGaussian() * 2);
                    worldIn.spawnEntity(temp);
                }
                break;
            default:
                for (BlockPos pos1 : BlockPos.getAllInBoxMutable(player.getPosition().add(-1, 0, -1), player.getPosition().add(1, 2, 1))) {
                    if (worldIn.getBlockState(pos1).getBlock().isReplaceable(worldIn, pos1)) {
                        worldIn.setBlockState(pos1, Blocks.WEB.getDefaultState());
                    }
                }
                int random5 = rand.nextInt(4) + 1;
                for (int i = 0; i < random5; i++) {
                    Entity spider = ForgeRegistries.ENTITIES.getValue(new ResourceLocation("minecraft", "cave_spider")).newInstance(worldIn);
                    spider.setPosition(player.posX + rand.nextGaussian() * 2, player.posY + 0.5, player.posZ + rand.nextGaussian() * 2);
                    worldIn.spawnEntity(spider);
                }
                for (int i = 0; i < random5; i++) {
                    Entity silver_fish = ForgeRegistries.ENTITIES.getValue(new ResourceLocation("minecraft", "silverfish")).newInstance(worldIn);
                    silver_fish.setPosition(player.posX + rand.nextGaussian() * 2, player.posY + 0.5, player.posZ + rand.nextGaussian() * 2);
                    worldIn.spawnEntity(silver_fish);
                }
                break;
        }
        player.inventory.decrStackSize(player.inventory.currentItem, 1);
    }
    if (worldIn.isRemote)
        worldIn.playSound(player, player.getPosition(), SoundEvents.ENTITY_ILLAGER_CAST_SPELL, SoundCategory.PLAYERS, 5, 1);
    return super.onItemRightClick(worldIn, player, handIn);
}
Also used : LootTable(net.minecraft.world.storage.loot.LootTable) WorldInfo(net.minecraft.world.storage.WorldInfo) ModItemBauble(com.bewitchment.common.item.util.ModItemBauble) Blocks(net.minecraft.init.Blocks) ModObjects(com.bewitchment.registry.ModObjects) Item(net.minecraft.item.Item) ModPotions(com.bewitchment.registry.ModPotions) EnumHand(net.minecraft.util.EnumHand) LootContext(net.minecraft.world.storage.loot.LootContext) Random(java.util.Random) ItemStack(net.minecraft.item.ItemStack) PotionEffect(net.minecraft.potion.PotionEffect) Block(net.minecraft.block.Block) Bewitchment(com.bewitchment.Bewitchment) SoundCategory(net.minecraft.util.SoundCategory) WorldServer(net.minecraft.world.WorldServer) BlockOre(net.minecraft.block.BlockOre) Entity(net.minecraft.entity.Entity) SoundEvents(net.minecraft.init.SoundEvents) LootTableList(net.minecraft.world.storage.loot.LootTableList) Items(net.minecraft.init.Items) InventoryHelper(net.minecraft.inventory.InventoryHelper) World(net.minecraft.world.World) ModEntities(com.bewitchment.registry.ModEntities) BlockPos(net.minecraft.util.math.BlockPos) Collectors(java.util.stream.Collectors) ModEntityMob(com.bewitchment.common.entity.util.ModEntityMob) ActionResult(net.minecraft.util.ActionResult) List(java.util.List) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ForgeRegistries(net.minecraftforge.fml.common.registry.ForgeRegistries) ResourceLocation(net.minecraft.util.ResourceLocation) Util(com.bewitchment.Util) LootTable(net.minecraft.world.storage.loot.LootTable) MobEffects(net.minecraft.init.MobEffects) Entity(net.minecraft.entity.Entity) PotionEffect(net.minecraft.potion.PotionEffect) LootContext(net.minecraft.world.storage.loot.LootContext) BlockOre(net.minecraft.block.BlockOre) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt) ModEntityMob(com.bewitchment.common.entity.util.ModEntityMob) Item(net.minecraft.item.Item) Random(java.util.Random) ResourceLocation(net.minecraft.util.ResourceLocation) Block(net.minecraft.block.Block) WorldInfo(net.minecraft.world.storage.WorldInfo) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack)

Aggregations

Bewitchment (com.bewitchment.Bewitchment)1 Util (com.bewitchment.Util)1 ModEntityMob (com.bewitchment.common.entity.util.ModEntityMob)1 ModItemBauble (com.bewitchment.common.item.util.ModItemBauble)1 ModEntities (com.bewitchment.registry.ModEntities)1 ModObjects (com.bewitchment.registry.ModObjects)1 ModPotions (com.bewitchment.registry.ModPotions)1 List (java.util.List)1 Random (java.util.Random)1 Collectors (java.util.stream.Collectors)1 Block (net.minecraft.block.Block)1 BlockOre (net.minecraft.block.BlockOre)1 Entity (net.minecraft.entity.Entity)1 EntityLightningBolt (net.minecraft.entity.effect.EntityLightningBolt)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 Blocks (net.minecraft.init.Blocks)1 Items (net.minecraft.init.Items)1 MobEffects (net.minecraft.init.MobEffects)1 SoundEvents (net.minecraft.init.SoundEvents)1 InventoryHelper (net.minecraft.inventory.InventoryHelper)1