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

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

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

World.getDifficultyForLocation介绍

暂无

代码示例

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

pixie.setProps(players.get(rand.nextInt(players.size())), this, 1, 8);
      pixie.setPosition(posX + width / 2, posY + 2, posZ + width / 2);
      pixie.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(pixie)), null);
      world.spawnEntity(pixie);
float range = 6F;
entity.setPosition(posX + 0.5 + Math.random() * range - range / 2, posY - 1, posZ + 0.5 + Math.random() * range - range / 2);
entity.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(entity)), null);
if(entity instanceof EntityWitherSkeleton && hardMode) {
  entity.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(ModItems.elementiumSword));

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

@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
  ItemStack stack = player.getHeldItem(hand);
  int range = 16;
  List<EntityWither> withers = world.getEntitiesWithinAABB(EntityWither.class, new AxisAlignedBB(player.posX - range, player.posY - range, player.posZ - range, player.posX + range, player.posY + range, player.posZ + range));
  for(EntityWither wither : withers)
    if(!world.isRemote && !wither.isDead && !(wither instanceof EntityPinkWither)) {
      wither.setDead();
      EntityPinkWither pink = new EntityPinkWither(world);
      pink.setLocationAndAngles(wither.posX, wither.posY, wither.posZ, wither.rotationYaw, wither.rotationPitch);
      pink.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(pink)), null);
      world.spawnEntity(pink);
      pink.spawnExplosionParticle();
      pink.playSound(SoundEvents.ENTITY_GENERIC_EXPLODE, 4F, (1F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F);
      UseItemSuccessTrigger.INSTANCE.trigger((EntityPlayerMP) player, stack, (WorldServer) world, player.posX, player.posY, player.posZ);
      stack.shrink(1);
      return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
    }
  return ActionResult.newResult(EnumActionResult.PASS, stack);
}

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

entity.getEntityData().setTag(TAG_ITEMSTACK_TO_DROP, cmp);
entity.onInitialSpawn(world.getDifficultyForLocation(pos), null);
world.spawnEntity(entity);
entity.spawnExplosionParticle();

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

if(entity instanceof EntityAgeable)
  ((EntityAgeable) entity).setGrowingAge(-24000);
entity.onInitialSpawn(world.getDifficultyForLocation(getPos()), null);
world.spawnEntity(entity);
entity.spawnExplosionParticle();

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

if(logic.spawnData.getNbt().getSize() == 1 && logic.spawnData.getNbt().hasKey("id", 8) && entity instanceof EntityLiving) {
  if(!net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn(entityliving, logic.getSpawnerWorld(), (float) entity.posX, (float) entity.posY, (float) entity.posZ))
    ((EntityLiving) entity).onInitialSpawn(world.getDifficultyForLocation(new BlockPos(entity)), (IEntityLivingData) null);

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

@Override
public @Nonnull DifficultyInstance getDifficultyForLocation(@Nonnull BlockPos pos) {
 return wrapped.getDifficultyForLocation(pos);
}

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

pixie.setProps(players.get(rand.nextInt(players.size())), this, 1, 8);
pixie.setPosition(posX + width / 2, posY + 2, posZ + width / 2);
pixie.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(pixie)), null);
world.spawnEntity(pixie);

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

@SubscribeEvent
public static void onDamageTaken(LivingHurtEvent event) {
  if(!event.getEntityLiving().world.isRemote && event.getEntityLiving() instanceof EntityPlayer && event.getSource().getTrueSource() instanceof EntityLivingBase) {
    EntityPlayer player = (EntityPlayer) event.getEntityLiving();
    ItemStack stack = PlayerHelper.getFirstHeldItemClass(player, IPixieSpawner.class);
    float chance = getChance(stack);
    for (ItemStack element : player.inventory.armorInventory)
      chance += getChance(element);
    IItemHandler baubles = BaublesApi.getBaublesHandler(player);
    for(int i = 0; i < baubles.getSlots(); i++)
      chance += getChance(baubles.getStackInSlot(i));
    if(Math.random() < chance) {
      EntityPixie pixie = new EntityPixie(player.world);
      pixie.setPosition(player.posX, player.posY + 2, player.posZ);
      if(((ItemElementiumHelm) ModItems.elementiumHelm).hasArmorSet(player)) {
        pixie.setApplyPotionEffect(new PotionEffect(potions[event.getEntityLiving().world.rand.nextInt(potions.length)], 40, 0));
      }
      float dmg = 4;
      if(!stack.isEmpty() && stack.getItem() == ModItems.elementiumSword)
        dmg += 2;
      pixie.setProps((EntityLivingBase) event.getSource().getTrueSource(), player, 0, dmg);
      pixie.onInitialSpawn(player.world.getDifficultyForLocation(new BlockPos(pixie)), null);
      player.world.spawnEntity(pixie);
    }
  }
}

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

public static float getDifficultyMultiplierForLocation(@Nonnull World world, double x, double y, double z) {
 // Value between 0 and 1 (normal) - 1.5 based on how long a chunk has been
 // occupied
 float occupiedDiffcultyMultiplier = world.getDifficultyForLocation(new BlockPos(x, y, z)).getClampedAdditionalDifficulty();
 occupiedDiffcultyMultiplier /= 1.5f; // normalize
 return occupiedDiffcultyMultiplier;
}

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

@Override
public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
  super.onBlockAdded(world, pos, state);
  if(!world.isRemote && world.getBlockState(pos.down()).getBlock() == Blocks.IRON_BARS && world.getBlockState(pos.down(2)).getBlock() == Blocks.IRON_BARS) {
    world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
    world.setBlockState(pos.down(), Blocks.AIR.getDefaultState(), 2);
    world.setBlockState(pos.down(2), Blocks.AIR.getDefaultState(), 2);
    EntityBlaze blaze = new EntityBlaze(world);
    blaze.setLocationAndAngles(pos.getX() + 0.5D, pos.getY() - 1.95D, pos.getZ() + 0.5D, 0.0F, 0.0F);
    blaze.deathLootTable = LOOT_TABLE;
    blaze.onInitialSpawn(world.getDifficultyForLocation(pos), null);
    world.spawnEntity(blaze);
    world.notifyNeighborsOfStateChange(pos, Blocks.AIR, false);
    world.notifyNeighborsOfStateChange(pos.down(), Blocks.AIR, false);
    world.notifyNeighborsOfStateChange(pos.down(2), Blocks.AIR, false);
  }
}

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

e.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(e)), null);
world.spawnEntity(e);
return true;

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

public EntityVillager createChild(EntityAgeable ageable) {
  EntitySnowVillager entityvillager = new EntitySnowVillager(this.world);
  entityvillager.onInitialSpawn(this.world.getDifficultyForLocation(new BlockPos(entityvillager)), (IEntityLivingData) null);
  return entityvillager;
}

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

newHorse.onInitialSpawn(player.world.getDifficultyForLocation(new BlockPos(newHorse)), null);
newHorse.setGrowingAge(horse.getGrowingAge());
player.world.spawnEntity(newHorse);

代码示例来源:origin: ForestryMC/ForestryMC

public static <E extends EntityLiving> E spawnEntity(World world, E living, double x, double y, double z) {
  living.setLocationAndAngles(x, y, z, MathHelper.wrapDegrees(world.rand.nextFloat() * 360.0f), 0.0f);
  living.rotationYawHead = living.rotationYaw;
  living.renderYawOffset = living.rotationYaw;
  living.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(x, y, z)), null);
  world.spawnEntity(living);
  living.playLivingSound();
  return living;
}

代码示例来源:origin: TeamWizardry/Wizardry

@Override
public boolean attackEntityAsMob(Entity entityIn) {
  boolean flag = super.attackEntityAsMob(entityIn);
  if (flag) {
    float f = this.world.getDifficultyForLocation(new BlockPos(this)).getAdditionalDifficulty();
    if (this.getHeldItemMainhand().isEmpty() && this.isBurning() && this.rand.nextFloat() < f * 0.3F) {
      entityIn.setFire(2 * (int) f);
    }
  }
  return flag;
}

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

private void setSpawn(byte id) {
  EntityGaiaValkyrie valyrie;
  if (id == 1) {
    explode();
    valyrie = new EntityGaiaValkyrie(world);
    valyrie.setLocationAndAngles(posX, posY, posZ, rotationYaw, 0.0F);
    valyrie.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(valyrie)), null);
    world.spawnEntity(valyrie);
  }
}

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

private void setSpawn(byte id) {
  EntityGaiaVampire vampire;
  if (id == 1) {
    explode();
    vampire = new EntityGaiaVampire(world);
    vampire.setLocationAndAngles(posX, posY, posZ, rotationYaw, 0.0F);
    vampire.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(vampire)), null);
    world.spawnEntity(vampire);
  }
}

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

private void setSpawn(byte id) {
  EntityGaiaMinotaur minotaur;
  if (id == 1) {
    explode();
    minotaur = new EntityGaiaMinotaur(world);
    minotaur.setLocationAndAngles(posX, posY, posZ, rotationYaw, 0.0F);
    minotaur.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(minotaur)), null);
    world.spawnEntity(minotaur);
  }
}

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

public void spawnLegendary(World world, Random random, BlockPos pos) {
  EntityRangedRogueAndroidMob legendaryMob = new EntityRangedRogueAndroidMob(world, 3, true);
  legendaryMob.setPosition(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
  world.spawnEntity(legendaryMob);
  legendaryMob.onInitialSpawn(world.getDifficultyForLocation(pos), null);
  legendaryMob.enablePersistence();
}

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

private void spawnHorse() {
    AbstractHorse horse = npc.instantiateHorseEntity();
    horse.setLocationAndAngles(npc.posX, npc.posY, npc.posZ, npc.rotationYaw, npc.rotationPitch);
    horse.onInitialSpawn(npc.world.getDifficultyForLocation(npc.getPosition()), null);
    horse.setGrowingAge(0);
    horse.setHorseTamed(true);
    this.horse = horse;
    npc.world.spawnEntity(horse);
    npc.startRiding(horse);
    onMountHorse();
  }
}

相关文章

微信公众号

最新文章

更多

World类方法