Skip to content

Commit

Permalink
Cleaned up code
Browse files Browse the repository at this point in the history
Added "Item Settings" and "BlockSettings"
  • Loading branch information
Jiingy committed Jan 27, 2021
1 parent 5284cf5 commit 4de60f2
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 149 deletions.
8 changes: 4 additions & 4 deletions src/main/java/com/jingy/jineric/Jineric.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.jingy.jineric;

import com.jingy.jineric.registry.ModBlocks;
import com.jingy.jineric.registry.ModItems;
import com.jingy.jineric.registry.Blocks;
import com.jingy.jineric.registry.Items;
import net.fabricmc.api.ModInitializer;

public class Jineric implements ModInitializer {
Expand All @@ -10,7 +10,7 @@ public class Jineric implements ModInitializer {

@Override
public void onInitialize() {
ModItems.registerItems();
ModBlocks.registerBlocks();
Items.registerItems();
Blocks.registerBlocks();
}
}
29 changes: 29 additions & 0 deletions src/main/java/com/jingy/jineric/registry/BlockSettings.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.jingy.jineric.registry;

import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.Block;
import net.minecraft.block.Material;
import net.minecraft.sound.BlockSoundGroup;

public class BlockSettings {

public static Block StoneSettings() {
return new Block(FabricBlockSettings
.of(Material.STONE)
.breakByTool(FabricToolTags.PICKAXES, 0)
.requiresTool()
.strength(1.5f, 30.0f)
.sounds(BlockSoundGroup.STONE));
}

public static Block SandstoneSettings() {
return new Block(FabricBlockSettings
.of(Material.STONE)
.breakByTool(FabricToolTags.PICKAXES, 0)
.requiresTool()
.strength(0.8f, 4f)
.sounds(BlockSoundGroup.SOUL_SAND));
}

}
49 changes: 49 additions & 0 deletions src/main/java/com/jingy/jineric/registry/Blocks.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.jingy.jineric.registry;

import com.jingy.jineric.Jineric;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.Block;
import net.minecraft.block.Material;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;

public class Blocks {

//STONE BLOCKS:
public static final Block CORRITE = BlockSettings.StoneSettings();
public static final Block BORITE = BlockSettings.StoneSettings();

//SAND BLOCKS:
public static final Block WAVY_SANDSTONE = BlockSettings.SandstoneSettings();

//SOUL SAND BLOCKS:

public static final Block SOUL_SANDSTONE = BlockSettings.SandstoneSettings();
public static final Block CUT_SOUL_SANDSTONE = BlockSettings.SandstoneSettings();
public static final Block CHISELED_SOUL_SANDSTONE = BlockSettings.SandstoneSettings();
public static final Block WAVY_SOUL_SANDSTONE = BlockSettings.SandstoneSettings();
public static final Block SMOOTH_SOUL_SANDSTONE = BlockSettings.SandstoneSettings();

public static void registerBlocks() {

//STONES:

//Corrite:
Registry.register(Registry.BLOCK, new Identifier(Jineric.MOD_ID, "corrite"), CORRITE);

//Borite:
Registry.register(Registry.BLOCK, new Identifier(Jineric.MOD_ID, "borite"), BORITE);

//SANDSTONES:
Registry.register(Registry.BLOCK, new Identifier(Jineric.MOD_ID, "wavy_sandstone"), WAVY_SANDSTONE);

//SOUL SANDSTONE:
Registry.register(Registry.BLOCK, new Identifier(Jineric.MOD_ID, "cut_soul_sandstone"), CUT_SOUL_SANDSTONE);
Registry.register(Registry.BLOCK, new Identifier(Jineric.MOD_ID, "chiseled_soul_sandstone"), CHISELED_SOUL_SANDSTONE);
Registry.register(Registry.BLOCK, new Identifier(Jineric.MOD_ID, "wavy_soul_sandstone"), WAVY_SOUL_SANDSTONE);
Registry.register(Registry.BLOCK, new Identifier(Jineric.MOD_ID, "smooth_soul_sandstone"), SMOOTH_SOUL_SANDSTONE);
Registry.register(Registry.BLOCK, new Identifier(Jineric.MOD_ID, "soul_sandstone"), SOUL_SANDSTONE);
}
}
17 changes: 17 additions & 0 deletions src/main/java/com/jingy/jineric/registry/ItemSettings.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.jingy.jineric.registry;

import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;

public class ItemSettings {
public static Item.Settings BuildingBlocks() {
return new Item.Settings().group(ItemGroup.BUILDING_BLOCKS);
}

public static Item.Settings Misc() {
return new Item.Settings().group(ItemGroup.MISC);
}
public static Item.Settings Decoration() {
return new Item.Settings().group(ItemGroup.DECORATIONS);
}
}
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
package com.jingy.jineric.registry;

import com.jingy.jineric.Jineric;
import net.minecraft.item.BlockItem;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;

public class ModItems {

//ITEMS:

//FOODS:
public static final Item GOLDEN_POTATO = new Item(
new Item.Settings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(6).saturationModifier(14.4f).build()));

public static final Item GOLDEN_SWEET_BERRIES = new Item(
new Item.Settings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(5).saturationModifier(8f).build()));

public static final Item GOLDEN_BEETROOT = new Item(
new Item.Settings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(4).saturationModifier(5f).build()));

//BLOCK ITEMS:
public static final BlockItem CORRITE = new BlockItem(ModBlocks.CORRITE, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS));
public static final BlockItem BORITE = new BlockItem(ModBlocks.BORITE, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS));
public static final BlockItem WAVY_SANDSTONE = new BlockItem(ModBlocks.WAVY_SANDSTONE, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS));
public static final BlockItem SOUL_SANDSTONE = new BlockItem(ModBlocks.SOUL_SANDSTONE, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS));
public static final BlockItem CUT_SOUL_SANDSTONE = new BlockItem(ModBlocks.CUT_SOUL_SANDSTONE, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS));
public static final BlockItem CHISELED_SOUL_SANDSTONE = new BlockItem(ModBlocks.CHISELED_SOUL_SANDSTONE, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS));
public static final BlockItem WAVY_SOUL_SANDSTONE = new BlockItem(ModBlocks.WAVY_SOUL_SANDSTONE, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS));
public static final BlockItem SMOOTH_SOUL_SANDSTONE = new BlockItem(ModBlocks.SMOOTH_SOUL_SANDSTONE, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS));

public static void registerItems() {
///ITEMS:
Registry.register(Registry.ITEM, new Identifier(Jineric.MOD_ID, "golden_potato"), GOLDEN_POTATO);
Registry.register(Registry.ITEM, new Identifier(Jineric.MOD_ID, "golden_sweet_berries"), GOLDEN_SWEET_BERRIES);
Registry.register(Registry.ITEM, new Identifier(Jineric.MOD_ID, "golden_beetroot"), GOLDEN_BEETROOT);

//BLOCKS:
Registry.register(Registry.ITEM, new Identifier(Jineric.MOD_ID, "corrite"), CORRITE);
Registry.register(Registry.ITEM, new Identifier(Jineric.MOD_ID, "borite"), BORITE);
Registry.register(Registry.ITEM, new Identifier(Jineric.MOD_ID, "wavy_sandstone"), WAVY_SANDSTONE);
Registry.register(Registry.ITEM, new Identifier(Jineric.MOD_ID, "soul_sandstone"), SOUL_SANDSTONE);
Registry.register(Registry.ITEM, new Identifier(Jineric.MOD_ID, "cut_soul_sandstone"), CUT_SOUL_SANDSTONE);
Registry.register(Registry.ITEM, new Identifier(Jineric.MOD_ID, "chiseled_soul_sandstone"), CHISELED_SOUL_SANDSTONE);
Registry.register(Registry.ITEM, new Identifier(Jineric.MOD_ID, "wavy_soul_sandstone"), WAVY_SOUL_SANDSTONE);
Registry.register(Registry.ITEM, new Identifier(Jineric.MOD_ID, "smooth_soul_sandstone"), SMOOTH_SOUL_SANDSTONE);
}

}
package com.jingy.jineric.registry;

import com.jingy.jineric.Jineric;
import net.minecraft.item.BlockItem;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;

public class Items {

//FOODS:
public static final Item GOLDEN_POTATO = new Item(
new Item.Settings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(6).saturationModifier(14.4f).build()));

public static final Item GOLDEN_SWEET_BERRIES = new Item(
new Item.Settings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(5).saturationModifier(8f).build()));

public static final Item GOLDEN_BEETROOT = new Item(
new Item.Settings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(4).saturationModifier(5f).build()));



//BLOCK ITEMS:
public static final BlockItem CORRITE = new BlockItem(Blocks.CORRITE, ItemSettings.BuildingBlocks());
public static final BlockItem BORITE = new BlockItem(Blocks.BORITE, ItemSettings.BuildingBlocks());
public static final BlockItem WAVY_SANDSTONE = new BlockItem(Blocks.WAVY_SANDSTONE, ItemSettings.BuildingBlocks());
public static final BlockItem SOUL_SANDSTONE = new BlockItem(Blocks.SOUL_SANDSTONE, ItemSettings.BuildingBlocks());
public static final BlockItem CUT_SOUL_SANDSTONE = new BlockItem(Blocks.CUT_SOUL_SANDSTONE, ItemSettings.BuildingBlocks());
public static final BlockItem CHISELED_SOUL_SANDSTONE = new BlockItem(Blocks.CHISELED_SOUL_SANDSTONE, ItemSettings.BuildingBlocks());
public static final BlockItem WAVY_SOUL_SANDSTONE = new BlockItem(Blocks.WAVY_SOUL_SANDSTONE, ItemSettings.BuildingBlocks());
public static final BlockItem SMOOTH_SOUL_SANDSTONE = new BlockItem(Blocks.SMOOTH_SOUL_SANDSTONE, ItemSettings.BuildingBlocks());


public static void registerItems() {
//ITEMS:
Registry.register(Registry.ITEM, new Identifier(Jineric.MOD_ID, "golden_potato"), GOLDEN_POTATO);
Registry.register(Registry.ITEM, new Identifier(Jineric.MOD_ID, "golden_sweet_berries"), GOLDEN_SWEET_BERRIES);
Registry.register(Registry.ITEM, new Identifier(Jineric.MOD_ID, "golden_beetroot"), GOLDEN_BEETROOT);

//BLOCKS:
Registry.register(Registry.ITEM, new Identifier(Jineric.MOD_ID, "corrite"), CORRITE);
Registry.register(Registry.ITEM, new Identifier(Jineric.MOD_ID, "borite"), BORITE);
Registry.register(Registry.ITEM, new Identifier(Jineric.MOD_ID, "wavy_sandstone"), WAVY_SANDSTONE);
Registry.register(Registry.ITEM, new Identifier(Jineric.MOD_ID, "soul_sandstone"), SOUL_SANDSTONE);
Registry.register(Registry.ITEM, new Identifier(Jineric.MOD_ID, "cut_soul_sandstone"), CUT_SOUL_SANDSTONE);
Registry.register(Registry.ITEM, new Identifier(Jineric.MOD_ID, "chiseled_soul_sandstone"), CHISELED_SOUL_SANDSTONE);
Registry.register(Registry.ITEM, new Identifier(Jineric.MOD_ID, "wavy_soul_sandstone"), WAVY_SOUL_SANDSTONE);
Registry.register(Registry.ITEM, new Identifier(Jineric.MOD_ID, "smooth_soul_sandstone"), SMOOTH_SOUL_SANDSTONE);
}
}
91 changes: 0 additions & 91 deletions src/main/java/com/jingy/jineric/registry/ModBlocks.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"entries": [
{
"type": "minecraft:item",
"name": "jineric:borite",
"name": "jineric:borite"
}
],
"conditions": [
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"sources": "https://github.com/Jiingy/Jineric-Mod"
},

"license": "CC0-1.0",
"license": "MIT",
"icon": "assets/jineric/icon.png",

"environment": "*",
Expand Down

0 comments on commit 4de60f2

Please sign in to comment.