feat(projector): baiscs

This commit is contained in:
xtex 2023-06-29 21:43:37 +08:00
parent baf865e80b
commit 0732fc24ef
Signed by: xtex
GPG Key ID: B918086ED8045B91
15 changed files with 106 additions and 64 deletions

View File

@ -1,15 +0,0 @@
package quaedam.mixin;
import net.minecraft.client.gui.screens.TitleScreen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(TitleScreen.class)
public class MixinTitleScreen {
@Inject(at = @At("HEAD"), method = "init()V")
private void init(CallbackInfo info) {
System.out.println("Hello from example architectury common mixin!");
}
}

View File

@ -0,0 +1,50 @@
package quaedam
import net.minecraft.core.BlockPos
import net.minecraft.world.InteractionHand
import net.minecraft.world.InteractionResult
import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.BlockItem
import net.minecraft.world.item.Item
import net.minecraft.world.level.Level
import net.minecraft.world.level.block.Block
import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.material.MapColor
import net.minecraft.world.phys.BlockHitResult
object Projector {
const val ID = "projector"
val block = Quaedam.blocks.register(ID) { ProjectorBlock }
val item = Quaedam.items.register(ID) {
BlockItem(
ProjectorBlock, Item.Properties()
.stacksTo(1)
.`arch$tab`(Quaedam.creativeModeTab)
)
}!!
}
object ProjectorBlock : Block(Properties.of()
.jumpFactor(0.8f)
.lightLevel { 3 }
.mapColor(MapColor.COLOR_BLACK)
.randomTicks()
.destroyTime(4.0f)
.requiresCorrectToolForDrops()) {
override fun use(
blockState: BlockState,
level: Level,
blockPos: BlockPos,
player: Player,
interactionHand: InteractionHand,
blockHitResult: BlockHitResult
): InteractionResult {
return InteractionResult.SUCCESS
}
}

View File

@ -8,31 +8,27 @@ import net.minecraft.network.chat.Component
import net.minecraft.world.item.CreativeModeTab import net.minecraft.world.item.CreativeModeTab
import net.minecraft.world.item.Item import net.minecraft.world.item.Item
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import quaedam.QuaedamExpectPlatform.getConfigDirectory import net.minecraft.world.item.Items
object Quaedam { object Quaedam {
const val MOD_ID = "quaedam"
private val createModeTabs = DeferredRegister.create(MOD_ID, Registries.CREATIVE_MODE_TAB) const val ID = "quaedam"
val exampleTab: RegistrySupplier<CreativeModeTab> = createModeTabs.register("example_tab") {
val creativeModeTabs = DeferredRegister.create(ID, Registries.CREATIVE_MODE_TAB)!!
val items = DeferredRegister.create(ID, Registries.ITEM)!!
val blocks = DeferredRegister.create(ID, Registries.BLOCK)!!
val creativeModeTab: RegistrySupplier<CreativeModeTab> = creativeModeTabs.register("quaedam") {
CreativeTabRegistry.create(Component.translatable("category.quaedam")) { CreativeTabRegistry.create(Component.translatable("category.quaedam")) {
ItemStack(exampleItem.get()) ItemStack(Items.TORCH)
} }
} }
private val items = DeferredRegister.create(MOD_ID, Registries.ITEM)
val exampleItem: RegistrySupplier<Item> = items.register(
"example_item"
) {
Item(
Item.Properties().`arch$tab`(exampleTab) // DON'T CALL GET ON exampleTab HERE
)
}
fun init() { fun init() {
createModeTabs.register() Projector
creativeModeTabs.register()
items.register() items.register()
blocks.register()
}
println("CONFIG DIR: ${getConfigDirectory().toAbsolutePath().normalize()}")
}
} }

View File

@ -1,13 +0,0 @@
package quaedam
import dev.architectury.injectables.annotations.ExpectPlatform
import java.nio.file.Path
object QuaedamExpectPlatform {
@JvmStatic // Make sure its Jvm Static
@ExpectPlatform
fun getConfigDirectory(): Path {
// Just throw an error, the content should get replaced at runtime.
throw AssertionError()
}
}

View File

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "quaedam:block/projector"
}
}
}

View File

@ -1,3 +1,4 @@
{ {
"item.quaedam.example_item": "Example Item" "category.quaedam": "Quaedam",
"block.quaedam.projector": "Projector"
} }

View File

@ -0,0 +1,9 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": []
}
]
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "quaedam:block/projector"
}
}

View File

@ -0,0 +1,3 @@
{
"parent": "quaedam:block/projector"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 397 B

View File

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"quaedam:projector"
]
}

View File

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"quaedam:projector"
]
}

View File

@ -3,7 +3,6 @@
"package": "quaedam.mixin", "package": "quaedam.mixin",
"compatibilityLevel": "JAVA_17", "compatibilityLevel": "JAVA_17",
"client": [ "client": [
"MixinTitleScreen"
], ],
"mixins": [ "mixins": [
], ],

View File

@ -1,14 +0,0 @@
package quaedam.forge
import net.minecraftforge.fml.loading.FMLPaths
import java.nio.file.Path
object QuaedamExpectPlatformImpl {
/**
* This is our actual method to [ExampleExpectPlatform.getConfigDirectory].
*/
@JvmStatic // Jvm Static is required so that java can access it
fun getConfigDirectory(): Path {
return FMLPaths.CONFIGDIR.get()
}
}

View File

@ -5,11 +5,12 @@ import net.minecraftforge.fml.common.Mod
import quaedam.Quaedam import quaedam.Quaedam
import thedarkcolour.kotlinforforge.forge.MOD_BUS import thedarkcolour.kotlinforforge.forge.MOD_BUS
@Mod(Quaedam.MOD_ID) @Mod(Quaedam.ID)
object QuaedamForge { object QuaedamForge {
init { init {
// Submit our event bus to let architectury register our content on the right time EventBuses.registerModEventBus(Quaedam.ID, MOD_BUS)
EventBuses.registerModEventBus(Quaedam.MOD_ID, MOD_BUS)
Quaedam.init() Quaedam.init()
} }
} }