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

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

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

World.getDifficultyForLocation介绍

暂无

代码示例

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

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

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

  1. @Nonnull
  2. @Override
  3. public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
  4. ItemStack stack = player.getHeldItem(hand);
  5. int range = 16;
  6. 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));
  7. for(EntityWither wither : withers)
  8. if(!world.isRemote && !wither.isDead && !(wither instanceof EntityPinkWither)) {
  9. wither.setDead();
  10. EntityPinkWither pink = new EntityPinkWither(world);
  11. pink.setLocationAndAngles(wither.posX, wither.posY, wither.posZ, wither.rotationYaw, wither.rotationPitch);
  12. pink.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(pink)), null);
  13. world.spawnEntity(pink);
  14. pink.spawnExplosionParticle();
  15. pink.playSound(SoundEvents.ENTITY_GENERIC_EXPLODE, 4F, (1F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F);
  16. UseItemSuccessTrigger.INSTANCE.trigger((EntityPlayerMP) player, stack, (WorldServer) world, player.posX, player.posY, player.posZ);
  17. stack.shrink(1);
  18. return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
  19. }
  20. return ActionResult.newResult(EnumActionResult.PASS, stack);
  21. }

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

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

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

  1. if(entity instanceof EntityAgeable)
  2. ((EntityAgeable) entity).setGrowingAge(-24000);
  3. entity.onInitialSpawn(world.getDifficultyForLocation(getPos()), null);
  4. world.spawnEntity(entity);
  5. entity.spawnExplosionParticle();

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

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

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

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

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

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

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

  1. @SubscribeEvent
  2. public static void onDamageTaken(LivingHurtEvent event) {
  3. if(!event.getEntityLiving().world.isRemote && event.getEntityLiving() instanceof EntityPlayer && event.getSource().getTrueSource() instanceof EntityLivingBase) {
  4. EntityPlayer player = (EntityPlayer) event.getEntityLiving();
  5. ItemStack stack = PlayerHelper.getFirstHeldItemClass(player, IPixieSpawner.class);
  6. float chance = getChance(stack);
  7. for (ItemStack element : player.inventory.armorInventory)
  8. chance += getChance(element);
  9. IItemHandler baubles = BaublesApi.getBaublesHandler(player);
  10. for(int i = 0; i < baubles.getSlots(); i++)
  11. chance += getChance(baubles.getStackInSlot(i));
  12. if(Math.random() < chance) {
  13. EntityPixie pixie = new EntityPixie(player.world);
  14. pixie.setPosition(player.posX, player.posY + 2, player.posZ);
  15. if(((ItemElementiumHelm) ModItems.elementiumHelm).hasArmorSet(player)) {
  16. pixie.setApplyPotionEffect(new PotionEffect(potions[event.getEntityLiving().world.rand.nextInt(potions.length)], 40, 0));
  17. }
  18. float dmg = 4;
  19. if(!stack.isEmpty() && stack.getItem() == ModItems.elementiumSword)
  20. dmg += 2;
  21. pixie.setProps((EntityLivingBase) event.getSource().getTrueSource(), player, 0, dmg);
  22. pixie.onInitialSpawn(player.world.getDifficultyForLocation(new BlockPos(pixie)), null);
  23. player.world.spawnEntity(pixie);
  24. }
  25. }
  26. }

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

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

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

  1. @Override
  2. public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
  3. super.onBlockAdded(world, pos, state);
  4. if(!world.isRemote && world.getBlockState(pos.down()).getBlock() == Blocks.IRON_BARS && world.getBlockState(pos.down(2)).getBlock() == Blocks.IRON_BARS) {
  5. world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
  6. world.setBlockState(pos.down(), Blocks.AIR.getDefaultState(), 2);
  7. world.setBlockState(pos.down(2), Blocks.AIR.getDefaultState(), 2);
  8. EntityBlaze blaze = new EntityBlaze(world);
  9. blaze.setLocationAndAngles(pos.getX() + 0.5D, pos.getY() - 1.95D, pos.getZ() + 0.5D, 0.0F, 0.0F);
  10. blaze.deathLootTable = LOOT_TABLE;
  11. blaze.onInitialSpawn(world.getDifficultyForLocation(pos), null);
  12. world.spawnEntity(blaze);
  13. world.notifyNeighborsOfStateChange(pos, Blocks.AIR, false);
  14. world.notifyNeighborsOfStateChange(pos.down(), Blocks.AIR, false);
  15. world.notifyNeighborsOfStateChange(pos.down(2), Blocks.AIR, false);
  16. }
  17. }

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

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

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

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

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

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

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

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

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

  1. @Override
  2. public boolean attackEntityAsMob(Entity entityIn) {
  3. boolean flag = super.attackEntityAsMob(entityIn);
  4. if (flag) {
  5. float f = this.world.getDifficultyForLocation(new BlockPos(this)).getAdditionalDifficulty();
  6. if (this.getHeldItemMainhand().isEmpty() && this.isBurning() && this.rand.nextFloat() < f * 0.3F) {
  7. entityIn.setFire(2 * (int) f);
  8. }
  9. }
  10. return flag;
  11. }

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

  1. private void setSpawn(byte id) {
  2. EntityGaiaValkyrie valyrie;
  3. if (id == 1) {
  4. explode();
  5. valyrie = new EntityGaiaValkyrie(world);
  6. valyrie.setLocationAndAngles(posX, posY, posZ, rotationYaw, 0.0F);
  7. valyrie.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(valyrie)), null);
  8. world.spawnEntity(valyrie);
  9. }
  10. }

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

  1. private void setSpawn(byte id) {
  2. EntityGaiaVampire vampire;
  3. if (id == 1) {
  4. explode();
  5. vampire = new EntityGaiaVampire(world);
  6. vampire.setLocationAndAngles(posX, posY, posZ, rotationYaw, 0.0F);
  7. vampire.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(vampire)), null);
  8. world.spawnEntity(vampire);
  9. }
  10. }

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

  1. private void setSpawn(byte id) {
  2. EntityGaiaMinotaur minotaur;
  3. if (id == 1) {
  4. explode();
  5. minotaur = new EntityGaiaMinotaur(world);
  6. minotaur.setLocationAndAngles(posX, posY, posZ, rotationYaw, 0.0F);
  7. minotaur.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(minotaur)), null);
  8. world.spawnEntity(minotaur);
  9. }
  10. }

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

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

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

  1. private void spawnHorse() {
  2. AbstractHorse horse = npc.instantiateHorseEntity();
  3. horse.setLocationAndAngles(npc.posX, npc.posY, npc.posZ, npc.rotationYaw, npc.rotationPitch);
  4. horse.onInitialSpawn(npc.world.getDifficultyForLocation(npc.getPosition()), null);
  5. horse.setGrowingAge(0);
  6. horse.setHorseTamed(true);
  7. this.horse = horse;
  8. npc.world.spawnEntity(horse);
  9. npc.startRiding(horse);
  10. onMountHorse();
  11. }
  12. }

相关文章

World类方法