Skip to content

Conversation

@illyrius666
Copy link
Member

@illyrius666 illyrius666 commented Jan 8, 2026

Description

How Has This Been Tested?

  • Unit tests
  • Integration tests
  • Manual testing
  • Other (please describe)

Signed-off-by: Illyrius <FitimQ@live.nl>
@illyrius666 illyrius666 self-assigned this Jan 8, 2026
@github-actions github-actions bot changed the title Feat/entity module/random animal sizes feat/EntityModule/RandomAnimalSizes Jan 8, 2026
@github-actions github-actions bot changed the base branch from main to dev January 8, 2026 07:47
illyrius666 and others added 8 commits January 8, 2026 08:47
…tion

Signed-off-by: Illyrius <fitimq@live.nl>
+
Signed-off-by: Illyrius <fitimq@live.nl>
+
Signed-off-by: Illyrius <fitimq@live.nl>
…nsistency

Signed-off-by: Illyrius <fitimq@live.nl>
@illyrius666 illyrius666 marked this pull request as ready for review January 8, 2026 09:15
Copilot AI review requested due to automatic review settings January 8, 2026 09:15
@illyrius666 illyrius666 merged commit 50ecca4 into dev Jan 8, 2026
1 check passed
@illyrius666 illyrius666 deleted the feat/EntityModule/RandomAnimalSizes branch January 8, 2026 09:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a feature to randomize the scale/size of spawning entities (animals, monsters, and villagers) based on configurable ranges. The implementation adds a reusable Range data class and integrates with the existing EntityModule configuration system.

Key changes:

  • Adds a serializable Range data class with min/max validation
  • Implements random entity scaling via EntitySpawnEvent handler
  • Adds three configurable scale ranges for different entity types

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 6 comments.

File Description
src/main/kotlin/org/xodium/vanillaplus/utils/Utils.kt Adds a serializable Range data class with validation to represent min/max numerical ranges
src/main/kotlin/org/xodium/vanillaplus/modules/EntityModule.kt Implements entity scale randomization, adds event handler for EntitySpawnEvent, updates config with scale ranges, and changes egg drop chance default
.idea/dictionaries/project.xml Adds "slenderman" to the project dictionary
Files not reviewed (1)
  • .idea/dictionaries/project.xml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +67 to +84
private fun randomizeEntityScale(entity: Entity) {
when (entity) {
is Animals -> {
val range = config.entityModule.animalScaleRange ?: return
entity.getAttribute(Attribute.SCALE)?.baseValue = Random.nextDouble(range.min, range.max)
}

is Monster -> {
val range = config.entityModule.monsterScaleRange ?: return
entity.getAttribute(Attribute.SCALE)?.baseValue = Random.nextDouble(range.min, range.max)
}

is Villager -> {
val range = config.entityModule.villagerScaleRange ?: return
entity.getAttribute(Attribute.SCALE)?.baseValue = Random.nextDouble(range.min, range.max)
}
}
}
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The randomizeEntityScale function should check if the module is enabled before applying changes. Other event handlers in the codebase follow the pattern of early returns based on config flags. Consider adding a check for the module's enabled state or individual config flags for each entity type's scale randomization.

Copilot uses AI. Check for mistakes.
var disableGhastGrief: Boolean = true,
var disableWitherGrief: Boolean = true,
var entityEggDropChance: Double = 0.1,
var entityEggDropChance: Double = 0.001,
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The entityEggDropChance has been changed from 0.1 (10%) to 0.001 (0.1%), which is a significant behavioral change unrelated to the random animal sizes feature. This change should either be reverted or explained in a separate commit/PR focused on egg drop mechanics.

Suggested change
var entityEggDropChance: Double = 0.001,
var entityEggDropChance: Double = 0.1,

Copilot uses AI. Check for mistakes.
<w>searchinv</w>
<w>shulker</w>
<w>signedit</w>
<w>slenderman</w>
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The addition of "slenderman" to the dictionary appears unrelated to the random animal sizes feature introduced in this PR. This dictionary entry should be removed or explained if it relates to a different change.

Suggested change
<w>slenderman</w>

Copilot uses AI. Check for mistakes.
Comment on lines +43 to +44
@EventHandler
fun on(event: EntitySpawnEvent) = randomizeEntityScale(event.entity)
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The EntitySpawnEvent fires for every entity spawn in the game, including projectiles, items, experience orbs, etc. The current implementation already handles this with early returns when the entity type doesn't match (Animals, Monster, or Villager), but consider adding documentation or a comment explaining this to clarify the performance characteristics of this event handler.

Copilot uses AI. Check for mistakes.
val max: Double,
) {
init {
require(min <= max) { "min must be less than or equal to max" }
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Range validation should also check for non-finite values (NaN and infinity). The current check only validates that min is less than or equal to max, but does not prevent invalid Double values such as Double.NaN or Double.POSITIVE_INFINITY, which could cause issues when used with Random.nextDouble.

Suggested change
require(min <= max) { "min must be less than or equal to max" }
require(min.isFinite() && max.isFinite() && min <= max) {
"min and max must be finite and min must be less than or equal to max"
}

Copilot uses AI. Check for mistakes.
var disableWitherGrief: Boolean = true,
var entityEggDropChance: Double = 0.1,
var entityEggDropChance: Double = 0.001,
var animalScaleRange: Utils.Range? = Utils.Range(0.8, 1.2),
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The monsterScaleRange default of 0.9 to 1.9 allows monsters to spawn up to 1.9x their normal size, which could create significant gameplay impact (hitboxes, visibility, balance). Consider documenting this range or adding validation to ensure reasonable limits, or provide a comment explaining the intended gameplay impact of these values.

Suggested change
var animalScaleRange: Utils.Range? = Utils.Range(0.8, 1.2),
var animalScaleRange: Utils.Range? = Utils.Range(0.8, 1.2),
/**
* Random scale range for hostile mobs.
*
* The default range of 0.91.9 intentionally allows monsters to spawn
* noticeably smaller or larger than normal (up to just under 2x size),
* which affects hitboxes, visibility, and combat difficulty. Values
* significantly higher than ~2.0 are not recommended as they may
* lead to extreme hitboxes or balance issues depending on the mob.
*/

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants