net.minecraft.world.World.getDifficulty()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(121)

本文整理了Java中net.minecraft.world.World.getDifficulty()方法的一些代码示例,展示了World.getDifficulty()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。World.getDifficulty()方法的具体详情如下:
包路径:net.minecraft.world.World
类名称:World
方法名:getDifficulty

World.getDifficulty介绍

暂无

代码示例

代码示例来源:origin: SleepyTrousers/EnderIO

@Override
public @Nonnull EnumDifficulty getDifficulty() {
 return wrapped.getDifficulty();
}

代码示例来源:origin: Vazkii/Botania

dismountRidingEntity();
if(world.getDifficulty() == EnumDifficulty.PEACEFUL)
  setDead();

代码示例来源:origin: vadis365/TheErebus

public double getAttackStrength() {
  switch (getEntityWorld().getDifficulty()) {
    default:
      return 2.0D;
    case EASY:
      return 2.0D;
    case NORMAL:
      return 2.0D;
    case HARD:
      return 4.0D;
  }
}

代码示例来源:origin: Vazkii/Botania

public static boolean spawn(EntityPlayer player, ItemStack stack, World world, BlockPos pos, boolean hard) {
  if(world.getTileEntity(pos) instanceof TileEntityBeacon && isTruePlayer(player)) {
    if(world.getDifficulty() == EnumDifficulty.PEACEFUL) {
      if(!world.isRemote)
        player.sendMessage(new TextComponentTranslation("botaniamisc.peacefulNoob").setStyle(new Style().setColor(TextFormatting.RED)));

代码示例来源:origin: vadis365/TheErebus

public double getAttackStrength() {
  switch (getEntityWorld().getDifficulty()) {
    default:
      return 1.0D;
    case EASY:
      return 1.0D;
    case NORMAL:
      return 2.0D;
    case HARD:
      return 3.0D;
  }
}

代码示例来源:origin: Alex-the-666/Ice_and_Fire

public void onDeath(DamageSource cause) {
  if (cause.getTrueSource() != null && cause.getTrueSource() instanceof EntityZombie && (this.world.getDifficulty() == EnumDifficulty.NORMAL || this.world.getDifficulty() == EnumDifficulty.HARD)) {
    return;
  } else {
    super.onDeath(cause);
  }
}

代码示例来源:origin: SleepyTrousers/EnderIO

@Override
public void onUpdate() {
 super.onUpdate();
 if (!world.isRemote && world.getDifficulty() == EnumDifficulty.PEACEFUL) {
  setDead();
 }
}

代码示例来源:origin: WayofTime/BloodMagic

public void reimbursePlayer(EntityLivingBase hitEntity, float damage)
{
  if (this.shootingEntity instanceof EntityPlayer)
  {
    if (hitEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(hitEntity instanceof IMob))
    {
      return;
    }
    PlayerDemonWillHandler.addDemonWill(type, (EntityPlayer) this.shootingEntity, reimbursedAmountOnHit * damage / 20f);
  }
}

代码示例来源:origin: CyclopsMC/EvilCraft

/**
 * If at the current time in the given world werewolves can appear.
 * @param world The world.
 * @return If it is werewolf party time.
 */
public static boolean isWerewolfTime(World world) {
  return world.getCurrentMoonPhaseFactor() == 1.0
      && !MinecraftHelpers.isDay(world)
      && world.getDifficulty() != EnumDifficulty.PEACEFUL;
}

代码示例来源:origin: CyclopsMC/EvilCraft

public void onUpdate()
{
  super.onUpdate();
  if (!this.world.isRemote && this.world.getDifficulty() == EnumDifficulty.PEACEFUL)
  {
    this.setDead();
  }
}

代码示例来源:origin: TeamLapen/Vampirism

@Override
public void onUpdate() {
  super.onUpdate();
  if (!this.world.isRemote && !peaceful && this.world.getDifficulty() == EnumDifficulty.PEACEFUL) {
    this.setDead();
  }
}

代码示例来源:origin: Silentine/GrimoireOfGaia

/**
 * Checks if the entity's current position is a valid location to spawn this entity.
 */
@Override
public boolean getCanSpawnHere() {
  return this.world.getDifficulty() != EnumDifficulty.PEACEFUL && this.isValidLightLevel() && super.getCanSpawnHere();
}

代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition

public EntityRougeAndroidMob(World world) {
  super(world);
  if (!world.isRemote) {
    setAndroidLevel((int) (MathHelper.clamp(Math.abs(rand.nextGaussian() * (1 + world.getDifficulty().getDifficultyId() * 0.25)), 0, 3)));
    boolean isLegendary = rand.nextDouble() < EntityRogueAndroid.LEGENDARY_SPAWN_CHANCE * getAndroidLevel();
    setLegendary(isLegendary);
    init();
    //getNavigator().setAvoidsWater(true);
    //getNavigator().setCanSwim(false);
  }
}

代码示例来源:origin: P3pp3rF1y/AncientWarfare2

@Override
public int getMaxFallHeight() {
  int i = super.getMaxFallHeight();
  if (i > 4)
    i += world.getDifficulty().getDifficultyId() * getMaxHealth() / 5;
  if (i >= getHealth())
    return (int) getHealth();
  return i;
}

代码示例来源:origin: Glitchfiend/ToughAsNails

@Override
public void performEffect(EntityLivingBase entity, int amplifier)
{
  EnumDifficulty enumdifficulty = entity.getEntityWorld().getDifficulty();
  if (!(entity instanceof EntityPlayer) || (enumdifficulty == EnumDifficulty.PEACEFUL && SyncedConfig.getBooleanValue(GameplayOption.ENABLE_PEACEFUL) && entity.getHealth() > 10.0F) || (enumdifficulty == EnumDifficulty.EASY && entity.getHealth() > 10.0F) || (enumdifficulty == EnumDifficulty.NORMAL && entity.getHealth() > 1.0F) || enumdifficulty == EnumDifficulty.HARD)
  {
    entity.attackEntityFrom(DamageSource.GENERIC, 0.5F);
  }
}

代码示例来源:origin: Glitchfiend/ToughAsNails

@Override
public void performEffect(EntityLivingBase entity, int amplifier)
{
  EnumDifficulty enumdifficulty = entity.getEntityWorld().getDifficulty();
  if (!(entity instanceof EntityPlayer) || (enumdifficulty == EnumDifficulty.PEACEFUL && SyncedConfig.getBooleanValue(GameplayOption.ENABLE_PEACEFUL) && entity.getHealth() > 10.0F) ||  (enumdifficulty == EnumDifficulty.EASY && entity.getHealth() > 10.0F) || (enumdifficulty == EnumDifficulty.NORMAL && entity.getHealth() > 1.0F) || enumdifficulty == EnumDifficulty.HARD)
  {
    entity.attackEntityFrom(DamageSource.GENERIC, 0.5F);
  }
}

代码示例来源:origin: vadis365/TheErebus

@Override
public boolean getCanSpawnHere() {
  float light = getBrightness();
  if (light >= 0F)
    return getEntityWorld().checkNoEntityCollision(getEntityBoundingBox()) && getEntityWorld().getCollisionBoxes(this, getEntityBoundingBox()).isEmpty() && !getEntityWorld().containsAnyLiquid(getEntityBoundingBox()) && getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL;
  return super.getCanSpawnHere();
}

代码示例来源:origin: vadis365/TheErebus

@Override
public boolean getCanSpawnHere() {
  float light = getBrightness();
  if (light >= 0F)
    return getEntityWorld().checkNoEntityCollision(getEntityBoundingBox()) && getEntityWorld().getCollisionBoxes(this, getEntityBoundingBox()).isEmpty() && !getEntityWorld().containsAnyLiquid(getEntityBoundingBox()) && getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL;
  return super.getCanSpawnHere();
}

代码示例来源:origin: vadis365/TheErebus

@Override
public boolean getCanSpawnHere() {
  float light = getBrightness();
  if (light >= 0F)
    return getEntityWorld().checkNoEntityCollision(getEntityBoundingBox()) && getEntityWorld().getCollisionBoxes(this, getEntityBoundingBox()).isEmpty() && !getEntityWorld().containsAnyLiquid(getEntityBoundingBox()) && getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL;
  return super.getCanSpawnHere();
}

代码示例来源:origin: TeamLapen/Vampirism

protected void attackWithCrossbow(EntityLivingBase target) {
  ItemStack arrows = attacker.getArrowStackForAttack(target);
  EntityCrossbowArrow entityArrow = EntityCrossbowArrow.createWithShooter(entity.getEntityWorld(), entity, 0, 0.3F, !entity.isLeftHanded(), arrows);
  double sx = target.posX - entityArrow.posX;
  double sy = target.getEntityBoundingBox().minY + (double) (target.height / 3.0F) - entityArrow.posY;
  double sz = target.posZ - entityArrow.posZ;
  double dist = MathHelper.sqrt(sx * sx + sz * sz);
  entityArrow.shoot(sx, sy + dist * 0.2, sz, 1.6F, (float) (13 - target.getEntityWorld().getDifficulty().getDifficultyId() * 4));
  this.entity.playSound(ModSounds.crossbow, 0.5F, 1);
  this.entity.getEntityWorld().spawnEntity(entityArrow);
}

相关文章

微信公众号

最新文章

更多

World类方法