aboutsummaryrefslogtreecommitdiff
path: root/common/src
diff options
context:
space:
mode:
authornea <romangraef@gmail.com>2022-07-12 14:20:22 +0200
committernea <romangraef@gmail.com>2022-07-12 14:20:22 +0200
commit372eec27e5e0c8ef796ed9e6bcdc68a10df84718 (patch)
tree425ab1a282196a68819da297c670e9170a8c514a /common/src
downloadFirmament-372eec27e5e0c8ef796ed9e6bcdc68a10df84718.tar.gz
Firmament-372eec27e5e0c8ef796ed9e6bcdc68a10df84718.tar.bz2
Firmament-372eec27e5e0c8ef796ed9e6bcdc68a10df84718.zip
initial
Diffstat (limited to 'common/src')
-rw-r--r--common/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUReiPlugin.kt140
-rw-r--r--common/src/main/kotlin/net/examplemod/ExampleExpectPlatform.kt30
-rw-r--r--common/src/main/kotlin/net/examplemod/ExampleMod.kt31
-rw-r--r--common/src/main/kotlin/net/examplemod/mixin/MixinTitleScreen.kt23
-rw-r--r--common/src/main/resources/architectury.common.json3
-rw-r--r--common/src/main/resources/assets/examplemod/lang/en_us.json3
-rw-r--r--common/src/main/resources/notenoughupdates-common.mixins.json13
-rw-r--r--common/src/main/resources/notenoughupdates.accesswidener1
8 files changed, 244 insertions, 0 deletions
diff --git a/common/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUReiPlugin.kt b/common/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUReiPlugin.kt
new file mode 100644
index 0000000..de8c689
--- /dev/null
+++ b/common/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUReiPlugin.kt
@@ -0,0 +1,140 @@
+package moe.nea.notenoughupdates.rei
+
+import com.mojang.blaze3d.vertex.PoseStack
+import io.github.moulberry.repo.NEURepository
+import me.shedaniel.math.Point
+import me.shedaniel.math.Rectangle
+import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer
+import me.shedaniel.rei.api.client.gui.widgets.Tooltip
+import me.shedaniel.rei.api.client.plugins.REIClientPlugin
+import me.shedaniel.rei.api.client.registry.entry.EntryRegistry
+import me.shedaniel.rei.api.common.entry.EntrySerializer
+import me.shedaniel.rei.api.common.entry.EntryStack
+import me.shedaniel.rei.api.common.entry.comparison.ComparisonContext
+import me.shedaniel.rei.api.common.entry.type.EntryDefinition
+import me.shedaniel.rei.api.common.entry.type.EntryType
+import me.shedaniel.rei.api.common.entry.type.EntryTypeRegistry
+import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes
+import me.shedaniel.rei.api.common.util.EntryStacks
+import net.minecraft.core.Registry
+import net.minecraft.network.chat.Component
+import net.minecraft.network.chat.TextComponent
+import net.minecraft.resources.ResourceLocation
+import net.minecraft.tags.TagKey
+import net.minecraft.world.item.Item
+import net.minecraft.world.item.ItemStack
+import net.minecraft.world.item.Items
+import net.minecraft.world.item.enchantment.Enchantments
+import java.nio.file.Path
+import java.util.stream.Stream
+
+
+class NEUReiPlugin : REIClientPlugin {
+
+ data class SBItem(val sbname: String, val backing: Item)
+ companion object {
+
+ fun EntryStack<NEUReiPlugin.SBItem>.asItemStack() =
+ EntryStack.of(VanillaEntryTypes.ITEM, ItemStack(this.value.backing).also {
+ it.enchant(Enchantments.BINDING_CURSE, 1)
+ it.hoverName = TextComponent(value.sbname)
+ })
+
+ val hehe = ResourceLocation("notenoughupdates", "skyblockitems")
+ }
+
+ object SBItemEntryDefinition : EntryDefinition<SBItem> {
+ override fun equals(o1: SBItem?, o2: SBItem?, context: ComparisonContext?): Boolean {
+ return o1 == o2
+ }
+
+ override fun getValueType(): Class<SBItem> = SBItem::class.java
+ override fun getType(): EntryType<SBItem> =
+ EntryType.deferred(hehe)
+
+ override fun getRenderer(): EntryRenderer<SBItem> = object : EntryRenderer<SBItem> {
+ override fun render(
+ entry: EntryStack<SBItem>,
+ matrices: PoseStack,
+ bounds: Rectangle,
+ mouseX: Int,
+ mouseY: Int,
+ delta: Float
+ ) {
+ VanillaEntryTypes.ITEM.definition.renderer
+ .render(
+ entry.asItemStack(),
+ matrices, bounds, mouseX, mouseY, delta
+ )
+ }
+
+ override fun getTooltip(entry: EntryStack<SBItem>, mouse: Point): Tooltip? {
+ return VanillaEntryTypes.ITEM.definition.renderer
+ .getTooltip(entry.asItemStack(), mouse)
+ }
+
+ }
+
+ override fun getSerializer(): EntrySerializer<SBItem>? {
+ return null
+ }
+
+ override fun getTagsFor(entry: EntryStack<SBItem>?, value: SBItem?): Stream<out TagKey<*>> {
+ return Stream.empty()
+ }
+
+ override fun asFormattedText(entry: EntryStack<SBItem>, value: SBItem): Component {
+ return VanillaEntryTypes.ITEM.definition.asFormattedText(entry.asItemStack(), ItemStack(value.backing))
+ }
+
+ override fun hash(entry: EntryStack<SBItem>, value: SBItem, context: ComparisonContext): Long {
+ return value.sbname.hashCode().toLong()
+ }
+
+ override fun wildcard(entry: EntryStack<SBItem>, value: SBItem): SBItem {
+ return value
+ }
+
+ override fun normalize(entry: EntryStack<SBItem>, value: SBItem): SBItem {
+ return value
+ }
+
+ override fun copy(entry: EntryStack<SBItem>?, value: SBItem): SBItem {
+ return value.copy()
+ }
+
+ override fun isEmpty(entry: EntryStack<SBItem>?, value: SBItem?): Boolean {
+ return false
+ }
+
+ override fun getIdentifier(entry: EntryStack<SBItem>?, value: SBItem): ResourceLocation? {
+ return ResourceLocation("skyblockitem", value.sbname)
+ }
+
+
+ }
+
+ val neuRepo = NEURepository.of(Path.of("NotEnoughUpdates-REPO")).also {
+ it.reload()
+ }
+
+ override fun registerEntryTypes(registry: EntryTypeRegistry) {
+ registry.register(hehe, SBItemEntryDefinition)
+ }
+
+ override fun registerEntries(registry: EntryRegistry) {
+ neuRepo.items.items.values.forEach {
+ println("Adding item: $it")
+ registry.addEntry(
+ EntryStack.of(
+ SBItemEntryDefinition, SBItem(
+ it.skyblockItemId.lowercase().replace(";", "__"), Registry.ITEM.get(ResourceLocation(it.minecraftItemId))
+ )
+ )
+ )
+ }
+ registry.addEntry(EntryStacks.of(ItemStack(Items.DIAMOND).also {
+ it.enchant(Enchantments.ALL_DAMAGE_PROTECTION, 10)
+ }))
+ }
+}
diff --git a/common/src/main/kotlin/net/examplemod/ExampleExpectPlatform.kt b/common/src/main/kotlin/net/examplemod/ExampleExpectPlatform.kt
new file mode 100644
index 0000000..4949054
--- /dev/null
+++ b/common/src/main/kotlin/net/examplemod/ExampleExpectPlatform.kt
@@ -0,0 +1,30 @@
+package net.examplemod
+
+import dev.architectury.injectables.annotations.ExpectPlatform
+import dev.architectury.platform.Platform
+import java.nio.file.Path
+
+object ExampleExpectPlatform {
+ /**
+ * We can use [Platform.getConfigFolder] but this is just an example of [ExpectPlatform].
+ *
+ *
+ * This must be a **public static** method. The platform-implemented solution must be placed under a
+ * platform sub-package, with its class suffixed with `Impl`.
+ *
+ *
+ * Example:
+ * Expect: net.examplemod.ExampleExpectPlatform#getConfigDirectory()
+ * Actual Fabric: net.examplemod.fabric.ExampleExpectPlatformImpl#getConfigDirectory()
+ * Actual Forge: net.examplemod.forge.ExampleExpectPlatformImpl#getConfigDirectory()
+ *
+ *
+ * [You should also get the IntelliJ plugin to help with @ExpectPlatform.](https://plugins.jetbrains.com/plugin/16210-architectury)
+ */
+ @ExpectPlatform
+ @JvmStatic
+ fun getConfigDirectory(): Path {
+ // Just throw an error, the content should get replaced at runtime.
+ throw AssertionError()
+ }
+}
diff --git a/common/src/main/kotlin/net/examplemod/ExampleMod.kt b/common/src/main/kotlin/net/examplemod/ExampleMod.kt
new file mode 100644
index 0000000..4f618ce
--- /dev/null
+++ b/common/src/main/kotlin/net/examplemod/ExampleMod.kt
@@ -0,0 +1,31 @@
+package net.examplemod
+
+import com.google.common.base.Suppliers
+import dev.architectury.registry.CreativeTabRegistry
+import dev.architectury.registry.registries.DeferredRegister
+import dev.architectury.registry.registries.Registries
+import dev.architectury.registry.registries.RegistrySupplier
+import net.minecraft.core.Registry
+import net.minecraft.resources.ResourceLocation
+import net.minecraft.world.item.CreativeModeTab
+import net.minecraft.world.item.Item
+import net.minecraft.world.item.ItemStack
+import java.util.function.Supplier
+
+object ExampleMod {
+ const val MOD_ID = "examplemod"
+
+ // We can use this if we don't want to use DeferredRegister
+ @Suppress("unused")
+ val REGISTRIES: Supplier<Registries> = Suppliers.memoize { Registries.get(MOD_ID) }
+
+ // Registering a new creative tab
+ val EXAMPLE_TAB: CreativeModeTab = CreativeTabRegistry.create(ResourceLocation(MOD_ID, "example_tab")) { ItemStack(EXAMPLE_ITEM.get()) }
+ val ITEMS: DeferredRegister<Item> = DeferredRegister.create(MOD_ID, Registry.ITEM_REGISTRY)
+ val EXAMPLE_ITEM: RegistrySupplier<Item> = ITEMS.register("example_item") { Item(Item.Properties().tab(EXAMPLE_TAB)) }
+
+ fun init() {
+ ITEMS.register()
+ println(ExampleExpectPlatform.getConfigDirectory().toAbsolutePath().normalize().toString())
+ }
+}
diff --git a/common/src/main/kotlin/net/examplemod/mixin/MixinTitleScreen.kt b/common/src/main/kotlin/net/examplemod/mixin/MixinTitleScreen.kt
new file mode 100644
index 0000000..0b7e009
--- /dev/null
+++ b/common/src/main/kotlin/net/examplemod/mixin/MixinTitleScreen.kt
@@ -0,0 +1,23 @@
+package net.examplemod.mixin
+
+import net.minecraft.client.gui.screens.TitleScreen
+import org.objectweb.asm.Opcodes
+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.Redirect
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo
+
+@Mixin(TitleScreen::class)
+class MixinTitleScreen {
+ @Inject(at = [At("HEAD")], method = ["init()V"])
+ private fun init(info: CallbackInfo) {
+ println("Hello from example architectury common mixin!")
+ }
+
+ @Redirect(method = ["render"], at = At("FIELD", target = "minceraftEasterEgg", opcode = Opcodes.GETFIELD))
+ private fun nextFloat(t: TitleScreen): Boolean {
+ return true
+ }
+
+}
diff --git a/common/src/main/resources/architectury.common.json b/common/src/main/resources/architectury.common.json
new file mode 100644
index 0000000..017e6cd
--- /dev/null
+++ b/common/src/main/resources/architectury.common.json
@@ -0,0 +1,3 @@
+{
+ "accessWidener": "notenoughupdates.accesswidener"
+}
diff --git a/common/src/main/resources/assets/examplemod/lang/en_us.json b/common/src/main/resources/assets/examplemod/lang/en_us.json
new file mode 100644
index 0000000..6bcd60e
--- /dev/null
+++ b/common/src/main/resources/assets/examplemod/lang/en_us.json
@@ -0,0 +1,3 @@
+{
+ "item.examplemod.example_item": "Example Item"
+} \ No newline at end of file
diff --git a/common/src/main/resources/notenoughupdates-common.mixins.json b/common/src/main/resources/notenoughupdates-common.mixins.json
new file mode 100644
index 0000000..d2e39dc
--- /dev/null
+++ b/common/src/main/resources/notenoughupdates-common.mixins.json
@@ -0,0 +1,13 @@
+{
+ "required": true,
+ "package": "net.examplemod.mixin",
+ "compatibilityLevel": "JAVA_16",
+ "client": [
+ "MixinTitleScreen"
+ ],
+ "mixins": [
+ ],
+ "injectors": {
+ "defaultRequire": 1
+ }
+} \ No newline at end of file
diff --git a/common/src/main/resources/notenoughupdates.accesswidener b/common/src/main/resources/notenoughupdates.accesswidener
new file mode 100644
index 0000000..236e6b1
--- /dev/null
+++ b/common/src/main/resources/notenoughupdates.accesswidener
@@ -0,0 +1 @@
+accessWidener v2 named