Caleb Bridges

Build a add on that add the sift dimension and a new ore called Slater it's dark green you mostly find it in deepslate and you can make tools with it like a shovel , a hoe , a sword , a pickaxe , and a spear.

Kodari AI
KodariNov 14 at 7:42 pm 14
SlaterDimensionAddon
Adds a new dimension called the Sift, accessible via a custom portal. Introduces a dark green ore named Slater, primarily found in deepslate layers. Slater can be smelted into ingots and used to craft a shovel, hoe, sword, pickaxe, and spear, each with unique durability and mining speed. Includes custom block, item, tool, and dimension generation logic.
  1. Add the Sift dimension with a survival-accessible Sift Key.

  2. Add deepslate Slater ore, world generation, raw Slater and ingots.

  3. Add craftable Slater shovel, hoe, sword, pickaxe and spear with textures, recipes, names and creative-tab entries.

Added the Sift Fabric mod with a separate Overworld-style Sift dimension, entered and exited using a craftable Sift Key.

  • Slater ore generates in deepslate from Y −56 to −8. Mine it with an iron-tier-or-better pickaxe to get Slater.

  • Survival crafting: use Slater and sticks to craft the shovel, hoe, sword, pickaxe, and spear. The tools can be repaired with Slater.

  • Sift Key: craft it from 4 Slater and an ender pearl; use it to travel between Sift and the Overworld.

The texture generator ran out of credits after creating the pickaxe, spear, and key textures. The ore currently uses vanilla deepslate emerald ore art, and the shovel, hoe, and sword use vanilla diamond-tool visuals.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
36 501
src/main/java/com/kodari/sift/SiftMod.java
package com.kodari.sift;

import java.util.Set;

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
import net.fabricmc.fabric.api.biome.v1.BiomeSelectors;
import net.fabricmc.fabric.api.creativetab.v1.CreativeModeTabEvents;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.Identifier;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.TagKey;
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.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ToolMaterial;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.levelgen.GenerationStep;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.portal.TeleportTransition;
import net.minecraft.world.phys.Vec3;

public class SiftMod implements ModInitializer {
	public static final String MOD_ID = "sift";
	public static final ResourceKey<Level> SIFT_DIMENSION = ResourceKey.create(
			Registries.DIMENSION,
			Identifier.fromNamespaceAndPath(MOD_ID, "sift")
	);

	private static final TagKey<Item> SLATER_REPAIR_ITEMS = TagKey.create(
			Registries.ITEM,
			id("slater_repairs")
	);
	private static final ToolMaterial SLATER_TOOL_MATERIAL = new ToolMaterial(
			BlockTags.INCORRECT_FOR_IRON_TOOL,
			720,
			7.0F,
			2.5F,
			18,
			SLATER_REPAIR_ITEMS
	);

	public static final Block DEEPSLATE_SLATER_ORE = registerBlock(
			"deepslate_slater_ore",
			BlockBehaviour.Properties.of().strength(4.5F, 3.0F).requiresCorrectToolForDrops()
	);
	public static final Item DEEPSLATE_SLATER_ORE_ITEM = registerBlockItem("deepslate_slater_ore", DEEPSLATE_SLATER_ORE);
	public static final Item SLATER = registerItem("slater", new Item(itemProperties("slater")));
	public static final Item SLATER_SHOVEL = registerItem("slater_shovel", new Item(
			itemProperties("slater_shovel").shovel(SLATER_TOOL_MATERIAL, 1.5F, -3.0F)
	));
	public static final Item SLATER_HOE = registerItem("slater_hoe", new Item(
			itemProperties("slater_hoe").hoe(SLATER_TOOL_MATERIAL, 0.0F, -3.0F)
	));
	public static final Item SLATER_SWORD = registerItem("slater_sword", new Item(
			itemProperties("slater_sword").sword(SLATER_TOOL_MATERIAL, 3.0F, -2.4F)
	));
	public static final Item SLATER_PICKAXE = registerItem("slater_pickaxe", new Item(
			itemProperties("slater_pickaxe").pickaxe(SLATER_TOOL_MATERIAL, 1.0F, -2.8F)
	));
	public static final Item SLATER_SPEAR = registerItem("slater_spear", new Item(
			itemProperties("slater_spear").spear(SLATER_TOOL_MATERIAL, 0.95F, 0.95F, 0.6F, 2.5F, 11.0F, 6.75F, 5.1F, 11.25F, 4.6F)
	));
	public static final Item SIFT_KEY = registerItem("sift_key", new SiftKey(itemProperties("sift_key")));

	private static final ResourceKey<net.minecraft.world.level.levelgen.placement.PlacedFeature> SLATER_ORE_PLACED_FEATURE = ResourceKey.create(
			Registries.PLACED_FEATURE,
			id("slater_ore")
	);

	@Override
	public void onInitialize() {
		BiomeModifications.addFeature(
				BiomeSelectors.foundInOverworld(),
				GenerationStep.Decoration.UNDERGROUND_ORES,
				SLATER_ORE_PLACED_FEATURE
		);

		CreativeModeTabEvents.modifyOutputEvent(creativeTab("tools_and_utilities")).register(output -> {
			output.prepend(SLATER_SHOVEL);
			output.prepend(SLATER_HOE);
			output.prepend(SLATER_SWORD);
			output.prepend(SLATER_PICKAXE);
			output.prepend(SLATER_SPEAR);
		});
		CreativeModeTabEvents.modifyOutputEvent(creativeTab("ingredients")).register(output -> {
			output.prepend(SLATER);
			output.prepend(SIFT_KEY);
		});
		CreativeModeTabEvents.modifyOutputEvent(creativeTab("building_blocks")).register(output -> output.prepend(DEEPSLATE_SLATER_ORE_ITEM));
	}

	private static Identifier id(String path) {
		return Identifier.fromNamespaceAndPath(MOD_ID, path);
	}

	private static ResourceKey<Item> itemKey(String path) {
		return ResourceKey.create(Registries.ITEM, id(path));
	}

	private static ResourceKey<CreativeModeTab> creativeTab(String path) {
		return ResourceKey.create(
				Registries.CREATIVE_MODE_TAB,
				Identifier.fromNamespaceAndPath("minecraft", path)
		);
	}

	private static Block registerBlock(String path, BlockBehaviour.Properties properties) {
		ResourceKey<Block> key = ResourceKey.create(Registries.BLOCK, id(path));
		return Registry.register(BuiltInRegistries.BLOCK, key, new Block(properties.setId(key)));
	}

	private static Item registerBlockItem(String path, Block block) {
		ResourceKey<Item> key = itemKey(path);
		return Registry.register(BuiltInRegistries.ITEM, key, new BlockItem(block, new Item.Properties().setId(key)));
	}

	private static Item registerItem(String path, Item item) {
		return Registry.register(BuiltInRegistries.ITEM, itemKey(path), item);
	}

	private static Item.Properties itemProperties(String path) {
		return new Item.Properties().setId(itemKey(path));
	}

	private static final class SiftKey extends Item {
		private SiftKey(Properties properties) {
			super(properties);
		}

		@Override
		public InteractionResult use(Level level, Player player, InteractionHand hand) {
			if (level.isClientSide()) {
				return InteractionResult.SUCCESS;
			}
			if (!(player instanceof ServerPlayer serverPlayer)) {
				return InteractionResult.PASS;
			}

			MinecraftServer server = level.getServer();
			if (server == null) {
				return InteractionResult.PASS;
			}

			ResourceKey<Level> targetKey = serverPlayer.level().dimension().equals(SIFT_DIMENSION)
					? Level.OVERWORLD
					: SIFT_DIMENSION;
			ServerLevel destination = server.getLevel(targetKey);
			if (destination == null) {
				return InteractionResult.PASS;
			}

			int x = (int) Math.floor(serverPlayer.getX());
			int z = (int) Math.floor(serverPlayer.getZ());
			int y = destination.getHeight(Heightmap.Types.MOTION_BLOCKING, x, z);
			Vec3 destinationPosition = new Vec3(x + 0.5, y, z + 0.5);
			serverPlayer.playSound(SoundEvents.PLAYER_TELEPORT, 1.0F, 1.0F);
			serverPlayer.teleport(new TeleportTransition(
					destination,
					destinationPosition,
					Vec3.ZERO,
					serverPlayer.getYRot(),
					serverPlayer.getXRot(),
					Set.of(),
					TeleportTransition.DO_NOTHING
			));
			return InteractionResult.SUCCESS;
		}
	}
}