1.18 exp 3. Changes to custom mobcap.
This commit is contained in:
1 parent
783f3f49f0
commit
77aa52dc0e
11 files changed
+53
-16
No files matched your search
+2
-2
@@ -10,8 +10,8 @@ archivesBaseName = project.archives_base_name
|
||||
version = project.minecraft_version+'-'+project.mod_version+'+v'+new Date().format('yyMMdd')
|
||||
group = project.maven_group
|
||||
|
||||
minecraft {
|
||||
accessWidener "src/main/resources/carpet.accesswidener"
|
||||
loom {
|
||||
accessWidenerPath = file("src/main/resources/carpet.accesswidener")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
+2
-2
@@ -4,8 +4,8 @@ org.gradle.jvmargs=-Xmx1G
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/use
|
||||
# or better: https://modmuss50.me/fabric.html
|
||||
minecraft_version=1.18_experimental-snapshot-2
|
||||
yarn_mappings=1.18_experimental-snapshot-2+build.3
|
||||
minecraft_version=1.18_experimental-snapshot-3
|
||||
yarn_mappings=1.18_experimental-snapshot-3+build.1
|
||||
loader_version=0.11.6
|
||||
fabric_version=0.37.2+1.18_experimental
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package carpet.commands;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.fakes.SpawnGroupInterface;
|
||||
import carpet.helpers.HopperCounter;
|
||||
import carpet.helpers.TickSpeed;
|
||||
import carpet.settings.SettingsManager;
|
||||
@@ -251,7 +252,7 @@ public class SpawnCommand
|
||||
|
||||
private static int setMobcaps(ServerCommandSource source, int hostile_cap)
|
||||
{
|
||||
double desired_ratio = (double)hostile_cap/ SpawnGroup.MONSTER.getCapacity();
|
||||
double desired_ratio = (double)hostile_cap/ ((SpawnGroupInterface)(Object)SpawnGroup.MONSTER).getInitialSpawnCap();
|
||||
SpawnReporter.mobcap_exponent = 4.0*Math.log(desired_ratio)/Math.log(2.0);
|
||||
Messenger.m(source, String.format("gi Mobcaps for hostile mobs changed to %d, other groups will follow", hostile_cap));
|
||||
return 1;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package carpet.fakes;
|
||||
|
||||
public interface SpawnGroupInterface
|
||||
{
|
||||
int getInitialSpawnCap();
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -52,7 +52,7 @@ public class Monitoring {
|
||||
Map<Value, Value> retDict = new HashMap<>();
|
||||
for (SpawnGroup category: mobcounts.keySet())
|
||||
{
|
||||
int currentCap = (int)(category.getCapacity() * chunks / SpawnReporter.currentMagicNumber()); // MAGIC_NUMBER
|
||||
int currentCap = (int)(category.getCapacity() * chunks / SpawnReporter.MAGIC_NUMBER);
|
||||
retDict.put(
|
||||
new StringValue(category.asString().toLowerCase(Locale.ROOT)),
|
||||
ListValue.of(
|
||||
@@ -67,7 +67,7 @@ public class Monitoring {
|
||||
if (cat == null) throw new InternalExpressionException("Unreconized mob category: "+catString);
|
||||
return ListValue.of(
|
||||
new NumericValue(mobcounts.getInt(cat)),
|
||||
new NumericValue((int)(cat.getCapacity() * chunks / SpawnReporter.currentMagicNumber()))
|
||||
new NumericValue((int)(cat.getCapacity() * chunks / SpawnReporter.MAGIC_NUMBER))
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public class WorldTools
|
||||
//chunkGenerator2 = GeneratorOptions.createOverworldGenerator(server.getRegistryManager().get(Registry.BIOME_KEY), server.getRegistryManager().get(Registry.NOISE_SETTINGS_WORLDGEN), (seed==null)?l:seed);
|
||||
|
||||
// from world/gen/GeneratorOptions
|
||||
chunkGenerator2 = new NoiseChunkGenerator(MultiNoiseBiomeSource.method_35242(server.getRegistryManager().get(Registry.BIOME_KEY), seed), seed, () -> {
|
||||
chunkGenerator2 = new NoiseChunkGenerator(MultiNoiseBiomeSource.createVanillaSource(server.getRegistryManager().get(Registry.BIOME_KEY), seed), seed, () -> {
|
||||
return server.getRegistryManager().get(Registry.CHUNK_GENERATOR_SETTINGS_KEY).getOrThrow(ChunkGeneratorSettings.OVERWORLD);
|
||||
});
|
||||
|
||||
|
||||
@@ -95,10 +95,10 @@ public class SpawnReporter
|
||||
}
|
||||
|
||||
public static final int MAGIC_NUMBER = (int)Math.pow(17.0D, 2.0D);
|
||||
public static double currentMagicNumber()
|
||||
/*public static double currentMagicNumber()
|
||||
{
|
||||
return MAGIC_NUMBER / (Math.pow(2.0,(SpawnReporter.mobcap_exponent/4)));
|
||||
}
|
||||
}*/
|
||||
|
||||
public static List<BaseText> printMobcapsForDimension(ServerWorld world, boolean multiline)
|
||||
{
|
||||
@@ -120,7 +120,7 @@ public class SpawnReporter
|
||||
for (SpawnGroup enumcreaturetype : SpawnGroup.values())
|
||||
{
|
||||
int cur = dimCounts.getOrDefault(enumcreaturetype, -1);
|
||||
int max = (int)(chunkcount * ((double)enumcreaturetype.getCapacity() / currentMagicNumber())); // from ServerChunkManager.CHUNKS_ELIGIBLE_FOR_SPAWNING
|
||||
int max = (int)(chunkcount * ((double)enumcreaturetype.getCapacity() / MAGIC_NUMBER)); // from ServerChunkManager.CHUNKS_ELIGIBLE_FOR_SPAWNING
|
||||
String color = Messenger.heatmap_color(cur, max);
|
||||
String mobColor = Messenger.creatureTypeColor(enumcreaturetype);
|
||||
if (multiline)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
"BarrierBlock_updateSuppressionBlockMixin",
|
||||
|
||||
"SpawnHelperInnerMixin",
|
||||
"SpawnGroup_spawnMixin",
|
||||
"CommandManagerMixin",
|
||||
|
||||
"ServerPlayNetworkHandlerMixin",
|
||||
|
||||
Reference in new issue
Block a user