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

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

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

World.getDifficulty介绍

暂无

代码示例

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

  1. @Override
  2. public @Nonnull EnumDifficulty getDifficulty() {
  3. return wrapped.getDifficulty();
  4. }

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

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

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

  1. public double getAttackStrength() {
  2. switch (getEntityWorld().getDifficulty()) {
  3. default:
  4. return 2.0D;
  5. case EASY:
  6. return 2.0D;
  7. case NORMAL:
  8. return 2.0D;
  9. case HARD:
  10. return 4.0D;
  11. }
  12. }

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

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

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

  1. public double getAttackStrength() {
  2. switch (getEntityWorld().getDifficulty()) {
  3. default:
  4. return 1.0D;
  5. case EASY:
  6. return 1.0D;
  7. case NORMAL:
  8. return 2.0D;
  9. case HARD:
  10. return 3.0D;
  11. }
  12. }

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

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

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

  1. @Override
  2. public void onUpdate() {
  3. super.onUpdate();
  4. if (!world.isRemote && world.getDifficulty() == EnumDifficulty.PEACEFUL) {
  5. setDead();
  6. }
  7. }

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

  1. public void reimbursePlayer(EntityLivingBase hitEntity, float damage)
  2. {
  3. if (this.shootingEntity instanceof EntityPlayer)
  4. {
  5. if (hitEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(hitEntity instanceof IMob))
  6. {
  7. return;
  8. }
  9. PlayerDemonWillHandler.addDemonWill(type, (EntityPlayer) this.shootingEntity, reimbursedAmountOnHit * damage / 20f);
  10. }
  11. }

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

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

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

  1. public void onUpdate()
  2. {
  3. super.onUpdate();
  4. if (!this.world.isRemote && this.world.getDifficulty() == EnumDifficulty.PEACEFUL)
  5. {
  6. this.setDead();
  7. }
  8. }

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

  1. @Override
  2. public void onUpdate() {
  3. super.onUpdate();
  4. if (!this.world.isRemote && !peaceful && this.world.getDifficulty() == EnumDifficulty.PEACEFUL) {
  5. this.setDead();
  6. }
  7. }

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

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

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

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

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

  1. @Override
  2. public int getMaxFallHeight() {
  3. int i = super.getMaxFallHeight();
  4. if (i > 4)
  5. i += world.getDifficulty().getDifficultyId() * getMaxHealth() / 5;
  6. if (i >= getHealth())
  7. return (int) getHealth();
  8. return i;
  9. }

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

  1. @Override
  2. public void performEffect(EntityLivingBase entity, int amplifier)
  3. {
  4. EnumDifficulty enumdifficulty = entity.getEntityWorld().getDifficulty();
  5. 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)
  6. {
  7. entity.attackEntityFrom(DamageSource.GENERIC, 0.5F);
  8. }
  9. }

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

  1. @Override
  2. public void performEffect(EntityLivingBase entity, int amplifier)
  3. {
  4. EnumDifficulty enumdifficulty = entity.getEntityWorld().getDifficulty();
  5. 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)
  6. {
  7. entity.attackEntityFrom(DamageSource.GENERIC, 0.5F);
  8. }
  9. }

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

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

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

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

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

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

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

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

相关文章

World类方法