Skip to content

Commit

Permalink
port to 1.20.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Minecraftschurli committed Jun 16, 2024
1 parent 1459d29 commit d7a9c4d
Show file tree
Hide file tree
Showing 2,796 changed files with 8,304 additions and 9,481 deletions.
8 changes: 7 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ helper.withTestSourceSet()

dependencies {
implementation(helper.neoforge())
testImplementation("net.neoforged:testframework:${helper.neoVersion.get()}")
testImplementation(helper.testframework())
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1")
}

tasks.named<Test>("test") {
useJUnitPlatform()
}

minecraft.accessTransformers.file("src/main/resources/META-INF/accesstransformer.cfg")
Expand Down
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G
org.gradle.daemon=false
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.configuration-cache=true
#org.gradle.configuration-cache=true

mod.group=com.github.minecraftschurlimods
mod.id=bibliocraft
Expand All @@ -15,7 +15,7 @@ mod.credits=Nuchaz for creating the original mod
mod.logo=logo.png
mod.url=https://www.curseforge.com/minecraft/mc-mods/bibliocraft-legacy

java_version=17
java_version=21

github.owner=MinecraftschurliMods
github.repo=Bibliocraft-Legacy
Expand All @@ -24,12 +24,12 @@ license.name=MIT
license.url=https://opensource.org/licenses/MIT

neogradle.subsystems.parchment.minecraftVersion=1.20.4
neogradle.subsystems.parchment.mappingsVersion=2024.02.25
neogradle.subsystems.parchment.mappingsVersion=2024.04.14

mc_version=1.20.4
mc_version_range=[1.20.4,1.20.5)
mc_version=1.20.6
mc_version_range=[1.20.6,1.21)

neo_version=20.4.233
neo_version_range=[20.4.233,20.5)
neo_version=20.6.84-beta
neo_version_range=[20.6.73-beta,21)

loader.version=[1,)
loader.version=[3,)
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pluginManagement {
plugins {
id("net.neoforged.gradle.userdev") version "7.0.133"
id("net.neoforged.gradle.userdev") version "7.0.142"
id("com.github.minecraftschurlimods.helperplugin") version "1.13"
}
repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ static BibliocraftWoodTypeRegistry getWoodTypeRegistry() {
*/
@ApiStatus.Internal
final class InstanceHolder {
private static final Lazy<BibliocraftDatagenHelper> DATAGEN_HELPER = Lazy.concurrentOf(fromServiceLoader(BibliocraftDatagenHelper.class));
private static final Lazy<BibliocraftWoodTypeRegistry> WOOD_TYPE_REGISTRY = Lazy.concurrentOf(fromServiceLoader(BibliocraftWoodTypeRegistry.class));
private static final Lazy<BibliocraftDatagenHelper> DATAGEN_HELPER = Lazy.of(fromServiceLoader(BibliocraftDatagenHelper.class));
private static final Lazy<BibliocraftWoodTypeRegistry> WOOD_TYPE_REGISTRY = Lazy.of(fromServiceLoader(BibliocraftWoodTypeRegistry.class));
private InstanceHolder() {}

private static <T> Supplier<T> fromServiceLoader(Class<T> clazz) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
import net.minecraft.data.DataProvider;
import net.minecraft.data.PackOutput;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.common.data.ExistingFileHelper;
import net.neoforged.neoforge.data.event.GatherDataEvent;
import org.apache.commons.lang3.function.TriFunction;

import java.util.concurrent.CompletableFuture;
import java.util.function.BiFunction;

@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, modid = BibliocraftApi.MOD_ID)
@EventBusSubscriber(bus = EventBusSubscriber.Bus.MOD, modid = BibliocraftApi.MOD_ID)
public final class BCDatagen {
@SubscribeEvent
private static void gatherData(GatherDataEvent event) {
Expand All @@ -39,10 +39,10 @@ private static void gatherData(GatherDataEvent event) {
client.addProvider(wrapWith(BCItemModelProvider::new, existingFileHelper));
client.addProvider(wrapWith(BCSoundDefinitionsProvider::new, existingFileHelper));

server.addProvider(BCLootTableProvider::new);
server.addProvider(BCRecipeProvider::new);
server.addProvider(wrapWith(BCLootTableProvider::new, lookupProvider));
BCBlockTagsProvider blockTags = server.addProvider(wrapWith(BCBlockTagsProvider::new, lookupProvider, existingFileHelper));
server.addProvider(wrapWith(BCItemTagsProvider::new, lookupProvider, blockTags.contentsGetter(), existingFileHelper));
server.addProvider(wrapWith(BCRecipeProvider::new, lookupProvider));
}

private static <T extends DataProvider, S> DataProvider.Factory<T> wrapWith(BiFunction<PackOutput, S, T> factory, S s) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public BCSoundDefinitionsProvider(PackOutput output, ExistingFileHelper helper)

@Override
public void registerSounds() {
add(BCSoundEvents.DESK_BELL.get(), SoundDefinition.definition().with(
add(BCSoundEvents.DESK_BELL.value(), SoundDefinition.definition().with(
sound(new ResourceLocation(BibliocraftApi.MOD_ID, "desk_bell_1")),
sound(new ResourceLocation(BibliocraftApi.MOD_ID, "desk_bell_2")),
sound(new ResourceLocation(BibliocraftApi.MOD_ID, "desk_bell_3")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ protected void addTags(HolderLookup.Provider lookupProvider) {
tag(BCTags.Items.POTION_SHELF_POTIONS).add(Items.POTION, Items.SPLASH_POTION, Items.LINGERING_POTION, Items.GLASS_BOTTLE, Items.EXPERIENCE_BOTTLE, Items.HONEY_BOTTLE, Items.DRAGON_BREATH);
tag(BCTags.Items.SWORD_PEDESTAL_SWORDS).addTag(ItemTags.SWORDS);
tag(BCTags.Items.TOOL_RACK_TOOLS).addTag(Tags.Items.TOOLS);
tag(ItemTags.DYEABLE).add(BCItems.SWORD_PEDESTAL.get());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.github.minecraftschurlimods.bibliocraft.api.BibliocraftApi;
import com.github.minecraftschurlimods.bibliocraft.init.BCBlocks;
import com.github.minecraftschurlimods.bibliocraft.util.DatagenUtil;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.component.DataComponents;
import net.minecraft.data.PackOutput;
import net.minecraft.data.loot.BlockLootSubProvider;
import net.minecraft.data.loot.LootTableProvider;
Expand All @@ -13,22 +15,19 @@
import net.minecraft.world.level.storage.loot.LootTable;
import net.minecraft.world.level.storage.loot.ValidationContext;
import net.minecraft.world.level.storage.loot.entries.LootItem;
import net.minecraft.world.level.storage.loot.functions.CopyNbtFunction;
import net.minecraft.world.level.storage.loot.functions.CopyComponentsFunction;
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
import net.minecraft.world.level.storage.loot.providers.nbt.ContextNbtProvider;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CompletableFuture;

public final class BCLootTableProvider extends LootTableProvider {
public BCLootTableProvider(PackOutput output) {
super(output, Set.of(), List.of(new SubProviderEntry(BCBlockLootProvider::new, LootContextParamSets.BLOCK)));
}

@Override
protected void validate(Map<ResourceLocation, LootTable> map, ValidationContext validationcontext) {
public BCLootTableProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookup) {
super(output, Set.of(), List.of(new SubProviderEntry(BCBlockLootProvider::new, LootContextParamSets.BLOCK)), lookup);
}

private static final class BCBlockLootProvider extends BlockLootSubProvider {
Expand All @@ -53,7 +52,7 @@ protected void generate() {
add(BCBlocks.DISC_RACK.get(), DatagenUtil.createNameableTable(BCBlocks.DISC_RACK.get()));
add(BCBlocks.WALL_DISC_RACK.get(), DatagenUtil.createNameableTable(BCBlocks.DISC_RACK.get()));
add(BCBlocks.IRON_FANCY_ARMOR_STAND.get(), DatagenUtil.createFancyArmorStandTable(BCBlocks.IRON_FANCY_ARMOR_STAND.get()));
add(BCBlocks.SWORD_PEDESTAL.get(), DatagenUtil.createStandardTable(LootItem.lootTableItem(BCBlocks.SWORD_PEDESTAL.get()).apply(CopyNbtFunction.copyData(ContextNbtProvider.BLOCK_ENTITY).copy("color", "display.color"))));
add(BCBlocks.SWORD_PEDESTAL.get(), DatagenUtil.createStandardTable(LootItem.lootTableItem(BCBlocks.SWORD_PEDESTAL.get()).apply(CopyComponentsFunction.copyComponents(CopyComponentsFunction.Source.BLOCK_ENTITY).include(DataComponents.DYED_COLOR))));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.github.minecraftschurlimods.bibliocraft.api.BibliocraftApi;
import com.github.minecraftschurlimods.bibliocraft.init.BCItems;
import com.github.minecraftschurlimods.bibliocraft.util.BCUtil;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.component.DataComponents;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.data.PackOutput;
import net.minecraft.data.recipes.RecipeCategory;
Expand All @@ -13,26 +15,31 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey;
import net.minecraft.util.FastColor;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.DyeItem;
import net.minecraft.world.item.DyeableLeatherItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.component.DyedItemColor;
import net.neoforged.neoforge.common.Tags;

import java.util.List;
import java.util.concurrent.CompletableFuture;

public final class BCRecipeProvider extends RecipeProvider {
public BCRecipeProvider(PackOutput output) {
super(output);
public BCRecipeProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookup) {
super(output, lookup);
}

@Override
protected void buildRecipes(RecipeOutput output) {
BibliocraftApi.getDatagenHelper().generateRecipes(output, BibliocraftApi.MOD_ID);
for (DyeColor color : DyeColor.values()) {
String name = color.getSerializedName();
ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, DyeableLeatherItem.dyeArmor(new ItemStack(BCItems.SWORD_PEDESTAL.get()), List.of(DyeItem.byColor(color))))
ItemStack result = new ItemStack(BCItems.SWORD_PEDESTAL.get());
float[] c = color.getTextureDiffuseColors();
result.set(DataComponents.DYED_COLOR, new DyedItemColor(FastColor.ARGB32.colorFromFloat(1, c[0], c[1], c[2]), false));
ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, result)
.pattern(" S ")
.pattern("SWS")
.define('S', Items.SMOOTH_STONE_SLAB)
Expand Down Expand Up @@ -64,7 +71,7 @@ protected void buildRecipes(RecipeOutput output) {
.pattern("CGC")
.pattern(" I ")
.pattern("NIN")
.define('C', Tags.Items.GLASS_COLORLESS)
.define('C', Tags.Items.GLASS_BLOCKS_COLORLESS)
.define('G', Items.GLOWSTONE)
.define('I', Tags.Items.INGOTS_GOLD)
.define('N', Tags.Items.NUGGETS_GOLD)
Expand All @@ -74,7 +81,7 @@ protected void buildRecipes(RecipeOutput output) {
.pattern("CGC")
.pattern(" I ")
.pattern("NIN")
.define('C', Tags.Items.GLASS_COLORLESS)
.define('C', Tags.Items.GLASS_BLOCKS_COLORLESS)
.define('G', Items.GLOWSTONE)
.define('I', Tags.Items.INGOTS_IRON)
.define('N', Tags.Items.NUGGETS_IRON)
Expand Down
Loading

0 comments on commit d7a9c4d

Please sign in to comment.