M build.gradle => build.gradle +2 -2
@@ 1,5 1,5 @@
plugins {
- id 'fabric-loom' version '1.8.13'
+ id 'fabric-loom' version '1.9.2'
id 'maven-publish'
}
@@ 22,7 22,7 @@ loom {
splitEnvironmentSourceSets()
mods {
- "me.aleteoryx.mc.fedimc" {
+ "fedimc" {
sourceSet sourceSets.main
sourceSet sourceSets.client
}
A build.sh => build.sh +3 -0
@@ 0,0 1,3 @@
+#!/bin/sh
+./gradlew build
+cp build/libs/fedimc-0.0.1.jar ~/.var/app/org.prismlauncher.PrismLauncher/data/PrismLauncher/instances/fedimc-dev/minecraft/mods/
M src/client/java/me/aleteoryx/mc/fedimc/ClientMod.java => src/client/java/me/aleteoryx/mc/fedimc/ClientMod.java +17 -0
@@ 1,10 1,27 @@
package me.aleteoryx.mc.fedimc;
import net.fabricmc.api.ClientModInitializer;
+import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
+
+import net.minecraft.text.Text;
+import net.minecraft.client.MinecraftClient;
public class ClientMod implements ClientModInitializer {
@Override
public void onInitializeClient() {
CoreMod.LOGGER.info("Hello Fabric client!");
+
+ ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> {
+ if (client.getServer() != null) {
+ chatMessage("This mod requires a dedicated server. Federation is not available in this environment.");
+ }
+ });
+ }
+
+ public static void chatMessage(String message) {
+ MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(CoreMod.prefixMessage(message));
+ }
+ public static void chatMessage(Text message) {
+ MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(CoreMod.prefixMessage(message));
}
}
M src/main/java/me/aleteoryx/mc/fedimc/CoreMod.java => src/main/java/me/aleteoryx/mc/fedimc/CoreMod.java +18 -1
@@ 2,16 2,33 @@ package me.aleteoryx.mc.fedimc;
import net.fabricmc.api.ModInitializer;
+import net.minecraft.text.Style;
+import net.minecraft.text.Text;
+import net.minecraft.text.MutableText;
+import net.minecraft.text.PlainTextContent;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CoreMod implements ModInitializer {
- public static final String MOD_ID = "me.aleteoryx.mc.fedimc";
+ public static final String MOD_ID = "fedimc";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
+ public static final Text chatPrefix = MutableText.of(PlainTextContent.of("[FediMC] "))
+ .setStyle(Style.EMPTY.withBold(true).withColor(0xCDCD00));
+
@Override
public void onInitialize() {
LOGGER.info("Hello Fabric world!");
+
+ ModBlocks.init();
+ }
+
+ public static MutableText prefixMessage(Text contents) {
+ return MutableText.of(PlainTextContent.of("")).append(chatPrefix).append(contents);
+ }
+ public static MutableText prefixMessage(String contents) {
+ return MutableText.of(PlainTextContent.of("")).append(chatPrefix).append(contents);
}
}
A src/main/java/me/aleteoryx/mc/fedimc/ModBlocks.java => src/main/java/me/aleteoryx/mc/fedimc/ModBlocks.java +44 -0
@@ 0,0 1,44 @@
+package me.aleteoryx.mc.fedimc;
+
+import java.util.function.Function;
+
+import net.minecraft.block.AbstractBlock;
+import net.minecraft.block.Block;
+import net.minecraft.item.BlockItem;
+import net.minecraft.item.Item;
+import net.minecraft.registry.Registry;
+import net.minecraft.registry.Registries;
+import net.minecraft.registry.RegistryKey;
+import net.minecraft.registry.RegistryKeys;
+import net.minecraft.sound.BlockSoundGroup;
+import net.minecraft.util.Identifier;
+
+public class ModBlocks {
+ public static Block registerWith(Function<AbstractBlock.Settings, Block> ctor, String name, boolean shouldRegisterItem) {
+ Identifier id = Identifier.of(CoreMod.MOD_ID, name);
+
+ AbstractBlock.Settings blocksettings = AbstractBlock.Settings.create()
+ .registryKey(RegistryKey.of(RegistryKeys.BLOCK, id));
+
+ Block block = ctor.apply(blocksettings);
+
+ if (shouldRegisterItem) {
+ Item.Settings itemsettings = (new Item.Settings())
+ .useBlockPrefixedTranslationKey()
+ .registryKey(RegistryKey.of(RegistryKeys.ITEM, id));
+ BlockItem blockItem = new BlockItem(block, itemsettings);
+ Registry.register(Registries.ITEM, id, blockItem);
+ }
+
+ return Registry.register(Registries.BLOCK, id, block);
+ }
+
+ public static void init() {}
+
+
+ public static final Block ANTENNA = registerWith(
+ (settings) -> new Block(settings.hardness(1.5f)),
+ "antenna",
+ true
+ );
+}
M src/main/java/me/aleteoryx/mc/fedimc/ServerMod.java => src/main/java/me/aleteoryx/mc/fedimc/ServerMod.java +17 -0
@@ 2,9 2,26 @@ package me.aleteoryx.mc.fedimc;
import net.fabricmc.api.DedicatedServerModInitializer;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.network.ServerPlayerEntity;
+import net.minecraft.text.Text;
+
public class ServerMod implements DedicatedServerModInitializer {
@Override
public void onInitializeServer() {
CoreMod.LOGGER.info("Hello Fabric server!");
}
+
+ public static void chatMessage(MinecraftServer server, String message) {
+ server.sendMessage(CoreMod.prefixMessage(message));
+ }
+ public static void chatMessage(MinecraftServer server, Text message) {
+ server.sendMessage(CoreMod.prefixMessage(message));
+ }
+ public static void chatMessage(ServerPlayerEntity player, String message) {
+ player.sendMessage(CoreMod.prefixMessage(message));
+ }
+ public static void chatMessage(ServerPlayerEntity player, Text message) {
+ player.sendMessage(CoreMod.prefixMessage(message));
+ }
}
A src/main/resources/assets/fedimc/blockstates/antenna.json => src/main/resources/assets/fedimc/blockstates/antenna.json +5 -0
@@ 0,0 1,5 @@
+{
+ "variants": {
+ "": { "model": "fedimc:block/antenna" }
+ }
+}
R src/main/resources/assets/modid/icon.png => src/main/resources/assets/fedimc/icon.png +0 -0
A src/main/resources/assets/fedimc/items/antenna.json => src/main/resources/assets/fedimc/items/antenna.json +6 -0
@@ 0,0 1,6 @@
+{
+ "model": {
+ "type": "minecraft:model",
+ "model": "fedimc:block/antenna"
+ }
+}
A src/main/resources/assets/fedimc/lang/en_us.json => src/main/resources/assets/fedimc/lang/en_us.json +3 -0
@@ 0,0 1,3 @@
+{
+ "block.fedimc.antenna": "Fediverse Antenna"
+}
A src/main/resources/assets/fedimc/models/block/antenna.json => src/main/resources/assets/fedimc/models/block/antenna.json +6 -0
@@ 0,0 1,6 @@
+{
+ "parent": "block/cube_all",
+ "textures": {
+ "all": "fedimc:block/antenna"
+ }
+}
A src/main/resources/assets/fedimc/textures/block/antenna.png => src/main/resources/assets/fedimc/textures/block/antenna.png +0 -0
A src/main/resources/data/fedimc/loot_table/blocks/antenna.json => src/main/resources/data/fedimc/loot_table/blocks/antenna.json +19 -0
@@ 0,0 1,19 @@
+{
+ "type": "minecraft:block",
+ "pools": [
+ {
+ "rolls": 1,
+ "entries": [
+ {
+ "type": "minecraft:item",
+ "name": "fedimc:antenna"
+ }
+ ],
+ "conditions": [
+ {
+ "condition": "minecraft:survives_explosion"
+ }
+ ]
+ }
+ ]
+}
A src/main/resources/data/minecraft/tags/block/mineable/pickaxe.json => src/main/resources/data/minecraft/tags/block/mineable/pickaxe.json +4 -0
@@ 0,0 1,4 @@
+{
+ "replace": false,
+ "values": ["fedimc:antenna"]
+}
A src/main/resources/data/minecraft/tags/block/needs_stone_tool.json => src/main/resources/data/minecraft/tags/block/needs_stone_tool.json +4 -0
@@ 0,0 1,4 @@
+{
+ "replace": false,
+ "values": ["fedimc:antenna"]
+}
M src/main/resources/fabric.mod.json => src/main/resources/fabric.mod.json +2 -2
@@ 1,6 1,6 @@
{
"schemaVersion": 1,
- "id": "me.aleteoryx.mc.fedimc",
+ "id": "fedimc",
"version": "${version}",
"name": "FediMC",
"description": "Administrate a Fediverse instance from inside Minecraft! What could go wrong?",
@@ 12,7 12,7 @@
"sources": "https://git.amehut.dev/~aleteoryx/fedimc/"
},
"license": "0BSD",
- "icon": "assets/modid/icon.png",
+ "icon": "assets/fedimc/icon.png",
"environment": "*",
"entrypoints": {
"main": [