Skip to content

Commit

Permalink
Datapack Shenanigans
Browse files Browse the repository at this point in the history
  • Loading branch information
NextdoorPsycho committed Feb 4, 2023
1 parent 0ffc642 commit ef07ec2
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 27 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ plugins {
id "de.undercouch.download" version "5.0.1"
}

version '2.3.13-1.19.3' // Needs to be version specific
version '2.3.14-1.19.3' // Needs to be version specific
def nmsVersion = "1.19.3" //[NMS]
def apiVersion = '1.19'
def specialSourceVersion = '1.11.0' //[NMS]
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/volmit/iris/Iris.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@

@SuppressWarnings("CanBeFinal")
public class Iris extends VolmitPlugin implements Listener {
public static final String OVERWORLD_TAG = "2092";
public static final String OVERWORLD_TAG = "2100";

private static final Queue<Runnable> syncJobs = new ShurikenQueue<>();

Expand Down
142 changes: 117 additions & 25 deletions src/main/java/com/volmit/iris/engine/object/IrisDimension.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,70 @@ public class IrisDimension extends IrisRegistrant {
public static final BlockData WATER = Material.WATER.createBlockData();
private static final String DP_OVERWORLD_DEFAULT = """
{
"ultrawarm": false,
"natural": true,
"coordinate_scale": 1.0,
"has_skylight": true,
"has_ceiling": false,
"ambient_light": 0,
"piglin_safe": false,
"bed_works": true,
"respawn_anchor_works": true,
"has_raids": true,
"monster_spawn_block_light_limit": 7,
"monster_spawn_light_level": 7,
"infiniburn": "#minecraft:infiniburn_overworld",
"effects": "minecraft:overworld"
"ambient_light": 0.0,
"bed_works": true,
"coordinate_scale": 1.0,
"effects": "minecraft:overworld",
"has_ceiling": false,
"has_raids": true,
"has_skylight": true,
"infiniburn": "#minecraft:infiniburn_overworld",
"monster_spawn_block_light_limit": 0,
"monster_spawn_light_level": {
"type": "minecraft:uniform",
"value": {
"max_inclusive": 7,
"min_inclusive": 0
}
},
"natural": true,
"piglin_safe": false,
"respawn_anchor_works": false,
"ultrawarm": false
}""";

private static final String DP_NETHER_DEFAULT = """
{
"ambient_light": 0.1,
"bed_works": false,
"coordinate_scale": 8.0,
"effects": "minecraft:the_nether",
"fixed_time": 18000,
"has_ceiling": true,
"has_raids": false,
"has_skylight": false,
"infiniburn": "#minecraft:infiniburn_nether",
"monster_spawn_block_light_limit": 15,
"monster_spawn_light_level": 7,
"natural": false,
"piglin_safe": true,
"respawn_anchor_works": true,
"ultrawarm": true
}""";

private static final String DP_END_DEFAULT = """
{
"ambient_light": 0.0,
"bed_works": false,
"coordinate_scale": 1.0,
"effects": "minecraft:the_end",
"fixed_time": 6000,
"has_ceiling": false,
"has_raids": true,
"has_skylight": false,
"infiniburn": "#minecraft:infiniburn_end",
"monster_spawn_block_light_limit": 0,
"monster_spawn_light_level": {
"type": "minecraft:uniform",
"value": {
"max_inclusive": 7,
"min_inclusive": 0
}
},
"natural": false,
"piglin_safe": false,
"respawn_anchor_works": false,
"ultrawarm": false
}""";
private final transient AtomicCache<Position2> parallaxSize = new AtomicCache<>();
private final transient AtomicCache<CNG> rockLayerGenerator = new AtomicCache<>();
Expand All @@ -86,6 +136,10 @@ public class IrisDimension extends IrisRegistrant {
@MaxNumber(2032)
@Desc("Maximum height at which players can be teleported to through gameplay.")
private int logicalHeight = 256;
@Desc("Maximum height at which players can be teleported to through gameplay.")
private int logicalHeightEnd = 256;
@Desc("Maximum height at which players can be teleported to through gameplay.")
private int logicalHeightNether = 256;
@RegistryListResource(IrisJigsawStructure.class)
@Desc("If defined, Iris will place the given jigsaw structure where minecraft should place the overworld stronghold.")
private String stronghold;
Expand All @@ -107,12 +161,8 @@ public class IrisDimension extends IrisRegistrant {
private int strongholdJumpDistance = 1280;
@Desc("Define the maximum strongholds to place")
private int maxStrongholds = 14;
@Desc("Improves the biome grid variation by shuffling the cell grid more depending on the seed. This makes biomes across multiple seeds look far different than before.")
private boolean aggressiveBiomeReshuffle = false;
@Desc("Tree growth override settings")
private IrisTreeSettings treeSettings = new IrisTreeSettings();
@Desc("Upon joining this world, Iris will send a resource pack request to the client. If they have previously selected yes, it will auto-switch depending on which dimension they go to.")
private String resourcePack = "";
@Desc("Spawn Entities in this dimension over time. Iris will continually replenish these mobs just like vanilla does.")
@ArrayType(min = 1, type = String.class)
@RegistryListResource(IrisSpawner.class)
Expand Down Expand Up @@ -174,6 +224,10 @@ public class IrisDimension extends IrisRegistrant {
private int fluidHeight = 63;
@Desc("Define the min and max Y bounds of this dimension. Please keep in mind that Iris internally generates from 0 to (max - min). \n\nFor example at -64 to 320, Iris is internally generating to 0 to 384, then on outputting chunks, it shifts it down by the min height (64 blocks). The default is -64 to 320. \n\nThe fluid height is placed at (fluid height + min height). So a fluid height of 63 would actually show up in the world at 1.")
private IrisRange dimensionHeight = new IrisRange(-64, 320);
@Desc("Define the min and max Y bounds of this dimension. Please keep in mind that Iris internally generates from 0 to (max - min). \n\nFor example at -64 to 320, Iris is internally generating to 0 to 384, then on outputting chunks, it shifts it down by the min height (64 blocks). The default is -64 to 320. \n\nThe fluid height is placed at (fluid height + min height). So a fluid height of 63 would actually show up in the world at 1.")
private IrisRange dimensionHeightEnd = new IrisRange(-64, 320);
@Desc("Define the min and max Y bounds of this dimension. Please keep in mind that Iris internally generates from 0 to (max - min). \n\nFor example at -64 to 320, Iris is internally generating to 0 to 384, then on outputting chunks, it shifts it down by the min height (64 blocks). The default is -64 to 320. \n\nThe fluid height is placed at (fluid height + min height). So a fluid height of 63 would actually show up in the world at 1.")
private IrisRange dimensionHeightNether = new IrisRange(-64, 320);
@RegistryListResource(IrisBiome.class)
@Desc("Keep this either undefined or empty. Setting any biome name into this will force iris to only generate the specified biome. Great for testing.")
private String focus = "";
Expand Down Expand Up @@ -279,7 +333,6 @@ public KList<Position2> getStrongholds(long seed) {
KList<Position2> pos = new KList<>();
int jump = strongholdJumpDistance;
RNG rng = new RNG((seed * 223) + 12945);

for (int i = 0; i < maxStrongholds + 1; i++) {
int m = i + 1;
pos.add(new Position2(
Expand Down Expand Up @@ -416,7 +469,7 @@ public boolean installDataPack(DataProvider data, File datapacks) {
}

if (!dimensionHeight.equals(new IrisRange(-64, 320)) && this.name.equalsIgnoreCase("overworld")) {
Iris.verbose(" Installing Data Pack Dimension Type: \"minecraft:overworld\"");
Iris.verbose(" Installing Data Pack Dimension Types: \"minecraft:overworld\", \"minecraft:the_nether\", \"minecraft:the_end\"");
changed = writeDimensionType(changed, datapacks);
}

Expand Down Expand Up @@ -457,24 +510,63 @@ public void scanForErrors(JSONObject p, VolmitSender sender) {
}

public boolean writeDimensionType(boolean changed, File datapacks) {
File dimType = new File(datapacks, "iris/data/minecraft/dimension_type/overworld.json");
if (!dimType.exists())
File dimTypeOverworld = new File(datapacks, "iris/data/minecraft/dimension_type/overworld.json");
if (!dimTypeOverworld.exists())
changed = true;
dimTypeOverworld.getParentFile().mkdirs();
try {
IO.writeAll(dimTypeOverworld, generateDatapackJsonOverworld());
} catch (IOException e) {
Iris.reportError(e);
e.printStackTrace();
}


File dimTypeNether = new File(datapacks, "iris/data/minecraft/dimension_type/the_nether.json");
if (!dimTypeNether.exists())
changed = true;
dimType.getParentFile().mkdirs();
dimTypeNether.getParentFile().mkdirs();
try {
IO.writeAll(dimType, generateDatapackJson());
IO.writeAll(dimTypeNether, generateDatapackJsonNether());
} catch (IOException e) {
Iris.reportError(e);
e.printStackTrace();
}


File dimTypeEnd = new File(datapacks, "iris/data/minecraft/dimension_type/the_end.json");
if (!dimTypeEnd.exists())
changed = true;
dimTypeEnd.getParentFile().mkdirs();
try {
IO.writeAll(dimTypeEnd, generateDatapackJsonEnd());
} catch (IOException e) {
Iris.reportError(e);
e.printStackTrace();
}

return changed;
}

private String generateDatapackJson() {
private String generateDatapackJsonOverworld() {
JSONObject obj = new JSONObject(DP_OVERWORLD_DEFAULT);
obj.put("min_y", dimensionHeight.getMin());
obj.put("height", dimensionHeight.getMax() - dimensionHeight.getMin());
obj.put("logical_height", logicalHeight);
return obj.toString(4);
}
private String generateDatapackJsonNether() {
JSONObject obj = new JSONObject(DP_NETHER_DEFAULT);
obj.put("min_y", dimensionHeightNether.getMin());
obj.put("height", dimensionHeightNether.getMax() - dimensionHeightNether.getMin());
obj.put("logical_height", logicalHeightNether);
return obj.toString(4);
}
private String generateDatapackJsonEnd() {
JSONObject obj = new JSONObject(DP_END_DEFAULT);
obj.put("min_y", dimensionHeightEnd.getMin());
obj.put("height", dimensionHeightEnd.getMax() - dimensionHeightEnd.getMin());
obj.put("logical_height", logicalHeightEnd);
return obj.toString(4);
}
}

0 comments on commit ef07ec2

Please sign in to comment.