mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-17 14:21:08 +00:00
Change Java whitespace handling in .editorconfig (#425)
* Change whitespace handling in .editorconfig * Reformat code * fix format error * Reformat code --------- Co-authored-by: Zoë Gidiere <duplexsys@protonmail.com>
This commit is contained in:
+8
-8
@@ -12,19 +12,19 @@ import com.dfsek.terra.api.event.events.platform.CommandRegistrationEvent;
|
||||
|
||||
public final class LifecycleEntryPoint {
|
||||
private static final Logger logger = LoggerFactory.getLogger(LifecycleEntryPoint.class);
|
||||
|
||||
|
||||
public static void initialize(String modName, LifecyclePlatform platform) {
|
||||
logger.info("Initializing Terra {} mod...", modName);
|
||||
|
||||
|
||||
FabricServerCommandManager<CommandSender> manager = new FabricServerCommandManager<>(
|
||||
CommandExecutionCoordinator.simpleCoordinator(),
|
||||
serverCommandSource -> (CommandSender) serverCommandSource,
|
||||
commandSender -> (ServerCommandSource) commandSender
|
||||
CommandExecutionCoordinator.simpleCoordinator(),
|
||||
serverCommandSource -> (CommandSender) serverCommandSource,
|
||||
commandSender -> (ServerCommandSource) commandSender
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
manager.brigadierManager().setNativeNumberSuggestions(false);
|
||||
|
||||
|
||||
platform.getEventManager().callEvent(new CommandRegistrationEvent(manager));
|
||||
}
|
||||
}
|
||||
|
||||
+21
-21
@@ -35,12 +35,12 @@ public abstract class LifecyclePlatform extends ModPlatform {
|
||||
private static final AtomicReference<Registry<ChunkGeneratorSettings>> SETTINGS = new AtomicReference<>();
|
||||
private static final AtomicReference<Registry<MultiNoiseBiomeSourceParameterList>> NOISE = new AtomicReference<>();
|
||||
private static MinecraftServer server;
|
||||
|
||||
|
||||
public LifecyclePlatform() {
|
||||
CommonPlatform.initialize(this);
|
||||
load();
|
||||
}
|
||||
|
||||
|
||||
public static void setRegistries(Registry<Biome> biomeRegistry,
|
||||
Registry<DimensionType> dimensionTypeRegistry,
|
||||
Registry<ChunkGeneratorSettings> chunkGeneratorSettingsRegistry,
|
||||
@@ -50,23 +50,23 @@ public abstract class LifecyclePlatform extends ModPlatform {
|
||||
SETTINGS.set(chunkGeneratorSettingsRegistry);
|
||||
NOISE.set(multiNoiseBiomeSourceParameterListRegistry);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public MinecraftServer getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
|
||||
public static void setServer(MinecraftServer server) {
|
||||
LifecyclePlatform.server = server;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean reload() {
|
||||
getTerraConfig().load(this);
|
||||
getRawConfigRegistry().clear();
|
||||
boolean succeed = getRawConfigRegistry().loadAll(this);
|
||||
|
||||
|
||||
|
||||
|
||||
if(server != null) {
|
||||
BiomeUtil.registerBiomes(server.getRegistryManager().get(RegistryKeys.BIOME));
|
||||
server.reloadResources(server.getDataPackManager().getNames()).exceptionally(throwable -> {
|
||||
@@ -84,13 +84,13 @@ public abstract class LifecyclePlatform extends ModPlatform {
|
||||
}
|
||||
return succeed;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Iterable<BaseAddon> platformAddon() {
|
||||
List<BaseAddon> addons = new ArrayList<>();
|
||||
|
||||
|
||||
super.platformAddon().forEach(addons::add);
|
||||
|
||||
|
||||
String mcVersion = MinecraftVersion.CURRENT.getName();
|
||||
try {
|
||||
addons.add(new EphemeralAddon(Versions.parseVersion(mcVersion), "minecraft"));
|
||||
@@ -101,12 +101,12 @@ public abstract class LifecyclePlatform extends ModPlatform {
|
||||
LOGGER.warn("Failed to parse Minecraft version", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
addons.addAll(getPlatformMods());
|
||||
|
||||
|
||||
return addons;
|
||||
}
|
||||
|
||||
|
||||
protected Stream<EphemeralAddon> parseModData(String id, String modVersion, String platform) {
|
||||
if(id.equals("terra") || id.equals("minecraft") || id.equals("java")) return Stream.empty();
|
||||
try {
|
||||
@@ -114,32 +114,32 @@ public abstract class LifecyclePlatform extends ModPlatform {
|
||||
return Stream.of(new EphemeralAddon(version, platform + ":" + id));
|
||||
} catch(ParseException e) {
|
||||
LOGGER.warn(
|
||||
"Mod {}, version {} does not follow semantic versioning specification, Terra addons will be unable to depend on " +
|
||||
"it.",
|
||||
id, modVersion);
|
||||
"Mod {}, version {} does not follow semantic versioning specification, Terra addons will be unable to depend on " +
|
||||
"it.",
|
||||
id, modVersion);
|
||||
}
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Registry<DimensionType> dimensionTypeRegistry() {
|
||||
return DIMENSIONS.get();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Registry<Biome> biomeRegistry() {
|
||||
return BIOMES.get();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Registry<ChunkGeneratorSettings> chunkGeneratorSettingsRegistry() {
|
||||
return SETTINGS.get();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Registry<MultiNoiseBiomeSourceParameterList> multiNoiseBiomeSourceParameterListRegistry() {
|
||||
return NOISE.get();
|
||||
}
|
||||
|
||||
|
||||
protected abstract Collection<BaseAddon> getPlatformMods();
|
||||
}
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ public class NoiseConfigMixin {
|
||||
@Shadow
|
||||
@Final
|
||||
private MultiNoiseSampler multiNoiseSampler;
|
||||
|
||||
|
||||
@Inject(method = "<init>(Lnet/minecraft/world/gen/chunk/ChunkGeneratorSettings;Lnet/minecraft/registry/RegistryEntryLookup;J)V",
|
||||
at = @At("TAIL"))
|
||||
private void mapMultiNoise(ChunkGeneratorSettings chunkGeneratorSettings,
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ public class SimpleRegistryMixin<T> implements RegistryHack {
|
||||
@Shadow
|
||||
@Final
|
||||
private Map<T, Reference<T>> valueToEntry;
|
||||
|
||||
|
||||
@Override
|
||||
public void terra_bind() {
|
||||
valueToEntry.forEach((value, entry) -> {
|
||||
|
||||
+27
-27
@@ -31,44 +31,44 @@ public class RegistryLoaderMixin {
|
||||
@Shadow
|
||||
@Final
|
||||
private static Logger LOGGER;
|
||||
|
||||
|
||||
@Redirect(
|
||||
method = "load(Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/registry/DynamicRegistryManager;Ljava/util/List;)" +
|
||||
"Lnet/minecraft/registry/DynamicRegistryManager$Immutable;",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Ljava/util/List;forEach(Ljava/util/function/Consumer;)V",
|
||||
ordinal = 1 // we want right after the first forEach
|
||||
)
|
||||
method = "load(Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/registry/DynamicRegistryManager;Ljava/util/List;)" +
|
||||
"Lnet/minecraft/registry/DynamicRegistryManager$Immutable;",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Ljava/util/List;forEach(Ljava/util/function/Consumer;)V",
|
||||
ordinal = 1 // we want right after the first forEach
|
||||
)
|
||||
)
|
||||
private static void grabManager(List<Pair<MutableRegistry<?>, Object>> instance, Consumer<Pair<MutableRegistry<?>, Object>> consumer) {
|
||||
instance.forEach(mutableRegistryObjectPair -> LOGGER.debug("{}: {} entries",
|
||||
mutableRegistryObjectPair.getFirst().toString(),
|
||||
mutableRegistryObjectPair.getFirst().size())
|
||||
);
|
||||
mutableRegistryObjectPair.getFirst().toString(),
|
||||
mutableRegistryObjectPair.getFirst().size())
|
||||
);
|
||||
extractRegistry(instance, RegistryKeys.BIOME).ifPresent(
|
||||
biomes -> { // this redirect triggers twice, second time only with dimension registry. don't try extraction second time
|
||||
MutableRegistry<DimensionType> dimensionTypes = extractRegistry(instance, RegistryKeys.DIMENSION_TYPE).orElseThrow();
|
||||
MutableRegistry<WorldPreset> worldPresets = extractRegistry(instance, RegistryKeys.WORLD_PRESET).orElseThrow();
|
||||
MutableRegistry<ChunkGeneratorSettings> chunkGeneratorSettings = extractRegistry(instance,
|
||||
RegistryKeys.CHUNK_GENERATOR_SETTINGS).orElseThrow();
|
||||
MutableRegistry<MultiNoiseBiomeSourceParameterList> multiNoiseBiomeSourceParameterLists = extractRegistry(instance,
|
||||
RegistryKeys.MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST).orElseThrow();
|
||||
|
||||
LifecyclePlatform.setRegistries(biomes, dimensionTypes, chunkGeneratorSettings, multiNoiseBiomeSourceParameterLists);
|
||||
LifecycleUtil.initialize(biomes, worldPresets);
|
||||
});
|
||||
biomes -> { // this redirect triggers twice, second time only with dimension registry. don't try extraction second time
|
||||
MutableRegistry<DimensionType> dimensionTypes = extractRegistry(instance, RegistryKeys.DIMENSION_TYPE).orElseThrow();
|
||||
MutableRegistry<WorldPreset> worldPresets = extractRegistry(instance, RegistryKeys.WORLD_PRESET).orElseThrow();
|
||||
MutableRegistry<ChunkGeneratorSettings> chunkGeneratorSettings = extractRegistry(instance,
|
||||
RegistryKeys.CHUNK_GENERATOR_SETTINGS).orElseThrow();
|
||||
MutableRegistry<MultiNoiseBiomeSourceParameterList> multiNoiseBiomeSourceParameterLists = extractRegistry(instance,
|
||||
RegistryKeys.MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST).orElseThrow();
|
||||
|
||||
LifecyclePlatform.setRegistries(biomes, dimensionTypes, chunkGeneratorSettings, multiNoiseBiomeSourceParameterLists);
|
||||
LifecycleUtil.initialize(biomes, worldPresets);
|
||||
});
|
||||
instance.forEach(consumer);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <T> Optional<MutableRegistry<T>> extractRegistry(List<Pair<MutableRegistry<?>, Object>> instance,
|
||||
RegistryKey<Registry<T>> key) {
|
||||
List<? extends MutableRegistry<?>> matches = instance
|
||||
.stream()
|
||||
.map(Pair::getFirst)
|
||||
.filter(r -> r.getKey().equals(key))
|
||||
.toList();
|
||||
.stream()
|
||||
.map(Pair::getFirst)
|
||||
.filter(r -> r.getKey().equals(key))
|
||||
.toList();
|
||||
if(matches.size() > 1) {
|
||||
throw new IllegalStateException("Illegal number of registries returned: " + matches);
|
||||
} else if(matches.isEmpty()) {
|
||||
|
||||
+9
-9
@@ -13,15 +13,15 @@ import com.dfsek.terra.mod.util.MinecraftUtil;
|
||||
@Mixin(SaveLoading.class)
|
||||
public class SaveLoadingMixin {
|
||||
@ModifyArg(
|
||||
method = "method_42097(Lnet/minecraft/registry/DynamicRegistryManager$Immutable;" +
|
||||
"Lnet/minecraft/server/SaveLoading$SaveApplierFactory;Lnet/minecraft/resource/LifecycledResourceManager;" +
|
||||
"Lnet/minecraft/registry/CombinedDynamicRegistries;Lnet/minecraft/server/SaveLoading$LoadContext;" +
|
||||
"Lnet/minecraft/server/DataPackContents;)Ljava/lang/Object;",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/DataPackContents;refresh(Lnet/minecraft/registry/DynamicRegistryManager;)V"
|
||||
),
|
||||
index = 0
|
||||
method = "method_42097(Lnet/minecraft/registry/DynamicRegistryManager$Immutable;" +
|
||||
"Lnet/minecraft/server/SaveLoading$SaveApplierFactory;Lnet/minecraft/resource/LifecycledResourceManager;" +
|
||||
"Lnet/minecraft/registry/CombinedDynamicRegistries;Lnet/minecraft/server/SaveLoading$LoadContext;" +
|
||||
"Lnet/minecraft/server/DataPackContents;)Ljava/lang/Object;",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/DataPackContents;refresh(Lnet/minecraft/registry/DynamicRegistryManager;)V"
|
||||
),
|
||||
index = 0
|
||||
)
|
||||
private static DynamicRegistryManager grabManager(DynamicRegistryManager in) {
|
||||
MinecraftUtil.registerFlora(in.get(RegistryKeys.BIOME));
|
||||
|
||||
+20
-20
@@ -24,11 +24,11 @@ import com.dfsek.terra.mod.util.MinecraftUtil;
|
||||
|
||||
public final class BiomeUtil {
|
||||
private static final Logger logger = LoggerFactory.getLogger(BiomeUtil.class);
|
||||
|
||||
|
||||
private BiomeUtil() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void registerBiomes(Registry<net.minecraft.world.biome.Biome> biomeRegistry) {
|
||||
logger.info("Registering biomes...");
|
||||
CommonPlatform.get().getConfigRegistry().forEach(pack -> { // Register all Terra biomes.
|
||||
@@ -37,7 +37,7 @@ public final class BiomeUtil {
|
||||
});
|
||||
logger.info("Terra biomes registered.");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clones a Vanilla biome and injects Terra data to create a Terra-vanilla biome delegate.
|
||||
*
|
||||
@@ -48,36 +48,36 @@ public final class BiomeUtil {
|
||||
com.dfsek.terra.api.registry.key.RegistryKey id,
|
||||
Registry<net.minecraft.world.biome.Biome> registry) {
|
||||
RegistryKey<net.minecraft.world.biome.Biome> vanilla = ((ProtoPlatformBiome) biome.getPlatformBiome()).get(registry);
|
||||
|
||||
|
||||
|
||||
|
||||
if(pack.getContext().get(PreLoadCompatibilityOptions.class).useVanillaBiomes()) {
|
||||
((ProtoPlatformBiome) biome.getPlatformBiome()).setDelegate(registry.getEntry(vanilla).orElseThrow());
|
||||
} else {
|
||||
VanillaBiomeProperties vanillaBiomeProperties = biome.getContext().get(VanillaBiomeProperties.class);
|
||||
|
||||
|
||||
net.minecraft.world.biome.Biome minecraftBiome = MinecraftUtil.createBiome(biome, Objects.requireNonNull(registry.get(vanilla)),
|
||||
vanillaBiomeProperties);
|
||||
|
||||
vanillaBiomeProperties);
|
||||
|
||||
Identifier identifier = new Identifier("terra", MinecraftUtil.createBiomeID(pack, id));
|
||||
|
||||
|
||||
if(registry.containsId(identifier)) {
|
||||
((ProtoPlatformBiome) biome.getPlatformBiome()).setDelegate(MinecraftUtil.getEntry(registry, identifier)
|
||||
.orElseThrow());
|
||||
.orElseThrow());
|
||||
} else {
|
||||
((ProtoPlatformBiome) biome.getPlatformBiome()).setDelegate(Registry.registerReference(registry,
|
||||
MinecraftUtil.registerKey(identifier)
|
||||
.getValue(),
|
||||
minecraftBiome));
|
||||
MinecraftUtil.registerKey(identifier)
|
||||
.getValue(),
|
||||
minecraftBiome));
|
||||
}
|
||||
|
||||
|
||||
Map<RegistryKey<net.minecraft.world.biome.Biome>, VillagerType> villagerMap = VillagerTypeAccessor.getBiomeTypeToIdMap();
|
||||
|
||||
|
||||
villagerMap.put(RegistryKey.of(RegistryKeys.BIOME, identifier),
|
||||
Objects.requireNonNullElse(vanillaBiomeProperties.getVillagerType(),
|
||||
villagerMap.getOrDefault(vanilla, VillagerType.PLAINS)));
|
||||
|
||||
Objects.requireNonNullElse(vanillaBiomeProperties.getVillagerType(),
|
||||
villagerMap.getOrDefault(vanilla, VillagerType.PLAINS)));
|
||||
|
||||
MinecraftUtil.TERRA_BIOME_MAP.computeIfAbsent(vanilla.getValue(), i -> new ArrayList<>()).add(identifier);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -13,13 +13,13 @@ import com.dfsek.terra.mod.CommonPlatform;
|
||||
|
||||
public final class LifecycleUtil {
|
||||
private LifecycleUtil() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void initialize(MutableRegistry<Biome> biomeMutableRegistry, MutableRegistry<WorldPreset> worldPresetMutableRegistry) {
|
||||
CommonPlatform.get().getEventManager().callEvent(new PlatformInitializationEvent());
|
||||
BiomeUtil.registerBiomes(biomeMutableRegistry);
|
||||
CommonPlatform.get().registerWorldTypes(
|
||||
(id, preset) -> Registry.register(worldPresetMutableRegistry, RegistryKey.of(RegistryKeys.WORLD_PRESET, id), preset));
|
||||
(id, preset) -> Registry.register(worldPresetMutableRegistry, RegistryKey.of(RegistryKeys.WORLD_PRESET, id), preset));
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -9,9 +9,9 @@ import com.dfsek.terra.mod.data.Codecs;
|
||||
|
||||
public final class RegistryUtil {
|
||||
private RegistryUtil() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void register() {
|
||||
Registry.register(Registries.CHUNK_GENERATOR, new Identifier("terra:terra"), Codecs.MINECRAFT_CHUNK_GENERATOR_WRAPPER);
|
||||
Registry.register(Registries.BIOME_SOURCE, new Identifier("terra:terra"), Codecs.TERRA_BIOME_SOURCE);
|
||||
|
||||
Reference in New Issue
Block a user