Java 类net.minecraft.util.WeightedSpawnerEntity 实例源码

项目:Backmemed    文件:MobSpawnerBaseLogic.java   
private void resetTimer()
{
    if (this.maxSpawnDelay <= this.minSpawnDelay)
    {
        this.spawnDelay = this.minSpawnDelay;
    }
    else
    {
        int i = this.maxSpawnDelay - this.minSpawnDelay;
        this.spawnDelay = this.minSpawnDelay + this.getSpawnerWorld().rand.nextInt(i);
    }

    if (!this.potentialSpawns.isEmpty())
    {
        this.setNextSpawnData((WeightedSpawnerEntity)WeightedRandom.getRandomItem(this.getSpawnerWorld().rand, this.potentialSpawns));
    }

    this.broadcastEvent(1);
}
项目:CustomWorldGen    文件:MobSpawnerBaseLogic.java   
private void resetTimer()
{
    if (this.maxSpawnDelay <= this.minSpawnDelay)
    {
        this.spawnDelay = this.minSpawnDelay;
    }
    else
    {
        int i = this.maxSpawnDelay - this.minSpawnDelay;
        this.spawnDelay = this.minSpawnDelay + this.getSpawnerWorld().rand.nextInt(i);
    }

    if (!this.minecartToSpawn.isEmpty())
    {
        this.setNextSpawnData((WeightedSpawnerEntity)WeightedRandom.getRandomItem(this.getSpawnerWorld().rand, this.minecartToSpawn));
    }

    this.broadcastEvent(1);
}
项目:Backmemed    文件:MobSpawnerBaseLogic.java   
public NBTTagCompound writeToNBT(NBTTagCompound p_189530_1_)
{
    ResourceLocation resourcelocation = this.func_190895_g();

    if (resourcelocation == null)
    {
        return p_189530_1_;
    }
    else
    {
        p_189530_1_.setShort("Delay", (short)this.spawnDelay);
        p_189530_1_.setShort("MinSpawnDelay", (short)this.minSpawnDelay);
        p_189530_1_.setShort("MaxSpawnDelay", (short)this.maxSpawnDelay);
        p_189530_1_.setShort("SpawnCount", (short)this.spawnCount);
        p_189530_1_.setShort("MaxNearbyEntities", (short)this.maxNearbyEntities);
        p_189530_1_.setShort("RequiredPlayerRange", (short)this.activatingRangeFromPlayer);
        p_189530_1_.setShort("SpawnRange", (short)this.spawnRange);
        p_189530_1_.setTag("SpawnData", this.randomEntity.getNbt().copy());
        NBTTagList nbttaglist = new NBTTagList();

        if (this.potentialSpawns.isEmpty())
        {
            nbttaglist.appendTag(this.randomEntity.toCompoundTag());
        }
        else
        {
            for (WeightedSpawnerEntity weightedspawnerentity : this.potentialSpawns)
            {
                nbttaglist.appendTag(weightedspawnerentity.toCompoundTag());
            }
        }

        p_189530_1_.setTag("SpawnPotentials", nbttaglist);
        return p_189530_1_;
    }
}
项目:Backmemed    文件:TileEntityMobSpawner.java   
public void setNextSpawnData(WeightedSpawnerEntity p_184993_1_)
{
    super.setNextSpawnData(p_184993_1_);

    if (this.getSpawnerWorld() != null)
    {
        IBlockState iblockstate = this.getSpawnerWorld().getBlockState(this.getSpawnerPosition());
        this.getSpawnerWorld().notifyBlockUpdate(TileEntityMobSpawner.this.pos, iblockstate, iblockstate, 4);
    }
}
项目:CustomWorldGen    文件:MobSpawnerBaseLogic.java   
public NBTTagCompound writeToNBT(NBTTagCompound p_189530_1_)
{
    String s = this.getEntityNameToSpawn();

    if (StringUtils.isNullOrEmpty(s))
    {
        return p_189530_1_;
    }
    else
    {
        p_189530_1_.setShort("Delay", (short)this.spawnDelay);
        p_189530_1_.setShort("MinSpawnDelay", (short)this.minSpawnDelay);
        p_189530_1_.setShort("MaxSpawnDelay", (short)this.maxSpawnDelay);
        p_189530_1_.setShort("SpawnCount", (short)this.spawnCount);
        p_189530_1_.setShort("MaxNearbyEntities", (short)this.maxNearbyEntities);
        p_189530_1_.setShort("RequiredPlayerRange", (short)this.activatingRangeFromPlayer);
        p_189530_1_.setShort("SpawnRange", (short)this.spawnRange);
        p_189530_1_.setTag("SpawnData", this.randomEntity.getNbt().copy());
        NBTTagList nbttaglist = new NBTTagList();

        if (this.minecartToSpawn.isEmpty())
        {
            nbttaglist.appendTag(this.randomEntity.toCompoundTag());
        }
        else
        {
            for (WeightedSpawnerEntity weightedspawnerentity : this.minecartToSpawn)
            {
                nbttaglist.appendTag(weightedspawnerentity.toCompoundTag());
            }
        }

        p_189530_1_.setTag("SpawnPotentials", nbttaglist);
        return p_189530_1_;
    }
}
项目:CustomWorldGen    文件:TileEntityMobSpawner.java   
public void setNextSpawnData(WeightedSpawnerEntity p_184993_1_)
{
    super.setNextSpawnData(p_184993_1_);

    if (this.getSpawnerWorld() != null)
    {
        IBlockState iblockstate = this.getSpawnerWorld().getBlockState(this.getSpawnerPosition());
        this.getSpawnerWorld().notifyBlockUpdate(TileEntityMobSpawner.this.pos, iblockstate, iblockstate, 4);
    }
}
项目:Backmemed    文件:MobSpawnerBaseLogic.java   
public void readFromNBT(NBTTagCompound nbt)
{
    this.spawnDelay = nbt.getShort("Delay");
    this.potentialSpawns.clear();

    if (nbt.hasKey("SpawnPotentials", 9))
    {
        NBTTagList nbttaglist = nbt.getTagList("SpawnPotentials", 10);

        for (int i = 0; i < nbttaglist.tagCount(); ++i)
        {
            this.potentialSpawns.add(new WeightedSpawnerEntity(nbttaglist.getCompoundTagAt(i)));
        }
    }

    if (nbt.hasKey("SpawnData", 10))
    {
        this.setNextSpawnData(new WeightedSpawnerEntity(1, nbt.getCompoundTag("SpawnData")));
    }
    else if (!this.potentialSpawns.isEmpty())
    {
        this.setNextSpawnData((WeightedSpawnerEntity)WeightedRandom.getRandomItem(this.getSpawnerWorld().rand, this.potentialSpawns));
    }

    if (nbt.hasKey("MinSpawnDelay", 99))
    {
        this.minSpawnDelay = nbt.getShort("MinSpawnDelay");
        this.maxSpawnDelay = nbt.getShort("MaxSpawnDelay");
        this.spawnCount = nbt.getShort("SpawnCount");
    }

    if (nbt.hasKey("MaxNearbyEntities", 99))
    {
        this.maxNearbyEntities = nbt.getShort("MaxNearbyEntities");
        this.activatingRangeFromPlayer = nbt.getShort("RequiredPlayerRange");
    }

    if (nbt.hasKey("SpawnRange", 99))
    {
        this.spawnRange = nbt.getShort("SpawnRange");
    }

    if (this.getSpawnerWorld() != null)
    {
        this.cachedEntity = null;
    }
}
项目:Backmemed    文件:MobSpawnerBaseLogic.java   
public void setNextSpawnData(WeightedSpawnerEntity p_184993_1_)
{
    this.randomEntity = p_184993_1_;
}
项目:CustomWorldGen    文件:MobSpawnerBaseLogic.java   
public void readFromNBT(NBTTagCompound nbt)
{
    this.spawnDelay = nbt.getShort("Delay");
    this.minecartToSpawn.clear();

    if (nbt.hasKey("SpawnPotentials", 9))
    {
        NBTTagList nbttaglist = nbt.getTagList("SpawnPotentials", 10);

        for (int i = 0; i < nbttaglist.tagCount(); ++i)
        {
            this.minecartToSpawn.add(new WeightedSpawnerEntity(nbttaglist.getCompoundTagAt(i)));
        }
    }

    NBTTagCompound nbttagcompound = nbt.getCompoundTag("SpawnData");

    if (!nbttagcompound.hasKey("id", 8))
    {
        nbttagcompound.setString("id", "Pig");
    }

    this.setNextSpawnData(new WeightedSpawnerEntity(1, nbttagcompound));

    if (nbt.hasKey("MinSpawnDelay", 99))
    {
        this.minSpawnDelay = nbt.getShort("MinSpawnDelay");
        this.maxSpawnDelay = nbt.getShort("MaxSpawnDelay");
        this.spawnCount = nbt.getShort("SpawnCount");
    }

    if (nbt.hasKey("MaxNearbyEntities", 99))
    {
        this.maxNearbyEntities = nbt.getShort("MaxNearbyEntities");
        this.activatingRangeFromPlayer = nbt.getShort("RequiredPlayerRange");
    }

    if (nbt.hasKey("SpawnRange", 99))
    {
        this.spawnRange = nbt.getShort("SpawnRange");
    }

    if (this.getSpawnerWorld() != null)
    {
        this.cachedEntity = null;
    }
}
项目:CustomWorldGen    文件:MobSpawnerBaseLogic.java   
public void setNextSpawnData(WeightedSpawnerEntity p_184993_1_)
{
    this.randomEntity = p_184993_1_;
}