Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.20' into multiblocks
Browse files Browse the repository at this point in the history
  • Loading branch information
maximumpower55 committed Nov 8, 2023
2 parents c5b26cd + add345b commit 67e6564
Show file tree
Hide file tree
Showing 52 changed files with 9,572 additions and 9 deletions.
18 changes: 18 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,29 @@ dependencies {

// dependencies
modImplementation("org.quiltmc.quilted-fabric-api:quilted-fabric-api:$qfapi_version")
include(implementation(annotationProcessor("io.github.llamalad7:mixinextras-fabric:$mixin_extras_version")))

// dev env
modLocalRuntime("com.terraformersmc:modmenu:$mod_menu_version")
}

loom {
runs {
datagen {
client()

name "Minecraft Data"
vmArg "-Dfabric-api.datagen"
vmArg "-Dfabric-api.datagen.output-dir=${file("src/generated/resources")}"
vmArg "-Dfabric-api.datagen.modid=portalcubed"
}

configureEach {
vmArg("-Dmixin.debug.export=true")
}
}
}

tasks.register("buildOrPublish") {
group = "build"
String mavenUser = System.getenv("MAVEN_USER")
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ loader_version = 0.21.2-beta.2
qfapi_version = 7.4.0+0.90.0-1.20.1
qm_build = 23

mixin_extras_version = 0.2.0

# Dev env mods
# https://modrinth.com/mod/modmenu/versions
mod_menu_version = 7.1.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.github.fusionflux.portalcubed;

import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint;
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;

public class PortalCubedDataGen implements DataGeneratorEntrypoint {
@Override
public void onInitializeDataGenerator(FabricDataGenerator generator) {
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.fusionflux.portalcubed.framework.registration.block;

import io.github.fusionflux.portalcubed.framework.registration.RenderTypes;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;

import org.quiltmc.qsl.block.extensions.api.QuiltBlockSettings;
Expand Down Expand Up @@ -33,6 +34,11 @@ public interface BlockBuilder<T extends Block> {
*/
BlockBuilder<T> item(BlockItemProvider<T> provider);

/**
* Set the factory for this block's item.
*/
<I extends Item> BlockBuilder<T> item(BlockItemFactory<T> factory);

/**
* Build this builder into a block.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class BlockBuilderImpl<T extends Block> implements BlockBuilder<T> {
private RenderTypes renderType;
@Nullable
private BlockItemProvider<T> itemProvider = BlockBuilderImpl::defaultBlock;
private BlockItemFactory<T> itemFactory = BlockItem::new;

public BlockBuilderImpl(Registrar registrar, String name, BlockFactory<T> factory) {
this.registrar = registrar;
Expand Down Expand Up @@ -69,6 +70,12 @@ public BlockBuilder<T> item(BlockItemProvider<T> provider) {
return this;
}

@Override
public <I extends Item> BlockBuilder<T> item(BlockItemFactory<T> factory) {
this.itemFactory = factory;
return this;
}

@Override
public T build() {
checkSettings();
Expand All @@ -78,12 +85,12 @@ public T build() {

Item item = null;
if (this.itemProvider != null) {
ItemBuilder<Item> itemBuilder = registrar.items.create(this.name, settings -> new BlockItem(block, settings));
ItemBuilder<Item> modifiedBuilder = this.itemProvider.create(block, itemBuilder);
ItemBuilder<Item> itemBuilder = registrar.items.create(
this.name, settings -> this.itemFactory.create(block, settings)
);
ItemBuilder<Item> modifiedBuilder = this.itemProvider.create(this.name, block, itemBuilder);
if (modifiedBuilder != null) {
item = modifiedBuilder.build();
// TODO: JAY
// Registry.register(BuiltInRegistries.ITEM, id, item);
item = modifiedBuilder.build(); // registers the item
}
}

Expand Down Expand Up @@ -113,7 +120,7 @@ private void checkSettings() {
}
}

private static ItemBuilder<Item> defaultBlock(Block block, ItemBuilder<Item> builder) {
private static ItemBuilder<Item> defaultBlock(String name, Block block, ItemBuilder<Item> builder) {
return builder;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.github.fusionflux.portalcubed.framework.registration.block;

import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;

public interface BlockItemFactory<T extends Block> {
Item create(T block, Item.Properties properties);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import net.minecraft.world.level.block.Block;

public interface BlockItemProvider<B extends Block> {
ItemBuilder<Item> create(B block, ItemBuilder<Item> builder);
ItemBuilder<Item> create(String name, B block, ItemBuilder<Item> builder);

static ItemBuilder<Item> noItem(Block block, ItemBuilder<Item> builder) {
static ItemBuilder<Item> noItem(String name, Block block, ItemBuilder<Item> builder) {
return null;
}
}
Binary file modified src/main/resources/assets/portalcubed/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 67e6564

Please sign in to comment.