From d4a8665a6a2321e158145b5a867816cb02b19e62 Mon Sep 17 00:00:00 2001 From: Will FP Date: Mon, 4 Mar 2024 18:36:38 +0000 Subject: [PATCH] Added chance option to replace --- .../category/spawning/impl/SpawnMethodFactoryReplace.kt | 5 +++++ .../core-plugin/src/main/resources/categories/_example.yml | 3 +++ 2 files changed, 8 insertions(+) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecomobs/category/spawning/impl/SpawnMethodFactoryReplace.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecomobs/category/spawning/impl/SpawnMethodFactoryReplace.kt index bcbcf8c..1b86ed4 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecomobs/category/spawning/impl/SpawnMethodFactoryReplace.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecomobs/category/spawning/impl/SpawnMethodFactoryReplace.kt @@ -2,6 +2,7 @@ package com.willfp.ecomobs.category.spawning.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.entities.Entities +import com.willfp.eco.util.randDouble import com.willfp.ecomobs.EcoMobsPlugin import com.willfp.ecomobs.category.MobCategory import com.willfp.ecomobs.category.spawning.SpawnMethod @@ -57,6 +58,10 @@ object SpawnMethodFactoryReplace : SpawnMethodFactory("replace") { return } + if (randDouble(0.0, 100.0) > config.getDouble("chance")) { + return + } + val mob = category.mobs.randomOrNull() ?: return diff --git a/eco-core/core-plugin/src/main/resources/categories/_example.yml b/eco-core/core-plugin/src/main/resources/categories/_example.yml index 2b37bff..f13c6c3 100644 --- a/eco-core/core-plugin/src/main/resources/categories/_example.yml +++ b/eco-core/core-plugin/src/main/resources/categories/_example.yml @@ -26,6 +26,9 @@ spawning: - zombie - skeleton + # The chance for the mob to override, as a percentage + chance: 100 + # Options for custom spawning custom: