1.18 exp 3. Changes to custom mobcap.

This commit is contained in:
gnembon committed 2021-08-11 17:04:56 -03:00
1 parent 783f3f49f0
commit 77aa52dc0e
11 files changed
+53 -16

No files matched your search

@@ -0,0 +1,29 @@
package carpet.mixins;
import carpet.fakes.SpawnGroupInterface;
import carpet.utils.SpawnReporter;
import net.minecraft.entity.SpawnGroup;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(SpawnGroup.class)
public class SpawnGroup_spawnMixin implements SpawnGroupInterface
{
@Shadow @Final private int capacity;
@Inject(method = "getCapacity", at = @At("HEAD"), cancellable = true)
private void getModifiedCapacity(CallbackInfoReturnable<Integer> cir)
{
cir.setReturnValue ((int) ((double)capacity*(Math.pow(2.0,(SpawnReporter.mobcap_exponent/4)))));
}
@Override
public int getInitialSpawnCap()
{
return capacity;
}
}
@@ -20,15 +20,15 @@ public class SpawnHelperInnerMixin implements SpawnHelperInnerInterface
@Shadow @Final private GravityField densityField;
@Shadow @Final private Object2IntOpenHashMap<SpawnGroup> groupToCount;
//@Shadow @Final private Object2IntOpenHashMap<SpawnGroup> groupToCount;
@Inject(method = "isBelowCap", at = @At("HEAD"), cancellable = true)
/*@Inject(method = "isBelowCap", at = @At("HEAD"), cancellable = true)
private void changeMobCaps(SpawnGroup entityCategory, CallbackInfoReturnable<Boolean> cir)
{
int newCap = (int) ((double)entityCategory.getCapacity()*(Math.pow(2.0,(SpawnReporter.mobcap_exponent/4))));
int i = newCap * spawningChunkCount / SpawnReporter.MAGIC_NUMBER;
cir.setReturnValue(groupToCount.getInt(entityCategory) < i);
}
}*/
@@ -282,7 +282,7 @@ public class SpawnHelperMixin
if ((spawnAnimals || !entityCategory.isPeaceful()) && (spawnMonsters || entityCategory.isPeaceful()) && (shouldSpawnAnimals || !entityCategory.isRare()) )
{
RegistryKey<World> dim = world.getRegistryKey(); // getDimensionType;
int newCap = (int) ((double)entityCategory.getCapacity()*(Math.pow(2.0,(SpawnReporter.mobcap_exponent/4))));
int newCap = entityCategory.getCapacity(); //(int) ((double)entityCategory.getCapacity()*(Math.pow(2.0,(SpawnReporter.mobcap_exponent/4))));
int int_2 = SpawnReporter.chunkCounts.get(dim); // eligible chunks for spawning
int int_3 = newCap * int_2 / CHUNK_AREA; //current spawning limits
int mobCount = info.getGroupToCount().getInt(entityCategory);
@@ -303,7 +303,7 @@ public class SpawnHelperMixin
SpawnReporter.spawn_cap_count.get(key) + mobCount);
}
if (mobCount <= int_3 || SpawnReporter.mock_spawns)
if (mobCount <= int_3 || SpawnReporter.mock_spawns) //TODO this will not float with player based mobcaps
{
//place 0 to indicate there were spawn attempts for a category
//if (entityCategory != EntityCategory.CREATURE || world.getServer().getTicks() % 400 == 0)