Merge branch 'master' into 1.16
# Conflicts: # src/main/java/carpet/commands/SpawnCommand.java # src/main/java/carpet/utils/SpawnReporter.java
This commit is contained in:
commit
5a746cc3c4
2 files changed
+18
-15
No files matched your search
@@ -98,7 +98,8 @@ public class SpawnCommand
|
|||||||
executes( (c) -> generalMobcaps(c.getSource()) ).
|
executes( (c) -> generalMobcaps(c.getSource()) ).
|
||||||
then(argument("type", string()).
|
then(argument("type", string()).
|
||||||
suggests( (c, b)->suggestMatching(Arrays.stream(SpawnGroup.values()).map(SpawnGroup::getName), b)).
|
suggests( (c, b)->suggestMatching(Arrays.stream(SpawnGroup.values()).map(SpawnGroup::getName), b)).
|
||||||
executes( (c) -> listEntitiesOfType(c.getSource(), getString(c, "type")))));
|
executes( (c) -> listEntitiesOfType(c.getSource(), getString(c, "type"), false)).
|
||||||
|
then(literal("all").executes( (c) -> listEntitiesOfType(c.getSource(), getString(c, "type"), true)))));
|
||||||
|
|
||||||
dispatcher.register(literalargumentbuilder);
|
dispatcher.register(literalargumentbuilder);
|
||||||
}
|
}
|
||||||
@@ -262,10 +263,10 @@ public class SpawnCommand
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int listEntitiesOfType(ServerCommandSource source, String mobtype) throws CommandSyntaxException
|
private static int listEntitiesOfType(ServerCommandSource source, String mobtype, boolean all) throws CommandSyntaxException
|
||||||
{
|
{
|
||||||
SpawnGroup cat = getCategory(mobtype);
|
SpawnGroup cat = getCategory(mobtype);
|
||||||
Messenger.send(source, SpawnReporter.printEntitiesByType(cat, source.getWorld()));
|
Messenger.send(source, SpawnReporter.printEntitiesByType(cat, source.getWorld(), all));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -187,7 +187,7 @@ public class SpawnReporter
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return printEntitiesByType(creature_type, worldIn);
|
return printEntitiesByType(creature_type, worldIn, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,22 +257,24 @@ public class SpawnReporter
|
|||||||
return get_type_string(get_creature_type_from_code(str));
|
return get_type_string(get_creature_type_from_code(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<BaseText> printEntitiesByType(SpawnGroup cat, World worldIn) //Class<?> entityType)
|
public static List<BaseText> printEntitiesByType(SpawnGroup cat, World worldIn, boolean all) //Class<?> entityType)
|
||||||
{
|
{
|
||||||
List<BaseText> lst = new ArrayList<>();
|
List<BaseText> lst = new ArrayList<>();
|
||||||
lst.add( Messenger.s(String.format("Loaded entities for %s class:", get_type_string(cat))));
|
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().getSpawnGroup()==cat))
|
for (Entity entity : ((ServerWorld)worldIn).getEntities(null, (e) -> e.getType().getSpawnGroup()==cat))
|
||||||
{
|
{
|
||||||
if (!(entity instanceof MobEntity) || !((MobEntity)entity).isPersistent())
|
boolean persistent = entity instanceof MobEntity && ( ((MobEntity) entity).isPersistent() || ((MobEntity) entity).cannotDespawn());
|
||||||
{
|
if (!all && persistent)
|
||||||
EntityType type = entity.getType();
|
continue;
|
||||||
BlockPos pos = entity.getBlockPos();
|
|
||||||
lst.add( Messenger.c(
|
EntityType type = entity.getType();
|
||||||
"w - ",
|
BlockPos pos = entity.getBlockPos();
|
||||||
Messenger.tp("wb",pos),
|
lst.add( Messenger.c(
|
||||||
String.format("w : %s", type.getName().getString())
|
"w - ",
|
||||||
));
|
Messenger.tp(persistent?"gb":"wb",pos),
|
||||||
}
|
String.format(persistent?"g : %s":"w : %s", type.getName().getString())
|
||||||
|
));
|
||||||
|
|
||||||
}
|
}
|
||||||
if (lst.size()==1)
|
if (lst.size()==1)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user