promotional bannermobile promotional banner
premium banner
# Mob Merger - Comprehensive Summary **Mob Merger** is a performance optimization mod for Fabric on Minecraft 1.20.1 (v1.0.9) that merges nearby farm mobs to reduce lag in massive farms while maintaining equivalent production.

Description

# Mob Merger - Comprehensive Summary

**Mob Merger** is a performance optimization mod for Fabric on Minecraft 1.20.1 (v1.0.9) that merges nearby farm mobs to reduce lag in massive farms while maintaining equivalent production.

## Core Functionality

- **Automatic Merging**: Combines farm mobs of the same type within a 5-block radius into a single entity with a counter
- **Mob Super-Stacking**: A single mob can represent up to 100 individual mobs
- **Performance Optimization**: Significantly reduces entity count, minimizing ticks, AABB checks, and rendering overhead

## Technical Parameters

- **Merge Radius**: 5.0 blocks
- **Merge Interval**: 20 ticks (1 second), staggered by entity ID
- **Max Merged Count**: 100 mobs per entity
- **Minimum Age for Merge**: 40 ticks (2 seconds) - allows prior detection by automated systems

## Key Features

### 1. **Realistic Death System**
- You must kill a merged mob as many times as its counter indicates
- Each "death" decrements the counter by 1, drops loot for 1 mob, and fully restores health
- Only when the counter reaches 1 does the mob die permanently
- Example: Mob with counter 10 = kill it 10 times to eliminate it

### 2. **Functional Breeding System**
- Merged mobs can breed normally
- Accumulates breeding food: every 2 foods = 1 baby
- When breeding, the merged mob's counter decrements based on babies born
- Automatic spawning of multiple babies according to accumulated food
- Equal distribution of decrements between both parents

### 3. **Scaled Production by Type**

#### **Chickens**
- Accelerate egg timer according to counter (up to 10x faster)
- When laying eggs, drop as many eggs as their counter indicates
- Additional egg-laying sounds

#### **Sheep**
- When sheared, drop wool multiplied by counter
- Random base amount (1-3) × counter
- Splits into stacks to avoid overflow (max 64 per stack)
- Correctly maintains wool color

#### **Cows**
- Can be milked normally
- Each use works the same as vanilla

#### **Pigs**
- Maintain normal behavior

### 4. **Jade Integration**
- Displays "Merged: X mobs" in tooltip when looking at a merged mob
- Client-server synchronization for accurate data

## Safety Exclusions

- ❌ Does NOT merge baby mobs
- ❌ Does NOT merge mobs during breeding (isInLove)
- ❌ Does NOT merge villagers (don't inherit from Animal)
- ❌ Does NOT merge bats (they are Ambient, not Animal)
- ✅ Allows merged mobs to breed after merging

## Supported Mobs

Any entity that inherits from `Animal`:
- ✅ Chickens, cows, pigs, sheep
- ✅ All vanilla farm animals
- ❌ Villagers and bats are automatically excluded

## Technical Implementation

### Code Structure

- **`IMergedMob`**: Interface for tracking merged mob counter and breeding food
- **`AnimalMixin`**: Main merging logic, breeding, and NBT persistence
- **`LivingEntityMixin`**: Multiple death system with loot drops
- **`ChickenMixin`**: Egg production acceleration
- **`SheepMixin`**: Wool multiplication when sheared
- **`CowMixin` & `PigMixin`**: Maintain normal behavior
- **`MergedMobProvider`**: Jade integration for tooltips

### Persistence

- Saves `MergedCount` and `BreedingFoodCount` to NBT
- Persists when saving/loading chunks

### Staggering

- Uses `(gameTime + entityID) % MERGE_INTERVAL` to distribute CPU load across ticks

## Use Cases

- Massive Create mod farms with hundreds of animals
- Lag reduction on servers with many automated farms
- Performance optimization without sacrificing gameplay mechanics
- Compatible with Create and other automation mods

## Configuration

Configurable values in `MobMerger.java`:
- `MERGE_RADIUS`: Search radius for merging (default: 5.0 blocks)
- `MERGE_INTERVAL`: Check frequency (default: 20 ticks = 1 second)
- `MAX_MERGED_COUNT`: Maximum mobs in one (default: 100)
- `MIN_AGE_FOR_MERGE`: Minimum age to merge (default: 40 ticks = 2 seconds)

## Compatibility

- Minecraft 1.20.1
- Fabric Loader 0.16.9+
- Fabric API 0.92.2+
- Jade (optional, for displaying information)
- Compatible with Create and other automation mods

## Supported Languages

- English (en_us)
- Spanish (es_es) available in assets

## Installation

1. Ensure you have Fabric Loader installed
2. Download the compiled .jar file
3. Place the file in your server/client `mods` folder
4. Restart the server/client

## Building

```bash
./gradlew build
```

The .jar file will be generated in `build/libs/`

## License

MIT License - See LICENSE file for more details

## Credits

Created by Julia  
Inspired by the Item Merger concept for Create farm optimization