summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/generated/data/funny-teleporters/advancement/recipes/transportation/coloured_chest.json32
-rw-r--r--src/main/generated/data/funny-teleporters/recipe/coloured_chest.json19
-rw-r--r--src/main/java/moe/nea/funnyteleporters/ColouredChestState.java4
-rw-r--r--src/main/java/moe/nea/funnyteleporters/FunnyDataGenerator.java13
-rw-r--r--src/main/java/moe/nea/funnyteleporters/FunnyRecipeProvider.java27
-rw-r--r--src/main/java/moe/nea/funnyteleporters/FunnyRegistry.java20
-rw-r--r--src/main/java/moe/nea/funnyteleporters/FunnyTeleporters.java5
-rw-r--r--src/main/resources/fabric.mod.json81
8 files changed, 151 insertions, 50 deletions
diff --git a/src/main/generated/data/funny-teleporters/advancement/recipes/transportation/coloured_chest.json b/src/main/generated/data/funny-teleporters/advancement/recipes/transportation/coloured_chest.json
new file mode 100644
index 0000000..ad3385a
--- /dev/null
+++ b/src/main/generated/data/funny-teleporters/advancement/recipes/transportation/coloured_chest.json
@@ -0,0 +1,32 @@
+{
+ "parent": "minecraft:recipes/root",
+ "criteria": {
+ "has_ender_chest": {
+ "conditions": {
+ "items": [
+ {
+ "items": "minecraft:ender_chest"
+ }
+ ]
+ },
+ "trigger": "minecraft:inventory_changed"
+ },
+ "has_the_recipe": {
+ "conditions": {
+ "recipe": "funny-teleporters:coloured_chest"
+ },
+ "trigger": "minecraft:recipe_unlocked"
+ }
+ },
+ "requirements": [
+ [
+ "has_the_recipe",
+ "has_ender_chest"
+ ]
+ ],
+ "rewards": {
+ "recipes": [
+ "funny-teleporters:coloured_chest"
+ ]
+ }
+} \ No newline at end of file
diff --git a/src/main/generated/data/funny-teleporters/recipe/coloured_chest.json b/src/main/generated/data/funny-teleporters/recipe/coloured_chest.json
new file mode 100644
index 0000000..a12c67e
--- /dev/null
+++ b/src/main/generated/data/funny-teleporters/recipe/coloured_chest.json
@@ -0,0 +1,19 @@
+{
+ "type": "minecraft:crafting_shapeless",
+ "category": "misc",
+ "ingredients": [
+ {
+ "item": "minecraft:ender_chest"
+ },
+ {
+ "item": "minecraft:redstone_block"
+ },
+ {
+ "item": "minecraft:hopper"
+ }
+ ],
+ "result": {
+ "count": 1,
+ "id": "funny-teleporters:coloured_chest"
+ }
+} \ No newline at end of file
diff --git a/src/main/java/moe/nea/funnyteleporters/ColouredChestState.java b/src/main/java/moe/nea/funnyteleporters/ColouredChestState.java
index 9e18b16..74f0207 100644
--- a/src/main/java/moe/nea/funnyteleporters/ColouredChestState.java
+++ b/src/main/java/moe/nea/funnyteleporters/ColouredChestState.java
@@ -22,8 +22,6 @@ import java.util.Map;
import java.util.Objects;
import java.util.StringJoiner;
-import static moe.nea.funnyteleporters.FunnyRegistry.MODID;
-
public class ColouredChestState extends PersistentState {
public Map<List<DyeColor>, DefaultedList<ItemStack>> inventories = new HashMap<>();
@@ -72,7 +70,7 @@ public class ColouredChestState extends PersistentState {
public static Type<ColouredChestState> TYPE = new Type<>(ColouredChestState::new, ColouredChestState::createFromNbt, null);
- public static Identifier identifier = Identifier.of(MODID, "coloured_chests");
+ public static Identifier identifier = FunnyTeleporters.id("coloured_chests");
public static ColouredChestState getServerState(MinecraftServer server) {
var persistentStateWorld = Objects.requireNonNull(server.getWorld(World.OVERWORLD)).getPersistentStateManager(); // Force all data saving to be done in the overworld
diff --git a/src/main/java/moe/nea/funnyteleporters/FunnyDataGenerator.java b/src/main/java/moe/nea/funnyteleporters/FunnyDataGenerator.java
new file mode 100644
index 0000000..195723e
--- /dev/null
+++ b/src/main/java/moe/nea/funnyteleporters/FunnyDataGenerator.java
@@ -0,0 +1,13 @@
+package moe.nea.funnyteleporters;
+
+import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint;
+import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
+
+public class FunnyDataGenerator implements DataGeneratorEntrypoint {
+ @Override
+ public void onInitializeDataGenerator(FabricDataGenerator dataGenerator) {
+ var pack = dataGenerator.createPack();
+ pack.addProvider(FunnyRecipeProvider::new);
+ }
+
+}
diff --git a/src/main/java/moe/nea/funnyteleporters/FunnyRecipeProvider.java b/src/main/java/moe/nea/funnyteleporters/FunnyRecipeProvider.java
new file mode 100644
index 0000000..5b7ee14
--- /dev/null
+++ b/src/main/java/moe/nea/funnyteleporters/FunnyRecipeProvider.java
@@ -0,0 +1,27 @@
+package moe.nea.funnyteleporters;
+
+import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
+import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider;
+import net.minecraft.data.server.recipe.RecipeExporter;
+import net.minecraft.data.server.recipe.ShapelessRecipeJsonBuilder;
+import net.minecraft.item.Items;
+import net.minecraft.recipe.book.RecipeCategory;
+import net.minecraft.registry.RegistryWrapper;
+
+import java.util.concurrent.CompletableFuture;
+
+public class FunnyRecipeProvider extends FabricRecipeProvider {
+
+ public FunnyRecipeProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) {
+ super(output, registriesFuture);
+ }
+
+ @Override
+ public void generate(RecipeExporter recipeExporter) {
+ ShapelessRecipeJsonBuilder.create(RecipeCategory.TRANSPORTATION, FunnyRegistry.COLOURED_CHEST)
+ .input(Items.ENDER_CHEST).input(Items.REDSTONE_BLOCK).input(Items.HOPPER)
+ .criterion(hasItem(Items.ENDER_CHEST), conditionsFromItem(Items.ENDER_CHEST))
+ .offerTo(recipeExporter);
+
+ }
+}
diff --git a/src/main/java/moe/nea/funnyteleporters/FunnyRegistry.java b/src/main/java/moe/nea/funnyteleporters/FunnyRegistry.java
index 87f2c4f..7b3e3c2 100644
--- a/src/main/java/moe/nea/funnyteleporters/FunnyRegistry.java
+++ b/src/main/java/moe/nea/funnyteleporters/FunnyRegistry.java
@@ -1,31 +1,35 @@
package moe.nea.funnyteleporters;
+import eu.pb4.polymer.core.api.block.PolymerBlockUtils;
+import eu.pb4.polymer.core.api.item.PolymerBlockItem;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
+import net.minecraft.item.Items;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;
public class FunnyRegistry {
- public static final String MODID = "funny_teleporters";
- public static Block COLOURED_CHEST = registerBlock("coloured_chest", new ColouredChestBlock(AbstractBlock.Settings.create()));
+ public static Block COLOURED_CHEST = registerBlock("coloured_chest", new ColouredChestBlock(AbstractBlock.Settings.create()), Items.RED_WOOL);
public static BlockEntityType<ColouredChestBlockEntity> COLOURED_CHEST_ENTITY = registerBlockEntity("coloured_chest", BlockEntityType.Builder.create(ColouredChestBlockEntity::new, COLOURED_CHEST));
private static <T extends BlockEntity> BlockEntityType<T> registerBlockEntity(String name, BlockEntityType.Builder<T> builder, Block... blocks) {
- return Registry.register(Registries.BLOCK_ENTITY_TYPE,
- Identifier.of(MODID, name),
- builder.build()
+ var be = Registry.register(Registries.BLOCK_ENTITY_TYPE,
+ Identifier.of(FunnyTeleporters.MOD_ID, name),
+ builder.build()
);
+ PolymerBlockUtils.registerBlockEntity(be);
+ return be;
}
- private static <T extends Block> T registerBlock(String name, T block) {
- var id = Identifier.of(MODID, name);
- Registry.register(Registries.ITEM, id, new BlockItem(block, new Item.Settings()));
+ private static <T extends Block> T registerBlock(String name, T block, Item blockItem) {
+ var id = Identifier.of(FunnyTeleporters.MOD_ID, name);
+ Registry.register(Registries.ITEM, id, new PolymerBlockItem(block, new Item.Settings(), blockItem));
return Registry.register(Registries.BLOCK, id, block);
}
diff --git a/src/main/java/moe/nea/funnyteleporters/FunnyTeleporters.java b/src/main/java/moe/nea/funnyteleporters/FunnyTeleporters.java
index eb4accb..a81c63c 100644
--- a/src/main/java/moe/nea/funnyteleporters/FunnyTeleporters.java
+++ b/src/main/java/moe/nea/funnyteleporters/FunnyTeleporters.java
@@ -2,6 +2,7 @@ package moe.nea.funnyteleporters;
import net.fabricmc.api.ModInitializer;
+import net.minecraft.util.Identifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -10,6 +11,10 @@ public class FunnyTeleporters implements ModInitializer {
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
+ public static Identifier id(String name) {
+ return Identifier.of(MOD_ID, name);
+ }
+
@Override
public void onInitialize() {
FunnyRegistry.init();
diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json
index 4f92431..14790af 100644
--- a/src/main/resources/fabric.mod.json
+++ b/src/main/resources/fabric.mod.json
@@ -1,41 +1,44 @@
{
- "schemaVersion": 1,
- "id": "funny-teleporters",
- "version": "${version}",
- "name": "Funny Teleporters",
- "description": "This is an example description! Tell everyone what your mod is about!",
- "authors": [
- "Me!"
- ],
- "contact": {
- "homepage": "https://fabricmc.net/",
- "sources": "https://github.com/FabricMC/fabric-example-mod"
- },
- "license": "CC0-1.0",
- "icon": "assets/funny-teleporters/icon.png",
- "environment": "*",
- "entrypoints": {
- "main": [
- "moe.nea.funnyteleporters.FunnyTeleporters"
- ],
- "client": [
- "moe.nea.funnyteleporters.FunnyTeleportersClient"
- ]
- },
- "mixins": [
- "funny-teleporters.mixins.json",
- {
- "config": "funny-teleporters.client.mixins.json",
- "environment": "client"
- }
- ],
- "depends": {
- "fabricloader": ">=0.16.9",
- "minecraft": "~1.21",
- "java": ">=21",
- "fabric-api": "*"
- },
- "suggests": {
- "another-mod": "*"
- }
+ "schemaVersion": 1,
+ "id": "funny-teleporters",
+ "version": "${version}",
+ "name": "Funny Teleporters",
+ "description": "This is an example description! Tell everyone what your mod is about!",
+ "authors": [
+ "Me!"
+ ],
+ "contact": {
+ "homepage": "https://fabricmc.net/",
+ "sources": "https://github.com/FabricMC/fabric-example-mod"
+ },
+ "license": "CC0-1.0",
+ "icon": "assets/funny-teleporters/icon.png",
+ "environment": "*",
+ "entrypoints": {
+ "main": [
+ "moe.nea.funnyteleporters.FunnyTeleporters"
+ ],
+ "client": [
+ "moe.nea.funnyteleporters.FunnyTeleportersClient"
+ ],
+ "fabric-datagen": [
+ "moe.nea.funnyteleporters.FunnyDataGenerator"
+ ]
+ },
+ "mixins": [
+ "funny-teleporters.mixins.json",
+ {
+ "config": "funny-teleporters.client.mixins.json",
+ "environment": "client"
+ }
+ ],
+ "depends": {
+ "fabricloader": ">=0.16.9",
+ "minecraft": "~1.21",
+ "java": ">=21",
+ "fabric-api": "*"
+ },
+ "suggests": {
+ "another-mod": "*"
+ }
} \ No newline at end of file