Skip to content

Commit

Permalink
Import all versions (#8)
Browse files Browse the repository at this point in the history
* Import all versions

* Prepare first workflow

* Cleanup build scripts

* More cleanup

* Cleanup more stuff and 1.7 on server

* Run multiple tasks in parallel

* Use version in job name

* Error on missing files

* Backport EULA mixin

* Update upload artifact

* Prevent build getting stuck

* Cleanup code

* More code cleanup

* Update build.yml

* Fix compilation

---------

Co-authored-by: Romain Beaumont <[email protected]>
  • Loading branch information
AlexProgrammerDE and rom1504 authored Dec 31, 2023
1 parent 5441b07 commit a48fb99
Show file tree
Hide file tree
Showing 556 changed files with 30,774 additions and 811 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Java CI with Gradle
on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
version: ["1.7", "1.8.9", "1.9.4", "1.10.2", "1.11.2", "1.12.2", "1.13", "1.14", "1.15", "1.16", "1.17", "1.18", "1.19", "1.19.2", "22w19a", "1.20"]

name: Build ${{ matrix.version }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Generate ${{ matrix.version }}
uses: gradle/gradle-build-action@v2
with:
arguments: :${{ matrix.version }}:runServer

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: data-${{ matrix.version }}
path: ${{ matrix.version }}/run/minecraft-data
if-no-files-found: error
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ gradle-app.setting
**/build/

# Common working directory
run/
**/run/

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

bin/
bin/
63 changes: 63 additions & 0 deletions 1.10.2/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
plugins {
id 'fabric-loom'
}

repositories {
maven {
name = "legacy-fabric"
url = "https://maven.legacyfabric.net"
}
}

loom {
setIntermediaryUrl('https://maven.legacyfabric.net/net/fabricmc/intermediary/%1$s/intermediary-%1$s-v2.jar');
customMinecraftManifest.set("https://meta.legacyfabric.net/v2/manifest/${minecraft_version}")
}

dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

// Fabric API provides hooks for events, item registration, and more. As most mods will need this, it's included by default.
// If you know for a fact you don't, it's not required and can be safely removed.
// modImplementation ("net.legacyfabric.legacy-fabric-api:legacy-fabric-api:${fabric_version}") {
// exclude module: "legacy-fabric-entity-events-v1"
// }

if (System.getProperty("os.name").toLowerCase().contains("mac")) {
implementation 'org.lwjgl.lwjgl:lwjgl_util:2.9.4-nightly-20150209'
implementation 'org.lwjgl.lwjgl:lwjgl:2.9.4-nightly-20150209'
implementation 'org.lwjgl.lwjgl:lwjgl-platform:2.9.4-nightly-20150209'
}
}

if (System.getProperty("os.name").toLowerCase().contains("mac")) {
configurations.configureEach {
resolutionStrategy {
dependencySubstitution {
substitute module('org.lwjgl.lwjgl:lwjgl_util:2.9.2-nightly-201408222') with module('org.lwjgl.lwjgl:lwjgl_util:2.9.4-nightly-20150209')
substitute module('org.lwjgl.lwjgl:lwjgl:2.9.2-nightly-201408222') with module('org.lwjgl.lwjgl:lwjgl:2.9.4-nightly-20150209')
}
force 'org.lwjgl.lwjgl:lwjgl-platform:2.9.4-nightly-20150209'
}
}
}

processResources {
filteringCharset "UTF-8"

filesMatching("fabric.mod.json") {
expand "version": project.version
}
}

tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
7 changes: 7 additions & 0 deletions 1.10.2/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Fabric Properties
# More versions available at: https://grayray75.github.io/LegacyFabric-Versions/
minecraft_version=1.10.2
yarn_mappings=1.10.2+build.202206020145
loader_version=0.14.3
# Dependencies
# More versions available at: https://grayray75.github.io/LegacyFabric-Versions/
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances;

import dev.u9g.minecraftdatagenerator.util.EmptyBlockView;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.biome.Biome;

import java.util.Iterator;

public class BiomeColors {
private static final ColorProvider GRASS_COLOR = (biome, pos) -> biome.getGrassColor(pos);
private static final ColorProvider FOLIAGE_COLOR = (biome, pos) -> biome.getFoliageColor(pos);
private static final ColorProvider WATER_COLOR = (biome, pos) -> biome.getWaterColor();

private static int getColor(EmptyBlockView view, BlockPos pos, ColorProvider provider) {
int i = 0;
int j = 0;
int k = 0;

int l;
for (Iterator iterator = BlockPos.mutableIterate(pos.add(-1, 0, -1), pos.add(1, 0, 1)).iterator(); iterator.hasNext(); k += l & 255) {
BlockPos.Mutable mutable = (BlockPos.Mutable) iterator.next();
l = provider.getColorAtPos(view.getBiome(mutable), mutable);
i += (l & 16711680) >> 16;
j += (l & '\uff00') >> 8;
}

return (i / 9 & 255) << 16 | (j / 9 & 255) << 8 | k / 9 & 255;
}

public static int getGrassColor(EmptyBlockView view, BlockPos pos) {
return getColor(view, pos, GRASS_COLOR);
}

public static int getFoliageColor(EmptyBlockView view, BlockPos pos) {
return getColor(view, pos, FOLIAGE_COLOR);
}

public static int getWaterColor(EmptyBlockView view, BlockPos pos) {
return getColor(view, pos, WATER_COLOR);
}

interface ColorProvider {
int getColorAtPos(Biome biome, BlockPos pos);
}
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances;

import dev.u9g.minecraftdatagenerator.util.EmptyBlockView;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import org.jetbrains.annotations.Nullable;

public interface BlockColorable {
int method_12155(BlockState blockState, @Nullable EmptyBlockView blockView, @Nullable BlockPos blockPos, int i);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances;

import dev.u9g.minecraftdatagenerator.util.EmptyBlockView;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.FlowerPotBlockEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.util.collection.IdList;
import net.minecraft.util.math.BlockPos;
import org.jetbrains.annotations.Nullable;

public class BlockColors {
private final IdList<BlockColorable> BlockColor2Id = new IdList<>(32);

public BlockColors() {
}

public static BlockColors create() {
final BlockColors blockColors = new BlockColors();
blockColors.method_12158((blockState, blockView, blockPos, i) -> {
DoublePlantBlock.DoublePlantType doublePlantType = (DoublePlantBlock.DoublePlantType) blockState.get(DoublePlantBlock.VARIANT);
return blockView == null || blockPos == null || doublePlantType != DoublePlantBlock.DoublePlantType.GRASS && doublePlantType != DoublePlantBlock.DoublePlantType.FERN ? -1 : BiomeColors.getGrassColor(blockView, blockPos);
}, Blocks.DOUBLE_PLANT);
blockColors.method_12158((blockState, blockView, blockPos, i) -> {
if (blockView != null && blockPos != null) {
BlockEntity blockEntity = blockView.getBlockEntity(blockPos);
if (blockEntity instanceof FlowerPotBlockEntity) {
Item item = ((FlowerPotBlockEntity) blockEntity).getItem();
if (item instanceof BlockItem) {
BlockState blockState2 = Block.getBlockFromItem(item).getDefaultState();
return blockColors.method_12157(blockState2, blockView, blockPos, i);
}
}
}

return -1;
}, Blocks.FLOWER_POT);
blockColors.method_12158((blockState, blockView, blockPos, i) -> blockView != null && blockPos != null ? BiomeColors.getGrassColor(blockView, blockPos) : GrassColors.getColor(0.5D, 1.0D), Blocks.GRASS);
blockColors.method_12158((blockState, blockView, blockPos, i) -> {
PlanksBlock.WoodType woodType = (PlanksBlock.WoodType) blockState.get(Leaves1Block.VARIANT);
if (woodType == PlanksBlock.WoodType.SPRUCE) {
return FoliageColors.getSpruceColor();
} else if (woodType == PlanksBlock.WoodType.BIRCH) {
return FoliageColors.getBirchColor();
} else {
return blockView != null && blockPos != null ? BiomeColors.getFoliageColor(blockView, blockPos) : FoliageColors.getDefaultColor();
}
}, Blocks.LEAVES);
blockColors.method_12158((blockState, blockView, blockPos, i) -> blockView != null && blockPos != null ? BiomeColors.getFoliageColor(blockView, blockPos) : FoliageColors.getDefaultColor(), Blocks.LEAVES2);
blockColors.method_12158((blockState, blockView, blockPos, i) -> blockView != null && blockPos != null ? BiomeColors.getWaterColor(blockView, blockPos) : -1, Blocks.WATER, Blocks.FLOWING_WATER);
blockColors.method_12158((blockState, blockView, blockPos, i) -> RedstoneWireBlock.method_8877((Integer) blockState.get(RedstoneWireBlock.POWER)), Blocks.REDSTONE_WIRE);
blockColors.method_12158((blockState, blockView, blockPos, i) -> blockView != null && blockPos != null ? BiomeColors.getGrassColor(blockView, blockPos) : -1, Blocks.SUGARCANE);
blockColors.method_12158((blockState, blockView, blockPos, i) -> {
int j = (Integer) blockState.get(AttachedStemBlock.AGE);
int k = j * 32;
int l = 255 - j * 8;
int m = j * 4;
return k << 16 | l << 8 | m;
}, Blocks.MELON_STEM, Blocks.PUMPKIN_STEM);
blockColors.method_12158((blockState, blockView, blockPos, i) -> {
if (blockView != null && blockPos != null) {
return BiomeColors.getGrassColor(blockView, blockPos);
} else {
return blockState.get(TallPlantBlock.TYPE) == TallPlantBlock.GrassType.DEAD_BUSH ? 16777215 : GrassColors.getColor(0.5D, 1.0D);
}
}, Blocks.TALLGRASS);
blockColors.method_12158((blockState, blockView, blockPos, i) -> blockView != null && blockPos != null ? BiomeColors.getFoliageColor(blockView, blockPos) : FoliageColors.getDefaultColor(), Blocks.VINE);
blockColors.method_12158((blockState, blockView, blockPos, i) -> blockView != null && blockPos != null ? 2129968 : 7455580, Blocks.LILY_PAD);
return blockColors;
}

public int method_13410(BlockState blockState) {
BlockColorable blockColorable = (BlockColorable) this.BlockColor2Id.fromId(Block.getIdByBlock(blockState.getBlock()));
if (blockColorable != null) {
return blockColorable.method_12155(blockState, (EmptyBlockView) null, (BlockPos) null, 0);
} else {
MaterialColor materialColor = blockState.getMaterialColor();
return materialColor != null ? materialColor.color : -1;
}
}

public int method_12157(BlockState blockState, @Nullable EmptyBlockView blockView, @Nullable BlockPos blockPos, int i) {
BlockColorable blockColorable = (BlockColorable) this.BlockColor2Id.fromId(Block.getIdByBlock(blockState.getBlock()));
return blockColorable == null ? -1 : blockColorable.method_12155(blockState, blockView, blockPos, i);
}

public void method_12158(BlockColorable blockColorable, Block... blocks) {
int i = blocks.length;

for (int j = 0; j < i; ++j) {
Block block = blocks[j];
this.BlockColor2Id.set(blockColorable, Block.getIdByBlock(block));
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances;

import net.minecraft.util.math.MathHelper;
import net.minecraft.world.biome.Biome;

public class FoliageColors {
private static int[] colorMap = new int[65536];

public static void setColorMap(int[] pixels) {
colorMap = pixels;
}

public static int getColor(double temperature, double humidity) {
humidity *= temperature;
int i = (int) ((1.0D - temperature) * 255.0D);
int j = (int) ((1.0D - humidity) * 255.0D);
return colorMap[j << 8 | i];
}

public static int getSpruceColor() {
return 6396257;
}

public static int getBirchColor() {
return 8431445;
}

public static int getDefaultColor() {
return 4764952;
}

public static int getFoliageColor(Biome biome) {
double d = (double) MathHelper.clamp(biome.getTemperature(), 0.0F, 1.0F);
double e = (double) MathHelper.clamp(biome.getRainfall(), 0.0F, 1.0F);
return FoliageColors.getColor(d, e);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances;

import net.minecraft.util.math.MathHelper;
import net.minecraft.world.biome.Biome;

public class GrassColors {
private static int[] colorMap = new int[65536];

public static void setColorMap(int[] map) {
colorMap = map;
}

public static int getColor(double temperature, double humidity) {
humidity *= temperature;
int i = (int) ((1.0D - temperature) * 255.0D);
int j = (int) ((1.0D - humidity) * 255.0D);
int k = j << 8 | i;
return k > colorMap.length ? -65281 : colorMap[k];
}

public static int getGrassColor(Biome biome) {
double d = (double) MathHelper.clamp(biome.getTemperature(), 0.0F, 1.0F);
double e = (double) MathHelper.clamp(biome.getRainfall(), 0.0F, 1.0F);
return GrassColors.getColor(d, e);
}
}



Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances;

import net.minecraft.util.math.MathHelper;

public class ServerSideRedstoneWireBlock {
public static int getWireColor(int powerLevel) {
float f = (float) powerLevel / 15.0F;
float g = f * 0.6F + 0.4F;
if (powerLevel == 0) {
g = 0.3F;
}

float h = f * f * 0.7F - 0.5F;
float j = f * f * 0.6F - 0.7F;
if (h < 0.0F) {
h = 0.0F;
}

if (j < 0.0F) {
j = 0.0F;
}

int k = MathHelper.clamp((int) (g * 255.0F), 0, 255);
int l = MathHelper.clamp((int) (h * 255.0F), 0, 255);
int m = MathHelper.clamp((int) (j * 255.0F), 0, 255);
return -16777216 | k << 16 | l << 8 | m;
}
}
13 changes: 13 additions & 0 deletions 1.10.2/src/main/java/dev/u9g/minecraftdatagenerator/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package dev.u9g.minecraftdatagenerator;

import net.fabricmc.api.ModInitializer;

import java.util.logging.Logger;

public class Main implements ModInitializer {
public static final Logger LOGGER = Logger.getLogger("mc-data-gen-serv");

@Override
public void onInitialize() {
}
}
Loading

0 comments on commit a48fb99

Please sign in to comment.