consistency
This commit is contained in:
1 parent
a4d97b1875
commit
78739b3a2c
3 files changed
+53
-55
No files matched your search
@@ -9,17 +9,17 @@ import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.BoolArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
||||
import net.minecraft.command.arguments.BlockPosArgumentType;
|
||||
import net.minecraft.command.arguments.DimensionArgumentType;
|
||||
import net.minecraft.entity.EntityCategory;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.DyeColor;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.util.DyeColor;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.mojang.brigadier.arguments.IntegerArgumentType.getInteger;
|
||||
@@ -102,6 +102,16 @@ public class SpawnCommand
|
||||
dispatcher.register(literalargumentbuilder);
|
||||
}
|
||||
|
||||
private static EntityCategory getCategory(String string) throws CommandSyntaxException
|
||||
{
|
||||
if (!Arrays.stream(EntityCategory.values()).map(EntityCategory::getName).collect(Collectors.toSet()).contains(string))
|
||||
{
|
||||
throw new SimpleCommandExceptionType(Messenger.c("r Wrong mob type: "+string+" should be "+ Arrays.stream(EntityCategory.values()).map(EntityCategory::getName).collect(Collectors.joining(", ")))).create();
|
||||
}
|
||||
return EntityCategory.valueOf(string.toUpperCase());
|
||||
}
|
||||
|
||||
|
||||
private static int listSpawns(ServerCommandSource source, BlockPos pos)
|
||||
{
|
||||
Messenger.send(source, SpawnReporter.report(pos, source.getWorld()));
|
||||
@@ -153,14 +163,10 @@ public class SpawnCommand
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int recentSpawnsForType(ServerCommandSource source, String mob_type)
|
||||
private static int recentSpawnsForType(ServerCommandSource source, String mob_type) throws CommandSyntaxException
|
||||
{
|
||||
if (!Arrays.stream(EntityCategory.values()).map(EntityCategory::getName).collect(Collectors.toSet()).contains(mob_type))
|
||||
{
|
||||
Messenger.m(source, "r Wrong mob type: "+mob_type+" should be "+ Arrays.stream(EntityCategory.values()).map(EntityCategory::getName).collect(Collectors.joining(", ")));
|
||||
return 0;
|
||||
}
|
||||
Messenger.send(source, SpawnReporter.recent_spawns(source.getWorld(), EntityCategory.valueOf(mob_type.toUpperCase())));
|
||||
EntityCategory cat = getCategory(mob_type);
|
||||
Messenger.send(source, SpawnReporter.recent_spawns(source.getWorld(), cat));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -233,10 +239,10 @@ public class SpawnCommand
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int setSpawnRates(ServerCommandSource source, String mobtype, int rounds)
|
||||
private static int setSpawnRates(ServerCommandSource source, String mobtype, int rounds) throws CommandSyntaxException
|
||||
{
|
||||
String code = SpawnReporter.get_creature_code_from_string(mobtype);
|
||||
//SpawnReporter.spawn_tries.put(code, rounds);
|
||||
EntityCategory cat = getCategory(mobtype);
|
||||
SpawnReporter.spawn_tries.put(cat, rounds);
|
||||
Messenger.m(source, "gi "+mobtype+" mobs will now spawn "+rounds+" times per tick");
|
||||
return 1;
|
||||
}
|
||||
@@ -255,9 +261,10 @@ public class SpawnCommand
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int listEntitiesOfType(ServerCommandSource source, String mobtype)
|
||||
private static int listEntitiesOfType(ServerCommandSource source, String mobtype) throws CommandSyntaxException
|
||||
{
|
||||
Messenger.send(source, SpawnReporter.printEntitiesByType(EntityCategory.valueOf(mobtype.toUpperCase()), source.getWorld()));
|
||||
EntityCategory cat = getCategory(mobtype);
|
||||
Messenger.send(source, SpawnReporter.printEntitiesByType(cat, source.getWorld()));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.utils.SpawnReporter;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import net.minecraft.entity.EntityCategory;
|
||||
@@ -18,7 +17,6 @@ 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.ModifyConstant;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
@@ -97,7 +95,7 @@ public abstract class ServerChunkManagerMixin
|
||||
private int getNewMobcaps(EntityCategory entityCategory)
|
||||
{
|
||||
DimensionType dim = this.world.dimension.getType();
|
||||
int newCap = entityCategory.getSpawnCap()*(int)(Math.pow(2.0,(SpawnReporter.mobcap_exponent/4)));
|
||||
int newCap = (int) ((double)entityCategory.getSpawnCap()*(Math.pow(2.0,(SpawnReporter.mobcap_exponent/4))));
|
||||
if (SpawnReporter.track_spawns > 0L)
|
||||
{
|
||||
int int_2 = SpawnReporter.chunkCounts.get(dim); // eligible chunks for spawning
|
||||
|
||||
@@ -1,47 +1,37 @@
|
||||
|
||||
package carpet.utils;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.mixins.WeightedPickerEntryMixin;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2LongMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityCategory;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.SpawnRestriction;
|
||||
import net.minecraft.entity.SpawnType;
|
||||
import net.minecraft.entity.mob.MobEntity;
|
||||
import net.minecraft.server.world.ServerChunkManager;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.structure.OceanMonumentGenerator;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.entity.passive.OcelotEntity;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.DyeColor;
|
||||
|
||||
import net.minecraft.entity.EntityCategory;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import net.minecraft.world.SpawnHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.world.SpawnHelper;
|
||||
import net.minecraft.entity.SpawnRestriction;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
import net.minecraft.entity.passive.OcelotEntity;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.lang.Math;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
public class SpawnReporter
|
||||
{
|
||||
@@ -111,7 +101,7 @@ public class SpawnReporter
|
||||
for (EntityCategory enumcreaturetype : EntityCategory.values())
|
||||
{
|
||||
int cur = dimCounts.getOrDefault(enumcreaturetype, -1);
|
||||
int max = chunkcount * enumcreaturetype.getSpawnCap() / (int)Math.pow(17.0D, 2.0D); // from ServerChunkManager.CHUNKS_ELIGIBLE_FOR_SPAWNING
|
||||
int max = chunkcount * (int)((double)enumcreaturetype.getSpawnCap() * (Math.pow(2.0,(SpawnReporter.mobcap_exponent/4)))) / (int)Math.pow(17.0D, 2.0D); // from ServerChunkManager.CHUNKS_ELIGIBLE_FOR_SPAWNING
|
||||
String color = Messenger.heatmap_color(cur, max);
|
||||
String mobColor = Messenger.creatureTypeColor(enumcreaturetype);
|
||||
if (multiline)
|
||||
@@ -160,8 +150,10 @@ public class SpawnReporter
|
||||
for (Pair<EntityType, BlockPos> pair : spawned_mobs.get(Pair.of(world.getDimension().getType(),creature_type)).keySet())
|
||||
{
|
||||
lst.add( Messenger.c(
|
||||
String.format("w - %s ", Registry.ENTITY_TYPE.getId(pair.getLeft()).toString().replaceFirst("minecraft.","")),
|
||||
Messenger.tp("wb",pair.getRight())));
|
||||
"w - ",
|
||||
Messenger.tp("wb",pair.getRight()),
|
||||
String.format("w : %s", EntityType.getId(pair.getLeft()).toString().replaceFirst("minecraft.",""))
|
||||
));
|
||||
}
|
||||
|
||||
if (lst.size()==1)
|
||||
@@ -261,20 +253,21 @@ public class SpawnReporter
|
||||
return get_type_string(get_creature_type_from_code(str));
|
||||
}
|
||||
|
||||
public static List<BaseComponent> printEntitiesByType(EntityCategory type, World worldIn) //Class<?> entityType)
|
||||
public static List<BaseComponent> printEntitiesByType(EntityCategory cat, World worldIn) //Class<?> entityType)
|
||||
{
|
||||
CarpetSettings.LOG.error("\n\n\nprinting spawnlist\n\n\n");
|
||||
List<BaseComponent> lst = new ArrayList<>();
|
||||
Class<?> cls = type.getDeclaringClass();// getBaseClass();// getCreatureClass();
|
||||
lst.add( Messenger.s(String.format("Loaded entities for %s class:", get_type_string(type))));
|
||||
|
||||
lst.add(Messenger.s(" <sorry, this list will be populated, once M figures out what counts>"));
|
||||
for (Entity entity : ((ServerWorld)worldIn).getEntities(null, (e) -> e.getType().getCategory()==type))
|
||||
lst.add( Messenger.s(String.format("Loaded entities for %s class:", get_type_string(cat))));
|
||||
for (Entity entity : ((ServerWorld)worldIn).getEntities(null, (e) -> e.getType().getCategory()==cat))
|
||||
{
|
||||
if (!(entity instanceof MobEntity) || !((MobEntity)entity).isPersistent())
|
||||
{
|
||||
lst.add(Messenger.c("w - ",
|
||||
Messenger.tp("w", entity.x, entity.y, entity.z),"w : "+EntityType.getId(entity.getType()).toString().replaceFirst("minecraft.","")));
|
||||
EntityType type = entity.getType();
|
||||
BlockPos pos = entity.getBlockPos();
|
||||
lst.add( Messenger.c(
|
||||
"w - ",
|
||||
Messenger.tp("wb",pos),
|
||||
String.format("w : %s", EntityType.getId(type).toString().replaceFirst("minecraft.",""))
|
||||
));
|
||||
}
|
||||
}
|
||||
if (lst.size()==1)
|
||||
|
||||
Reference in new issue
Block a user