Search in sources :

Example 1 with DifficultyInstance

use of net.minecraft.world.DifficultyInstance in project Railcraft by Railcraft.

the class EntityAIHalloweenKnights method updateTask.

/**
     * Updates the task
     */
@Override
public void updateTask() {
    executed = true;
    DifficultyInstance difficultyinstance = horse.worldObj.getDifficultyForLocation(new BlockPos(horse));
    horse.setType(HorseType.SKELETON);
    horse.setHorseTamed(true);
    horse.setGrowingAge(0);
    horse.worldObj.addWeatherEffect(new EntityLightningBolt(horse.worldObj, horse.posX, horse.posY, horse.posZ, true));
    EntitySkeleton entityskeleton = createSkeleton(difficultyinstance, horse);
    entityskeleton.startRiding(horse);
    for (int i = 0; i < 3; ++i) {
        EntityHorse entityhorse = createHorse(difficultyinstance);
        EntitySkeleton skeleton = createSkeleton(difficultyinstance, entityhorse);
        skeleton.startRiding(entityhorse);
        entityhorse.addVelocity(horse.getRNG().nextGaussian() * 0.5D, 0.0D, horse.getRNG().nextGaussian() * 0.5D);
    }
}
Also used : EntityHorse(net.minecraft.entity.passive.EntityHorse) DifficultyInstance(net.minecraft.world.DifficultyInstance) EntitySkeleton(net.minecraft.entity.monster.EntitySkeleton) BlockPos(net.minecraft.util.math.BlockPos) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt)

Example 2 with DifficultyInstance

use of net.minecraft.world.DifficultyInstance in project SilentGems by SilentChaos512.

the class ModuleEntityRandomEquipment method tryGiveMobEquipment.

public static void tryGiveMobEquipment(EntityLivingBase entity) {
    if (!MODULE_ENABLED || entity.world.isRemote || !(entity instanceof EntityMob))
        return;
    EnumDifficulty worldDiff = entity.world.getDifficulty();
    DifficultyInstance localDiff = entity.world.getDifficultyForLocation(entity.getPosition());
    Random rand = SilentGems.random;
    ItemStack sword = null;
    // chances of spawning with equipment.
    if (entity instanceof EntityZombie) {
        if (selectBasedOnDifficulty(SWORD_MULTI_ZOMBIE * SWORD_CHANCE, worldDiff, localDiff, rand))
            sword = generateRandomMeleeWeapon(entity, rand);
    } else if (entity instanceof EntitySkeleton) {
        if (selectBasedOnDifficulty(SWORD_MULTI_SKELETON * SWORD_CHANCE, worldDiff, localDiff, rand))
            sword = generateRandomMeleeWeapon(entity, rand);
    }
    /*else if (EntityList.NAME_TO_CLASS.get("headcrumbs.Human") == entity.getClass()) {
      if (selectBasedOnDifficulty(SWORD_MULTI_HUMAN * SWORD_CHANCE, worldDiff, localDiff, rand)) {
        // A little easter egg...
        if (entity.getName().equals(Names.SILENT_CHAOS_512)) {
          sword = SILENT_KATANA.copy();
          sword.setStackDisplayName("Silent's Creatively Named Katana");
        } else {
          sword = generateRandomMeleeWeapon(entity, rand);
        }
      }
    }*/
    // FIXME
    ItemStack currentMain = entity.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND);
    if (StackHelper.isValid(sword) && (StackHelper.isEmpty(currentMain) || !currentMain.hasTagCompound())) {
        String makerName = SilentGems.localizationHelper.getMiscText("Tooltip.OriginalOwner.Mob", entity.getName());
        ToolHelper.setOriginalOwner(sword, makerName);
        entity.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, sword);
        if (entity instanceof EntityLiving)
            ((EntityLiving) entity).setDropChance(EntityEquipmentSlot.MAINHAND, EQUIPMENT_DROP_CHANCE);
    }
}
Also used : EntityMob(net.minecraft.entity.monster.EntityMob) Random(java.util.Random) EntityLiving(net.minecraft.entity.EntityLiving) EntityZombie(net.minecraft.entity.monster.EntityZombie) DifficultyInstance(net.minecraft.world.DifficultyInstance) EntitySkeleton(net.minecraft.entity.monster.EntitySkeleton) ItemStack(net.minecraft.item.ItemStack) EnumDifficulty(net.minecraft.world.EnumDifficulty)

Example 3 with DifficultyInstance

use of net.minecraft.world.DifficultyInstance in project Railcraft by Railcraft.

the class EntityAIHalloweenKnights method updateTask.

/**
 * Updates the task
 */
@Override
public void updateTask() {
    executed = true;
    DifficultyInstance difficultyinstance = horse.world.getDifficultyForLocation(new BlockPos(horse));
    horse.setHorseTamed(true);
    horse.setGrowingAge(0);
    horse.world.addWeatherEffect(new EntityLightningBolt(horse.world, horse.posX, horse.posY, horse.posZ, true));
    EntitySkeleton entityskeleton = createSkeleton(difficultyinstance, horse);
    entityskeleton.startRiding(horse);
    for (int i = 0; i < 3; ++i) {
        EntitySkeletonHorse createdHorse = createHorse(difficultyinstance);
        EntitySkeleton skeleton = createSkeleton(difficultyinstance, createdHorse);
        skeleton.startRiding(createdHorse);
        createdHorse.addVelocity(horse.getRNG().nextGaussian() * 0.5D, 0.0D, horse.getRNG().nextGaussian() * 0.5D);
    }
}
Also used : DifficultyInstance(net.minecraft.world.DifficultyInstance) EntitySkeleton(net.minecraft.entity.monster.EntitySkeleton) EntitySkeletonHorse(net.minecraft.entity.passive.EntitySkeletonHorse) BlockPos(net.minecraft.util.math.BlockPos) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt)

Example 4 with DifficultyInstance

use of net.minecraft.world.DifficultyInstance in project Denizen-For-Bukkit by DenizenScript.

the class WorldHelperImpl method getLocalDifficulty.

@Override
public float getLocalDifficulty(Location location) {
    BlockPos pos = new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ());
    DifficultyInstance scaler = ((CraftWorld) location.getWorld()).getHandle().getCurrentDifficultyAt(pos);
    return scaler.getEffectiveDifficulty();
}
Also used : DifficultyInstance(net.minecraft.world.DifficultyInstance) BlockPos(net.minecraft.core.BlockPos)

Example 5 with DifficultyInstance

use of net.minecraft.world.DifficultyInstance in project Denizen-For-Bukkit by DenizenScript.

the class WorldHelperImpl method getLocalDifficulty.

@Override
public float getLocalDifficulty(Location location) {
    BlockPos pos = new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ());
    DifficultyInstance scaler = ((CraftWorld) location.getWorld()).getHandle().getCurrentDifficultyAt(pos);
    return scaler.getEffectiveDifficulty();
}
Also used : DifficultyInstance(net.minecraft.world.DifficultyInstance) BlockPos(net.minecraft.core.BlockPos)

Aggregations

DifficultyInstance (net.minecraft.world.DifficultyInstance)7 EntityLightningBolt (net.minecraft.entity.effect.EntityLightningBolt)3 EntitySkeleton (net.minecraft.entity.monster.EntitySkeleton)3 BlockPos (net.minecraft.util.math.BlockPos)3 BlockPos (net.minecraft.core.BlockPos)2 EntitySkeletonHorse (net.minecraft.entity.passive.EntitySkeletonHorse)2 ItemStack (net.minecraft.item.ItemStack)2 EnumDifficulty (net.minecraft.world.EnumDifficulty)2 Random (java.util.Random)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 EntityLiving (net.minecraft.entity.EntityLiving)1 EntityMob (net.minecraft.entity.monster.EntityMob)1 EntityZombie (net.minecraft.entity.monster.EntityZombie)1 EntityHorse (net.minecraft.entity.passive.EntityHorse)1 EnumSkyBlock (net.minecraft.world.EnumSkyBlock)1 World (net.minecraft.world.World)1 Chunk (net.minecraft.world.chunk.Chunk)1 ExtendedBlockStorage (net.minecraft.world.chunk.storage.ExtendedBlockStorage)1 ItemGemSword (net.silentchaos512.gems.item.tool.ItemGemSword)1