Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
833ad32
stop here (not finished peeled mecanics BUGS)
iambibi May 12, 2026
a454cb5
Merge remote-tracking branch 'upstream/master' into feat/daily-events
iambibi Jun 2, 2026
2e1b943
add: todos
iambibi Jun 2, 2026
6636797
Merge remote-tracking branch 'origin/master' into feat/daily-events
iambibi Jun 7, 2026
5890259
feat: base of daily event and DailyEventManager (init events planned)
iambibi Jun 7, 2026
972fb56
feat: make calendar functional
iambibi Jun 8, 2026
4602898
change: sort upcoming events
iambibi Jun 8, 2026
2d61273
fix: dynamic item
iambibi Jun 8, 2026
c3a2973
change: logs
iambibi Jun 8, 2026
5e3ef16
feat: end event
iambibi Jun 8, 2026
c808146
add: todo pour pas oublier
iambibi Jun 8, 2026
0acf5a7
feat: add interface HasToast + use of toast (beginning, start, end)
iambibi Jun 9, 2026
e108cfb
Merge remote-tracking branch 'origin/master' into feat/daily-events
iambibi Jun 9, 2026
59a5951
feat: add interface HasAmbient + use of ambient (start, end)
iambibi Jun 9, 2026
eb1e5b3
build: fix
iambibi Jun 9, 2026
74d4dd9
fix: bug with duration
iambibi Jun 9, 2026
69a2f49
branch; change
iambibi Jun 9, 2026
4ca54ad
toast cant show (idem for basic advencement)
iambibi Jun 10, 2026
020cd2e
toast todo
iambibi Jun 10, 2026
b43c3b3
update todo
iambibi Jun 11, 2026
aafc730
update todo
iambibi Jun 11, 2026
013135a
fix: part (1/2) Environnement Attributes overriden by something. : ti…
iambibi Jun 11, 2026
e515d10
rename TimelinesInjector
iambibi Jun 11, 2026
84d6028
feat: BiomeInjector
iambibi Jun 11, 2026
e9fcac9
divise builder in package datapacks.builders
iambibi Jun 11, 2026
3dceaea
chore EnvironnementAttributeBuilder
iambibi Jun 11, 2026
1907a89
Add BiomeAmbient to CustomAmbient
iambibi Jun 11, 2026
206d00c
ri1
iambibi Jun 11, 2026
9972369
part 2 : Fixes Environnement Attribute + Add Effects Attributes (gras…
iambibi Jun 12, 2026
e55747a
remplace param namespace and id to Identifier
iambibi Jun 12, 2026
5bd6c8b
create AmbientBuild how manage, repartition between (dimension types,…
iambibi Jun 12, 2026
3c75a5e
fix: water color problem
iambibi Jun 12, 2026
7b6925e
chore: optimize getFakeChunkWithMapping
iambibi Jun 12, 2026
7e22521
chore: optimize for chunk who contains one biome
iambibi Jun 12, 2026
40f9787
fix: if datapack crash the registries, someone must delete OpenMC/dat…
iambibi Jun 13, 2026
5a420e2
change: golden ambient
iambibi Jun 13, 2026
221139d
feat: Bloody Ambient (need feedback) + SetTimeNMS
iambibi Jun 13, 2026
8ea9753
Merge remote-tracking branch 'origin/master' into feat/daily-events
iambibi Jun 13, 2026
9da5ca4
BloodyAmbient + blood moon
iambibi Jun 14, 2026
d0ff2ff
fix: swapping between 2 ambient (biomes arent applied)
iambibi Jun 14, 2026
7c91878
fix: golden ambient moon/sun/blood_ùmoon weird
iambibi Jun 15, 2026
215bb4d
add BlessedAmbient
iambibi Jun 15, 2026
353c91d
add ambient sound builder + applied to BloodyAmbient
iambibi Jun 15, 2026
3964c60
add weather type to builder
iambibi Jun 16, 2026
9ee8532
better ambience (sound) + fix weather clear
iambibi Jun 16, 2026
a1ab85a
add broadcast
iambibi Jun 16, 2026
37f4088
add javadocs
iambibi Jun 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 74 additions & 6 deletions src/main/java/fr/openmc/api/datapacks/OMCDatapack.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package fr.openmc.api.datapacks;

import fr.openmc.api.datapacks.injectors.PackMetadataInjector;
import fr.openmc.core.OMCPlugin;
import fr.openmc.core.utils.FilesUtils;
import io.papermc.paper.plugin.bootstrap.BootstrapContext;
import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents;
import lombok.Getter;
import org.bukkit.Bukkit;

import java.io.IOException;
import java.net.URI;
Expand All @@ -19,37 +22,102 @@ public class OMCDatapack {
private final String namespace;
private final Set<DatapackInjector> injectors = new HashSet<>();

public final String ID_DATAPACK_INJECTED = "openmc-injected";
private final String ID_TEMP_DATAPACK_FOLDER = "datapacks-openmc";

public OMCDatapack(String packName, String namespace) {
this.packName = packName;
this.namespace = namespace;
}

public void build(BootstrapContext context) throws IOException {
Path tempDir = Files.createTempDirectory("datapacks-openmc");
public void buildBootstrap(BootstrapContext context, boolean generateFiles) throws IOException {
Path dir;

if (generateFiles) {
dir = context.getDataDirectory().resolve(ID_TEMP_DATAPACK_FOLDER);

FilesUtils.deleteDirectory(dir.toFile());
Files.createDirectories(dir);
} else {
dir = Files.createTempDirectory(ID_TEMP_DATAPACK_FOLDER);
}

runInjector(tempDir, new PackMetadataInjector());
runInjector(dir, new PackMetadataInjector());

for (DatapackInjector injector : injectors) {
runInjector(tempDir, injector);
runInjector(dir, injector);
}

context.getLifecycleManager().registerEventHandler(LifecycleEvents.DATAPACK_DISCOVERY.newHandler(
event -> {
try {
URI uri = tempDir.toUri();
URI uri = dir.toUri();

event.registrar().discoverPack(uri, "openmc-injected");
event.registrar().discoverPack(uri, ID_DATAPACK_INJECTED);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
));
}

/**
* Dangeureux à utiliser, veillez bien que serveur restart apres, car les registres nms de minecraft
* (pas reloadable, ex worldgen/biome et worldgen/..) ne peuvent pas etre reload. et donc vous pourrez pas acceder à vos valeures
* @param onBuilded execute une action lorsque le datapack est build (par ex redemarrer le serveur si y'a des registres pas reloadable affecté)
* @throws IOException
*/
public void buildRuntime(Runnable onBuilded) throws IOException {
Path dir = OMCPlugin.getInstance().getServer()
.getLevelDirectory()
.resolve("datapacks")
.resolve(ID_TEMP_DATAPACK_FOLDER);

cleanupRumtime();
Files.createDirectories(dir);

runInjector(dir, new PackMetadataInjector());

for (DatapackInjector injector : injectors) {
runInjector(dir, injector);
}

Bukkit.getScheduler().runTaskLater(OMCPlugin.getInstance(), onBuilded, 20L);
}

public void cleanupBootstrap(BootstrapContext context) throws IOException {
Path dataDir = context.getDataDirectory().toFile()
.toPath()
.toAbsolutePath()
.normalize(); // * ex /home/container/plugins/OpenMC

Path serverRoot = dataDir.getParent() // * plugins/
.getParent(); // * /container

Path dir = serverRoot
.resolve("world") // * /container/world
.resolve("datapacks") // * /container/datapacks
.resolve(ID_TEMP_DATAPACK_FOLDER);
FilesUtils.deleteDirectory(dir.toFile());
}

public void cleanupRumtime() throws IOException {
Path dir = OMCPlugin.getInstance().getServer().getLevelDirectory()
.resolve("datapacks")
.resolve(ID_TEMP_DATAPACK_FOLDER);
FilesUtils.deleteDirectory(dir.toFile());
}

public void addInjector(DatapackInjector injector) {
injectors.add(injector);
}

public void addInjector(Iterable<DatapackInjector> injectors) {
for (DatapackInjector injector : injectors) {
addInjector(injector);
}
}

private static void runInjector(Path datapackRoot, DatapackInjector injector) {
injector.inject(datapackRoot.toFile());
}
Expand Down
183 changes: 183 additions & 0 deletions src/main/java/fr/openmc/api/datapacks/builders/BiomeBuilder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
package fr.openmc.api.datapacks.builders;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import lombok.Getter;

import java.util.function.Consumer;

/**
* Exemple simple d'un biome:
* {
* "attributes": {},
* "carvers": [],
* "creature_spawn_probability": 0.03,
* "downfall": 0,
* "effects": {
* "foliage_color": "#9e814d",
* "grass_color": "#90814d",
* "water_color": "#3f76e4",
* "dry_foliage_color": "",
* "grass_color_modifier": "none"
* },
* "features": [],
* "has_precipitation": false,
* "spawn_costs": {},
* "spawners": {},
* "temperature": 2
* }
*/
public final class BiomeBuilder {
private JsonObject attributes = new JsonObject();
private final JsonArray carvers = new JsonArray();
@Getter
private final JsonObject effects = new JsonObject();
private final JsonArray features = new JsonArray();
private final JsonObject spawnCosts = new JsonObject();
private final JsonObject spawners = new JsonObject();
private String temperatureModifier = "none";
private Double creatureSpawnProbability = 0.03;
private Float downfall = 0.5f;
private Float temperatures = 0.5f;
private Boolean hasPrecipitation = true;

public BiomeBuilder attributes(EnvironnementAttributeBuilder builder) {
this.attributes = builder.getOutputData();
return this;
}

public BiomeBuilder carver(String id) {
this.carvers.add(id);
return this;
}

public BiomeBuilder features(JsonElement id) {
this.features.add(id);
return this;
}

public BiomeBuilder temperatureModifier(String id) {
this.temperatureModifier =id;
return this;
}

public BiomeBuilder creatureSpawnProbability(Double value) {
this.creatureSpawnProbability=value;
return this;
}

public BiomeBuilder downfall(Float value) {
this.downfall=value;
return this;
}

public BiomeBuilder effects(Consumer<JsonObject> builder) {
JsonObject obj = new JsonObject();
builder.accept(obj);
for (var entry : obj.entrySet()) {
this.effects.add(entry.getKey(), entry.getValue());
}
return this;
}

public BiomeBuilder waterColor(String color) {
this.effects.addProperty("water_color", color);
return this;
}

public BiomeBuilder grassColor(String color) {
this.effects.addProperty("grass_color", color);
return this;
}

public BiomeBuilder foliageColor(String color) {
this.effects.addProperty("foliage_color", color);
return this;
}

public BiomeBuilder dryFoliageColor(String color) {
this.effects.addProperty("dry_foliage_color", color);
return this;
}

public BiomeBuilder waterColor(Integer color) {
this.effects.addProperty("water_color", color);
return this;
}

public BiomeBuilder grassColor(Integer color) {
this.effects.addProperty("grass_color", color);
return this;
}

public BiomeBuilder foliageColor(Integer color) {
this.effects.addProperty("foliage_color", color);
return this;
}

public BiomeBuilder dryFoliageColor(Integer color) {
this.effects.addProperty("dry_foliage_color", color);
return this;
}

/**
* Set la grass color modifier
* @param id none, dark_forest, swamp
* @return le builder
*/
public BiomeBuilder grassColorModifier(String id) {
this.effects.addProperty("grass_color_modifier", id);
return this;
}

public BiomeBuilder spawnCosts(Consumer<JsonObject> builder) {
JsonObject obj = new JsonObject();
builder.accept(obj);
for (var entry : obj.entrySet()) {
this.spawnCosts.add(entry.getKey(), entry.getValue());
}
return this;
}

public BiomeBuilder spawnCosts(JsonObject spawnCosts) {
for (var entry : spawnCosts.entrySet()) {
this.spawnCosts.add(entry.getKey(), entry.getValue());
}
return this;
}

public BiomeBuilder spawners(JsonObject spawners) {
for (var entry : spawners.entrySet()) {
this.spawners.add(entry.getKey(), entry.getValue());
}
return this;
}

public BiomeBuilder temperatures(Float value) {
this.temperatures=value;
return this;
}

public BiomeBuilder hasPrecipitation(Boolean bool) {
this.hasPrecipitation=bool;
return this;
}

public JsonObject toJson() {
JsonObject json = new JsonObject();
if (attributes != null) json.add("attributes", attributes);
if (temperatureModifier != null) json.addProperty("temperature_modifier", temperatureModifier);
if (creatureSpawnProbability != null) json.addProperty("creature_spawn_probability", creatureSpawnProbability);
if (carvers != null) json.add("carvers", carvers);
if (downfall != null) json.addProperty("downfall", downfall);
if (effects != null) json.add("effects", effects);
if (features != null) json.add("features", features);
if (hasPrecipitation != null) json.addProperty("has_precipitation", hasPrecipitation);
if (spawnCosts != null) json.add("spawn_costs", spawnCosts);
if (spawners != null) json.add("spawners", spawners);
if (temperatures != null) json.addProperty("temperature", temperatures);

return json;
}
}
Loading
Loading