-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 1.20.5 recipes: null over -1 * add 1.21 * 1.21 (#26) * update classname * update moved class * updated to equivelant method since gettranslatekey removed * added isCursed list as bandaid alternative for now since isCursed() removed * added isTreasure list as bandaid alternative for now since isTreasure() removed * found alternative method to canCombine() since removed * modified getEnchantmentTarget name to handle registryEntryList since getApplicableItems dosnt return tagKey anymore * bandaid list solution for "tradeable" property since isTradeable removed and no alternative in mappings * bandaid solution for discoverable property since removed and no alternative to isAvailiableForRandomSelection in 1.21 mappings * removed .toPath since apparently it dosnt exist * no longer outputs in tagkey format * fixed not adding enchantcategories for items properly * added SuperGamerTron tag solution * Update build.yml --------- Co-authored-by: Madlykeanu <[email protected]> Co-authored-by: Romain Beaumont <[email protected]>
- Loading branch information
1 parent
131218c
commit 2c423f7
Showing
25 changed files
with
1,681 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,8 @@ jobs: | |
"1.19.2", | ||
"1.20", | ||
"1.20.4", | ||
"1.20.5" | ||
"1.20.5", | ||
"1.21" | ||
] | ||
|
||
name: Build ${{ matrix.version }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import xyz.wagyourtail.unimined.api.minecraft.task.RemapJarTask | ||
import xyz.wagyourtail.unimined.internal.minecraft.MinecraftProvider | ||
|
||
plugins { | ||
id 'xyz.wagyourtail.unimined' | ||
} | ||
|
||
unimined.minecraft { | ||
version "1.21" | ||
|
||
mappings { | ||
intermediary() | ||
yarn(1) | ||
|
||
devFallbackNamespace "intermediary" | ||
} | ||
|
||
runs.config("server") { | ||
javaVersion = JavaVersion.VERSION_21 | ||
} | ||
|
||
customPatcher(new CustomOfficialFabricMinecraftTransformer(project, delegate as MinecraftProvider)) { | ||
it.loader libs.versions.fabric.loader.get() | ||
} | ||
|
||
defaultRemapJar = true | ||
} | ||
|
||
dependencies { | ||
implementation project(":common") | ||
} | ||
|
||
processResources { | ||
filteringCharset "UTF-8" | ||
|
||
filesMatching("fabric.mod.json") { | ||
expand "version": project.version | ||
} | ||
} | ||
|
||
tasks.withType(RemapJarTask).configureEach { | ||
onlyIf { false} | ||
} | ||
|
||
tasks.withType(JavaCompile).configureEach { | ||
it.options.encoding = "UTF-8" | ||
} |
115 changes: 115 additions & 0 deletions
115
1.21/src/main/java/dev/u9g/minecraftdatagenerator/generators/BiomesDataGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
package dev.u9g.minecraftdatagenerator.generators; | ||
|
||
import com.google.gson.JsonArray; | ||
import com.google.gson.JsonObject; | ||
import dev.u9g.minecraftdatagenerator.util.DGU; | ||
import net.minecraft.registry.DynamicRegistryManager; | ||
import net.minecraft.registry.Registry; | ||
import net.minecraft.registry.RegistryKeys; | ||
import net.minecraft.registry.tag.BiomeTags; | ||
import net.minecraft.util.Identifier; | ||
import net.minecraft.world.biome.Biome; | ||
|
||
public class BiomesDataGenerator implements IDataGenerator { | ||
private static String guessBiomeDimensionFromCategory(Biome biome) { | ||
var biomeRegistry = DGU.getWorld().getRegistryManager().get(RegistryKeys.BIOME); | ||
if (biomeRegistry.getEntry(biome).isIn(BiomeTags.IS_NETHER)) { | ||
return "nether"; | ||
} else if (biomeRegistry.getEntry(biome).isIn(BiomeTags.IS_END)) { | ||
return "end"; | ||
} else { | ||
return "overworld"; | ||
} | ||
} | ||
|
||
private static String guessCategoryBasedOnName(String name, String dimension) { | ||
if (dimension.equals("nether")) { | ||
return "nether"; | ||
} else if (dimension.equals("end")) { | ||
return "the_end"; | ||
} | ||
|
||
if (name.contains("end")) { | ||
System.out.println(); | ||
} | ||
|
||
if (name.contains("hills")) { | ||
return "extreme_hills"; | ||
} else if (name.contains("ocean")) { | ||
return "ocean"; | ||
} else if (name.contains("plains")) { | ||
return "plains"; | ||
} else if (name.contains("ice") || name.contains("frozen")) { | ||
return "ice"; | ||
} else if (name.contains("jungle")) { | ||
return "jungle"; | ||
} else if (name.contains("desert")) { | ||
return "desert"; | ||
} else if (name.contains("forest") || name.contains("grove")) { | ||
return "forest"; | ||
} else if (name.contains("taiga")) { | ||
return "taiga"; | ||
} else if (name.contains("swamp")) { | ||
return "swamp"; | ||
} else if (name.contains("river")) { | ||
return "river"; | ||
} else if (name.equals("the_end")) { | ||
return "the_end"; | ||
} else if (name.contains("mushroom")) { | ||
return "mushroom"; | ||
} else if (name.contains("beach") || name.equals("stony_shore")) { | ||
return "beach"; | ||
} else if (name.contains("savanna")) { | ||
return "savanna"; | ||
} else if (name.contains("badlands")) { | ||
return "mesa"; | ||
} else if (name.contains("peaks") || name.equals("snowy_slopes") || name.equals("meadow")) { | ||
return "mountain"; | ||
} else if (name.equals("the_void")) { | ||
return "none"; | ||
} else if (name.contains("cave") || name.equals("deep_dark")) { | ||
return "underground"; | ||
} else { | ||
System.out.println("Unable to find biome category for biome with name: '" + name + "'"); | ||
return "none"; | ||
} | ||
} | ||
|
||
public static JsonObject generateBiomeInfo(Registry<Biome> registry, Biome biome) { | ||
JsonObject biomeDesc = new JsonObject(); | ||
Identifier registryKey = registry.getKey(biome).orElseThrow().getValue(); | ||
String localizationKey = String.format("biome.%s.%s", registryKey.getNamespace(), registryKey.getPath()); | ||
String name = registryKey.getPath(); | ||
biomeDesc.addProperty("id", registry.getRawId(biome)); | ||
biomeDesc.addProperty("name", name); | ||
String dimension = guessBiomeDimensionFromCategory(biome); | ||
biomeDesc.addProperty("category", guessCategoryBasedOnName(name, dimension)); | ||
biomeDesc.addProperty("temperature", biome.getTemperature()); | ||
//biomeDesc.addProperty("precipitation", biome.getPrecipitation().getName());// - removed in 1.19.4 | ||
biomeDesc.addProperty("has_precipitation", biome.hasPrecipitation()); | ||
//biomeDesc.addProperty("depth", biome.getDepth()); - Doesn't exist anymore in minecraft source | ||
biomeDesc.addProperty("dimension", dimension); | ||
biomeDesc.addProperty("displayName", DGU.translateText(localizationKey)); | ||
biomeDesc.addProperty("color", biome.getSkyColor()); | ||
//biomeDesc.addProperty("rainfall", biome.getDownfall());// - removed in 1.19.4 | ||
|
||
return biomeDesc; | ||
} | ||
|
||
@Override | ||
public String getDataName() { | ||
return "biomes"; | ||
} | ||
|
||
@Override | ||
public JsonArray generateDataJson() { | ||
JsonArray biomesArray = new JsonArray(); | ||
DynamicRegistryManager registryManager = DGU.getWorld().getRegistryManager(); | ||
Registry<Biome> biomeRegistry = registryManager.get(RegistryKeys.BIOME); | ||
|
||
biomeRegistry.stream() | ||
.map(biome -> generateBiomeInfo(biomeRegistry, biome)) | ||
.forEach(biomesArray::add); | ||
return biomesArray; | ||
} | ||
} |
110 changes: 110 additions & 0 deletions
110
...ain/java/dev/u9g/minecraftdatagenerator/generators/BlockCollisionShapesDataGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
package dev.u9g.minecraftdatagenerator.generators; | ||
|
||
import com.google.gson.JsonArray; | ||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonObject; | ||
import com.google.gson.JsonPrimitive; | ||
import dev.u9g.minecraftdatagenerator.util.DGU; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.registry.Registry; | ||
import net.minecraft.registry.RegistryKeys; | ||
import net.minecraft.util.Identifier; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.shape.VoxelShape; | ||
import net.minecraft.world.EmptyBlockView; | ||
|
||
import java.util.*; | ||
|
||
public class BlockCollisionShapesDataGenerator implements IDataGenerator { | ||
|
||
@Override | ||
public String getDataName() { | ||
return "blockCollisionShapes"; | ||
} | ||
|
||
@Override | ||
public JsonObject generateDataJson() { | ||
Registry<Block> blockRegistry = DGU.getWorld().getRegistryManager().get(RegistryKeys.BLOCK); | ||
BlockShapesCache blockShapesCache = new BlockShapesCache(); | ||
|
||
blockRegistry.forEach(blockShapesCache::processBlock); | ||
|
||
JsonObject resultObject = new JsonObject(); | ||
|
||
resultObject.add("blocks", blockShapesCache.dumpBlockShapeIndices(blockRegistry)); | ||
resultObject.add("shapes", blockShapesCache.dumpShapesObject()); | ||
|
||
return resultObject; | ||
} | ||
|
||
private static class BlockShapesCache { | ||
public final Map<VoxelShape, Integer> uniqueBlockShapes = new LinkedHashMap<>(); | ||
public final Map<Block, List<Integer>> blockCollisionShapes = new LinkedHashMap<>(); | ||
private int lastCollisionShapeId = 0; | ||
|
||
public void processBlock(Block block) { | ||
List<BlockState> blockStates = block.getStateManager().getStates(); | ||
List<Integer> blockCollisionShapes = new ArrayList<>(); | ||
|
||
for (BlockState blockState : blockStates) { | ||
VoxelShape blockShape = blockState.getCollisionShape(EmptyBlockView.INSTANCE, BlockPos.ORIGIN); | ||
Integer blockShapeIndex = uniqueBlockShapes.get(blockShape); | ||
|
||
if (blockShapeIndex == null) { | ||
blockShapeIndex = lastCollisionShapeId++; | ||
uniqueBlockShapes.put(blockShape, blockShapeIndex); | ||
} | ||
blockCollisionShapes.add(blockShapeIndex); | ||
} | ||
|
||
this.blockCollisionShapes.put(block, blockCollisionShapes); | ||
} | ||
|
||
public JsonObject dumpBlockShapeIndices(Registry<Block> blockRegistry) { | ||
JsonObject resultObject = new JsonObject(); | ||
|
||
for (var entry : blockCollisionShapes.entrySet()) { | ||
List<Integer> blockCollisions = entry.getValue(); | ||
long distinctShapesCount = blockCollisions.stream().distinct().count(); | ||
JsonElement blockCollision; | ||
if (distinctShapesCount == 1L) { | ||
blockCollision = new JsonPrimitive(blockCollisions.getFirst()); | ||
} else { | ||
blockCollision = new JsonArray(); | ||
for (int collisionId : blockCollisions) { | ||
((JsonArray) blockCollision).add(collisionId); | ||
} | ||
} | ||
|
||
Identifier registryKey = blockRegistry.getKey(entry.getKey()).orElseThrow().getValue(); | ||
resultObject.add(registryKey.getPath(), blockCollision); | ||
} | ||
|
||
return resultObject; | ||
} | ||
|
||
public JsonObject dumpShapesObject() { | ||
JsonObject shapesObject = new JsonObject(); | ||
|
||
for (var entry : uniqueBlockShapes.entrySet()) { | ||
JsonArray boxesArray = new JsonArray(); | ||
entry.getKey().forEachBox((x1, y1, z1, x2, y2, z2) -> { | ||
JsonArray oneBoxJsonArray = new JsonArray(); | ||
|
||
oneBoxJsonArray.add(x1); | ||
oneBoxJsonArray.add(y1); | ||
oneBoxJsonArray.add(z1); | ||
|
||
oneBoxJsonArray.add(x2); | ||
oneBoxJsonArray.add(y2); | ||
oneBoxJsonArray.add(z2); | ||
|
||
boxesArray.add(oneBoxJsonArray); | ||
}); | ||
shapesObject.add(Integer.toString(entry.getValue()), boxesArray); | ||
} | ||
return shapesObject; | ||
} | ||
} | ||
} |
Oops, something went wrong.