25w02a
This commit is contained in:
1 parent
d9c7334400
commit
b16eec89e7
34 files changed
+299
-347
No files matched your search
@@ -17,6 +17,7 @@ import net.minecraft.world.phys.Vec3;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -147,11 +148,11 @@ public class Messenger
|
||||
Style previousStyle = previousMessage.getStyle();
|
||||
MutableComponent ret = previousMessage;
|
||||
previousMessage.setStyle(switch (desc.charAt(0)) {
|
||||
case '?' -> previousStyle.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, message.substring(1)));
|
||||
case '!' -> previousStyle.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, message.substring(1)));
|
||||
case '^' -> previousStyle.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, c(message.substring(1))));
|
||||
case '@' -> previousStyle.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, message.substring(1)));
|
||||
case '&' -> previousStyle.withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, message.substring(1)));
|
||||
case '?' -> previousStyle.withClickEvent(new ClickEvent.SuggestCommand(message.substring(1)));
|
||||
case '!' -> previousStyle.withClickEvent(new ClickEvent.RunCommand(message.substring(1)));
|
||||
case '^' -> previousStyle.withHoverEvent(new HoverEvent.ShowText(c(message.substring(1))));
|
||||
case '@' -> previousStyle.withClickEvent(new ClickEvent.OpenUrl(URI.create(message.substring(1))));
|
||||
case '&' -> previousStyle.withClickEvent(new ClickEvent.CopyToClipboard(message.substring(1)));
|
||||
default -> { // Create a new component
|
||||
ret = Component.literal(str);
|
||||
ret.setStyle(parseStyle(desc));
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.List;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.util.random.Weighted;
|
||||
import net.minecraft.world.entity.AgeableMob;
|
||||
import net.minecraft.world.entity.EntitySpawnReason;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
@@ -162,9 +163,10 @@ public class PerimeterDiagnostics
|
||||
if (sle == null || !worldServer.getChunkSource().getGenerator().getMobsAt(worldServer.getBiome(pos), worldServer.structureManager(), ctype, pos).unwrap().contains(sle))
|
||||
{
|
||||
sle = null;
|
||||
for (MobSpawnSettings.SpawnerData sle: worldServer.getChunkSource().getGenerator().getMobsAt(worldServer.getBiome(pos), worldServer.structureManager(), ctype, pos).unwrap())
|
||||
for (Weighted<MobSpawnSettings.SpawnerData> wsle: worldServer.getChunkSource().getGenerator().getMobsAt(worldServer.getBiome(pos), worldServer.structureManager(), ctype, pos).unwrap())
|
||||
{
|
||||
if (el.getType() == sle.type)
|
||||
MobSpawnSettings.SpawnerData sle = wsle.value();
|
||||
if (el.getType() == sle.type())
|
||||
{
|
||||
this.sle = sle;
|
||||
break;
|
||||
@@ -176,7 +178,7 @@ public class PerimeterDiagnostics
|
||||
}
|
||||
}
|
||||
|
||||
if (SpawnPlacements.isSpawnPositionOk(sle.type, worldServer, pos))
|
||||
if (SpawnPlacements.isSpawnPositionOk(sle.type(), worldServer, pos))
|
||||
{
|
||||
el.moveTo(pos.getX() + 0.5F, pos.getY(), pos.getZ()+0.5F, 0.0F, 0.0F);
|
||||
return el.checkSpawnObstruction(worldServer) && el.checkSpawnRules(worldServer, EntitySpawnReason.NATURAL) &&
|
||||
|
||||
@@ -8,7 +8,7 @@ import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.util.random.WeightedRandomList;
|
||||
import net.minecraft.util.random.WeightedList;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.level.StructureManager;
|
||||
@@ -32,28 +32,28 @@ public class SpawnOverrides {
|
||||
|
||||
static {
|
||||
addOverride(() -> CarpetSettings.huskSpawningInTemples, MobCategory.MONSTER, BuiltinStructures.DESERT_PYRAMID, StructureSpawnOverride.BoundingBoxType.STRUCTURE,
|
||||
WeightedRandomList.create(new MobSpawnSettings.SpawnerData(EntityType.HUSK, 1, 1, 1))
|
||||
WeightedList.of(new MobSpawnSettings.SpawnerData(EntityType.HUSK, 1, 1))
|
||||
);
|
||||
addOverride(() -> CarpetSettings.shulkerSpawningInEndCities, MobCategory.MONSTER, BuiltinStructures.END_CITY, StructureSpawnOverride.BoundingBoxType.PIECE,
|
||||
WeightedRandomList.create(new MobSpawnSettings.SpawnerData(EntityType.SHULKER, 10, 4, 4))
|
||||
WeightedList.of(new MobSpawnSettings.SpawnerData(EntityType.SHULKER, 4, 4))
|
||||
);
|
||||
addOverride(() -> CarpetSettings.piglinsSpawningInBastions, MobCategory.MONSTER, BuiltinStructures.BASTION_REMNANT, StructureSpawnOverride.BoundingBoxType.PIECE,
|
||||
WeightedRandomList.create(
|
||||
new MobSpawnSettings.SpawnerData(EntityType.PIGLIN_BRUTE, 5, 1, 2),
|
||||
new MobSpawnSettings.SpawnerData(EntityType.PIGLIN, 10, 2, 4),
|
||||
new MobSpawnSettings.SpawnerData(EntityType.HOGLIN, 2, 1, 2)
|
||||
)
|
||||
WeightedList.<MobSpawnSettings.SpawnerData>builder()
|
||||
.add(new MobSpawnSettings.SpawnerData(EntityType.PIGLIN_BRUTE,1, 2), 5)
|
||||
.add(new MobSpawnSettings.SpawnerData(EntityType.PIGLIN, 2, 4), 10)
|
||||
.add(new MobSpawnSettings.SpawnerData(EntityType.HOGLIN, 1, 2), 2)
|
||||
.build()
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public static void addOverride(BooleanSupplier when, MobCategory cat, ResourceKey<Structure> poo,
|
||||
StructureSpawnOverride.BoundingBoxType type, WeightedRandomList<MobSpawnSettings.SpawnerData> spawns) {
|
||||
StructureSpawnOverride.BoundingBoxType type, WeightedList<MobSpawnSettings.SpawnerData> spawns) {
|
||||
carpetOverrides.put(Pair.of(cat, poo), Pair.of(when, new StructureSpawnOverride(type, spawns)));
|
||||
}
|
||||
|
||||
public static WeightedRandomList<MobSpawnSettings.SpawnerData> test(StructureManager structureFeatureManager, LongSet foo,
|
||||
MobCategory cat, Structure confExisting, BlockPos where) {
|
||||
public static WeightedList<MobSpawnSettings.SpawnerData> test(StructureManager structureFeatureManager, LongSet foo,
|
||||
MobCategory cat, Structure confExisting, BlockPos where) {
|
||||
ResourceLocation resource = structureFeatureManager.registryAccess().lookupOrThrow(Registries.STRUCTURE).getKey(confExisting);
|
||||
ResourceKey<Structure> key = ResourceKey.create(Registries.STRUCTURE, resource);
|
||||
final Pair<BooleanSupplier, StructureSpawnOverride> spawnData = carpetOverrides.get(Pair.of(cat, key));
|
||||
|
||||
@@ -12,6 +12,8 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.util.random.Weighted;
|
||||
import net.minecraft.util.random.WeightedList;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntitySpawnReason;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
@@ -389,8 +391,8 @@ public class SpawnReporter
|
||||
}
|
||||
|
||||
// yeeted from NaturalSpawner - temporary access fix
|
||||
private static List<MobSpawnSettings.SpawnerData> getSpawnEntries(ServerLevel serverLevel, StructureManager structureManager, ChunkGenerator chunkGenerator, MobCategory mobCategory, BlockPos blockPos, @Nullable Holder<Biome> holder) {
|
||||
return NaturalSpawner.isInNetherFortressBounds(blockPos, serverLevel, mobCategory, structureManager) ? NetherFortressStructure.FORTRESS_ENEMIES.unwrap() : chunkGenerator.getMobsAt(holder != null ? holder : serverLevel.getBiome(blockPos), structureManager, mobCategory, blockPos).unwrap();
|
||||
private static WeightedList<MobSpawnSettings.SpawnerData> getSpawnEntries(ServerLevel serverLevel, StructureManager structureManager, ChunkGenerator chunkGenerator, MobCategory mobCategory, BlockPos blockPos, @Nullable Holder<Biome> holder) {
|
||||
return NaturalSpawner.isInNetherFortressBounds(blockPos, serverLevel, mobCategory, structureManager) ? NetherFortressStructure.FORTRESS_ENEMIES : chunkGenerator.getMobsAt(holder != null ? holder : serverLevel.getBiome(blockPos), structureManager, mobCategory, blockPos);
|
||||
}
|
||||
|
||||
public static List<Component> report(BlockPos pos, ServerLevel worldIn)
|
||||
@@ -407,21 +409,22 @@ public class SpawnReporter
|
||||
for (MobCategory category : cachedMobCategories())
|
||||
{
|
||||
String categoryCode = String.valueOf(category).substring(0, 3);
|
||||
List<MobSpawnSettings.SpawnerData> lst = getSpawnEntries(worldIn, worldIn.structureManager(), worldIn.getChunkSource().getGenerator(), category, pos, worldIn.getBiome(pos));
|
||||
WeightedList<MobSpawnSettings.SpawnerData> lst = getSpawnEntries(worldIn, worldIn.structureManager(), worldIn.getChunkSource().getGenerator(), category, pos, worldIn.getBiome(pos));
|
||||
if (lst != null && !lst.isEmpty())
|
||||
{
|
||||
for (MobSpawnSettings.SpawnerData spawnEntry : lst)
|
||||
for (Weighted<MobSpawnSettings.SpawnerData> wspawnEntry : lst.unwrap())
|
||||
{
|
||||
if (SpawnPlacements.getPlacementType(spawnEntry.type) == null)
|
||||
MobSpawnSettings.SpawnerData spawnEntry = wspawnEntry.value();
|
||||
if (SpawnPlacements.getPlacementType(spawnEntry.type()) == null)
|
||||
continue; // vanilla bug
|
||||
boolean canSpawn = SpawnPlacements.isSpawnPositionOk(spawnEntry.type, worldIn, pos);
|
||||
boolean canSpawn = SpawnPlacements.isSpawnPositionOk(spawnEntry.type(), worldIn, pos);
|
||||
int willSpawn = -1;
|
||||
boolean fits = false;
|
||||
|
||||
Mob mob;
|
||||
try
|
||||
{
|
||||
mob = (Mob) spawnEntry.type.create(worldIn, EntitySpawnReason.NATURAL);
|
||||
mob = (Mob) spawnEntry.type().create(worldIn, EntitySpawnReason.NATURAL);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -467,7 +470,7 @@ public class SpawnReporter
|
||||
|
||||
try
|
||||
{
|
||||
mob = (Mob) spawnEntry.type.create(worldIn, EntitySpawnReason.NATURAL);
|
||||
mob = (Mob) spawnEntry.type().create(worldIn, EntitySpawnReason.NATURAL);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -479,12 +482,12 @@ public class SpawnReporter
|
||||
|
||||
String mobTypeName = mob.getType().getDescription().getString();
|
||||
//String pack_size = Integer.toString(mob.getMaxSpawnClusterSize());//String.format("%d-%d", animal.minGroupCount, animal.maxGroupCount);
|
||||
int weight = spawnEntry.getWeight().asInt();
|
||||
int weight = wspawnEntry.weight();
|
||||
if (canSpawn)
|
||||
{
|
||||
String color = (fits && willSpawn > 0) ? "e" : "gi";
|
||||
rep.add(Messenger.c(
|
||||
String.format("%s %s: %s (%d:%d-%d/%d), can: ", color, categoryCode, mobTypeName, weight, spawnEntry.minCount, spawnEntry.maxCount, mob.getMaxSpawnClusterSize()),
|
||||
String.format("%s %s: %s (%d:%d-%d/%d), can: ", color, categoryCode, mobTypeName, weight, spawnEntry.minCount(), spawnEntry.maxCount(), mob.getMaxSpawnClusterSize()),
|
||||
"l YES",
|
||||
color + " , fit: ",
|
||||
(fits ? "l YES" : "r NO"),
|
||||
@@ -494,7 +497,7 @@ public class SpawnReporter
|
||||
}
|
||||
else
|
||||
{
|
||||
rep.add(Messenger.c(String.format("gi %s: %s (%d:%d-%d/%d), can: ", categoryCode, mobTypeName, weight, spawnEntry.minCount, spawnEntry.maxCount, mob.getMaxSpawnClusterSize()), "n NO"));
|
||||
rep.add(Messenger.c(String.format("gi %s: %s (%d:%d-%d/%d), can: ", categoryCode, mobTypeName, weight, spawnEntry.minCount(), spawnEntry.maxCount(), mob.getMaxSpawnClusterSize()), "n NO"));
|
||||
}
|
||||
killEntity(mob);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user