This commit is contained in:
gnembon committed 2020-05-10 01:42:19 -03:00
1 parent 566515d0c3
commit ae0975d626
20 files changed
+130 -134

No files matched your search

+7 -4
View File
@@ -1,8 +1,11 @@
package carpet.utils;
import net.minecraft.block.*;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.block.MaterialColor;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnType;
import net.minecraft.entity.SpawnReason;
import net.minecraft.entity.ai.TargetFinder;
import net.minecraft.entity.ai.goal.WanderAroundGoal;
import net.minecraft.entity.ai.pathing.NavigationType;
@@ -57,7 +60,7 @@ public class BlockInfo
put(BlockSoundGroup.BASALT, "basalt");
put(BlockSoundGroup.WART_BLOCK, "wart");
put(BlockSoundGroup.NETHERRACK, "netherrack");
put(BlockSoundGroup.NETHER_BRICK, "nether_bricks");
put(BlockSoundGroup.NETHER_BRICKS, "nether_bricks");
put(BlockSoundGroup.NETHER_SPROUTS, "nether_sprouts");
put(BlockSoundGroup.NETHER_ORE, "nether_ore");
put(BlockSoundGroup.BONE, "bone");
@@ -220,7 +223,7 @@ public class BlockInfo
private static BaseText wander_chances(BlockPos pos, World worldIn)
{
MobEntityWithAi creature = new ZombifiedPiglinEntity(EntityType.ZOMBIFIED_PIGLIN, worldIn);
creature.initialize(worldIn, worldIn.getLocalDifficulty(pos), SpawnType.NATURAL, null, null);
creature.initialize(worldIn, worldIn.getLocalDifficulty(pos), SpawnReason.NATURAL, null, null);
creature.refreshPositionAndAngles(pos, 0.0F, 0.0F);
WanderAroundGoal wander = new WanderAroundGoal(creature, 0.8D);
int success = 0;
+2 -2
View File
@@ -1,7 +1,7 @@
package carpet.utils;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.entity.EntityCategory;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.BaseText;
import net.minecraft.text.ClickEvent;
@@ -100,7 +100,7 @@ public class Messenger
if (actual > reference) color = "m";
return color;
}
public static String creatureTypeColor(EntityCategory type)
public static String creatureTypeColor(SpawnGroup type)
{
switch (type)
{
@@ -4,9 +4,9 @@ import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.block.Material;
import net.minecraft.block.BlockState;
import net.minecraft.entity.EntityCategory;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.entity.SpawnRestriction;
import net.minecraft.entity.SpawnType;
import net.minecraft.entity.SpawnReason;
import net.minecraft.entity.mob.WaterCreatureEntity;
import net.minecraft.entity.mob.AmbientEntity;
import net.minecraft.entity.mob.MobEntity;
@@ -35,9 +35,9 @@ public class PerimeterDiagnostics
}
private Biome.SpawnEntry sle;
private ServerWorld worldServer;
private EntityCategory ctype;
private SpawnGroup ctype;
private MobEntity el;
private PerimeterDiagnostics(ServerWorld server, EntityCategory ctype, MobEntity el)
private PerimeterDiagnostics(ServerWorld server, SpawnGroup ctype, MobEntity el)
{
this.sle = null;
this.worldServer = server;
@@ -60,28 +60,28 @@ public class PerimeterDiagnostics
//int specific_spawns = 0;
boolean add_water = false;
boolean add_ground = false;
EntityCategory ctype = null;
SpawnGroup ctype = null;
if (el != null)
{
if (el instanceof WaterCreatureEntity)
{
add_water = true;
ctype = EntityCategory.WATER_CREATURE;
ctype = SpawnGroup.WATER_CREATURE;
}
else if (el instanceof PassiveEntity)
{
add_ground = true;
ctype = EntityCategory.CREATURE;
ctype = SpawnGroup.CREATURE;
}
else if (el instanceof Monster)
{
add_ground = true;
ctype = EntityCategory.MONSTER;
ctype = SpawnGroup.MONSTER;
}
else if (el instanceof AmbientEntity)
{
ctype = EntityCategory.AMBIENT;
ctype = SpawnGroup.AMBIENT;
}
}
PerimeterDiagnostics diagnostic = new PerimeterDiagnostics(worldserver,ctype,el);
@@ -177,8 +177,8 @@ public class PerimeterDiagnostics
if (SpawnHelper.canSpawn(spt, worldServer, pos, sle.type))
{
el.refreshPositionAndAngles((float)pos.getX() + 0.5F, (float)pos.getY(), (float)pos.getZ()+0.5F, 0.0F, 0.0F);
return el.canSpawn(worldServer) && el.canSpawn(worldServer, SpawnType.NATURAL) &&
SpawnRestriction.canSpawn(el.getType(),el.getEntityWorld(), SpawnType.NATURAL, el.getBlockPos(), el.getEntityWorld().random) &&
return el.canSpawn(worldServer) && el.canSpawn(worldServer, SpawnReason.NATURAL) &&
SpawnRestriction.canSpawn(el.getType(),el.getEntityWorld(), SpawnReason.NATURAL, el.getBlockPos(), el.getEntityWorld().random) &&
worldServer.doesNotCollide(el); // check collision rules once they stop fiddling with them after 1.14.1
}
return false;
+44 -44
View File
@@ -6,11 +6,11 @@ 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.SpawnGroup;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.SpawnRestriction;
import net.minecraft.entity.SpawnType;
import net.minecraft.entity.SpawnReason;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.passive.OcelotEntity;
import net.minecraft.text.BaseText;
@@ -39,29 +39,29 @@ public class SpawnReporter
public static Long track_spawns = 0L;
public static final HashMap<DimensionType, Integer> chunkCounts = new HashMap<>();
public static final HashMap<Pair<DimensionType, EntityCategory>, Object2LongMap<EntityType>> spawn_stats = new HashMap<>();
public static final HashMap<Pair<DimensionType, SpawnGroup>, Object2LongMap<EntityType>> spawn_stats = new HashMap<>();
public static double mobcap_exponent = 0.0D;
public static final HashMap<Pair<DimensionType, EntityCategory>, Long> spawn_attempts = new HashMap<>();
public static final HashMap<Pair<DimensionType, EntityCategory>, Long> overall_spawn_ticks = new HashMap<>();
public static final HashMap<Pair<DimensionType, EntityCategory>, Long> spawn_ticks_full = new HashMap<>();
public static final HashMap<Pair<DimensionType, EntityCategory>, Long> spawn_ticks_fail = new HashMap<>();
public static final HashMap<Pair<DimensionType, EntityCategory>, Long> spawn_ticks_succ = new HashMap<>();
public static final HashMap<Pair<DimensionType, EntityCategory>, Long> spawn_ticks_spawns = new HashMap<>();
public static final HashMap<Pair<DimensionType, EntityCategory>, Long> spawn_cap_count = new HashMap<>();
public static final HashMap<Pair<DimensionType, EntityCategory>, EvictingQueue<Pair<EntityType, BlockPos>>> spawned_mobs = new HashMap<>();
public static final HashMap<EntityCategory, Integer> spawn_tries = new HashMap<>();
public static final HashMap<Pair<DimensionType, SpawnGroup>, Long> spawn_attempts = new HashMap<>();
public static final HashMap<Pair<DimensionType, SpawnGroup>, Long> overall_spawn_ticks = new HashMap<>();
public static final HashMap<Pair<DimensionType, SpawnGroup>, Long> spawn_ticks_full = new HashMap<>();
public static final HashMap<Pair<DimensionType, SpawnGroup>, Long> spawn_ticks_fail = new HashMap<>();
public static final HashMap<Pair<DimensionType, SpawnGroup>, Long> spawn_ticks_succ = new HashMap<>();
public static final HashMap<Pair<DimensionType, SpawnGroup>, Long> spawn_ticks_spawns = new HashMap<>();
public static final HashMap<Pair<DimensionType, SpawnGroup>, Long> spawn_cap_count = new HashMap<>();
public static final HashMap<Pair<DimensionType, SpawnGroup>, EvictingQueue<Pair<EntityType, BlockPos>>> spawned_mobs = new HashMap<>();
public static final HashMap<SpawnGroup, Integer> spawn_tries = new HashMap<>();
public static BlockPos lower_spawning_limit = null;
public static BlockPos upper_spawning_limit = null;
// in case game gets each thread for each world - these need to belong to workd.
public static HashMap<EntityCategory, Long> local_spawns = null; // per world
public static HashSet<EntityCategory> first_chunk_marker = null;
public static HashMap<SpawnGroup, Long> local_spawns = null; // per world
public static HashSet<SpawnGroup> first_chunk_marker = null;
static {
reset_spawn_stats(true);
}
public static void registerSpawn(DimensionType dim, MobEntity mob, EntityCategory cat, BlockPos pos)
public static void registerSpawn(DimensionType dim, MobEntity mob, SpawnGroup cat, BlockPos pos)
{
if (lower_spawning_limit != null)
{
@@ -73,7 +73,7 @@ public class SpawnReporter
return;
}
}
Pair<DimensionType, EntityCategory> key = Pair.of(mob.dimension, cat);
Pair<DimensionType, SpawnGroup> key = Pair.of(mob.dimension, cat);
long count = spawn_stats.get(key).getOrDefault(mob.getType(), 0L);
spawn_stats.get(key).put(mob.getType(), count + 1);
spawned_mobs.get(key).put(Pair.of(mob.getType(), pos));
@@ -89,7 +89,7 @@ public class SpawnReporter
if (multiline)
lst.add(Messenger.s(String.format("Mobcaps for %s:",name)));
SpawnHelper.Info lastSpawner = world.getChunkManager().getSpawnInfo();
Object2IntMap<EntityCategory> dimCounts = lastSpawner.getCategoryToCount();
Object2IntMap<SpawnGroup> dimCounts = lastSpawner.getGroupToCount();
int chunkcount = chunkCounts.getOrDefault(dim, -1);
if (dimCounts == null || chunkcount < 0)
{
@@ -98,10 +98,10 @@ public class SpawnReporter
}
List<String> shortCodes = new ArrayList<>();
for (EntityCategory enumcreaturetype : EntityCategory.values())
for (SpawnGroup enumcreaturetype : SpawnGroup.values())
{
int cur = dimCounts.getOrDefault(enumcreaturetype, -1);
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
int max = chunkcount * (int)((double)enumcreaturetype.getCapacity() * (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)
@@ -136,7 +136,7 @@ public class SpawnReporter
return lst;
}
public static List<BaseText> recent_spawns(World world, EntityCategory creature_type)
public static List<BaseText> recent_spawns(World world, SpawnGroup creature_type)
{
List<BaseText> lst = new ArrayList<>();
if ((track_spawns == 0L))
@@ -178,7 +178,7 @@ public class SpawnReporter
return printMobcapsForDimension(worldIn, true );
}
}
EntityCategory creature_type = get_type_code_from_wool_code(under);
SpawnGroup creature_type = get_type_code_from_wool_code(under);
if (creature_type != null)
{
if (track_spawns > 0L)
@@ -203,51 +203,51 @@ public class SpawnReporter
}
public static EntityCategory get_type_code_from_wool_code(DyeColor color)
public static SpawnGroup get_type_code_from_wool_code(DyeColor color)
{
switch (color)
{
case RED:
return EntityCategory.MONSTER;
return SpawnGroup.MONSTER;
case GREEN:
return EntityCategory.CREATURE;
return SpawnGroup.CREATURE;
case BLUE:
return EntityCategory.WATER_CREATURE;
return SpawnGroup.WATER_CREATURE;
case BROWN:
return EntityCategory.AMBIENT;
return SpawnGroup.AMBIENT;
case CYAN:
return EntityCategory.WATER_AMBIENT;
return SpawnGroup.WATER_AMBIENT;
}
return null;
}
public static EntityCategory get_creature_type_from_code(String type_code)
public static SpawnGroup get_creature_type_from_code(String type_code)
{
if ("hostile".equalsIgnoreCase(type_code))
{
return EntityCategory.MONSTER;
return SpawnGroup.MONSTER;
}
else if ("passive".equalsIgnoreCase(type_code))
{
return EntityCategory.CREATURE;
return SpawnGroup.CREATURE;
}
else if ("water".equalsIgnoreCase(type_code))
{
return EntityCategory.WATER_CREATURE;
return SpawnGroup.WATER_CREATURE;
}
else if ("fish".equalsIgnoreCase(type_code))
{
return EntityCategory.WATER_AMBIENT;
return SpawnGroup.WATER_AMBIENT;
}
else if ("ambient".equalsIgnoreCase(type_code))
{
return EntityCategory.AMBIENT;
return SpawnGroup.AMBIENT;
}
return null;
}
public static String get_type_string(EntityCategory type)
public static String get_type_string(SpawnGroup type)
{
return String.format("%s", type);
}
@@ -257,11 +257,11 @@ public class SpawnReporter
return get_type_string(get_creature_type_from_code(str));
}
public static List<BaseText> printEntitiesByType(EntityCategory cat, World worldIn) //Class<?> entityType)
public static List<BaseText> printEntitiesByType(SpawnGroup cat, World worldIn) //Class<?> entityType)
{
List<BaseText> lst = new ArrayList<>();
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))
for (Entity entity : ((ServerWorld)worldIn).getEntities(null, (e) -> e.getType().getSpawnGroup()==cat))
{
if (!(entity instanceof MobEntity) || !((MobEntity)entity).isPersistent())
{
@@ -295,7 +295,7 @@ public class SpawnReporter
spawn_stats.clear();
spawned_mobs.clear();
for (EntityCategory enumcreaturetype : EntityCategory.values())
for (SpawnGroup enumcreaturetype : SpawnGroup.values())
{
if (full)
{
@@ -303,7 +303,7 @@ public class SpawnReporter
}
for (DimensionType dim : DimensionType.getAll())
{
Pair<DimensionType, EntityCategory> key = Pair.of(dim, enumcreaturetype);
Pair<DimensionType, SpawnGroup> key = Pair.of(dim, enumcreaturetype);
overall_spawn_ticks.put(key, 0L);
spawn_attempts.put(key, 0L);
spawn_ticks_full.put(key, 0L);
@@ -337,13 +337,13 @@ public class SpawnReporter
lower_spawning_limit.getX(),lower_spawning_limit.getY(),lower_spawning_limit.getZ(),
upper_spawning_limit.getX(),upper_spawning_limit.getY(),upper_spawning_limit.getZ() ):"";
report.add(Messenger.s(String.format("%sSpawn statistics %s: for %.1f min", simulated, location, (duration/72000.0)*60)));
for (EntityCategory enumcreaturetype : EntityCategory.values())
for (SpawnGroup enumcreaturetype : SpawnGroup.values())
{
//String type_code = String.format("%s", enumcreaturetype);
boolean there_are_mobs_to_list = false;
for (DimensionType dim: DimensionType.getAll()) //String world_code: new String[] {"", " (N)", " (E)"})
{
Pair<DimensionType, EntityCategory> code = Pair.of(dim, enumcreaturetype);
Pair<DimensionType, SpawnGroup> code = Pair.of(dim, enumcreaturetype);
if (spawn_ticks_spawns.get(code) > 0L)
{
there_are_mobs_to_list = true;
@@ -405,7 +405,7 @@ public class SpawnReporter
if (y == lc) where = "right at it.";
rep.add(Messenger.s(String.format("Maximum spawn Y value for (%+d, %+d) is %d. You are "+where, x, z, lc )));
rep.add(Messenger.s("Spawns:"));
for (EntityCategory enumcreaturetype : EntityCategory.values())
for (SpawnGroup enumcreaturetype : SpawnGroup.values())
{
String type_code = String.format("%s", enumcreaturetype).substring(0, 3);
List<Biome.SpawnEntry> lst = ((ChunkGenerator)worldIn.getChunkManager().getChunkGenerator()).getEntitySpawnList(worldIn.getStructureAccessor(), enumcreaturetype, pos);
@@ -448,15 +448,15 @@ public class SpawnReporter
for (int i = 0; i < 20; ++i)
{
if (
SpawnRestriction.canSpawn(etype,worldIn, SpawnType.NATURAL, pos, worldIn.random) &&
SpawnRestriction.canSpawn(etype,worldIn, SpawnReason.NATURAL, pos, worldIn.random) &&
SpawnHelper.canSpawn(SpawnRestriction.getLocation(etype), worldIn, pos, etype) &&
mob.canSpawn(worldIn, SpawnType.NATURAL) // && mob.canSpawn(worldIn) // entity collisions
mob.canSpawn(worldIn, SpawnReason.NATURAL) // && mob.canSpawn(worldIn) // entity collisions
)
{
will_spawn += 1;
}
}
mob.initialize(worldIn, worldIn.getLocalDifficulty(mob.getBlockPos()), SpawnType.NATURAL, null, null);
mob.initialize(worldIn, worldIn.getLocalDifficulty(mob.getBlockPos()), SpawnReason.NATURAL, null, null);
// the code invokes onInitialSpawn after getCanSpawHere
fits = fits1 && worldIn.doesNotCollide(mob);
if (fits)
+2 -2
View File
@@ -51,10 +51,10 @@ public class WoolTool
{
ServerCommandSource source = placer.getCommandSource();
if (!DistanceCalculator.hasStartingPoint(source) || placer.isSneaking()) {
DistanceCalculator.setStart(source, Vec3d.method_24954(pos) ); // zero padded pos
DistanceCalculator.setStart(source, Vec3d.of(pos) ); // zero padded pos
}
else {
DistanceCalculator.setEnd(source, Vec3d.method_24954(pos));
DistanceCalculator.setEnd(source, Vec3d.of(pos));
}
}
break;