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

Commit

Permalink
yarn
Browse files Browse the repository at this point in the history
  • Loading branch information
RawDiamondMC committed Dec 13, 2023
1 parent aaa3262 commit 2b2cb4f
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 101 deletions.
17 changes: 3 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ subprojects {
}

dependencies {
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
// The following line declares the mojmap mappings, you may use other mappings as well
mappings loom.officialMojangMappings()
// The following line declares the yarn mappings you may select this one as well.
// mappings "net.fabricmc:yarn:1.20.1+build.10:v2"
minecraft "com.mojang:minecraft:$minecraft_version"
mappings "net.fabricmc:yarn:$yarn_version:v2"
}
}

Expand All @@ -35,15 +32,7 @@ allprojects {
version = rootProject.mod_version
group = rootProject.maven_group

repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
}

tasks.withType(JavaCompile) {
tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
options.release = 17
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,46 +1,45 @@
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 net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectCategory;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

import java.util.Set;

public class ItemCleanNegative extends Item {
private final Set<MobEffectInstance> effects;
private final Set<StatusEffectInstance> 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()
public ItemCleanNegative(int hunger, float saturation, StatusEffectInstance ... effects) {
super(new Item.Settings().arch$tab(MainCommon.STONE_CRAFT_TABS).food(
new FoodComponent.Builder()
.hunger(hunger)
.saturationModifier(saturation)
.alwaysEdible()
.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));
public ItemStack finishUsing(ItemStack item, World world, LivingEntity user) {
if (user instanceof PlayerEntity player) {
player.getStatusEffects().forEach((effect) -> checkAndCleanNegativeEffectInstance(player, effect.getEffectType()));
effects.forEach((effect) -> player.addStatusEffect(effect));
}

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

private void checkAndCleanNegativeEffectInstance(Player player, MobEffect effect) {
if (effect.getCategory() == MobEffectCategory.HARMFUL) {
player.removeEffect(effect);
private void checkAndCleanNegativeEffectInstance(PlayerEntity player, StatusEffect effect) {
if (effect.getCategory() == StatusEffectCategory.HARMFUL) {
player.removeStatusEffect(effect);
}
}
}
16 changes: 8 additions & 8 deletions common/src/main/java/top/ctnstudios/stonecraft/MainCommon.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import dev.architectury.registry.registries.DeferredRegister;
import dev.architectury.registry.registries.RegistrarManager;
import dev.architectury.registry.registries.RegistrySupplier;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.text.Text;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import top.ctnstudios.stonecraft.init.BlockInit;
import top.ctnstudios.stonecraft.init.ItemInit;

Expand All @@ -19,9 +19,9 @@ public class MainCommon {
public static final String MOD_ID = "stonecraft";
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> STONE_CRAFT_TABS = TABS.register("stonecraft_tab", () ->
CreativeTabRegistry.create(Component.translatable("itemGroup." + MOD_ID + ".stonecraft_tab"),
public static final DeferredRegister<ItemGroup> TABS = DeferredRegister.create(MOD_ID, RegistryKeys.ITEM_GROUP);
public static final RegistrySupplier<ItemGroup> STONE_CRAFT_TABS = TABS.register("stonecraft_tab", () ->
CreativeTabRegistry.create(Text.translatable("itemGroup." + MOD_ID + ".stonecraft_tab"),
() -> new ItemStack(Items.COBBLESTONE)));

public static void init() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

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 net.minecraft.registry.RegistryKeys;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.block.AbstractBlock;

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 DeferredRegister<Block> BLOCKS = DeferredRegister.create(MOD_ID, RegistryKeys.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));
Expand All @@ -19,6 +19,6 @@ public class BlockInit {
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));
return new Block(AbstractBlock.Settings.copy(Blocks.COBBLESTONE).strength(0.4f * lv, 1.2f * lv));
}
}
40 changes: 20 additions & 20 deletions common/src/main/java/top/ctnstudios/stonecraft/init/ItemInit.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

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 net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.registry.RegistryKeys;
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 DeferredRegister<Item> ITEMS = DeferredRegister.create(MOD_ID, RegistryKeys.ITEM);

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);
Expand All @@ -29,25 +29,25 @@ public class ItemInit {
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_MELON = ITEMS.register("stone_melon", () -> new ItemCleanNegative(4, 0.24f, new StatusEffectInstance(StatusEffects.REGENERATION,40*20,1)));
public static final RegistrySupplier<Item> STONE_KELP = ITEMS.register("stone_kelp", () -> new ItemCleanNegative(2, 0.12f, new StatusEffectInstance(StatusEffects.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)
new StatusEffectInstance(StatusEffects.RESISTANCE,160*20,1),
new StatusEffectInstance(StatusEffects.SPEED,160*20,1),
new StatusEffectInstance(StatusEffects.JUMP_BOOST,160*20,1),
new StatusEffectInstance(StatusEffects.NIGHT_VISION,160*20,1),
new StatusEffectInstance(StatusEffects.REGENERATION,160*20,1),
new StatusEffectInstance(StatusEffects.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)));
public static final RegistrySupplier<Item> LV1STONE = ITEMS.register("lv1stone", () -> new BlockItem(BlockInit.LV1STONE.get(), new Item.Settings().arch$tab(MainCommon.STONE_CRAFT_TABS)));
public static final RegistrySupplier<Item> LV2STONE = ITEMS.register("lv2stone", () -> new BlockItem(BlockInit.LV2STONE.get(), new Item.Settings().arch$tab(MainCommon.STONE_CRAFT_TABS)));
public static final RegistrySupplier<Item> LV3STONE = ITEMS.register("lv3stone", () -> new BlockItem(BlockInit.LV3STONE.get(), new Item.Settings().arch$tab(MainCommon.STONE_CRAFT_TABS)));
public static final RegistrySupplier<Item> LV4STONE = ITEMS.register("lv4stone", () -> new BlockItem(BlockInit.LV4STONE.get(), new Item.Settings().arch$tab(MainCommon.STONE_CRAFT_TABS)));
public static final RegistrySupplier<Item> LV5STONE = ITEMS.register("lv5stone", () -> new BlockItem(BlockInit.LV5STONE.get(), new Item.Settings().arch$tab(MainCommon.STONE_CRAFT_TABS)));

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

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

public enum MaterialTool implements Tier {
public enum MaterialTool implements ToolMaterial {
STONE_LV_1(175, 5.0f, 1.5f, 1, 7, ItemInit.LV1STONE.get()),
STONE_LV_2(227, 5.0f, 1.5f, 1, 7, ItemInit.LV2STONE.get()),
STONE_LV_3(1550, 6.0f, 2.5f, 1, 6, ItemInit.LV3STONE.get()),
Expand All @@ -17,9 +17,9 @@ public enum MaterialTool implements Tier {
private final float damage;
private final int lv;
private final int enchantmentValue;
private final ItemLike[] items;
private final ItemConvertible[] items;

MaterialTool(int durability, float speed, float damage, int lv, int enchantmentValue, ItemLike ... items) {
MaterialTool(int durability, float speed, float damage, int lv, int enchantmentValue, ItemConvertible ... items) {
this.durability = durability;
this.speed = speed;
this.damage = damage;
Expand All @@ -29,32 +29,32 @@ public enum MaterialTool implements Tier {
}

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

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

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

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

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

@Override
public Ingredient getRepairIngredient() {
return Ingredient.of(items);
return Ingredient.ofItems(items);
}
}
6 changes: 3 additions & 3 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ configurations {
}

dependencies {
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
modImplementation "net.fabricmc:fabric-loader:$rootProject.fabric_loader_version"
modApi "net.fabricmc.fabric-api:fabric-api:$rootProject.fabric_api_version"

modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}"
modApi "dev.architectury:architectury-fabric:$rootProject.architectury_version"

common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
Expand Down
4 changes: 2 additions & 2 deletions forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ configurations {
}

dependencies {
forge "net.minecraftforge:forge:${rootProject.forge_version}"
forge "net.minecraftforge:forge:$rootProject.forge_version"

modApi "dev.architectury:architectury-forge:${rootProject.architectury_version}"
modApi "dev.architectury:architectury-forge:$rootProject.architectury_version"

common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false }
Expand Down
14 changes: 6 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
org.gradle.jvmargs=-Xmx2048M

archives_base_name=stonecraft
minecraft_version=1.20.1
maven_group=top.ctnstudios.stonecraft
enabled_platforms=forge,fabric,quilt

archives_base_name=stonecraft
mod_version=0.3.0
maven_group=top.ctnstudios.stonecraft

architectury_version=9.1.12

fabric_loader_version=0.15.1
fabric_api_version=0.91.0+1.20.1

forge_version=1.20.1-47.2.17

quilt_loader_version=0.22.1-beta.4
yarn_version=1.20.1+build.10

fabric_api_version=0.91.0+1.20.1
quilt_fabric_api_version=7.4.0+0.90.0-1.20.1
architectury_version=9.1.12
6 changes: 3 additions & 3 deletions quilt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ configurations {
}

dependencies {
modImplementation "org.quiltmc:quilt-loader:${rootProject.quilt_loader_version}"
modApi "org.quiltmc.quilted-fabric-api:quilted-fabric-api:${rootProject.quilt_fabric_api_version}"
modImplementation "org.quiltmc:quilt-loader:$rootProject.quilt_loader_version"
modApi "org.quiltmc.quilted-fabric-api:quilted-fabric-api:$rootProject.quilt_fabric_api_version"

modApi("dev.architectury:architectury-fabric:${rootProject.architectury_version}") {
modApi("dev.architectury:architectury-fabric:$rootProject.architectury_version") {
exclude group: "net.fabricmc"
exclude group: "net.fabricmc.fabric-api"
}
Expand Down

0 comments on commit 2b2cb4f

Please sign in to comment.