Skip to content

Commit

Permalink
Start Rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
UnRealDinnerbone committed Oct 31, 2023
1 parent 6e6603d commit 60b11f1
Show file tree
Hide file tree
Showing 38 changed files with 999 additions and 366 deletions.
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ plugins {
id("java")
id "me.modmuss50.mod-publish-plugin" version "0.3.0"

id("fabric-loom") version("1.3.9") apply(false)
id("net.minecraftforge.gradle") version("6.0.+") apply(false)
id("fabric-loom") version("1.4.2") apply(false)
id 'net.neoforged.gradle' version '[6.0.18,6.2)' apply(false)
}

java.toolchain.languageVersion = JavaLanguageVersion.of(17)
Expand All @@ -15,6 +15,8 @@ multiLoader.root() {
minecraftVersion.set(project.property("minecraft_version"))
modID.set(project.property("mod_id"))
splitSources.set(true)
accessWidenerFile.set(project(":common").file("src/main/resources/${mod_id}.accesswidener"))

dataGen {
useFabric.set(project(":common").file("src/generated/resources"))
useForge.set(project(":forge").file("src/generated/resources"))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// 1.20.1 2023-08-20T09:33:14.6325483 Just Another Mining Dimension/Language (en_us)
4d0b94d0ebdcaaafe16d0133c0028cf20bec5a5f assets\jamd\lang\en_us.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// 1.20.1 2023-08-20T09:33:14.6340461 Just Another Mining Dimension/Model Definitions
bf3a9f8231659d8cbc7ea68a7cdde8e3b029071f assets\jamd\blockstates\end_portal.json
7e626048016ba0c9d3b92a12b89eb0ec4d6fe677 assets\jamd\models\block\nether_portal.json
2d9db6c9191663e8106bc53141670ea054209f9a assets\jamd\models\block\portal_block.json
6b50f23823f194ff35bcec0e1694e77efd20e385 assets\jamd\blockstates\nether_portal.json
c43b79f0a1988c4d812f8e77f1c7506d596430a0 assets\jamd\models\item\end_portal.json
098aa69a37ff6ca1b266436f24e891314007f976 assets\jamd\blockstates\portal_block.json
76633e08f2190391221ca5bc14b6536cda1b87a9 assets\jamd\models\item\nether_portal.json
6048ff3f9c71f641213c1d7aa6d605d9b23fed72 assets\jamd\models\block\end_portal.json
155f13040d10cd90e514a56c4d7338c0db232883 assets\jamd\models\item\portal_block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// 1.20.1 2023-08-20T09:33:14.633546 Just Another Mining Dimension/JAMD World Data
e022cecafe8e7e93c9e3e503c46197cf1fb33450 data\jamd\dimension_type\mining.json
9493a2c0221f086efbb4263f171937a72c6d6992 data\jamd\worldgen\biome\end.json
ac9e79911103955c5e8d0b82bd377f175796afac data\jamd\worldgen\biome\mining.json
5015669d20cfba456749215c51c22bc7ace1d4b3 data\jamd\dimension_type\nether.json
cbc1941a40b6da486531a2010be4e6db0866e4f4 data\jamd\dimension_type\end.json
9eb37f0889d455d2929fd947bb4667057ba1b0fe data\jamd\worldgen\biome\nether.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// 1.20.1 2023-08-20T09:33:14.6345452 Just Another Mining Dimension/Tags for minecraft:block
d21a5dcdd4b5cd0b493217e7e9e4aa477a755db8 data\minecraft\tags\blocks\mineable\pickaxe.json
d21a5dcdd4b5cd0b493217e7e9e4aa477a755db8 data\minecraft\tags\blocks\needs_diamond_tool.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// 1.20.1 2023-08-20T09:33:14.6350463 Just Another Mining Dimension/Recipes
6a1227f9e0b372e3546b782215347c8c76dd6f4f data\jamd\advancements\recipes\transportation\nether_portal_block.json
be575abba95e7f591761941b8ce7b15805dd16f5 data\jamd\advancements\recipes\transportation\end_portal_block.json
64a379634715c9f4ea69b6fc5a330a0008cbb33f data\jamd\recipes\portal_block.json
351ba1cdc449781ef49cc5cdb4bfdd5bc5722a13 data\jamd\recipes\nether_portal_block.json
a202bbb60a616a623a317c3b0902f18436701002 data\jamd\recipes\end_portal_block.json
8be629b04926b089b8c6acc497e9fed86ca0ae1b data\jamd\advancements\recipes\transportation\portal_block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// 1.20.1 2023-08-20T09:33:14.633546 Just Another Mining Dimension/Block Loot Tables
d02ea46f3e4060ea18cb73c3b3fe1f1738d4e47c data\jamd\loot_tables\blocks\portal_block.json
8f213054226c115851779a7dd3fb5e0cfb8323f9 data\jamd\loot_tables\blocks\end_portal.json
d4122e44c4d0d50740cfa507d4d05078c7163a7d data\jamd\loot_tables\blocks\nether_portal.json

This file was deleted.

This file was deleted.

21 changes: 0 additions & 21 deletions common/src/generated/resources/data/jamd/recipes/portal_block.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,7 @@
[],
[],
[],
[
"minecraft:ore_coal_upper",
"minecraft:ore_coal_lower",
"minecraft:ore_iron_upper",
"minecraft:ore_iron_middle",
"minecraft:ore_iron_small",
"minecraft:ore_gold",
"minecraft:ore_gold_lower",
"minecraft:ore_redstone",
"minecraft:ore_redstone_lower",
"minecraft:ore_diamond",
"minecraft:ore_diamond_large",
"minecraft:ore_diamond_buried",
"minecraft:ore_lapis",
"minecraft:ore_lapis_buried",
"minecraft:ore_copper",
"minecraft:underwater_magma",
"minecraft:ore_emerald",
"minecraft:ore_copper_large",
"minecraft:ore_tuff"
]
[]
],
"has_precipitation": true,
"spawn_costs": {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,7 @@
[],
[],
[],
[
"minecraft:ore_gravel_nether",
"minecraft:ore_blackstone",
"minecraft:ore_gold_nether",
"minecraft:ore_quartz_nether",
"minecraft:ore_ancient_debris_large",
"minecraft:ore_debris_small"
]
[]
],
"has_precipitation": false,
"spawn_costs": {},
Expand Down
12 changes: 12 additions & 0 deletions common/src/main/java/com/unrealdinnerbone/jamd/ConfigCodec.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.unrealdinnerbone.jamd;

import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;

import java.util.List;

public record ConfigCodec(List<OresCodec> ores) {
public static final Codec<ConfigCodec> CODEC = RecordCodecBuilder.create(instance -> instance.group(
Codec.list(OresCodec.CODEC).fieldOf("ores").forGetter(ConfigCodec::ores)
).apply(instance, ConfigCodec::new));
}
41 changes: 0 additions & 41 deletions common/src/main/java/com/unrealdinnerbone/jamd/DefaultConfig.java

This file was deleted.

81 changes: 77 additions & 4 deletions common/src/main/java/com/unrealdinnerbone/jamd/JAMD.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,89 @@
package com.unrealdinnerbone.jamd;

import com.unrealdinnerbone.config.ConfigManager;
import com.unrealdinnerbone.trenzalore.api.config.ConfigManger;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import com.mojang.serialization.DataResult;
import com.mojang.serialization.JsonOps;
import com.unrealdinnerbone.jamd.util.Transformers;
import com.unrealdinnerbone.trenzalore.api.platform.Services;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;

public class JAMD {

private static final Logger LOGGER = LoggerFactory.getLogger(JAMD.class);

public static final Path CONFIG_FOLDER = Services.PLATFORM.getConfigPath().resolve("jamd");
public static final String MOD_ID = "jamd";
private static final ConfigManager CONFIG_MANAGER = ConfigManger.createConfigManager(MOD_ID);
public static final JamdConfig CONFIG = CONFIG_MANAGER.loadConfig("general", JamdConfig::new);
public static final Map<ResourceKey<Biome>, Map<String, PlacedFeature>> REGISTERED_FEATURES = new HashMap<>();


private static final List<String> DIM_TYPES = Arrays.asList("mining", "nether", "end");

public static void init() {
try {
createFiles();
}catch (IOException e) {
LOGGER.error("Failed to create config files", e);
return;
}
for (String dimType : DIM_TYPES) {
try {
String jsonString = Files.readString(CONFIG_FOLDER.resolve(dimType + ".json"));
JsonElement parse = new JsonParser().parse(jsonString);
DataResult<ConfigCodec> data = ConfigCodec.CODEC.parse(JsonOps.INSTANCE, parse);
if(data.error().isPresent()) {
LOGGER.error("Failed to parse config: {}", data.error().get().message());
return;
}
Optional<ConfigCodec> result = data.result();
if(result.isPresent()) {
Map<String, PlacedFeature> placedFeatureMap = new HashMap<>();
ConfigCodec configCodec = result.get();
for (OresCodec ore : configCodec.ores()) {
if(placedFeatureMap.containsKey(ore.id())) {
LOGGER.error("Duplicate ore: {} found in config {}", ore.id(), dimType);
continue;
}
placedFeatureMap.put(ore.id(), Transformers.fromConfigCodec(ore));
LOGGER.debug("Registered ore: {} for dim type: {}", ore.id(), dimType);
}
REGISTERED_FEATURES.put(ResourceKey.create(Registries.BIOME, new ResourceLocation(MOD_ID, dimType)), placedFeatureMap);
}
}catch (IOException e) {
LOGGER.error("Failed to load config for dim type: {}", dimType, e);
}

}
}

private static void createFiles() throws IOException {
if(!Files.exists(CONFIG_FOLDER)) {
Files.createDirectories(CONFIG_FOLDER);
}
for (String dimType : DIM_TYPES) {
Path path = CONFIG_FOLDER.resolve(dimType + ".json");
if(!Files.exists(path)) {
InputStream defaultConfig = JAMD.class.getResourceAsStream("/defaults/" + dimType + ".json");
if(defaultConfig != null) {
Files.copy(defaultConfig, path);
}else {
throw new IOException("Failed to find default config for: " + dimType);
}
}
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
import org.jetbrains.annotations.ApiStatus;

import java.util.List;
Expand Down
46 changes: 0 additions & 46 deletions common/src/main/java/com/unrealdinnerbone/jamd/JamdConfig.java

This file was deleted.

Loading

0 comments on commit 60b11f1

Please sign in to comment.