Skip to content

Commit

Permalink
Update to 1.15.1
Browse files Browse the repository at this point in the history
  • Loading branch information
LexManos committed Dec 18, 2019
1 parent ba0877e commit d5d4cef
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 71 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ apply plugin: 'eclipse'
apply plugin: 'maven-publish'

ext {
MC_VERSION = '1.14.4'
FORGE_VERSION = '28.1.0'
MC_VERSION = '1.15.1'
FORGE_VERSION = '30.0.7'
MY_VERSION = gitVersion()
MODID = 'chunknogobyebye'
changelog = rootProject.file('build/changelog.txt')
Expand Down Expand Up @@ -72,7 +72,7 @@ minecraft {
data {
workingDirectory project.file('run')
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
property 'forge.logging.console.level', 'debug'
property 'forge.logging.console.level', 'info'

args '--mod', MODID, '--all', '--output', file('src/generated/resources/')

Expand Down
83 changes: 20 additions & 63 deletions src/main/java/net/minecraftforge/lex/cngbb/DataCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,29 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TreeMap;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Supplier;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.util.TriConsumer;

import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.common.collect.ImmutableList;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import com.mojang.datafixers.util.Pair;

import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.DirectoryCache;
import net.minecraft.data.IDataProvider;
import net.minecraft.data.IFinishedRecipe;
import net.minecraft.data.LootTableProvider;
import net.minecraft.data.RecipeProvider;
import net.minecraft.data.ShapedRecipeBuilder;
import net.minecraft.data.loot.BlockLootTables;
Expand All @@ -57,15 +57,15 @@
import net.minecraft.world.storage.loot.LootParameterSet;
import net.minecraft.world.storage.loot.LootParameterSets;
import net.minecraft.world.storage.loot.LootTable;
import net.minecraft.world.storage.loot.LootTableManager;
import net.minecraft.world.storage.loot.LootTables;
import net.minecraft.world.storage.loot.ValidationTracker;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
import net.minecraftforge.fml.event.lifecycle.GatherDataEvent;

@EventBusSubscriber(modid = MODID, bus = Bus.MOD)
public class DataCreator {
@SuppressWarnings("unused")
private static final Logger LOGGER = LogManager.getLogger();
private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().create();

Expand Down Expand Up @@ -98,19 +98,8 @@ private static void save(DirectoryCache cache, Object object, Path target) throw
}

private static class Recipes extends RecipeProvider {
private final DataGenerator gen;
private final Path ADV_ROOT;

public Recipes(DataGenerator gen) {
super(gen);
this.gen = gen;
ADV_ROOT = this.gen.getOutputFolder().resolve("data/minecraft/advancements/recipes/root.json");
}

@Override
protected void saveRecipeAdvancement(DirectoryCache cache, JsonObject json, Path path) {
if (path.equals(ADV_ROOT)) return; //We NEVER care about this.
super.saveRecipeAdvancement(cache, json, path);
}

@Override
Expand All @@ -123,73 +112,41 @@ protected void registerRecipes(Consumer<IFinishedRecipe> consumer) {
}
}

private static class Loots implements IDataProvider {
private final DataGenerator gen;

private static class Loots extends LootTableProvider {
public Loots(DataGenerator gen) {
this.gen = gen;
super(gen);
}


@Override
public String getName() {
return "LootTables";
}

@Override
public void act(DirectoryCache cache) {
Map<ResourceLocation, LootTable> map = Maps.newHashMap();
TriConsumer<LootParameterSet, ResourceLocation, LootTable.Builder> consumer = (set, key, builder) -> {
if (map.put(key, builder.setParameterSet(set).build()) != null)
throw new IllegalStateException("Duplicate loot table " + key);
};

new Blocks().accept((key, builder) -> consumer.accept(LootParameterSets.BLOCK, key, builder));

map.forEach((key, table) -> {
Path target = this.gen.getOutputFolder().resolve("data/" + key.getNamespace() + "/loot_tables/" + key.getPath() + ".json");

try {
IDataProvider.save(GSON, cache, LootTableManager.toJson(table), target);
} catch (IOException ioexception) {
LOGGER.error("Couldn't save loot table {}", target, ioexception);
}
});
protected List<Pair<Supplier<Consumer<BiConsumer<ResourceLocation, LootTable.Builder>>>, LootParameterSet>> getTables() {
return ImmutableList.of(Pair.of(Blocks::new, LootParameterSets.BLOCK));
}

@Override
protected void validate(Map<ResourceLocation, LootTable> map, ValidationTracker tracker) {} //We don't do validation

private class Blocks extends BlockLootTables {
private Set<Block> knownBlocks = new HashSet<>();

private void addTables() {
protected void addTables() {
this.func_218492_c(LOADER_BLOCK.get());
}

@Override
public void accept(BiConsumer<ResourceLocation, LootTable.Builder> consumer) {
this.addTables();

Set<ResourceLocation> visited = Sets.newHashSet();

for(Block block : knownBlocks) {
ResourceLocation tabke_name = block.getLootTable();
if (tabke_name != LootTables.EMPTY && visited.add(tabke_name)) {
LootTable.Builder builder = this.field_218581_i.remove(tabke_name);
if (builder == null)
throw new IllegalStateException(String.format("Missing loottable '%s' for '%s'", tabke_name, block.getRegistryName()));

consumer.accept(tabke_name, builder);
}
}

if (!this.field_218581_i.isEmpty())
throw new IllegalStateException("Created block loot tables for non-blocks: " + this.field_218581_i.keySet());
}

@Override
public void func_218492_c(Block block) {
knownBlocks.add(block);
super.func_218492_c(block);
}

@Override
protected Iterable<Block> getKnownBlocks() {
return this.knownBlocks;
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
modLoader="javafml"
loaderVersion="[28,)"
loaderVersion="[30,)"
# A URL to refer people to when problems occur with this mod
#issueTrackerURL="http://my.issue.tracker/" #optional

Expand All @@ -17,13 +17,13 @@ loaderVersion="[28,)"
[[dependencies.chunknogobyebye]]
modId="forge"
mandatory=true
versionRange="[28.1,)"
versionRange="[30,)"
ordering="NONE"
side="BOTH"

[[dependencies.chunknogobyebye]]
modId="minecraft"
mandatory=true
versionRange="[1.14.4]"
versionRange="[1.15.1]"
ordering="NONE"
side="BOTH"
4 changes: 2 additions & 2 deletions src/main/resources/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"pack": {
"description": "examplemod resources",
"pack_format": 4,
"description": "ChunkNoGoByeBye",
"pack_format": 5,
"_comment": "A pack_format of 4 requires json lang files. Note: we require v4 pack meta for all mods."
}
}

0 comments on commit d5d4cef

Please # to comment.