This repository has been archived by the owner on Jan 26, 2025. It is now read-only.
generated from FabricMC/fabric-example-mod
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
195 additions
and
27 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
common/src/main/java/top/ctnstudios/stonecraft/ItemCleanNegative.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
common/src/main/java/top/ctnstudios/stonecraft/init/BlockInit.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
common/src/main/java/top/ctnstudios/stonecraft/init/MaterialArmor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package top.ctnstudios.stonecraft.init; | ||
|
||
public enum MaterialArmor { | ||
} |
57 changes: 57 additions & 0 deletions
57
common/src/main/java/top/ctnstudios/stonecraft/init/MaterialTool.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
11
fabric/src/main/java/net/examplemod/fabric/ExampleModFabric.java
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
fabric/src/main/java/top/ctnstudios/stonecraft/MainFabric.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 3 additions & 4 deletions
7
...net/examplemod/forge/ExampleModForge.java → .../top/ctnstudios/stonecraft/MainForge.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...net/examplemod/quilt/ExampleModQuilt.java → .../top/ctnstudios/stonecraft/MainQuilt.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters