Compare commits

..

2 Commits

Author SHA1 Message Date
Dani The Skunk 30610e36b1 abstracted away block registering 2022-10-22 04:47:09 +00:00
Dani The Skunk 7bb294a0d7 moved to mojmaps 2022-10-20 20:42:56 +00:00
4 changed files with 81 additions and 17 deletions

View File

@ -19,14 +19,14 @@ repositories {
// See https://docs.gradle.org/current/userguide/platforms.html for information on how version catalogs work.
dependencies {
minecraft libs.minecraft
mappings variantOf(libs.quilt.mappings) { classifier "intermediary-v2" }
//mappings variantOf(libs.quilt.mappings) { classifier "intermediary-v2" }
// Replace the above line with the block below if you want to use Mojang mappings as your primary mappings, falling back on QM for parameters and Javadocs
/*
mappings loom.layered {
mappings "org.quiltmc:quilt-mappings:${libs.versions.quilt.mappings.get()}:intermediary-v2"
officialMojangMappings()
}
*/
modImplementation libs.quilt.loader
// QSL is not a complete API; You will need Quilted Fabric API to fill in the gaps.

View File

@ -0,0 +1,34 @@
package com.danitheskunk.skunkstuff;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.material.Material;
import org.quiltmc.qsl.block.extensions.api.QuiltBlockSettings;
public class BlockBuilder extends QuiltBlockSettings {
public String name;
public CreativeModeTab creativeModeTab = CreativeModeTab.TAB_MISC;
public Block block;
public BlockBuilder() {
super(QuiltBlockSettings.of(Material.WOOD));
strength(2);
opaque(false);
}
public BlockBuilder name(String name) {
this.name = name;
return this;
}
public BlockBuilder creativeModeTab(CreativeModeTab creativeModeTab) {
this.creativeModeTab = creativeModeTab;
return this;
}
public Block build() {
block = new Block(this);
Blocks.addToDeffered(this);
return block;
}
}

View File

@ -0,0 +1,41 @@
package com.danitheskunk.skunkstuff;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.CreativeModeTab;
import org.quiltmc.qsl.item.setting.api.QuiltItemSettings;
import java.util.ArrayList;
import java.util.List;
public class Blocks {
private static final List<BlockBuilder> deferred = new ArrayList<>();
private static final String namespace = "skunkstuff";
public static BlockBuilder register() {
return new BlockBuilder();
}
public static void addToDeffered(BlockBuilder builder) {
deferred.add(builder);
}
public static void registerAll() {
for(var block : deferred) {
Registry.register(
Registry.BLOCK,
new ResourceLocation(namespace, block.name),
block.block
);
Registry.register(
Registry.ITEM,
new ResourceLocation(namespace, block.name),
new BlockItem(
block.block,
new QuiltItemSettings().group(block.creativeModeTab)
)
);
}
}
}

View File

@ -1,15 +1,8 @@
package com.danitheskunk.skunkstuff;
import net.minecraft.block.Block;
import net.minecraft.block.Material;
import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemGroup;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.level.block.Block;
import org.quiltmc.loader.api.ModContainer;
import org.quiltmc.qsl.base.api.entrypoint.ModInitializer;
import org.quiltmc.qsl.block.extensions.api.QuiltBlockSettings;
import org.quiltmc.qsl.item.setting.api.QuiltItemSettings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -17,14 +10,10 @@ public class SkunkStuff implements ModInitializer {
public static final Logger LOGGER = LoggerFactory.getLogger("SkunkStuff");
public static final Block GOBAN_BLOCK =
new Block(QuiltBlockSettings.of(Material.WOOD).strength(2).opaque(false));
Blocks.register().name("goban").build();
@Override
public void onInitialize(ModContainer mod) {
Registry.register(Registry.BLOCK, new Identifier("skunkstuff", "goban"), GOBAN_BLOCK);
Registry.register(Registry.ITEM, new Identifier("skunkstuff",
"goban"), new BlockItem(GOBAN_BLOCK,
new QuiltItemSettings().group(ItemGroup.MISC)));
LOGGER.info("Hello Quilt world from {}!", mod.metadata().name());
Blocks.registerAll();
}
}