Skip to content
This repository has been archived by the owner on Jan 26, 2025. It is now read-only.

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
AmarokIce committed Dec 10, 2023
1 parent 4762d09 commit 5052920
Show file tree
Hide file tree
Showing 13 changed files with 195 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package top.ctnstudios.stonecraft;

import com.google.common.collect.Sets;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectCategory;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.food.FoodProperties;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import top.ctnstudios.stonecraft.MainCommon;

import java.util.Set;

public class ItemCleanNegative extends Item {
private final Set<MobEffectInstance> effects;

public ItemCleanNegative(int hunger, float saturation, MobEffectInstance ... effects) {
super(new Item.Properties().arch$tab(MainCommon.STONE_CRAFT_TABS).food(
new FoodProperties.Builder()
.nutrition(hunger)
.saturationMod(saturation)
.alwaysEat()
.build()
));

this.effects = Sets.newHashSet(effects);
}
@Override
public ItemStack finishUsingItem(ItemStack item, Level world, LivingEntity user) {
if (user instanceof Player player) {
player.getActiveEffects().forEach((effect) -> checkAndCleanNegativeEffectInstance(player, effect.getEffect()));
effects.forEach((effect) -> player.addEffect(effect));
}

return super.finishUsingItem(item, world, user);
}

private void checkAndCleanNegativeEffectInstance(Player player, MobEffect effect) {
if (effect.getCategory() == MobEffectCategory.HARMFUL) {
player.removeEffect(effect);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import top.ctnstudios.stonecraft.init.BlockInit;
import top.ctnstudios.stonecraft.init.ItemInit;

import java.util.function.Supplier;
Expand All @@ -19,14 +20,13 @@ public class MainCommon {
public static final Supplier<RegistrarManager> REGISTRIES = Suppliers.memoize(() -> RegistrarManager.get(MOD_ID));

public static final DeferredRegister<CreativeModeTab> TABS = DeferredRegister.create(MOD_ID, Registries.CREATIVE_MODE_TAB);
public static final RegistrySupplier<CreativeModeTab> EXAMPLE_TAB = TABS.register("stonecraft_tab", () ->
public static final RegistrySupplier<CreativeModeTab> STONE_CRAFT_TABS = TABS.register("stonecraft_tab", () ->
CreativeTabRegistry.create(Component.translatable("itemGroup." + MOD_ID + ".stonecraft_tab"),
() -> new ItemStack(Items.COBBLESTONE)));



public static void init() {
TABS.register();
ItemInit.ITEMS.register();
BlockInit.BLOCKS.register();
}
}
24 changes: 24 additions & 0 deletions common/src/main/java/top/ctnstudios/stonecraft/init/BlockInit.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package top.ctnstudios.stonecraft.init;

import dev.architectury.registry.registries.DeferredRegister;
import dev.architectury.registry.registries.RegistrySupplier;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockBehaviour;

import static top.ctnstudios.stonecraft.MainCommon.MOD_ID;

public class BlockInit {
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(MOD_ID, Registries.BLOCK);

public static final RegistrySupplier<Block> LV1STONE = BLOCKS.register("lv1stone", () -> BlockInit.getBlockByLV(1));
public static final RegistrySupplier<Block> LV2STONE = BLOCKS.register("lv2stone", () -> BlockInit.getBlockByLV(2));
public static final RegistrySupplier<Block> LV3STONE = BLOCKS.register("lv3stone", () -> BlockInit.getBlockByLV(3));
public static final RegistrySupplier<Block> LV4STONE = BLOCKS.register("lv4stone", () -> BlockInit.getBlockByLV(4));
public static final RegistrySupplier<Block> LV5STONE = BLOCKS.register("lv5stone", () -> BlockInit.getBlockByLV(5));

private static Block getBlockByLV(int lv) {
return new Block(BlockBehaviour.Properties.copy(Blocks.COBBLESTONE).strength(0.4f * lv, 1.2f * lv));
}
}
44 changes: 42 additions & 2 deletions common/src/main/java/top/ctnstudios/stonecraft/init/ItemInit.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,51 @@
import dev.architectury.registry.registries.DeferredRegister;
import dev.architectury.registry.registries.RegistrySupplier;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import top.ctnstudios.stonecraft.MainCommon;
import top.ctnstudios.stonecraft.ItemCleanNegative;

import static top.ctnstudios.stonecraft.MainCommon.MOD_ID;

public class ItemInit {
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(MOD_ID, Registries.ITEM);
public static final RegistrySupplier<Item> EXAMPLE_ITEM = ITEMS.register("example_item", () ->
new Item(new Item.Properties().arch$tab(MainCommon.EXAMPLE_TAB)));

public static final RegistrySupplier<Item> STONE_STAR = ITEMS.register("stone_star", ItemInit::getItemBase);
public static final RegistrySupplier<Item> HEAD_SHARD = ITEMS.register("head_shard", ItemInit::getItemBase);
public static final RegistrySupplier<Item> HEAD_DEBRIS = ITEMS.register("head_debris", ItemInit::getItemBase);
public static final RegistrySupplier<Item> STONE_KEY = ITEMS.register("stone_key", ItemInit::getItemBase);
public static final RegistrySupplier<Item> STONE_COIN = ITEMS.register("stone_coin", ItemInit::getItemBase);
public static final RegistrySupplier<Item> STONE_NUGGET = ITEMS.register("stone_nugget", ItemInit::getItemBase);
public static final RegistrySupplier<Item> RAW_STONE_ESSENCE = ITEMS.register("raw_stone_essence", ItemInit::getItemBase);
public static final RegistrySupplier<Item> STONE_ESSENCE_NUGGET = ITEMS.register("stone_essence_nugget", ItemInit::getItemBase);
public static final RegistrySupplier<Item> STONE_ESSENCE = ITEMS.register("stone_essence", ItemInit::getItemBase);
public static final RegistrySupplier<Item> ACTIVE_STONE_ESSENCE = ITEMS.register("activated_stone_essence", ItemInit::getItemBase);

public static final RegistrySupplier<Item> STONE_APPLE = ITEMS.register("stone_apple", () -> new ItemCleanNegative(4, 0.48F));
public static final RegistrySupplier<Item> STONE_BREAD = ITEMS.register("stone_bread", () -> new ItemCleanNegative(10, 1.2f));
public static final RegistrySupplier<Item> STONE_POTATO = ITEMS.register("stone_potato", () -> new ItemCleanNegative(10, 1.2f));
public static final RegistrySupplier<Item> STONE_MELON = ITEMS.register("stone_melon", () -> new ItemCleanNegative(4, 0.24f, new MobEffectInstance(MobEffects.REGENERATION,40*20,1)));
public static final RegistrySupplier<Item> STONE_KELP = ITEMS.register("stone_kelp", () -> new ItemCleanNegative(2, 0.12f, new MobEffectInstance(MobEffects.WATER_BREATHING,160*20,0)));
public static final RegistrySupplier<Item> STONE_HODGEPODGE = ITEMS.register("stone_hodgepodge",
() -> new ItemCleanNegative(30, 2.5f,
new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE,160*20,1),
new MobEffectInstance(MobEffects.MOVEMENT_SPEED,160*20,1),
new MobEffectInstance(MobEffects.JUMP,160*20,1),
new MobEffectInstance(MobEffects.NIGHT_VISION,160*20,1),
new MobEffectInstance(MobEffects.REGENERATION,160*20,1),
new MobEffectInstance(MobEffects.WATER_BREATHING,160*20,1)
));

public static final RegistrySupplier<Item> LV1STONE = ITEMS.register("lv1stone", () -> new BlockItem(BlockInit.LV1STONE.get(), new Item.Properties().arch$tab(MainCommon.STONE_CRAFT_TABS)));
public static final RegistrySupplier<Item> LV2STONE = ITEMS.register("lv2stone", () -> new BlockItem(BlockInit.LV2STONE.get(), new Item.Properties().arch$tab(MainCommon.STONE_CRAFT_TABS)));
public static final RegistrySupplier<Item> LV3STONE = ITEMS.register("lv3stone", () -> new BlockItem(BlockInit.LV3STONE.get(), new Item.Properties().arch$tab(MainCommon.STONE_CRAFT_TABS)));
public static final RegistrySupplier<Item> LV4STONE = ITEMS.register("lv4stone", () -> new BlockItem(BlockInit.LV4STONE.get(), new Item.Properties().arch$tab(MainCommon.STONE_CRAFT_TABS)));
public static final RegistrySupplier<Item> LV5STONE = ITEMS.register("lv5stone", () -> new BlockItem(BlockInit.LV5STONE.get(), new Item.Properties().arch$tab(MainCommon.STONE_CRAFT_TABS)));

private static Item getItemBase() {
return new Item(new Item.Properties().arch$tab(MainCommon.STONE_CRAFT_TABS));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package top.ctnstudios.stonecraft.init;

public enum MaterialArmor {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package top.ctnstudios.stonecraft.init;

import net.minecraft.world.item.Tier;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.ItemLike;

public enum MaterialTool implements Tier {
// TODO
STONE_LV_1(175, 5.0f, 1.5f, 1, 7)
;

private final int durability;
private final float speed;
private final float damage;
private final int lv;
private final int enchantmentValue;
private final ItemLike[] items;

MaterialTool(int durability, float speed, float damage, int lv, int enchantmentValue, ItemLike ... items) {
this.durability = durability;
this.speed = speed;
this.damage = damage;
this.lv = lv;
this.enchantmentValue = enchantmentValue;
this.items = items;
}

@Override
public int getUses() {
return durability;
}

@Override
public float getSpeed() {
return speed;
}

@Override
public float getAttackDamageBonus() {
return damage;
}

@Override
public int getLevel() {
return lv;
}

@Override
public int getEnchantmentValue() {
return enchantmentValue;
}

@Override
public Ingredient getRepairIngredient() {
return Ingredient.of(items);
}
}
11 changes: 0 additions & 11 deletions fabric/src/main/java/net/examplemod/fabric/ExampleModFabric.java

This file was deleted.

10 changes: 10 additions & 0 deletions fabric/src/main/java/top/ctnstudios/stonecraft/MainFabric.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package top.ctnstudios.stonecraft;

import net.fabricmc.api.ModInitializer;

public class MainFabric implements ModInitializer {
@Override
public void onInitialize() {
MainCommon.init();
}
}
2 changes: 1 addition & 1 deletion fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"environment": "*",
"entrypoints": {
"main": [
"net.examplemod.fabric.ExampleModFabric"
"top.ctnstudios.stonecraft.MainFabric"
]
},
"depends": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package net.examplemod.forge;
package top.ctnstudios.stonecraft;

import dev.architectury.platform.forge.EventBuses;
import top.ctnstudios.stonecraft.MainCommon;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;

@Mod(MainCommon.MOD_ID)
public class ExampleModForge {
public ExampleModForge() {
// Submit our event bus to let architectury register our content on the right time
public class MainForge {
public MainForge() {
EventBuses.registerModEventBus(MainCommon.MOD_ID, FMLJavaModLoadingContext.get().getModEventBus());
MainCommon.init();
}
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ org.gradle.jvmargs=-Xmx2048M
minecraft_version=1.20.1
enabled_platforms=quilt,fabric,forge

archives_base_name=examplemod
archives_base_name=stonecraft
mod_version=1.0.0
maven_group=net.examplemod
maven_group=top.ctnstudios.stonecraft

architectury_version=9.1.12

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package net.examplemod.quilt;
package top.ctnstudios.stonecraft;

import top.ctnstudios.stonecraft.MainCommon;
import org.quiltmc.loader.api.ModContainer;
import org.quiltmc.qsl.base.api.entrypoint.ModInitializer;

public class ExampleModQuilt implements ModInitializer {
public class MainQuilt implements ModInitializer {
@Override
public void onInitialize(ModContainer mod) {
MainCommon.init();
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ include("fabric")
include("quilt")
include("forge")

rootProject.name = "architectury-example-mod"
rootProject.name = "stone-craft-mod"

0 comments on commit 5052920

Please sign in to comment.