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);
}
}
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);
}
}
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);
}
}
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();
}
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();
}
Aggregations