Skip to content

Commit

Permalink
Compile data provider
Browse files Browse the repository at this point in the history
  • Loading branch information
Kotori316 committed Dec 16, 2024
1 parent 6739feb commit c53e8f3
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 19 deletions.
3 changes: 3 additions & 0 deletions dependency-check/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id("com.kotori316.common")
id("scala")
}

dependencies {
Expand All @@ -10,4 +11,6 @@ dependencies {
version = project.property("parchment.mapping").toString(),
ext = "zip",
)
// Scala 3
implementation(libs.scala)
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,24 @@ class QuarryDataCommonGenerator {
object QuarryDataCommonGenerator {
@static
@SubscribeEvent
def onEvent(event: GatherDataEvent): Unit = {
def onEvent(event: GatherDataEvent.Client): Unit = {
QuarryPlus.LOGGER.info("Start common data generation")
val enchantmentProvider = new EnchantmentProvider(event.getGenerator.getPackOutput, event.getLookupProvider)
event.getGenerator.addProvider(event.includeServer, enchantmentProvider)
event.getGenerator.addProvider(event.includeServer, new LootTableProvider(event.getGenerator.getPackOutput, Collections.emptySet(),
event.addProvider(enchantmentProvider)
event.addProvider(new LootTableProvider(event.getGenerator.getPackOutput, Collections.emptySet(),
CollectionConverters.asJava(Seq(new LootTableProvider.SubProviderEntry(r => new BlockDropProvider(r), LootContextParamSets.BLOCK))),
event.getLookupProvider
))
event.getGenerator.addProvider(event.includeClient, StateAndModelProvider(event.getGenerator, event.getExistingFileHelper))
event.getGenerator.addProvider(event.includeClient, QuarrySpriteSourceProvider(event.getGenerator.getPackOutput, event.getLookupProvider, event.getExistingFileHelper))
event.getGenerator.addProvider(true, PackMetadataGenerator(event.getGenerator.getPackOutput)
event.addProvider(StateAndModelProvider(event.getGenerator, event.getExistingFileHelper))
event.addProvider(QuarrySpriteSourceProvider(event.getGenerator.getPackOutput, event.getLookupProvider, event.getExistingFileHelper))
event.addProvider(PackMetadataGenerator(event.getGenerator.getPackOutput)
.add(PackMetadataSection.TYPE, PackMetadataSection(Component.literal("QuarryPlus Resource"), DetectedVersion.BUILT_IN.getPackVersion(PackType.CLIENT_RESOURCES)))
)

val blockTag = QuarryBlockTagProvider(event.getGenerator.getPackOutput, event.getLookupProvider, event.getExistingFileHelper)
val itemTag = QuarryItemTagProvider(event.getGenerator.getPackOutput, event.getLookupProvider, event.getExistingFileHelper, blockTag.contentsGetter())
event.getGenerator.addProvider(event.includeServer, blockTag)
event.getGenerator.addProvider(event.includeServer, itemTag)
event.getGenerator.addProvider(event.includeServer, QuarryEnchantmentTagProvider(event.getGenerator.getPackOutput, enchantmentProvider, event.getExistingFileHelper))
event.addProvider(blockTag)
event.addProvider(itemTag)
event.addProvider(QuarryEnchantmentTagProvider(event.getGenerator.getPackOutput, enchantmentProvider, event.getExistingFileHelper))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.yogpc.qp.machine.QpBlockProperty;
import com.yogpc.qp.machine.QpItem;
import com.yogpc.qp.neoforge.PlatformAccessNeoForge;
import net.minecraft.client.renderer.RenderStateShard;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.core.Direction;
import net.minecraft.core.registries.BuiltInRegistries;
Expand Down Expand Up @@ -79,14 +80,14 @@ protected void registerStatesAndModels() {

void frame() {
var center = models().getBuilder("block/frame_post")
.renderType(RenderType.cutout().name)
.renderType(renderTypeName(RenderType.cutout()))
.texture("texture", blockTexture("frame"))
.texture("particle", blockTexture("frame"))
.element().from(4.0f, 4.0f, 4.0f).to(12.0f, 12.0f, 12.0f)
.allFaces((direction, faceBuilder) -> faceBuilder.uvs(4, 4, 12, 12).texture("#texture"))
.end();
var side = models().getBuilder("block/frame_side")
.renderType(RenderType.cutout().name)
.renderType(renderTypeName(RenderType.cutout()))
.texture("texture", blockTexture("frame"))
.texture("particle", blockTexture("frame"))
.element().from(4, 4, 0).to(12, 12, 4)
Expand Down Expand Up @@ -118,9 +119,9 @@ void frame() {
}

void dummyBlocks() {
var dummyReplacerModel = models().withExistingParent("block/dummy_replacer", ResourceLocation.fromNamespaceAndPath("minecraft", "block/glass")).renderType(RenderType.translucent().name);
var dummyReplacerModel = models().withExistingParent("block/dummy_replacer", ResourceLocation.fromNamespaceAndPath("minecraft", "block/glass")).renderType(renderTypeName(RenderType.translucent()));
itemModels().withExistingParent("item/dummy_replacer", ResourceLocation.fromNamespaceAndPath("minecraft", "block/glass"));
var dummyBlockModel = models().cubeAll("block/dummy_block", blockTexture("dummy_block")).renderType(RenderType.translucent().name);
var dummyBlockModel = models().cubeAll("block/dummy_block", blockTexture("dummy_block")).renderType(renderTypeName(RenderType.translucent()));

simpleBlock(PlatformAccessNeoForge.RegisterObjectsNeoForge.BLOCK_SOFT.get(), dummyBlockModel);
simpleBlockItem(PlatformAccessNeoForge.RegisterObjectsNeoForge.BLOCK_SOFT.get(), dummyBlockModel);
Expand Down Expand Up @@ -403,4 +404,14 @@ void waterloggedMarkers() {
simpleBlockItem(marker, m);
}
}

private static String renderTypeName(RenderStateShard type) {
try {
var field = RenderStateShard.class.getDeclaredField("name");
field.setAccessible(true);
return (String) field.get(type);
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import net.minecraft.tags.TagKey
import net.minecraft.world.item.crafting.Ingredient
import net.minecraft.world.item.{Item, Items}
import net.neoforged.neoforge.common.Tags
import net.neoforged.neoforge.common.conditions.FalseCondition
import net.neoforged.neoforge.common.conditions.NeverCondition

final class IngredientProviderNeoForge(itemRegistry: HolderGetter[Item]) extends IngredientProvider(itemRegistry) {
override def glowStoneDust: Ingredient = Ingredient.of(itemRegistry.getOrThrow(Tags.Items.DUSTS_GLOWSTONE))
Expand Down Expand Up @@ -35,7 +35,7 @@ final class IngredientProviderNeoForge(itemRegistry: HolderGetter[Item]) extends
override def diamondBlock: Ingredient = Ingredient.of(itemRegistry.getOrThrow(Tags.Items.STORAGE_BLOCKS_DIAMOND))

override def installBedrockModuleQuarryRecipeOutput(original: RecipeOutput): RecipeOutput = {
original.withConditions(FalseCondition.INSTANCE)
original.withConditions(NeverCondition.INSTANCE)
}

override def enderPearl: Ingredient = Ingredient.of(itemRegistry.getOrThrow(Tags.Items.ENDER_PEARLS))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import scala.annotation.static
object QuarryDataGenerator {
@static
@SubscribeEvent
def onEvent(event: GatherDataEvent): Unit = {
def onEvent(event: GatherDataEvent.Client): Unit = {
QuarryPlus.LOGGER.info("Start NeoForge data generation")
event.getGenerator.addProvider(event.includeServer, new RecipeNeoForge(event.getGenerator.getPackOutput, event.getLookupProvider))
event.addProvider(new RecipeNeoForge(event.getGenerator.getPackOutput, event.getLookupProvider))
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"neoforge:conditions": [
{
"type": "neoforge:false"
"type": "neoforge:never"
}
],
"parent": "minecraft:recipes/root",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"neoforge:conditions": [
{
"type": "neoforge:false"
"type": "neoforge:never"
}
],
"type": "quarryplus:install_bedrock_module_recipe",
Expand Down

0 comments on commit c53e8f3

Please sign in to comment.