类net.minecraft.world.EnumDifficulty源码实例Demo

下面列出了怎么用net.minecraft.world.EnumDifficulty的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: TofuCraftReload   文件: EntityTofuSlime.java
@Override
public boolean getCanSpawnHere() {

    if (this.world.getDifficulty() != EnumDifficulty.PEACEFUL) {
        int lightValue = this.world.getLightFromNeighbors(new BlockPos(MathHelper.floor(this.posX), MathHelper.floor(this.posY), MathHelper.floor(this.posZ)));

        if (this.dimension == TofuMain.TOFU_DIMENSION.getId() && this.rand.nextInt((int) (this.world.getLightBrightness(getPosition()) * 10 + 30)) == 0
                && this.world.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().expand(48.0D, 20.0D, 48.0D)).size() == 0) {

            //It does not spawn when there is a light like a torch (spawns when there is no light like a torch even if there is light in the sky)
            return this.world.getLightFor(EnumSkyBlock.BLOCK, getPosition()) < 2 + this.rand.nextInt(6) && this.baseGetCanSpawnHere();
        }

        if (this.dimension == 0 && this.rand.nextInt(10) == 0
                && isSpawnChunk(this.world, this.posX, this.posZ)
                && this.posY < 40.0D
                && lightValue <= this.rand.nextInt(10))
            return this.baseGetCanSpawnHere();
    }
    return false;
}
 
源代码2 项目: EnderZoo   文件: MobSpawnEventHandler.java
public MobSpawnEventHandler() {

    ezHealthMods.put(EnumDifficulty.PEACEFUL, 1d);
    ezHealthMods.put(EnumDifficulty.EASY, Config.enderZooEasyHealthModifier);
    ezHealthMods.put(EnumDifficulty.NORMAL, Config.enderZooNormalHealthModifier);
    ezHealthMods.put(EnumDifficulty.HARD, Config.enderZooHardHealthModifier);
    ezAttackMods.put(EnumDifficulty.PEACEFUL, 1d);
    ezAttackMods.put(EnumDifficulty.EASY, Config.enderZooEasyAttackModifier);
    ezAttackMods.put(EnumDifficulty.NORMAL, Config.enderZooNormalAttackModifier);
    ezAttackMods.put(EnumDifficulty.HARD, Config.enderZooHardAttackModifier);

    otherHealthMods.put(EnumDifficulty.PEACEFUL, 1d);
    otherHealthMods.put(EnumDifficulty.EASY, Config.globalEasyHealthModifier);
    otherHealthMods.put(EnumDifficulty.NORMAL, Config.globalNormalHealthModifier);
    otherHealthMods.put(EnumDifficulty.HARD, Config.globalHardHealthModifier);
    otherAttackMods.put(EnumDifficulty.PEACEFUL, 1d);
    otherAttackMods.put(EnumDifficulty.EASY, Config.globalEasyAttackModifier);
    otherAttackMods.put(EnumDifficulty.NORMAL, Config.globalNormalAttackModifier);
    otherAttackMods.put(EnumDifficulty.HARD, Config.globalHardAttackModifier);

  }
 
源代码3 项目: GregTech   文件: EntitySpawnHandler.java
@SubscribeEvent
public static void onEntitySpawn(LivingSpawnEvent.SpecialSpawn event) {
    EntityLivingBase entity = event.getEntityLiving();
    EnumDifficulty difficulty = entity.world.getDifficulty();
    if (difficulty == EnumDifficulty.HARD && entity.getRNG().nextFloat() <= 0.03f) {
        if (entity instanceof EntityZombie) {
            ItemStack itemStack = MetaItems.NANO_SABER.getInfiniteChargedStack();
            ToggleEnergyConsumerBehavior.setItemActive(itemStack, true);
            entity.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, itemStack);
            ((EntityZombie) entity).setDropChance(EntityEquipmentSlot.MAINHAND, 0.0f);
        }
    }
}
 
源代码4 项目: litematica   文件: SchematicWorldHandler.java
public static void recreateSchematicWorld(boolean remove)
{
    if (remove)
    {
        world = null;
    }
    else
    {
        // Note: The dimension used here must have no skylight, because the custom Chunks don't have those arrays
        world = new WorldSchematic(null, SETTINGS, 1, EnumDifficulty.PEACEFUL, MC.profiler);
        //this.world.addEventListener(LitematicaRenderer.getInstance().getRenderGlobal());
    }

    LitematicaRenderer.getInstance().onSchematicWorldChanged(world);
}
 
源代码5 项目: litematica   文件: MaterialCache.java
private MaterialCache()
{
    WorldSettings settings = new WorldSettings(0L, GameType.CREATIVE, false, false, WorldType.FLAT);

    this.tempWorld = new WorldSchematic(null, settings, -1, EnumDifficulty.PEACEFUL, Minecraft.getMinecraft().profiler);
    this.checkPos = new BlockPos(8, 0, 8);

    WorldUtils.loadChunksClientWorld(this.tempWorld, this.checkPos, new Vec3i(1, 1, 1));
}
 
源代码6 项目: ToroQuest   文件: EntityMonolithEye.java
/**
 * Updates the task
 */
public void updateTask() {
	EntityLivingBase entitylivingbase = this.theEntity.getAttackTarget();
	this.theEntity.getNavigator().clearPath();
	this.theEntity.getLookHelper().setLookPositionWithEntity(entitylivingbase, 90.0F, 90.0F);

	if (!this.theEntity.canEntityBeSeen(entitylivingbase)) {
		this.theEntity.setAttackTarget((EntityLivingBase) null);
	} else {
		++this.tickCounter;

		if (this.tickCounter == 0) {
			this.theEntity.setTargetedEntity(this.theEntity.getAttackTarget().getEntityId());
			// this.theEntity.world.setEntityState(this.theEntity,
			// (byte) 21);
		} else if (this.tickCounter >= this.theEntity.getAttackDuration()) {
			float damage = 3.0F;

			if (this.theEntity.world.getDifficulty() == EnumDifficulty.HARD) {
				damage += 3.0F;
			}

			DamageSource ds = DamageSource.causeIndirectMagicDamage(this.theEntity, this.theEntity);

			entitylivingbase.attackEntityFrom(ds, damage);
			entitylivingbase.attackEntityFrom(DamageSource.causeMobDamage(this.theEntity),
					(float) this.theEntity.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue());
			theEntity.attackedTarget = theEntity.getAttackTarget();
			theEntity.setAttackTarget((EntityLivingBase) null);
			theEntity.world.setEntityState(theEntity, (byte) 15);
			theEntity.playSound(SoundEvents.ENTITY_GENERIC_EXPLODE, 1.0F, 1.0F / (theEntity.getRNG().nextFloat() * 0.4F + 0.8F));
		}

		super.updateTask();
	}
}
 
源代码7 项目: Gadomancy   文件: TileExtendedNode.java
private boolean handleGrowingNodeSecond(boolean needUpdate) {
    if(extendedNodeType == null || extendedNodeType != ExtendedNodeType.GROWING) return needUpdate;

    if(worldObj.difficultySetting == EnumDifficulty.PEACEFUL) return needUpdate;
    if(worldObj.isRemote) return needUpdate;
    if(ticksExisted % 8 != 0) return needUpdate;

    List livingEntities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1).expand(6.0D, 6.0D, 6.0D));
    if ((livingEntities != null) && (livingEntities.size() > 0)) {
        for (Object e : livingEntities) {
            EntityLivingBase livingEntity = (EntityLivingBase) e;
            if ((livingEntity.isEntityAlive()) && (!livingEntity.isEntityInvulnerable())) {
                if(livingEntity instanceof EntityPlayer && ((EntityPlayer) livingEntity).capabilities.isCreativeMode) continue;
                if(!behavior.mayZapNow()) continue;

                ResearchHelper.distributeResearch(Gadomancy.MODID.toUpperCase() + ".GROWING_AGGRESSION", worldObj, xCoord, yCoord, zCoord, 6);

                livingEntity.attackEntityFrom(DamageSource.magic, behavior.getZapDamage());

                worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "thaumcraft:zap", 0.8F, 1.0F);

                PacketTCNodeBolt packet = new PacketTCNodeBolt(xCoord + 0.5F, yCoord + 0.5F, zCoord + 0.5F, (float) livingEntity.posX, (float) (livingEntity.posY + livingEntity.height), (float) livingEntity.posZ, 0, false);
                PacketHandler.INSTANCE.sendToAllAround(packet, new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 32.0D));
            }
        }
    }

    return needUpdate;
}
 
源代码8 项目: Gadomancy   文件: AuraEffects.java
@Override
public void doBlockEffect(ChunkCoordinates originTile, ChunkCoordinates selectedBlock, World world) {
    EntityLiving mob = world.rand.nextBoolean() ? new EntitySkeleton(world) : new EntityZombie(world);
    if(setAndCheckPosition(mob, selectedBlock, world, true) && world.difficultySetting != EnumDifficulty.PEACEFUL) {
        for(int i = 0; i < 5; i++) {
            mob.setCurrentItemOrArmor(i, null);
        }

        int timeout = 40;
        int totalCount = (world.rand.nextInt(3) == 0 ? 1 : 0) + 2;
        do {
            int slot = mob.getEquipmentInSlot(0) == null ? 0 : (mob.getEquipmentInSlot(4) == null ? 4 : (world.rand.nextInt(3)+1));
            if(mob.getEquipmentInSlot(slot) == null) {
                ItemStack[] items = ITEMS_SOUL[slot];
                ItemStack stack = items[world.rand.nextInt(items.length)];
                if(stack.getItem() != Items.bow || mob instanceof EntitySkeleton) {
                    totalCount--;
                    mob.setCurrentItemOrArmor(slot, stack);
                    mob.setEquipmentDropChance(slot, 0);
                }
            }
            timeout--;
        } while (totalCount > 0 && timeout > 0);

        if(timeout > 0) {
            mob.addPotionEffect(new PotionEffect(Potion.invisibility.getId(), MiscUtils.ticksForMinutes(60*24*365), 1, true));

            ChunkCoordinates pos = new ChunkCoordinates((int) mob.posX, (int) mob.posY, (int) mob.posZ);
            pos = iterateDown(pos, world);
            mob.setPosition(pos.posX + 0.5, pos.posY, pos.posZ + 0.5);
            world.spawnEntityInWorld(mob);
        }
    }
}
 
源代码9 项目: Gadomancy   文件: AuraEffects.java
@Override
public void doBlockEffect(ChunkCoordinates originTile, ChunkCoordinates selectedBlock, World world) {
    EntitySlime slime = new EntitySlime(world);
    NBTTagCompound data = new NBTTagCompound();
    slime.writeEntityToNBT(data);
    data.setInteger("Size", 0);
    slime.readEntityFromNBT(data);
    boolean canSpawn = setAndCheckPosition(slime, selectedBlock, world, true) && world.difficultySetting != EnumDifficulty.PEACEFUL;
    if(canSpawn) {
        ChunkCoordinates pos = new ChunkCoordinates((int) slime.posX, (int) slime.posY, (int) slime.posZ);
        pos = iterateDown(pos, world);
        slime.setPosition(pos.posX + 0.5, pos.posY, pos.posZ + 0.5);
        world.spawnEntityInWorld(slime);
    }
}
 
源代码10 项目: EnderZoo   文件: EntityFallenMount.java
@Override
public void onUpdate() {
  super.onUpdate();
  if(!world.isRemote && world.getDifficulty() == EnumDifficulty.PEACEFUL) {
    setDead();
  }
}
 
源代码11 项目: Kettle   文件: CraftWorld.java
public void setDifficulty(Difficulty difficulty) {
    this.getHandle().worldInfo.setDifficulty(EnumDifficulty.getDifficultyEnum(difficulty.getValue()));
}
 
源代码12 项目: litematica   文件: WorldSchematic.java
public WorldSchematic(NetHandlerPlayClient netHandler, WorldSettings settings, int dimension,
        EnumDifficulty difficulty, Profiler profilerIn)
{
    super(netHandler, settings, dimension, difficulty, profilerIn);
}
 
源代码13 项目: Gadomancy   文件: FakeWorld.java
public FakeWorld(WorldProvider provider) {
    super(FakeSaveHandler.instance, "", null, provider, new Profiler());
    theProfiler.profilingEnabled = false;
    difficultySetting = EnumDifficulty.NORMAL;
}
 
源代码14 项目: Gadomancy   文件: FakeWorld.java
public FakeWorld() {
    super(FakeSaveHandler.instance, "", null, FakeWorldProvider.instance, null);
    difficultySetting = EnumDifficulty.NORMAL;
}
 
源代码15 项目: Framez   文件: FakeWorldClient.java
private FakeWorldClient() {

        super(new NetHandlerPlayClient(Minecraft.getMinecraft(), null, new NetworkManager(true)), new WorldSettings(0, GameType.NOT_SET,
                false, false, WorldType.DEFAULT), 0, EnumDifficulty.PEACEFUL, Minecraft.getMinecraft().theWorld.theProfiler);
    }
 
源代码16 项目: EnderZoo   文件: EntityFallenMount.java
@Override
public IEntityLivingData onInitialSpawn(DifficultyInstance di, IEntityLivingData data) {  

  setHorseArmorStack(ItemStack.EMPTY);        
  setHorseSaddled(true);    
  setGrowingAge(0);
  getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(Config.fallenMountHealth);
  getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.2);
  getAttributeMap().getAttributeInstanceByName("horse.jumpStrength").setBaseValue(0.5);
  setHealth(getMaxHealth());
  
  float chanceOfArmor = world.getDifficulty() == EnumDifficulty.HARD ? Config.fallenMountChanceArmoredHard
      : Config.fallenMountChanceArmored;
  if(rand.nextFloat() <= chanceOfArmor) {

    //Value between 0 and 1 (normal) - 1.5 based on how long a chunk has been occupied and the moon phase
    
    //float occupiedDiffcultyMultiplier = worldObj.func_147462_b(posX, posY, posZ);
    
    float occupiedDiffcultyMultiplier = di.getClampedAdditionalDifficulty();
    //TODO: Do I need this normalised still?
    occupiedDiffcultyMultiplier /= 1.5f; // normalize
    float chanceImprovedArmor = world.getDifficulty() == EnumDifficulty.HARD ? Config.fallenMountChanceArmorUpgradeHard
        : Config.fallenMountChanceArmorUpgrade;
    chanceImprovedArmor *= (1 + occupiedDiffcultyMultiplier); //If we have the max occupied factor, double the chance of improved armor

    int armorLevel = 0;
    for (int i = 0; i < 2; i++) {
      if(rand.nextFloat() <= chanceImprovedArmor) {
        armorLevel++;
      }
    }
    Item armorItem = Items.IRON_HORSE_ARMOR;
    switch (armorLevel) {
    case 1:
      armorItem = Items.GOLDEN_HORSE_ARMOR;
      break;
    case 2:
      armorItem = Items.DIAMOND_HORSE_ARMOR;
      break;
    }
    armor = new ItemStack(armorItem);
    setHorseArmorStack(armor);
  } else {
    armor = ItemStack.EMPTY;
    setHorseArmorStack(armor);
  }
  return data;
}
 
源代码17 项目: EnderZoo   文件: EntityUtil.java
public static boolean isHardDifficulty(World worldObj) {
  return worldObj.getDifficulty() == EnumDifficulty.HARD;
}
 
 类所在包
 类方法
 同包方法