Skip to content

Commit

Permalink
feat: registrar test
Browse files Browse the repository at this point in the history
  • Loading branch information
CallMeEchoCodes committed Aug 28, 2024
1 parent 16740b6 commit 418b677
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package dev.spiritstudios.testmod;

import net.fabricmc.fabric.api.gametest.v1.FabricGameTest;
import net.minecraft.test.GameTest;
import net.minecraft.test.TestContext;
import net.minecraft.util.math.BlockPos;

@SuppressWarnings("unused")
public class SpecterRegistryGameTest {
@GameTest(templateName = FabricGameTest.EMPTY_STRUCTURE)
public void testRegistrar(TestContext context) {
context.setBlockState(new BlockPos(0, 1, 0), SpecterRegistryTestBlockRegistrar.TEST_BLOCK);

context.expectBlock(SpecterRegistryTestBlockRegistrar.TEST_BLOCK, new BlockPos(0, 1, 0));
context.complete();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package dev.spiritstudios.testmod;

import dev.spiritstudios.specter.api.registry.registration.BlockRegistrar;
import net.minecraft.block.Block;

@SuppressWarnings("unused")
public class SpecterRegistryTestBlockRegistrar implements BlockRegistrar {
public static final Block TEST_BLOCK = new Block(Block.Settings.copy(net.minecraft.block.Blocks.STONE));
}
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
package dev.spiritstudios.testmod;

import com.mojang.serialization.Codec;
import dev.spiritstudios.specter.api.registry.attachment.Attachment;
import dev.spiritstudios.specter.api.registry.registration.Registrar;
import net.fabricmc.api.ModInitializer;

import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;

import net.minecraft.block.Block;
import net.minecraft.network.codec.PacketCodecs;
import net.minecraft.registry.Registries;

import dev.spiritstudios.specter.api.registry.attachment.Attachment;
import net.minecraft.util.Identifier;

public class SpecterRegistryTestMod implements ModInitializer {

public static final String MOD_ID = "specter-registry-testmod";
public static final Identifier ATTACHMENT_ID = Identifier.of(MOD_ID, "attachment_test");
public static final Attachment<Block, Integer> TEST_ATTACHMENT = Attachment.builder(
Registries.BLOCK,
ATTACHMENT_ID,
Codec.INT,
PacketCodecs.INTEGER.cast()
Registries.BLOCK,
ATTACHMENT_ID,
Codec.INT,
PacketCodecs.INTEGER.cast()
).build();

@Override
public void onInitialize() {
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
SpecterRegistryTestCommand.register(dispatcher);
});

Registrar.process(SpecterRegistryTestBlockRegistrar.class, "specter-registry-testmod");
}

}
5 changes: 4 additions & 1 deletion specter-registry/src/testmod/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
"environment": "*",
"entrypoints": {
"main": [
"dev.spiritstudios.testmod.SpecterRegistryTestMod"
"dev.spiritstudios.testmod.SpecterRegistryTestMod"
],
"fabric-gametest": [
"dev.spiritstudios.testmod.SpecterRegistryGameTest"
]
},
"depends": {
Expand Down

0 comments on commit 418b677

Please sign in to comment.